From fb08af6d045231756cddaea1938626fee026656c Mon Sep 17 00:00:00 2001 From: mamutcho Date: Sat, 2 Nov 2019 22:24:00 +0200 Subject: [PATCH] Add Device settings (screen on, time format, disconnect reminder, find my phone). Changed device icon. --- app/src/main/AndroidManifest.xml | 2 +- .../LenovoWatchCalibrationActivity.java | 2 +- .../watchxplus/WatchXPlusConstants.java | 15 ++ .../WatchXPlusDeviceCoordinator.java | 75 +++++++- .../gadgetbridge/model/DeviceType.java | 4 +- .../watchxplus/WatchXPlusDeviceSupport.java | 178 +++++++++++++++++- app/src/main/res/values-bg/strings.xml | 14 ++ app/src/main/res/values/strings.xml | 7 + app/src/main/res/xml/preferences.xml | 23 +++ 9 files changed, 309 insertions(+), 11 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e1e1d26f9..bf0a9c242 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -411,7 +411,7 @@ android:label="@string/title_activity_watch9_pairing" /> + android:label="@string/title_activity_watchXplus_calibration" /> > 1) & 1) != 1) { + //z = false; + refuse = refuse + " off"; + } else { + refuse = refuse + " on"; + } + LOG.info(" handleShakeState: " + light + " " + refuse); + } + +// handle disconnect reminder state +// for test purposes only + private void handleDisconnectReminderState(byte[] value) { + boolean z = true; + if (1 != value[8]) { + z = false; + } + LOG.info(" disconnectReminder: " + Boolean.valueOf(z) + " val: " + value[8]); + + return; + + + } + +// read preferences + private void syncPreferences(TransactionBuilder transaction) { + SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(this.getDevice().getAddress()); + this.setHeadsUpScreen(transaction, sharedPreferences); + this.setDisconnectReminder(transaction, sharedPreferences); + this.setTimeMode(transaction, sharedPreferences); + } + private Handler mFindPhoneHandler = new Handler(); + + private void onReverseFindDevice(boolean start) { + if (start) { + SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs( + this.getDevice().getAddress()); + + int findPhone = WatchXPlusDeviceCoordinator.getFindPhone(sharedPreferences); + + if (findPhone != WatchXPlusDeviceCoordinator.FindPhone_OFF) { + GBDeviceEventFindPhone findPhoneEvent = new GBDeviceEventFindPhone(); + + findPhoneEvent.event = GBDeviceEventFindPhone.Event.START; + + evaluateGBDeviceEvent(findPhoneEvent); + + if (findPhone > 0) { + this.mFindPhoneHandler.postDelayed(new Runnable() { + @Override + public void run() { + onReverseFindDevice(false); + } + }, findPhone * 1000); + } + } + } else { + // Always send stop, ignore preferences. + GBDeviceEventFindPhone findPhoneEvent = new GBDeviceEventFindPhone(); + + findPhoneEvent.event = GBDeviceEventFindPhone.Event.STOP; + + evaluateGBDeviceEvent(findPhoneEvent); + } + } + // Set Lift Wrist to Light Screen based on saved preferences + private WatchXPlusDeviceSupport setHeadsUpScreen(TransactionBuilder transactionBuilder, SharedPreferences sharedPreferences) { + return this.setHeadsUpScreen(transactionBuilder, + WatchXPlusDeviceCoordinator.shouldEnableHeadsUpScreen(sharedPreferences)); + } + + // Command to toggle Lift Wrist to Light Screen + private WatchXPlusDeviceSupport setHeadsUpScreen(TransactionBuilder transactionBuilder, boolean enable) { + byte refuseCall = 0x00; + byte lightScreen = 0x00; + if (enable) { + lightScreen = 0x01; + } + byte b = (byte) (lightScreen + (refuseCall << 1)); + byte[] liftScreen = new byte[4]; + liftScreen[0] = 0x00; + liftScreen[1] = 0x00; + liftScreen[2] = 0x00; + liftScreen[3] = b; //byte[11] + transactionBuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_SHAKE_SWITCH, + WatchXPlusConstants.WRITE_VALUE, + liftScreen)); + return this; + } + + private WatchXPlusDeviceSupport setDisconnectReminder(TransactionBuilder transactionBuilder, SharedPreferences sharedPreferences) { + return this.setDisconnectReminder(transactionBuilder, + WatchXPlusDeviceCoordinator.shouldEnableDisconnectReminder(sharedPreferences)); + } + + private WatchXPlusDeviceSupport setDisconnectReminder(TransactionBuilder transactionBuilder, boolean enable) { + transactionBuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_DISCONNECT_REMIND, + WatchXPlusConstants.WRITE_VALUE, + new byte[]{(byte) (enable ? 0x01 : 0x00)})); + return this; + } + +// Request status of Disconnect reminder + public WatchXPlusDeviceSupport getDisconnectReminderStatus(TransactionBuilder transactionBuilder) { + transactionBuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_DISCONNECT_REMIND, + WatchXPlusConstants.READ_VALUE)); + return this; + } +// Request status of Lift Wrist to Light Screen, and Shake to Refuse Call + public WatchXPlusDeviceSupport getShakeStatus(TransactionBuilder transactionBuilder) { + transactionBuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_SHAKE_SWITCH, + WatchXPlusConstants.READ_VALUE)); + return this; + } + +// set time format + private WatchXPlusDeviceSupport setTimeMode(TransactionBuilder transactionBuilder, byte timeMode) { + byte[] bArr = new byte[2]; + bArr[0] = 0x01; //byte[08] language - force to English language + bArr[1] = timeMode; //byte[09] time + transactionBuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_TIME_LANGUAGE, + WatchXPlusConstants.WRITE_VALUE, + bArr)); + LOG.info(" setTimeMode: " + bArr); + return this; + + } + + private WatchXPlusDeviceSupport setTimeMode(TransactionBuilder transactionBuilder, SharedPreferences sharedPreferences) { + return this.setTimeMode(transactionBuilder, + WatchXPlusDeviceCoordinator.getTimeMode(sharedPreferences)); + } + @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 b519a3802..8f44a7130 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -30,6 +30,12 @@ Приложения в кеша Инсталирани приложения Инсталирани циферблати + Включи екрана при вдигане + Известие при прекъсване + Намери телефона + Включи намиране на телефона + Използвайте устройството, за да накарате телефона да звъни. + Звънене - секунди Изтриване Изтриване и премахване от кеша Преинсталиране @@ -253,6 +259,14 @@ Име/Псевдоним Брой на вибрациите Когато часовникът завибрира, разклатете устройството или натиснете бутона + Минути: + Часове: + Секунди: + Задайте времето, което показва устройството Ви. + Сверяване + Watch 9 свързване + Watch 9 сверяване + WatchX Plus сверяване Наблюдение/анализ на съня Съхраняване на log файлове Инициализиране diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 748a27d6b..2149d785e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -186,6 +186,12 @@ Screen on duration All day heart rate measurement HPlus/Makibes settings + + Units + Time format + Screen on duration + Lift wirst to screen on + WatchXPlus settings Makibes HR3 settings @@ -701,6 +707,7 @@ Calibrate Watch 9 pairing Watch 9 calibration + WatchX Plus calibration Contextual Arabic Enable this to support contextual Arabic Right To Left Support diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index a4d9ac89f..706c633d9 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -574,6 +574,29 @@ android:icon="@drawable/ic_device_zetime" android:key="pref_key_zetime" android:title="@string/zetime_title_settings"/> + + + + + + + + + + +