Some changes...

This commit is contained in:
Andy Rozman 2019-01-04 22:08:22 +01:00
parent 56eaacb3a2
commit 8935abf8a5
3 changed files with 78 additions and 79 deletions

View file

@ -128,7 +128,7 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
} }
}); });
startScanBLE(); prepareForScanning();
} }
@ -150,16 +150,19 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.rileylink_miScan: case R.id.rileylink_miScan: {
// FIXME
scanLeDevice(true); scanLeDevice(true);
return true; return true;
}
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
} }
public void startScanBLE() { public void prepareForScanning() {
// https://developer.android.com/training/permissions/requesting.html // https://developer.android.com/training/permissions/requesting.html
// http://developer.radiusnetworks.com/2015/09/29/is-your-beacon-app-ready-for-android-6.html // http://developer.radiusnetworks.com/2015/09/29/is-your-beacon-app-ready-for-android-6.html
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
@ -194,10 +197,11 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
filters = Arrays.asList(new ScanFilter.Builder().setServiceUuid( filters = Arrays.asList(new ScanFilter.Builder().setServiceUuid(
ParcelUuid.fromString(GattAttributes.SERVICE_RADIO)).build()); ParcelUuid.fromString(GattAttributes.SERVICE_RADIO)).build());
scanLeDevice(true); // scanLeDevice(true);
} }
} }
// disable currently selected RL, so that we can discover it
RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnect); RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnect);
} }
@ -224,13 +228,9 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
Log.d(TAG, scanRecord.toString()); Log.d(TAG, scanRecord.toString());
runOnUiThread(new Runnable() { runOnUiThread(() -> {
@Override
public void run() {
if (addDevice(scanRecord)) if (addDevice(scanRecord))
mLeDeviceListAdapter.notifyDataSetChanged(); mLeDeviceListAdapter.notifyDataSetChanged();
}
}); });
} }
@ -238,10 +238,7 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
@Override @Override
public void onBatchScanResults(final List<ScanResult> results) { public void onBatchScanResults(final List<ScanResult> results) {
runOnUiThread(new Runnable() { runOnUiThread(() -> {
@Override
public void run() {
boolean added = false; boolean added = false;
@ -253,7 +250,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
if (added) if (added)
mLeDeviceListAdapter.notifyDataSetChanged(); mLeDeviceListAdapter.notifyDataSetChanged();
}
}); });
} }
@ -293,7 +289,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
private String getDeviceDebug(BluetoothDevice device) { private String getDeviceDebug(BluetoothDevice device) {
return "BluetoothDevice [name=" + device.getName() + ", address=" + device.getAddress() + // return "BluetoothDevice [name=" + device.getName() + ", address=" + device.getAddress() + //
", type=" + device.getType(); // + ", alias=" + device.getAlias(); ", type=" + device.getType(); // + ", alias=" + device.getAlias();
} }

View file

@ -252,15 +252,19 @@ public class MedtronicFragment extends SubscriberFragment {
pumpStatus.rileyLinkError = (RileyLinkError)checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError()); pumpStatus.rileyLinkError = (RileyLinkError)checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError());
if (errorsView != null) {
if (pumpStatus.rileyLinkError != null) { if (pumpStatus.rileyLinkError != null) {
int resourceId = pumpStatus.rileyLinkError.getResourceId(getTargetDevice()); int resourceId = pumpStatus.rileyLinkError.getResourceId(getTargetDevice());
errorsView.setText(getTranslation(resourceId)); errorsView.setText(getTranslation(resourceId));
} else } else
errorsView.setText("-"); errorsView.setText("-");
}
pumpStatus.pumpDeviceState = (PumpDeviceState)checkStatusSet(pumpStatus.pumpDeviceState, pumpStatus.pumpDeviceState = (PumpDeviceState)checkStatusSet(pumpStatus.pumpDeviceState,
MedtronicUtil.getPumpDeviceState()); MedtronicUtil.getPumpDeviceState());
if (pumpStatusIconView != null) {
if (pumpStatus.pumpDeviceState != null) { if (pumpStatus.pumpDeviceState != null) {
// TODO Pump State // TODO Pump State
@ -292,8 +296,8 @@ public class MedtronicFragment extends SubscriberFragment {
if (cmd == MedtronicCommandType.GetHistoryData) { if (cmd == MedtronicCommandType.GetHistoryData) {
if (MedtronicUtil.frameNumber == null) { if (MedtronicUtil.frameNumber == null) {
pumpStatusIconView.setText(MainApp.gs(R.string.medtronic_cmd_desc_get_history_request, pumpStatusIconView.setText(MainApp.gs(
MedtronicUtil.pageNumber)); R.string.medtronic_cmd_desc_get_history_request, MedtronicUtil.pageNumber));
} else { } else {
pumpStatusIconView.setText(MainApp.gs(resourceId, MedtronicUtil.pageNumber, pumpStatusIconView.setText(MainApp.gs(resourceId, MedtronicUtil.pageNumber,
MedtronicUtil.frameNumber)); MedtronicUtil.frameNumber));
@ -327,6 +331,7 @@ public class MedtronicFragment extends SubscriberFragment {
} else { } else {
pumpStatusIconView.setText("{fa-bed} "); pumpStatusIconView.setText("{fa-bed} ");
} }
}
if (queueView != null) { if (queueView != null) {
Spanned status = ConfigBuilderPlugin.getPlugin().getCommandQueue().spannedStatus(); Spanned status = ConfigBuilderPlugin.getPlugin().getCommandQueue().spannedStatus();

View file

@ -5,7 +5,6 @@
<item <item
android:id="@+id/rileylink_miScan" android:id="@+id/rileylink_miScan"
android:icon="@drawable/refresh"
app:showAsAction="ifRoom" app:showAsAction="ifRoom"
android:title="Scan"></item> android:title="Scan"></item>
</menu> </menu>