1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-15 13:17:49 +01:00

Huami: Move inactivity warnings and goal notification to device-specific settings

This commit is contained in:
José Rebelo 2022-05-14 21:08:32 +01:00 committed by Gitea
parent bfdc24ab87
commit 3b348a5d5d
42 changed files with 200 additions and 223 deletions

View File

@ -117,7 +117,7 @@ public class GBApplication extends Application {
private static SharedPreferences sharedPrefs;
private static final String PREFS_VERSION = "shared_preferences_version";
//if preferences have to be migrated, increment the following and add the migration logic in migratePrefs below; see http://stackoverflow.com/questions/16397848/how-can-i-migrate-android-preferences-with-a-new-version
private static final int CURRENT_PREFS_VERSION = 12;
private static final int CURRENT_PREFS_VERSION = 13;
private static LimitedQueue mIDSenderLookup = new LimitedQueue(16);
private static Prefs prefs;
@ -1085,6 +1085,42 @@ public class GBApplication extends Application {
editor.putString("inactivity_warnings_threshold", String.valueOf(prefs.getInt("inactivity_warnings_threshold", 60)));
editor.putString("fitness_goal", String.valueOf(prefs.getInt("fitness_goal", 8000)));
}
if (oldVersion < 13) {
try (DBHandler db = acquireDB()) {
final DaoSession daoSession = db.getDaoSession();
final List<Device> activeDevices = DBHelper.getActiveDevices(daoSession);
for (Device dbDevice : activeDevices) {
final SharedPreferences deviceSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
final SharedPreferences.Editor deviceSharedPrefsEdit = deviceSharedPrefs.edit();
if (dbDevice.getManufacturer().equals("Huami")) {
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_enable", prefs.getBoolean("inactivity_warnings_enable", false));
deviceSharedPrefsEdit.putString("inactivity_warnings_threshold", prefs.getString("inactivity_warnings_threshold", "60"));
deviceSharedPrefsEdit.putString("inactivity_warnings_start", prefs.getString("inactivity_warnings_start", "06:00"));
deviceSharedPrefsEdit.putString("inactivity_warnings_end", prefs.getString("inactivity_warnings_end", "22:00"));
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_dnd", prefs.getBoolean("inactivity_warnings_dnd", false));
deviceSharedPrefsEdit.putString("inactivity_warnings_dnd_start", prefs.getString("inactivity_warnings_dnd_start", "12:00"));
deviceSharedPrefsEdit.putString("inactivity_warnings_dnd_end", prefs.getString("inactivity_warnings_dnd_end", "14:00"));
deviceSharedPrefsEdit.putBoolean("fitness_goal_notification", prefs.getBoolean("mi2_goal_notification", false));
}
// Not removing the first 4 preferences since they're still used by some devices (ZeTime)
editor.remove("inactivity_warnings_dnd");
editor.remove("inactivity_warnings_dnd_start");
editor.remove("inactivity_warnings_dnd_end");
editor.remove("mi2_goal_notification");
deviceSharedPrefsEdit.apply();
}
} catch (Exception e) {
Log.w(TAG, "error acquiring DB lock");
}
}
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
editor.apply();
}

View File

@ -190,4 +190,5 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_SOUNDS = "sounds";
public static final String PREF_AUTH_KEY = "authkey";
public static final String PREF_USER_FITNESS_GOAL = "fitness_goal";
public static final String PREF_USER_FITNESS_GOAL_NOTIFICATION = "fitness_goal_notification";
}

View File

