From 5570ac8349a6b432948a930112d718f35dc52f8f Mon Sep 17 00:00:00 2001 From: Cre3per Date: Tue, 8 Oct 2019 17:18:41 +0200 Subject: [PATCH] makibes hr3. added fakeBattery. fixed string comparison using operator. --- .../makibeshr3/MakibesHR3Coordinator.java | 4 ++-- .../makibeshr3/MakibesHR3DeviceSupport.java | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/makibeshr3/MakibesHR3Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/makibeshr3/MakibesHR3Coordinator.java index 8ac310f80..d0aff0442 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/makibeshr3/MakibesHR3Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/makibeshr3/MakibesHR3Coordinator.java @@ -55,14 +55,14 @@ public class MakibesHR3Coordinator extends AbstractDeviceCoordinator { String liftMode = sharedPrefs.getString(MakibesHR3Constants.PREF_HEADS_UP_SCREEN, getContext().getString(R.string.p_on)); // Makibes HR3 doesn't support scheduled intervals. Treat it as "on". - return (liftMode != getContext().getString(R.string.p_off)); + return !liftMode.equals(getContext().getString(R.string.p_off)); } public static boolean shouldEnableLostReminder(SharedPreferences sharedPrefs) { String lostReminder = sharedPrefs.getString(MakibesHR3Constants.PREF_LOST_REMINDER, getContext().getString(R.string.p_on)); // Makibes HR3 doesn't support scheduled intervals. Treat it as "on". - return (lostReminder != getContext().getString(R.string.p_off)); + return !lostReminder.equals(getContext().getString(R.string.p_off)); } public static byte getTimeMode(SharedPreferences sharedPrefs) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/makibeshr3/MakibesHR3DeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/makibeshr3/MakibesHR3DeviceSupport.java index 0933ac88d..8249f0de0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/makibeshr3/MakibesHR3DeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/makibeshr3/MakibesHR3DeviceSupport.java @@ -4,8 +4,6 @@ // TODO: All the commands that aren't supported by GB should be added to device specific settings. -// TODO: GB doesn't always display the step count even though there's a sample in the db. - // TODO: It'd be cool if we could change the language. There's no official way to do so, but the // TODO: watch is sold as chinese/english. Screen-on-time would be nice too. @@ -560,8 +558,26 @@ public class MakibesHR3DeviceSupport extends AbstractBTLEDeviceSupport implement } } + /** + * Use to show the battery icon in the device card. + * If the icon shows up later, the user might be trying to tap one thing but the battery icon + * will shift everything. + * This is hacky. There should be a "supportsBattery" function in the coordinator that displays + * the battery icon before the battery level is received. + */ + private void fakeBattery() { + GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo(); + + batteryInfo.level = 100; + batteryInfo.state = BatteryState.UNKNOWN; + + this.handleGBDeviceEvent(batteryInfo); + } + @Override protected TransactionBuilder initializeDevice(TransactionBuilder builder) { + this.fakeBattery(); + GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), true, 0, getContext()); gbDevice.setState(GBDevice.State.INITIALIZING);