vibrate less on bolus
This commit is contained in:
parent
a3cbb663b9
commit
30689c38aa
1 changed files with 48 additions and 51 deletions
|
@ -115,7 +115,6 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
// Log.d(TAG, logPrefix + "DataRequester: doInBack: " + params);
|
// Log.d(TAG, logPrefix + "DataRequester: doInBack: " + params);
|
||||||
|
@ -364,7 +363,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, logPrefix + "sendData: execute lastRequest:" + WearUtil.dateTimeText(lastRequest));
|
Log.d(TAG, logPrefix + "sendData: execute lastRequest:" + WearUtil.dateTimeText(lastRequest));
|
||||||
mDataRequester = (DataRequester)new DataRequester(this, path, payload).execute();
|
mDataRequester = (DataRequester) new DataRequester(this, path, payload).execute();
|
||||||
// executeTask(mDataRequester);
|
// executeTask(mDataRequester);
|
||||||
|
|
||||||
// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||||
|
@ -402,7 +401,6 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void forceGoogleApiConnect() {
|
private void forceGoogleApiConnect() {
|
||||||
if (googleApiClient == null || (!googleApiClient.isConnected() && !googleApiClient.isConnecting())) {
|
if (googleApiClient == null || (!googleApiClient.isConnected() && !googleApiClient.isConnecting())) {
|
||||||
try {
|
try {
|
||||||
|
@ -424,7 +422,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
if (intent != null && ACTION_RESEND.equals(intent.getAction())) {
|
if (intent != null && ACTION_RESEND.equals(intent.getAction())) {
|
||||||
googleApiConnect();
|
googleApiConnect();
|
||||||
requestData();
|
requestData();
|
||||||
} else if(intent != null && ACTION_CANCELBOLUS.equals(intent.getAction())){
|
} else if (intent != null && ACTION_CANCELBOLUS.equals(intent.getAction())) {
|
||||||
googleApiConnect();
|
googleApiConnect();
|
||||||
|
|
||||||
//dismiss notification
|
//dismiss notification
|
||||||
|
@ -436,7 +434,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
cancelBolus();
|
cancelBolus();
|
||||||
|
|
||||||
|
|
||||||
} else if(intent != null && ACTION_CONFIRMATION.equals(intent.getAction())){
|
} else if (intent != null && ACTION_CONFIRMATION.equals(intent.getAction())) {
|
||||||
googleApiConnect();
|
googleApiConnect();
|
||||||
|
|
||||||
//dismiss notification
|
//dismiss notification
|
||||||
|
@ -447,7 +445,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
String actionstring = intent.getStringExtra("actionstring");
|
String actionstring = intent.getStringExtra("actionstring");
|
||||||
sendConfirmActionstring(actionstring);
|
sendConfirmActionstring(actionstring);
|
||||||
|
|
||||||
} else if(intent != null && ACTION_CONFIRMCHANGE.equals(intent.getAction())){
|
} else if (intent != null && ACTION_CONFIRMCHANGE.equals(intent.getAction())) {
|
||||||
googleApiConnect();
|
googleApiConnect();
|
||||||
|
|
||||||
//dismiss notification
|
//dismiss notification
|
||||||
|
@ -458,7 +456,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
String actionstring = intent.getStringExtra("actionstring");
|
String actionstring = intent.getStringExtra("actionstring");
|
||||||
sendConfirmActionstring(actionstring);
|
sendConfirmActionstring(actionstring);
|
||||||
|
|
||||||
} else if(intent != null && ACTION_INITIATE_ACTION.equals(intent.getAction())){
|
} else if (intent != null && ACTION_INITIATE_ACTION.equals(intent.getAction())) {
|
||||||
googleApiConnect();
|
googleApiConnect();
|
||||||
|
|
||||||
String actionstring = intent.getStringExtra("actionstring");
|
String actionstring = intent.getStringExtra("actionstring");
|
||||||
|
@ -497,7 +495,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
String message = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("message");
|
String message = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("message");
|
||||||
String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring");
|
String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring");
|
||||||
|
|
||||||
if("opencpp".equals(title) && actionstring.startsWith("opencpp")){
|
if ("opencpp".equals(title) && actionstring.startsWith("opencpp")) {
|
||||||
String[] act = actionstring.split("\\s+");
|
String[] act = actionstring.split("\\s+");
|
||||||
Intent intent = new Intent(this, CPPActivity.class);
|
Intent intent = new Intent(this, CPPActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
@ -518,16 +516,16 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
messageIntent.putExtra("status", dataMap.toBundle());
|
messageIntent.putExtra("status", dataMap.toBundle());
|
||||||
Persistence.storeDataMap(RawDisplayData.STATUS_PERSISTENCE_KEY, dataMap);
|
Persistence.storeDataMap(RawDisplayData.STATUS_PERSISTENCE_KEY, dataMap);
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
|
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
|
||||||
} else if (path.equals(BASAL_DATA_PATH)){
|
} else if (path.equals(BASAL_DATA_PATH)) {
|
||||||
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
||||||
Intent messageIntent = new Intent();
|
Intent messageIntent = new Intent();
|
||||||
messageIntent.setAction(Intent.ACTION_SEND);
|
messageIntent.setAction(Intent.ACTION_SEND);
|
||||||
messageIntent.putExtra("basals", dataMap.toBundle());
|
messageIntent.putExtra("basals", dataMap.toBundle());
|
||||||
Persistence.storeDataMap(RawDisplayData.BASALS_PERSISTENCE_KEY, dataMap);
|
Persistence.storeDataMap(RawDisplayData.BASALS_PERSISTENCE_KEY, dataMap);
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
|
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
|
||||||
} else if (path.equals(NEW_PREFERENCES_PATH)){
|
} else if (path.equals(NEW_PREFERENCES_PATH)) {
|
||||||
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
||||||
if(dataMap.containsKey("wearcontrol")) {
|
if (dataMap.containsKey("wearcontrol")) {
|
||||||
boolean wearcontrol = dataMap.getBoolean("wearcontrol", false);
|
boolean wearcontrol = dataMap.getBoolean("wearcontrol", false);
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
@ -607,12 +605,22 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
|
|
||||||
private void showBolusProgress(int progresspercent, String progresstatus) {
|
private void showBolusProgress(int progresspercent, String progresstatus) {
|
||||||
|
|
||||||
|
long[] vibratePattern;
|
||||||
|
boolean vibrate = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(this).getBoolean("vibrateOnBolus", true);
|
||||||
|
if (vibrate) {
|
||||||
|
vibratePattern = new long[]{0, 50, 1000};
|
||||||
|
} else {
|
||||||
|
vibratePattern = new long[]{0, 1, 1000};
|
||||||
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
CharSequence name = "AAPS Bolus Progress";
|
CharSequence name = "AAPS Bolus Progress";
|
||||||
String description = "Bolus progress and cancel";
|
String description = "Bolus progress and cancel";
|
||||||
NotificationChannel channel = new NotificationChannel(AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS, name, NotificationManager.IMPORTANCE_HIGH);
|
NotificationChannel channel = new NotificationChannel(AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS, name, NotificationManager.IMPORTANCE_HIGH);
|
||||||
channel.setDescription(description);
|
channel.setDescription(description);
|
||||||
channel.enableVibration(true);
|
channel.enableVibration(true);
|
||||||
|
channel.setVibrationPattern(vibratePattern);
|
||||||
|
|
||||||
// Register the channel with the system; you can't change the importance
|
// Register the channel with the system; you can't change the importance
|
||||||
// or other notification behaviors after this
|
// or other notification behaviors after this
|
||||||
|
@ -624,16 +632,6 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
cancelIntent.setAction(ACTION_CANCELBOLUS);
|
cancelIntent.setAction(ACTION_CANCELBOLUS);
|
||||||
PendingIntent cancelPendingIntent = PendingIntent.getService(this, 0, cancelIntent, 0);
|
PendingIntent cancelPendingIntent = PendingIntent.getService(this, 0, cancelIntent, 0);
|
||||||
|
|
||||||
long[] vibratePattern;
|
|
||||||
boolean vibreate = PreferenceManager
|
|
||||||
.getDefaultSharedPreferences(this).getBoolean("vibrateOnBolus", true);
|
|
||||||
if(vibreate){
|
|
||||||
vibratePattern = new long[]{0, 50, 1000};
|
|
||||||
} else {
|
|
||||||
vibratePattern = new long[]{0, 1, 1000};
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: proper channel. Does cancel work?
|
|
||||||
NotificationCompat.Builder notificationBuilder =
|
NotificationCompat.Builder notificationBuilder =
|
||||||
new NotificationCompat.Builder(this, AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS)
|
new NotificationCompat.Builder(this, AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS)
|
||||||
.setSmallIcon(R.drawable.ic_icon)
|
.setSmallIcon(R.drawable.ic_icon)
|
||||||
|
@ -652,7 +650,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
notificationManager.cancel(CONFIRM_NOTIF_ID); // multiple watch setup
|
notificationManager.cancel(CONFIRM_NOTIF_ID); // multiple watch setup
|
||||||
|
|
||||||
|
|
||||||
if (progresspercent == 100){
|
if (progresspercent == 100) {
|
||||||
scheduleDismissBolusprogress(5);
|
scheduleDismissBolusprogress(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -675,18 +673,17 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class DismissThread extends Thread {
|
||||||
private class DismissThread extends Thread{
|
|
||||||
private final int notificationID;
|
private final int notificationID;
|
||||||
private final int seconds;
|
private final int seconds;
|
||||||
private boolean valid = true;
|
private boolean valid = true;
|
||||||
|
|
||||||
DismissThread(int notificationID, int seconds){
|
DismissThread(int notificationID, int seconds) {
|
||||||
this.notificationID = notificationID;
|
this.notificationID = notificationID;
|
||||||
this.seconds = seconds;
|
this.seconds = seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void invalidate(){
|
public synchronized void invalidate() {
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,7 +691,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
public void run() {
|
public void run() {
|
||||||
SystemClock.sleep(seconds * 1000);
|
SystemClock.sleep(seconds * 1000);
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if(valid) {
|
if (valid) {
|
||||||
NotificationManagerCompat notificationManager =
|
NotificationManagerCompat notificationManager =
|
||||||
NotificationManagerCompat.from(ListenerService.this);
|
NotificationManagerCompat.from(ListenerService.this);
|
||||||
notificationManager.cancel(notificationID);
|
notificationManager.cancel(notificationID);
|
||||||
|
|
Loading…
Reference in a new issue