@ -471,6 +471,7 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
addPreferenceHandlerFor(PREF_QC35_NOISE_CANCELLING_LEVEL);
addPreferenceHandlerFor(PREF_USER_FITNESS_GOAL);
addPreferenceHandlerFor(PREF_USER_FITNESS_GOAL_NOTIFICATION);
addPreferenceHandlerFor(PREF_UM25_SHOW_THRESHOLD_NOTIFICATION);
addPreferenceHandlerFor(PREF_UM25_SHOW_THRESHOLD);
@ -643,6 +644,7 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_FIND_PHONE_DURATION, InputType.TYPE_CLASS_NUMBER);
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR, InputType.TYPE_CLASS_NUMBER);
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_RESERVER_REMINDERS_CALENDAR, InputType.TYPE_CLASS_NUMBER);
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, InputType.TYPE_CLASS_NUMBER);
String deviceActionsFellSleepSelection = prefs.getString(PREF_DEVICE_ACTION_FELL_SLEEP_SELECTION, PREF_DEVICE_ACTION_SELECTION_OFF);
final Preference deviceActionsFellSleep = findPreference(PREF_DEVICE_ACTION_FELL_SLEEP_SELECTION);
@ -827,6 +829,8 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
protected Set<String> getPreferenceKeysWithSummary() {
final Set<String> keysWithSummary = new HashSet<>();
keysWithSummary.add(PREF_INACTIVITY_THRESHOLD);
if (deviceSpecificSettingsCustomizer != null) {
keysWithSummary.addAll(deviceSpecificSettingsCustomizer.getPreferenceKeysWithSummary());
}

View File

@ -209,9 +209,9 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
return prefs.getBoolean(HuamiConst.PREF_USE_CUSTOM_FONT, false);
}
public static boolean getGoalNotification() {
Prefs prefs = GBApplication.getPrefs();
return prefs.getBoolean(MiBandConst.PREF_MI2_GOAL_NOTIFICATION, false);
public static boolean getGoalNotification(String deviceAddress) {
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);
return prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_USER_FITNESS_GOAL_NOTIFICATION, false);
}
public static boolean getRotateWristToSwitchInfo(String deviceAddress) {
@ -219,35 +219,35 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
return prefs.getBoolean(MiBandConst.PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO, false);
}
public static boolean getInactivityWarnings() {
Prefs prefs = GBApplication.getPrefs();
public static boolean getInactivityWarnings(String deviceAddress) {
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);
return prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE, false);
}
public static int getInactivityWarningsThreshold() {
Prefs prefs = GBApplication.getPrefs();
public static int getInactivityWarningsThreshold(String deviceAddress) {
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(deviceAddress));
return prefs.getInt(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, 60);
}
public static boolean getInactivityWarningsDnd() {
Prefs prefs = GBApplication.getPrefs();
public static boolean getInactivityWarningsDnd(String deviceAddress) {
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);
return prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_DND, false);
}
public static Date getInactivityWarningsStart() {
return getTimePreference(DeviceSettingsPreferenceConst.PREF_INACTIVITY_START, "06:00");
public static Date getInactivityWarningsStart(String deviceAddress) {
return getTimePreference(DeviceSettingsPreferenceConst.PREF_INACTIVITY_START, "06:00", deviceAddress);
}
public static Date getInactivityWarningsEnd() {
return getTimePreference(DeviceSettingsPreferenceConst.PREF_INACTIVITY_END, "22:00");
public static Date getInactivityWarningsEnd(String deviceAddress) {
return getTimePreference(DeviceSettingsPreferenceConst.PREF_INACTIVITY_END, "22:00", deviceAddress);
}
public static Date getInactivityWarningsDndStart() {
return getTimePreference(DeviceSettingsPreferenceConst.PREF_INACTIVITY_DND_START, "12:00");
public static Date getInactivityWarningsDndStart(String deviceAddress) {
return getTimePreference(DeviceSettingsPreferenceConst.PREF_INACTIVITY_DND_START, "12:00", deviceAddress);
}
public static Date getInactivityWarningsDndEnd() {
return getTimePreference(DeviceSettingsPreferenceConst.PREF_INACTIVITY_DND_END, "14:00");
public static Date getInactivityWarningsDndEnd(String deviceAddress) {
return getTimePreference(DeviceSettingsPreferenceConst.PREF_INACTIVITY_DND_END, "14:00", deviceAddress);
}
public static Date getDoNotDisturbStart(String deviceAddress) {

View File

@ -101,12 +101,14 @@ public class AmazfitBand5Coordinator extends HuamiCoordinator {
R.xml.devicesettings_amazfitband5,
R.xml.devicesettings_miband5_vibration,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_dateformat,
R.xml.devicesettings_world_clocks,
R.xml.devicesettings_nightmode,
R.xml.devicesettings_liftwrist_display_sensitivity,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_swipeunlock,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -83,8 +83,10 @@ public class AmazfitBipCoordinator extends HuamiCoordinator {
R.xml.devicesettings_amazfitbip,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -72,8 +72,10 @@ public class AmazfitBipLiteCoordinator extends AmazfitBipCoordinator {
R.xml.devicesettings_amazfitbip,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_bt_connected_advertisement,

View File

@ -99,8 +99,10 @@ public class AmazfitBipSCoordinator extends HuamiCoordinator {
R.xml.devicesettings_timeformat,
R.xml.devicesettings_world_clocks,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,
R.xml.devicesettings_expose_hr_thirdparty,

View File

@ -111,8 +111,10 @@ public class AmazfitBipUCoordinator extends HuamiCoordinator {
R.xml.devicesettings_timeformat,
R.xml.devicesettings_world_clocks,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_liftwrist_display_sensitivity,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,
R.xml.devicesettings_expose_hr_thirdparty,

View File

@ -110,8 +110,10 @@ public class AmazfitBipUProCoordinator extends HuamiCoordinator {
R.xml.devicesettings_timeformat,
R.xml.devicesettings_world_clocks,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_liftwrist_display_sensitivity,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,
R.xml.devicesettings_expose_hr_thirdparty,

View File

@ -90,9 +90,11 @@ public class AmazfitCorCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitcor,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -92,9 +92,11 @@ public class AmazfitCor2Coordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitcor,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -90,8 +90,10 @@ public class AmazfitGTRCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitgtsgtr,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -91,8 +91,10 @@ public class AmazfitGTRLiteCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitgtsgtr,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -96,8 +96,10 @@ public class AmazfitGTR2Coordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitgtsgtr2,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -96,8 +96,10 @@ public class AmazfitGTR2eCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitgtsgtr2,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -90,8 +90,10 @@ public class AmazfitGTSCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitgtsgtr,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -96,8 +96,10 @@ public class AmazfitGTS2Coordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitgtsgtr2,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -65,8 +65,10 @@ public class AmazfitGTS2MiniCoordinator extends AmazfitGTS2Coordinator {
return new int[]{
R.xml.devicesettings_amazfitgts2mini,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -96,8 +96,10 @@ public class AmazfitGTS2eCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitgtsgtr2,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -84,8 +84,10 @@ public class AmazfitNeoCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitneo,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,

View File

@ -90,8 +90,10 @@ public class AmazfitTRexCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfittrex,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -90,8 +90,10 @@ public class AmazfitTRexProCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfittrexpro,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -91,7 +91,9 @@ public class AmazfitVergeLCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitvergel,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -93,11 +93,13 @@ public class AmazfitXCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitx,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_dateformat,
R.xml.devicesettings_nightmode,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_swipeunlock,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -84,9 +84,11 @@ public class MiBand2Coordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_miband2,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_donotdisturb_withauto,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_rotatewrist_cycleinfo,
R.xml.devicesettings_buttonactions,
R.xml.devicesettings_reserve_alarms_calendar,

View File

@ -87,8 +87,10 @@ public class MiBand2HRXCoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_miband2,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_donotdisturb_withauto,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_rotatewrist_cycleinfo,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_transliteration

View File

@ -103,11 +103,13 @@ public class MiBand3Coordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_miband3,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_dateformat,
R.xml.devicesettings_nightmode,
R.xml.devicesettings_donotdisturb_withauto,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_donotdisturb_lift_wrist,
R.xml.devicesettings_swipeunlock,
R.xml.devicesettings_sync_calendar,

View File

@ -90,11 +90,13 @@ public class MiBand4Coordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_miband3,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_dateformat,
R.xml.devicesettings_nightmode,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_swipeunlock,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -101,12 +101,14 @@ public class MiBand5Coordinator extends HuamiCoordinator {
R.xml.devicesettings_miband5,
R.xml.devicesettings_miband5_vibration,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_dateformat,
R.xml.devicesettings_world_clocks,
R.xml.devicesettings_nightmode,
R.xml.devicesettings_liftwrist_display_sensitivity,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_swipeunlock,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -85,12 +85,14 @@ public class MiBand6Coordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_miband6,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_dateformat,
R.xml.devicesettings_world_clocks,
R.xml.devicesettings_nightmode,
R.xml.devicesettings_liftwrist_display_sensitivity,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_swipeunlock,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,

View File

@ -90,8 +90,10 @@ public class ZeppECoordinator extends HuamiCoordinator {
return new int[]{
R.xml.devicesettings_amazfitgtsgtr,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_expose_hr_thirdparty,

View File

@ -27,7 +27,6 @@ public final class MiBandConst {
public static final String PREF_MIBAND_USE_HR_FOR_SLEEP_DETECTION = "mi_hr_sleep_detection";
public static final String PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS = "device_time_offset_hours";
public static final String PREF_MI2_DATEFORMAT = "mi2_dateformat";
public static final String PREF_MI2_GOAL_NOTIFICATION = "mi2_goal_notification";
public static final String PREF_MI2_DISPLAY_ITEM_CLOCK = "clock";
public static final String PREF_MI2_DISPLAY_ITEM_STEPS = "steps";
public static final String PREF_MI2_DISPLAY_ITEM_DISTANCE = "distance";

View File

@ -37,16 +37,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_INACTIVITY_START;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_INACTIVITY_END;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_INACTIVITY_DND;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_INACTIVITY_DND_START;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_INACTIVITY_DND_END;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.ORIGIN_ALARM_CLOCK;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.ORIGIN_INCOMING_CALL;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_GOAL_NOTIFICATION;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MIBAND_ADDRESS;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MIBAND_USE_HR_FOR_SLEEP_DETECTION;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.VIBRATION_COUNT;
@ -82,120 +75,6 @@ public class MiBandPreferencesActivity extends AbstractSettingsActivity {
}
});
final Preference goalNotification = findPreference(PREF_MI2_GOAL_NOTIFICATION);
goalNotification.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_MI2_GOAL_NOTIFICATION);
}
});
return true;
}
});
final Preference inactivityWarnings = findPreference(PREF_INACTIVITY_ENABLE);
inactivityWarnings.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_INACTIVITY_ENABLE);
}
});
return true;
}
});
final Preference inactivityWarningsThreshold = findPreference(PREF_INACTIVITY_THRESHOLD);
inactivityWarningsThreshold.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_INACTIVITY_THRESHOLD);
}
});
return true;
}
});
final Preference inactivityWarningsStart = findPreference(PREF_INACTIVITY_START);
inactivityWarningsStart.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_INACTIVITY_START);
}
});
return true;
}
});
final Preference inactivityWarningsEnd = findPreference(PREF_INACTIVITY_END);
inactivityWarningsEnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_INACTIVITY_END);
}
});
return true;
}
});
final Preference inactivityWarningsDnd = findPreference(PREF_INACTIVITY_DND);
inactivityWarningsDnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_INACTIVITY_DND);
}
});
return true;
}
});
final Preference inactivityWarningsDndStart = findPreference(PREF_INACTIVITY_DND_START);
inactivityWarningsDndStart.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_INACTIVITY_DND_START);
}
});
return true;
}
});
final Preference inactivityWarningsDndEnd = findPreference(PREF_INACTIVITY_DND_END);
inactivityWarningsDndEnd.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
invokeLater(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onSendConfiguration(PREF_INACTIVITY_DND_END);
}
});
return true;
}
});
final Preference fitnessGoal = findPreference(ActivityUser.PREF_USER_STEPS_GOAL);
fitnessGoal.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override

