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 90d75ef58..f5c04e7cd 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
@@ -16,13 +16,17 @@ import org.slf4j.LoggerFactory;
import java.util.Objects;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
+import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.makibeshr3.MakibesHR3Constants;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.XTimePreference;
import nodomain.freeyourgadget.gadgetbridge.util.XTimePreferenceFragment;
-import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.*;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DATEFORMAT;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SCREEN_ORIENTATION;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION_END;
@@ -370,25 +374,12 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
});
}
- EditTextPreference mibandTimeOffset = findPreference(MiBandConst.PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS);
- if (mibandTimeOffset != null) {
- mibandTimeOffset.setOnBindEditTextListener(new EditTextPreference.OnBindEditTextListener() {
- @Override
- public void onBindEditText(@NonNull EditText editText) {
- editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
- }
- });
- }
+ setInputTypeFor(HuamiConst.PREF_BUTTON_ACTION_BROADCAST_DELAY, InputType.TYPE_CLASS_NUMBER);
+ setInputTypeFor(HuamiConst.PREF_BUTTON_ACTION_PRESS_MAX_INTERVAL, InputType.TYPE_CLASS_NUMBER);
+ setInputTypeFor(HuamiConst.PREF_BUTTON_ACTION_PRESS_COUNT, InputType.TYPE_CLASS_NUMBER);
+ setInputTypeFor(MiBandConst.PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS, InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
+ setInputTypeFor(MakibesHR3Constants.PREF_FIND_PHONE_DURATION, InputType.TYPE_CLASS_NUMBER);
- EditTextPreference findPhoneDuration = findPreference(MakibesHR3Constants.PREF_FIND_PHONE_DURATION);
- if (findPhoneDuration != null) {
- findPhoneDuration.setOnBindEditTextListener(new EditTextPreference.OnBindEditTextListener() {
- @Override
- public void onBindEditText(@NonNull EditText editText) {
- editText.setInputType(InputType.TYPE_CLASS_NUMBER);
- }
- });
- }
}
static DeviceSpecificSettingsFragment newInstance(String settingsFileSuffix, @NonNull int[] supportedSettings) {
@@ -431,4 +422,16 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
});
}
}
+
+ private void setInputTypeFor(final String preferenceKey, final int editTypeFlags) {
+ EditTextPreference textPreference = findPreference(preferenceKey);
+ if (textPreference != null) {
+ textPreference.setOnBindEditTextListener(new EditTextPreference.OnBindEditTextListener() {
+ @Override
+ public void onBindEditText(@NonNull EditText editText) {
+ editText.setInputType(editTypeFlags);
+ }
+ });
+ }
+ }
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java
index 891a14c0e..ada18bb2d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java
@@ -63,6 +63,13 @@ public class HuamiConst {
public static final String PREF_EXPOSE_HR_THIRDPARTY = "expose_hr_thirdparty";
public static final String PREF_USE_CUSTOM_FONT = "use_custom_font";
+ public static final String PREF_BUTTON_ACTION_ENABLE = "button_action_enable";
+ public static final String PREF_BUTTON_ACTION_VIBRATE = "button_action_vibrate";
+ public static final String PREF_BUTTON_ACTION_PRESS_COUNT = "button_action_press_count";
+ public static final String PREF_BUTTON_ACTION_PRESS_MAX_INTERVAL = "button_action_press_max_interval";
+ public static final String PREF_BUTTON_ACTION_BROADCAST_DELAY = "button_action_broadcast_delay";
+ public static final String PREF_BUTTON_ACTION_BROADCAST = "button_action_broadcast";
+
public static int toActivityKind(int rawType) {
switch (rawType) {
case TYPE_DEEP_SLEEP:
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipCoordinator.java
index 7de49a73c..1b28bb5e6 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipCoordinator.java
@@ -86,6 +86,7 @@ public class AmazfitBipCoordinator extends HuamiCoordinator {
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_expose_hr_thirdparty,
+ R.xml.devicesettings_buttonactions,
R.xml.devicesettings_pairingkey
};
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2Coordinator.java
index b087dbe1d..f39fd61f7 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2Coordinator.java
@@ -84,6 +84,7 @@ public class MiBand2Coordinator extends HuamiCoordinator {
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_rotatewrist_cycleinfo,
R.xml.devicesettings_expose_hr_thirdparty,
+ R.xml.devicesettings_buttonactions,
R.xml.devicesettings_pairingkey
};
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandConst.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandConst.java
index 7e2ab22a7..ff7b69883 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandConst.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandConst.java
@@ -27,12 +27,6 @@ public final class MiBandConst {
public static final String PREF_MIBAND_ALARMS = "mi_alarms";
public static final String PREF_MIBAND_DONT_ACK_TRANSFER = "mi_dont_ack_transfer";
public static final String PREF_MIBAND_RESERVE_ALARM_FOR_CALENDAR = "mi_reserve_alarm_calendar";
- public static final String PREF_MIBAND_BUTTON_ACTION_ENABLE = "mi2_enable_button_action";
- public static final String PREF_MIBAND_BUTTON_ACTION_VIBRATE = "mi2_button_action_vibrate";
- public static final String PREF_MIBAND_BUTTON_PRESS_COUNT = "mi_button_press_count";
- public static final String PREF_MIBAND_BUTTON_PRESS_MAX_DELAY = "mi_button_press_count_max_delay";
- public static final String PREF_MIBAND_BUTTON_ACTION_DELAY = "mi_button_press_count_match_delay";
- public static final String PREF_MIBAND_BUTTON_PRESS_BROADCAST = "mi_button_press_broadcast";
public static final String PREF_MIBAND_USE_HR_FOR_SLEEP_DETECTION = "mi_hr_sleep_detection";
public static final String PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS = "device_time_offset_hours";
public static final String PREF_MI2_DATEFORMAT = "mi2_dateformat";
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java
index 92c0e49c9..eca222cbb 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java
@@ -1090,7 +1090,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
return;
}
- String requiredButtonPressMessage = prefs.getString(MiBandConst.PREF_MIBAND_BUTTON_PRESS_BROADCAST,
+ String requiredButtonPressMessage = prefs.getString(HuamiConst.PREF_BUTTON_ACTION_BROADCAST,
this.getContext().getString(R.string.mi2_prefs_button_press_broadcast_default_value));
Intent in = new Intent();
@@ -1098,7 +1098,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
in.putExtra("button_id", currentButtonActionId);
LOG.info("Sending " + requiredButtonPressMessage + " with button_id " + currentButtonActionId);
this.getContext().getApplicationContext().sendBroadcast(in);
- if (prefs.getBoolean(MiBandConst.PREF_MIBAND_BUTTON_ACTION_VIBRATE, false)) {
+ if (prefs.getBoolean(HuamiConst.PREF_BUTTON_ACTION_VIBRATE, false)) {
performPreferredNotification(null, null, null, HuamiService.ALERT_LEVEL_VIBRATE_ONLY, null);
}
@@ -1215,18 +1215,17 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
}
}
- public void handleButtonEvent() {
- ///logMessageContent(value);
+ private void handleButtonEvent() {
// If disabled we return from function immediately
- Prefs prefs = GBApplication.getPrefs();
- if (!prefs.getBoolean(MiBandConst.PREF_MIBAND_BUTTON_ACTION_ENABLE, false)) {
+ Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
+ if (!prefs.getBoolean(HuamiConst.PREF_BUTTON_ACTION_ENABLE, false)) {
return;
}
- int buttonPressMaxDelay = prefs.getInt(MiBandConst.PREF_MIBAND_BUTTON_PRESS_MAX_DELAY, 2000);
- int buttonActionDelay = prefs.getInt(MiBandConst.PREF_MIBAND_BUTTON_ACTION_DELAY, 0);
- int requiredButtonPressCount = prefs.getInt(MiBandConst.PREF_MIBAND_BUTTON_PRESS_COUNT, 0);
+ int buttonPressMaxDelay = prefs.getInt(HuamiConst.PREF_BUTTON_ACTION_PRESS_MAX_INTERVAL, 2000);
+ int buttonActionDelay = prefs.getInt(HuamiConst.PREF_BUTTON_ACTION_BROADCAST_DELAY, 0);
+ int requiredButtonPressCount = prefs.getInt(HuamiConst.PREF_BUTTON_ACTION_PRESS_COUNT, 0);
if (requiredButtonPressCount > 0) {
long timeSinceLastPress = System.currentTimeMillis() - currentButtonPressTime;
@@ -1244,7 +1243,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
currentButtonTimerActivationTime = currentButtonPressTime;
if (buttonActionDelay > 0) {
LOG.info("Activating timer");
- final Timer buttonActionTimer = new Timer("Mi Band Button Action Timer");
+ final Timer buttonActionTimer = new Timer("Huami Button Action Timer");
buttonActionTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipFirmwareInfo.java
index 9b446278d..6ac8d83be 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipFirmwareInfo.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipFirmwareInfo.java
@@ -156,6 +156,12 @@ public class AmazfitBipFirmwareInfo extends HuamiFirmwareInfo {
crcToVersion.put(61054, "8");
crcToVersion.put(62291, "9 (old Latin)");
crcToVersion.put(59577, "9 (Latin)");
+
+ // BipOS FW
+ crcToVersion.put(28373, "1.1.5.02 (BipOS 0.5)");
+
+ // BipOS RES
+ crcToVersion.put(16303, "1.1.5.02 (BipOS 0.5)");
}
public AmazfitBipFirmwareInfo(byte[] bytes) {
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipSupport.java
index e152872c0..2fa1329c2 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipSupport.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipSupport.java
@@ -79,11 +79,6 @@ public class AmazfitBipSupport extends HuamiSupport {
onSetCallState(callSpec);
}
- @Override
- public void handleButtonEvent() {
- // ignore
- }
-
@Override
protected AmazfitBipSupport setDisplayItems(TransactionBuilder builder) {
if (gbDevice.getFirmwareVersion() == null) {
diff --git a/app/src/main/res/xml/devicesettings_buttonactions.xml b/app/src/main/res/xml/devicesettings_buttonactions.xml
new file mode 100644
index 000000000..14083cd18
--- /dev/null
+++ b/app/src/main/res/xml/devicesettings_buttonactions.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+ public static final String PREF_BUTTON_ACTION_PRESS_DELAY = "button_action_press_count_delay";
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/xml/miband_preferences.xml b/app/src/main/res/xml/miband_preferences.xml
index 13dca15b9..9cda47158 100644
--- a/app/src/main/res/xml/miband_preferences.xml
+++ b/app/src/main/res/xml/miband_preferences.xml
@@ -22,62 +22,6 @@
android:summary="@string/mi2_prefs_goal_notification_summary"
android:title="@string/mi2_prefs_goal_notification" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-