1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-23 02:16:48 +01:00

Moyoung: Add inactivity reminder preference

This commit is contained in:
Arjan Schrijver 2024-09-24 14:12:34 +02:00
parent 7ef3473f40
commit 822e67c15d
8 changed files with 58 additions and 93 deletions

View File

@ -192,6 +192,7 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_INACTIVITY_DND = "inactivity_warnings_dnd";
public static final String PREF_INACTIVITY_DND_START = "inactivity_warnings_dnd_start";
public static final String PREF_INACTIVITY_DND_END = "inactivity_warnings_dnd_end";
public static final String PREF_INACTIVITY_STEPS = "inactivity_warnings_steps";
public static final String PREF_HEARTRATE_USE_FOR_SLEEP_DETECTION = "heartrate_sleep_detection";
public static final String PREF_HEARTRATE_MEASUREMENT_INTERVAL = "heartrate_measurement_interval";

View File

@ -211,7 +211,7 @@ public abstract class AbstractMoyoungDeviceCoordinator extends AbstractBLEDevice
generic.add(R.xml.devicesettings_sync_calendar);
final List<Integer> health = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.HEALTH);
health.add(R.xml.devicesettings_heartrate_interval);
health.add(R.xml.devicesettings_moyoung_sedentary_reminder);
health.add(R.xml.devicesettings_inactivity_with_steps);
return deviceSpecificSettings;
}

View File

@ -432,9 +432,4 @@ public class MoyoungConstants {
public static final String PREF_LANGUAGE = "moyoung_language";
public static final String PREF_LANGUAGE_SUPPORT = "moyoung_language_supported";
public static final String PREF_MOYOUNG_DEVICE_VERSION = "moyoung_device_version";
public static final String PREF_SEDENTARY_REMINDER = "sedentary_reminder";
public static final String PREF_SEDENTARY_REMINDER_PERIOD = "sedentary_reminder_period";
public static final String PREF_SEDENTARY_REMINDER_STEPS = "sedentary_reminder_steps";
public static final String PREF_SEDENTARY_REMINDER_START = "sedentary_reminder_start";
public static final String PREF_SEDENTARY_REMINDER_END = "sedentary_reminder_end";
}

View File

@ -1683,20 +1683,19 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
sendSetting(getSetting("POWER_SAVING"), powerSavingPref);
break;
case MoyoungConstants.PREF_SEDENTARY_REMINDER:
String sedentaryReminderPref = prefs.getString(MoyoungConstants.PREF_SEDENTARY_REMINDER, "off");
boolean sedentaryReminderEnabled = !sedentaryReminderPref.equals("off");
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE:
boolean sedentaryReminderEnabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE, false);
sendSetting(getSetting("SEDENTARY_REMINDER"), sedentaryReminderEnabled);
break;
case MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD:
case MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS:
case MoyoungConstants.PREF_SEDENTARY_REMINDER_START:
case MoyoungConstants.PREF_SEDENTARY_REMINDER_END:
byte sedentaryPeriod = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD, 30);
byte sedentarySteps = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS, 100);
byte sedentaryStart = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_START, 10);
byte sedentaryEnd = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_END, 22);
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_START:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_END:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_STEPS:
byte sedentaryPeriod = (byte) prefs.getInt(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, 30);
byte sedentarySteps = (byte) prefs.getInt(DeviceSettingsPreferenceConst.PREF_INACTIVITY_STEPS, 100);
byte sedentaryStart = (byte) prefs.getInt(DeviceSettingsPreferenceConst.PREF_INACTIVITY_START, 10);
byte sedentaryEnd = (byte) prefs.getInt(DeviceSettingsPreferenceConst.PREF_INACTIVITY_END, 22);
sendSetting(getSetting("REMINDERS_TO_MOVE_PERIOD"),
new MoyoungSettingRemindersToMove.RemindersToMove(sedentaryPeriod, sedentarySteps, sedentaryStart, sedentaryEnd));
break;
@ -1765,14 +1764,14 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
// querySetting(getSetting("QUICK_VIEW_TIME"));
// break;
case MoyoungConstants.PREF_SEDENTARY_REMINDER:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE:
querySetting(getSetting("SEDENTARY_REMINDER"));
break;
case MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD:
case MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS:
case MoyoungConstants.PREF_SEDENTARY_REMINDER_START:
case MoyoungConstants.PREF_SEDENTARY_REMINDER_END:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD_EXTENDED:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_START:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_END:
querySetting(getSetting("REMINDERS_TO_MOVE_PERIOD"));
break;
default:

