From 037c037032651ac9669baf4596bd23825d582017 Mon Sep 17 00:00:00 2001 From: mamutcho Date: Mon, 23 Dec 2019 13:33:39 +0200 Subject: [PATCH] Add option to force time sync. --- .../watchxplus/WatchXPlusConstants.java | 2 +- .../watchxplus/WatchXPlusDeviceSupport.java | 24 +++++++++++-------- app/src/main/res/values-bg/strings.xml | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- .../main/res/xml/watchxplus_preferences.xml | 8 +++---- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WatchXPlusConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WatchXPlusConstants.java index 2325990b7..caa62a20d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WatchXPlusConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WatchXPlusConstants.java @@ -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; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java index fa00d6471..615d836a7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java @@ -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 "); - } + LOG.info(" Auto set time "); + enableCalibration(true); + setTime(BLETypeConversions.createCalendar()); + enableCalibration(false); } 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"); + } } } diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index e61697d1a..65169e11a 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -316,8 +316,8 @@ Включи напомняне за активност Период на неактивност (минути) Език - Синхронизирай часа - Синхронизирай дата и час при свързване + Принудително синхронизирай часа + Принудително синхронизирай дата и час при свързване. Стрелките може да показват грешно време. Известия и Обаждания Наблюдение/анализ на съня diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 45f21568f..90d3827a0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -222,8 +222,8 @@ Inactivity time interval is from DND setting Enable inactivity reminder Inactivity period (minutes) - Synchronize time - On reconnect auto synchronize time + Force synchronize time + Force auto synchronize time on reconnect. Analog hands may show incorrect time! Language diff --git a/app/src/main/res/xml/watchxplus_preferences.xml b/app/src/main/res/xml/watchxplus_preferences.xml index 9b50866a1..e9dcb88b9 100644 --- a/app/src/main/res/xml/watchxplus_preferences.xml +++ b/app/src/main/res/xml/watchxplus_preferences.xml @@ -91,10 +91,10 @@ + 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" />