mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-29 12:05:53 +01:00
Add option to force time sync.
This commit is contained in:
parent
57df6ec703
commit
037c037032
@ -52,7 +52,7 @@ public final class WatchXPlusConstants extends LenovoWatchConstants {
|
|||||||
public static final String PREF_LONGSIT_PERIOD = "pref_watchxplus_longsit_period";
|
public static final String PREF_LONGSIT_PERIOD = "pref_watchxplus_longsit_period";
|
||||||
public static final String PREF_WXP_LANGUAGE = "pref_wxp_language";
|
public static final String PREF_WXP_LANGUAGE = "pref_wxp_language";
|
||||||
public static final String PREF_POWER_MODE = "pref_wxp_power";
|
public static final String PREF_POWER_MODE = "pref_wxp_power";
|
||||||
public static final String PREF_ONLY_DIGITAL = "pref_wxp_only_digital";
|
public static final String PREF_FORCE_TIME = "pref_wxp_force_time";
|
||||||
|
|
||||||
// time format constants
|
// time format constants
|
||||||
public static final byte ARG_SET_TIMEMODE_24H = 0x00;
|
public static final byte ARG_SET_TIMEMODE_24H = 0x00;
|
||||||
|
@ -353,22 +353,26 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
nowDevice.set(Calendar.DAY_OF_WEEK, Conversion.fromBcd8(time[16]) + 1);
|
nowDevice.set(Calendar.DAY_OF_WEEK, Conversion.fromBcd8(time[16]) + 1);
|
||||||
|
|
||||||
long timeDiff = (Math.abs(now.getTimeInMillis() - nowDevice.getTimeInMillis())) / 1000;
|
long timeDiff = (Math.abs(now.getTimeInMillis() - nowDevice.getTimeInMillis())) / 1000;
|
||||||
|
|
||||||
LOG.info(" Time diff: " + timeDiff);
|
LOG.info(" Time diff: " + timeDiff);
|
||||||
if (10 < timeDiff && timeDiff < 120) {
|
if (10 < timeDiff && timeDiff < 120) {
|
||||||
LOG.info(" Set new time ");
|
LOG.info(" Auto set time ");
|
||||||
boolean onlyDigital = prefs.getBoolean(WatchXPlusConstants.PREF_ONLY_DIGITAL, true);
|
enableCalibration(true);
|
||||||
if (onlyDigital) {
|
setTime(BLETypeConversions.createCalendar());
|
||||||
LOG.info(" Auto set time ");
|
enableCalibration(false);
|
||||||
enableCalibration(true);
|
|
||||||
setTime(BLETypeConversions.createCalendar());
|
|
||||||
enableCalibration(false);
|
|
||||||
} else {
|
|
||||||
LOG.info(" Auto set time is OFF ");
|
|
||||||
}
|
|
||||||
} else if (timeDiff > 120) {
|
} else if (timeDiff > 120) {
|
||||||
LOG.info(" Time diff is too big ");
|
LOG.info(" Time diff is too big ");
|
||||||
GB.toast("Manual time calibration needed!", Toast.LENGTH_LONG, GB.WARN);
|
GB.toast("Manual time calibration needed!", Toast.LENGTH_LONG, GB.WARN);
|
||||||
sendNotification(WatchXPlusConstants.NOTIFICATION_CHANNEL_DEFAULT, "Calibrate time");
|
sendNotification(WatchXPlusConstants.NOTIFICATION_CHANNEL_DEFAULT, "Calibrate time");
|
||||||
|
boolean forceTime = prefs.getBoolean(WatchXPlusConstants.PREF_FORCE_TIME, false);
|
||||||
|
if (forceTime) {
|
||||||
|
LOG.info(" Force set time ");
|
||||||
|
enableCalibration(true);
|
||||||
|
setTime(BLETypeConversions.createCalendar());
|
||||||
|
enableCalibration(false);
|
||||||
|
GB.toast("Check analog time!", Toast.LENGTH_LONG, GB.WARN);
|
||||||
|
sendNotification(WatchXPlusConstants.NOTIFICATION_CHANNEL_DEFAULT, "Check analog time");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,8 +316,8 @@
|
|||||||
<string name="prefs_wxp_longsit_switch">Включи напомняне за активност</string>
|
<string name="prefs_wxp_longsit_switch">Включи напомняне за активност</string>
|
||||||
<string name="pref_wxp_title_longsit">Период на неактивност (минути)</string>
|
<string name="pref_wxp_title_longsit">Период на неактивност (минути)</string>
|
||||||
<string name="wxp_language_title">Език</string>
|
<string name="wxp_language_title">Език</string>
|
||||||
<string name="pref_wxp_title_only_digital">Синхронизирай часа</string>
|
<string name="pref_wxp_title_force_time">Принудително синхронизирай часа</string>
|
||||||
<string name="pref_wxp_title_only_digital_sum">Синхронизирай дата и час при свързване</string>
|
<string name="pref_wxp_title_force_time_sum">Принудително синхронизирай дата и час при свързване. Стрелките може да показват грешно време.</string>
|
||||||
<string name="pref_header_wxp_call_notification">Известия и Обаждания</string>
|
<string name="pref_header_wxp_call_notification">Известия и Обаждания</string>
|
||||||
|
|
||||||
<string name="title_activity_sleepmonitor">Наблюдение/анализ на съня</string>
|
<string name="title_activity_sleepmonitor">Наблюдение/анализ на съня</string>
|
||||||
|
@ -222,8 +222,8 @@
|
|||||||
<string name="pref_wxp_longsit_switch_summary">Inactivity time interval is from DND setting</string>
|
<string name="pref_wxp_longsit_switch_summary">Inactivity time interval is from DND setting</string>
|
||||||
<string name="prefs_wxp_longsit_switch">Enable inactivity reminder</string>
|
<string name="prefs_wxp_longsit_switch">Enable inactivity reminder</string>
|
||||||
<string name="pref_wxp_title_longsit">Inactivity period (minutes)</string>
|
<string name="pref_wxp_title_longsit">Inactivity period (minutes)</string>
|
||||||
<string name="pref_wxp_title_only_digital">Synchronize time</string>
|
<string name="pref_wxp_title_force_time">Force synchronize time</string>
|
||||||
<string name="pref_wxp_title_only_digital_sum">On reconnect auto synchronize time</string>
|
<string name="pref_wxp_title_force_time_sum">Force auto synchronize time on reconnect. Analog hands may show incorrect time!</string>
|
||||||
<string name="wxp_language_title">Language</string>
|
<string name="wxp_language_title">Language</string>
|
||||||
|
|
||||||
<!-- Makibes HR3 Preferences -->
|
<!-- Makibes HR3 Preferences -->
|
||||||
|
@ -91,10 +91,10 @@
|
|||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:layout="@layout/preference_checkbox"
|
android:layout="@layout/preference_checkbox"
|
||||||
android:defaultValue="true"
|
android:defaultValue="false"
|
||||||
android:key="pref_wxp_only_digital"
|
android:key="pref_wxp_force_time"
|
||||||
android:summary="@string/pref_wxp_title_only_digital_sum"
|
android:summary="@string/pref_wxp_title_force_time_sum"
|
||||||
android:title="@string/pref_wxp_title_only_digital" />
|
android:title="@string/pref_wxp_title_force_time" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_category_watchxplus_calibration"
|
android:key="pref_category_watchxplus_calibration"
|
||||||
|
Loading…
Reference in New Issue
Block a user