From 001591a1d6585163340aee85d3a6115f61f32e1e Mon Sep 17 00:00:00 2001 From: rICTx-T1D Date: Wed, 30 Sep 2020 15:20:11 +0200 Subject: [PATCH] Add function to vibrate each hour (when activated in watchface configuration) --- .../androidaps/watchfaces/RICTxWF01.java | 28 +++++++++++-------- .../main/res/xml/rictxwf01configuration.xml | 2 -- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/RICTxWF01.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/RICTxWF01.java index 3cb37358b7..cb2450d349 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/RICTxWF01.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/RICTxWF01.java @@ -1,15 +1,14 @@ package info.nightscout.androidaps.watchfaces; import android.content.Intent; +import android.os.Vibrator; import android.support.wearable.watchface.WatchFaceStyle; import android.util.Log; import android.view.LayoutInflater; import android.widget.LinearLayout; - import androidx.core.content.ContextCompat; - +import com.ustwo.clockwise.common.WatchFaceTime; import com.ustwo.clockwise.common.WatchMode; - import info.nightscout.androidaps.R; import info.nightscout.androidaps.interaction.menus.MainMenuActivity; @@ -115,14 +114,6 @@ public class RICTxWF01 extends BaseWatchFace { /* ToDo Implement a configurable background image * layoutView.setBackground(); */ - - - /* ToDo Implement hourly vibartion - Boolean hourlyVibratePref = sharedPrefs.getBoolean("rictxwf01_vibrateHourly", false); - Log.i("hourlyVibratePref",Boolean.toString(hourlyVibratePref)); - */ - - } protected void setColorLowRes() { @@ -137,4 +128,19 @@ public class RICTxWF01 extends BaseWatchFace { } } + + @Override + protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) { + super.onTimeChanged(oldTime,newTime); + + /* hourly vibration*/ + Boolean hourlyVibratePref = sharedPrefs.getBoolean("rictxwf01_vibrateHourly", false); + if (hourlyVibratePref && layoutSet && newTime.hasHourChanged(oldTime)) { + Log.i("hourlyVibratePref", "true --> " + newTime.toString()); + Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); + long[] vibrationPattern = {0, 300, 150, 150}; + vibrator.vibrate(vibrationPattern, -1); + } + + } } diff --git a/wear/src/main/res/xml/rictxwf01configuration.xml b/wear/src/main/res/xml/rictxwf01configuration.xml index 21952c0489..f9edf6b7f0 100644 --- a/wear/src/main/res/xml/rictxwf01configuration.xml +++ b/wear/src/main/res/xml/rictxwf01configuration.xml @@ -26,12 +26,10 @@ android:entryValues="@array/rictxwf01_backgroundimage_values" /> --> -