Move zetime_inactivity* constants

This commit is contained in:
Damien Gaignon 2022-03-07 14:33:10 +01:00 committed by Gitea
parent 3b75a1701a
commit ae796c81eb
6 changed files with 83 additions and 85 deletions

View File

@ -63,6 +63,21 @@ public class DeviceSettingsPreferenceConst {
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_START = "inactivity_warnings_start";
public static final String PREF_INACTIVITY_END = "inactivity_warnings_end";
public static final String PREF_INACTIVITY_THRESHOLD = "inactivity_warnings_threshold";
public static final String PREF_INACTIVITY_MO = "inactivity_warnings_mo";
public static final String PREF_INACTIVITY_TU = "inactivity_warnings_tu";
public static final String PREF_INACTIVITY_WE = "inactivity_warnings_we";
public static final String PREF_INACTIVITY_TH = "inactivity_warnings_th";
public static final String PREF_INACTIVITY_FR = "inactivity_warnings_fr";
public static final String PREF_INACTIVITY_SA = "inactivity_warnings_sa";
public static final String PREF_INACTIVITY_SU = "inactivity_warnings_su";
public static final String PREF_AUTOHEARTRATE_SWITCH = "pref_autoheartrate_switch";
public static final String PREF_AUTOHEARTRATE_SLEEP = "pref_autoheartrate_sleep";
@ -73,9 +88,6 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_POWER_MODE = "power_mode";
public static final String PREF_BUTTON_BP_CALIBRATE = "prefs_sensors_button_bp_calibration";
public static final String PREF_ALTITUDE_CALIBRATE = "pref_sensors_altitude";
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_DO_NOT_DISTURB_NOAUTO = "do_not_disturb_no_auto";
public static final String PREF_DO_NOT_DISTURB_NOAUTO_START = "do_not_disturb_no_auto_start";
public static final String PREF_DO_NOT_DISTURB_NOAUTO_END = "do_not_disturb_no_auto_end";

View File

@ -369,6 +369,17 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
addPreferenceHandlerFor(PREF_LONGSIT_SWITCH);
addPreferenceHandlerFor(PREF_LONGSIT_START);
addPreferenceHandlerFor(PREF_LONGSIT_END);
addPreferenceHandlerFor(PREF_INACTIVITY_ENABLE);
addPreferenceHandlerFor(PREF_INACTIVITY_START);
addPreferenceHandlerFor(PREF_INACTIVITY_END);
addPreferenceHandlerFor(PREF_INACTIVITY_THRESHOLD);
addPreferenceHandlerFor(PREF_INACTIVITY_MO);
addPreferenceHandlerFor(PREF_INACTIVITY_TU);
addPreferenceHandlerFor(PREF_INACTIVITY_WE);
addPreferenceHandlerFor(PREF_INACTIVITY_TH);
addPreferenceHandlerFor(PREF_INACTIVITY_FR);
addPreferenceHandlerFor(PREF_INACTIVITY_SA);
addPreferenceHandlerFor(PREF_INACTIVITY_SU);
addPreferenceHandlerFor(PREF_AUTOHEARTRATE_SWITCH);
addPreferenceHandlerFor(PREF_AUTOHEARTRATE_SLEEP);
addPreferenceHandlerFor(PREF_AUTOHEARTRATE_INTERVAL);

View File

@ -135,19 +135,6 @@ public class ZeTimeConstants {
public static final String PREF_ZETIME_MIN_HEARTRATE = "alarm_min_heart_rate";
public static final String PREF_ZETIME_HEARTRATE_INTERVAL = "heartrate_measurement_interval";
public static final String PREF_INACTIVITY_KEY = "zetime_inactivity_warning_key";
public static final String PREF_INACTIVITY_ENABLE = "zetime_inactivity_warnings";
public static final String PREF_INACTIVITY_START = "zetime_inactivity_warnings_start";
public static final String PREF_INACTIVITY_END = "zetime_inactivity_warnings_end";
public static final String PREF_INACTIVITY_THRESHOLD = "zetime_inactivity_warnings_threshold";
public static final String PREF_INACTIVITY_MO = "zetime_prefs_inactivity_repetitions_mo";
public static final String PREF_INACTIVITY_TU = "zetime_prefs_inactivity_repetitions_tu";
public static final String PREF_INACTIVITY_WE = "zetime_prefs_inactivity_repetitions_we";
public static final String PREF_INACTIVITY_TH = "zetime_prefs_inactivity_repetitions_th";
public static final String PREF_INACTIVITY_FR = "zetime_prefs_inactivity_repetitions_fr";
public static final String PREF_INACTIVITY_SA = "zetime_prefs_inactivity_repetitions_sa";
public static final String PREF_INACTIVITY_SU = "zetime_prefs_inactivity_repetitions_su";
public static final String PREF_ANALOG_MODE = "zetime_analog_mode";
public static final String PREF_ACTIVITY_TRACKING = "zetime_activity_tracking";
public static final String PREF_HANDMOVE_DISPLAY = "zetime_handmove_display";

View File

@ -53,18 +53,6 @@ public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
addPreferenceHandlerFor(ZeTimeConstants.PREF_DATE_FORMAT);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_ENABLE);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_START);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_END);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_THRESHOLD);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_MO);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_TU);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_WE);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_TH);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_FR);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_SA);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_SU);
addPreferenceHandlerFor(ZeTimeConstants.PREF_SMS_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_CALENDAR_SIGNALING);

View File

@ -183,18 +183,18 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
case ZeTimeConstants.PREF_DATE_FORMAT:
setDateFormate(builder);
break;
case ZeTimeConstants.PREF_INACTIVITY_KEY:
case ZeTimeConstants.PREF_INACTIVITY_ENABLE:
case ZeTimeConstants.PREF_INACTIVITY_START:
case ZeTimeConstants.PREF_INACTIVITY_END:
case ZeTimeConstants.PREF_INACTIVITY_THRESHOLD:
case ZeTimeConstants.PREF_INACTIVITY_MO:
case ZeTimeConstants.PREF_INACTIVITY_TU:
case ZeTimeConstants.PREF_INACTIVITY_WE:
case ZeTimeConstants.PREF_INACTIVITY_TH:
case ZeTimeConstants.PREF_INACTIVITY_FR:
case ZeTimeConstants.PREF_INACTIVITY_SA:
case ZeTimeConstants.PREF_INACTIVITY_SU:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_KEY:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_START:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_END:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_MO:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_TU:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_WE:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_TH:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_FR:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_SA:
case DeviceSettingsPreferenceConst.PREF_INACTIVITY_SU:
setInactivityAlert(builder);
break;
case ZeTimeConstants.PREF_SMS_SIGNALING:
@ -1817,8 +1817,8 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
private void setInactivityAlert(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs();
boolean enabled = prefs.getBoolean(ZeTimeConstants.PREF_INACTIVITY_ENABLE, false);
int threshold = prefs.getInt(ZeTimeConstants.PREF_INACTIVITY_THRESHOLD, 60);
boolean enabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE, false);
int threshold = prefs.getInt(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, 60);
if (threshold > 0xff) {
threshold = 0xff;
@ -1843,21 +1843,21 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
};
if (enabled) {
String start = prefs.getString(ZeTimeConstants.PREF_INACTIVITY_START, "06:00");
String end = prefs.getString(ZeTimeConstants.PREF_INACTIVITY_END, "22:00");
String start = prefs.getString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_START, "06:00");
String end = prefs.getString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_END, "22:00");
DateFormat df_start = new SimpleDateFormat("HH:mm");
DateFormat df_end = new SimpleDateFormat("HH:mm");
Calendar calendar = GregorianCalendar.getInstance();
Calendar calendar_end = GregorianCalendar.getInstance();
int reps = (1 << 7); // set inactivity active: set bit 7
reps |= (prefs.getBoolean(ZeTimeConstants.PREF_INACTIVITY_MO, false) ? 1 : 0);
reps |= ((prefs.getBoolean(ZeTimeConstants.PREF_INACTIVITY_TU, false) ? 1 : 0) << 1);
reps |= ((prefs.getBoolean(ZeTimeConstants.PREF_INACTIVITY_WE, false) ? 1 : 0) << 2);
reps |= ((prefs.getBoolean(ZeTimeConstants.PREF_INACTIVITY_TH, false) ? 1 : 0) << 3);
reps |= ((prefs.getBoolean(ZeTimeConstants.PREF_INACTIVITY_FR, false) ? 1 : 0) << 4);
reps |= ((prefs.getBoolean(ZeTimeConstants.PREF_INACTIVITY_SA, false) ? 1 : 0) << 5);
reps |= ((prefs.getBoolean(ZeTimeConstants.PREF_INACTIVITY_SU, false) ? 1 : 0) << 6);
reps |= (prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_MO, false) ? 1 : 0);
reps |= ((prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_TU, false) ? 1 : 0) << 1);
reps |= ((prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_WE, false) ? 1 : 0) << 2);
reps |= ((prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_TH, false) ? 1 : 0) << 3);
reps |= ((prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_FR, false) ? 1 : 0) << 4);
reps |= ((prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_SA, false) ? 1 : 0) << 5);
reps |= ((prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_SU, false) ? 1 : 0) << 6);
inactivity[5] = (byte) reps;
@ -2147,45 +2147,45 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
String starttime = String.format("%02d:%02d", msg[7], msg[8]);
String endtime = String.format("%02d:%02d", msg[9], msg[10]);
prefs.putString(ZeTimeConstants.PREF_INACTIVITY_THRESHOLD, Integer.toString(msg[6]));
prefs.putString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, Integer.toString(msg[6]));
if (0 != msg[5]) {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_ENABLE, true);
prefs.putString(ZeTimeConstants.PREF_INACTIVITY_START, starttime);
prefs.putString(ZeTimeConstants.PREF_INACTIVITY_END, endtime);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE, true);
prefs.putString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_START, starttime);
prefs.putString(DeviceSettingsPreferenceConst.PREF_INACTIVITY_END, endtime);
if (0 != (msg[5] & (1 << 0))) {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_MO, true);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_MO, true);
} else {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_MO, false);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_MO, false);
}
if (0 != (msg[5] & (1 << 1))) {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_TU, true);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_TU, true);
} else {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_TU, false);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_TU, false);
}
if (0 != (msg[5] & (1 << 2))) {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_WE, true);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_WE, true);
} else {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_WE, false);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_WE, false);
}
if (0 != (msg[5] & (1 << 3))) {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_TH, true);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_TH, true);
} else {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_TH, false);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_TH, false);
}
if (0 != (msg[5] & (1 << 4))) {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_FR, true);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_FR, true);
} else {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_FR, false);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_FR, false);
}
if (0 != (msg[5] & (1 << 5))) {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_SA, true);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_SA, true);
} else {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_SA, false);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_SA, false);
}
if (0 != (msg[5] & (1 << 6))) {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_SU, true);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_SU, true);
} else {
prefs.putBoolean(ZeTimeConstants.PREF_INACTIVITY_SU, false);
prefs.putBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_SU, false);
}
}
prefs.apply();

View File

@ -52,7 +52,7 @@
android:title="@string/activity_prefs_activetime_minutes" />
<PreferenceScreen
android:key="zetime_inactivity_warning_key"
android:key="inactivity_warnings_key"
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
android:title="@string/mi2_prefs_inactivity_warnings"
android:persistent="false">
@ -64,60 +64,60 @@
<CheckBoxPreference
android:defaultValue="false"
android:key="zetime_inactivity_warnings"
android:key="inactivity_warnings"
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
android:title="@string/mi2_prefs_inactivity_warnings" />
<EditTextPreference
android:defaultValue="60"
android:dependency="zetime_inactivity_warnings"
android:dependency="inactivity_warnings"
android:inputType="numberSigned"
android:key="zetime_inactivity_warnings_threshold"
android:key="inactivity_warnings_threshold"
android:maxLength="3"
android:title="@string/mi2_prefs_inactivity_warnings_threshold" />
<nodomain.freeyourgadget.gadgetbridge.util.TimePreference
android:defaultValue="06:00"
android:dependency="zetime_inactivity_warnings"
android:key="zetime_inactivity_warnings_start"
android:dependency="inactivity_warnings"
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="zetime_inactivity_warnings"
android:key="zetime_inactivity_warnings_end"
android:dependency="inactivity_warnings"
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="zetime_inactivity_warnings">
android:dependency="inactivity_warnings">
<CheckBoxPreference
android:defaultValue="false"
android:key="zetime_prefs_inactivity_repetitions_mo"
android:key="inactivity_warnings_mo"
android:title="@string/zetime_prefs_inactivity_mo" />
<CheckBoxPreference
android:defaultValue="false"
android:key="zetime_prefs_inactivity_repetitions_tu"
android:key="inactivity_warnings_tu"
android:title="@string/zetime_prefs_inactivity_tu" />
<CheckBoxPreference
android:defaultValue="false"
android:key="zetime_prefs_inactivity_repetitions_we"
android:key="inactivity_warnings_we"
android:title="@string/zetime_prefs_inactivity_we" />
<CheckBoxPreference
android:defaultValue="false"
android:key="zetime_prefs_inactivity_repetitions_th"
android:key="inactivity_warnings_th"
android:title="@string/zetime_prefs_inactivity_th" />
<CheckBoxPreference
android:defaultValue="false"
android:key="zetime_prefs_inactivity_repetitions_fr"
android:key="inactivity_warnings_fr"
android:title="@string/zetime_prefs_inactivity_fr" />
<CheckBoxPreference
android:defaultValue="false"
android:key="zetime_prefs_inactivity_repetitions_sa"
android:key="inactivity_warnings_sa"
android:title="@string/zetime_prefs_inactivity_sa" />
<CheckBoxPreference
android:defaultValue="false"
android:key="zetime_prefs_inactivity_repetitions_su"
android:key="inactivity_warnings_su"
android:title="@string/zetime_prefs_inactivity_su" />
</PreferenceCategory>
</PreferenceScreen>