From 5cff42cd92768da5f79eb600b7c493fdcbbdb6f0 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 7 Feb 2017 09:29:59 +0100 Subject: [PATCH] wear toggle setting to enable watch vibration on bolus --- .../info/nightscout/androidaps/ListenerService.java | 13 ++++++++++++- wear/src/main/res/xml/preferences.xml | 8 ++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index 9cb724bac9..a2b3646f1c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -6,6 +6,7 @@ import android.content.Context; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; @@ -47,6 +48,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp GoogleApiClient googleApiClient; private long lastRequest = 0; + public class DataRequester extends AsyncTask { Context mContext; @@ -181,6 +183,15 @@ public class ListenerService extends WearableListenerService implements GoogleAp cancelIntent.setAction(ACTION_CANCELBOLUS); 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}; + } + NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_icon) @@ -188,7 +199,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp .setContentText(progresspercent + "% - " + progresstatus) .setContentIntent(cancelPendingIntent) .setPriority(NotificationCompat.PRIORITY_MAX) - .setVibrate(new long[]{0, 50, 1000}) + .setVibrate(vibratePattern) .addAction(R.drawable.ic_cancel, "CANCEL BOLUS", cancelPendingIntent); // Get an instance of the NotificationManager service diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml index 97f8bb4027..d5c8503423 100644 --- a/wear/src/main/res/xml/preferences.xml +++ b/wear/src/main/res/xml/preferences.xml @@ -1,6 +1,14 @@ + + +