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 3a42bdbf8..2ac346f40 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 @@ -34,6 +34,9 @@ public final class WatchXPlusConstants extends LenovoWatchConstants { public static final String PREF_DISCONNECT_REMIND = "disconnect_notification"; public static final String PREF_FIND_PHONE = "prefs_find_phone"; public static final String PREF_FIND_PHONE_DURATION = "prefs_find_phone_duration"; + public static final String PREF_ALTITUDE = "watchxplus_altitude"; + public static final String PREF_REPEAT = "watchxplus_repeat"; + // time format constants public static final byte ARG_SET_TIMEMODE_24H = 0x00; public static final byte ARG_SET_TIMEMODE_12H = 0x01; @@ -50,6 +53,7 @@ public final class WatchXPlusConstants extends LenovoWatchConstants { public static final byte[] CMD_NOTIFICATION_TEXT_TASK = new byte[]{0x03, 0x06}; + public static final byte[] CMD_NOTIFICATION_CANCEL = new byte[]{0x03, 0x04}; public static final byte[] CMD_NOTIFICATION_SETTINGS = new byte[]{0x03, 0x02}; public static final byte[] CMD_DO_NOT_DISTURB_SETTINGS = new byte[]{0x03, 0x61}; @@ -59,6 +63,7 @@ public final class WatchXPlusConstants extends LenovoWatchConstants { public static final byte[] CMD_SHAKE_SWITCH = new byte[]{0x03, -0x6E}; public static final byte[] CMD_DISCONNECT_REMIND = new byte[]{0x00, 0x11}; public static final byte[] CMD_TIME_LANGUAGE = new byte[]{0x03, -0x6F}; + public static final byte[] CMD_ALTITUDE = new byte[]{0x05, 0x0A}; public static final byte[] RESP_SHAKE_SWITCH = new byte[]{0x08, 0x03, -0x6E}; public static final byte[] RESP_DISCONNECT_REMIND = new byte[]{0x08, 0x00, 0x11}; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WatchXPlusDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WatchXPlusDeviceCoordinator.java index f55f8d5ee..2fb9a6179 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WatchXPlusDeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/lenovo/watchxplus/WatchXPlusDeviceCoordinator.java @@ -15,6 +15,7 @@ import androidx.annotation.Nullable; import java.util.Collection; import java.util.Collections; +import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst; @@ -28,6 +29,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import static nodomain.freeyourgadget.gadgetbridge.GBApplication.getContext; @@ -35,6 +37,7 @@ public class WatchXPlusDeviceCoordinator extends AbstractDeviceCoordinator { public static final int FindPhone_ON = -1; public static final int FindPhone_OFF = 0; + protected static Prefs prefs = GBApplication.getPrefs(); @NonNull @Override @@ -182,6 +185,18 @@ public class WatchXPlusDeviceCoordinator extends AbstractDeviceCoordinator { // WatchXPlus doesn't support scheduled intervals. Treat it as "on". return !lostReminder.equals(getContext().getString(R.string.p_off)); } +// read altitude from preferences + public static int getAltitude(String address) { + return (int) prefs.getInt(WatchXPlusConstants.PREF_ALTITUDE, 200); + } + +// read repeat call notification + public static int getRepeatOnCall(String address) { + return (int) prefs.getInt(WatchXPlusConstants.PREF_REPEAT, 1); + } + +// read repeat call preferences + public static int getRepeat = 0; /** * @return {@link #FindPhone_OFF}, {@link #FindPhone_ON}, or the duration diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/operations/InitOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/operations/InitOperation.java index c161e7f50..f5f366f5b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/operations/InitOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/operations/InitOperation.java @@ -79,7 +79,7 @@ public class InitOperation extends AbstractBTLEOperation> 24)); + bArr[1] = (byte) ((int) (mPosition >> 16)); + bArr[2] = (byte) ((int) (mPosition >> 8)); + bArr[3] = (byte) ((int) mPosition); + builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_NOTIFICATION_CANCEL, + WatchXPlusConstants.WRITE_VALUE, + bArr)); + } + } } - builder.queue(getQueue()); } catch (IOException e) { LOG.warn("Unable to send notification", e); @@ -439,17 +474,23 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { alarmValue)); } } - + int repeat = 0; @Override public void onSetCallState(CallSpec callSpec) { + SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); switch (callSpec.command) { case CallSpec.CALL_INCOMING: - sendNotification(WatchXPlusConstants.NOTIFICATION_CHANNEL_PHONE_CALL, callSpec.name); + WatchXPlusDeviceCoordinator.getRepeat = 1; + sendNotification(WatchXPlusConstants.NOTIFICATION_CHANNEL_PHONE_CALL, callSpec.name, true); break; case CallSpec.CALL_START: + WatchXPlusDeviceCoordinator.getRepeat = 1; + sendNotification(WatchXPlusConstants.NOTIFICATION_CHANNEL_PHONE_CALL, "stop", false); + break; case CallSpec.CALL_END: -// sendNotification(WatchXPlusConstants.NOTIFICATION_CHANNEL_PHONE_CALL, true); -// break; + WatchXPlusDeviceCoordinator.getRepeat = 0; + sendNotification(WatchXPlusConstants.NOTIFICATION_CHANNEL_PHONE_CALL, "stop", false); + break; default: break; } @@ -595,6 +636,10 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { break; case DeviceSettingsPreferenceConst.PREF_TIMEFORMAT: setTimeMode(builder, sharedPreferences); + break; + case WatchXPlusConstants.PREF_ALTITUDE: + LOG.info(" ALTITUDE: " + config); + break; } builder.queue(getQueue()); @@ -1174,10 +1219,12 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { // 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); + this.setHeadsUpScreen(transaction, sharedPreferences); // lift wirst to screen on + this.setDisconnectReminder(transaction, sharedPreferences); // disconnect reminder + this.setTimeMode(transaction, sharedPreferences); // set time mode 12/24h + this.setAltitude(transaction); // set altitude calibration } + private Handler mFindPhoneHandler = new Handler(); private void onReverseFindDevice(boolean start) { @@ -1220,7 +1267,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { // Command to toggle Lift Wrist to Light Screen private WatchXPlusDeviceSupport setHeadsUpScreen(TransactionBuilder transactionBuilder, boolean enable) { - byte refuseCall = 0x00; + byte refuseCall = 0x00; // force refuse call to OFF byte lightScreen = 0x00; if (enable) { lightScreen = 0x01; @@ -1275,9 +1322,29 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { buildCommand(WatchXPlusConstants.CMD_TIME_LANGUAGE, WatchXPlusConstants.WRITE_VALUE, bArr)); - LOG.info(" setTimeMode: " + bArr); + //LOG.info(" setTimeMode: " + bArr); return this; + } +// calibrate altitude + private WatchXPlusDeviceSupport setAltitude(TransactionBuilder transactionBuilder) { + int value = WatchXPlusDeviceCoordinator.getAltitude(getDevice().getAddress()); + int mAltitude = value; + if (mAltitude < 0) { + mAltitude = (Math.abs(mAltitude) ^ 65535) + 1; + } + int mAirPressure = Math.abs(0); // air pressure 0 ??? + byte[] bArr = new byte[4]; + bArr[0] = (byte) (mAltitude >> 8); // bytr[8] + bArr[1] = (byte) mAltitude; // bytr[9] + bArr[2] = (byte) (mAirPressure >> 8); // bytr[10] + bArr[3] = (byte) mAirPressure; // bytr[11] + transactionBuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_ALTITUDE, + WatchXPlusConstants.WRITE_VALUE, + bArr)); + //LOG.info(" setAltitude: " + mAltitude); + return this; } private WatchXPlusDeviceSupport setTimeMode(TransactionBuilder transactionBuilder, SharedPreferences sharedPreferences) { diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 8f44a7130..e3aab489e 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -1,5 +1,22 @@ + Бутон за ново устройство + Винаги видим + Видим само ако няма свързано устройство + Език и регион + За Вас + Година на раждане + Пол + Височина в cm + Тегло в kg + Настройки на Графиката + Показвай средни стойности + Настройки на графика + Max сърдечен ритъм + Min сърдечен ритъм + Обхват на Графиката + Обхвата е Месец + Обхвата е Седмица Gadgetbridge Gadgetbridge Настройки diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2149d785e..ea014997e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -189,8 +189,8 @@ Units Time format - Screen on duration - Lift wirst to screen on + Altitude calibration + Repeat vibration on call WatchXPlus settings Makibes HR3 settings diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 706c633d9..5d1cd46e9 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -584,15 +584,14 @@ android:title="@string/pref_header_general"> + android:defaultValue="200" + android:key="watchxplus_altitude" + android:title="@string/pref_wxp_title_altitude"/> - +