View File

@ -184,6 +184,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SOUNDS;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SYNC_CALENDAR;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_USER_FITNESS_GOAL_NOTIFICATION;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_BUTTON_ACTION_SELECTION_BROADCAST;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_START;
@ -2410,7 +2411,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
case MiBandConst.PREF_MI2_DATEFORMAT:
setDateDisplay(builder);
break;
case MiBandConst.PREF_MI2_GOAL_NOTIFICATION:
case PREF_USER_FITNESS_GOAL_NOTIFICATION:
setGoalNotification(builder);
break;
case PREF_ACTIVATE_DISPLAY_ON_LIFT:
@ -2904,7 +2905,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
}
private HuamiSupport setGoalNotification(TransactionBuilder builder) {
boolean enable = HuamiCoordinator.getGoalNotification();
boolean enable = HuamiCoordinator.getGoalNotification(gbDevice.getAddress());
LOG.info("Setting goal notification to " + enable);
if (enable) {
writeToConfiguration(builder,HuamiService.COMMAND_ENABLE_GOAL_NOTIFICATION);
@ -3236,23 +3237,23 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
}
private HuamiSupport setInactivityWarnings(TransactionBuilder builder) {
boolean enable = HuamiCoordinator.getInactivityWarnings();
boolean enable = HuamiCoordinator.getInactivityWarnings(gbDevice.getAddress());
LOG.info("Setting inactivity warnings to " + enable);
if (enable) {
byte[] data = HuamiService.COMMAND_ENABLE_INACTIVITY_WARNINGS.clone();
int threshold = HuamiCoordinator.getInactivityWarningsThreshold();
int threshold = HuamiCoordinator.getInactivityWarningsThreshold(gbDevice.getAddress());
data[HuamiService.INACTIVITY_WARNINGS_THRESHOLD] = (byte) threshold;
Calendar calendar = GregorianCalendar.getInstance();
boolean enableDnd = HuamiCoordinator.getInactivityWarningsDnd();
boolean enableDnd = HuamiCoordinator.getInactivityWarningsDnd(gbDevice.getAddress());
Date intervalStart = HuamiCoordinator.getInactivityWarningsStart();
Date intervalEnd = HuamiCoordinator.getInactivityWarningsEnd();
Date dndStart = HuamiCoordinator.getInactivityWarningsDndStart();
Date dndEnd = HuamiCoordinator.getInactivityWarningsDndEnd();
Date intervalStart = HuamiCoordinator.getInactivityWarningsStart(gbDevice.getAddress());
Date intervalEnd = HuamiCoordinator.getInactivityWarningsEnd(gbDevice.getAddress());
Date dndStart = HuamiCoordinator.getInactivityWarningsDndStart(gbDevice.getAddress());
Date dndEnd = HuamiCoordinator.getInactivityWarningsDndEnd(gbDevice.getAddress());
// The first interval always starts when the warnings interval starts
calendar.setTime(intervalStart);

View File

@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#7E7E7E"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M7.59,5.41c-0.78,-0.78 -0.78,-2.05 0,-2.83 0.78,-0.78 2.05,-0.78 2.83,0 0.78,0.78 0.78,2.05 0,2.83 -0.79,0.79 -2.05,0.79 -2.83,0zM6,16L6,7L4,7v9c0,2.76 2.24,5 5,5h6v-2L9,19c-1.66,0 -3,-1.34 -3,-3zM20,20.07L14.93,15L11.5,15v-3.68c1.4,1.15 3.6,2.16 5.5,2.16v-2.16c-1.66,0.02 -3.61,-0.87 -4.67,-2.04l-1.4,-1.55c-0.19,-0.21 -0.43,-0.38 -0.69,-0.5 -0.29,-0.14 -0.62,-0.23 -0.96,-0.23h-0.03C8.01,7 7,8.01 7,9.25L7,15c0,1.66 1.34,3 3,3h5.07l3.5,3.5L20,20.07z"/>
</vector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:defaultValue="false"
android:icon="@drawable/ic_star_gray"
android:key="fitness_goal_notification"
android:summary="@string/mi2_prefs_goal_notification_summary"
android:title="@string/mi2_prefs_goal_notification" />
</androidx.preference.PreferenceScreen>

View File

@ -7,25 +7,26 @@
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
android:title="@string/mi2_prefs_inactivity_warnings">
<!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/mi2_prefs_inactivity_warnings_summary" />
<SwitchPreference
android:defaultValue="false"
android:key="inactivity_warnings_enable"
android:title="@string/mi2_prefs_inactivity_warnings" />
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"/>
<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" />

View File

@ -0,0 +1,56 @@
<?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">
<SwitchPreference
android:defaultValue="false"
android:key="inactivity_warnings_enable"
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:inputType="number"
android:key="inactivity_warnings_threshold"
android:maxLength="2"
android:title="@string/mi2_prefs_inactivity_warnings_threshold" />
<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="22:00"
android:dependency="inactivity_warnings_enable"
android:key="inactivity_warnings_end"
android:title="@string/mi2_prefs_do_not_disturb_end" />
<SwitchPreference
android:defaultValue="false"
android:dependency="inactivity_warnings_enable"
android:key="inactivity_warnings_dnd"
android:summary="@string/mi2_prefs_inactivity_warnings_dnd_summary"
android:title="@string/mi2_prefs_do_not_disturb" />
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
android:defaultValue="12:00"
android:dependency="inactivity_warnings_dnd"
android:key="inactivity_warnings_dnd_start"
android:title="@string/mi2_prefs_do_not_disturb_start" />
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
android:defaultValue="14:00"
android:dependency="inactivity_warnings_dnd"
android:key="inactivity_warnings_dnd_end"
android:title="@string/mi2_prefs_do_not_disturb_end" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View File

@ -13,7 +13,8 @@
<SwitchPreference
android:defaultValue="false"
android:key="inactivity_warnings_enable"
android:title="@string/mi2_prefs_inactivity_warnings" />
android:title="@string/mi2_prefs_inactivity_warnings"
android:summary="@string/mi2_prefs_inactivity_warnings_summary" />
<ListPreference
android:defaultValue="4"
@ -26,11 +27,13 @@
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
android:defaultValue="08: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="16:00"
android:dependency="inactivity_warnings_enable"
android:key="inactivity_warnings_end"
android:title="@string/mi2_prefs_do_not_disturb_end" />
</PreferenceScreen>

View File

@ -161,7 +161,7 @@
<PreferenceScreen
android:key="vibration_profile_key_idle_alerts"
android:icon="@drawable/ic_seat_normal"
android:icon="@drawable/ic_chair"
android:title="@string/pref_screen_notification_idle_alerts"
android:persistent="false">

View File

@ -16,12 +16,6 @@
android:maxLength="5"
android:title="@string/miband_prefs_fitness_goal" />
<CheckBoxPreference
android:defaultValue="false"
android:key="mi2_goal_notification"
android:summary="@string/mi2_prefs_goal_notification_summary"
android:title="@string/mi2_prefs_goal_notification" />
<CheckBoxPreference
android:defaultValue="false"
android:key="mi_hr_sleep_detection"
@ -35,63 +29,6 @@
android:summary="%s"
android:title="@string/prefs_title_heartrate_measurement_interval" />
<PreferenceScreen
android:key="inactivity_warnings_key"
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
android:title="@string/mi2_prefs_inactivity_warnings"
android:persistent="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/mi2_prefs_inactivity_warnings"
/>
<CheckBoxPreference
android:defaultValue="false"
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_enable"
android:inputType="numberSigned"
android:key="inactivity_warnings_threshold"
android:maxLength="2"
android:title="@string/mi2_prefs_inactivity_warnings_threshold" />
<nodomain.freeyourgadget.gadgetbridge.util.TimePreference
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.TimePreference
android:defaultValue="22:00"
android:dependency="inactivity_warnings_enable"
android:key="inactivity_warnings_end"
android:title="@string/mi2_prefs_do_not_disturb_end" />
<CheckBoxPreference
android:defaultValue="false"
android:dependency="inactivity_warnings_enable"
android:key="inactivity_warnings_dnd"
android:summary="@string/mi2_prefs_inactivity_warnings_dnd_summary"
android:title="@string/mi2_prefs_do_not_disturb" />
<nodomain.freeyourgadget.gadgetbridge.util.TimePreference
android:defaultValue="12:00"
android:dependency="inactivity_warnings_dnd"
android:key="inactivity_warnings_dnd_start"
android:title="@string/mi2_prefs_do_not_disturb_start" />
<nodomain.freeyourgadget.gadgetbridge.util.TimePreference
android:defaultValue="14:00"
android:dependency="inactivity_warnings_dnd"
android:key="inactivity_warnings_dnd_end"
android:title="@string/mi2_prefs_do_not_disturb_end" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory