diff --git a/README.md b/README.md index 34672bc7..d3b29963 100644 --- a/README.md +++ b/README.md @@ -227,5 +227,5 @@ contributed based on the [Apache 2.0 license](http://www.apache.org/licenses/LIC - Android 4.3 or newer is required. - Compatible with nRF5 devices running samples from the Nordic SDK and other devices implementing standard profiles. -- Development kits can be ordered from http://www.nordicsemi.com/eng/Buy-Online. -- The nRF51 or nRF52 SDKs and SoftDevices are available online at http://developer.nordicsemi.com. +- Development kits: https://www.nordicsemi.com/Software-and-tools/Development-Kits. +- The nRF5 SDK and SoftDevices are available online at http://developer.nordicsemi.com. diff --git a/app/build.gradle b/app/build.gradle index 5be7dd13..1cd83615 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,16 +8,16 @@ android { applicationId "no.nordicsemi.android.nrftoolbox" minSdkVersion 18 targetSdkVersion 29 - versionCode 75 - versionName "2.8.3" + versionCode 76 + versionName "2.8.4" resConfigs "en" vectorDrawables.useSupportLibrary = true } buildTypes { debug { - minifyEnabled true - shrinkResources true + minifyEnabled false + shrinkResources false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/ExpandableRecordAdapter.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/ExpandableRecordAdapter.java index 71595b86..6bc6cbad 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/ExpandableRecordAdapter.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/ExpandableRecordAdapter.java @@ -39,8 +39,8 @@ public class ExpandableRecordAdapter extends BaseExpandableListAdapter {; private final Context context; private SparseArray records; - public ExpandableRecordAdapter(final Context context, final GlucoseManager manager) { - glucoseManager = manager; + ExpandableRecordAdapter(final Context context, final GlucoseManager manager) { + this.glucoseManager = manager; this.context = context; inflater = LayoutInflater.from(context); records = manager.getRecords().clone(); diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseActivity.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseActivity.java index 043a0aa3..238f650e 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseActivity.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseActivity.java @@ -81,8 +81,8 @@ public class GlucoseActivity extends BleProfileExpandableListActivity implements @Override protected LoggableBleManager initializeManager() { - GlucoseManager manager = glucoseManager = GlucoseManager.getGlucoseManager(getApplicationContext()); - manager.setGattCallbacks(this); + final GlucoseManager manager = glucoseManager = GlucoseManager.getGlucoseManager(getApplicationContext()); + manager.setManagerCallbacks(this); return manager; } diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseManager.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseManager.java index caf5d72a..6ac2a3f9 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseManager.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseManager.java @@ -118,7 +118,7 @@ public class GlucoseManager extends BatteryManager { } device.setCharacteristicNotification(recordAccessControlPointCharacteristic, true); */ - setNotificationCallback(glucoseMeasurementContextCharacteristic) + setNotificationCallback(glucoseMeasurementCharacteristic) .with(new GlucoseMeasurementDataCallback() { @Override public void onDataReceived(@NonNull final BluetoothDevice device, @NonNull final Data data) { @@ -255,7 +255,7 @@ public class GlucoseManager extends BatteryManager { } }); - enableNotifications(glucoseMeasurementContextCharacteristic).enqueue(); + enableNotifications(glucoseMeasurementCharacteristic).enqueue(); enableNotifications(glucoseMeasurementContextCharacteristic).enqueue(); enableIndications(recordAccessControlPointCharacteristic) .fail((device, status) -> log(Log.WARN, "Failed to enabled Record Access Control Point indications (error " + status + ")")) @@ -301,7 +301,10 @@ public class GlucoseManager extends BatteryManager { */ public void clear() { records.clear(); - callbacks.onOperationCompleted(getBluetoothDevice()); + final BluetoothDevice target = getBluetoothDevice(); + if (target != null) { + callbacks.onOperationCompleted(target); + } } /** @@ -312,9 +315,12 @@ public class GlucoseManager extends BatteryManager { void getLastRecord() { if (recordAccessControlPointCharacteristic == null) return; + final BluetoothDevice target = getBluetoothDevice(); + if (target == null) + return; clear(); - callbacks.onOperationStarted(getBluetoothDevice()); + callbacks.onOperationStarted(target); writeCharacteristic(recordAccessControlPointCharacteristic, RecordAccessControlPointData.reportLastStoredRecord()) .with((device, data) -> log(LogContract.Log.Level.APPLICATION, "\"" + RecordAccessControlPointParser.parse(data) + "\" sent")) .enqueue(); @@ -328,9 +334,12 @@ public class GlucoseManager extends BatteryManager { void getFirstRecord() { if (recordAccessControlPointCharacteristic == null) return; + final BluetoothDevice target = getBluetoothDevice(); + if (target == null) + return; clear(); - callbacks.onOperationStarted(getBluetoothDevice()); + callbacks.onOperationStarted(target); writeCharacteristic(recordAccessControlPointCharacteristic, RecordAccessControlPointData.reportFirstStoredRecord()) .with((device, data) -> log(LogContract.Log.Level.APPLICATION, "\"" + RecordAccessControlPointParser.parse(data) + "\" sent")) .enqueue(); @@ -345,9 +354,12 @@ public class GlucoseManager extends BatteryManager { void getAllRecords() { if (recordAccessControlPointCharacteristic == null) return; + final BluetoothDevice target = getBluetoothDevice(); + if (target == null) + return; clear(); - callbacks.onOperationStarted(getBluetoothDevice()); + callbacks.onOperationStarted(target); writeCharacteristic(recordAccessControlPointCharacteristic, RecordAccessControlPointData.reportNumberOfAllStoredRecords()) .with((device, data) -> log(LogContract.Log.Level.APPLICATION, "\"" + RecordAccessControlPointParser.parse(data) + "\" sent")) .enqueue(); @@ -366,11 +378,14 @@ public class GlucoseManager extends BatteryManager { void refreshRecords() { if (recordAccessControlPointCharacteristic == null) return; + final BluetoothDevice target = getBluetoothDevice(); + if (target == null) + return; if (records.size() == 0) { getAllRecords(); } else { - callbacks.onOperationStarted(getBluetoothDevice()); + callbacks.onOperationStarted(target); // obtain the last sequence number final int sequenceNumber = records.keyAt(records.size() - 1) + 1; @@ -390,6 +405,9 @@ public class GlucoseManager extends BatteryManager { void abort() { if (recordAccessControlPointCharacteristic == null) return; + final BluetoothDevice target = getBluetoothDevice(); + if (target == null) + return; writeCharacteristic(recordAccessControlPointCharacteristic, RecordAccessControlPointData.abortOperation()) .with((device, data) -> log(LogContract.Log.Level.APPLICATION, "\"" + RecordAccessControlPointParser.parse(data) + "\" sent")) @@ -403,9 +421,12 @@ public class GlucoseManager extends BatteryManager { void deleteAllRecords() { if (recordAccessControlPointCharacteristic == null) return; + final BluetoothDevice target = getBluetoothDevice(); + if (target == null) + return; clear(); - callbacks.onOperationStarted(getBluetoothDevice()); + callbacks.onOperationStarted(target); writeCharacteristic(recordAccessControlPointCharacteristic, RecordAccessControlPointData.deleteAllStoredRecords()) .with((device, data) -> log(LogContract.Log.Level.APPLICATION, "\"" + RecordAccessControlPointParser.parse(data) + "\" sent")) .enqueue(); diff --git a/app/src/main/res/layout-land/activity_feature_gls.xml b/app/src/main/res/layout-land/activity_feature_gls.xml index d76a7c3b..49b36ff3 100644 --- a/app/src/main/res/layout-land/activity_feature_gls.xml +++ b/app/src/main/res/layout-land/activity_feature_gls.xml @@ -157,6 +157,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" + tools:visibility="gone" android:orientation="vertical">