1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 18:45:49 +01:00

Fossil Hybrid HR: Hide old settings on newer firmwares

This commit is contained in:
Arjan Schrijver 2021-05-07 11:24:10 +02:00 committed by Gitea
parent be73e84829
commit beb1597b75
5 changed files with 52 additions and 18 deletions

View File

@ -30,6 +30,8 @@ import androidx.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.GBException;
@ -43,8 +45,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.model.ItemWithDetails; import nodomain.freeyourgadget.gadgetbridge.util.Version;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
public class QHybridCoordinator extends AbstractDeviceCoordinator { public class QHybridCoordinator extends AbstractDeviceCoordinator {
@NonNull @NonNull
@ -192,6 +193,16 @@ public class QHybridCoordinator extends AbstractDeviceCoordinator {
@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) {
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_pairingkey,
R.xml.devicesettings_custom_deviceicon
};
}
if (isHybridHR()) { if (isHybridHR()) {
return new int[]{ return new int[]{
R.xml.devicesettings_fossilhybridhr, R.xml.devicesettings_fossilhybridhr,
@ -214,4 +225,16 @@ public class QHybridCoordinator extends AbstractDeviceCoordinator {
} }
return false; return false;
} }
private Version getFirmwareVersion() {
String firmware = GBApplication.app().getDeviceManager().getSelectedDevice().getFirmwareVersion();
if (firmware != null) {
Matcher matcher = Pattern.compile("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+").matcher(firmware); // DN1.0.2.19r.v5
if (matcher.find()) {
firmware = matcher.group(0);
return new Version(firmware);
}
}
return null;
}
} }

View File

@ -1170,4 +1170,6 @@
<string name="pref_summary_physical_buttons">Configure the functionality of the physical buttons on the watch</string> <string name="pref_summary_physical_buttons">Configure the functionality of the physical buttons on the watch</string>
<string name="qhybrid_summary_file_management">Upload and download files</string> <string name="qhybrid_summary_file_management">Upload and download files</string>
<string name="qhybrid_summary_calibration">Calibrate the watch hands</string> <string name="qhybrid_summary_calibration">Calibrate the watch hands</string>
<string name="pref_summary_canned_messages_set">Send the messages configured below to your device</string>
<string name="pref_summary_canned_messages_dismisscall">Dismiss calls from the watch with an SMS message</string>
</resources> </resources>

View File

@ -4,10 +4,12 @@
<PreferenceScreen <PreferenceScreen
android:key="screen_canned_messages_dismisscall" android:key="screen_canned_messages_dismisscall"
android:persistent="false" android:persistent="false"
android:title="@string/pref_title_canned_messages_dismisscall"> android:title="@string/pref_title_canned_messages_dismisscall"
android:summary="@string/pref_summary_canned_messages_dismisscall">
<Preference <Preference
android:key="canned_messages_dismisscall_send" android:key="canned_messages_dismisscall_send"
android:title="@string/pref_title_canned_messages_set" /> android:title="@string/pref_title_canned_messages_set"
android:summary="@string/pref_summary_canned_messages_set"/>
<EditTextPreference <EditTextPreference
android:key="canned_message_dismisscall_1" android:key="canned_message_dismisscall_1"
android:maxLength="64" android:maxLength="64"

View File

@ -72,20 +72,6 @@
--> -->
</PreferenceScreen> </PreferenceScreen>
<SwitchPreference
android:defaultValue="false"
android:key="force_white_color_scheme"
android:summary="@string/pref_summary_force_white_color_scheme"
android:title="@string/pref_title_force_white_color_scheme" />
<SwitchPreference
android:defaultValue="false"
android:key="widget_draw_circles"
android:title="@string/pref_qhybrid_title_widget_draw_circles" />
<SwitchPreference
android:defaultValue="false"
android:key="save_raw_activity_files"
android:title="@string/pref_qhybrid_save_raw_activity_files" />
<SeekBarPreference <SeekBarPreference
android:defaultValue="2" android:defaultValue="2"
android:key="vibration_strength" android:key="vibration_strength"
@ -100,6 +86,12 @@
android:targetPackage="nodomain.freeyourgadget.gadgetbridge" android:targetPackage="nodomain.freeyourgadget.gadgetbridge"
android:targetClass="nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.CalibrationActivity" /> android:targetClass="nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.CalibrationActivity" />
</Preference> </Preference>
<SwitchPreference
android:defaultValue="false"
android:key="save_raw_activity_files"
android:title="@string/pref_qhybrid_save_raw_activity_files" />
<Preference <Preference
android:title="@string/qhybrid_title_file_management" android:title="@string/qhybrid_title_file_management"
android:summary="@string/qhybrid_summary_file_management"> android:summary="@string/qhybrid_summary_file_management">

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreference
android:defaultValue="false"
android:key="force_white_color_scheme"
android:summary="@string/pref_summary_force_white_color_scheme"
android:title="@string/pref_title_force_white_color_scheme" />
<SwitchPreference
android:defaultValue="false"
android:key="widget_draw_circles"
android:title="@string/pref_qhybrid_title_widget_draw_circles" />
</androidx.preference.PreferenceScreen>