1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-09 23:21:34 +02:00

Fossil HR: fixed version calculation

This commit is contained in:
Daniel Dakhno 2022-08-26 15:02:21 +02:00
parent fe485d80ec
commit 7b836036af

View File

@ -265,7 +265,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
initializeAfterWatchConfirmation(false); initializeAfterWatchConfirmation(false);
return; return;
} }
boolean versionSupportsConfirmation = getCleanFWVersion().compareTo(new Version("2.22")) != -1; boolean versionSupportsConfirmation = getCleanFWVersion().greaterOrEqualThan(new Version("2.22"));
if(!versionSupportsConfirmation){ if(!versionSupportsConfirmation){
initializeAfterWatchConfirmation(true); initializeAfterWatchConfirmation(true);
return; return;
@ -614,7 +614,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
private void loadWidgets() { private void loadWidgets() {
Version firmwareVersion = getCleanFWVersion(); Version firmwareVersion = getCleanFWVersion();
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("2.20")) >= 0) { if (firmwareVersion != null && firmwareVersion.greaterOrEqualThan(new Version("2.20"))) {
return; // this does not work on newer firmware versions return; // this does not work on newer firmware versions
} }
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDeviceSupport().getDevice().getAddress())); Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDeviceSupport().getDevice().getAddress()));
@ -736,7 +736,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
private void renderWidgets() { private void renderWidgets() {
Version firmwareVersion = getCleanFWVersion(); Version firmwareVersion = getCleanFWVersion();
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("2.20")) >= 0) { if (firmwareVersion != null && firmwareVersion.greaterOrEqualThan(new Version("2.20"))) {
return; // this does not work on newer firmware versions return; // this does not work on newer firmware versions
} }
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDeviceSupport().getDevice().getAddress())); Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDeviceSupport().getDevice().getAddress()));
@ -1497,7 +1497,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
String singlePressEvent = "short_press_release"; String singlePressEvent = "short_press_release";
Version firmwareVersion = getCleanFWVersion(); Version firmwareVersion = getCleanFWVersion();
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("2.19")) < 0) { if (firmwareVersion != null && firmwareVersion.smallerThan(new Version("2.19"))) {
singlePressEvent = "single_click"; singlePressEvent = "single_click";
} }
ArrayList<ButtonConfiguration> configs = new ArrayList<>(5); ArrayList<ButtonConfiguration> configs = new ArrayList<>(5);
@ -1745,7 +1745,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
public void onFindDevice(boolean start) { public void onFindDevice(boolean start) {
super.onFindDevice(start); super.onFindDevice(start);
boolean versionSupportsConfirmation = getCleanFWVersion().compareTo(new Version("2.22")) != -1; boolean versionSupportsConfirmation = getCleanFWVersion().greaterOrEqualThan(new Version("2.22"));
versionSupportsConfirmation |= getDeviceSupport().getDevice().getModel().startsWith("VA"); versionSupportsConfirmation |= getDeviceSupport().getDevice().getModel().startsWith("VA");
@ -1851,13 +1851,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
private Version getCleanFWVersion() { private Version getCleanFWVersion() {
String firmware = getDeviceSupport().getDevice().getFirmwareVersion(); String firmware = getDeviceSupport().getDevice().getFirmwareVersion();
firmware = firmware.replaceFirst("DN1\\.0\\.", "").replaceFirst("IV0\\.0\\.", ""); return new Version(firmware.substring(6, 9));
Matcher matcher = Pattern.compile("[0-9]+\\.[0-9]+").matcher(firmware); // DN1.0.2.19r.v5
if (matcher.find()) {
firmware = matcher.group(0);
return new Version(firmware);
}
return null;
} }
public String getInstalledAppNameFromUUID(UUID uuid) { public String getInstalledAppNameFromUUID(UUID uuid) {