diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapter.java index 3e3a25a2..18fabf09 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapter.java @@ -134,6 +134,14 @@ public class GBDeviceAdapter extends ArrayAdapter { deviceImageView.setImageResource(R.drawable.ic_device_lovetoy_disabled); } break; + case HPLUS: + case MAKIBESF68: + if( device.isConnected()) { + deviceImageView.setImageResource(R.drawable.ic_device_hplus); + } else { + deviceImageView.setImageResource(R.drawable.ic_device_hplus_disabled); + } + break; default: if (device.isConnected()) { deviceImageView.setImageResource(R.drawable.ic_launcher); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusConstants.java index 2fe12b9d..6d5dd308 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusConstants.java @@ -14,6 +14,8 @@ public final class HPlusConstants { public static final UUID UUID_CHARACTERISTIC_MEASURE = UUID.fromString("14702853-620a-3973-7c78-9cfff0876abd"); public static final UUID UUID_SERVICE_HP = UUID.fromString("14701820-620a-3973-7c78-9cfff0876abd"); + public static final byte ARG_WRIST_LEFT = 0; //Guess... + public static final byte ARG_WRIST_RIGHT = 1; //Guess... public static final byte ARG_LANGUAGE_CN = 1; public static final byte ARG_LANGUAGE_EN = 2; @@ -104,15 +106,11 @@ public final class HPlusConstants { public static final String PREF_HPLUS_SCREENTIME = "hplus_screentime"; public static final String PREF_HPLUS_ALLDAYHR = "hplus_alldayhr"; - public static final String PREF_HPLUS_HR = "hplus_hr_enable"; public static final String PREF_HPLUS_UNIT = "hplus_unit"; - public static final String PREF_HPLUS_TIMEMODE = "hplus_timemode"; + public static final String PREF_HPLUS_TIMEFORMAT = "hplus_timeformat"; public static final String PREF_HPLUS_WRIST = "hplus_wrist"; - public static final String PREF_HPLUS_SWALERT = "hplus_sw_alert"; - public static final String PREF_HPLUS_ALERT_TIME = "hplus_alert_time"; public static final String PREF_HPLUS_SIT_START_TIME = "hplus_sit_start_time"; public static final String PREF_HPLUS_SIT_END_TIME = "hplus_sit_end_time"; - public static final String PREF_HPLUS_LANGUAGE = "hplus_language"; public static final Map transliterateMap = new HashMap(){ { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java index 785905f5..a8656145 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java @@ -36,6 +36,9 @@ import org.slf4j.LoggerFactory; import java.util.Collection; import java.util.Collections; +import java.util.Locale; + +import static nodomain.freeyourgadget.gadgetbridge.GBApplication.getContext; public class HPlusCoordinator extends AbstractDeviceCoordinator { protected static final Logger LOG = LoggerFactory.getLogger(HPlusCoordinator.class); @@ -144,16 +147,41 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator { } public static byte getLanguage(String address) { - return (byte) prefs.getInt(HPlusConstants.PREF_HPLUS_LANGUAGE + "_" + address, HPlusConstants.ARG_LANGUAGE_EN); + String language = prefs.getString("language", "default"); + Locale locale; + if (language.equals("default")) { + locale = Locale.getDefault(); + } else { + locale = new Locale(language); + } + + if (locale.getLanguage().equals(new Locale("cn").getLanguage())){ + return HPlusConstants.ARG_LANGUAGE_CN; + }else{ + return HPlusConstants.ARG_LANGUAGE_EN; + } } public static byte getTimeMode(String address) { - return (byte) prefs.getInt(HPlusConstants.PREF_HPLUS_TIMEMODE + "_" + address, HPlusConstants.ARG_TIMEMODE_24H); + String tmode = prefs.getString(HPlusConstants.PREF_HPLUS_TIMEFORMAT, getContext().getString(R.string.p_timeformat_24h)); + + if(tmode.equals(getContext().getString(R.string.p_timeformat_24h))) { + return HPlusConstants.ARG_TIMEMODE_24H; + }else{ + return HPlusConstants.ARG_TIMEMODE_12H; + } + } public static byte getUnit(String address) { - return (byte) prefs.getInt(HPlusConstants.PREF_HPLUS_UNIT + "_" + address, 0); + String units = prefs.getString(HPlusConstants.PREF_HPLUS_UNIT, getContext().getString(R.string.p_unit_metric)); + + if(units.equals(getContext().getString(R.string.p_unit_metric))){ + return HPlusConstants.ARG_UNIT_METRIC; + }else{ + return HPlusConstants.ARG_UNIT_IMPERIAL; + } } public static byte getUserWeight(String address) { @@ -190,15 +218,17 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator { } public static byte getScreenTime(String address) { - return (byte) (prefs.getInt(HPlusConstants.PREF_HPLUS_SCREENTIME + "_" + address, 5) & 0xFF); + return (byte) (prefs.getInt(HPlusConstants.PREF_HPLUS_SCREENTIME, 5) & 0xFF); } public static byte getAllDayHR(String address) { - return (byte) (prefs.getInt(HPlusConstants.PREF_HPLUS_ALLDAYHR + "_" + address, HPlusConstants.ARG_HEARTRATE_ALLDAY_ON) & 0xFF); - } + Boolean value = (prefs.getBoolean(HPlusConstants.PREF_HPLUS_ALLDAYHR, true)); - public static byte getHRState(String address) { - return (byte) (prefs.getInt(HPlusConstants.PREF_HPLUS_HR + "_" + address, HPlusConstants.ARG_HEARTRATE_MEASURE_ON) & 0xFF); + if(value){ + return HPlusConstants.ARG_HEARTRATE_ALLDAY_ON; + }else{ + return HPlusConstants.ARG_HEARTRATE_ALLDAY_OFF; + } } public static byte getSocial(String address) { @@ -208,15 +238,21 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator { } public static byte getUserWrist(String address) { - return (byte) (prefs.getInt(HPlusConstants.PREF_HPLUS_WRIST + "_" + address, 10) & 0xFF); + String value = prefs.getString(HPlusConstants.PREF_HPLUS_WRIST, getContext().getString(R.string.left)); + + if(value.equals(getContext().getString(R.string.left))){ + return HPlusConstants.ARG_WRIST_LEFT; + }else{ + return HPlusConstants.ARG_WRIST_RIGHT; + } } public static int getSITStartTime(String address) { - return prefs.getInt(HPlusConstants.PREF_HPLUS_SIT_START_TIME + "_" + address, 0); + return prefs.getInt(HPlusConstants.PREF_HPLUS_SIT_START_TIME, 0); } public static int getSITEndTime(String address) { - return prefs.getInt(HPlusConstants.PREF_HPLUS_SIT_END_TIME + "_" + address, 0); + return prefs.getInt(HPlusConstants.PREF_HPLUS_SIT_END_TIME, 0); } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java index 6ddffffb..25513755 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java @@ -172,6 +172,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport { private HPlusSupport setTimeMode(TransactionBuilder transaction) { byte value = HPlusCoordinator.getTimeMode(getDevice().getAddress()); + transaction.write(ctrlCharacteristic, new byte[]{ HPlusConstants.CMD_SET_TIMEMODE, value @@ -333,15 +334,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport { private HPlusSupport setAllDayHeart(TransactionBuilder transaction) { - byte value = HPlusCoordinator.getHRState(getDevice().getAddress()); - - transaction.write(ctrlCharacteristic, new byte[]{ - HPlusConstants.CMD_SET_HEARTRATE_STATE, - value - }); - - - value = HPlusCoordinator.getAllDayHR(getDevice().getAddress()); + byte value = HPlusCoordinator.getAllDayHR(getDevice().getAddress()); transaction.write(ctrlCharacteristic, new byte[]{ HPlusConstants.CMD_SET_ALLDAY_HRM, @@ -481,7 +474,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport { @Override public void onEnableRealtimeSteps(boolean enable) { - + onEnableRealtimeHeartRateMeasurement(enable); } @Override diff --git a/app/src/main/res/drawable-hdpi/ic_device_hplus.png b/app/src/main/res/drawable-hdpi/ic_device_hplus.png new file mode 100644 index 00000000..7af95bdd Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_device_hplus.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_device_hplus_disabled.png b/app/src/main/res/drawable-hdpi/ic_device_hplus_disabled.png new file mode 100644 index 00000000..a4a7d7fd Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_device_hplus_disabled.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_device_hplus.png b/app/src/main/res/drawable-mdpi/ic_device_hplus.png new file mode 100644 index 00000000..88e4c9c1 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_device_hplus.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_device_hplus_disabled.png b/app/src/main/res/drawable-mdpi/ic_device_hplus_disabled.png new file mode 100644 index 00000000..84496f3e Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_device_hplus_disabled.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_device_hplus.png b/app/src/main/res/drawable-xhdpi/ic_device_hplus.png new file mode 100644 index 00000000..e91f060f Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_device_hplus.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_device_hplus_disabled.png b/app/src/main/res/drawable-xhdpi/ic_device_hplus_disabled.png new file mode 100644 index 00000000..2c3f219c Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_device_hplus_disabled.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_device_hplus.png b/app/src/main/res/drawable-xxhdpi/ic_device_hplus.png new file mode 100644 index 00000000..01996225 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_device_hplus.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_device_hplus_disabled.png b/app/src/main/res/drawable-xxhdpi/ic_device_hplus_disabled.png new file mode 100644 index 00000000..a70528df Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_device_hplus_disabled.png differ diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index e2aff8f5..63bbb310 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -122,4 +122,24 @@ @string/p_dateformat_datetime + + @string/unit_metric + @string/unit_imperial + + + + @string/p_unit_metric + @string/p_unit_imperial + + + + @string/timeformat_24h + @string/timeformat_am_pm + + + + @string/p_timeformat_24h + @string/p_timeformat_am_pm + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 88226d4c..d72def7f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -142,6 +142,13 @@ Reconnection Attempts + //HPlus Preferences + Units + Time format + Screen on duration + All day heart rate measurement + HPlus/Makibes Settings + not connected connecting connected @@ -382,4 +389,11 @@ Make sure that this skin is enabled in the Weather Notification app to get weather information on your Pebble.\n\nNo configuration is needed here.\n\nYou can enable the system weather app of your Pebble from the app management.\n\nSupported watchfaces will show the weather automatically. Enable Bluetooth pairing Deactivate this if you have trouble connecting + + Metric + Imperial + + 24H + AM/PM + diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml index df90cb5b..d8a8eff7 100644 --- a/app/src/main/res/values/values.xml +++ b/app/src/main/res/values/values.xml @@ -12,4 +12,10 @@ dateformat_time dateformat_datetime + metric + imperial + + 24h + am/pm + diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 39c7d9ed..e9df02ac 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -388,6 +388,51 @@ android:title="Emulator Port" /> + + + + + + + + + + + + + + + +