Add function to vibrate each hour (when activated in watchface configuration)
This commit is contained in:
parent
278b15d8ac
commit
001591a1d6
|
@ -1,15 +1,14 @@
|
||||||
package info.nightscout.androidaps.watchfaces;
|
package info.nightscout.androidaps.watchfaces;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Vibrator;
|
||||||
import android.support.wearable.watchface.WatchFaceStyle;
|
import android.support.wearable.watchface.WatchFaceStyle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import com.ustwo.clockwise.common.WatchFaceTime;
|
||||||
import com.ustwo.clockwise.common.WatchMode;
|
import com.ustwo.clockwise.common.WatchMode;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
|
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
|
||||||
|
|
||||||
|
@ -115,14 +114,6 @@ public class RICTxWF01 extends BaseWatchFace {
|
||||||
/* ToDo Implement a configurable background image
|
/* ToDo Implement a configurable background image
|
||||||
* layoutView.setBackground();
|
* layoutView.setBackground();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* ToDo Implement hourly vibartion
|
|
||||||
Boolean hourlyVibratePref = sharedPrefs.getBoolean("rictxwf01_vibrateHourly", false);
|
|
||||||
Log.i("hourlyVibratePref",Boolean.toString(hourlyVibratePref));
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setColorLowRes() {
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,10 @@
|
||||||
android:entryValues="@array/rictxwf01_backgroundimage_values" />
|
android:entryValues="@array/rictxwf01_backgroundimage_values" />
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- Idea for future implementation @ToDo Implement Hourly Vibration
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="rictxwf01_vibrateHourly"
|
android:key="rictxwf01_vibrateHourly"
|
||||||
android:title="@string/pref_vibrate_hourly"
|
android:title="@string/pref_vibrate_hourly"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
app:wear_iconOff="@drawable/settings_off"
|
app:wear_iconOff="@drawable/settings_off"
|
||||||
app:wear_iconOn="@drawable/settings_on" />
|
app:wear_iconOn="@drawable/settings_on" />
|
||||||
-->
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Reference in a new issue