1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-05 17:57:03 +01:00

Add ZeTime settings: choose on which wrist you wear the watch and set screen on duration.

This commit is contained in:
Sebastian Kranz 2018-09-06 14:51:29 +02:00
parent 88ba3e8e14
commit ca7108c153
5 changed files with 83 additions and 0 deletions

View File

@ -55,6 +55,7 @@ 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_DISPLAY_TIMEOUT = (byte) 0x25;
public static final byte CMD_USER_INFO = (byte) 0x30;
public static final byte CMD_USAGE_HABITS = (byte) 0x31;
public static final byte CMD_USER_NAME = (byte) 0x32;
@ -105,4 +106,12 @@ 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;
// watch settings
public static final String PREF_WRIST = "zetime_wrist";
public static final byte WEAR_ON_LEFT_WRIST = (byte) 0x00;
public static final byte WEAR_ON_RIGHT_WRIST = (byte) 0x01;
public static final String PREF_SCREENTIME = "zetime_screentime";
public static final int MAX_SCREEN_ON_TIME = 0xffff;
}

View File

@ -120,6 +120,8 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
builder.notify(notifyCharacteristic, true);
requestDeviceInfo(builder);
requestBatteryInfo(builder);
setWrist(builder);
setScreenTime(builder);
requestActivityInfo(builder);
synchronizeTime(builder);
@ -1153,4 +1155,45 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
ZeTimeConstants.CMD_END};
sendMsgToWatch(builder, timeSync);
}
// function serving the settings
private void setWrist(TransactionBuilder builder)
{
String value = GBApplication.getPrefs().getString(ZeTimeConstants.PREF_WRIST,"left");
byte[] wrist = {ZeTimeConstants.CMD_PREAMBLE,
ZeTimeConstants.CMD_USAGE_HABITS,
ZeTimeConstants.CMD_SEND,
(byte)0x1,
(byte)0x0,
ZeTimeConstants.WEAR_ON_LEFT_WRIST,
ZeTimeConstants.CMD_END};
if (value.equals("right")) {
wrist[5] = ZeTimeConstants.WEAR_ON_RIGHT_WRIST;
}
LOG.warn("Wrist: " + wrist[5]);
sendMsgToWatch(builder, wrist);
}
private void setScreenTime(TransactionBuilder builder)
{
int value = GBApplication.getPrefs().getInt(ZeTimeConstants.PREF_SCREENTIME, 30);
if(value > ZeTimeConstants.MAX_SCREEN_ON_TIME)
{
GB.toast(getContext(), "Value for screen on time is greater than 18h! ", Toast.LENGTH_LONG, GB.ERROR);
value = ZeTimeConstants.MAX_SCREEN_ON_TIME;
}
byte[] screentime = {ZeTimeConstants.CMD_PREAMBLE,
ZeTimeConstants.CMD_DISPLAY_TIMEOUT,
ZeTimeConstants.CMD_SEND,
(byte)0x2,
(byte)0x0,
(byte)(value & 0xff),
(byte)(value >> 8),
ZeTimeConstants.CMD_END};
sendMsgToWatch(builder, screentime);
}
}

View File

@ -571,4 +571,8 @@
<string name="korean">Koreanisch</string>
<string name="japanese">Japanisch</string>
<!-- ZeTime Preferences -->
<string name="zetime_title_settings">ZeTime Einstellungen</string>
<string name="zetime_title_screentime">Bildschirm-An-Dauer in Sekunden</string>
</resources>

View File

@ -205,6 +205,10 @@
<string name="preferences_id115_settings">ID115 settings</string>
<string name="prefs_screen_orientation">Screen orientation</string>
<!-- ZeTime Preferences -->
<string name="zetime_title_settings">ZeTime settings</string>
<string name="zetime_title_screentime">Screen on duration in seconds</string>
<!-- Auto export preferences -->
<string name="pref_header_auto_export">Auto export</string>
<string name="pref_title_auto_export_enabled">Auto export enabled</string>

View File

@ -701,6 +701,29 @@
android:summary="%s" />
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen
android:icon="@drawable/ic_device_default"
android:key="pref_key_zetime"
android:title="@string/zetime_title_settings">
<PreferenceCategory
android:key="pref_category_zetime_general"
android:title="@string/pref_header_general">
<ListPreference
android:defaultValue="left"
android:entries="@array/wearside"
android:entryValues="@array/wearside_values"
android:key="zetime_wrist"
android:title="@string/miband_prefs_wearside"
android:summary="%s" />
<EditTextPreference
android:inputType="number"
android:maxLength="5"
android:defaultValue="30"
android:key="zetime_screentime"
android:title="@string/zetime_title_screentime"/>
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory