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 34143003d..1242801a5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java @@ -405,8 +405,6 @@ public class SettingsActivity extends AbstractSettingsActivity { } }); - - /* final Preference miBand3DisplayItems = findPreference("miband3_display_items"); miBand3DisplayItems.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override @@ -420,7 +418,6 @@ public class SettingsActivity extends AbstractSettingsActivity { return true; } }); - */ final Preference corDisplayItems = findPreference("cor_display_items"); corDisplayItems.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3Service.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3Service.java index e8bf6dd9b..31cdf89ad 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3Service.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3Service.java @@ -22,7 +22,7 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.EN import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.ENDPOINT_DISPLAY_ITEMS; public class MiBand3Service { - public static final byte[] COMMAND_CHANGE_SCREENS = new byte[]{ENDPOINT_DISPLAY_ITEMS, DISPLAY_ITEM_BIT_CLOCK, 0x30, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; + public static final byte[] COMMAND_CHANGE_SCREENS = new byte[]{ENDPOINT_DISPLAY_ITEMS, DISPLAY_ITEM_BIT_CLOCK, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00}; public static final byte[] COMMAND_ENABLE_BAND_SCREEN_UNLOCK = new byte[]{ENDPOINT_DISPLAY, 0x16, 0x00, 0x01}; public static final byte[] COMMAND_DISABLE_BAND_SCREEN_UNLOCK = new byte[]{ENDPOINT_DISPLAY, 0x16, 0x00, 0x00}; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband3/MiBand3Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband3/MiBand3Support.java index faeed4a05..94402e4cb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband3/MiBand3Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband3/MiBand3Support.java @@ -43,33 +43,46 @@ public class MiBand3Support extends AmazfitBipSupport { private static final Logger LOG = LoggerFactory.getLogger(MiBand3Support.class); @Override - protected AmazfitBipSupport setDisplayItems(TransactionBuilder builder) { - if (true) { - return this; - } - + protected MiBand3Support setDisplayItems(TransactionBuilder builder) { Prefs prefs = GBApplication.getPrefs(); Set pages = prefs.getStringSet("miband3_display_items", null); LOG.info("Setting display items to " + (pages == null ? "none" : pages)); byte[] command = MiBand3Service.COMMAND_CHANGE_SCREENS.clone(); + byte pos = 1; if (pages != null) { - if (pages.contains("notifications")) { - command[1] |= 0x02; - } - if (pages.contains("weather")) { - command[1] |= 0x04; - } - if (pages.contains("more")) { - command[1] |= 0x10; - } - if (pages.contains("status")) { - command[1] |= 0x20; - } - if (pages.contains("heart_rate")) { - command[1] |= 0x40; + for (String page : pages) { + switch (page) { + case "notifications": + command[1] |= 0x02; + command[4] = pos++; + break; + case "weather": + command[1] |= 0x04; + command[5] = pos++; + break; + case "more": + command[1] |= 0x10; + command[7] = pos++; + break; + case "status": + command[1] |= 0x20; + command[8] = pos++; + break; + case "heart_rate": + command[1] |= 0x40; + command[9] = pos++; + break; + } } } + + for (int i = 4; i <= 9; i++) { + if (command[i] == 0) { + command[i] = pos++; + } + } + builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), command); return this; diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index ea71718ee..bd1f20a53 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -217,7 +217,6 @@ android:key="mi3_band_screen_unlock" android:summary="@string/mi3_prefs_band_screen_unlock_summary" android:title="@string/mi3_prefs_band_screen_unlock" /> -