View File

@ -438,11 +438,6 @@
<string name="pref_summary_huami_force_new_protocol">Enable if your device no longer connects after a firmware upgrade</string>
<string name="pref_watch_face">Watch face</string>
<string name="pref_device_version">Device version</string>
<string name="pref_sedentary_reminder">Sedentary reminder</string>
<string name="pref_sedentary_reminder_period">Time period (minutes)</string>
<string name="pref_sedentary_reminder_steps">Minimum steps</string>
<string name="pref_sedentary_reminder_start">Start time (hour)</string>
<string name="pref_sedentary_reminder_end">End time (hour)</string>
<!-- HPlus Preferences -->
<string name="pref_title_unit_system">Units</string>
<string name="pref_title_timeformat">Time format</string>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen
android:icon="@drawable/ic_chair"
android:key="screen_inactivity"
android:persistent="false"
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
android:title="@string/mi2_prefs_inactivity_warnings">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_enable"
android:layout="@layout/preference_checkbox"
android:title="@string/mi2_prefs_inactivity_warnings"
android:summary="@string/mi2_prefs_inactivity_warnings_summary" />
<EditTextPreference
android:defaultValue="60"
android:dependency="inactivity_warnings_enable"
android:key="inactivity_warnings_threshold"
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
android:title="@string/mi2_prefs_inactivity_warnings_threshold"/>
<EditTextPreference
android:defaultValue="60"
android:dependency="inactivity_warnings_enable"
android:key="inactivity_warnings_steps"
android:title="@string/inactivity_warnings_minimum_steps_title"
android:summary="@string/inactivity_warnings_minimum_steps_summary"/>
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
android:defaultValue="06:00"
android:dependency="inactivity_warnings_enable"
android:key="inactivity_warnings_start"
android:title="@string/mi2_prefs_do_not_disturb_start" />
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
android:defaultValue="23:00"
android:dependency="inactivity_warnings_enable"
android:key="inactivity_warnings_end"
android:title="@string/mi2_prefs_do_not_disturb_end" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:icon="@drawable/ic_language"
android:defaultValue="0"
android:key="moyoung_language"
android:summary="%s"
android:title="@string/pref_title_language" />
</androidx.preference.PreferenceScreen>

View File

@ -1,57 +0,0 @@
<?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">
<PreferenceScreen
android:icon="@drawable/ic_sitting"
android:key="screen_sedentary_reminder"
android:persistent="false"
android:title="@string/pref_sedentary_reminder">
<ListPreference
android:defaultValue="@string/p_off"
android:entries="@array/sedentary_reminder"
android:entryValues="@array/sedentary_reminder_values"
android:key="sedentary_reminder"
android:summary="%s"
android:title="@string/pref_sedentary_reminder" />
<androidx.preference.EditTextPreference
android:defaultValue="30"
android:inputType="number"
android:key="sedentary_reminder_period"
android:maxLength="3"
app:useSimpleSummaryProvider="true"
android:dependency="sedentary_reminder"
android:title="@string/pref_sedentary_reminder_period" />
<androidx.preference.EditTextPreference
android:defaultValue="100"
android:inputType="number"
android:key="sedentary_reminder_steps"
android:maxLength="3"
app:useSimpleSummaryProvider="true"
android:dependency="sedentary_reminder"
android:title="@string/pref_sedentary_reminder_steps" />
<androidx.preference.EditTextPreference
android:defaultValue="10"
android:inputType="number"
android:key="sedentary_reminder_start"
android:maxLength="2"
app:useSimpleSummaryProvider="true"
android:dependency="sedentary_reminder"
android:title="@string/pref_sedentary_reminder_start" />
<androidx.preference.EditTextPreference
android:defaultValue="22"
android:inputType="number"
android:key="sedentary_reminder_end"
android:maxLength="2"
app:useSimpleSummaryProvider="true"
android:dependency="sedentary_reminder"
android:title="@string/pref_sedentary_reminder_end" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>