1
0
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:
mamutcho 2019-12-23 13:33:39 +02:00
parent 57df6ec703
commit 037c037032
5 changed files with 23 additions and 19 deletions

View File

@ -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_WXP_LANGUAGE = "pref_wxp_language";
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
public static final byte ARG_SET_TIMEMODE_24H = 0x00;

View File

@ -353,22 +353,26 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport {
nowDevice.set(Calendar.DAY_OF_WEEK, Conversion.fromBcd8(time[16]) + 1);
long timeDiff = (Math.abs(now.getTimeInMillis() - nowDevice.getTimeInMillis())) / 1000;
LOG.info(" Time diff: " + timeDiff);
if (10 < timeDiff && timeDiff < 120) {
LOG.info(" Set new time ");
boolean onlyDigital = prefs.getBoolean(WatchXPlusConstants.PREF_ONLY_DIGITAL, true);
if (onlyDigital) {
LOG.info(" Auto set time ");
enableCalibration(true);
setTime(BLETypeConversions.createCalendar());
enableCalibration(false);
} else {
LOG.info(" Auto set time is OFF ");
}
} else if (timeDiff > 120) {
LOG.info(" Time diff is too big ");
GB.toast("Manual time calibration needed!", Toast.LENGTH_LONG, GB.WARN);
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");
}
}
}

View File

@ -316,8 +316,8 @@
<string name="prefs_wxp_longsit_switch">Включи напомняне за активност</string>
<string name="pref_wxp_title_longsit">Период на неактивност (минути)</string>
<string name="wxp_language_title">Език</string>
<string name="pref_wxp_title_only_digital">Синхронизирай часа</string>
<string name="pref_wxp_title_only_digital_sum">Синхронизирай дата и час при свързване</string>
<string name="pref_wxp_title_force_time">Принудително синхронизирай часа</string>
<string name="pref_wxp_title_force_time_sum">Принудително синхронизирай дата и час при свързване. Стрелките може да показват грешно време.</string>
<string name="pref_header_wxp_call_notification">Известия и Обаждания</string>
<string name="title_activity_sleepmonitor">Наблюдение/анализ на съня</string>

View File

@ -222,8 +222,8 @@
<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="pref_wxp_title_longsit">Inactivity period (minutes)</string>
<string name="pref_wxp_title_only_digital">Synchronize time</string>
<string name="pref_wxp_title_only_digital_sum">On reconnect auto synchronize time</string>
<string name="pref_wxp_title_force_time">Force 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>
<!-- Makibes HR3 Preferences -->

View File

@ -91,10 +91,10 @@
</PreferenceScreen>
<CheckBoxPreference
android:layout="@layout/preference_checkbox"
android:defaultValue="true"
android:key="pref_wxp_only_digital"
android:summary="@string/pref_wxp_title_only_digital_sum"
android:title="@string/pref_wxp_title_only_digital" />
android:defaultValue="false"
android:key="pref_wxp_force_time"
android:summary="@string/pref_wxp_title_force_time_sum"
android:title="@string/pref_wxp_title_force_time" />
</PreferenceCategory>
<PreferenceCategory
android:key="pref_category_watchxplus_calibration"