From 6fa2dc04f365a51e4ab315e0b8931746dbc80d1a Mon Sep 17 00:00:00 2001 From: Sebastian Kranz Date: Fri, 28 Sep 2018 19:36:35 +0200 Subject: [PATCH] Setting the signal types is written to the watch now. --- .../devices/zetime/ZeTimeConstants.java | 21 +++++- .../zetime/ZeTimePreferenceActivity.java | 64 +++++++++++++++++++ .../devices/zetime/ZeTimeDeviceSupport.java | 47 ++++++++++++-- app/src/main/res/values/arrays.xml | 4 +- app/src/main/res/xml/zetime_preferences.xml | 2 +- 5 files changed, 130 insertions(+), 8 deletions(-) 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 59ac4be1e..38d6f7e02 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 @@ -113,6 +113,16 @@ public class ZeTimeConstants { public static final byte NOTIFICATION_SKYPE = (byte) 0x15; // reminders types public static final byte REMINDER_ALARM = (byte) 0x04; + // signaling types + public static final byte ANTI_LOSS_TYPE = (byte) 0x00; + public static final byte CALL_TYPE = (byte) 0x02; + public static final byte MISSED_CALL_TYPE = (byte) 0x03; + public static final byte SMS_TYPE = (byte) 0x04; + public static final byte SOCIAL_TYPE = (byte) 0x05; + public static final byte EMAIL_TYPE = (byte) 0x06; + public static final byte CALENDAR_TYPE = (byte) 0x07; + public static final byte INACTIVITY_TYPE = (byte) 0x08; + public static final byte LOW_POWER_TYPE = (byte) 0x09; // watch settings public static final String PREF_WRIST = "zetime_wrist"; public static final byte WEAR_ON_LEFT_WRIST = (byte) 0x00; @@ -153,7 +163,16 @@ 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_SMS_SIGNALING = "zetime_vibration_profile_sms"; + public static final String PREF_CALL_SIGNALING = "zetime_vibration_profile_incoming_call"; + public static final String PREF_MISSED_CALL_SIGNALING = "zetime_vibration_profile_missed_call"; + public static final String PREF_EMAIL_SIGNALING = "zetime_vibration_profile_generic_email"; + public static final String PREF_SOCIAL_SIGNALING = "zetime_vibration_profile_generic_social"; + public static final String PREF_CALENDAR_SIGNALING = "zetime_vibration_profile_calendar"; + public static final String PREF_INACTIVITY_SIGNALING = "zetime_vibration_profile_inactivity"; + public static final String PREF_LOW_POWER_SIGNALING = "zetime_vibration_profile_lowpower"; + public static final String PREF_ANTI_LOSS_SIGNALING = "zetime_vibration_profile_antiloss"; + 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 4a10fc592..364a2943c 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 @@ -293,6 +293,70 @@ public class ZeTimePreferenceActivity extends AbstractSettingsActivity { return true; } }); + final Preference antiSignaling = findPreference(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING); + antiSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING); + return true; + } + }); + final Preference calendarSignaling = findPreference(ZeTimeConstants.PREF_CALENDAR_SIGNALING); + calendarSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALENDAR_SIGNALING); + return true; + } + }); + final Preference callSignaling = findPreference(ZeTimeConstants.PREF_CALL_SIGNALING); + callSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALL_SIGNALING); + return true; + } + }); + final Preference missedSignaling = findPreference(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING); + missedSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING); + return true; + } + }); + final Preference emailSignaling = findPreference(ZeTimeConstants.PREF_EMAIL_SIGNALING); + emailSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_EMAIL_SIGNALING); + return true; + } + }); + final Preference inactivitySignaling = findPreference(ZeTimeConstants.PREF_INACTIVITY_SIGNALING); + inactivitySignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_INACTIVITY_SIGNALING); + return true; + } + }); + final Preference powerSignaling = findPreference(ZeTimeConstants.PREF_LOW_POWER_SIGNALING); + powerSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_LOW_POWER_SIGNALING); + return true; + } + }); + final Preference socialSignaling = findPreference(ZeTimeConstants.PREF_SOCIAL_SIGNALING); + socialSignaling.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_SOCIAL_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 b7a0e38d3..3604e620f 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 @@ -174,7 +174,15 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { setInactivityAlert(builder); break; case ZeTimeConstants.PREF_SMS_SIGNALING: - setSMSSignaling(builder); + case ZeTimeConstants.PREF_CALL_SIGNALING: + case ZeTimeConstants.PREF_MISSED_CALL_SIGNALING: + case ZeTimeConstants.PREF_EMAIL_SIGNALING: + case ZeTimeConstants.PREF_SOCIAL_SIGNALING: + case ZeTimeConstants.PREF_CALENDAR_SIGNALING: + case ZeTimeConstants.PREF_INACTIVITY_SIGNALING: + case ZeTimeConstants.PREF_LOW_POWER_SIGNALING: + case ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING: + setSignaling(builder, config); break; case ZeTimeConstants.PREF_SHOCK_STRENGTH: setShockStrength(builder); @@ -1773,10 +1781,10 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { sendMsgToWatch(builder, strength); } - private void setSMSSignaling(TransactionBuilder builder) + private void setSignaling(TransactionBuilder builder, String signalingType) { Prefs prefs = GBApplication.getPrefs(); - int signalType = prefs.getInt(ZeTimeConstants.PREF_SMS_SIGNALING, 0); + int signalType = prefs.getInt(signalingType, 0); byte[] signaling = { ZeTimeConstants.CMD_PREAMBLE, @@ -1784,11 +1792,42 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { ZeTimeConstants.CMD_SEND, (byte)0x2, (byte)0x0, - (byte)0x4, + (byte)0x0, (byte)signalType, ZeTimeConstants.CMD_END }; + switch(signalingType) + { + case ZeTimeConstants.PREF_SMS_SIGNALING: + signaling[5] = ZeTimeConstants.SMS_TYPE; + break; + case ZeTimeConstants.PREF_CALL_SIGNALING: + signaling[5] = ZeTimeConstants.CALL_TYPE; + break; + case ZeTimeConstants.PREF_MISSED_CALL_SIGNALING: + signaling[5] = ZeTimeConstants.MISSED_CALL_TYPE; + break; + case ZeTimeConstants.PREF_EMAIL_SIGNALING: + signaling[5] = ZeTimeConstants.EMAIL_TYPE; + break; + case ZeTimeConstants.PREF_SOCIAL_SIGNALING: + signaling[5] = ZeTimeConstants.SOCIAL_TYPE; + break; + case ZeTimeConstants.PREF_CALENDAR_SIGNALING: + signaling[5] = ZeTimeConstants.CALENDAR_TYPE; + break; + case ZeTimeConstants.PREF_INACTIVITY_SIGNALING: + signaling[5] = ZeTimeConstants.INACTIVITY_TYPE; + break; + case ZeTimeConstants.PREF_LOW_POWER_SIGNALING: + signaling[5] = ZeTimeConstants.LOW_POWER_TYPE; + break; + case ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING: + signaling[5] = ZeTimeConstants.ANTI_LOSS_TYPE; + break; + } + sendMsgToWatch(builder, signaling); } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 56a9920cb..b85bbbaae 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -491,7 +491,6 @@ 3 - @string/zetime_signaling_none @string/zetime_signaling_vibrate_once @string/zetime_signaling_vibrate_twice @string/zetime_signaling_vibrate @@ -500,9 +499,9 @@ @string/zetime_signaling_beep @string/zetime_signaling_vibrate_beep_once @string/zetime_signaling_vibrate_beep + @string/zetime_signaling_none - 0 2 4 7 @@ -511,6 +510,7 @@ 11 12 13 + 14 diff --git a/app/src/main/res/xml/zetime_preferences.xml b/app/src/main/res/xml/zetime_preferences.xml index 2f3b22154..653d9bd02 100644 --- a/app/src/main/res/xml/zetime_preferences.xml +++ b/app/src/main/res/xml/zetime_preferences.xml @@ -233,7 +233,7 @@ android:defaultValue="2" android:entries="@array/zetime_signaling_types" android:entryValues="@array/zetime_signaling_types_values" - android:key="zetime_sms_signaling" + android:key="zetime_vibration_profile_sms" android:title="@string/miband_prefs_vibration" android:summary="%s" />