1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

Hybrid HR: Add support for Hybrid HR 38mm watches

This commit is contained in:
Hasan Ammar 2022-08-06 18:17:42 -04:00 committed by Gitea
parent 6d947a9008
commit c2054c4a8b
7 changed files with 27 additions and 17 deletions

View File

@ -60,7 +60,7 @@ public class AppsManagementActivity extends AbstractGBActivity {
if (
device.getType() == DeviceType.FOSSILQHYBRID &&
device.isConnected() &&
device.getModel().startsWith("DN") &&
(device.getModel().startsWith("DN") || device.getModel().startsWith("IV")) &&
device.getState() == GBDevice.State.INITIALIZED
) {
String installedAppsJson = device.getDeviceInfo("INSTALLED_APPS").getDetails();

View File

@ -171,12 +171,13 @@ public class HRConfigActivity extends AbstractGBActivity {
// Disable some functions on watches with too new firmware (from official app 4.6.0 and higher)
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
for(GBDevice device : devices){
if(device.getType() == DeviceType.FOSSILQHYBRID){
for (GBDevice device : devices) {
if (device.getType() == DeviceType.FOSSILQHYBRID) {
String fwVersion_str = device.getFirmwareVersion();
fwVersion_str = fwVersion_str.replaceFirst("^DN", "").replaceFirst("r\\.v.*", "");
fwVersion_str = fwVersion_str.replaceFirst("^DN1\\.0\\.", "").replaceFirst
("^IV0\\.0\\.", "").replaceFirst("r\\.v.*", "");
Version fwVersion = new Version(fwVersion_str);
if (fwVersion.compareTo(new Version("1.0.2.20")) >= 0) {
if (fwVersion.compareTo(new Version("2.20")) >= 0) {
findViewById(R.id.qhybrid_widget_add).setEnabled(false);
for (int i = 0; i < widgetButtonsMapping.size(); i++) {
final int widgetButtonId = widgetButtonsMapping.keyAt(i);

View File

@ -253,7 +253,7 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
if (isHybridHR() && getFirmwareVersion() != null && getFirmwareVersion().compareTo(new Version("1.0.2.20")) < 0) {
if (isHybridHR() && getFirmwareVersion() != null && getFirmwareVersion().compareTo(new Version("2.20")) < 0) {
return new int[]{
R.xml.devicesettings_fossilhybridhr_pre_fw20,
R.xml.devicesettings_fossilhybridhr,
@ -299,11 +299,12 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
private Version getFirmwareVersion() {
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
for(GBDevice device : devices){
if(isFossilHybrid(device)){
for (GBDevice device : devices) {
if (isFossilHybrid(device)) {
String firmware = device.getFirmwareVersion();
if (firmware != null) {
Matcher matcher = Pattern.compile("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+").matcher(firmware); // DN1.0.2.19r.v5
firmware = firmware.replaceFirst("DN1\\.0\\.", "").replaceFirst("IV0\\.0\\.", "");
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);

View File

@ -80,10 +80,12 @@ public abstract class WatchAdapter {
return "Q Commuter";
case "HL.0.0":
return "Q Activist";
case "IV.0.0":
return "Hybrid HR";
case "DN.1.0":
return "Hybrid HR Collider";
return "Hybrid HR";
}
return "unknwon Q";
return "unknown Q";
}
public abstract void onFetchActivityData();

View File

@ -25,6 +25,7 @@ public final class WatchAdapterFactory {
public final WatchAdapter createWatchAdapter(String firmwareVersion, QHybridSupport deviceSupport){
char hardwareVersion = firmwareVersion.charAt(2);
if(hardwareVersion == '1') return new FossilHRWatchAdapter(deviceSupport);
if(firmwareVersion.startsWith("IV0")) return new FossilHRWatchAdapter(deviceSupport);
char major = firmwareVersion.charAt(6);
switch (major){

View File

@ -457,6 +457,8 @@ public class FossilWatchAdapter extends WatchAdapter {
return true;
case "HL.0.0":
return false;
case "IV.0.0":
return true;
case "DN.1.0":
return true;
}
@ -471,6 +473,8 @@ public class FossilWatchAdapter extends WatchAdapter {
return true;
case "HL.0.0":
return false;
case "IV.0.0":
return false;
case "DN.1.0":
return false;
}

View File

@ -235,7 +235,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
initializeAfterWatchConfirmation(false);
return;
}
boolean versionSupportsConfirmation = getCleanFWVersion().compareTo(new Version("1.0.2.22")) != -1;
boolean versionSupportsConfirmation = getCleanFWVersion().compareTo(new Version("2.22")) != -1;
if(!versionSupportsConfirmation){
initializeAfterWatchConfirmation(true);
return;
@ -472,7 +472,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
private void loadWidgets() {
Version firmwareVersion = getCleanFWVersion();
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("1.0.2.20")) >= 0) {
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("2.20")) >= 0) {
return; // this does not work on newer firmware versions
}
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDeviceSupport().getDevice().getAddress()));
@ -594,7 +594,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
private void renderWidgets() {
Version firmwareVersion = getCleanFWVersion();
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("1.0.2.20")) >= 0) {
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("2.20")) >= 0) {
return; // this does not work on newer firmware versions
}
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDeviceSupport().getDevice().getAddress()));
@ -1361,7 +1361,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
String singlePressEvent = "short_press_release";
Version firmwareVersion = getCleanFWVersion();
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("1.0.2.19")) < 0) {
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("2.19")) < 0) {
singlePressEvent = "single_click";
}
ArrayList<ButtonConfiguration> configs = new ArrayList<>(5);
@ -1609,7 +1609,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
public void onFindDevice(boolean start) {
super.onFindDevice(start);
boolean versionSupportsConfirmation = getCleanFWVersion().compareTo(new Version("1.0.2.22")) != -1;
boolean versionSupportsConfirmation = getCleanFWVersion().compareTo(new Version("2.22")) != -1;
if(!versionSupportsConfirmation){
GB.toast("not supported in this version", Toast.LENGTH_SHORT, GB.ERROR);
@ -1713,7 +1713,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
private Version getCleanFWVersion() {
String firmware = getDeviceSupport().getDevice().getFirmwareVersion();
Matcher matcher = Pattern.compile("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+").matcher(firmware); // DN1.0.2.19r.v5
firmware = firmware.replaceFirst("DN1\\.0\\.", "").replaceFirst("IV0\\.0\\.", "");
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);