diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridCoordinator.java index 4266a8041..10669d43b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridCoordinator.java @@ -28,6 +28,7 @@ import android.os.ParcelUuid; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import org.apache.commons.lang3.ArrayUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -244,24 +245,26 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator { @Override public int[] getSupportedDeviceSpecificSettings(GBDevice device) { - if (isHybridHR() && getFirmwareVersion() != null && getFirmwareVersion().smallerThan(new Version("2.20"))) { - return new int[]{ - R.xml.devicesettings_fossilhybridhr_pre_fw20, - R.xml.devicesettings_fossilhybridhr, - R.xml.devicesettings_autoremove_notifications, - R.xml.devicesettings_canned_dismisscall_16, - R.xml.devicesettings_transliteration - }; + if (!isHybridHR()) { + return new int[0]; } - if (isHybridHR()) { - return new int[]{ - R.xml.devicesettings_fossilhybridhr, - R.xml.devicesettings_autoremove_notifications, - R.xml.devicesettings_canned_dismisscall_16, - }; - } - return new int[]{ + //Settings applicable to all firmware versions + int[] supportedSettings = new int[]{ + R.xml.devicesettings_fossilhybridhr, + R.xml.devicesettings_autoremove_notifications, + R.xml.devicesettings_canned_dismisscall_16, + R.xml.devicesettings_transliteration }; + //Firmware specific settings + if (getFirmwareVersion() != null && getFirmwareVersion().smallerThan(new Version("3.0"))) { + supportedSettings = ArrayUtils.insert(0, supportedSettings, R.xml.devicesettings_fossilhybridhr_buttonconfiguration_pre_fw30); + } else { + supportedSettings = ArrayUtils.insert(0, supportedSettings, R.xml.devicesettings_fossilhybridhr_buttonconfiguration); + } + if (getFirmwareVersion() != null && getFirmwareVersion().smallerThan(new Version("2.20"))) { + supportedSettings = ArrayUtils.insert(1, supportedSettings, R.xml.devicesettings_fossilhybridhr_pre_fw20); + } + return supportedSettings; } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java index a70eba18f..15796ea1e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java @@ -1502,12 +1502,14 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { if (firmwareVersion != null && firmwareVersion.smallerThan(new Version("2.19"))) { singlePressEvent = "single_click"; } - ArrayList configs = new ArrayList<>(5); + ArrayList configs = new ArrayList<>(6); configs.add(new ButtonConfiguration("top_" + singlePressEvent, prefs.getString(DeviceSettingsPreferenceConst.PREF_BUTTON_1_FUNCTION_SHORT, "weatherApp"))); configs.add(new ButtonConfiguration("top_hold", prefs.getString(DeviceSettingsPreferenceConst.PREF_BUTTON_1_FUNCTION_LONG, "weatherApp"))); // configs.add(new ButtonConfiguration("top_double_click", prefs.getString(DeviceSettingsPreferenceConst.PREF_BUTTON_1_FUNCTION_DOUBLE, "weatherApp"))); configs.add(new ButtonConfiguration("middle_" + singlePressEvent, prefs.getString(DeviceSettingsPreferenceConst.PREF_BUTTON_2_FUNCTION_SHORT, "commuteApp"))); - // configs.add(new ButtonConfiguration("middle_hold", prefs.getString(DeviceSettingsPreferenceConst.PREF_BUTTON_2_FUNCTION_LONG, "commuteApp"))); + if (firmwareVersion != null && firmwareVersion.greaterOrEqualThan(new Version("3.0"))) { + configs.add(new ButtonConfiguration("middle_hold", prefs.getString(DeviceSettingsPreferenceConst.PREF_BUTTON_2_FUNCTION_LONG, "launcherApp"))); + } // configs.add(new ButtonConfiguration("middle_double_click", prefs.getString(DeviceSettingsPreferenceConst.PREF_BUTTON_2_FUNCTION_DOUBLE, "commuteApp"))); configs.add(new ButtonConfiguration("bottom_" + singlePressEvent, prefs.getString(DeviceSettingsPreferenceConst.PREF_BUTTON_3_FUNCTION_SHORT, "musicApp"))); configs.add(new ButtonConfiguration("bottom_hold", prefs.getString(DeviceSettingsPreferenceConst.PREF_BUTTON_3_FUNCTION_LONG, "musicApp"))); diff --git a/app/src/main/res/xml/devicesettings_fossilhybridhr.xml b/app/src/main/res/xml/devicesettings_fossilhybridhr.xml index d8ba4e4bb..62f6d6f99 100644 --- a/app/src/main/res/xml/devicesettings_fossilhybridhr.xml +++ b/app/src/main/res/xml/devicesettings_fossilhybridhr.xml @@ -2,59 +2,6 @@ - - - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/devicesettings_fossilhybridhr_buttonconfiguration_pre_fw30.xml b/app/src/main/res/xml/devicesettings_fossilhybridhr_buttonconfiguration_pre_fw30.xml new file mode 100644 index 000000000..30cb3110a --- /dev/null +++ b/app/src/main/res/xml/devicesettings_fossilhybridhr_buttonconfiguration_pre_fw30.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + \ No newline at end of file