merge with staging/master
This commit is contained in:
Коммит
760dc4125c
|
@ -2,15 +2,18 @@ apply plugin: 'com.android.application'
|
|||
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
url "http://dl.bintray.com/project-rome/maven"
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "25.0.0"
|
||||
defaultConfig {
|
||||
applicationId "com.microsoft.romanapp"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 22
|
||||
targetSdkVersion 23
|
||||
versionCode 3
|
||||
versionName "beta1.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
@ -44,10 +47,10 @@ dependencies {
|
|||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
compile 'com.android.support:appcompat-v7:22.2.0'
|
||||
compile 'com.android.support:design:22.2.0'
|
||||
compile 'com.android.support:cardview-v7:22.0.0'
|
||||
compile 'com.android.support:recyclerview-v7:22.0.0'
|
||||
compile(group: 'com.microsoft.connecteddevices', name: 'connecteddevices-sdk-armv7', version: '0.2.0', ext: 'aar', classifier: 'release')
|
||||
compile 'com.android.support:appcompat-v7:23.2.0'
|
||||
compile 'com.android.support:design:23.2.0'
|
||||
compile 'com.android.support:cardview-v7:23.2.0'
|
||||
compile 'com.android.support:recyclerview-v7:23.2.0'
|
||||
compile(group: 'com.microsoft.connecteddevices', name: 'connecteddevices-sdk-armv7', version: '0.3.0', ext: 'aar', classifier: 'release')
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
package="com.microsoft.romanapp">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
|
|
@ -22,7 +22,7 @@ import android.widget.Button;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.microsoft.connecteddevices.AppServiceClientClosedStatus;
|
||||
import com.microsoft.connecteddevices.AppServiceClientConnectionClosedStatus;
|
||||
import com.microsoft.connecteddevices.AppServiceClientConnection;
|
||||
import com.microsoft.connecteddevices.AppServiceClientConnectionStatus;
|
||||
import com.microsoft.connecteddevices.AppServiceClientResponse;
|
||||
|
@ -41,10 +41,10 @@ import static com.microsoft.connecteddevices.RemoteLaunchUriStatus.SUCCESS;
|
|||
|
||||
public class DeviceActivity extends Activity implements AdapterView.OnItemSelectedListener {
|
||||
private static final String TAG = DeviceActivity.class.getName();
|
||||
private static final String URL = "https://www.bing.com";
|
||||
|
||||
private static final String APP_SERVICE = Secrets.APP_SERVICE;
|
||||
private static final String APP_IDENTIFIER = Secrets.APP_IDENTIFIER;
|
||||
private static final String APP_SERVICE = ""; // Fill in your app service name
|
||||
private static final String APP_IDENTIFIER = ""; // Fill in your app identifier
|
||||
|
||||
private static final String DATE_FORMAT = "MM/dd/yyyy HH:mm:ss";
|
||||
private static final String TIME_STAMP_FORMAT = "HH:mm:ss.SSS";
|
||||
|
||||
|
@ -292,7 +292,7 @@ public class DeviceActivity extends Activity implements AdapterView.OnItemSelect
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(AppServiceClientClosedStatus status) {
|
||||
public void onClosed(AppServiceClientConnectionClosedStatus status) {
|
||||
Log.i(TAG, "AppServiceClientConnectionListener onClosed status [" + status.toString()+"]");
|
||||
logMessage("AppService connection closed");
|
||||
_sendPingButton.setEnabled(false);
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.microsoft.connecteddevices.RemoteSystem;
|
|||
import com.microsoft.connecteddevices.RemoteSystemDiscovery;
|
||||
import com.microsoft.connecteddevices.RemoteSystemDiscoveryType;
|
||||
import com.microsoft.connecteddevices.RemoteSystemDiscoveryTypeFilter;
|
||||
import com.microsoft.connecteddevices.RemoteSystemKind;
|
||||
import com.microsoft.connecteddevices.RemoteSystemKinds;
|
||||
import com.microsoft.connecteddevices.RemoteSystemKindFilter;
|
||||
|
||||
public class DeviceRecyclerActivity extends AppCompatActivity {
|
||||
|
@ -208,6 +208,10 @@ public class DeviceRecyclerActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void onRemoteSystemRemoved(String remoteSystemId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
}).filter(generateDiscoveryTypeFilter()).filter(generateSystemKindFilter());
|
||||
|
||||
startDiscovery();
|
||||
|
@ -231,30 +235,30 @@ public class DeviceRecyclerActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private RemoteSystemKindFilter generateSystemKindFilter() {
|
||||
ArrayList<RemoteSystemKind> kinds = new ArrayList<>(Arrays.asList(RemoteSystemKind.UNKNOWN));
|
||||
ArrayList<RemoteSystemKinds> kinds = new ArrayList<>(Arrays.asList(RemoteSystemKinds.UNKNOWN));
|
||||
|
||||
switch (_systemKind) {
|
||||
case ALL:
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKind.UNKNOWN,
|
||||
RemoteSystemKind.DESKTOP,
|
||||
RemoteSystemKind.HOLOGRAPHIC,
|
||||
RemoteSystemKind.PHONE,
|
||||
RemoteSystemKind.XBOX));
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKinds.UNKNOWN,
|
||||
RemoteSystemKinds.DESKTOP,
|
||||
RemoteSystemKinds.HOLOGRAPHIC,
|
||||
RemoteSystemKinds.PHONE,
|
||||
RemoteSystemKinds.XBOX));
|
||||
break;
|
||||
case UNKNOWN:
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKind.UNKNOWN));
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKinds.UNKNOWN));
|
||||
break;
|
||||
case DESKTOP:
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKind.DESKTOP));
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKinds.DESKTOP));
|
||||
break;
|
||||
case HOLOGRAPHIC:
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKind.HOLOGRAPHIC));
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKinds.HOLOGRAPHIC));
|
||||
break;
|
||||
case PHONE:
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKind.PHONE));
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKinds.PHONE));
|
||||
break;
|
||||
case XBOX:
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKind.XBOX));
|
||||
kinds = new ArrayList<>(Arrays.asList(RemoteSystemKinds.XBOX));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,17 @@
|
|||
|
||||
package com.microsoft.romanapp;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
|
@ -25,10 +29,13 @@ import com.microsoft.connecteddevices.IPlatformInitializationHandler;
|
|||
import com.microsoft.connecteddevices.Platform;
|
||||
import com.microsoft.connecteddevices.PlatformInitializationStatus;
|
||||
|
||||
public class MainActivity extends FragmentActivity {
|
||||
// Use your own Client ID, assigned when your app was registered with MSA.
|
||||
private static String CLIENT_ID = Secrets.CLIENT_ID;
|
||||
import java.util.Random;
|
||||
|
||||
public class MainActivity extends FragmentActivity implements ActivityCompat.OnRequestPermissionsResultCallback {
|
||||
// Use your own Client ID, assigned when your app was registered with MSA.
|
||||
private static String CLIENT_ID = ""; //get a client ID from https://apps.dev.microsoft.com/
|
||||
|
||||
private int _permissionRequestCode = -1;
|
||||
private TextView _statusOutput;
|
||||
private Button _signInButton;
|
||||
private String _oauthUrl;
|
||||
|
@ -53,51 +60,16 @@ public class MainActivity extends FragmentActivity {
|
|||
_web.getSettings().setJavaScriptEnabled(true);
|
||||
_web.getSettings().setDomStorageEnabled(true);
|
||||
|
||||
appendStatus("Initializing Platform");
|
||||
appendStatus("Platform will attempt to use previously saved refresh token");
|
||||
Platform.initialize(getApplicationContext(), new IAuthCodeProvider() {
|
||||
@Override
|
||||
/**
|
||||
* ConnectedDevices Platform needs the app to fetch a MSA auth_code using the given oauthUrl.
|
||||
* When app is fetched the auth_code, it needs to invoke the authCodeHandler onAuthCodeFetched method.
|
||||
*/
|
||||
public void fetchAuthCodeAsync(String oauthUrl, Platform.IAuthCodeHandler handler) {
|
||||
_oauthUrl = oauthUrl;
|
||||
_authCodeHandler = handler;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
_signInButton.setVisibility(View.VISIBLE);
|
||||
_signInButton.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* ConnectedDevices Platform needs your app's registered client ID.
|
||||
*/
|
||||
public String getClientId() {
|
||||
return CLIENT_ID;
|
||||
}
|
||||
}, new IPlatformInitializationHandler() {
|
||||
|
||||
@Override
|
||||
public void onDone() {
|
||||
Log.i(TAG, "Initialized platform successfully");
|
||||
Intent intent = new Intent(MainActivity.this, DeviceRecyclerActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(PlatformInitializationStatus status) {
|
||||
if (status == PlatformInitializationStatus.PLATFORM_FAILURE) {
|
||||
Log.e(TAG, "Error initializing platform");
|
||||
} else if (status == PlatformInitializationStatus.TOKEN_ERROR) {
|
||||
Log.e(TAG, "Error refreshing tokens");
|
||||
}
|
||||
}
|
||||
});
|
||||
appendStatus("Checking BT permission");
|
||||
Random rng = new Random();
|
||||
_permissionRequestCode = rng.nextInt(128);
|
||||
int permissionCheck = ContextCompat.checkSelfPermission(this.getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
if (permissionCheck == PackageManager.PERMISSION_DENIED) {
|
||||
ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION}, _permissionRequestCode);
|
||||
// InitializePlatform will be later invoked from onRequestPermissionsResult
|
||||
} else {
|
||||
InitializePlatform();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -168,6 +140,17 @@ public class MainActivity extends FragmentActivity {
|
|||
_authDialog.setCancelable(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
if (requestCode == _permissionRequestCode) {
|
||||
// Platform handles if no permission granted for bluetooth, no need to do anything special.
|
||||
InitializePlatform();
|
||||
_permissionRequestCode = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private void appendStatus(final String status) {
|
||||
if (_statusOutput == null) {
|
||||
Log.e(TAG, "StatusOutput field is null");
|
||||
|
@ -183,4 +166,57 @@ public class MainActivity extends FragmentActivity {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void InitializePlatform() {
|
||||
this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
appendStatus("Initializing Platform");
|
||||
appendStatus("Platform will attempt to use previously saved refresh token");
|
||||
|
||||
Platform.initialize(getApplicationContext(), new IAuthCodeProvider() {
|
||||
@Override
|
||||
/**
|
||||
* ConnectedDevices Platform needs the app to fetch a MSA auth_code using the given oauthUrl.
|
||||
* When app is fetched the auth_code, it needs to invoke the authCodeHandler onAuthCodeFetched method.
|
||||
*/
|
||||
public void fetchAuthCodeAsync(String oauthUrl, Platform.IAuthCodeHandler handler) {
|
||||
_oauthUrl = oauthUrl;
|
||||
_authCodeHandler = handler;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
_signInButton.setVisibility(View.VISIBLE);
|
||||
_signInButton.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* ConnectedDevices Platform needs your app's registered client ID.
|
||||
*/
|
||||
public String getClientId() {
|
||||
return CLIENT_ID;
|
||||
}
|
||||
}, new IPlatformInitializationHandler() {
|
||||
@Override
|
||||
public void onDone() {
|
||||
Log.i(TAG, "Initialized platform successfully");
|
||||
Intent intent = new Intent(MainActivity.this, DeviceRecyclerActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(PlatformInitializationStatus status) {
|
||||
if (status == PlatformInitializationStatus.PLATFORM_FAILURE) {
|
||||
Log.e(TAG, "Error initializing platform");
|
||||
} else if (status == PlatformInitializationStatus.TOKEN_ERROR) {
|
||||
Log.e(TAG, "Error refreshing tokens");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,8 @@
|
|||
android:id="@+id/launch_uri_button_layout">
|
||||
|
||||
<EditText
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text"
|
||||
android:text="http://bing.com"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<resources>
|
||||
<string name="app_name">RomanApp</string>
|
||||
<string-array name="uri_array">
|
||||
<item>ms-windows-store://pdp/?productid=9NBLGGH4NNQJ</item>
|
||||
<item>http://microsoft.com</item>
|
||||
<item>http://bing.com</item>
|
||||
<item>http://xbox.com</item>
|
||||
|
|
|
@ -40,3 +40,4 @@ See [Microsoft's privacy statement](https://privacy.microsoft.com/en-us/privacys
|
|||
## Microsoft Open Source Code of Conduct
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
# pr
|
||||
|
|
|
@ -57,6 +57,10 @@
|
|||
<Reference Include="ConnectedDevices.Xamarin.Droid.Core">
|
||||
<HintPath>..\..\..\src\ConnectedDevices.Xamarin.Droid.Core\bin\Release\ConnectedDevices.Xamarin.Droid.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ConnectedDevices.Xamarin.Droid, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ConnectedDevices.Xamarin.Droid.0.3.0\lib\MonoAndroid71\Microsoft.ConnectedDevices.Xamarin.Droid.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
|
@ -72,6 +76,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="GettingStarted.Xamarin" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
<None Include="Assets\AboutAssets.txt" />
|
||||
<AndroidResource Include="Resources\layout\RemoteSystemView.axml" />
|
||||
|
|
|
@ -25,8 +25,7 @@ namespace ConnectedDevices.Xamarin.Droid.Sample
|
|||
public class MainActivity : ListActivity
|
||||
{
|
||||
// Use your own client id
|
||||
//private const string CLIENT_ID = ""; //get a client ID from https://apps.dev.microsoft.com/
|
||||
|
||||
// private const string CLIENT_ID = ""; //get a client ID from https://apps.dev.microsoft.com/
|
||||
|
||||
private WebView _webView;
|
||||
internal Dialog _authDialog;
|
||||
|
@ -147,14 +146,14 @@ namespace ConnectedDevices.Xamarin.Droid.Sample
|
|||
}
|
||||
public class RemoteSystemAdapter : ArrayAdapter<RemoteSystem>
|
||||
{
|
||||
private static readonly Dictionary<RemoteSystemKind, int> RemoteSystemKindImages = new Dictionary<RemoteSystemKind, int>
|
||||
private static readonly Dictionary<RemoteSystemKinds, int> RemoteSystemKindImages = new Dictionary<RemoteSystemKinds, int>
|
||||
{
|
||||
{ RemoteSystemKind.Desktop, Resource.Drawable.Desktop },
|
||||
{ RemoteSystemKind.Phone, Resource.Drawable.Phone },
|
||||
{ RemoteSystemKind.Xbox, Resource.Drawable.Xbox },
|
||||
{ RemoteSystemKind.Holographic, Resource.Drawable.Hololens },
|
||||
{ RemoteSystemKind.Hub, Resource.Drawable.SurfaceHub },
|
||||
{ RemoteSystemKind.Unknown, Resource.Drawable.Unknown}
|
||||
{ RemoteSystemKinds.Desktop, Resource.Drawable.Desktop },
|
||||
{ RemoteSystemKinds.Phone, Resource.Drawable.Phone },
|
||||
{ RemoteSystemKinds.Xbox, Resource.Drawable.Xbox },
|
||||
{ RemoteSystemKinds.Holographic, Resource.Drawable.Hololens },
|
||||
{ RemoteSystemKinds.Hub, Resource.Drawable.SurfaceHub },
|
||||
{ RemoteSystemKinds.Unknown, Resource.Drawable.Unknown}
|
||||
};
|
||||
|
||||
public List<RemoteSystem> Items { get; }
|
||||
|
@ -175,7 +174,7 @@ namespace ConnectedDevices.Xamarin.Droid.Sample
|
|||
view = context.LayoutInflater.Inflate(Resource.Layout.RemoteSystemView, null);
|
||||
view.FindViewById<TextView>(Resource.Id.Text1).Text = item.DisplayName;
|
||||
view.FindViewById<TextView>(Resource.Id.Text2).Text = item.IsAvailableByProximity ? "Proximal" : "Cloud";
|
||||
int id = RemoteSystemKindImages.ContainsKey(item.Kind) ? RemoteSystemKindImages[item.Kind] : RemoteSystemKindImages[RemoteSystemKind.Unknown];
|
||||
int id = RemoteSystemKindImages.ContainsKey(item.Kind) ? RemoteSystemKindImages[item.Kind] : RemoteSystemKindImages[RemoteSystemKinds.Unknown];
|
||||
view.FindViewById<ImageView>(Resource.Id.Image).SetImageResource(id);
|
||||
|
||||
return view;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.ConnectedDevices.Xamarin.Droid" version="0.3.0" targetFramework="monoandroid71" />
|
||||
</packages>
|
|
@ -25,5 +25,5 @@ using Android.App;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.2.2.0")]
|
||||
[assembly: AssemblyFileVersion("0.2.2.0")]
|
||||
[assembly: AssemblyVersion("0.3.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.3.0.0")]
|
Загрузка…
Ссылка в новой задаче