wear: show bolusprogress again and make it cancellable
This commit is contained in:
parent
819a3b7d43
commit
c7ed508392
2 changed files with 23 additions and 12 deletions
|
@ -80,11 +80,12 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
|
||||
|
||||
private static final String ACTION_RESEND_BULK = "com.dexdrip.stephenblack.nightwatch.RESEND_BULK_DATA";
|
||||
private static final String AAPS_NOTIFY_CHANNEL_ID = "AndroidAPS-Openloop";
|
||||
private static final String AAPS_NOTIFY_CHANNEL_ID_OPENLOOP = "AndroidAPS-Openloop";
|
||||
private static final String AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS = "AndroidAPS-bolus-progress";
|
||||
|
||||
|
||||
GoogleApiClient googleApiClient;
|
||||
private long lastRequest = 0;
|
||||
private DismissThread confirmThread;
|
||||
private DismissThread bolusprogressThread;
|
||||
private static final String TAG = "ListenerService";
|
||||
|
||||
|
@ -559,7 +560,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
CharSequence name = "AAPS Open Loop";
|
||||
String description = "Open Loop request notiffication";//getString(R.string.channel_description);
|
||||
NotificationChannel channel = new NotificationChannel(AAPS_NOTIFY_CHANNEL_ID, name, NotificationManager.IMPORTANCE_HIGH);
|
||||
NotificationChannel channel = new NotificationChannel(AAPS_NOTIFY_CHANNEL_ID_OPENLOOP, name, NotificationManager.IMPORTANCE_HIGH);
|
||||
channel.setDescription(description);
|
||||
channel.enableVibration(true);
|
||||
|
||||
|
@ -570,7 +571,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
}
|
||||
|
||||
NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(this, AAPS_NOTIFY_CHANNEL_ID);
|
||||
new NotificationCompat.Builder(this, AAPS_NOTIFY_CHANNEL_ID_OPENLOOP);
|
||||
|
||||
builder = builder.setSmallIcon(R.drawable.notif_icon)
|
||||
.setContentTitle(title)
|
||||
|
@ -605,6 +606,20 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
}
|
||||
|
||||
private void showBolusProgress(int progresspercent, String progresstatus) {
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
CharSequence name = "AAPS Bolus Progress";
|
||||
String description = "Bolus progress and cancel";
|
||||
NotificationChannel channel = new NotificationChannel(AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS, name, NotificationManager.IMPORTANCE_HIGH);
|
||||
channel.setDescription(description);
|
||||
channel.enableVibration(true);
|
||||
|
||||
// Register the channel with the system; you can't change the importance
|
||||
// or other notification behaviors after this
|
||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
Intent cancelIntent = new Intent(this, ListenerService.class);
|
||||
cancelIntent.setAction(ACTION_CANCELBOLUS);
|
||||
PendingIntent cancelPendingIntent = PendingIntent.getService(this, 0, cancelIntent, 0);
|
||||
|
@ -618,11 +633,13 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
vibratePattern = new long[]{0, 1, 1000};
|
||||
}
|
||||
|
||||
// TODO: proper channel. Does cancel work?
|
||||
NotificationCompat.Builder notificationBuilder =
|
||||
new NotificationCompat.Builder(this)
|
||||
new NotificationCompat.Builder(this, AAPS_NOTIFY_CHANNEL_ID_OPENLOOP)
|
||||
.setSmallIcon(R.drawable.ic_icon)
|
||||
.setContentTitle("Bolus Progress")
|
||||
.setContentText(progresspercent + "% - " + progresstatus)
|
||||
.setSubText("press to cancel")
|
||||
.setContentIntent(cancelPendingIntent)
|
||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||
.setVibrate(vibratePattern)
|
||||
|
@ -631,9 +648,6 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
NotificationManagerCompat notificationManager =
|
||||
NotificationManagerCompat.from(this);
|
||||
|
||||
if(confirmThread != null){
|
||||
confirmThread.invalidate();
|
||||
}
|
||||
notificationManager.notify(BOLUS_PROGRESS_NOTIF_ID, notificationBuilder.build());
|
||||
notificationManager.cancel(CONFIRM_NOTIF_ID); // multiple watch setup
|
||||
|
||||
|
@ -656,9 +670,6 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
}
|
||||
|
||||
private void scheduleDismissBolusprogress(final int seconds) {
|
||||
if(confirmThread != null){
|
||||
confirmThread.invalidate();
|
||||
}
|
||||
bolusprogressThread = new DismissThread(BOLUS_PROGRESS_NOTIF_ID, seconds);
|
||||
bolusprogressThread.start();
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class CPPActivity extends ViewSelectorActivity {
|
|||
if (editPercentage != null){
|
||||
def = SafeParse.stringToDouble(editPercentage.editText.getText().toString());
|
||||
}
|
||||
editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 50d, 150d, 1d, new DecimalFormat("0"), false);
|
||||
editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 30d, 250d, 1d, new DecimalFormat("0"), false);
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_percentage));
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
|
Loading…
Reference in a new issue