From 24439008abbcc29dea5809dfc1e31b0414f2d636 Mon Sep 17 00:00:00 2001 From: mamutcho Date: Sun, 10 Nov 2019 23:15:13 +0200 Subject: [PATCH] Add watch power mode and DND --- .../activities/SettingsActivity.java | 16 +- .../watchxplus/WatchXPlusConstants.java | 11 +- .../WatchXPlusDeviceCoordinator.java | 40 ++++- .../devices/lenovo/watchxplus/WorkProgress | 55 +++--- .../watchxplus/WatchXPlusDeviceSupport.java | 170 ++++++++++++++---- app/src/main/res/values-bg/strings.xml | 118 +++++++++++- app/src/main/res/values/arrays.xml | 11 ++ app/src/main/res/values/strings.xml | 5 + app/src/main/res/xml/preferences.xml | 35 +++- 9 files changed, 384 insertions(+), 77 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java index b12a71711..9ad6d7dc0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java @@ -91,7 +91,6 @@ public class SettingsActivity extends AbstractSettingsActivity { Prefs prefs = GBApplication.getPrefs(); Preference pref = findPreference("notifications_generic"); - pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"); @@ -211,13 +210,22 @@ public class SettingsActivity extends AbstractSettingsActivity { }); - pref = findPreference("watchxplus_button_BP_calibration"); + pref = findPreference("wxp_button_BP_calibration"); + pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + preference.setSummary("Calibrating, please wait... (if no result after 15s. re-run)"); + GBApplication.deviceService().onSendConfiguration("BP_CAL"); + return true; + } + }); + + pref = findPreference("wxp_power_mode"); pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newVal) { LOG.info(" uhaaaa "); - preference.setSummary("Calibrating, please wait... (if no result after 15s. re-run)"); - GBApplication.deviceService().onSendConfiguration("BP_CAL"); + GBApplication.deviceService().onSendConfiguration("WXP_POWER_MODE"); return true; } }); 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 42a739a12..424eb2ab3 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 @@ -43,7 +43,9 @@ public final class WatchXPlusConstants extends LenovoWatchConstants { public static final String PREF_SHAKE_REJECT = "watchxplus_shake_reject"; public static final String PREF_BP_CAL_LOW = "pref_wxp_bp_calibration_low"; public static final String PREF_BP_CAL_HIGH = "pref_wxp_bp_calibration_high"; - + public static final String PREF_DO_NOT_DISTURB = "do_not_disturb_no_auto"; + public static final String PREF_DO_NOT_DISTURB_START = "do_not_disturb_no_auto_start"; + public static final String PREF_DO_NOT_DISTURB_END = "do_not_disturb_no_auto_end"; // time format constants public static final byte ARG_SET_TIMEMODE_24H = 0x00; @@ -66,7 +68,10 @@ public final class WatchXPlusConstants extends LenovoWatchConstants { 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}; - public static final byte[] CMD_POWER_MODE = new byte[]{0x03, -0x7F}; //bArr[8] - 0 normal, 1 poser save, 2 green + public static final byte[] CMD_POWER_MODE = new byte[]{0x03, -0x7F}; + public static final byte[] CMD_SET_QUITE_HOURS_TIME = new byte[]{0x03, 0x62}; + public static final byte[] CMD_SET_QUITE_HOURS_SWITCH = new byte[]{0x03, 0x61}; + public static final byte[] CMD_SET_PERSONAL_INFO = new byte[]{0x01, 0x0E}; public static final byte[] CMD_FITNESS_GOAL_SETTINGS = new byte[]{0x10, 0x02}; public static final byte[] CMD_DAY_STEPS_INFO = new byte[]{0x10, 0x03}; @@ -81,6 +86,8 @@ public final class WatchXPlusConstants extends LenovoWatchConstants { public static final byte[] RESP_IS_BP_CALIBRATED = new byte[]{0x08, 0x05, 0x0B}; public static final byte[] RESP_BUTTON_WHILE_RING = new byte[]{0x04, 0x03, 0x03}; public static final byte[] RESP_BP_CALIBRATION = new byte[]{0x08, 0x05, 0x0C}; + public static final byte[] RESP_SET_PERSONAL_INFO = new byte[]{0x08, 0x01, 0x0E}; + public static final byte[] RESP_GOAL_AIM_STATUS = new byte[]{0x08, 0x10, 0x02}; public static final byte[] RESP_AUTHORIZATION_TASK = new byte[]{0x01, 0x01, 0x05}; public static final byte[] RESP_DAY_STEPS_INDICATOR = new byte[]{0x08, 0x10, 0x03}; 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 dd24b6760..6f64f5807 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 @@ -12,6 +12,12 @@ import android.os.ParcelUuid; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Collection; import java.util.Collections; @@ -34,8 +40,9 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import static nodomain.freeyourgadget.gadgetbridge.GBApplication.getContext; -public class WatchXPlusDeviceCoordinator extends AbstractDeviceCoordinator { +public class WatchXPlusDeviceCoordinator extends AbstractDeviceCoordinator { + private static final Logger LOG = LoggerFactory.getLogger(WatchXPlusDeviceSupport.class); public static final int FindPhone_ON = -1; public static final int FindPhone_OFF = 0; public static boolean isBPCalibrated = false; @@ -163,7 +170,8 @@ public class WatchXPlusDeviceCoordinator extends AbstractDeviceCoordinator { R.xml.devicesettings_liftwrist_display, R.xml.devicesettings_disconnectnotification, R.xml.devicesettings_find_phone, - R.xml.devicesettings_timeformat + R.xml.devicesettings_timeformat, + R.xml.devicesettings_donotdisturb_no_auto }; } @@ -224,6 +232,34 @@ Prefs from device settings on main page } } + /** + * @param startOut out Only hour/minute are used. + * @param endOut out Only hour/minute are used. + * @return True if quite hours are enabled. + */ + public static boolean getQuiteHours(SharedPreferences sharedPrefs, Calendar startOut, Calendar endOut) { + String doNotDisturb = sharedPrefs.getString(WatchXPlusConstants.PREF_DO_NOT_DISTURB, getContext().getString(R.string.p_off)); + + if (doNotDisturb.equals(getContext().getString(R.string.p_off))) { + LOG.info(" DND is disabled "); + return false; + } else { + String start = sharedPrefs.getString(WatchXPlusConstants.PREF_DO_NOT_DISTURB_START, "00:00"); + String end = sharedPrefs.getString(WatchXPlusConstants.PREF_DO_NOT_DISTURB_END, "00:00"); + + DateFormat df = new SimpleDateFormat("HH:mm"); + + try { + startOut.setTime(df.parse(start)); + endOut.setTime(df.parse(end)); + + return true; + } catch (Exception e) { + return false; + } + } + } + /* Values from device specific settings page */ 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 284038f85..e34cb75e0 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 @@ -1,27 +1,19 @@ NEDD TO BE DONE Watch settings - - Set watch modes (energy saving): - - Normal -> the watch work normally - - Power-saving mode -> the app turn off the bluetooth on the watch - - Trad-watch mode -> the watch only works as an analog one - Set watch language (currently forced to English) - Set watch units (metric/imperial) - - Implement send User details to watch - - Age, height, gender, etc. - - Implement Do not disturb (on, off, scheduled) - - Implement themperature alarm on watch + - Implement temperature alarm on watch - switch, lowTemp, highTemp - Implement continious blood pressure measurement (on, off, scheduled) - - implement long sit reminder + - Implement long sit reminder Add feature to initiate button press event on watch - Send command to watch - - Get triger on button press + - Get trigger on button press Schedulers: - Screen on scheduler (inApp, not supported by watch) - Disconnect reminder scheduler (inApp, not supported by watch) - - Do not disturb (supported by watch) - Continious blood pressure measurement (supported by watch) Refine send weather to watch @@ -32,51 +24,56 @@ NEDD TO BE DONE Measurements - Blood pressure mesurement - - Add blood pressure calibration (view) - - Add blood pressure calibration function - Show blood pressure measurement (view) - Implement heart rate measurement - - Implement themperature measurement + - Implement temperature measurement - Implement UV index measurement WORK PROGRESS Send notification to watch - - on incomming call + - On incoming call - add function to cancel notification on watch (04.11.2019) - cancel notification on change phone state (end call, reject call etc.) (06.11.2019) - settings for repeat notification [0-10 times] (05.11.2019) - settings for continious notification while phone ring [on, off] (06.11.2019) - settings for send once notification for missed call [on, off] (06.11.2019) - - on text message, or other application - - on triger phone alarm (05.11.2019) + - On text message, or other application + - On triger phone alarm (05.11.2019) Call handling - - setting for ignore/reject call with watch button [on->reject call, off->ignore call] (06.11.2019) - - setting for ignore/reject call with shake device - duplicates button action [on, off] (06.11.2019) - - on watch - show small phone icon near bluetooth icon when there are missed call (06.11.2019) + - Setting for ignore/reject call with watch button [on->reject call, off->ignore call] (06.11.2019) + - Setting for ignore/reject call with shake device - duplicates button action [on, off] (06.11.2019) + - On watch - show small phone icon near bluetooth icon when there are missed call (06.11.2019) Calibrations - - time calibration + - Time calibration * send current date/time to watch - - set watch alarms - - altitude calibration [altitude (meters)] (04.11.2019) + - Set watch alarms + - Altitude calibration [altitude (meters)] (04.11.2019) * it's used in Climb activity - - status of blood pressure calibration (06.11.2019) + - Status of blood pressure calibration (06.11.2019) * it's used in blood pressure measurement + - Blood pressure calibration (09.11.2019) (TODO fix button initiating calibration) Device settings - - lift wrist to screen on [on, off,TODO scheduled] (02.11.2019) - - change time format 12/24h (02.11.2019) - - disconnect reminder [on, off,TODO scheduled] (02.11.2019) - - find my phone [on, off, ring duration] (02.11.2019) + - Lift wrist to screen on [on, off,TODO scheduled] (02.11.2019) + - Change time format 12/24h (02.11.2019) + - Disconnect reminder [on, off,TODO scheduled] (02.11.2019) + - Find my phone [on, off, ring duration] (02.11.2019) + - Set watch modes (energy saving) (10.11.2019) (Need testing) + - Normal -> the watch work normally + - Power-saving mode -> the app turn off the bluetooth on the watch + - Trad-watch mode -> the watch only works as an analog one + - Do not disturb [on, off, scheduled] (10.11.2019) (need reconnect to apply) + - Send User details to watch [height, weight, age, gender] (10.11.2019) (need more testing) Activity data - get steps per day - get heart reate measurements - get sleep data - - set user goal for steps (TODO set user details) + - set user goal for steps Changed in app device icon (02.11.2019) Get blood pressure measurement result (work only if blood pressure is calibrated) 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 590fa09c3..1fd5186a2 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 @@ -26,18 +26,12 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.net.Uri; import android.os.Handler; -import android.view.Gravity; -import android.view.View; -import android.view.ViewGroup; import android.widget.Toast; import androidx.annotation.IntRange; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.localbroadcastmanager.content.LocalBroadcastManager; -import com.google.android.material.snackbar.Snackbar; - -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -276,15 +270,6 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { return this; } - private WatchXPlusDeviceSupport enableDoNotDisturb(TransactionBuilder builder, boolean active) { - builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), - buildCommand(WatchXPlusConstants.CMD_DO_NOT_DISTURB_SETTINGS, - WatchXPlusConstants.WRITE_VALUE, - new byte[]{(byte) (active ? 0x01 : 0x00)})); - - return this; - } - private void enableCalibration(boolean enable) { try { TransactionBuilder builder = performInitialized("enableCalibration"); @@ -399,21 +384,10 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { return this; } - private WatchXPlusDeviceSupport setFitnessGoal(TransactionBuilder builder) { - int fitnessGoal = new ActivityUser().getStepsGoal(); - builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), - buildCommand(WatchXPlusConstants.CMD_FITNESS_GOAL_SETTINGS, - WatchXPlusConstants.WRITE_VALUE, - Conversion.toByteArr16(fitnessGoal))); - - return this; - } - public WatchXPlusDeviceSupport initialize(TransactionBuilder builder) { getFirmwareVersion(builder) .getBatteryState(builder) .enableNotificationChannels(builder) - .enableDoNotDisturb(builder, false) .setFitnessGoal(builder) .getBloodPressureCalibrationStatus(builder) .syncPreferences(builder); @@ -574,8 +548,43 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { } } + private WatchXPlusDeviceSupport setFitnessGoal(TransactionBuilder builder) { + int fitnessGoal = new ActivityUser().getStepsGoal(); + builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_FITNESS_GOAL_SETTINGS, + WatchXPlusConstants.WRITE_VALUE, + Conversion.toByteArr16(fitnessGoal))); + return this; + } +// set personal info + private WatchXPlusDeviceSupport setPersonalInformation(TransactionBuilder builder, int height, int weight, int age, int gender) { + LOG.warn(" Setting Personal Information... height:"+height+" weight:"+weight+" age:"+age+" gender:"+gender); + byte[] command = WatchXPlusConstants.CMD_SET_PERSONAL_INFO; + + byte[] bArr = new byte[4]; + bArr[0] = (byte) height; // byte[08] + bArr[1] = (byte) weight; // byte[09] + bArr[2] = (byte) age; // byte[10] + bArr[3] = (byte) gender; // byte[11] + + builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(command, + WatchXPlusConstants.WRITE_VALUE, + bArr)); + return this; + } + +// handle get/set personal info +// for test purposes only + private void handlePersonalInfo(byte[] value) { + int height = Conversion.fromByteArr16(value[8]); + int weight = Conversion.fromByteArr16(value[9]); + int age = Conversion.fromByteArr16(value[10]); + int gender = Conversion.fromByteArr16(value[11]); + LOG.info(" Personal info - height:" + height + ", weight:" + weight + ", age:" + age + ", gender:" + gender); + } @Override public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) { @@ -648,7 +657,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { @Override public void onReset(int flags) { - + // testNewCommands(); } @Override @@ -701,6 +710,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(this.getDevice().getAddress()); try { builder = performInitialized("sendConfig: " + config); + LOG.info(" config changed:" + config); switch (config) { case ActivityUser.PREF_USER_STEPS_GOAL: setFitnessGoal(builder); @@ -716,9 +726,18 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { case DeviceSettingsPreferenceConst.PREF_TIMEFORMAT: setTimeFormat(builder, sharedPreferences); break; + case WatchXPlusConstants.PREF_DO_NOT_DISTURB: + case WatchXPlusConstants.PREF_DO_NOT_DISTURB_START: + case WatchXPlusConstants.PREF_DO_NOT_DISTURB_END: + LOG.info(" bravo "); + setQuiteHours(builder, sharedPreferences); + break; case "BP_CAL": sendBloodPressureCalibration(); break; + case "WXP_POWER_MODE": + setPowerMode(config); + break; } builder.queue(getQueue()); } catch (IOException e) { @@ -736,6 +755,71 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { requestBloodPressureMeasurement(); } +// set do not disturb time + private WatchXPlusDeviceSupport setQuiteHours(TransactionBuilder tbuilder, boolean enable, int hourStart, int minuteStart, int hourEnd, int minuteEnd) { + LOG.warn(" Setting DND time... Hs:"+hourStart+" Ms:"+minuteStart+" He:"+hourEnd+" Me:"+minuteEnd); + byte[] command = WatchXPlusConstants.CMD_SET_QUITE_HOURS_TIME; + + byte[] bArr = new byte[4]; + bArr[0] = (byte) hourStart; // byte[08] + bArr[1] = (byte) minuteStart; // byte[09] + bArr[2] = (byte) hourEnd; // byte[10] + bArr[3] = (byte) minuteEnd; // byte[11] + + tbuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_SET_QUITE_HOURS_TIME, + WatchXPlusConstants.WRITE_VALUE, + bArr)); + setQuiteHoursSwitch(tbuilder, enable); + return this; + } + + // set do not disturb switch + private WatchXPlusDeviceSupport setQuiteHoursSwitch(TransactionBuilder tbuilder, boolean enable) { + LOG.warn("Setting DND switch to" + enable); + tbuilder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_SET_QUITE_HOURS_SWITCH, + WatchXPlusConstants.WRITE_VALUE, + new byte[]{(byte) (enable ? 0x01 : 0x00)})); + return this; + } + + private WatchXPlusDeviceSupport setQuiteHours(TransactionBuilder builder, SharedPreferences sharedPreferences) { + Calendar start = new GregorianCalendar(); + Calendar end = new GregorianCalendar(); + boolean enable = WatchXPlusDeviceCoordinator.getQuiteHours(sharedPreferences, start, end); + if (enable) { + return this.setQuiteHours(builder, enable, + start.get(Calendar.HOUR_OF_DAY), start.get(Calendar.MINUTE), + end.get(Calendar.HOUR_OF_DAY), end.get(Calendar.MINUTE)); + } else { + LOG.info(" Quiet hours are disabled"); + return this.setQuiteHoursSwitch(builder, enable); + } + } + +// set watch power mode + private WatchXPlusDeviceSupport setPowerMode(String config) { + int settingRead = prefs.getInt("wxp_power_mode", 0); + byte[] bArr = new byte[1]; + if (settingRead == 0) bArr[0] = 0x00; + if (settingRead == 1) bArr[0] = 0x01; + if (settingRead == 2) bArr[0] = 0x02; + LOG.info(" setting: " + config + " mode: " + bArr[0]); + + try { + TransactionBuilder builder = performInitialized("setPowerMode"); + builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), + buildCommand(WatchXPlusConstants.CMD_POWER_MODE, + WatchXPlusConstants.TASK, + bArr)); + builder.queue(getQueue()); + } catch (IOException e) { + LOG.warn("Unable to set power mode", e); + } + return this; + } + // check status of blood pressure calibration private WatchXPlusDeviceSupport getBloodPressureCalibrationStatus(TransactionBuilder builder) { builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), @@ -771,7 +855,8 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { buildCommand(command, WatchXPlusConstants.TASK, bArr)); - builder.queue(getQueue()); } catch (IOException e) { + builder.queue(getQueue()); + } catch (IOException e) { LOG.warn("Unable to send BP Calibration", e); } return this; @@ -820,27 +905,27 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { } - /* + // not working!!! - private void requestHeartRateMeasurement() { + private void testNewCommands() { try { - TransactionBuilder builder = performInitialized("hrMeasure"); + TransactionBuilder builder = performInitialized("test"); - byte[] command = new byte[]{0x05, 0x0B}; + 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 " + command); builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), buildCommand(command, WatchXPlusConstants.READ_VALUE)); - // builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), - // buildCommand(command, - // WatchXPlusConstants.TASK, new byte[]{0x01})); builder.queue(getQueue()); } catch (IOException e) { LOG.warn("Unable to request HR Measure", e); } } -*/ + @Override public void onSendWeather(WeatherSpec weatherSpec) { @@ -878,12 +963,16 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { handleFirmwareInfo(value); } else if (ArrayUtils.equals(value, WatchXPlusConstants.RESP_SHAKE_SWITCH, 5)) { handleShakeState(value); + } else if (ArrayUtils.equals(value, WatchXPlusConstants.RESP_SET_PERSONAL_INFO, 5)) { + handlePersonalInfo(value); } else if (ArrayUtils.equals(value, WatchXPlusConstants.RESP_BUTTON_WHILE_RING, 5)) { handleButtonWhenRing(value); } else if (ArrayUtils.equals(value, WatchXPlusConstants.RESP_DISCONNECT_REMIND, 5)) { handleDisconnectReminderState(value); } else if (ArrayUtils.equals(value, WatchXPlusConstants.RESP_BATTERY_INFO, 5)) { handleBatteryState(value); + } else if (ArrayUtils.equals(value, WatchXPlusConstants.RESP_GOAL_AIM_STATUS, 5)) { + handleSportAimStatus(value); } else if (ArrayUtils.equals(value, WatchXPlusConstants.RESP_TIME_SETTINGS, 5)) { handleTime(value); } else if (ArrayUtils.equals(value, WatchXPlusConstants.RESP_IS_BP_CALIBRATED, 5)) { @@ -1214,6 +1303,11 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { return result; } + private void handleSportAimStatus(byte[] value) { + int stepsAim = Conversion.fromByteArr16(value[8], value[9]); + LOG.debug(" Received goal stepsAim: " + stepsAim); + } + private void handleStepsInfo(byte[] value) { int steps = Conversion.fromByteArr16(value[8], value[9]); LOG.debug(" Received steps count: " + steps); @@ -1395,9 +1489,13 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { private void syncPreferences(TransactionBuilder transaction) { SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(this.getDevice().getAddress()); this.setHeadsUpScreen(transaction, sharedPreferences); // lift wirst to screen on + this.setQuiteHours(transaction, sharedPreferences); // DND this.setDisconnectReminder(transaction, sharedPreferences); // disconnect reminder this.setTimeFormat(transaction, sharedPreferences); // set time mode 12/24h this.setAltitude(transaction); // set altitude calibration + ActivityUser activityUser = new ActivityUser(); + this.setPersonalInformation(transaction, activityUser.getHeightCm(), activityUser.getWeightKg(), + activityUser.getAge(),activityUser.getGender()); } private Handler mFindPhoneHandler = new Handler(); diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 5d83bcc25..920f0e19d 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -284,7 +284,7 @@ Watch 9 свързване Watch 9 сверяване WatchX Plus сверяване - Edinici + Единици Формат на часа Калибриране на височина Повтори известия за звънене @@ -466,4 +466,120 @@ Стартирайте активност Специфични настройки за устройството Средно: %1$s + Отказ + Изтрий + Дълбок сън + Лек сън + Не е носен + Активност + Отговори + Управление на базата + Изчисти БД + Импорт БД + Изтрий стара БД + Експорт на БД + Експортиране на БД... + Стартирай авто експортиране + Локацията за експорт на БД е: + АвтоЕкспорт + ИзпразниБД + Внимание! Ако натиснете този бутон БД ще се изтрие. + Експорт и Импорт + Време за сън в часове + Активности + Активност + Колоездене + Дълбок сън + Лек сън + Упражнение + Не е измерено + Не е носено + Бягане + Плуване + Неизвестна активност + Ходене + Не е свързан, алармата не е настроена. + Аларма за %1$02d:%2$02d + Автоматично + Удостоверяване + Изисква удостоверяване + Сърдечна честота + Избери локация за експорт + Час + Замени + Firmware версия: %1$s + Hardware версия: %1$s + Не е свързан. + Неизвестно устройство + Опит за свързване с %1$s + Не се свързвай + Включи bluetooth за намиране на устройства. + Свързване с %1$s? + Опит за свързване с: %1$s + Свържи + Не филтрирай + Намери ме! + Шрифт + Невалидни данни + Сърдечен ритъм + Продължителност + Аларма + Активност + Компас + Музика + Настройки + Известия + Прогноза за време + Таймер + Изкл. + Разписание + Край + Начало + Не безпокой + Вие спахте от %1$s до %2$s + Режим на часовника + Само часовник + Икономичен + Нормален + Стъпки: %1$02d + Сън: %1$s + 5 минути + 20 минути + 1 час + 10 минути + Крачки за месец + Сън за месец + Внимание! + Изчаква свързване + Всички аларми са изключени + Метрична + Инчова + Въведете поне една дума + Филтъра за известия е запазен + Вибрация + Филтър за известия + Управление на БД + Избери всички + Сподели + Запази настройките + Натисни тук за старт на калибрирането + Започни калибриране + Горна граница + Долна граница + От ляво на дясно + Аларми + WatchXPlus настройки + метрични + инчови + крачки + разписание + изкл. + вкл. + изкл. + прогноза + настройки + известия + Изкл. + Вкл. + Няма данни \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 6a38a6e9b..c766f389d 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -69,6 +69,17 @@ never + + @string/wxp_mode_normal + @string/wxp_mode_saving + @string/wxp_mode_watch + + + 0 + 1 + 2 + + @string/male @string/female diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 98e0eb93d..2dd8fb0ff 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -205,6 +205,11 @@ Begin calibration Press here to begin calibration WatchXPlus calibration + WatchXPlus settings + Watch mode + Normal + Power saving + Only watch Makibes HR3 settings diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 1b998ef85..c84357aee 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -611,8 +611,20 @@ android:summary="@string/pref_wxp_title_shake_reject_summary" android:title="@string/prefs_wxp_shake_reject" /> + + + + - - +