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
4 changed files with 27 additions and 15 deletions
|
@ -50,8 +50,8 @@ android {
|
||||||
applicationId "info.nightscout.androidaps"
|
applicationId "info.nightscout.androidaps"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 1
|
versionCode 2
|
||||||
versionName "1.0.2"
|
versionName "1.0.3"
|
||||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
||||||
}
|
}
|
||||||
buildTypes {
|
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 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;
|
GoogleApiClient googleApiClient;
|
||||||
private long lastRequest = 0;
|
private long lastRequest = 0;
|
||||||
private DismissThread confirmThread;
|
|
||||||
private DismissThread bolusprogressThread;
|
private DismissThread bolusprogressThread;
|
||||||
private static final String TAG = "ListenerService";
|
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) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
CharSequence name = "AAPS Open Loop";
|
CharSequence name = "AAPS Open Loop";
|
||||||
String description = "Open Loop request notiffication";//getString(R.string.channel_description);
|
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.setDescription(description);
|
||||||
channel.enableVibration(true);
|
channel.enableVibration(true);
|
||||||
|
|
||||||
|
@ -570,7 +571,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationCompat.Builder builder =
|
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)
|
builder = builder.setSmallIcon(R.drawable.notif_icon)
|
||||||
.setContentTitle(title)
|
.setContentTitle(title)
|
||||||
|
@ -605,6 +606,20 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showBolusProgress(int progresspercent, String progresstatus) {
|
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);
|
Intent cancelIntent = new Intent(this, ListenerService.class);
|
||||||
cancelIntent.setAction(ACTION_CANCELBOLUS);
|
cancelIntent.setAction(ACTION_CANCELBOLUS);
|
||||||
PendingIntent cancelPendingIntent = PendingIntent.getService(this, 0, cancelIntent, 0);
|
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};
|
vibratePattern = new long[]{0, 1, 1000};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: proper channel. Does cancel work?
|
||||||
NotificationCompat.Builder notificationBuilder =
|
NotificationCompat.Builder notificationBuilder =
|
||||||
new NotificationCompat.Builder(this)
|
new NotificationCompat.Builder(this, AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS)
|
||||||
.setSmallIcon(R.drawable.ic_icon)
|
.setSmallIcon(R.drawable.ic_icon)
|
||||||
.setContentTitle("Bolus Progress")
|
.setContentTitle("Bolus Progress")
|
||||||
.setContentText(progresspercent + "% - " + progresstatus)
|
.setContentText(progresspercent + "% - " + progresstatus)
|
||||||
|
.setSubText("press to cancel")
|
||||||
.setContentIntent(cancelPendingIntent)
|
.setContentIntent(cancelPendingIntent)
|
||||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||||
.setVibrate(vibratePattern)
|
.setVibrate(vibratePattern)
|
||||||
|
@ -631,9 +648,6 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
NotificationManagerCompat notificationManager =
|
NotificationManagerCompat notificationManager =
|
||||||
NotificationManagerCompat.from(this);
|
NotificationManagerCompat.from(this);
|
||||||
|
|
||||||
if(confirmThread != null){
|
|
||||||
confirmThread.invalidate();
|
|
||||||
}
|
|
||||||
notificationManager.notify(BOLUS_PROGRESS_NOTIF_ID, notificationBuilder.build());
|
notificationManager.notify(BOLUS_PROGRESS_NOTIF_ID, notificationBuilder.build());
|
||||||
notificationManager.cancel(CONFIRM_NOTIF_ID); // multiple watch setup
|
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) {
|
private void scheduleDismissBolusprogress(final int seconds) {
|
||||||
if(confirmThread != null){
|
|
||||||
confirmThread.invalidate();
|
|
||||||
}
|
|
||||||
bolusprogressThread = new DismissThread(BOLUS_PROGRESS_NOTIF_ID, seconds);
|
bolusprogressThread = new DismissThread(BOLUS_PROGRESS_NOTIF_ID, seconds);
|
||||||
bolusprogressThread.start();
|
bolusprogressThread.start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class CPPActivity extends ViewSelectorActivity {
|
||||||
if (editPercentage != null){
|
if (editPercentage != null){
|
||||||
def = SafeParse.stringToDouble(editPercentage.editText.getText().toString());
|
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));
|
setLabelToPlusMinusView(view, aaps.gs(R.string.action_percentage));
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
return view;
|
return view;
|
||||||
|
|
|
@ -31,6 +31,7 @@ import lecho.lib.hellocharts.model.Viewport;
|
||||||
*/
|
*/
|
||||||
public class BgGraphBuilder {
|
public class BgGraphBuilder {
|
||||||
public static final double MAX_PREDICTION__TIME_RATIO = (3d / 5);
|
public static final double MAX_PREDICTION__TIME_RATIO = (3d / 5);
|
||||||
|
public static final double UPPER_CUTOFF_SGV = 400;
|
||||||
private final long predictionEndTime;
|
private final long predictionEndTime;
|
||||||
private final List<BgWatchData> predictionsList;
|
private final List<BgWatchData> predictionsList;
|
||||||
private final ArrayList<BolusWatchData> bolusWatchDataList;
|
private final ArrayList<BolusWatchData> bolusWatchDataList;
|
||||||
|
@ -317,7 +318,7 @@ public class BgGraphBuilder {
|
||||||
long endTime = getPredictionEndTime();
|
long endTime = getPredictionEndTime();
|
||||||
for (BgWatchData bwd : predictionsList) {
|
for (BgWatchData bwd : predictionsList) {
|
||||||
if (bwd.timestamp <= endTime) {
|
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)) {
|
if (!values.containsKey(bwd.color)) {
|
||||||
values.put(bwd.color, new ArrayList<>());
|
values.put(bwd.color, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue