From d3571d53b22aaf97b7931e75e40dd5979dcd4de4 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Wed, 26 Oct 2016 00:03:54 +0200 Subject: [PATCH] Mi Band: allow to remove mac address from preferences (this allows to clear an extra mi band from the control center) Evil hack... --- .../miband/MiBandPreferencesActivity.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandPreferencesActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandPreferencesActivity.java index c96128ae..4c8de0aa 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandPreferencesActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandPreferencesActivity.java @@ -34,6 +34,20 @@ public class MiBandPreferencesActivity extends AbstractSettingsActivity { addPreferencesFromResource(R.xml.miband_preferences); + addTryListeners(); + + final Preference enableHeartrateSleepSupport = findPreference(PREF_MIBAND_USE_HR_FOR_SLEEP_DETECTION); + enableHeartrateSleepSupport.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + GBApplication.deviceService().onEnableHeartRateSleepSupport(Boolean.TRUE.equals(newVal)); + return true; + } + }); + } + + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); final Preference developmentMiaddr = findPreference(PREF_MIBAND_ADDRESS); developmentMiaddr.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override @@ -45,17 +59,6 @@ public class MiBandPreferencesActivity extends AbstractSettingsActivity { } }); - - addTryListeners(); - - final Preference enableHeartrateSleepSupport = findPreference(PREF_MIBAND_USE_HR_FOR_SLEEP_DETECTION); - enableHeartrateSleepSupport.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newVal) { - GBApplication.deviceService().onEnableHeartRateSleepSupport(Boolean.TRUE.equals(newVal)); - return true; - } - }); } private void addTryListeners() {