From 7dab1cb0f749beda3985723318b8576b94971f43 Mon Sep 17 00:00:00 2001 From: mamutcho Date: Wed, 22 Apr 2020 23:36:09 +0300 Subject: [PATCH] Move settings to per device (gear icon) Add missing files --- app/src/main/AndroidManifest.xml | 6 +- .../activities/SettingsActivity.java | 12 -- .../DeviceSettingsPreferenceConst.java | 9 + .../DeviceSpecificSettingsFragment.java | 17 ++ .../watchxplus/WatchXPlusConstants.java | 38 ++-- .../WatchXPlusDeviceCoordinator.java | 111 ++-------- .../WatchXPlusPreferenceActivity.java | 64 ------ .../watchxplus/WatchXPlusDeviceSupport.java | 196 ++++++++---------- app/src/main/res/values-bg/strings.xml | 73 ++++--- app/src/main/res/values/arrays.xml | 21 +- app/src/main/res/values/strings.xml | 71 +++---- ...settings_disconnectnotification_noshed.xml | 8 + ...evicesettings_liftwrist_display_noshed.xml | 8 + .../main/res/xml/devicesettings_longsit.xml | 35 ++++ .../res/xml/devicesettings_power_mode.xml | 11 + .../res/xml/devicesettings_watchxplus.xml | 102 +++++++++ app/src/main/res/xml/preferences.xml | 6 - .../main/res/xml/watchxplus_preferences.xml | 133 ------------ 18 files changed, 400 insertions(+), 521 deletions(-) delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WatchXPlusPreferenceActivity.java create mode 100644 app/src/main/res/xml/devicesettings_disconnectnotification_noshed.xml create mode 100644 app/src/main/res/xml/devicesettings_liftwrist_display_noshed.xml create mode 100644 app/src/main/res/xml/devicesettings_longsit.xml create mode 100644 app/src/main/res/xml/devicesettings_power_mode.xml create mode 100644 app/src/main/res/xml/devicesettings_watchxplus.xml delete 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 d4de4f2a2..77f7f75a2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -75,10 +75,6 @@ android:name=".devices.zetime.ZeTimePreferenceActivity" android:label="@string/zetime_title_settings" android:parentActivityName=".activities.SettingsActivity" /> - + android:label="@string/title_activity_LenovoWatch_calibration" /> . */ - -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; - -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/service/devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java index 89aaadac9..7699b0a97 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 @@ -90,6 +90,9 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; +import static nodomain.freeyourgadget.gadgetbridge.GBApplication.getContext; +import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_LANGUAGE; + public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { private static final Prefs prefs = GBApplication.getPrefs(); @@ -476,7 +479,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { 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); + boolean forceTime = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(WatchXPlusConstants.PREF_FORCE_TIME, false); if (forceTime) { LOG.info(" Force set time "); enableCalibration(true); @@ -626,14 +629,12 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { final int repeatDelay = 5000; // repeat delay of 5 sec (watch show call notifications for about 5 sec.) final int repeatMissedDelay = 60000; // repeat missed call delay of 60 sec // set settings for missed call - int repeatCount = WatchXPlusDeviceCoordinator.getRepeatOnCall(); - int repeatCountMissed = WatchXPlusDeviceCoordinator.getMissedCallRepeat(); - // check if repeatCount is in boundaries min=0, max=10 - if (repeatCount < 0) repeatCount = 0; - if (repeatCount > 10) repeatCount = 10; // limit repeats to 10 - // check if repeatCountMissed is in boundaries min=0, max=10 - if (repeatCountMissed < 0) repeatCountMissed = 0; - if (repeatCountMissed > 10) repeatCountMissed = 10; // limit repeats to 10 + //int repeatCount = WatchXPlusDeviceCoordinator.getRepeatOnCall(); + + final boolean continuousRing = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(WatchXPlusConstants.PREF_CONTINIOUS_RING, false); + int repeatCount = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getInt(WatchXPlusConstants.PREF_REPEAT_RING, 0); + final boolean enableMissedCall = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(WatchXPlusConstants.PREF_MISSED_CALL_ENABLE, false); + int repeatCountMissed = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getInt(WatchXPlusConstants.PREF_MISSED_CALL_REPEAT, 0); switch (callSpec.command) { case CallSpec.CALL_INCOMING: @@ -652,7 +653,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { handler.postDelayed(new Runnable() { public void run() { // Actions to do after repeatDelay seconds - if (((isRinging) && (remainingRepeats > 0)) || ((isRinging) && (WatchXPlusDeviceCoordinator.getContiniousVibrationOnCall()))) { + if (((isRinging) && (remainingRepeats > 0)) || ((isRinging) && (continuousRing))) { remainingRepeats = remainingRepeats - 1; sendNotification(WatchXPlusConstants.NOTIFICATION_CHANNEL_PHONE_CALL, callSpec.name); // re-run handler @@ -698,7 +699,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { if (isMissedCall) { remainingMissedRepeats = repeatCountMissed; // send missed call notification if enabled in settings - if (WatchXPlusDeviceCoordinator.getMissedCallReminder()) { + if (enableMissedCall) { LOG.info(" Missed call reminder "); sendNotification(WatchXPlusConstants.NOTIFICATION_CHANNEL_PHONE_CALL, "Missed call"); // repeat missed call notification @@ -748,7 +749,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { private void handleButtonWhenRing() { GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl(); // get saved settings if true - reject call, otherwise ignore call - boolean buttonReject = WatchXPlusDeviceCoordinator.getButtonReject(); + boolean buttonReject = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(WatchXPlusConstants.PREF_BUTTON_REJECT, false); if (buttonReject) { LOG.info(" call rejected "); isRinging = false; @@ -945,6 +946,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { public void onSendConfiguration(String config) { TransactionBuilder builder; SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(this.getDevice().getAddress()); + LOG.info(" onSendConfiguration: " + config); try { builder = performInitialized("sendConfig: " + config); switch (config) { @@ -956,39 +958,37 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { setFitnessGoal(builder); break; // settings from App Settings -> WatchXPlus settings - case WatchXPlusConstants.PREF_POWER_MODE: + case DeviceSettingsPreferenceConst.PREF_POWER_MODE: setPowerMode(); break; - case WatchXPlusConstants.PREF_WXP_LANGUAGE: - setLanguageAndTimeFormat(builder, sharedPreferences); + case WatchXPlusConstants.PREF_LANGUAGE: + setLanguageAndTimeFormat(builder); break; - case WatchXPlusConstants.PREF_LONGSIT_PERIOD: - case WatchXPlusConstants.PREF_LONGSIT_SWITCH: - setLongSitHours(builder, sharedPreferences); + + case DeviceSettingsPreferenceConst.PREF_LONGSIT_PERIOD: + case DeviceSettingsPreferenceConst.PREF_LONGSIT_SWITCH: + setLongSitHours(builder); break; // calibrations - case WatchXPlusConstants.PREF_ALTITUDE: + case DeviceSettingsPreferenceConst.PREF_ALTITUDE_CALIBRATE: setAltitude(builder); break; - case WatchXPlusConstants.PREF_BP_CAL_SWITCH: + case DeviceSettingsPreferenceConst.PREF_BUTTON_BP_CALIBRATE: sendBloodPressureCalibration(); break; // settings from device card - case WatchXPlusConstants.PREF_ACTIVATE_DISPLAY: - setHeadsUpScreen(builder, sharedPreferences); + case DeviceSettingsPreferenceConst.PREF_LIFTWRIST_NOSHED: + setHeadsUpScreen(builder); getShakeStatus(builder); break; - case WatchXPlusConstants.PREF_DISCONNECT_REMIND: - setDisconnectReminder(builder, sharedPreferences); - getDisconnectReminderStatus(builder); + case DeviceSettingsPreferenceConst.PREF_DISCONNECTNOTIF_NOSHED: + setDisconnectReminder(builder); break; case DeviceSettingsPreferenceConst.PREF_TIMEFORMAT: - setLanguageAndTimeFormat(builder, sharedPreferences); + setLanguageAndTimeFormat(builder); break; case WatchXPlusConstants.PREF_DO_NOT_DISTURB: - case WatchXPlusConstants.PREF_DO_NOT_DISTURB_START: - case WatchXPlusConstants.PREF_DO_NOT_DISTURB_END: - setDNDHours(builder, sharedPreferences); + setDNDHours(builder); break; } builder.queue(getQueue()); @@ -999,7 +999,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { @Override public void onReadConfiguration(String config) { - + LOG.info(" onReadConfiguration : " + config); } @Override @@ -1019,7 +1019,6 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { private void setLongSitHours(TransactionBuilder builder, boolean enable, int hourStart, int minuteStart, int hourEnd, int minuteEnd, int period) { LOG.info(" Setting Long sit reminder... Enabled:"+enable+" Period:"+period); LOG.info(" Setting Long sit time... Hs:"+hourEnd+" Ms:"+minuteEnd+" He:"+hourStart+" Me:"+minuteStart); - LOG.info(" Setting Long sit DND time... Hs:"+hourStart+" Ms:"+minuteStart+" He:"+hourEnd+" Me:"+minuteEnd); // set Long Sit reminder time byte[] command = WatchXPlusConstants.CMD_INACTIVITY_REMINDER_SET; @@ -1043,14 +1042,15 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { /** get Long sit settings from app, and send it to watch * @param builder - transaction builder - * @param sharedPreferences - shared preferences */ - private void setLongSitHours(TransactionBuilder builder, SharedPreferences sharedPreferences) { + private void setLongSitHours(TransactionBuilder builder) { Calendar start = new GregorianCalendar(); Calendar end = new GregorianCalendar(); - boolean enable = WatchXPlusDeviceCoordinator.getLongSitHours(sharedPreferences, start, end); + boolean enable = WatchXPlusDeviceCoordinator.getLongSitHours(gbDevice.getAddress(), start, end); if (enable) { - int period = prefs.getInt(WatchXPlusConstants.PREF_LONGSIT_PERIOD, 60); + String periodString = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_LONGSIT_PERIOD, "60"); + int period = Integer.parseInt(periodString); + this.setLongSitHours(builder, enable, start.get(Calendar.HOUR_OF_DAY), start.get(Calendar.MINUTE), end.get(Calendar.HOUR_OF_DAY), end.get(Calendar.MINUTE), @@ -1114,12 +1114,11 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { /** get DND settings from app, and send it to watch * @param builder - transaction builder - * @param sharedPreferences - shared preferences */ - private void setDNDHours(TransactionBuilder builder, SharedPreferences sharedPreferences) { + private void setDNDHours(TransactionBuilder builder) { Calendar start = new GregorianCalendar(); Calendar end = new GregorianCalendar(); - boolean enable = WatchXPlusDeviceCoordinator.getDNDHours(sharedPreferences, start, end); + boolean enable = WatchXPlusDeviceCoordinator.getDNDHours(gbDevice.getAddress(), start, end); if (enable) { this.setDNDHours(builder, enable, start.get(Calendar.HOUR_OF_DAY), start.get(Calendar.MINUTE), @@ -1136,12 +1135,21 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { * modes (0- normal, 1- energysaving, 2- only watch) */ private void setPowerMode() { - int settingRead = prefs.getInt(WatchXPlusConstants.PREF_POWER_MODE, 0); + byte setWatchPowerMode = 0x00; + String powermodeStr = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_POWER_MODE, "0"); + if (powermodeStr.equals("0")) { + setWatchPowerMode = 0x00; + } else if (powermodeStr.equals("1")) { + setWatchPowerMode = 0x01; + } else if (powermodeStr.equals("2")) { + setWatchPowerMode = 0x02; + } + byte[] bArr = new byte[1]; - bArr[0] = (byte) settingRead; - LOG.info(" setting power mode to: " + settingRead); + bArr[0] = (byte) setWatchPowerMode; + LOG.info(" setting power mode to: " + setWatchPowerMode); try { - TransactionBuilder builder = performInitialized("setPowerMode"); + TransactionBuilder builder = performInitialized("setWatchPowerMode"); builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), buildCommand(WatchXPlusConstants.CMD_POWER_MODE, WatchXPlusConstants.TASK, @@ -1212,18 +1220,18 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { */ private void sendBloodPressureCalibration() { try { - int beginCalibration = prefs.getInt(WatchXPlusConstants.PREF_BP_CAL_SWITCH, 0); - if (beginCalibration == 1) { + String beginCalibration = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_BUTTON_BP_CALIBRATE, "0"); + if (beginCalibration.equals("1")) { LOG.info(" Calibrating BP - cancel " + beginCalibration); return; } - int mLowP = prefs.getInt(WatchXPlusConstants.PREF_BP_CAL_LOW, 80); - int mHighP = prefs.getInt(WatchXPlusConstants.PREF_BP_CAL_HIGH, 130); + String mLowPString = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(WatchXPlusConstants.PREF_BP_CAL_LOW, "80"); + int mLowP = Integer.parseInt(mLowPString); + String mHighPString = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(WatchXPlusConstants.PREF_BP_CAL_HIGH, "130"); + int mHighP = Integer.parseInt(mHighPString); LOG.warn(" Calibrating BP ... LowP=" + mLowP + " HighP="+mHighP); GB.toast("Calibrating BP...", Toast.LENGTH_LONG, GB.INFO); - - TransactionBuilder builder = performInitialized("bpCalibrate"); - + TransactionBuilder builder = performInitialized("bpCalibrate"); byte[] command = WatchXPlusConstants.CMD_BP_CALIBRATION; byte mStart = 0x01; // initiate calibration @@ -1290,29 +1298,6 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { } } - - - // not working!!! - private void testNewCommands() { - try { - TransactionBuilder builder = performInitialized("test"); - - int first = prefs.getInt("wxp_newcmd_first", 0); - int second = prefs.getInt("wxp_newcmd_second", 0); - byte[] command = new byte[]{(byte) first, (byte) second}; - - LOG.info(" testing new command " + Arrays.toString(command)); - builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), - buildCommand(command, - WatchXPlusConstants.READ_VALUE)); - - builder.queue(getQueue()); - } catch (IOException e) { - LOG.warn(" Unable to request new command ", e); - } - } - - @Override public void onSendWeather(WeatherSpec weatherSpec) { try { @@ -2020,13 +2005,12 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { // read preferences private void syncPreferences(TransactionBuilder transaction) { - SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(this.getDevice().getAddress()); - this.setHeadsUpScreen(transaction, sharedPreferences); // lift wirst to screen on - this.setDNDHours(transaction, sharedPreferences); // DND - this.setDisconnectReminder(transaction, sharedPreferences); // disconnect reminder - this.setLanguageAndTimeFormat(transaction, sharedPreferences); // set time mode 12/24h + this.setHeadsUpScreen(transaction); // lift wirst to screen on + this.setDNDHours(transaction); // DND + this.setDisconnectReminder(transaction); // disconnect reminder + this.setLanguageAndTimeFormat(transaction); // set time mode 12/24h this.setAltitude(transaction); // set altitude calibration - this.setLongSitHours(transaction, sharedPreferences); // set Long sit reminder + this.setLongSitHours(transaction); // set Long sit reminder ActivityUser activityUser = new ActivityUser(); this.setPersonalInformation(transaction, activityUser.getHeightCm(), activityUser.getWeightKg(), activityUser.getAge(),activityUser.getGender()); @@ -2066,15 +2050,11 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { evaluateGBDeviceEvent(findPhoneEvent); } } - // Set Lift Wrist to Light Screen based on saved preferences - private void setHeadsUpScreen(TransactionBuilder transactionBuilder, SharedPreferences sharedPreferences) { - this.setHeadsUpScreen(transactionBuilder, - WatchXPlusDeviceCoordinator.shouldEnableHeadsUpScreen(sharedPreferences)); - } // Command to toggle Lift Wrist to Light Screen, and shake to ignore/reject call - private void setHeadsUpScreen(TransactionBuilder transactionBuilder, boolean enable) { - boolean shakeReject = WatchXPlusDeviceCoordinator.getShakeReject(); + private void setHeadsUpScreen(TransactionBuilder transactionBuilder) { + boolean enable = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_LIFTWRIST_NOSHED, false); + boolean shakeReject = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(WatchXPlusConstants.PREF_SHAKE_REJECT, false); byte refuseCall = 0x00; // force shake wrist to ignore/reject call to OFF // returned characteristic is equal with button press while ringing if (shakeReject) refuseCall = 0x01; @@ -2094,24 +2074,15 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { liftScreen)); } - private void setDisconnectReminder(TransactionBuilder transactionBuilder, SharedPreferences sharedPreferences) { - this.setDisconnectReminder(transactionBuilder, - WatchXPlusDeviceCoordinator.shouldEnableDisconnectReminder(sharedPreferences)); - } - - private void setDisconnectReminder(TransactionBuilder transactionBuilder, boolean enable) { + // command to set disconnect reminder + private void setDisconnectReminder(TransactionBuilder transactionBuilder) { + boolean enable = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_DISCONNECTNOTIF_NOSHED, false); transactionBuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), buildCommand(WatchXPlusConstants.CMD_DISCONNECT_REMIND, WatchXPlusConstants.WRITE_VALUE, new byte[]{(byte) (enable ? 0x01 : 0x00)})); } -// Request status of Disconnect reminder - private void getDisconnectReminderStatus(TransactionBuilder transactionBuilder) { - transactionBuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), - buildCommand(WatchXPlusConstants.CMD_DISCONNECT_REMIND, - WatchXPlusConstants.READ_VALUE)); - } // Request status of Lift Wrist to Light Screen, and Shake to Ignore/Reject Call private void getShakeStatus(TransactionBuilder transactionBuilder) { transactionBuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), @@ -2121,7 +2092,8 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { // calibrate altitude private void setAltitude(TransactionBuilder transactionBuilder) { - int mAltitude = WatchXPlusDeviceCoordinator.getAltitude(); + String altitudeString = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_ALTITUDE_CALIBRATE, "200"); + int mAltitude = Integer.parseInt(altitudeString); if (mAltitude < 0) { mAltitude = (Math.abs(mAltitude) ^ 65535) + 1; } @@ -2139,22 +2111,32 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { } // set time format - private void setLanguageAndTimeFormat(TransactionBuilder transactionBuilder, byte timeMode, byte language) { + private void setLanguageAndTimeFormat(TransactionBuilder transactionBuilder) { + byte setLanguage, setTimeMode; + String languageString = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(WatchXPlusConstants.PREF_LANGUAGE, "1"); + if (languageString == null || languageString.equals("1")) { + setLanguage = 0x01; + } else { + setLanguage = 0x00; + } + + String timeformatString = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, "1"); + assert timeformatString != null; + if (timeformatString.equals(getContext().getString(R.string.p_timeformat_24h))) { + setTimeMode = WatchXPlusConstants.ARG_SET_TIMEMODE_24H; + } else { + setTimeMode = WatchXPlusConstants.ARG_SET_TIMEMODE_12H; + } + byte[] bArr = new byte[2]; - bArr[0] = language; //byte[08] language - bArr[1] = timeMode; //byte[09] time + bArr[0] = setLanguage; //byte[08] language + bArr[1] = setTimeMode; //byte[09] time transactionBuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), buildCommand(WatchXPlusConstants.CMD_TIME_LANGUAGE, WatchXPlusConstants.WRITE_VALUE, bArr)); } - private void setLanguageAndTimeFormat(TransactionBuilder transactionBuilder, SharedPreferences sharedPreferences) { - this.setLanguageAndTimeFormat(transactionBuilder, - WatchXPlusDeviceCoordinator.getTimeMode(sharedPreferences), - WatchXPlusDeviceCoordinator.getLanguage()); - } - @Override public void dispose() { LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext()); diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 161bb7694..ba67773ef 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -283,43 +283,42 @@ Сверяване Watch 9 свързване Watch 9 сверяване - - Watch X Plus сверяване - Единици - Формат на часа - Калибриране на височината - Повтаряй известие за позвъняване - Възможни стойности min=0, max=10 - Известявай докато телефона звъни - Watch X Plus настройки - Изкл. - заглуши, Вкл. - откажи - Бутона заглушава/отказва повикване - Повтаря действието на бутона - Разклати за заглушаване/отказване на повикването - Калибриране на кръвно налягане - Кръвно налягане DIASTOLIC (ниска) - Кръвно налягане SYSTOLIC (висока) - Калибриране - Натисни тук за калибриране - Калибриране на сензорите - Настройки на устройството - Режим на часовника - Нормален - Икономичен - Само часовник - Повтаряй известие за пропуснато повикване всяка минута за X пъти - Повтаряй известието за пропуснато повикване - Известявай за пропуснато повикване - Управление на обажданията - Напомняне за бездействие - Напомняй ако няма активност за повече от X минути - Времевия интервал е от настройката за DND - Включи напомняне за активност - Период на неактивност (минути) - Език - Принудително синхронизирай часа - Принудително синхронизирай дата и час при свързване. Стрелките може да показват грешно време. - Известия и Обаждания + Няма да се получават известия докато е активно + + Watch X Plus сверяване + + Известия и Обаждания + Повтаряй известие за позвъняване + Известявай докато телефона звъни + Известявай за пропуснато повикване + Повтаря се на всяка минута + Повтаряй за Х минути + Управление на обажданията + Бутона заглушава/отказва повикване + Изкл. - заглуши, Вкл. - откажи + Разклати за заглушаване/отказване на повикването + Повтаря действието на бутона + + Настройки на устройството + Принудително синхронизирай часа + Принудително синхронизирай дата и час при свързване. Стрелките може да показват грешно време. + + Калибриране на сензорите + Калибриране на височината + Калибриране на кръвно налягане + Кръвно налягане DIASTOLIC (ниска) + Кръвно налягане SYSTOLIC (висока) + Калибриране + Натисни тук за калибриране + + Напомни ако няма активност за повече от X минути + Напомняне за бездействие + Период на неактивност (минути) + + Режим на часовника + Нормален + Икономичен + Само часовник Наблюдение/анализ на съня Съхраняване на log файлове Инициализиране diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 8e108cb49..76ee5ee9e 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -69,28 +69,29 @@ never - + @string/simplified_chinese @string/english - + 0 1 - - @string/prefs_wxp_button_bp_calibration + + @string/prefs_sensors_button_bp_calibration @string/Cancel - + 0 1 - - @string/wxp_mode_normal - @string/wxp_mode_saving - @string/wxp_mode_watch + + + @string/power_mode_normal + @string/power_mode_saving + @string/power_mode_watch - + 0 1 2 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7c583cc4b..571371a35 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -199,43 +199,40 @@ All day heart rate measurement HPlus/Makibes settings - Watch X Plus calibration - Units - Time format - Altitude calibration - Repeat call notification - Possible values min=0, max=10 - Vibration during phone ring - Watch X Plus settings - Notifications and Calls - Off - ignore, On - reject - Button ignore/reject call - Duplicates watch button action - Shake wrist ignore/reject call - Blood Pressure calibration - Blood Pressure DIASTOLIC (low) - Blood Pressure SYSTOLIC (high) - Calibration - Press here to begin calibration - Sensors Calibration - Device settings - Watch mode - Normal - Power saving - Only watch - Repeat missed call notification every minute for X times - Repeat missed call notification - Notify for missed call - 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) - Force synchronize time - Force auto synchronize time on reconnect. Analog hands may show incorrect time! - Language - + Watch X Plus calibration + + Notifications and Calls + Repeat call notification + Notification during phone ring + Notify for missed call + Repeats on every minute + Repeat for X minutes + Call Handling + Button ignore/reject call + Off - ignore, On - reject + Shake wrist ignore/reject call + Duplicates watch button action + + Device settings + Force synchronize time + Force auto synchronize time on reconnect. Analog hands may show incorrect time! + + Sensors Calibration + Altitude calibration + Blood Pressure calibration + Blood Pressure DIASTOLIC (low) + Blood Pressure SYSTOLIC (high) + Calibration + Press here to begin calibration + + Remind if there are inactivity for X minutes + Inactivity reminder + Inactivity period (minutes) + + Watch power mode + Normal + Power saving + Only watch Makibes HR3 settings diff --git a/app/src/main/res/xml/devicesettings_disconnectnotification_noshed.xml b/app/src/main/res/xml/devicesettings_disconnectnotification_noshed.xml new file mode 100644 index 000000000..c4d384e03 --- /dev/null +++ b/app/src/main/res/xml/devicesettings_disconnectnotification_noshed.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/devicesettings_liftwrist_display_noshed.xml b/app/src/main/res/xml/devicesettings_liftwrist_display_noshed.xml new file mode 100644 index 000000000..9cd0ccba0 --- /dev/null +++ b/app/src/main/res/xml/devicesettings_liftwrist_display_noshed.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/devicesettings_longsit.xml b/app/src/main/res/xml/devicesettings_longsit.xml new file mode 100644 index 000000000..0f199cdb5 --- /dev/null +++ b/app/src/main/res/xml/devicesettings_longsit.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/devicesettings_power_mode.xml b/app/src/main/res/xml/devicesettings_power_mode.xml new file mode 100644 index 000000000..1dacde056 --- /dev/null +++ b/app/src/main/res/xml/devicesettings_power_mode.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/devicesettings_watchxplus.xml b/app/src/main/res/xml/devicesettings_watchxplus.xml new file mode 100644 index 000000000..04a7bd91b --- /dev/null +++ b/app/src/main/res/xml/devicesettings_watchxplus.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index ad284fa9e..5b8ea1e9e 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -580,12 +580,6 @@ android:icon="@drawable/ic_device_zetime" android:key="pref_key_zetime" android:title="@string/zetime_title_settings"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -