mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-30 03:27:34 +01:00
Move longsit constants to inactivity
This commit is contained in:
parent
ae796c81eb
commit
46f93bd2e4
@ -61,13 +61,9 @@ public class DeviceSettingsPreferenceConst {
|
||||
|
||||
public static final String PREF_LIFTWRIST_NOSHED = "activate_display_on_lift_wrist_noshed";
|
||||
public static final String PREF_DISCONNECTNOTIF_NOSHED = "disconnect_notification_noshed";
|
||||
public static final String PREF_LONGSIT_START = "pref_longsit_start";
|
||||
public static final String PREF_LONGSIT_END = "pref_longsit_end";
|
||||
public static final String PREF_LONGSIT_PERIOD = "pref_longsit_period";
|
||||
public static final String PREF_LONGSIT_SWITCH = "pref_longsit_switch";
|
||||
public static final String PREF_LONGSIT_SWITCH_NOSHED = "screen_longsit_noshed";
|
||||
public static final String PREF_INACTIVITY_KEY = "inactivity_warnings_key";
|
||||
public static final String PREF_INACTIVITY_ENABLE = "inactivity_warnings";
|
||||
public static final String PREF_INACTIVITY_ENABLE = "inactivity_warnings_enable";
|
||||
public static final String PREF_INACTIVITY_ENABLE_NOSHED = "inactivity_warnings_enable_noshed";
|
||||
public static final String PREF_INACTIVITY_START = "inactivity_warnings_start";
|
||||
public static final String PREF_INACTIVITY_END = "inactivity_warnings_end";
|
||||
public static final String PREF_INACTIVITY_THRESHOLD = "inactivity_warnings_threshold";
|
||||
|
@ -365,10 +365,6 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
|
||||
addPreferenceHandlerFor(PREF_DISCONNECTNOTIF_NOSHED);
|
||||
addPreferenceHandlerFor(PREF_BUTTON_BP_CALIBRATE);
|
||||
addPreferenceHandlerFor(PREF_ALTITUDE_CALIBRATE);
|
||||
addPreferenceHandlerFor(PREF_LONGSIT_PERIOD);
|
||||
addPreferenceHandlerFor(PREF_LONGSIT_SWITCH);
|
||||
addPreferenceHandlerFor(PREF_LONGSIT_START);
|
||||
addPreferenceHandlerFor(PREF_LONGSIT_END);
|
||||
addPreferenceHandlerFor(PREF_INACTIVITY_ENABLE);
|
||||
addPreferenceHandlerFor(PREF_INACTIVITY_START);
|
||||
addPreferenceHandlerFor(PREF_INACTIVITY_END);
|
||||
|
@ -46,8 +46,6 @@ public final class WatchXPlusConstants extends LenovoWatchConstants {
|
||||
public static final String PREF_BP_CAL_LOW = "pref_sensors_bp_calibration_low";
|
||||
public static final String PREF_BP_CAL_HIGH = "pref_sensors_bp_calibration_high";
|
||||
|
||||
public static final String PREF_LONGSIT_START = "pref_longsit_start";
|
||||
public static final String PREF_LONGSIT_END = "pref_longsit_end";
|
||||
public static final String PREF_SHOW_RAW_GRAPH = "show_raw_graph";
|
||||
// moved to gear icon (per device settings)
|
||||
public static final String PREF_LANGUAGE = "language";
|
||||
|
@ -272,14 +272,14 @@ public class WatchXPlusDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
*/
|
||||
public static boolean getLongSitHours(String deviceAddress, Calendar startOut, Calendar endOut) {
|
||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);
|
||||
boolean enabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_LONGSIT_SWITCH, false);
|
||||
boolean enabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE, false);
|
||||
|
||||
if (!enabled) {
|
||||
LOG.info(" Long sit reminder is disabled ");
|
||||
return false;
|
||||
} else {
|
||||
String start = prefs.getString(WatchXPlusConstants.PREF_LONGSIT_START, "06:00");
|
||||
String end = prefs.getString(WatchXPlusConstants.PREF_LONGSIT_END, "23:00");
|
||||
String start = prefs.getString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_START, "06:00");
|
||||
String end = prefs.getString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_END, "23:00");
|
||||
|
||||
DateFormat df = new SimpleDateFormat("HH:mm");
|
||||
|
||||
|
@ -543,10 +543,10 @@ public class FitProDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
case DeviceSettingsPreferenceConst.PREF_LANGUAGE:
|
||||
setLanguage(builder);
|
||||
break;
|
||||
case DeviceSettingsPreferenceConst.PREF_LONGSIT_PERIOD:
|
||||
case DeviceSettingsPreferenceConst.PREF_LONGSIT_SWITCH:
|
||||
case DeviceSettingsPreferenceConst.PREF_LONGSIT_START:
|
||||
case DeviceSettingsPreferenceConst.PREF_LONGSIT_END:
|
||||
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD:
|
||||
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE:
|
||||
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_START:
|
||||
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_END:
|
||||
setLongSitReminder(builder);
|
||||
break;
|
||||
case DeviceSettingsPreferenceConst.PREF_ACTIVATE_DISPLAY_ON_LIFT:
|
||||
@ -1143,14 +1143,14 @@ public class FitProDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
public FitProDeviceSupport setLongSitReminder(TransactionBuilder builder) {
|
||||
LOG.debug("FitPro set inactivity warning");
|
||||
boolean prefLongsitSwitch = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean("pref_longsit_switch", false);
|
||||
boolean prefLongsitSwitch = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE, false);
|
||||
LOG.info("Setting long sit warning to " + prefLongsitSwitch);
|
||||
|
||||
if (prefLongsitSwitch) {
|
||||
|
||||
String inactivity = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString("pref_longsit_period", "4");
|
||||
String start = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString("pref_longsit_start", "08:00");
|
||||
String end = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString("pref_longsit_end", "16:00");
|
||||
String inactivity = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, "4");
|
||||
String start = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_START, "08:00");
|
||||
String end = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_END, "16:00");
|
||||
Calendar startCalendar = GregorianCalendar.getInstance();
|
||||
Calendar endCalendar = GregorianCalendar.getInstance();
|
||||
DateFormat df = new SimpleDateFormat("HH:mm");
|
||||
|
@ -405,15 +405,15 @@ public class LefunDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sendEnabledFeaturesSetting(features);
|
||||
break;
|
||||
}
|
||||
case DeviceSettingsPreferenceConst.PREF_LONGSIT_SWITCH: {
|
||||
boolean enabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_LONGSIT_SWITCH, false);
|
||||
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE: {
|
||||
boolean enabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE, false);
|
||||
FeaturesCommand features = getCurrentEnabledFeatures();
|
||||
features.setFeature(FeaturesCommand.FEATURE_SEDENTARY_REMINDER, enabled);
|
||||
sendEnabledFeaturesSetting(features);
|
||||
break;
|
||||
}
|
||||
case DeviceSettingsPreferenceConst.PREF_LONGSIT_PERIOD: {
|
||||
String periodStr = prefs.getString(DeviceSettingsPreferenceConst.PREF_LONGSIT_PERIOD, "60");
|
||||
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD: {
|
||||
String periodStr = prefs.getString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, "60");
|
||||
try {
|
||||
int period = Integer.parseInt(periodStr);
|
||||
sendSedentaryReminderIntervalSetting(period);
|
||||
@ -523,7 +523,7 @@ public class LefunDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
||||
boolean raiseToWakeEnabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_LIFTWRIST_NOSHED, true);
|
||||
boolean antilostEnabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_ANTILOST_ENABLED, true);
|
||||
boolean sedentaryEnabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_LONGSIT_SWITCH, false);
|
||||
boolean sedentaryEnabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE, false);
|
||||
boolean hydrationEnabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_HYDRATION_SWITCH, false);
|
||||
|
||||
FeaturesCommand cmd = new FeaturesCommand();
|
||||
@ -693,7 +693,7 @@ public class LefunDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
prefs.edit()
|
||||
.putBoolean(DeviceSettingsPreferenceConst.PREF_LIFTWRIST_NOSHED,
|
||||
cmd.getFeature(FeaturesCommand.FEATURE_RAISE_TO_WAKE))
|
||||
.putBoolean(DeviceSettingsPreferenceConst.PREF_LONGSIT_SWITCH,
|
||||
.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE,
|
||||
cmd.getFeature(FeaturesCommand.FEATURE_SEDENTARY_REMINDER))
|
||||
.putBoolean(DeviceSettingsPreferenceConst.PREF_HYDRATION_SWITCH,
|
||||
cmd.getFeature(FeaturesCommand.FEATURE_HYDRATION_REMINDER))
|
||||
@ -710,7 +710,7 @@ public class LefunDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
public void receiveSedentaryReminderIntervalSetting(int period) {
|
||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
||||
prefs.edit()
|
||||
.putString(DeviceSettingsPreferenceConst.PREF_LONGSIT_PERIOD, String.valueOf(period))
|
||||
.putString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, String.valueOf(period))
|
||||
.apply();
|
||||
}
|
||||
|
||||
|
@ -964,8 +964,8 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
setLanguageAndTimeFormat(builder);
|
||||
break;
|
||||
|
||||
case DeviceSettingsPreferenceConst.PREF_LONGSIT_PERIOD:
|
||||
case DeviceSettingsPreferenceConst.PREF_LONGSIT_SWITCH:
|
||||
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD:
|
||||
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE:
|
||||
setLongSitHours(builder);
|
||||
break;
|
||||
// calibrations
|
||||
@ -1049,7 +1049,7 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
Calendar end = new GregorianCalendar();
|
||||
boolean enable = WatchXPlusDeviceCoordinator.getLongSitHours(gbDevice.getAddress(), start, end);
|
||||
if (enable) {
|
||||
String periodString = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_LONGSIT_PERIOD, "60");
|
||||
String periodString = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, "60");
|
||||
int period = Integer.parseInt(periodString);
|
||||
|
||||
this.setLongSitHours(builder, enable,
|
||||
|
@ -548,7 +548,7 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
|
||||
(byte) 0x00 // unknown, sniffed by original app
|
||||
};
|
||||
|
||||
if (GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_LONGSIT_SWITCH_NOSHED, false)) {
|
||||
if (GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE_NOSHED, false)) {
|
||||
deviceBytes[1] = (byte) 0x01;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceScreen
|
||||
android:icon="@drawable/ic_chair"
|
||||
android:key="screen_longsit"
|
||||
android:key="screen_inactivity"
|
||||
android:persistent="false"
|
||||
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
|
||||
android:title="@string/mi2_prefs_inactivity_warnings">
|
||||
@ -12,21 +12,21 @@
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_longsit_switch"
|
||||
android:key="inactivity_warnings_enable"
|
||||
android:title="@string/mi2_prefs_inactivity_warnings" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="60"
|
||||
android:key="pref_longsit_period"
|
||||
android:key="inactivity_warnings_threshold"
|
||||
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
|
||||
android:title="@string/mi2_prefs_inactivity_warnings_threshold"/>
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
android:defaultValue="06:00"
|
||||
android:key="pref_longsit_start"
|
||||
android:key="inactivity_warnings_start"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_start" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
android:defaultValue="23:00"
|
||||
android:key="pref_longsit_end"
|
||||
android:key="inactivity_warnings_end"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_end" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceScreen
|
||||
android:icon="@drawable/ic_chair"
|
||||
android:key="screen_longsit"
|
||||
android:key="screen_inactivity_extended"
|
||||
android:persistent="false"
|
||||
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
|
||||
android:title="@string/mi2_prefs_inactivity_warnings">
|
||||
@ -12,26 +12,26 @@
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_longsit_switch"
|
||||
android:key="inactivity_warnings_enable"
|
||||
android:title="@string/mi2_prefs_inactivity_warnings" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="4"
|
||||
android:dependency="pref_longsit_switch"
|
||||
android:dependency="inactivity_warnings_enable"
|
||||
android:entries="@array/inactivity_minutes"
|
||||
android:entryValues="@array/inactivity_minutes_values"
|
||||
android:key="pref_longsit_period"
|
||||
android:key="inactivity_warnings_threshold"
|
||||
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
|
||||
android:title="@string/mi2_prefs_inactivity_warnings_threshold" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
android:defaultValue="08:00"
|
||||
android:key="pref_longsit_start"
|
||||
android:key="inactivity_warnings_start"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_start" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
android:defaultValue="16:00"
|
||||
android:key="pref_longsit_end"
|
||||
android:key="inactivity_warnings_end"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_end" />
|
||||
</PreferenceScreen>
|
||||
</androidx.preference.PreferenceScreen>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/ic_chair"
|
||||
android:defaultValue="false"
|
||||
android:key="screen_longsit_noshed"
|
||||
android:key="inactivity_warnings_enable_noshed"
|
||||
android:title="@string/mi2_prefs_inactivity_warnings"
|
||||
android:summary="@string/mi2_prefs_inactivity_warnings_summary"/>
|
||||
</androidx.preference.PreferenceScreen>
|
||||
|
@ -64,13 +64,13 @@
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="inactivity_warnings"
|
||||
android:key="inactivity_warnings_enable"
|
||||
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
|
||||
android:title="@string/mi2_prefs_inactivity_warnings" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="60"
|
||||
android:dependency="inactivity_warnings"
|
||||
android:dependency="inactivity_warnings_enable"
|
||||
android:inputType="numberSigned"
|
||||
android:key="inactivity_warnings_threshold"
|
||||
android:maxLength="3"
|
||||
@ -78,19 +78,19 @@
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.TimePreference
|
||||
android:defaultValue="06:00"
|
||||
android:dependency="inactivity_warnings"
|
||||
android:dependency="inactivity_warnings_enable"
|
||||
android:key="inactivity_warnings_start"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_start" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.TimePreference
|
||||
android:defaultValue="22:00"
|
||||
android:dependency="inactivity_warnings"
|
||||
android:dependency="inactivity_warnings_enable"
|
||||
android:key="inactivity_warnings_end"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_end" />
|
||||
|
||||
<!-- workaround for missing toolbar -->
|
||||
<PreferenceCategory android:title="@string/zetime_prefs_inactivity_repetitions"
|
||||
android:dependency="inactivity_warnings">
|
||||
android:dependency="inactivity_warnings_enable">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="inactivity_warnings_mo"
|
||||
|
Loading…
x
Reference in New Issue
Block a user