mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-05 01:37:03 +01:00
Hybrid HR: Add support for Hybrid HR 38mm watches
This commit is contained in:
parent
6d947a9008
commit
c2054c4a8b
@ -60,7 +60,7 @@ public class AppsManagementActivity extends AbstractGBActivity {
|
|||||||
if (
|
if (
|
||||||
device.getType() == DeviceType.FOSSILQHYBRID &&
|
device.getType() == DeviceType.FOSSILQHYBRID &&
|
||||||
device.isConnected() &&
|
device.isConnected() &&
|
||||||
device.getModel().startsWith("DN") &&
|
(device.getModel().startsWith("DN") || device.getModel().startsWith("IV")) &&
|
||||||
device.getState() == GBDevice.State.INITIALIZED
|
device.getState() == GBDevice.State.INITIALIZED
|
||||||
) {
|
) {
|
||||||
String installedAppsJson = device.getDeviceInfo("INSTALLED_APPS").getDetails();
|
String installedAppsJson = device.getDeviceInfo("INSTALLED_APPS").getDetails();
|
||||||
|
@ -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)
|
// Disable some functions on watches with too new firmware (from official app 4.6.0 and higher)
|
||||||
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
||||||
for(GBDevice device : devices){
|
for (GBDevice device : devices) {
|
||||||
if(device.getType() == DeviceType.FOSSILQHYBRID){
|
if (device.getType() == DeviceType.FOSSILQHYBRID) {
|
||||||
String fwVersion_str = device.getFirmwareVersion();
|
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);
|
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);
|
findViewById(R.id.qhybrid_widget_add).setEnabled(false);
|
||||||
for (int i = 0; i < widgetButtonsMapping.size(); i++) {
|
for (int i = 0; i < widgetButtonsMapping.size(); i++) {
|
||||||
final int widgetButtonId = widgetButtonsMapping.keyAt(i);
|
final int widgetButtonId = widgetButtonsMapping.keyAt(i);
|
||||||
|
@ -253,7 +253,7 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
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[]{
|
return new int[]{
|
||||||
R.xml.devicesettings_fossilhybridhr_pre_fw20,
|
R.xml.devicesettings_fossilhybridhr_pre_fw20,
|
||||||
R.xml.devicesettings_fossilhybridhr,
|
R.xml.devicesettings_fossilhybridhr,
|
||||||
@ -299,11 +299,12 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
|
|
||||||
private Version getFirmwareVersion() {
|
private Version getFirmwareVersion() {
|
||||||
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
||||||
for(GBDevice device : devices){
|
for (GBDevice device : devices) {
|
||||||
if(isFossilHybrid(device)){
|
if (isFossilHybrid(device)) {
|
||||||
String firmware = device.getFirmwareVersion();
|
String firmware = device.getFirmwareVersion();
|
||||||
if (firmware != null) {
|
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()) {
|
if (matcher.find()) {
|
||||||
firmware = matcher.group(0);
|
firmware = matcher.group(0);
|
||||||
return new Version(firmware);
|
return new Version(firmware);
|
||||||
|
@ -80,10 +80,12 @@ public abstract class WatchAdapter {
|
|||||||
return "Q Commuter";
|
return "Q Commuter";
|
||||||
case "HL.0.0":
|
case "HL.0.0":
|
||||||
return "Q Activist";
|
return "Q Activist";
|
||||||
|
case "IV.0.0":
|
||||||
|
return "Hybrid HR";
|
||||||
case "DN.1.0":
|
case "DN.1.0":
|
||||||
return "Hybrid HR Collider";
|
return "Hybrid HR";
|
||||||
}
|
}
|
||||||
return "unknwon Q";
|
return "unknown Q";
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void onFetchActivityData();
|
public abstract void onFetchActivityData();
|
||||||
|
@ -25,6 +25,7 @@ public final class WatchAdapterFactory {
|
|||||||
public final WatchAdapter createWatchAdapter(String firmwareVersion, QHybridSupport deviceSupport){
|
public final WatchAdapter createWatchAdapter(String firmwareVersion, QHybridSupport deviceSupport){
|
||||||
char hardwareVersion = firmwareVersion.charAt(2);
|
char hardwareVersion = firmwareVersion.charAt(2);
|
||||||
if(hardwareVersion == '1') return new FossilHRWatchAdapter(deviceSupport);
|
if(hardwareVersion == '1') return new FossilHRWatchAdapter(deviceSupport);
|
||||||
|
if(firmwareVersion.startsWith("IV0")) return new FossilHRWatchAdapter(deviceSupport);
|
||||||
|
|
||||||
char major = firmwareVersion.charAt(6);
|
char major = firmwareVersion.charAt(6);
|
||||||
switch (major){
|
switch (major){
|
||||||
|
@ -457,6 +457,8 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
return true;
|
return true;
|
||||||
case "HL.0.0":
|
case "HL.0.0":
|
||||||
return false;
|
return false;
|
||||||
|
case "IV.0.0":
|
||||||
|
return true;
|
||||||
case "DN.1.0":
|
case "DN.1.0":
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -471,6 +473,8 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
return true;
|
return true;
|
||||||
case "HL.0.0":
|
case "HL.0.0":
|
||||||
return false;
|
return false;
|
||||||
|
case "IV.0.0":
|
||||||
|
return false;
|
||||||
case "DN.1.0":
|
case "DN.1.0":
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
|||||||
initializeAfterWatchConfirmation(false);
|
initializeAfterWatchConfirmation(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean versionSupportsConfirmation = getCleanFWVersion().compareTo(new Version("1.0.2.22")) != -1;
|
boolean versionSupportsConfirmation = getCleanFWVersion().compareTo(new Version("2.22")) != -1;
|
||||||
if(!versionSupportsConfirmation){
|
if(!versionSupportsConfirmation){
|
||||||
initializeAfterWatchConfirmation(true);
|
initializeAfterWatchConfirmation(true);
|
||||||
return;
|
return;
|
||||||
@ -472,7 +472,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("1.0.2.20")) >= 0) {
|
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("2.20")) >= 0) {
|
||||||
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()));
|
||||||
@ -594,7 +594,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("1.0.2.20")) >= 0) {
|
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("2.20")) >= 0) {
|
||||||
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()));
|
||||||
@ -1361,7 +1361,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("1.0.2.19")) < 0) {
|
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("2.19")) < 0) {
|
||||||
singlePressEvent = "single_click";
|
singlePressEvent = "single_click";
|
||||||
}
|
}
|
||||||
ArrayList<ButtonConfiguration> configs = new ArrayList<>(5);
|
ArrayList<ButtonConfiguration> configs = new ArrayList<>(5);
|
||||||
@ -1609,7 +1609,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("1.0.2.22")) != -1;
|
boolean versionSupportsConfirmation = getCleanFWVersion().compareTo(new Version("2.22")) != -1;
|
||||||
|
|
||||||
if(!versionSupportsConfirmation){
|
if(!versionSupportsConfirmation){
|
||||||
GB.toast("not supported in this version", Toast.LENGTH_SHORT, GB.ERROR);
|
GB.toast("not supported in this version", Toast.LENGTH_SHORT, GB.ERROR);
|
||||||
@ -1713,7 +1713,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
|||||||
|
|
||||||
private Version getCleanFWVersion() {
|
private Version getCleanFWVersion() {
|
||||||
String firmware = getDeviceSupport().getDevice().getFirmwareVersion();
|
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()) {
|
if (matcher.find()) {
|
||||||
firmware = matcher.group(0);
|
firmware = matcher.group(0);
|
||||||
return new Version(firmware);
|
return new Version(firmware);
|
||||||
|
Loading…
Reference in New Issue
Block a user