1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-09 03:37:03 +01:00

ZeTime: Migrate global preferences to device-specific

This commit is contained in:
José Rebelo 2024-08-23 20:22:20 +01:00
parent 141ff623c7
commit d8266b3d6b
36 changed files with 711 additions and 951 deletions

View File

@ -190,10 +190,6 @@
android:name=".devices.pebble.PebbleSettingsActivity" android:name=".devices.pebble.PebbleSettingsActivity"
android:label="@string/pref_title_pebble_settings" android:label="@string/pref_title_pebble_settings"
android:parentActivityName=".activities.SettingsActivity" /> android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name=".devices.zetime.ZeTimePreferenceActivity"
android:label="@string/zetime_title_settings"
android:parentActivityName=".activities.SettingsActivity" />
<activity <activity
android:name=".activities.ActivitySummariesActivity" android:name=".activities.ActivitySummariesActivity"
android:label="@string/activity_summaries" android:label="@string/activity_summaries"

View File

@ -122,7 +122,7 @@ public class GBApplication extends Application {
private static SharedPreferences sharedPrefs; private static SharedPreferences sharedPrefs;
private static final String PREFS_VERSION = "shared_preferences_version"; 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 //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 = 34; private static final int CURRENT_PREFS_VERSION = 35;
private static final LimitedQueue<Integer, String> mIDSenderLookup = new LimitedQueue<>(16); private static final LimitedQueue<Integer, String> mIDSenderLookup = new LimitedQueue<>(16);
private static GBPrefs prefs; private static GBPrefs prefs;
@ -1614,6 +1614,72 @@ public class GBApplication extends Application {
} }
} }
if (oldVersion < 35) {
// Migrate ZeTime preferences to device-specific
try (DBHandler db = acquireDB()) {
final DaoSession daoSession = db.getDaoSession();
final List<Device> activeDevices = DBHelper.getActiveDevices(daoSession);
for (Device dbDevice : activeDevices) {
final DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
if (deviceType == DeviceType.ZETIME) {
final SharedPreferences deviceSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
final SharedPreferences.Editor deviceSharedPrefsEdit = deviceSharedPrefs.edit();
// Vibration Profiles
deviceSharedPrefsEdit.putString("zetime_vibration_profile_sms", sharedPrefs.getString("zetime_vibration_profile_sms", "2"));
deviceSharedPrefsEdit.putString("zetime_vibration_profile_incoming_call", sharedPrefs.getString("zetime_vibration_profile_incoming_call", "13"));
deviceSharedPrefsEdit.putString("zetime_vibration_profile_missed_call", sharedPrefs.getString("zetime_vibration_profile_missed_call", "12"));
deviceSharedPrefsEdit.putString("zetime_vibration_profile_generic_email", sharedPrefs.getString("zetime_vibration_profile_generic_email", "12"));
deviceSharedPrefsEdit.putString("zetime_vibration_profile_generic_social", sharedPrefs.getString("zetime_vibration_profile_generic_social", "12"));
deviceSharedPrefsEdit.putString("zetime_alarm_signaling", sharedPrefs.getString("zetime_alarm_signaling", "11"));
deviceSharedPrefsEdit.putString("zetime_vibration_profile_calendar", sharedPrefs.getString("zetime_vibration_profile_calendar", "12"));
deviceSharedPrefsEdit.putString("zetime_vibration_profile_inactivity", sharedPrefs.getString("zetime_vibration_profile_inactivity", "12"));
deviceSharedPrefsEdit.putString("zetime_vibration_profile_lowpower", sharedPrefs.getString("zetime_vibration_profile_lowpower", "4"));
deviceSharedPrefsEdit.putString("zetime_vibration_profile_antiloss", sharedPrefs.getString("zetime_vibration_profile_antiloss", "13"));
// DND
deviceSharedPrefsEdit.putString("do_not_disturb_no_auto", sharedPrefs.getString("do_not_disturb", "off"));
deviceSharedPrefsEdit.putString("do_not_disturb_no_auto_start", sharedPrefs.getString("do_not_disturb_start", "22:00"));
deviceSharedPrefsEdit.putString("do_not_disturb_no_auto_end", sharedPrefs.getString("do_not_disturb_end", "07:00"));
// HR
deviceSharedPrefsEdit.putString("heartrate_measurement_interval", sharedPrefs.getString("heartrate_measurement_interval", "0"));
deviceSharedPrefsEdit.putBoolean("zetime_heartrate_alarm_enable", sharedPrefs.getBoolean("zetime_heartrate_alarm_enable", false));
deviceSharedPrefsEdit.putString("alarm_max_heart_rate", sharedPrefs.getString("alarm_max_heart_rate", "180"));
deviceSharedPrefsEdit.putString("alarm_min_heart_rate", sharedPrefs.getString("alarm_min_heart_rate", "60"));
// Inactivity warnings
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_enable", sharedPrefs.getBoolean("inactivity_warnings_enable", false));
deviceSharedPrefsEdit.putString("inactivity_warnings_threshold", sharedPrefs.getString("inactivity_warnings_threshold", "60"));
deviceSharedPrefsEdit.putString("inactivity_warnings_start", sharedPrefs.getString("inactivity_warnings_start", "06:00"));
deviceSharedPrefsEdit.putString("inactivity_warnings_end", sharedPrefs.getString("inactivity_warnings_end", "22:00"));
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_mo", sharedPrefs.getBoolean("inactivity_warnings_mo", false));
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_tu", sharedPrefs.getBoolean("inactivity_warnings_tu", false));
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_we", sharedPrefs.getBoolean("inactivity_warnings_we", false));
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_th", sharedPrefs.getBoolean("inactivity_warnings_th", false));
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_fr", sharedPrefs.getBoolean("inactivity_warnings_fr", false));
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_sa", sharedPrefs.getBoolean("inactivity_warnings_sa", false));
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_su", sharedPrefs.getBoolean("inactivity_warnings_su", false));
// Developer settings
deviceSharedPrefsEdit.putBoolean("keep_activity_data_on_device", sharedPrefs.getBoolean("zetime_dont_del_actdata", false));
// Activity info
deviceSharedPrefsEdit.putBoolean("zetime_activity_tracking", sharedPrefs.getBoolean("zetime_activity_tracking", false));
deviceSharedPrefsEdit.putString("zetime_calories_type", sharedPrefs.getString("zetime_calories_type", "0"));
// Display
deviceSharedPrefsEdit.putString("zetime_screentime", sharedPrefs.getString("zetime_screentime", "30"));
deviceSharedPrefsEdit.putBoolean("zetime_handmove_display", sharedPrefs.getBoolean("zetime_handmove_display", false));
deviceSharedPrefsEdit.putString("zetime_analog_mode", sharedPrefs.getString("zetime_analog_mode", "0"));
// Date format
deviceSharedPrefsEdit.putString("zetime_date_format", sharedPrefs.getString("zetime_date_format", "2"));
// Unused, but migrate it anyway
deviceSharedPrefsEdit.putString("zetime_shock_strength", sharedPrefs.getString("zetime_shock_strength", "255"));
deviceSharedPrefsEdit.apply();
}
}
} catch (Exception e) {
Log.w(TAG, "error acquiring DB lock");
}
}
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION)); editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
editor.apply(); editor.apply();
} }

View File

@ -231,7 +231,13 @@ public abstract class AbstractPreferenceFragment extends PreferenceFragmentCompa
summary = prefs.getString(key, preference.getSummary() != null ? preference.getSummary().toString() : ""); summary = prefs.getString(key, preference.getSummary() != null ? preference.getSummary().toString() : "");
} }
if (preference.getSummaryProvider() != null) {
try {
preference.setSummary(summary); preference.setSummary(summary);
} catch (final IllegalStateException e) {
LOG.error("Failed to set preference summary for {}", key, e);
}
}
} }
AbstractPreferenceFragment.this.onSharedPreferenceChanged(preference); AbstractPreferenceFragment.this.onSharedPreferenceChanged(preference);

View File

