From e3f838afa043975a2045c0f68b9d4ba35daaa57c Mon Sep 17 00:00:00 2001 From: mamutcho Date: Tue, 19 Nov 2019 20:51:37 +0200 Subject: [PATCH] Bump version ot 0.39 Redesign Settings page --- app/src/main/AndroidManifest.xml | 4 + .../activities/SettingsActivity.java | 56 ++------ .../watchxplus/WatchXPlusConstants.java | 10 +- .../WatchXPlusPreferenceActivity.java | 65 +++++++++ .../devices/lenovo/watchxplus/WorkProgress | 2 + .../watchxplus/WatchXPlusDeviceSupport.java | 53 ++++---- app/src/main/res/values-bg/strings.xml | 9 +- app/src/main/res/values/strings.xml | 10 +- app/src/main/res/xml/preferences.xml | 128 +----------------- .../main/res/xml/watchxplus_preferences.xml | 128 ++++++++++++++++++ 10 files changed, 260 insertions(+), 205 deletions(-) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WatchXPlusPreferenceActivity.java create mode 100644 app/src/main/res/xml/watchxplus_preferences.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bf0a9c242..9ba42d80e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -73,6 +73,10 @@ android:name=".devices.zetime.ZeTimePreferenceActivity" android:label="@string/zetime_title_settings" android:parentActivityName=".activities.SettingsActivity" /> + . */ + +package nodomain.freeyourgadget.gadgetbridge.devices.lenovo.watchxplus; + +import android.os.Bundle; +import android.preference.Preference; + +import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity; +import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst; + +public class WatchXPlusPreferenceActivity extends AbstractSettingsActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + addPreferencesFromResource(R.xml.watchxplus_preferences); + + // notifications + //addPreferenceHandlerFor(WatchXPlusConstants.PREF_REPEAT); + //addPreferenceHandlerFor(WatchXPlusConstants.PREF_CONTINIOUS); + //addPreferenceHandlerFor(WatchXPlusConstants.PREF_MISSED_CALL); + //addPreferenceHandlerFor(WatchXPlusConstants.PREF_MISSED_CALL_REPEAT); + //addPreferenceHandlerFor(WatchXPlusConstants.PREF_BUTTON_REJECT); + //addPreferenceHandlerFor(WatchXPlusConstants.PREF_SHAKE_REJECT); + + // settings + addPreferenceHandlerFor(WatchXPlusConstants.PREF_POWER_MODE); + addPreferenceHandlerFor(WatchXPlusConstants.PREF_WXP_LANGUAGE); + addPreferenceHandlerFor(WatchXPlusConstants.PREF_LONGSIT_PERIOD); + addPreferenceHandlerFor(WatchXPlusConstants.PREF_LONGSIT_SWITCH); + // calibration + addPreferenceHandlerFor(WatchXPlusConstants.PREF_ALTITUDE); + addPreferenceHandlerFor(WatchXPlusConstants.PREF_BP_CAL_LOW); + addPreferenceHandlerFor(WatchXPlusConstants.PREF_BP_CAL_HIGH); + addPreferenceHandlerFor(WatchXPlusConstants.PREF_BP_CAL_SWITCH); + + } + + private void addPreferenceHandlerFor(final String preferenceKey) { + Preference pref = findPreference(preferenceKey); + pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onSendConfiguration(preferenceKey); + return true; + } + }); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WorkProgress b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WorkProgress index 696bd4fa1..737a398ea 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WorkProgress +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WorkProgress @@ -25,6 +25,7 @@ NEED TO BE DONE WORK PROGRESS + Bump version to 0.39 (19.11.2019) Send notification to watch - On incoming call - add function to cancel notification on watch (04.11.2019) @@ -65,6 +66,7 @@ WORK PROGRESS - Implemented long sit reminder (inactivity reminder)[on, off, period] (17.11.2019) - Set watch language [English, Chinese] (17.11.2019) - Set watch units (metric/imperial) (17.11.2019) + - Redesign Device Settings (19.11.2019) Activity data - get steps per day 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 4b615db4c..7059d7f37 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 @@ -799,11 +799,35 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(this.getDevice().getAddress()); try { builder = performInitialized("sendConfig: " + config); - LOG.info(" config changed:" + config); switch (config) { + // settings from App Settings + case SettingsActivity.PREF_MEASUREMENT_SYSTEM: + setUnitsSettings(); + break; case ActivityUser.PREF_USER_STEPS_GOAL: setFitnessGoal(builder); break; + + // settings from App Settings -> WatchXPlus settings + case WatchXPlusConstants.PREF_POWER_MODE: + setPowerMode(); + break; + case WatchXPlusConstants.PREF_WXP_LANGUAGE: + setLanguageAndTimeFormat(builder, sharedPreferences); + break; + case WatchXPlusConstants.PREF_LONGSIT_PERIOD: + case WatchXPlusConstants.PREF_LONGSIT_SWITCH: + setLongSitHours(builder, sharedPreferences); + break; + // calibrations + case WatchXPlusConstants.PREF_ALTITUDE: + setAltitude(builder); + break; + case WatchXPlusConstants.PREF_BP_CAL_SWITCH: + sendBloodPressureCalibration(); + break; + + // settings from device card case WatchXPlusConstants.PREF_ACTIVATE_DISPLAY: setHeadsUpScreen(builder, sharedPreferences); getShakeStatus(builder); @@ -820,21 +844,6 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { case WatchXPlusConstants.PREF_DO_NOT_DISTURB_END: setQuiteHours(builder, sharedPreferences); break; - case "BP_CAL": - sendBloodPressureCalibration(); - break; - case "LONG_SIT": - setLongSitHours(builder, sharedPreferences); - break; - case "WXP_POWER_MODE": - setPowerMode(config); - break; - case "WXP_LANGUAGE": - setLanguageAndTimeFormat(builder, sharedPreferences); - break; - case "measurement_system": - setUnitsSettings(); - break; } builder.queue(getQueue()); } catch (IOException e) { @@ -987,15 +996,14 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { } /** set watch power - * @param config * switch watch power mode * modes (0- normal, 1- energysaving, 2- only watch) */ - private WatchXPlusDeviceSupport setPowerMode(String config) { - int settingRead = prefs.getInt("wxp_power_mode", 0); + private WatchXPlusDeviceSupport setPowerMode() { + int settingRead = prefs.getInt(WatchXPlusConstants.PREF_POWER_MODE, 0); byte[] bArr = new byte[1]; bArr[0] = (byte) settingRead; - LOG.info(" setting: " + config); + LOG.info(" setting power mode to: " + settingRead); try { TransactionBuilder builder = performInitialized("setPowerMode"); builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), @@ -1882,8 +1890,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { // calibrate altitude private WatchXPlusDeviceSupport setAltitude(TransactionBuilder transactionBuilder) { - int value = WatchXPlusDeviceCoordinator.getAltitude(getDevice().getAddress()); - int mAltitude = value; + int mAltitude = WatchXPlusDeviceCoordinator.getAltitude(getDevice().getAddress()); if (mAltitude < 0) { mAltitude = (Math.abs(mAltitude) ^ 65535) + 1; } @@ -1897,7 +1904,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { buildCommand(WatchXPlusConstants.CMD_ALTITUDE, WatchXPlusConstants.WRITE_VALUE, bArr)); - //LOG.info(" setAltitude: " + mAltitude); + LOG.info(" setAltitude: " + mAltitude); return this; } diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index f2a48350d..606bcc473 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -293,7 +293,8 @@ Известявай докато телефона звъни Известие за пропуснато обаждане Watch X Plus настройки - Настройки на известията + Известия при обаждане + Известия при пропуснато обаждане Изкл. - заглуши, Вкл. - откажи Бутона заглушава/отказва повикване Повтаря действието на бутона @@ -309,14 +310,16 @@ Нормален Икономичен Само часовник - Повтаряй известие за пропуснато повикване всяка минута за X пъти - Повтаряй известието за пропуснато повикване + Повтаряй известие за пропуснато повикване всяка минута за X пъти + Повтаряй известието за пропуснато повикване + Управление на обажданията Напомняне за бездействие Напомняй ако няма активност за повече от X минути Времевия интервал е от настройката за DND Включи напомняне за активност Период на неактивност (минути) Език + Известия и Обаждания Наблюдение/анализ на съня Съхраняване на log файлове diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c85a80697..2e8a6af54 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -199,7 +199,9 @@ Vibration during phone ring Vibration on missed call Watch X Plus settings - Notification settings + Notifications and Calls + Call notifications + MissCall notifications Off - ignore, On - reject Button ignore/reject call Duplicates watch button action @@ -215,14 +217,16 @@ Normal Power saving Only watch - Repeat missed call notification every minute for X times - Repeat missed call notification + Repeat missed call notification every minute for X times + Repeat missed call notification + Call Handling Inactivity reminder Remind if there is no activity for more than X minutes Inactivity time interval is from DND setting Enable inactivity reminder Inactivity period (minutes) Language + Makibes HR3 settings diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index c8c0f3f0b..7839cd3a5 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -575,134 +575,10 @@ android:key="pref_key_zetime" android:title="@string/zetime_title_settings"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:title="@string/preferences_watchxplus_settings"/> diff --git a/app/src/main/res/xml/watchxplus_preferences.xml b/app/src/main/res/xml/watchxplus_preferences.xml new file mode 100644 index 000000000..68348e7d7 --- /dev/null +++ b/app/src/main/res/xml/watchxplus_preferences.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file