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 bd94c4f5..8513df93 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 @@ -23,6 +23,7 @@ package no.nordicsemi.android.nrftoolbox.gls; import android.bluetooth.BluetoothDevice; import android.os.Bundle; +import android.support.annotation.NonNull; import android.util.SparseArray; import android.view.MenuInflater; import android.view.MenuItem; @@ -48,6 +49,7 @@ public class GlucoseActivity extends BleProfileExpandableListActivity implements private View mControlPanelStd; private View mControlPanelAbort; private TextView mUnitView; + private TextView mBatteryLevelView; @Override protected void onCreateView(final Bundle savedInstanceState) { @@ -59,6 +61,7 @@ public class GlucoseActivity extends BleProfileExpandableListActivity implements mUnitView = findViewById(R.id.unit); mControlPanelStd = findViewById(R.id.gls_control_std); mControlPanelAbort = findViewById(R.id.gls_control_abort); + mBatteryLevelView = findViewById(R.id.battery); findViewById(R.id.action_last).setOnClickListener(v -> mGlucoseManager.getLastRecord()); findViewById(R.id.action_all).setOnClickListener(v -> mGlucoseManager.getAllRecords()); @@ -125,6 +128,7 @@ public class GlucoseActivity extends BleProfileExpandableListActivity implements @Override protected void setDefaultUI() { mGlucoseManager.clear(); + mBatteryLevelView.setText(R.string.not_available); } private void setOperationInProgress(final boolean progress) { @@ -138,6 +142,7 @@ public class GlucoseActivity extends BleProfileExpandableListActivity implements public void onDeviceDisconnected(final BluetoothDevice device) { super.onDeviceDisconnected(device); setOperationInProgress(false); + runOnUiThread(() -> mBatteryLevelView.setText(R.string.not_available)); } @Override @@ -188,4 +193,9 @@ public class GlucoseActivity extends BleProfileExpandableListActivity implements public void onNumberOfRecordsRequested(final BluetoothDevice device, final int value) { showToast(getResources().getQuantityString(R.plurals.gls_progress, value, value)); } + + @Override + public void onBatteryLevelChanged(@NonNull final BluetoothDevice device, final int batteryLevel) { + runOnUiThread(() -> mBatteryLevelView.setText(getString(R.string.battery, batteryLevel))); + } }