diff --git a/app/app.iml b/app/app.iml index a4d4a813..8b30910a 100644 --- a/app/app.iml +++ b/app/app.iml @@ -69,6 +69,8 @@ + + @@ -89,10 +91,10 @@ - - + - + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 50805557..3abb9f5f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "no.nordicsemi.android.nrftoolbox" minSdkVersion 18 targetSdkVersion 22 - versionCode 34 - versionName "1.14.1" + versionCode 35 + versionName "1.14.2" } buildTypes { release { @@ -20,7 +20,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.2.0' + compile 'com.android.support:appcompat-v7:22.2.1' compile 'com.android.support:design:22.2.0' compile project(':dfu') compile files('libs/achartengine-1.1.0.jar') diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b2f600e7..5805dcfb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,8 +23,8 @@ + android:versionCode="35" + android:versionName="1.14.2" > 1) + mTextUploading.setText(getString(R.string.dfu_status_uploading_part, currentPart, partsTotal)); + else + mTextUploading.setText(R.string.dfu_status_uploading); + } + + @Override + public void onError(final String deviceAddress, final int error, final int errorType, final String message) { + showErrorMessage(message); + + // We have to wait a bit before canceling notification. This is called before DfuService creates the last notification. + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + // if this activity is still open and upload process was completed, cancel the notification + final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + manager.cancel(DfuService.NOTIFICATION_ID); + } + }, 200); } }; @@ -231,25 +293,14 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks 1) - mTextUploading.setText(getString(R.string.dfu_status_uploading_part, part, total)); - else - mTextUploading.setText(R.string.dfu_status_uploading); - } - break; - } - } - private void showProgressBar() { mProgressBar.setVisibility(View.VISIBLE); mTextPercentage.setVisibility(View.VISIBLE); @@ -884,12 +867,9 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks { /** * Disconnects from the device. Does nothing if not connected. + * @return true if device is to be disconnected. False if it was already disconnected. */ - public void disconnect() { + public boolean disconnect() { mUserDisconnected = true; if (mConnected && mBluetoothGatt != null) { Logger.v(mLogSession, "Disconnecting..."); + mCallbacks.onDeviceDisconnecting(); Logger.d(mLogSession, "gatt.disconnect()"); mBluetoothGatt.disconnect(); + return true; } + return false; } /** @@ -618,7 +622,7 @@ public abstract class BleManager { @Override public final void onConnectionStateChange(final BluetoothGatt gatt, final int status, final int newState) { - Logger.v(mLogSession, "[Callback] Connection state changed with status: " + status + " and new state: " + newState + " (" + stateToString(newState) + ")"); + Logger.d(mLogSession, "[Callback] Connection state changed with status: " + status + " and new state: " + newState + " (" + stateToString(newState) + ")"); if (status == BluetoothGatt.GATT_SUCCESS && newState == BluetoothProfile.STATE_CONNECTED) { // Notify the parent activity/service diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManagerCallbacks.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManagerCallbacks.java index e2400ef5..c7c4b65e 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManagerCallbacks.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManagerCallbacks.java @@ -33,7 +33,7 @@ public interface BleManagerCallbacks { public void onDeviceConnected(); /** - * Called when user pressed the DISCONNECT button. + * Called when user initialized disconnection. */ public void onDeviceDisconnecting(); @@ -43,8 +43,8 @@ public interface BleManagerCallbacks { public void onDeviceDisconnected(); /** - * Some profiles may use this method to notify user that the link was lost. You must call this method in your Ble Manager instead of {@link #onDeviceDisconnected()} while you discover - * disconnection not initiated by the user. + * This callback is invoked when the Ble Manager lost connection to a device that has been connected with autoConnect option. Otherwise a {@link #onDeviceDisconnected()} + * method will be called on such event. */ public void onLinklossOccur(); @@ -64,7 +64,7 @@ public interface BleManagerCallbacks { public void onDeviceReady(); /** - * Called when battery value has been received from the device + * Called when battery value has been received from the device. * * @param value * the battery value in percent @@ -77,7 +77,7 @@ public interface BleManagerCallbacks { public void onBondingRequired(); /** - * Called when the device has been successfully bonded + * Called when the device has been successfully bonded. */ public void onBonded(); @@ -92,7 +92,7 @@ public interface BleManagerCallbacks { public void onError(final String message, final int errorCode); /** - * Called when service discovery has finished but the main services were not found on the device. This may occur when connecting to bonded device that does not support required services. + * Called when service discovery has finished but the main services were not found on the device. */ public void onDeviceNotSupported(); } diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleProfileService.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleProfileService.java index 26571d22..c0253762 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleProfileService.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleProfileService.java @@ -82,18 +82,12 @@ public abstract class BleProfileService extends Service implements BleManagerCal * Disconnects from the sensor. */ public final void disconnect() { - onDeviceDisconnecting(); if (!mConnected) { mBleManager.close(); onDeviceDisconnected(); return; } - // Notify user about changing the state to DISCONNECTING - final Intent broadcast = new Intent(BROADCAST_CONNECTION_STATE); - broadcast.putExtra(EXTRA_CONNECTION_STATE, STATE_DISCONNECTING); - LocalBroadcastManager.getInstance(BleProfileService.this).sendBroadcast(broadcast); - mBleManager.disconnect(); } @@ -278,7 +272,10 @@ public abstract class BleProfileService extends Service implements BleManagerCal @Override public void onDeviceDisconnecting() { - // do nothing + // Notify user about changing the state to DISCONNECTING + final Intent broadcast = new Intent(BROADCAST_CONNECTION_STATE); + broadcast.putExtra(EXTRA_CONNECTION_STATE, STATE_DISCONNECTING); + LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); } @Override diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleProfileServiceReadyActivity.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleProfileServiceReadyActivity.java index d7121aa3..3f0c1612 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleProfileServiceReadyActivity.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleProfileServiceReadyActivity.java @@ -398,7 +398,6 @@ public abstract class BleProfileServiceReadyActivity { } @Override - public void disconnect() { - super.disconnect(); + public boolean disconnect() { + final boolean result = super.disconnect(); closeGattServer(); + return result; } @Override diff --git a/build.gradle b/build.gradle index d3ff69d6..9405f3fd 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.1.0' + classpath 'com.android.tools.build:gradle:1.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/release/nRFToolbox_1_14_1.apk b/release/nRFToolbox_1_14_1.apk deleted file mode 100644 index cf4865d7..00000000 Binary files a/release/nRFToolbox_1_14_1.apk and /dev/null differ