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 514829a06..3339dd0e4 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
@@ -55,6 +55,8 @@ public class ZeTimeConstants {
public static final byte CMD_SCREEN_ON_TIME = (byte) 0x13;
public static final byte CMD_SNOOZE = (byte) 0x14;
public static final byte CMD_DO_NOT_DISTURB = (byte) 0x15;
+ public static final byte CMD_ANALOG_MODE = (byte) 0x17;
+ public static final byte CMD_CONTROL_DEVICE = (byte) 0x1A;
public static final byte CMD_DISPLAY_TIMEOUT = (byte) 0x25;
public static final byte CMD_USER_INFO = (byte) 0x30;
public static final byte CMD_USAGE_HABITS = (byte) 0x31;
@@ -74,6 +76,7 @@ public class ZeTimeConstants {
public static final byte CMD_GET_HEARTRATE_EXDATA = (byte) 0x61;
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_PUSH_CALENDAR_DAY = (byte) 0x99;
public static final byte CMD_MUSIC_CONTROL = (byte) 0xD0;
// here are the action commands
@@ -120,4 +123,14 @@ public class ZeTimeConstants {
public static final String PREF_ZETIME_MAX_HEARTRATE = "alarm_max_heart_rate";
public static final String PREF_ZETIME_MIN_HEARTRATE = "alarm_min_heart_rate";
+ public static final String PREF_DO_NOT_DISTURB = "zetime_do_not_disturb";
+ public static final String PREF_DO_NOT_DISTURB_START = "zetime_do_not_disturb_start";
+ public static final String PREF_DO_NOT_DISTURB_END = "zetime_do_not_disturb_end";
+
+ public static final String PREF_ANALOG_MODE = "zetime_analog_mode";
+ public static final String PREF_ACTIVITY_TRACKING = "zetime_activity_tracking";
+ public static final String PREF_HANDMOVE_DISPLAY = "zetime_handmove_display";
+ 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";
}
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 e3b9520ba..9d97eccc5 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
@@ -17,7 +17,7 @@ public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.preferences);
+ addPreferencesFromResource(R.xml.zetime_preferences);
//addTryListeners();
@@ -49,6 +49,87 @@ public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
return true;
}
});
+
+ final Preference analogMode = findPreference(ZeTimeConstants.PREF_ANALOG_MODE);
+ analogMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newVal) {
+ GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ANALOG_MODE);
+ return true;
+ }
+ });
+
+ final Preference activity = findPreference(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
+ activity.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newVal) {
+ GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
+ return true;
+ }
+ });
+
+ final Preference handmove = findPreference(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
+ handmove.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newVal) {
+ GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
+ return true;
+ }
+ });
+
+ final Preference dnd = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB);
+ dnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newVal) {
+ GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
+ return true;
+ }
+ });
+
+ final Preference dnd_start = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB_START);
+ dnd_start.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newVal) {
+ GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
+ return true;
+ }
+ });
+
+ final Preference dnd_end = findPreference(ZeTimeConstants.PREF_DO_NOT_DISTURB_END);
+ dnd_end.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newVal) {
+ GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DO_NOT_DISTURB);
+ return true;
+ }
+ });
+
+ final Preference caloriesType = findPreference(ZeTimeConstants.PREF_CALORIES_TYPE);
+ caloriesType.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newVal) {
+ GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_CALORIES_TYPE);
+ return true;
+ }
+ });
+
+ final Preference timeFormat = findPreference(ZeTimeConstants.PREF_TIME_FORMAT);
+ timeFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newVal) {
+ GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_TIME_FORMAT);
+ return true;
+ }
+ });
+
+ final Preference dateFormat = findPreference(ZeTimeConstants.PREF_DATE_FORMAT);
+ dateFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newVal) {
+ GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_DATE_FORMAT);
+ return true;
+ }
+ });
}
// private void addTryListeners() {
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 23f34f7bf..46ec21fe5 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
@@ -27,6 +27,8 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -124,8 +126,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
requestDeviceInfo(builder);
requestBatteryInfo(builder);
setUserInfo(builder);
- setWrist(builder);
- setScreenTime(builder);
setUserGoals(builder);
setHeartRateLimits(builder);
requestActivityInfo(builder);
@@ -149,6 +149,27 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
case ZeTimeConstants.PREF_SCREENTIME:
setScreenTime(builder);
break;
+ case ZeTimeConstants.PREF_ANALOG_MODE:
+ setAnalogMode(builder);
+ break;
+ case ZeTimeConstants.PREF_ACTIVITY_TRACKING:
+ setActivityTracking(builder);
+ break;
+ case ZeTimeConstants.PREF_HANDMOVE_DISPLAY:
+ setDisplayOnMovement(builder);
+ break;
+ case ZeTimeConstants.PREF_DO_NOT_DISTURB:
+ setDoNotDisturb(builder);
+ break;
+ case ZeTimeConstants.PREF_CALORIES_TYPE:
+ setCaloriesType(builder);
+ break;
+ case ZeTimeConstants.PREF_TIME_FORMAT:
+ setTimeFormate(builder);
+ break;
+ case ZeTimeConstants.PREF_DATE_FORMAT:
+ setDateFormate(builder);
+ break;
}
builder.queue(getQueue());
} catch (IOException e) {
@@ -1433,4 +1454,164 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
volume,
ZeTimeConstants.CMD_END});
}
+
+ private void setAnalogMode(TransactionBuilder builder)
+ {
+ Prefs prefs = GBApplication.getPrefs();
+ int mode = prefs.getInt(ZeTimeConstants.PREF_ANALOG_MODE, 0);
+
+ byte[] analog = {ZeTimeConstants.CMD_PREAMBLE,
+ ZeTimeConstants.CMD_ANALOG_MODE,
+ ZeTimeConstants.CMD_SEND,
+ (byte)0x1,
+ (byte)0x0,
+ (byte)mode,
+ ZeTimeConstants.CMD_END};
+
+ sendMsgToWatch(builder, analog);
+ }
+
+ private void setActivityTracking(TransactionBuilder builder)
+ {
+ Prefs prefs = GBApplication.getPrefs();
+ boolean tracking = prefs.getBoolean(ZeTimeConstants.PREF_ACTIVITY_TRACKING, false);
+
+ byte[] activity = {ZeTimeConstants.CMD_PREAMBLE,
+ ZeTimeConstants.CMD_CONTROL_DEVICE,
+ ZeTimeConstants.CMD_SEND,
+ (byte)0x1,
+ (byte)0x0,
+ (byte)0x9,
+ ZeTimeConstants.CMD_END};
+ if(tracking)
+ {
+ activity[5] = (byte)0xa;
+ }
+ sendMsgToWatch(builder, activity);
+ }
+
+ private void setDisplayOnMovement(TransactionBuilder builder)
+ {
+ Prefs prefs = GBApplication.getPrefs();
+ boolean movement = prefs.getBoolean(ZeTimeConstants.PREF_ACTIVITY_TRACKING, false);
+
+ byte[] handmove = {ZeTimeConstants.CMD_PREAMBLE,
+ ZeTimeConstants.CMD_SWITCH_SETTINGS,
+ ZeTimeConstants.CMD_SEND,
+ (byte)0x3,
+ (byte)0x0,
+ (byte)0x1,
+ (byte)0xe,
+ (byte)0x0,
+ ZeTimeConstants.CMD_END};
+ if(movement)
+ {
+ handmove[7] = (byte)0x1;
+ }
+ sendMsgToWatch(builder, handmove);
+ }
+
+ private void setDoNotDisturb(TransactionBuilder builder)
+ {
+ Prefs prefs = GBApplication.getPrefs();
+ String scheduled = prefs.getString(ZeTimeConstants.PREF_DO_NOT_DISTURB, "off");
+ String dndScheduled = getContext().getString(R.string.p_scheduled);
+ String start = prefs.getString(ZeTimeConstants.PREF_DO_NOT_DISTURB_START, "22:00");
+ String end = prefs.getString(ZeTimeConstants.PREF_DO_NOT_DISTURB_END, "07:00");
+ DateFormat df_start = new SimpleDateFormat("HH:mm");
+ DateFormat df_end = new SimpleDateFormat("HH:mm");
+ Calendar calendar = GregorianCalendar.getInstance();
+ Calendar calendar_end = GregorianCalendar.getInstance();
+
+ try {
+ calendar.setTime(df_start.parse(start));
+ try {
+ calendar_end.setTime(df_end.parse(end));
+
+ byte[] doNotDisturb = {ZeTimeConstants.CMD_PREAMBLE,
+ ZeTimeConstants.CMD_DO_NOT_DISTURB,
+ ZeTimeConstants.CMD_SEND,
+ (byte)0x5,
+ (byte)0x0,
+ (byte)0x0,
+ (byte)calendar.get(Calendar.HOUR_OF_DAY),
+ (byte)calendar.get(Calendar.MINUTE),
+ (byte)calendar_end.get(Calendar.HOUR_OF_DAY),
+ (byte)calendar_end.get(Calendar.MINUTE),
+ ZeTimeConstants.CMD_END};
+
+ if(scheduled.equals(dndScheduled))
+ {
+ doNotDisturb[5] = (byte)0x1;
+ }
+ sendMsgToWatch(builder, doNotDisturb);
+ } catch(Exception e) {
+ LOG.error("Unexpected exception in ZeTimeDeviceSupport.setDoNotDisturb: " + e.getMessage());
+ }
+ } catch(Exception e) {
+ LOG.error("Unexpected exception in ZeTimeDeviceSupport.setDoNotDisturb: " + e.getMessage());
+ }
+ }
+
+ private void setCaloriesType(TransactionBuilder builder)
+ {
+ Prefs prefs = GBApplication.getPrefs();
+ int type = prefs.getInt(ZeTimeConstants.PREF_CALORIES_TYPE, 0);
+
+ byte[] calories = {ZeTimeConstants.CMD_PREAMBLE,
+ ZeTimeConstants.CMD_CALORIES_TYPE,
+ ZeTimeConstants.CMD_SEND,
+ (byte)0x1,
+ (byte)0x0,
+ (byte)type,
+ ZeTimeConstants.CMD_END};
+
+ sendMsgToWatch(builder, calories);
+ }
+
+ private void setTimeFormate(TransactionBuilder builder)
+ {
+ Prefs prefs = GBApplication.getPrefs();
+ int type = prefs.getInt(ZeTimeConstants.PREF_TIME_FORMAT, 0);
+
+ byte[] timeformat = {ZeTimeConstants.CMD_PREAMBLE,
+ ZeTimeConstants.CMD_TIME_SURFACE_SETTINGS,
+ ZeTimeConstants.CMD_SEND,
+ (byte)0x8,
+ (byte)0x0,
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)type,
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ ZeTimeConstants.CMD_END};
+
+ sendMsgToWatch(builder, timeformat);
+ }
+
+ private void setDateFormate(TransactionBuilder builder)
+ {
+ Prefs prefs = GBApplication.getPrefs();
+ int type = prefs.getInt(ZeTimeConstants.PREF_TIME_FORMAT, 0);
+
+ byte[] dateformat = {ZeTimeConstants.CMD_PREAMBLE,
+ ZeTimeConstants.CMD_TIME_SURFACE_SETTINGS,
+ ZeTimeConstants.CMD_SEND,
+ (byte)0x8,
+ (byte)0x0,
+ (byte)type,
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ (byte)0xff, // set to ff to not change anything on the watch
+ ZeTimeConstants.CMD_END};
+
+ sendMsgToWatch(builder, dateformat);
+ }
}
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index c21121fdf..99403968d 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -159,6 +159,15 @@
- @string/p_scheduled
+
+ - @string/mi2_dnd_off
+ - @string/mi2_dnd_scheduled
+
+
+ - @string/p_off
+ - @string/p_scheduled
+
+
- @string/off
- @string/on
@@ -407,7 +416,9 @@
- @string/off
- @string/interval_five_minutes
- @string/interval_ten_minutes
+ - @string/interval_fifteen_minutes
- @string/interval_thirty_minutes
+ - @string/interval_forty_five_minutes
- @string/interval_one_hour
@@ -415,7 +426,9 @@
- 0
- 300
- 600
+ - 900
- 1800
+ - 2700
- 3600
@@ -442,4 +455,40 @@
- 1800
+
+
+ - @string/zetime_analog_mode_hands
+ - @string/zetime_analog_mode_handsandsteps
+
+
+ - 0
+ - 1
+
+
+ - @string/zetime_calories_type_active
+ - @string/zetime_calories_type_all
+
+
+ - 0
+ - 1
+
+
+ - @string/zetime_time_format_24h
+ - @string/zetime_time_format_12h
+
+
+ - 1
+ - 2
+
+
+ - @string/zetime_date_format_1
+ - @string/zetime_date_format_2
+ - @string/zetime_date_format_3
+
+
+ - 1
+ - 2
+ - 3
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 51de96138..1d48124c8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -207,9 +207,27 @@
ZeTime settings
+ Heart rate settings
Screen on duration in seconds
Max heart rate alarm
Min heart rate alarm
+ Analog mode
+ Only hands
+ Hands and steps
+ Activity tracking
+ Switching the activity tracking on, will count your steps and so on.
+ Hand movement
+ Rotate your wrist to activate or deactivate the display.
+ Calories type
+ Only active burnt calories
+ Active and inactive burnt calories
+ Time format
+ 24h
+ 12h
+ Date format
+ YY/MM/DD
+ DD/MM/YY
+ MM/DD/YY
Auto export
@@ -317,7 +335,9 @@
once a minute
every 5 minutes
every 10 minutes
+ every 15 minutes
every 30 minutes
+ every 45 minutes
once an hour
Speed zones
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index e588ab5cf..178a11102 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -722,54 +722,10 @@
android:summary="%s" />
-
-
-
-
-
-
-
-
-
-
-
-
+ android:title="@string/zetime_title_settings"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file