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 a0d8deda1..e746f44aa 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 @@ -77,6 +77,7 @@ public class ZeTimeConstants { public static final byte CMD_PUSH_EX_MSG = (byte) 0x76; public static final byte CMD_PUSH_WEATHER_DATA = (byte) 0x77; public static final byte CMD_SWITCH_SETTINGS = (byte) 0x90; + public static final byte CMD_REMINDERS = (byte) 0x97; public static final byte CMD_PUSH_CALENDAR_DAY = (byte) 0x99; public static final byte CMD_MUSIC_CONTROL = (byte) 0xD0; // here are the action commands @@ -109,6 +110,8 @@ public class ZeTimeConstants { public static final byte NOTIFICATION_UBER = (byte) 0x13; public static final byte NOTIFICATION_LINE = (byte) 0x14; public static final byte NOTIFICATION_SKYPE = (byte) 0x15; + // reminders types + public static final byte REMINDER_ALARM = (byte) 0x04; // watch settings public static final String PREF_WRIST = "zetime_wrist"; public static final byte WEAR_ON_LEFT_WRIST = (byte) 0x00; @@ -147,4 +150,6 @@ public class ZeTimeConstants { public static final String PREF_CALORIES_TYPE = "zetime_calories_type"; public static final String PREF_TIME_FORMAT = "zetime_time_format"; public static final String PREF_DATE_FORMAT = "zetime_date_format"; + + public static final String PREF_ALARM_SIGNALING = "zetime_alarm_signaling"; } 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 51eaea75a..bf4efb818 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 @@ -229,7 +229,38 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { @Override public void onSetAlarms(ArrayList alarms) { + byte[] alarmMessage = null; + try { + TransactionBuilder builder = performInitialized("setAlarms"); + Prefs prefs = GBApplication.getPrefs(); + + for (Alarm alarm : alarms) { + alarmMessage = new byte[]{ + ZeTimeConstants.CMD_PREAMBLE, + ZeTimeConstants.CMD_REMINDERS, + ZeTimeConstants.CMD_SEND, + (byte) 0xb, + (byte) 0x0, + (byte) alarm.getIndex(), // index + ZeTimeConstants.REMINDER_ALARM, + (byte) 0x0, // year low byte + (byte) 0x0, // year high byte + (byte) 0x0, // month + (byte) 0x0, // day + (byte) alarm.getAlarmCal().get(Calendar.HOUR_OF_DAY), + (byte) alarm.getAlarmCal().get(Calendar.MINUTE), + (byte) alarm.getRepetitionMask(), + (byte) (alarm.isEnabled() ? 1 : 0), + (byte) prefs.getInt(ZeTimeConstants.PREF_ALARM_SIGNALING, 11), // reminder signaling + ZeTimeConstants.CMD_END + }; + sendMsgToWatch(builder, alarmMessage); + } + builder.queue(getQueue()); + } catch (IOException e) { + GB.toast(getContext(), "Error set alarms: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR); + } } @Override diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 99403968d..5fd1849a5 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -490,5 +490,15 @@ 2 3 + + @string/zetime_signaling_vibrate + @string/zetime_signaling_buzzer + @string/zetime_signaling_vibrate_buzzer + + + 7 + 11 + 13 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ce8ca4777..cc52bceb2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -239,6 +239,10 @@ Friday Saturday Sunday + Set type of signaling for the alarm + Vibrate + Buzzer + Vibrate and Buzzer Auto export diff --git a/app/src/main/res/xml/zetime_preferences.xml b/app/src/main/res/xml/zetime_preferences.xml index 9f85c7c7e..e4a5aa0d3 100644 --- a/app/src/main/res/xml/zetime_preferences.xml +++ b/app/src/main/res/xml/zetime_preferences.xml @@ -18,6 +18,14 @@ android:key="zetime_screentime" android:title="@string/zetime_title_screentime"/> + +