mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2026-02-23 15:44:21 +01:00
Added support for Android Wear 2.0 and wear synchronization in China
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "no.nordicsemi.android.nrftoolbox"
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 25
|
||||
versionCode 56
|
||||
versionName "2.2.1"
|
||||
versionCode 57
|
||||
versionName "2.2.2"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
@@ -19,8 +19,8 @@ android {
|
||||
}
|
||||
productFlavors {
|
||||
fastBuild {
|
||||
// Switching the flavor to fastBuild accelerates te build speed (works only with Android 5+ devices)
|
||||
minSdkVersion 21
|
||||
// Switching the flavor to fastBuild accelerates te build speed (works only with Android 7+ devices)
|
||||
minSdkVersion 25
|
||||
versionName "Instant Run"
|
||||
}
|
||||
releaseBuild {
|
||||
@@ -31,7 +31,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.google.android.gms:play-services-wearable:9.2.0'
|
||||
compile 'com.android.support:appcompat-v7:25.0.1'
|
||||
compile 'com.android.support:design:25.0.1'
|
||||
compile 'no.nordicsemi.android.support.v18:scanner:1.0.0'
|
||||
@@ -42,10 +41,12 @@ dependencies {
|
||||
}
|
||||
compile files('libs/achartengine-1.1.0.jar')
|
||||
compile project(':common')
|
||||
wearApp project(':wear')
|
||||
wearApp project(path: ':wear', configuration: 'wear1Release')
|
||||
// nRF Toolbox is using Play Service 7.8.87 in order to make the app working in China:
|
||||
// https://developer.android.com/training/wearables/apps/creating-app-china.html#ChinaSDK
|
||||
compile 'com.google.android.gms:play-services-wearable:7.8.87'
|
||||
|
||||
// The DFU Library is imported automatically from jcenter.
|
||||
compile 'no.nordicsemi.android:dfu:1.1.1'
|
||||
compile 'no.nordicsemi.android:dfu:1.2.0'
|
||||
// If you want to make some changes in the DFU Library, clone the https://github.com/NordicSemiconductor/Android-DFU-Library project into DFULibrary folder,
|
||||
// add it as a module in Project Structure and uncomment the following line:
|
||||
|
||||
@@ -183,6 +183,10 @@ public class UARTActivity extends BleProfileServiceReadyActivity<UARTService.UAR
|
||||
*/
|
||||
@Override
|
||||
public void onConnected(final Bundle bundle) {
|
||||
// Ensure the Wearable API was connected
|
||||
if (!mWearableSynchronizer.hasConnectedApi())
|
||||
return;
|
||||
|
||||
if (!mPreferences.getBoolean(PREFS_WEAR_SYNCED, false)) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -67,7 +67,7 @@ public class UARTConfigurationSynchronizer {
|
||||
return;
|
||||
|
||||
mGoogleApiClient = new GoogleApiClient.Builder(context)
|
||||
.addApi(Wearable.API)
|
||||
.addApiIfAvailable(Wearable.API)
|
||||
.addConnectionCallbacks(listener)
|
||||
.build();
|
||||
mGoogleApiClient.connect();
|
||||
@@ -82,13 +82,20 @@ public class UARTConfigurationSynchronizer {
|
||||
mGoogleApiClient = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if Wearable API has been connected.
|
||||
*/
|
||||
public boolean hasConnectedApi() {
|
||||
return mGoogleApiClient != null && mGoogleApiClient.isConnected() && mGoogleApiClient.hasConnectedApi(Wearable.API);
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronizes the UART configurations between handheld and wearables.
|
||||
* Call this when configuration has been created or altered.
|
||||
* @return pending result
|
||||
*/
|
||||
public PendingResult<DataApi.DataItemResult> onConfigurationAddedOrEdited(final long id, final UartConfiguration configuration) {
|
||||
if (mGoogleApiClient == null || !mGoogleApiClient.isConnected())
|
||||
if (!hasConnectedApi())
|
||||
return null;
|
||||
|
||||
final PutDataMapRequest mapRequest = PutDataMapRequest.create(Constants.UART.CONFIGURATIONS + "/" + id);
|
||||
@@ -115,7 +122,7 @@ public class UARTConfigurationSynchronizer {
|
||||
* @return pending result
|
||||
*/
|
||||
public PendingResult<DataApi.DeleteDataItemsResult> onConfigurationDeleted(final long id) {
|
||||
if (mGoogleApiClient == null || !mGoogleApiClient.isConnected())
|
||||
if (!hasConnectedApi())
|
||||
return null;
|
||||
return Wearable.DataApi.deleteDataItems(mGoogleApiClient, id2Uri(id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user