Merge pull request #203 from nightscout/fix/wear-show-bolusprogress-again
wear: show bolusprogress again and make it cancellable
This commit is contained in:
commit
96e6ac900b
|
@ -50,8 +50,8 @@ android {
|
|||
applicationId "info.nightscout.androidaps"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
versionName "1.0.2"
|
||||
versionCode 2
|
||||
versionName "1.0.3"
|
||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
||||
}
|
||||
buildTypes {
|
||||
|
|
|
@ -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_BOLUSPROGRESS)
|
||||
.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;
|
||||
|
|
|
@ -31,6 +31,7 @@ import lecho.lib.hellocharts.model.Viewport;
|
|||
*/
|
||||
public class BgGraphBuilder {
|
||||
public static final double MAX_PREDICTION__TIME_RATIO = (3d / 5);
|
||||
public static final double UPPER_CUTOFF_SGV = 400;
|
||||
private final long predictionEndTime;
|
||||
private final List<BgWatchData> predictionsList;
|
||||
private final ArrayList<BolusWatchData> bolusWatchDataList;
|
||||
|
@ -317,7 +318,7 @@ public class BgGraphBuilder {
|
|||
long endTime = getPredictionEndTime();
|
||||
for (BgWatchData bwd : predictionsList) {
|
||||
if (bwd.timestamp <= endTime) {
|
||||
double value = bwd.sgv < 300 ? bwd.sgv : 300;
|
||||
double value = Math.min(bwd.sgv, UPPER_CUTOFF_SGV);
|
||||
if (!values.containsKey(bwd.color)) {
|
||||
values.put(bwd.color, new ArrayList<>());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue