diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java
index f11e7ac65..242743746 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java
@@ -51,6 +51,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.CalBlacklistActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.ConfigureWorldClocks;
+import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
@@ -349,79 +350,7 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
});
}
- final Preference enableHeartrateSleepSupport = findPreference(PREF_HEARTRATE_USE_FOR_SLEEP_DETECTION);
- if (enableHeartrateSleepSupport != null) {
- enableHeartrateSleepSupport.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newVal) {
- GBApplication.deviceService(device).onEnableHeartRateSleepSupport(Boolean.TRUE.equals(newVal));
- return true;
- }
- });
- }
- addPreferenceHandlerFor(PREF_HEARTRATE_ALERT_HIGH_THRESHOLD);
- addPreferenceHandlerFor(PREF_HEARTRATE_ALERT_LOW_THRESHOLD);
-
- final ListPreference heartrateMeasurementInterval = findPreference(PREF_HEARTRATE_MEASUREMENT_INTERVAL);
- final ListPreference heartrateAlertHigh = findPreference(PREF_HEARTRATE_ALERT_HIGH_THRESHOLD);
- final ListPreference heartrateAlertLow = findPreference(PREF_HEARTRATE_ALERT_LOW_THRESHOLD);
- // Newer devices that have low alert threshold can only use it if measurement interval is smart (-1) or 1 minute
- final boolean hrAlertsNeedSmartOrOne = heartrateAlertHigh != null && heartrateAlertLow != null && heartrateMeasurementInterval != null;
- if (hrAlertsNeedSmartOrOne) {
- final boolean hrMonitoringIsSmartOrOne = heartrateMeasurementInterval.getValue().equals("60") ||
- heartrateMeasurementInterval.getValue().equals("-1");
-
- heartrateAlertHigh.setEnabled(hrMonitoringIsSmartOrOne);
- heartrateAlertLow.setEnabled(hrMonitoringIsSmartOrOne);
- }
-
- if (heartrateMeasurementInterval != null) {
- final SwitchPreference activityMonitoring = findPreference(PREF_HEARTRATE_ACTIVITY_MONITORING);
- final SwitchPreference heartrateAlertEnabled = findPreference(PREF_HEARTRATE_ALERT_ENABLED);
- final SwitchPreference stressMonitoring = findPreference(PREF_HEARTRATE_STRESS_MONITORING);
-
- heartrateMeasurementInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
- public boolean onPreferenceChange(final Preference preference, final Object newVal) {
- GBApplication.deviceService(device).onSetHeartRateMeasurementInterval(Integer.parseInt((String) newVal));
-
- final boolean isMeasurementIntervalEnabled = !newVal.equals("0");
-
- if (activityMonitoring != null) {
- activityMonitoring.setEnabled(isMeasurementIntervalEnabled);
- }
- if (heartrateAlertEnabled != null) {
- heartrateAlertEnabled.setEnabled(isMeasurementIntervalEnabled);
- }
- if (hrAlertsNeedSmartOrOne) {
- // Same as above, check if smart or 1 minute
- final boolean hrMonitoringIsSmartOrOne = newVal.equals("60") || newVal.equals("-1");
-
- heartrateAlertHigh.setEnabled(hrMonitoringIsSmartOrOne);
- heartrateAlertLow.setEnabled(hrMonitoringIsSmartOrOne);
- }
- if (stressMonitoring != null && !hrAlertsNeedSmartOrOne) {
- // Newer devices (that have hrAlertsNeedSmartOrOne) also don't need HR monitoring for stress monitoring
- stressMonitoring.setEnabled(isMeasurementIntervalEnabled);
- }
-
- return true;
- }
- });
-
- final boolean isMeasurementIntervalEnabled = !heartrateMeasurementInterval.getValue().equals("0");
-
- if (activityMonitoring != null) {
- activityMonitoring.setEnabled(isMeasurementIntervalEnabled);
- }
- if (heartrateAlertEnabled != null) {
- heartrateAlertEnabled.setEnabled(isMeasurementIntervalEnabled);
- }
- if (stressMonitoring != null && !hrAlertsNeedSmartOrOne) {
- // Newer devices (that have hrAlertsNeedSmartOrOne) also don't need HR monitoring for stress monitoring
- stressMonitoring.setEnabled(isMeasurementIntervalEnabled);
- }
- }
addPreferenceHandlerFor(PREF_SWIPE_UNLOCK);
addPreferenceHandlerFor(PREF_MI2_DATEFORMAT);
@@ -828,6 +757,7 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, InputType.TYPE_CLASS_NUMBER);
new PasswordCapabilityImpl().registerPreferences(getContext(), coordinator.getPasswordCapability(), this);
+ new HeartRateCapability().registerPreferences(getContext(), coordinator.getHeartRateMeasurementIntervals(), this);
String deviceActionsFellSleepSelection = prefs.getString(PREF_DEVICE_ACTION_FELL_SLEEP_SELECTION, PREF_DEVICE_ACTION_SELECTION_OFF);
final Preference deviceActionsFellSleep = findPreference(PREF_DEVICE_ACTION_FELL_SLEEP_SELECTION);
@@ -1018,6 +948,11 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
}
}
+ @Override
+ public GBDevice getDevice() {
+ return device;
+ }
+
/**
* Keys of preferences which should print its values as a summary below the preference name.
*/
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsHandler.java
index 97917e837..c6d1732f5 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsHandler.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsHandler.java
@@ -19,6 +19,8 @@ package nodomain.freeyourgadget.gadgetbridge.activities.devicesettings;
import androidx.annotation.NonNull;
import androidx.preference.Preference;
+import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
+
/**
* A device-specific preference handler, that allows for {@link nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator}s to register
* their own preferences dynamically.
@@ -61,4 +63,11 @@ public interface DeviceSpecificSettingsHandler {
* @param editTypeFlags the edit type {@link android.text.InputType} flags.
*/
void setInputTypeFor(final String preferenceKey, final int editTypeFlags);
+
+ /**
+ * Get the device associated with this {@link DeviceSpecificSettingsHandler}.
+ *
+ * @return the {@link GBDevice}.
+ */
+ GBDevice getDevice();
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/capabilities/HeartRateCapability.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/capabilities/HeartRateCapability.java
new file mode 100644
index 000000000..c855c6203
--- /dev/null
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/capabilities/HeartRateCapability.java
@@ -0,0 +1,158 @@
+/* Copyright (C) 2022 José Rebelo
+
+ This file is part of Gadgetbridge.
+
+ Gadgetbridge is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Gadgetbridge is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see . */
+package nodomain.freeyourgadget.gadgetbridge.capabilities;
+
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HEARTRATE_ACTIVITY_MONITORING;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HEARTRATE_ALERT_ENABLED;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HEARTRATE_ALERT_HIGH_THRESHOLD;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HEARTRATE_ALERT_LOW_THRESHOLD;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HEARTRATE_MEASUREMENT_INTERVAL;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HEARTRATE_STRESS_MONITORING;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HEARTRATE_USE_FOR_SLEEP_DETECTION;
+
+import android.content.Context;
+
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import java.util.List;
+
+import nodomain.freeyourgadget.gadgetbridge.GBApplication;
+import nodomain.freeyourgadget.gadgetbridge.R;
+import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler;
+
+public class HeartRateCapability {
+ public enum MeasurementInterval {
+ OFF(0, R.string.off),
+ SMART(-1, R.string.smart),
+ MINUTES_1(60, R.string.interval_one_minute),
+ MINUTES_5(300, R.string.interval_five_minutes),
+ MINUTES_10(600, R.string.interval_ten_minutes),
+ MINUTES_15(900, R.string.interval_fifteen_minutes),
+ MINUTES_30(1800, R.string.interval_thirty_minutes),
+ MINUTES_45(2700, R.string.interval_forty_five_minutes),
+ HOUR_1(3600, R.string.interval_one_hour),
+ ;
+
+ private final int intervalSeconds;
+ private final int label;
+
+ MeasurementInterval(final int intervalSeconds, final int label) {
+ this.intervalSeconds = intervalSeconds;
+ this.label = label;
+ }
+
+ public int getIntervalSeconds() {
+ return intervalSeconds;
+ }
+
+ public int getLabel() {
+ return label;
+ }
+
+ public String getLabel(final Context context) {
+ return context.getString(label);
+ }
+ }
+
+ public void registerPreferences(final Context context, final List intervals, final DeviceSpecificSettingsHandler handler) {
+ final Preference enableHeartrateSleepSupport = handler.findPreference(PREF_HEARTRATE_USE_FOR_SLEEP_DETECTION);
+ if (enableHeartrateSleepSupport != null) {
+ enableHeartrateSleepSupport.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newVal) {
+ GBApplication.deviceService(handler.getDevice()).onEnableHeartRateSleepSupport(Boolean.TRUE.equals(newVal));
+ return true;
+ }
+ });
+ }
+
+ handler.addPreferenceHandlerFor(PREF_HEARTRATE_ALERT_HIGH_THRESHOLD);
+ handler.addPreferenceHandlerFor(PREF_HEARTRATE_ALERT_LOW_THRESHOLD);
+
+ final ListPreference heartrateMeasurementInterval = handler.findPreference(PREF_HEARTRATE_MEASUREMENT_INTERVAL);
+ final ListPreference heartrateAlertHigh = handler.findPreference(PREF_HEARTRATE_ALERT_HIGH_THRESHOLD);
+ final ListPreference heartrateAlertLow = handler.findPreference(PREF_HEARTRATE_ALERT_LOW_THRESHOLD);
+ // Newer devices that have low alert threshold can only use it if measurement interval is smart (-1) or 1 minute
+ final boolean hrAlertsNeedSmartOrOne = heartrateAlertHigh != null && heartrateAlertLow != null && heartrateMeasurementInterval != null;
+ if (hrAlertsNeedSmartOrOne) {
+ final boolean hrMonitoringIsSmartOrOne = heartrateMeasurementInterval.getValue().equals("60") ||
+ heartrateMeasurementInterval.getValue().equals("-1");
+
+ heartrateAlertHigh.setEnabled(hrMonitoringIsSmartOrOne);
+ heartrateAlertLow.setEnabled(hrMonitoringIsSmartOrOne);
+ }
+
+ if (heartrateMeasurementInterval != null) {
+ // Set the measurement intervals dynamically, as per the device's capability
+ final CharSequence[] entries = new CharSequence[intervals.size()];
+ final CharSequence[] values = new CharSequence[intervals.size()];
+ for (int i = 0; i < intervals.size(); i++) {
+ entries[i] = intervals.get(i).getLabel(context);
+ values[i] = String.valueOf(intervals.get(i).getIntervalSeconds());
+ }
+ heartrateMeasurementInterval.setEntries(entries);
+ heartrateMeasurementInterval.setEntryValues(values);
+
+ final SwitchPreference activityMonitoring = handler.findPreference(PREF_HEARTRATE_ACTIVITY_MONITORING);
+ final SwitchPreference heartrateAlertEnabled = handler.findPreference(PREF_HEARTRATE_ALERT_ENABLED);
+ final SwitchPreference stressMonitoring = handler.findPreference(PREF_HEARTRATE_STRESS_MONITORING);
+
+ heartrateMeasurementInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ public boolean onPreferenceChange(final Preference preference, final Object newVal) {
+ GBApplication.deviceService(handler.getDevice()).onSetHeartRateMeasurementInterval(Integer.parseInt((String) newVal));
+
+ final boolean isMeasurementIntervalEnabled = !newVal.equals("0");
+
+ if (activityMonitoring != null) {
+ activityMonitoring.setEnabled(isMeasurementIntervalEnabled);
+ }
+ if (heartrateAlertEnabled != null) {
+ heartrateAlertEnabled.setEnabled(isMeasurementIntervalEnabled);
+ }
+ if (hrAlertsNeedSmartOrOne) {
+ // Same as above, check if smart or 1 minute
+ final boolean hrMonitoringIsSmartOrOne = newVal.equals("60") || newVal.equals("-1");
+
+ heartrateAlertHigh.setEnabled(hrMonitoringIsSmartOrOne);
+ heartrateAlertLow.setEnabled(hrMonitoringIsSmartOrOne);
+ }
+ if (stressMonitoring != null && !hrAlertsNeedSmartOrOne) {
+ // Newer devices (that have hrAlertsNeedSmartOrOne) also don't need HR monitoring for stress monitoring
+ stressMonitoring.setEnabled(isMeasurementIntervalEnabled);
+ }
+
+ return true;
+ }
+ });
+
+ final boolean isMeasurementIntervalEnabled = !heartrateMeasurementInterval.getValue().equals("0");
+
+ if (activityMonitoring != null) {
+ activityMonitoring.setEnabled(isMeasurementIntervalEnabled);
+ }
+ if (heartrateAlertEnabled != null) {
+ heartrateAlertEnabled.setEnabled(isMeasurementIntervalEnabled);
+ }
+ if (stressMonitoring != null && !hrAlertsNeedSmartOrOne) {
+ // Newer devices (that have hrAlertsNeedSmartOrOne) also don't need HR monitoring for stress monitoring
+ stressMonitoring.setEnabled(isMeasurementIntervalEnabled);
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/capabilities/password/PasswordCapabilityImpl.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/capabilities/password/PasswordCapabilityImpl.java
index adaea4027..069336ad7 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/capabilities/password/PasswordCapabilityImpl.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/capabilities/password/PasswordCapabilityImpl.java
@@ -31,14 +31,13 @@ import java.util.ArrayList;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.R;
-import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler;
public class PasswordCapabilityImpl {
public static final String PREF_PASSWORD = "pref_password";
public static final String PREF_PASSWORD_ENABLED = "pref_password_enabled";
- public static enum Mode {
+ public enum Mode {
NONE,
NUMBERS_4_DIGITS_1_TO_4,
NUMBERS_6,
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java
index 18a5998a3..90cc4ed74 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java
@@ -32,14 +32,17 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
+import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
@@ -343,4 +346,16 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
public PasswordCapabilityImpl.Mode getPasswordCapability() {
return PasswordCapabilityImpl.Mode.NONE;
}
+
+ @Override
+ public List getHeartRateMeasurementIntervals() {
+ return Arrays.asList(
+ HeartRateCapability.MeasurementInterval.OFF,
+ HeartRateCapability.MeasurementInterval.MINUTES_1,
+ HeartRateCapability.MeasurementInterval.MINUTES_5,
+ HeartRateCapability.MeasurementInterval.MINUTES_10,
+ HeartRateCapability.MeasurementInterval.MINUTES_30,
+ HeartRateCapability.MeasurementInterval.HOUR_1
+ );
+ }
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java
index 438713174..4cfa35513 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java
@@ -28,11 +28,13 @@ import android.os.Build;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
+import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
+import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@@ -448,4 +450,6 @@ public interface DeviceCoordinator {
boolean supportsPowerOff();
PasswordCapabilityImpl.Mode getPasswordCapability();
+
+ List getHeartRateMeasurementIntervals();
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java
index 9951ccdf6..6d35b0f6c 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java
@@ -26,7 +26,11 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Arrays;
+import java.util.List;
+
import nodomain.freeyourgadget.gadgetbridge.R;
+import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@@ -147,4 +151,15 @@ public class MiBand4Coordinator extends HuamiCoordinator {
public PasswordCapabilityImpl.Mode getPasswordCapability() {
return PasswordCapabilityImpl.Mode.NUMBERS_4_DIGITS_1_TO_4;
}
+
+ @Override
+ public List getHeartRateMeasurementIntervals() {
+ return Arrays.asList(
+ HeartRateCapability.MeasurementInterval.OFF,
+ HeartRateCapability.MeasurementInterval.MINUTES_1,
+ HeartRateCapability.MeasurementInterval.MINUTES_5,
+ HeartRateCapability.MeasurementInterval.MINUTES_10,
+ HeartRateCapability.MeasurementInterval.MINUTES_30
+ );
+ }
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband5/MiBand5Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband5/MiBand5Coordinator.java
index 2880331e5..310c6186d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband5/MiBand5Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband5/MiBand5Coordinator.java
@@ -26,7 +26,11 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Arrays;
+import java.util.List;
+
import nodomain.freeyourgadget.gadgetbridge.R;
+import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@@ -160,4 +164,15 @@ public class MiBand5Coordinator extends HuamiCoordinator {
public int getBondingStyle() {
return BONDING_STYLE_REQUIRE_KEY;
}
+
+ @Override
+ public List getHeartRateMeasurementIntervals() {
+ return Arrays.asList(
+ HeartRateCapability.MeasurementInterval.OFF,
+ HeartRateCapability.MeasurementInterval.MINUTES_1,
+ HeartRateCapability.MeasurementInterval.MINUTES_5,
+ HeartRateCapability.MeasurementInterval.MINUTES_10,
+ HeartRateCapability.MeasurementInterval.MINUTES_30
+ );
+ }
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband6/MiBand6Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband6/MiBand6Coordinator.java
index 5f7ee89ea..c71a96bad 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband6/MiBand6Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband6/MiBand6Coordinator.java
@@ -10,6 +10,10 @@ import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
+import java.util.Arrays;
+import java.util.List;
+
+import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@@ -146,4 +150,15 @@ public class MiBand6Coordinator extends HuamiCoordinator {
public PasswordCapabilityImpl.Mode getPasswordCapability() {
return PasswordCapabilityImpl.Mode.NUMBERS_6;
}
+
+ @Override
+ public List getHeartRateMeasurementIntervals() {
+ return Arrays.asList(
+ HeartRateCapability.MeasurementInterval.OFF,
+ HeartRateCapability.MeasurementInterval.MINUTES_1,
+ HeartRateCapability.MeasurementInterval.MINUTES_5,
+ HeartRateCapability.MeasurementInterval.MINUTES_10,
+ HeartRateCapability.MeasurementInterval.MINUTES_30
+ );
+ }
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7Coordinator.java
index 3cb3c2ad4..de7d83111 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7Coordinator.java
@@ -25,14 +25,15 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Arrays;
+import java.util.List;
+
import nodomain.freeyourgadget.gadgetbridge.R;
+import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
-import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
-import nodomain.freeyourgadget.gadgetbridge.entities.AbstractActivitySample;
-import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
@@ -139,4 +140,15 @@ public class MiBand7Coordinator extends Huami2021Coordinator {
public PasswordCapabilityImpl.Mode getPasswordCapability() {
return PasswordCapabilityImpl.Mode.NUMBERS_6;
}
+
+ @Override
+ public List getHeartRateMeasurementIntervals() {
+ return Arrays.asList(
+ HeartRateCapability.MeasurementInterval.OFF,
+ HeartRateCapability.MeasurementInterval.SMART,
+ HeartRateCapability.MeasurementInterval.MINUTES_1,
+ HeartRateCapability.MeasurementInterval.MINUTES_10,
+ HeartRateCapability.MeasurementInterval.MINUTES_30
+ );
+ }
}
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 08854b649..3c4c81ef1 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -1742,37 +1742,13 @@
+
- @string/off
- - @string/interval_one_minute
- - @string/interval_five_minutes
- - @string/interval_ten_minutes
- - @string/interval_thirty_minutes
- - @string/interval_one_hour
+
- 0
- - 60
- - 300
- - 600
- - 1800
- - 3600
-
-
-
- - @string/off
- - @string/smart
- - @string/interval_one_minute
- - @string/interval_ten_minutes
- - @string/interval_thirty_minutes
-
-
-
- - 0
- - -1
- - 60
- - 600
- - 1800
diff --git a/app/src/main/res/xml/devicesettings_heartrate_sleep_alert_activity_stress_spo2.xml b/app/src/main/res/xml/devicesettings_heartrate_sleep_alert_activity_stress_spo2.xml
index de10b371b..70052caa1 100644
--- a/app/src/main/res/xml/devicesettings_heartrate_sleep_alert_activity_stress_spo2.xml
+++ b/app/src/main/res/xml/devicesettings_heartrate_sleep_alert_activity_stress_spo2.xml
@@ -30,8 +30,8 @@