@ -67,7 +67,6 @@ import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsPreferencesA
import nodomain.freeyourgadget.gadgetbridge.activities.discovery.DiscoveryPairingPreferenceActivity; import nodomain.freeyourgadget.gadgetbridge.activities.discovery.DiscoveryPairingPreferenceActivity;
import nodomain.freeyourgadget.gadgetbridge.database.PeriodicExporter; import nodomain.freeyourgadget.gadgetbridge.database.PeriodicExporter;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleSettingsActivity; import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleSettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.devices.zetime.ZeTimePreferenceActivity;
import nodomain.freeyourgadget.gadgetbridge.externalevents.TimeChangeReceiver; import nodomain.freeyourgadget.gadgetbridge.externalevents.TimeChangeReceiver;
import nodomain.freeyourgadget.gadgetbridge.model.Weather; import nodomain.freeyourgadget.gadgetbridge.model.Weather;
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils; import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
@ -136,15 +135,6 @@ public class SettingsActivity extends AbstractSettingsActivityV2 {
}); });
} }
pref = findPreference("pref_key_zetime");
if (pref != null) {
pref.setOnPreferenceClickListener(preference -> {
Intent enableIntent = new Intent(requireContext(), ZeTimePreferenceActivity.class);
startActivity(enableIntent);
return true;
});
}
pref = findPreference("datetime_synconconnect"); pref = findPreference("datetime_synconconnect");
if (pref != null) { if (pref != null) {
pref.setOnPreferenceChangeListener((preference, newVal) -> { pref.setOnPreferenceChangeListener((preference, newVal) -> {

View File

@ -38,10 +38,12 @@ public interface DeviceSpecificSettingsCustomizer extends Parcelable {
/** /**
* Customize the settings on the {@link DeviceSpecificSettingsFragment}. * Customize the settings on the {@link DeviceSpecificSettingsFragment}.
*
* @param handler the {@link DeviceSpecificSettingsHandler} * @param handler the {@link DeviceSpecificSettingsHandler}
* @param prefs the {@link android.content.SharedPreferences} * @param prefs the {@link android.content.SharedPreferences}
* @param rootKey the root key of the current screen
*/ */
void customizeSettings(final DeviceSpecificSettingsHandler handler, Prefs prefs); void customizeSettings(final DeviceSpecificSettingsHandler handler, Prefs prefs, final String rootKey);
/** /**
* Keys of preferences which should print its values as a summary below the preference name. * Keys of preferences which should print its values as a summary below the preference name.

View File

@ -192,7 +192,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
} }
} }
setChangeListener(); setChangeListener(rootKey);
} }
private void addDynamicSettings(final String rootKey) { private void addDynamicSettings(final String rootKey) {
@ -334,7 +334,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
}); });
} }
private void setChangeListener() { private void setChangeListener(final String rootKey) {
final DeviceCoordinator coordinator = device.getDeviceCoordinator(); final DeviceCoordinator coordinator = device.getDeviceCoordinator();
final Prefs prefs = new Prefs(getPreferenceManager().getSharedPreferences()); final Prefs prefs = new Prefs(getPreferenceManager().getSharedPreferences());
@ -1255,7 +1255,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
} }
if (deviceSpecificSettingsCustomizer != null) { if (deviceSpecificSettingsCustomizer != null) {
deviceSpecificSettingsCustomizer.customizeSettings(this, prefs); deviceSpecificSettingsCustomizer.customizeSettings(this, prefs, rootKey);
} }
} }

View File

@ -72,7 +72,7 @@ public class BangleJSSettingsCustomizer implements DeviceSpecificSettingsCustomi
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
final Preference fullSyncPref = handler.findPreference(PREF_BANGLEJS_ACTIVITY_FULL_SYNC_TRIGGER); final Preference fullSyncPref = handler.findPreference(PREF_BANGLEJS_ACTIVITY_FULL_SYNC_TRIGGER);
if (fullSyncPref != null) { if (fullSyncPref != null) {
fullSyncPref.setOnPreferenceClickListener(preference -> { fullSyncPref.setOnPreferenceClickListener(preference -> {

View File

@ -35,7 +35,7 @@ public class CmfWatchProSettingsCustomizer implements DeviceSpecificSettingsCust
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
final String[] prefsToHide = new String[]{ final String[] prefsToHide = new String[]{
"pref_key_header_heartrate_sleep", "pref_key_header_heartrate_sleep",
DeviceSettingsPreferenceConst.PREF_HEARTRATE_USE_FOR_SLEEP_DETECTION, DeviceSettingsPreferenceConst.PREF_HEARTRATE_USE_FOR_SLEEP_DETECTION,

View File

@ -51,7 +51,7 @@ public class GalaxyBudsSettingsCustomizer implements DeviceSpecificSettingsCusto
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, Prefs prefs, final String rootKey) {
final Preference pref_galaxy_buds_pro_balance = handler.findPreference(PREF_GALAXY_BUDS_PRO_BALANCE); final Preference pref_galaxy_buds_pro_balance = handler.findPreference(PREF_GALAXY_BUDS_PRO_BALANCE);
if (pref_galaxy_buds_pro_balance != null) { if (pref_galaxy_buds_pro_balance != null) {

View File

@ -49,7 +49,7 @@ public class GarminSettingsCustomizer implements DeviceSpecificSettingsCustomize
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
final Preference realtimeSettings = handler.findPreference(GarminPreferences.PREF_GARMIN_REALTIME_SETTINGS); final Preference realtimeSettings = handler.findPreference(GarminPreferences.PREF_GARMIN_REALTIME_SETTINGS);
if (realtimeSettings != null) { if (realtimeSettings != null) {
realtimeSettings.setOnPreferenceClickListener(preference -> { realtimeSettings.setOnPreferenceClickListener(preference -> {

View File

@ -51,7 +51,7 @@ public class HuamiSettingsCustomizer implements DeviceSpecificSettingsCustomizer
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
final Preference hrAlertActivePref = handler.findPreference(DeviceSettingsPreferenceConst.PREF_HEARTRATE_ALERT_ACTIVE_HIGH_THRESHOLD); final Preference hrAlertActivePref = handler.findPreference(DeviceSettingsPreferenceConst.PREF_HEARTRATE_ALERT_ACTIVE_HIGH_THRESHOLD);
if (hrAlertActivePref != null) { if (hrAlertActivePref != null) {
hrAlertActivePref.setVisible(false); hrAlertActivePref.setVisible(false);

View File

@ -59,8 +59,8 @@ public class ZeppOsSettingsCustomizer extends HuamiSettingsCustomizer {
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
super.customizeSettings(handler, prefs); super.customizeSettings(handler, prefs, rootKey);
// These are not reported by the normal configs // These are not reported by the normal configs
populateOrHideListPreference(HuamiConst.PREF_DISPLAY_ITEMS_SORTABLE, handler, prefs); populateOrHideListPreference(HuamiConst.PREF_DISPLAY_ITEMS_SORTABLE, handler, prefs);

View File

@ -40,7 +40,6 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants.PREF_HUAWEI_DEBUG_REQUEST; import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants.PREF_HUAWEI_DEBUG_REQUEST;
import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants.PREF_HUAWEI_TRUSLEEP; import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants.PREF_HUAWEI_TRUSLEEP;
import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants.PREF_HUAWEI_WORKMODE; import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants.PREF_HUAWEI_WORKMODE;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO;
public class HuaweiSettingsCustomizer implements DeviceSpecificSettingsCustomizer { public class HuaweiSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
final GBDevice device; final GBDevice device;
@ -93,7 +92,7 @@ public class HuaweiSettingsCustomizer implements DeviceSpecificSettingsCustomize
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, Prefs prefs, final String rootKey) {
handler.addPreferenceHandlerFor(PREF_FORCE_OPTIONS); handler.addPreferenceHandlerFor(PREF_FORCE_OPTIONS);
handler.addPreferenceHandlerFor(PREF_FORCE_ENABLE_SMART_ALARM); handler.addPreferenceHandlerFor(PREF_FORCE_ENABLE_SMART_ALARM);

View File

@ -45,7 +45,7 @@ public class MiBandSettingsCustomizer implements DeviceSpecificSettingsCustomize
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
for (final NotificationType type : NotificationType.values()) { for (final NotificationType type : NotificationType.values()) {
String countPrefKey = "mi_vibration_count_" + type.getGenericType(); String countPrefKey = "mi_vibration_count_" + type.getGenericType();
handler.setInputTypeFor(countPrefKey, InputType.TYPE_CLASS_NUMBER); handler.setInputTypeFor(countPrefKey, InputType.TYPE_CLASS_NUMBER);

View File

@ -49,7 +49,7 @@ public class EarSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
final AbstractEarCoordinator earCoordinator = (AbstractEarCoordinator) handler.getDevice().getDeviceCoordinator(); final AbstractEarCoordinator earCoordinator = (AbstractEarCoordinator) handler.getDevice().getDeviceCoordinator();
if (!earCoordinator.supportsLightAncAndTransparency()) { if (!earCoordinator.supportsLightAncAndTransparency()) {

View File

@ -20,7 +20,7 @@ public class QHybridSettingsCustomizer implements DeviceSpecificSettingsCustomiz
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
final Preference pref = handler.findPreference("pref_key_qhybrid_legacy"); final Preference pref = handler.findPreference("pref_key_qhybrid_legacy");
if (pref != null) { if (pref != null) {
pref.setOnPreferenceClickListener(preference -> { pref.setOnPreferenceClickListener(preference -> {

View File

@ -55,7 +55,6 @@ import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
@ -118,7 +117,7 @@ public class SonyHeadphonesSettingsCustomizer implements DeviceSpecificSettingsC
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, Prefs prefs, final String rootKey) {
final SonyHeadphonesCoordinator coordinator = (SonyHeadphonesCoordinator) device.getDeviceCoordinator(); final SonyHeadphonesCoordinator coordinator = (SonyHeadphonesCoordinator) device.getDeviceCoordinator();
// Only enable the focus on voice check and voice level slider if the ambient sound control mode is ambient sound // Only enable the focus on voice check and voice level slider if the ambient sound control mode is ambient sound

View File

@ -29,7 +29,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class SonyWena3SettingsCustomizer implements DeviceSpecificSettingsCustomizer { public class SonyWena3SettingsCustomizer implements DeviceSpecificSettingsCustomizer {
@Override @Override
public void customizeSettings(DeviceSpecificSettingsHandler handler, Prefs prefs) { public void customizeSettings(DeviceSpecificSettingsHandler handler, Prefs prefs, final String rootKey) {
handler.addPreferenceHandlerFor(SonyWena3SettingKeys.RICH_DESIGN_MODE); handler.addPreferenceHandlerFor(SonyWena3SettingKeys.RICH_DESIGN_MODE);
handler.addPreferenceHandlerFor(SonyWena3SettingKeys.LARGE_FONT_SIZE); handler.addPreferenceHandlerFor(SonyWena3SettingKeys.LARGE_FONT_SIZE);
handler.addPreferenceHandlerFor(SonyWena3SettingKeys.WEATHER_IN_STATUSBAR); handler.addPreferenceHandlerFor(SonyWena3SettingKeys.WEATHER_IN_STATUSBAR);

View File

@ -63,7 +63,7 @@ public class SoundcoreMotion300SettingsCustomizer implements DeviceSpecificSetti
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
ListPreference equalizerDirection = handler.findPreference(PREF_SOUNDCORE_EQUALIZER_DIRECTION); ListPreference equalizerDirection = handler.findPreference(PREF_SOUNDCORE_EQUALIZER_DIRECTION);
if (equalizerDirection != null) { if (equalizerDirection != null) {

View File

@ -37,7 +37,7 @@ public class TestDeviceSpecificSettingsCustomizer implements DeviceSpecificSetti
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
final Preference pref = handler.findPreference(TestDeviceConst.PREF_TEST_FEATURES); final Preference pref = handler.findPreference(TestDeviceConst.PREF_TEST_FEATURES);
if (pref == null) { if (pref == null) {
return; return;

View File

@ -39,7 +39,7 @@ public class XiaomiSettingsCustomizer implements DeviceSpecificSettingsCustomize
} }
@Override @Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) { public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
final Preference activityMonitoringPref = handler.findPreference(DeviceSettingsPreferenceConst.PREF_HEARTRATE_ACTIVITY_MONITORING); final Preference activityMonitoringPref = handler.findPreference(DeviceSettingsPreferenceConst.PREF_HEARTRATE_ACTIVITY_MONITORING);
if (activityMonitoringPref != null) { if (activityMonitoringPref != null) {
activityMonitoringPref.setVisible(false); activityMonitoringPref.setVisible(false);

View File

@ -152,11 +152,5 @@ public class ZeTimeConstants {
public static final String PREF_LOW_POWER_SIGNALING = "zetime_vibration_profile_lowpower"; public static final String PREF_LOW_POWER_SIGNALING = "zetime_vibration_profile_lowpower";
public static final String PREF_ANTI_LOSS_SIGNALING = "zetime_vibration_profile_antiloss"; public static final String PREF_ANTI_LOSS_SIGNALING = "zetime_vibration_profile_antiloss";
public static final String PREF_USER_SLEEP_GOAL = "activity_user_sleep_duration";
public static final String PREF_USER_CALORIES_GOAL = "activity_user_calories_burnt";
public static final String PREF_USER_DISTANCE_GOAL = "activity_user_distance_meters";
public static final String PREF_USER_ACTIVETIME_GOAL = "activity_user_activetime_minutes";
public static final String PREF_SHOCK_STRENGTH = "zetime_shock_strength"; public static final String PREF_SHOCK_STRENGTH = "zetime_shock_strength";
} }

View File

@ -17,55 +17,34 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.zetime; package nodomain.freeyourgadget.gadgetbridge.devices.zetime;
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.Collection; import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsScreen;
import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.Device; import nodomain.freeyourgadget.gadgetbridge.entities.Device;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
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.service.DeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.zetime.ZeTimeDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.zetime.ZeTimeDeviceSupport;
public class ZeTimeCoordinator extends AbstractBLEDeviceCoordinator { public class ZeTimeCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public Collection<? extends ScanFilter> createBLEScanFilters() {
return super.createBLEScanFilters();
}
@Override @Override
protected Pattern getSupportedDeviceName() { protected Pattern getSupportedDeviceName() {
return Pattern.compile("ZeTime.*"); return Pattern.compile("ZeTime.*");
} }
@Nullable
@Override
public Class<? extends Activity> getPairingActivity() {
return null;
}
@Override @Override
public boolean supportsScreenshots(final GBDevice device) { public int getAlarmSlotCount(final GBDevice device) {
return false;
}
@Override
public int getAlarmSlotCount(GBDevice device) {
return 3; // FIXME - check the real value return 3; // FIXME - check the real value
} }
@ -79,11 +58,6 @@ public class ZeTimeCoordinator extends AbstractBLEDeviceCoordinator {
return true; return true;
} }
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {
return null;
}
@Override @Override
public String getManufacturer() { public String getManufacturer() {
return "MyKronoz"; return "MyKronoz";
@ -94,11 +68,6 @@ public class ZeTimeCoordinator extends AbstractBLEDeviceCoordinator {
return true; return true;
} }
@Override
public Class<? extends Activity> getAppsManagementActivity() {
return null;
}
@Override @Override
public boolean supportsHeartRateMeasurement(GBDevice device) { public boolean supportsHeartRateMeasurement(GBDevice device) {
return true; return true;
@ -109,16 +78,6 @@ public class ZeTimeCoordinator extends AbstractBLEDeviceCoordinator {
return true; return true;
} }
@Override
public boolean supportsAppsManagement(final GBDevice device) {
return false;
}
@Override
public boolean supportsCalendarEvents() {
return false;
}
@Override @Override
public SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session) { public SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
return new ZeTimeSampleProvider(device, session); return new ZeTimeSampleProvider(device, session);
@ -145,16 +104,85 @@ public class ZeTimeCoordinator extends AbstractBLEDeviceCoordinator {
} }
@Override @Override
public boolean supportsUnicodeEmojis() { return true; } public boolean supportsUnicodeEmojis() {
return true;
}
@Override @Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) { public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
return new int[]{ final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
R.xml.devicesettings_zetime,
R.xml.devicesettings_timeformat, final List<Integer> generic = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.GENERIC);
R.xml.devicesettings_wearlocation, generic.add(R.xml.devicesettings_wearlocation);
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_transliteration final List<Integer> datetime = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DATE_TIME);
datetime.add(R.xml.devicesettings_timeformat);
datetime.add(R.xml.devicesettings_zetime_date_format);
final List<Integer> display = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DISPLAY);
display.add(R.xml.devicesettings_zetime_display);
final List<Integer> health = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.HEALTH);
health.add(R.xml.devicesettings_zetime_health);
final List<Integer> notifications = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CALLS_AND_NOTIFICATIONS);
notifications.add(R.xml.devicesettings_donotdisturb_no_auto);
notifications.add(R.xml.devicesettings_zetime_vibrationpatterns);
notifications.add(R.xml.devicesettings_transliteration);
final List<Integer> calendar = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CALENDAR);
calendar.add(R.xml.devicesettings_sync_calendar);
final List<Integer> activityInfo = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.ACTIVITY_INFO);
activityInfo.add(R.xml.devicesettings_zetime_activity_info);
final List<Integer> developer = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DEVELOPER);
developer.add(R.xml.devicesettings_keep_activity_data_on_device);
return deviceSpecificSettings;
}
@Override
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) {
return new ZeTimeSettingsCustomizer(device);
}
@Override
public List<HeartRateCapability.MeasurementInterval> getHeartRateMeasurementIntervals() {
return Arrays.asList(
HeartRateCapability.MeasurementInterval.OFF,
HeartRateCapability.MeasurementInterval.MINUTES_5,
HeartRateCapability.MeasurementInterval.MINUTES_10,
HeartRateCapability.MeasurementInterval.MINUTES_15,
HeartRateCapability.MeasurementInterval.MINUTES_30,
HeartRateCapability.MeasurementInterval.MINUTES_45,
HeartRateCapability.MeasurementInterval.HOUR_1
);
}
@Override
public String[] getSupportedLanguageSettings(final GBDevice device) {
return new String[]{
"auto",
"zh_CN",
"zh_TW",
"en_US",
"es_ES",
"de_DE",
"it_IT",
"fr_FR",
"pt_PT",
"nl_NL",
"sv_SE",
"pl_PL",
"cs_CZ",
"el_GR",
"ru_RU",
"he_IL",
"ar_SA",
"ja_JP",
"ko_KO",
"th_TH",
}; };
} }
@ -164,13 +192,11 @@ public class ZeTimeCoordinator extends AbstractBLEDeviceCoordinator {
return ZeTimeDeviceSupport.class; return ZeTimeDeviceSupport.class;
} }
@Override @Override
public int getDeviceNameResource() { public int getDeviceNameResource() {
return R.string.devicetype_mykronoz_zetime; return R.string.devicetype_mykronoz_zetime;
} }
@Override @Override
public int getDefaultIconResource() { public int getDefaultIconResource() {
return R.drawable.ic_device_zetime; return R.drawable.ic_device_zetime;

View File

@ -1,132 +0,0 @@
/* Copyright (C) 2018-2024 Andreas Shimokawa, Damien Gaignon, José Rebelo,
Sebastian Kranz
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.zetime;
import android.os.Bundle;
import android.text.InputType;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractPreferenceFragment;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2;
public class ZeTimePreferenceActivity extends AbstractSettingsActivityV2 {
@Override
protected String fragmentTag() {
return ZeTimePreferencesFragment.FRAGMENT_TAG;
}
@Override
protected PreferenceFragmentCompat newFragment() {
return new ZeTimePreferencesFragment();
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GBApplication.deviceService().onReadConfiguration("do_it");
}
public static class ZeTimePreferencesFragment extends AbstractPreferenceFragment {
static final String FRAGMENT_TAG = "ZETIME_PREFERENCES_FRAGMENT";
@Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
setPreferencesFromResource(R.xml.zetime_preferences, rootKey);
final Preference heartrateMeasurementInterval = findPreference(ZeTimeConstants.PREF_ZETIME_HEARTRATE_INTERVAL);
if (heartrateMeasurementInterval != null) {
heartrateMeasurementInterval.setOnPreferenceChangeListener((preference, newVal) -> {
GBApplication.deviceService().onSetHeartRateMeasurementInterval(Integer.parseInt((String) newVal));
return true;
});
}
setInputTypeFor(ZeTimeConstants.PREF_SCREENTIME, InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("fitness_goal", InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("activity_user_sleep_duration", InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("activity_user_calories_burnt", InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("activity_user_distance_meters", InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("activity_user_activetime_minutes", InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("inactivity_warnings_threshold", InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("alarm_max_heart_rate", InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("alarm_min_heart_rate", InputType.TYPE_CLASS_NUMBER);
addPreferenceHandlerFor(ZeTimeConstants.PREF_SCREENTIME);
addPreferenceHandlerFor(ZeTimeConstants.PREF_ANALOG_MODE);
addPreferenceHandlerFor(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
addPreferenceHandlerFor(ZeTimeConstants.PREF_CALORIES_TYPE);
addPreferenceHandlerFor(ZeTimeConstants.PREF_DATE_FORMAT);
addPreferenceHandlerFor(ZeTimeConstants.PREF_SMS_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_CALENDAR_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_CALL_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_EMAIL_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_LOW_POWER_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_SOCIAL_SIGNALING);
addPreferenceHandlerFor(ZeTimeConstants.PREF_ZETIME_HEARTRATE_ALARM);
addPreferenceHandlerFor(ZeTimeConstants.PREF_ZETIME_MAX_HEARTRATE);
addPreferenceHandlerFor(ZeTimeConstants.PREF_ZETIME_MIN_HEARTRATE);
addPreferenceHandlerFor(ZeTimeConstants.PREF_USER_SLEEP_GOAL);
addPreferenceHandlerFor(ZeTimeConstants.PREF_USER_CALORIES_GOAL);
addPreferenceHandlerFor(ZeTimeConstants.PREF_USER_DISTANCE_GOAL);
addPreferenceHandlerFor(ZeTimeConstants.PREF_USER_ACTIVETIME_GOAL);
}
private void addPreferenceHandlerFor(final String preferenceKey) {
final Preference pref = findPreference(preferenceKey);
if (pref != null) {
pref.setOnPreferenceChangeListener((preference, newVal) -> {
notifyPreferenceChanged(preferenceKey);
return true;
});
}
}
/*
* delayed execution so that the preferences are applied first
*/
private void invokeLater(Runnable runnable) {
getListView().post(runnable);
}
/*
* delayed execution so that the preferences are applied first
*/
public void notifyPreferenceChanged(final String preferenceKey) {
invokeLater(() -> GBApplication.deviceService().onSendConfiguration(preferenceKey));
}
}
}

View File

@ -0,0 +1,111 @@
/* Copyright (C) 2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.zetime;
import android.os.Parcel;
import android.text.InputType;
import androidx.preference.Preference;
import java.util.Collections;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class ZeTimeSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
private final GBDevice device;
public ZeTimeSettingsCustomizer(final GBDevice device) {
this.device = device;
}
@Override
public void onPreferenceChange(final Preference preference, final DeviceSpecificSettingsHandler handler) {
}
@Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs, final String rootKey) {
if (rootKey == null) {
// Main screen - read the settings
GBApplication.deviceService(device).onReadConfiguration("do_it");
}
// Date time
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_DATE_FORMAT);
// Display
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_SCREENTIME);
handler.setInputTypeFor(ZeTimeConstants.PREF_SCREENTIME, InputType.TYPE_CLASS_NUMBER);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_ANALOG_MODE);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_HANDMOVE_DISPLAY);
// Vibration patterns
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_SMS_SIGNALING);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_CALENDAR_SIGNALING);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_CALL_SIGNALING);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_MISSED_CALL_SIGNALING);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_EMAIL_SIGNALING);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_SIGNALING);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_LOW_POWER_SIGNALING);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_SOCIAL_SIGNALING);
// Heart rate
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_ZETIME_HEARTRATE_ALARM);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_ZETIME_MAX_HEARTRATE);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_ZETIME_MIN_HEARTRATE);
handler.setInputTypeFor(ZeTimeConstants.PREF_ZETIME_MAX_HEARTRATE, InputType.TYPE_CLASS_NUMBER);
handler.setInputTypeFor(ZeTimeConstants.PREF_ZETIME_MIN_HEARTRATE, InputType.TYPE_CLASS_NUMBER);
// Activity info
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
handler.addPreferenceHandlerFor(ZeTimeConstants.PREF_CALORIES_TYPE);
}
@Override
public Set<String> getPreferenceKeysWithSummary() {
return Collections.emptySet();
}
public static final Creator<ZeTimeSettingsCustomizer> CREATOR = new Creator<ZeTimeSettingsCustomizer>() {
@Override
public ZeTimeSettingsCustomizer createFromParcel(final Parcel in) {
final GBDevice device = in.readParcelable(ZeTimeSettingsCustomizer.class.getClassLoader());
return new ZeTimeSettingsCustomizer(device);
}
@Override
public ZeTimeSettingsCustomizer[] newArray(final int size) {
return new ZeTimeSettingsCustomizer[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(final Parcel dest, final int flags) {
dest.writeParcelable(device, 0);
}
}

View File

@ -169,9 +169,9 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
case ZeTimeConstants.PREF_HANDMOVE_DISPLAY: case ZeTimeConstants.PREF_HANDMOVE_DISPLAY:
setDisplayOnMovement(builder); setDisplayOnMovement(builder);
break; break;
case DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB: case DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO:
case DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_START: case DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO_START:
case DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_END: case DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO_END:
setDoNotDisturb(builder); setDoNotDisturb(builder);
break; break;
case ZeTimeConstants.PREF_CALORIES_TYPE: case ZeTimeConstants.PREF_CALORIES_TYPE:
@ -216,10 +216,10 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
setHeartRateLimits(builder); setHeartRateLimits(builder);
break; break;
case DeviceSettingsPreferenceConst.PREF_USER_FITNESS_GOAL: case DeviceSettingsPreferenceConst.PREF_USER_FITNESS_GOAL:
case ZeTimeConstants.PREF_USER_SLEEP_GOAL: case ActivityUser.PREF_USER_SLEEP_DURATION:
case ZeTimeConstants.PREF_USER_CALORIES_GOAL: case ActivityUser.PREF_USER_CALORIES_BURNT:
case ZeTimeConstants.PREF_USER_DISTANCE_GOAL: case ActivityUser.PREF_USER_DISTANCE_METERS:
case ZeTimeConstants.PREF_USER_ACTIVETIME_GOAL: case ActivityUser.PREF_USER_ACTIVETIME_MINUTES:
setUserGoals(builder); setUserGoals(builder);
break; break;
} }
@ -282,7 +282,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
try { try {
TransactionBuilder builder = performInitialized("setAlarms"); TransactionBuilder builder = performInitialized("setAlarms");
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
for (Alarm alarm : alarms) { for (Alarm alarm : alarms) {
if (remindersOnWatch[alarm.getPosition()][0] == 0) { if (remindersOnWatch[alarm.getPosition()][0] == 0) {
@ -657,6 +657,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
int notification_length = body_length; int notification_length = body_length;
byte[] subject = null; byte[] subject = null;
byte[] notification; byte[] notification;
//noinspection ExtractMethodRecommender
Calendar time = GregorianCalendar.getInstance(); Calendar time = GregorianCalendar.getInstance();
// convert every single digit of the date to ascii characters // convert every single digit of the date to ascii characters
// we do it like so: use the base chrachter of '0' and add the digit // we do it like so: use the base chrachter of '0' and add the digit
@ -883,7 +884,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
return true; return true;
} }
} else { } else {
LOG.info("Unhandled characteristic changed: " + characteristicUUID); LOG.warn("Unhandled characteristic changed: {}", characteristicUUID);
logMessageContent(characteristic.getValue()); logMessageContent(characteristic.getValue());
} }
return false; return false;
@ -926,7 +927,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
} }
private ZeTimeDeviceSupport requestBatteryInfo(TransactionBuilder builder) { private void requestBatteryInfo(TransactionBuilder builder) {
LOG.debug("Requesting Battery Info!"); LOG.debug("Requesting Battery Info!");
builder.write(writeCharacteristic, new byte[]{ZeTimeConstants.CMD_PREAMBLE, builder.write(writeCharacteristic, new byte[]{ZeTimeConstants.CMD_PREAMBLE,
ZeTimeConstants.CMD_BATTERY_POWER, ZeTimeConstants.CMD_BATTERY_POWER,
@ -936,10 +937,9 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
0x00, 0x00,
ZeTimeConstants.CMD_END}); ZeTimeConstants.CMD_END});
builder.write(ackCharacteristic, new byte[]{ZeTimeConstants.CMD_ACK_WRITE}); builder.write(ackCharacteristic, new byte[]{ZeTimeConstants.CMD_ACK_WRITE});
return this;
} }
private ZeTimeDeviceSupport requestDeviceInfo(TransactionBuilder builder) { private void requestDeviceInfo(TransactionBuilder builder) {
LOG.debug("Requesting Device Info!"); LOG.debug("Requesting Device Info!");
builder.write(writeCharacteristic, new byte[]{ZeTimeConstants.CMD_PREAMBLE, builder.write(writeCharacteristic, new byte[]{ZeTimeConstants.CMD_PREAMBLE,
ZeTimeConstants.CMD_WATCH_ID, ZeTimeConstants.CMD_WATCH_ID,
@ -967,10 +967,9 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
0x02, 0x02,
ZeTimeConstants.CMD_END}); ZeTimeConstants.CMD_END});
builder.write(ackCharacteristic, new byte[]{ZeTimeConstants.CMD_ACK_WRITE}); builder.write(ackCharacteristic, new byte[]{ZeTimeConstants.CMD_ACK_WRITE});
return this;
} }
private ZeTimeDeviceSupport requestActivityInfo(TransactionBuilder builder) { private void requestActivityInfo(TransactionBuilder builder) {
builder.write(writeCharacteristic, new byte[]{ZeTimeConstants.CMD_PREAMBLE, builder.write(writeCharacteristic, new byte[]{ZeTimeConstants.CMD_PREAMBLE,
ZeTimeConstants.CMD_AVAIABLE_DATA, ZeTimeConstants.CMD_AVAIABLE_DATA,
ZeTimeConstants.CMD_REQUEST, ZeTimeConstants.CMD_REQUEST,
@ -979,7 +978,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
0x00, 0x00,
ZeTimeConstants.CMD_END}); ZeTimeConstants.CMD_END});
builder.write(ackCharacteristic, new byte[]{ZeTimeConstants.CMD_ACK_WRITE}); builder.write(ackCharacteristic, new byte[]{ZeTimeConstants.CMD_ACK_WRITE});
return this;
} }
private ZeTimeDeviceSupport requestShockStrength(TransactionBuilder builder) { private ZeTimeDeviceSupport requestShockStrength(TransactionBuilder builder) {
@ -1166,7 +1164,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
progressSteps = (msg[5] & 0xff) | ((msg[6] << 8) & 0xff00); progressSteps = (msg[5] & 0xff) | ((msg[6] << 8) & 0xff00);
GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), true, progressSteps * 100 / availableStepsData, getContext()); GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), true, progressSteps * 100 / availableStepsData, getContext());
if (progressSteps == availableStepsData) { if (progressSteps == availableStepsData) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
progressSteps = 0; progressSteps = 0;
availableStepsData = 0; availableStepsData = 0;
GB.updateTransferNotification(null, "", false, 100, getContext()); GB.updateTransferNotification(null, "", false, 100, getContext());
@ -1213,7 +1211,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
progressSleep = (msg[5] & 0xff) | (msg[6] << 8) & 0xff00; progressSleep = (msg[5] & 0xff) | (msg[6] << 8) & 0xff00;
GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), true, progressSleep * 100 / availableSleepData, getContext()); GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), true, progressSleep * 100 / availableSleepData, getContext());
if (progressSleep == availableSleepData) { if (progressSleep == availableSleepData) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
progressSleep = 0; progressSleep = 0;
availableSleepData = 0; availableSleepData = 0;
GB.updateTransferNotification(null, "", false, 100, getContext()); GB.updateTransferNotification(null, "", false, 100, getContext());
@ -1272,7 +1270,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
if (progressHeartRate == availableHeartRateData) { if (progressHeartRate == availableHeartRateData) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
progressHeartRate = 0; progressHeartRate = 0;
availableHeartRateData = 0; availableHeartRateData = 0;
GB.updateTransferNotification(null, "", false, 100, getContext()); GB.updateTransferNotification(null, "", false, 100, getContext());
@ -1446,7 +1444,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void setScreenTime(TransactionBuilder builder) { private void setScreenTime(TransactionBuilder builder) {
int value = GBApplication.getPrefs().getInt(ZeTimeConstants.PREF_SCREENTIME, 30); int value = getDevicePrefs().getInt(ZeTimeConstants.PREF_SCREENTIME, 30);
if (value > ZeTimeConstants.MAX_SCREEN_ON_TIME) { if (value > ZeTimeConstants.MAX_SCREEN_ON_TIME) {
GB.toast(getContext(), "Value for screen on time is greater than 18h! ", Toast.LENGTH_LONG, GB.ERROR); GB.toast(getContext(), "Value for screen on time is greater than 18h! ", Toast.LENGTH_LONG, GB.ERROR);
value = ZeTimeConstants.MAX_SCREEN_ON_TIME; value = ZeTimeConstants.MAX_SCREEN_ON_TIME;
@ -1552,7 +1550,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void setHeartRateLimits(TransactionBuilder builder) { private void setHeartRateLimits(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
boolean alarmEnabled = prefs.getBoolean(ZeTimeConstants.PREF_ZETIME_HEARTRATE_ALARM, false); boolean alarmEnabled = prefs.getBoolean(ZeTimeConstants.PREF_ZETIME_HEARTRATE_ALARM, false);
int maxHR = prefs.getInt(ZeTimeConstants.PREF_ZETIME_MAX_HEARTRATE, 180); int maxHR = prefs.getInt(ZeTimeConstants.PREF_ZETIME_MAX_HEARTRATE, 180);
@ -1582,7 +1580,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void setAnalogMode(TransactionBuilder builder) { private void setAnalogMode(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
int mode = prefs.getInt(ZeTimeConstants.PREF_ANALOG_MODE, 0); int mode = prefs.getInt(ZeTimeConstants.PREF_ANALOG_MODE, 0);
byte[] analog = {ZeTimeConstants.CMD_PREAMBLE, byte[] analog = {ZeTimeConstants.CMD_PREAMBLE,
@ -1597,7 +1595,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void setActivityTracking(TransactionBuilder builder) { private void setActivityTracking(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
boolean tracking = prefs.getBoolean(ZeTimeConstants.PREF_ACTIVITY_TRACKING, false); boolean tracking = prefs.getBoolean(ZeTimeConstants.PREF_ACTIVITY_TRACKING, false);
byte[] activity = {ZeTimeConstants.CMD_PREAMBLE, byte[] activity = {ZeTimeConstants.CMD_PREAMBLE,
@ -1614,7 +1612,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void setDisplayOnMovement(TransactionBuilder builder) { private void setDisplayOnMovement(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
boolean movement = prefs.getBoolean(ZeTimeConstants.PREF_HANDMOVE_DISPLAY, false); boolean movement = prefs.getBoolean(ZeTimeConstants.PREF_HANDMOVE_DISPLAY, false);
byte[] handmove = {ZeTimeConstants.CMD_PREAMBLE, byte[] handmove = {ZeTimeConstants.CMD_PREAMBLE,
@ -1633,11 +1631,11 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void setDoNotDisturb(TransactionBuilder builder) { private void setDoNotDisturb(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
String scheduled = prefs.getString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB, "off"); String scheduled = prefs.getString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO, "off");
String dndScheduled = getContext().getString(R.string.p_scheduled); String dndScheduled = getContext().getString(R.string.p_scheduled);
String start = prefs.getString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_START, "22:00"); String start = prefs.getString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO_START, "22:00");
String end = prefs.getString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_END, "07:00"); String end = prefs.getString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO_END, "07:00");
DateFormat df_start = new SimpleDateFormat("HH:mm"); DateFormat df_start = new SimpleDateFormat("HH:mm");
DateFormat df_end = new SimpleDateFormat("HH:mm"); DateFormat df_end = new SimpleDateFormat("HH:mm");
Calendar calendar = GregorianCalendar.getInstance(); Calendar calendar = GregorianCalendar.getInstance();
@ -1673,7 +1671,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void setCaloriesType(TransactionBuilder builder) { private void setCaloriesType(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
int type = prefs.getInt(ZeTimeConstants.PREF_CALORIES_TYPE, 0); int type = prefs.getInt(ZeTimeConstants.PREF_CALORIES_TYPE, 0);
byte[] calories = {ZeTimeConstants.CMD_PREAMBLE, byte[] calories = {ZeTimeConstants.CMD_PREAMBLE,
@ -1715,7 +1713,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void setDateFormate(TransactionBuilder builder) { private void setDateFormate(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
int type = prefs.getInt(ZeTimeConstants.PREF_DATE_FORMAT, 0); int type = prefs.getInt(ZeTimeConstants.PREF_DATE_FORMAT, 0);
byte[] dateformat = {ZeTimeConstants.CMD_PREAMBLE, byte[] dateformat = {ZeTimeConstants.CMD_PREAMBLE,
@ -1737,7 +1735,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void setInactivityAlert(TransactionBuilder builder) { private void setInactivityAlert(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
boolean enabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE, false); boolean enabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_INACTIVITY_ENABLE, false);
int threshold = prefs.getInt(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, 60); int threshold = prefs.getInt(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, 60);
@ -1803,7 +1801,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void setShockStrength(TransactionBuilder builder) { private void setShockStrength(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
int shockStrength = prefs.getInt(ZeTimeConstants.PREF_SHOCK_STRENGTH, 255); int shockStrength = prefs.getInt(ZeTimeConstants.PREF_SHOCK_STRENGTH, 255);
byte[] strength = { byte[] strength = {
@ -1819,51 +1817,67 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
sendMsgToWatch(builder, strength); sendMsgToWatch(builder, strength);
} }
private void setSignaling(TransactionBuilder builder, String signalingType) { private void setSignaling(final TransactionBuilder builder, final String signalingType) {
Prefs prefs = GBApplication.getPrefs(); final Prefs prefs = getDevicePrefs();
int signalType = prefs.getInt(signalingType, 0);
byte[] signaling = { final byte typeByte;
final int signalTypeDefault;
switch (signalingType) {
case ZeTimeConstants.PREF_SMS_SIGNALING:
typeByte = ZeTimeConstants.SMS_TYPE;
signalTypeDefault = 2;
break;
case ZeTimeConstants.PREF_CALL_SIGNALING:
typeByte = ZeTimeConstants.CALL_TYPE;
signalTypeDefault = 13;
break;
case ZeTimeConstants.PREF_MISSED_CALL_SIGNALING:
typeByte = ZeTimeConstants.MISSED_CALL_TYPE;
signalTypeDefault = 12;
break;
case ZeTimeConstants.PREF_EMAIL_SIGNALING:
typeByte = ZeTimeConstants.EMAIL_TYPE;
signalTypeDefault = 12;
break;
case ZeTimeConstants.PREF_SOCIAL_SIGNALING:
typeByte = ZeTimeConstants.SOCIAL_TYPE;
signalTypeDefault = 12;
break;
case ZeTimeConstants.PREF_CALENDAR_SIGNALING:
typeByte = ZeTimeConstants.CALENDAR_TYPE;
signalTypeDefault = 12;
break;
case ZeTimeConstants.PREF_INACTIVITY_SIGNALING:
typeByte = ZeTimeConstants.INACTIVITY_TYPE;
signalTypeDefault = 12;
break;
case ZeTimeConstants.PREF_LOW_POWER_SIGNALING:
typeByte = ZeTimeConstants.LOW_POWER_TYPE;
signalTypeDefault = 4;
break;
case ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING:
typeByte = ZeTimeConstants.ANTI_LOSS_TYPE;
signalTypeDefault = 13;
break;
default:
LOG.error("Unknown signaling type {}", signalingType);
return;
}
final int signalType = prefs.getInt(signalingType, signalTypeDefault);
final byte[] signaling = {
ZeTimeConstants.CMD_PREAMBLE, ZeTimeConstants.CMD_PREAMBLE,
ZeTimeConstants.CMD_SHOCK_MODE, ZeTimeConstants.CMD_SHOCK_MODE,
ZeTimeConstants.CMD_SEND, ZeTimeConstants.CMD_SEND,
(byte) 0x2, (byte) 0x2,
(byte) 0x0, (byte) 0x0,
(byte) 0x0, typeByte,
(byte) signalType, (byte) signalType,
ZeTimeConstants.CMD_END ZeTimeConstants.CMD_END
}; };
switch (signalingType) {
case ZeTimeConstants.PREF_SMS_SIGNALING:
signaling[5] = ZeTimeConstants.SMS_TYPE;
break;
case ZeTimeConstants.PREF_CALL_SIGNALING:
signaling[5] = ZeTimeConstants.CALL_TYPE;
break;
case ZeTimeConstants.PREF_MISSED_CALL_SIGNALING:
signaling[5] = ZeTimeConstants.MISSED_CALL_TYPE;
break;
case ZeTimeConstants.PREF_EMAIL_SIGNALING:
signaling[5] = ZeTimeConstants.EMAIL_TYPE;
break;
case ZeTimeConstants.PREF_SOCIAL_SIGNALING:
signaling[5] = ZeTimeConstants.SOCIAL_TYPE;
break;
case ZeTimeConstants.PREF_CALENDAR_SIGNALING:
signaling[5] = ZeTimeConstants.CALENDAR_TYPE;
break;
case ZeTimeConstants.PREF_INACTIVITY_SIGNALING:
signaling[5] = ZeTimeConstants.INACTIVITY_TYPE;
break;
case ZeTimeConstants.PREF_LOW_POWER_SIGNALING:
signaling[5] = ZeTimeConstants.LOW_POWER_TYPE;
break;
case ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING:
signaling[5] = ZeTimeConstants.ANTI_LOSS_TYPE;
break;
}
sendMsgToWatch(builder, signaling); sendMsgToWatch(builder, signaling);
} }
@ -1970,24 +1984,21 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void getDateTimeFormat(byte[] msg) { private void getDateTimeFormat(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); SharedPreferences.Editor prefs = getDevicePrefs().getPreferences().edit();
prefs.putString(ZeTimeConstants.PREF_DATE_FORMAT, Integer.toString(msg[5])); prefs.putString(ZeTimeConstants.PREF_DATE_FORMAT, Integer.toString(msg[5]));
prefs.apply();
String timeFormat = "24h"; String timeFormat = "24h";
SharedPreferences.Editor prefsEditor = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).edit();
if (msg[6] == 2) { if (msg[6] == 2) {
timeFormat = "am/pm"; timeFormat = "am/pm";
} }
prefsEditor.putString(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, timeFormat); prefs.putString(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, timeFormat);
prefsEditor.apply();
prefs.apply();
} }
private void getSignaling(byte[] msg) { private void getSignaling(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); SharedPreferences.Editor prefs = getDevicePrefs().getPreferences().edit();
prefs.putString(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING, Integer.toString(msg[5])); prefs.putString(ZeTimeConstants.PREF_ANTI_LOSS_SIGNALING, Integer.toString(msg[5]));
prefs.putString(ZeTimeConstants.PREF_CALL_SIGNALING, Integer.toString(msg[7])); prefs.putString(ZeTimeConstants.PREF_CALL_SIGNALING, Integer.toString(msg[7]));
@ -2002,40 +2013,36 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void getDoNotDisturb(byte[] msg) { private void getDoNotDisturb(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); SharedPreferences.Editor prefs = getDevicePrefs().getPreferences().edit();
String starttime = String.format("%02d:%02d", msg[6], msg[7]); String starttime = String.format("%02d:%02d", msg[6], msg[7]);
String endtime = String.format("%02d:%02d", msg[8], msg[9]); String endtime = String.format("%02d:%02d", msg[8], msg[9]);
if (0x1 == msg[5]) { if (0x1 == msg[5]) {
prefs.putString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB, "scheduled"); prefs.putString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO, "scheduled");
} else { } else {
prefs.putString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB, "off"); prefs.putString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO, "off");
} }
prefs.putString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_START, starttime); prefs.putString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO_START, starttime);
prefs.putString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_END, endtime); prefs.putString(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO_END, endtime);
prefs.apply(); prefs.apply();
} }
private void getAnalogMode(byte[] msg) { private void getAnalogMode(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); SharedPreferences.Editor prefs = getDevicePrefs().getPreferences().edit();
prefs.putString(ZeTimeConstants.PREF_ANALOG_MODE, Integer.toString(msg[5])); prefs.putString(ZeTimeConstants.PREF_ANALOG_MODE, Integer.toString(msg[5]));
prefs.apply(); prefs.apply();
} }
private void getActivityTracking(byte[] msg) { private void getActivityTracking(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); SharedPreferences.Editor prefs = getDevicePrefs().getPreferences().edit();
if (0x1 == msg[6]) { prefs.putBoolean(ZeTimeConstants.PREF_ACTIVITY_TRACKING, 0x1 != msg[6]);
prefs.putBoolean(ZeTimeConstants.PREF_ACTIVITY_TRACKING, false);
} else {
prefs.putBoolean(ZeTimeConstants.PREF_ACTIVITY_TRACKING, true);
}
prefs.apply(); prefs.apply();
} }
private void getScreenTime(byte[] msg) { private void getScreenTime(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); SharedPreferences.Editor prefs = getDevicePrefs().getPreferences().edit();
prefs.putString(ZeTimeConstants.PREF_SCREENTIME, Integer.toString((msg[5] | (msg[6] << 8)))); prefs.putString(ZeTimeConstants.PREF_SCREENTIME, Integer.toString((msg[5] | (msg[6] << 8))));
prefs.apply(); prefs.apply();
@ -2053,18 +2060,18 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void getHeartRateMeasurement(byte[] msg) { private void getHeartRateMeasurement(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); SharedPreferences.Editor prefs = getDevicePrefs().getPreferences().edit();
prefs.putString(ZeTimeConstants.PREF_ZETIME_HEARTRATE_INTERVAL, Integer.toString((msg[5] * 60))); // multiply with 60 because of the conversion from minutes to seconds prefs.putString(ZeTimeConstants.PREF_ZETIME_HEARTRATE_INTERVAL, Integer.toString((msg[5] * 60))); // multiply with 60 because of the conversion from minutes to seconds
prefs.apply(); prefs.apply();
} }
private void getHeartRateLimits(byte[] msg) { private void getHeartRateLimits(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); SharedPreferences.Editor prefs = getDevicePrefs().getPreferences().edit();
prefs.apply(); prefs.apply();
} }
private void getInactivityAlert(byte[] msg) { private void getInactivityAlert(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); SharedPreferences.Editor prefs = getDevicePrefs().getPreferences().edit();
String starttime = String.format("%02d:%02d", msg[7], msg[8]); String starttime = String.format("%02d:%02d", msg[7], msg[8]);
String endtime = String.format("%02d:%02d", msg[9], msg[10]); String endtime = String.format("%02d:%02d", msg[9], msg[10]);
@ -2113,7 +2120,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void getCaloriesType(byte[] msg) { private void getCaloriesType(byte[] msg) {
SharedPreferences prefs = GBApplication.getPrefs().getPreferences(); SharedPreferences prefs = getDevicePrefs().getPreferences();
SharedPreferences.Editor myedit = prefs.edit(); SharedPreferences.Editor myedit = prefs.edit();
myedit.putString(ZeTimeConstants.PREF_CALORIES_TYPE, Integer.toString(msg[5])); myedit.putString(ZeTimeConstants.PREF_CALORIES_TYPE, Integer.toString(msg[5]));
@ -2121,7 +2128,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
} }
private void getDisplayOnMovement(byte[] msg) { private void getDisplayOnMovement(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit(); SharedPreferences.Editor prefs = getDevicePrefs().getPreferences().edit();
if (0 != (msg[6] & (1 << 6))) { if (0 != (msg[6] & (1 << 6))) {
prefs.putBoolean(ZeTimeConstants.PREF_HANDMOVE_DISPLAY, true); prefs.putBoolean(ZeTimeConstants.PREF_HANDMOVE_DISPLAY, true);
} else { } else {

View File

@ -2555,52 +2555,6 @@
<item>ru_RU</item> <item>ru_RU</item>
</string-array> </string-array>
<string-array name="pref_zetime_language">
<item name="auto">@string/automatic</item>
<item name="zh_CN">@string/simplified_chinese</item>
<item name="zh_TW">@string/traditional_chinese</item>
<item name="en_US">@string/english</item>
<item name="es_ES">@string/spanish</item>
<item name="de_DE">@string/german</item>
<item name="it_IT">@string/italian</item>
<item name="fr_FR">@string/french</item>
<item name="pt_PT">@string/portuguese</item>
<item name="nl_NL">@string/dutch</item>
<item name="sv_SE">@string/swedish</item>
<item name="pl_PL">@string/polish</item>
<item name="cs_CZ">@string/czesh</item>
<item name="el_GR">@string/greek</item>
<item name="ru_RU">@string/russian</item>
<item name="he_IL">@string/hebrew</item>
<item name="ar_SA">@string/arabic</item>
<item name="ja_JP">@string/japanese</item>
<item name="ko_KO">@string/korean</item>
<item name="th_TH">@string/thai</item>
</string-array>
<string-array name="pref_zetime_language_values">
<item>auto</item>
<item>zh_CN</item>
<item>zh_TW</item>
<item>en_US</item>
<item>es_ES</item>
<item>de_DE</item>
<item>it_IT</item>
<item>fr_FR</item>
<item>pt_PT</item>
<item>nl_NL</item>
<item>sv_SE</item>
<item>pl_PL</item>
<item>cs_CZ</item>
<item>el_GR</item>
<item>ru_RU</item>
<item>he_IL</item>
<item>ar_SA</item>
<item>ja_JP</item>
<item>ko_KO</item>
<item>th_TH</item>
</string-array>
<string-array name="prefs_heartrate_measurement_interval"> <string-array name="prefs_heartrate_measurement_interval">
<!-- This will be filled dynamically by HeartRateCapability --> <!-- This will be filled dynamically by HeartRateCapability -->
<item name="0">@string/off</item> <item name="0">@string/off</item>

View File

@ -7,9 +7,6 @@
android:summary="@string/mi2_prefs_do_not_disturb_summary" android:summary="@string/mi2_prefs_do_not_disturb_summary"
android:title="@string/mi2_prefs_do_not_disturb"> android:title="@string/mi2_prefs_do_not_disturb">
<!-- workaround for missing toolbar -->
<PreferenceCategory android:title="@string/mi2_prefs_do_not_disturb" />
<ListPreference <ListPreference
android:defaultValue="@string/p_off" android:defaultValue="@string/p_off"
android:entries="@array/do_not_disturb_no_auto" android:entries="@array/do_not_disturb_no_auto"

View File

@ -1,11 +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="auto"
android:entries="@array/pref_zetime_language"
android:entryValues="@array/pref_zetime_language_values"
android:key="language"
android:summary="%s"
android:title="@string/pref_title_language" />
</androidx.preference.PreferenceScreen>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="zetime_activity_tracking"
android:layout="@layout/preference_checkbox"
android:summary="@string/zetime_activity_tracking_summary"
android:title="@string/zetime_activity_tracking"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="0"
android:entries="@array/zetime_calories_type"
android:entryValues="@array/zetime_calories_type_values"
android:key="zetime_calories_type"
android:title="@string/zetime_calories_type"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ListPreference
android:defaultValue="2"
android:entries="@array/zetime_date_format"
android:entryValues="@array/zetime_date_format_values"
android:icon="@drawable/ic_access_time"
android:key="zetime_date_format"
android:title="@string/zetime_date_format"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<EditTextPreference
android:defaultValue="30"
android:inputType="number"
android:key="zetime_screentime"
android:maxLength="5"
android:title="@string/zetime_title_screentime"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="zetime_handmove_display"
android:layout="@layout/preference_checkbox"
android:summary="@string/zetime_handmove_display_summary"
android:title="@string/zetime_handmove_display"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="0"
android:entries="@array/zetime_analog_mode"
android:entryValues="@array/zetime_analog_mode_values"
android:key="zetime_analog_mode"
android:title="@string/zetime_analog_mode"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>

View File

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ListPreference
android:defaultValue="0"
android:entries="@array/prefs_zetime_heartrate_measurement_interval"
android:entryValues="@array/prefs_zetime_heartrate_measurement_interval_values"
android:icon="@drawable/ic_heart"
android:key="heartrate_measurement_interval"
android:title="@string/prefs_title_heartrate_measurement_interval"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<PreferenceScreen
android:icon="@drawable/ic_heartrate"
android:key="zetime_heartrate_alarm_key"
android:persistent="false"
android:summary="@string/zetime_title_heart_rate_alarm_summary"
android:title="@string/zetime_title_heart_rate_alarm"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="zetime_heartrate_alarm_enable"
android:layout="@layout/preference_checkbox"
android:summary="@string/zetime_title_heart_rate_alarm_summary"
android:title="@string/zetime_title_heart_rate_alarm"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue="180"
android:dependency="zetime_heartrate_alarm_enable"
android:inputType="number"
android:key="alarm_max_heart_rate"
android:maxLength="3"
android:title="@string/activity_prefs_alarm_max_heart_rate"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:defaultValue="60"
android:dependency="zetime_heartrate_alarm_enable"
android:inputType="number"
android:key="alarm_min_heart_rate"
android:maxLength="3"
android:title="@string/activity_prefs_alarm_min_heart_rate"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>
<PreferenceScreen
android:icon="@drawable/ic_chair"
android:key="inactivity_warnings_key"
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
android:title="@string/mi2_prefs_inactivity_warnings"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_enable"
android:layout="@layout/preference_checkbox"
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
android:title="@string/mi2_prefs_inactivity_warnings"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue="60"
android:dependency="inactivity_warnings_enable"
android:inputType="numberSigned"
android:key="inactivity_warnings_threshold"
android:maxLength="3"
android:title="@string/mi2_prefs_inactivity_warnings_threshold"
app:iconSpaceReserved="false" />
<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"
app:iconSpaceReserved="false" />
<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"
app:iconSpaceReserved="false" />
<PreferenceCategory
android:dependency="inactivity_warnings_enable"
android:title="@string/zetime_prefs_inactivity_repetitions"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_mo"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_mo"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_tu"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_tu"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_we"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_we"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_th"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_th"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_fr"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_fr"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_sa"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_sa"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_su"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_su"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceScreen>

View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen
android:icon="@drawable/ic_vibration"
android:key="vibration_patterns_key"
android:persistent="false"
android:summary="@string/pref_screen_vibration_patterns_summary"
android:title="@string/pref_screen_vibration_patterns_title">
<ListPreference
android:defaultValue="2"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:icon="@drawable/ic_message_outline"
android:key="zetime_vibration_profile_sms"
android:title="@string/pref_screen_notification_profile_sms"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:defaultValue="13"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:icon="@drawable/ic_phone"
android:key="zetime_vibration_profile_incoming_call"
android:title="@string/pref_screen_notification_profile_incoming_call"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:defaultValue="12"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:icon="@drawable/ic_phone_missed_outline"
android:key="zetime_vibration_profile_missed_call"
android:title="@string/pref_screen_notification_profile_missed_call"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:defaultValue="12"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:icon="@drawable/ic_email"
android:key="zetime_vibration_profile_generic_email"
android:title="@string/pref_screen_notification_profile_email"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:icon="@drawable/ic_person"
android:defaultValue="12"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_generic_social"
android:title="@string/pref_screen_notification_profile_generic_social"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:icon="@drawable/ic_access_alarms"
android:defaultValue="11"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_alarm_signaling"
android:title="@string/pref_screen_notification_profile_alarm_clock"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:icon="@drawable/ic_calendar_to"
android:defaultValue="12"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_calendar"
android:title="@string/pref_screen_notification_profile_calendar"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:icon="@drawable/ic_chair"
android:defaultValue="12"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_inactivity"
android:title="@string/pref_screen_notification_profile_inactivity"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:icon="@drawable/ic_battery"
android:defaultValue="4"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_lowpower"
android:title="@string/pref_screen_notification_profile_low_power"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:icon="@drawable/ic_signal_cellular_connected_no_internet_4_bar"
android:defaultValue="13"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_antiloss"
android:title="@string/pref_screen_notification_profile_anti_loss"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>
</PreferenceScreen>

View File

@ -275,10 +275,7 @@
android:key="pref_key_pebble" android:key="pref_key_pebble"
android:title="@string/pref_title_pebble_settings"> android:title="@string/pref_title_pebble_settings">
</Preference> </Preference>
<Preference
android:icon="@drawable/ic_device_zetime"
android:key="pref_key_zetime"
android:title="@string/zetime_title_settings" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory

View File

@ -1,560 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="pref_category_zetime_general"
android:title="@string/pref_header_general"
app:iconSpaceReserved="false">
<EditTextPreference
android:defaultValue="30"
android:inputType="number"
android:key="zetime_screentime"
android:maxLength="5"
android:title="@string/zetime_title_screentime"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="zetime_activity_tracking"
android:layout="@layout/preference_checkbox"
android:summary="@string/zetime_activity_tracking_summary"
android:title="@string/zetime_activity_tracking"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue="10000"
android:inputType="number"
android:key="fitness_goal"
android:maxLength="5"
android:title="@string/miband_prefs_fitness_goal"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:inputType="number"
android:key="activity_user_sleep_duration"
android:maxLength="2"
android:title="@string/activity_prefs_sleep_duration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:defaultValue="2000"
android:inputType="number"
android:key="activity_user_calories_burnt"
android:maxLength="4"
android:title="@string/activity_prefs_calories_burnt"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:defaultValue="5"
android:inputType="number"
android:key="activity_user_distance_meters"
android:maxLength="5"
android:title="@string/activity_prefs_distance_meters"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:defaultValue="60"
android:inputType="number"
android:key="activity_user_activetime_minutes"
android:maxLength="3"
android:title="@string/activity_prefs_activetime_minutes"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<PreferenceScreen
android:key="inactivity_warnings_key"
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
android:title="@string/mi2_prefs_inactivity_warnings"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/mi2_prefs_inactivity_warnings"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_enable"
android:layout="@layout/preference_checkbox"
android:summary="@string/mi2_prefs_inactivity_warnings_summary"
android:title="@string/mi2_prefs_inactivity_warnings"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue="60"
android:dependency="inactivity_warnings_enable"
android:inputType="numberSigned"
android:key="inactivity_warnings_threshold"
android:maxLength="3"
android:title="@string/mi2_prefs_inactivity_warnings_threshold"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<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"
app:iconSpaceReserved="false" />
<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"
app:iconSpaceReserved="false" />
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:dependency="inactivity_warnings_enable"
android:title="@string/zetime_prefs_inactivity_repetitions"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_mo"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_mo"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_tu"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_tu"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_we"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_we"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_th"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_th"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_fr"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_fr"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_sa"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_sa"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="inactivity_warnings_su"
android:layout="@layout/preference_checkbox"
android:title="@string/zetime_prefs_inactivity_su"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>
<ListPreference
android:defaultValue="0"
android:entries="@array/zetime_calories_type"
android:entryValues="@array/zetime_calories_type_values"
android:key="zetime_calories_type"
android:title="@string/zetime_calories_type"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="zetime_handmove_display"
android:layout="@layout/preference_checkbox"
android:summary="@string/zetime_handmove_display_summary"
android:title="@string/zetime_handmove_display"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="0"
android:entries="@array/zetime_analog_mode"
android:entryValues="@array/zetime_analog_mode_values"
android:key="zetime_analog_mode"
android:title="@string/zetime_analog_mode"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:defaultValue="2"
android:entries="@array/zetime_date_format"
android:entryValues="@array/zetime_date_format_values"
android:key="zetime_date_format"
android:title="@string/zetime_date_format"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="zetime_dont_del_actdata"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_keep_data_on_device"
android:title="@string/pref_title_keep_data_on_device"
app:iconSpaceReserved="false" />
<PreferenceScreen
android:key="zetime_do_not_disturb_key"
android:persistent="false"
android:summary="@string/mi2_prefs_do_not_disturb_summary"
android:title="@string/mi2_prefs_do_not_disturb"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/mi2_prefs_do_not_disturb"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="@string/p_off"
android:entries="@array/zetime_do_not_disturb"
android:entryValues="@array/zetime_do_not_disturb_values"
android:key="do_not_disturb"
android:title="@string/mi2_prefs_do_not_disturb"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
android:defaultValue="22:00"
android:key="do_not_disturb_start"
android:title="@string/mi2_prefs_do_not_disturb_start"
app:iconSpaceReserved="false" />
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
android:defaultValue="07:00"
android:key="do_not_disturb_end"
android:title="@string/mi2_prefs_do_not_disturb_end"
app:iconSpaceReserved="false" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:key="pref_category_zetime_heartrate"
android:title="@string/zetime_title_heartrate"
app:iconSpaceReserved="false">
<ListPreference
android:defaultValue="0"
android:entries="@array/prefs_zetime_heartrate_measurement_interval"
android:entryValues="@array/prefs_zetime_heartrate_measurement_interval_values"
android:key="heartrate_measurement_interval"
android:title="@string/prefs_title_heartrate_measurement_interval"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<PreferenceScreen
android:key="zetime_heartrate_alarm_key"
android:persistent="false"
android:summary="@string/zetime_title_heart_rate_alarm_summary"
android:title="@string/zetime_title_heart_rate_alarm"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/zetime_title_heart_rate_alarm"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="zetime_heartrate_alarm_enable"
android:layout="@layout/preference_checkbox"
android:summary="@string/zetime_title_heart_rate_alarm_summary"
android:title="@string/zetime_heart_rate_alarm_enable"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue="180"
android:dependency="zetime_heartrate_alarm_enable"
android:inputType="number"
android:key="alarm_max_heart_rate"
android:maxLength="3"
android:title="@string/activity_prefs_alarm_max_heart_rate"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:defaultValue="60"
android:dependency="zetime_heartrate_alarm_enable"
android:inputType="number"
android:key="alarm_min_heart_rate"
android:maxLength="3"
android:title="@string/activity_prefs_alarm_min_heart_rate"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:key="pref_category_miband_notification"
android:title="@string/pref_header_vibration_settings"
app:iconSpaceReserved="false">
<PreferenceScreen
android:key="vibration_profile_key_sms"
android:persistent="false"
android:title="@string/pref_screen_notification_profile_sms"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_sms"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="2"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_sms"
android:title="@string/miband_prefs_vibration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<Preference
android:key="zetime_try_generic_sms"
android:persistent="false"
android:title="@string/vibration_try"
app:iconSpaceReserved="false" />
</PreferenceScreen>
<PreferenceScreen
android:key="vibration_profile_key_incoming_call"
android:persistent="false"
android:title="@string/pref_screen_notification_profile_incoming_call"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_incoming_call"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="13"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_incoming_call"
android:title="@string/miband_prefs_vibration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>
<PreferenceScreen
android:key="vibration_profile_key_missed_call"
android:persistent="false"
android:title="@string/pref_screen_notification_profile_missed_call"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_missed_call"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="12"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_missed_call"
android:title="@string/miband_prefs_vibration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>
<PreferenceScreen
android:key="vibration_profile_key_generic_email"
android:persistent="false"
android:title="@string/pref_screen_notification_profile_email"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_email"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="12"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_generic_email"
android:title="@string/miband_prefs_vibration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<Preference
android:key="zetime_try_generic_email"
android:persistent="false"
android:title="@string/vibration_try"
app:iconSpaceReserved="false" />
</PreferenceScreen>
<PreferenceScreen
android:key="vibration_profile_key_generic_social"
android:persistent="false"
android:title="@string/pref_screen_notification_profile_generic_social"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_generic_social"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="12"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_generic_social"
android:title="@string/miband_prefs_vibration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<Preference
android:key="zetime_try_generic_social"
android:persistent="false"
android:title="@string/vibration_try"
app:iconSpaceReserved="false" />
</PreferenceScreen>
<PreferenceScreen
android:key="vibration_profile_key_alarm"
android:persistent="false"
android:title="@string/pref_screen_notification_profile_alarm_clock"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_alarm_clock"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="11"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_alarm_signaling"
android:title="@string/miband_prefs_vibration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<Preference
android:key="zetime_try_generic_alarm_clock"
android:persistent="false"
android:title="@string/vibration_try"
app:iconSpaceReserved="false" />
</PreferenceScreen>
<PreferenceScreen
android:key="vibration_profile_key_calendar"
android:persistent="false"
android:title="@string/pref_screen_notification_profile_calendar"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_calendar"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="12"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_calendar"
android:title="@string/miband_prefs_vibration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<Preference
android:key="zetime_try_calendar"
android:persistent="false"
android:title="@string/vibration_try"
app:iconSpaceReserved="false" />
</PreferenceScreen>
<PreferenceScreen
android:key="vibration_profile_key_inactivity"
android:persistent="false"
android:title="@string/pref_screen_notification_profile_inactivity"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_inactivity"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="12"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_inactivity"
android:title="@string/miband_prefs_vibration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<Preference
android:key="zetime_try_inactivity"
android:persistent="false"
android:title="@string/vibration_try"
app:iconSpaceReserved="false" />
</PreferenceScreen>
<PreferenceScreen
android:key="vibration_profile_key_lowpower"
android:persistent="false"
android:title="@string/pref_screen_notification_profile_low_power"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_low_power"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="4"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_lowpower"
android:title="@string/miband_prefs_vibration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<Preference
android:key="zetime_try_lowpower"
android:persistent="false"
android:title="@string/vibration_try"
app:iconSpaceReserved="false" />
</PreferenceScreen>
<PreferenceScreen
android:key="vibration_profile_key_antiloss"
android:persistent="false"
android:title="@string/pref_screen_notification_profile_anti_loss"
app:iconSpaceReserved="false">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_anti_loss"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="13"
android:entries="@array/zetime_signaling_types"
android:entryValues="@array/zetime_signaling_types_values"
android:key="zetime_vibration_profile_antiloss"
android:title="@string/miband_prefs_vibration"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<Preference
android:key="zetime_try_antiloss"
android:persistent="false"
android:title="@string/vibration_try"
app:iconSpaceReserved="false" />
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>