diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java index a8de5d504..59ac4be1e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java @@ -153,4 +153,7 @@ public class ZeTimeConstants { public static final String PREF_DATE_FORMAT = "zetime_date_format"; public static final String PREF_ALARM_SIGNALING = "zetime_alarm_signaling"; + public static final String PREF_SMS_SIGNALING = "zetime_sms_signaling"; + public static final String PREF_SHOCK_STRENGTH = "zetime_shock_strength"; + } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimePreferenceActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimePreferenceActivity.java index 8eabbc36f..4a10fc592 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimePreferenceActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimePreferenceActivity.java @@ -284,6 +284,15 @@ public class ZeTimePreferenceActivity extends AbstractSettingsActivity { return true; } }); + + final Preference smsSignaling = findPreference(ZeTimeConstants.PREF_SMS_SIGNALING); + smsSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SMS_SIGNALING); + return true; + } + }); } /** diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java index c46edf60e..b7a0e38d3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java @@ -173,6 +173,12 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { case ZeTimeConstants.PREF_INACTIVITY_KEY: setInactivityAlert(builder); break; + case ZeTimeConstants.PREF_SMS_SIGNALING: + setSMSSignaling(builder); + break; + case ZeTimeConstants.PREF_SHOCK_STRENGTH: + setShockStrength(builder); + break; } builder.queue(getQueue()); } catch (IOException e) { @@ -426,7 +432,22 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { @Override public void onTestNewFunction() { - + byte[] strength = { + ZeTimeConstants.CMD_PREAMBLE, + ZeTimeConstants.CMD_SHOCK_STRENGTH, + ZeTimeConstants.CMD_REQUEST, + (byte)0x1, + (byte)0x0, + (byte)0x0, + ZeTimeConstants.CMD_END + }; + try { + TransactionBuilder builder = performInitialized("testNewFunction"); + sendMsgToWatch(builder, strength); + builder.queue(getQueue()); + } catch (IOException e) { + GB.toast(getContext(), "Error on testing new function: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR); + } } @Override @@ -1733,4 +1754,41 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { sendMsgToWatch(builder, inactivity); } + + private void setShockStrength(TransactionBuilder builder) + { + Prefs prefs = GBApplication.getPrefs(); + int shockStrength = prefs.getInt(ZeTimeConstants.PREF_SHOCK_STRENGTH, 255); + + byte[] strength = { + ZeTimeConstants.CMD_PREAMBLE, + ZeTimeConstants.CMD_SHOCK_STRENGTH, + ZeTimeConstants.CMD_SEND, + (byte)0x1, + (byte)0x0, + (byte)shockStrength, + ZeTimeConstants.CMD_END + }; + + sendMsgToWatch(builder, strength); + } + + private void setSMSSignaling(TransactionBuilder builder) + { + Prefs prefs = GBApplication.getPrefs(); + int signalType = prefs.getInt(ZeTimeConstants.PREF_SMS_SIGNALING, 0); + + byte[] signaling = { + ZeTimeConstants.CMD_PREAMBLE, + ZeTimeConstants.CMD_SHOCK_MODE, + ZeTimeConstants.CMD_SEND, + (byte)0x2, + (byte)0x0, + (byte)0x4, + (byte)signalType, + ZeTimeConstants.CMD_END + }; + + sendMsgToWatch(builder, signaling); + } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 5fd1849a5..56a9920cb 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -491,13 +491,25 @@ 3 + @string/zetime_signaling_none + @string/zetime_signaling_vibrate_once + @string/zetime_signaling_vibrate_twice @string/zetime_signaling_vibrate - @string/zetime_signaling_buzzer - @string/zetime_signaling_vibrate_buzzer + @string/zetime_signaling_beep_once + @string/zetime_signaling_beep_twice + @string/zetime_signaling_beep + @string/zetime_signaling_vibrate_beep_once + @string/zetime_signaling_vibrate_beep + 0 + 2 + 4 7 + 9 + 10 11 + 12 13 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cc52bceb2..36cf72ee3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -240,9 +240,15 @@ Saturday Sunday Set type of signaling for the alarm - Vibrate - Buzzer - Vibrate and Buzzer + Silent + Continuous vibration + Continuous beeping + Continuous vibration and beeping + Vibrate once + Vibrate twice + Beep once + Beep twice + Vibrate and beep once Auto export @@ -342,9 +348,14 @@ Generic notification E-mail notification Incoming call notification + Missed call notification Chat Navigation Social network + Calendar notification + Inactivity notification + Low power warning + Anti-loss warning Whole day HR measurement once a minute diff --git a/app/src/main/res/xml/zetime_preferences.xml b/app/src/main/res/xml/zetime_preferences.xml index e4a5aa0d3..2f3b22154 100644 --- a/app/src/main/res/xml/zetime_preferences.xml +++ b/app/src/main/res/xml/zetime_preferences.xml @@ -18,14 +18,6 @@ android:key="zetime_screentime" android:title="@string/zetime_title_screentime"/> - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file