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

Write heart rate alarm limits, when changed instead of on connect. - Missing reading of that preference.

This commit is contained in:
Sebastian Kranz 2019-02-21 09:19:05 +01:00
parent f898bf5050
commit e0399a056f
3 changed files with 85 additions and 2 deletions

View File

@ -174,6 +174,12 @@ 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_FITNESS_GOAL = "mi_fitness_goal";
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_kmeters";
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

@ -18,6 +18,9 @@ public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.zetime_preferences); addPreferencesFromResource(R.xml.zetime_preferences);
addPreferencesFromResource(R.xml.preferences);
GBApplication.deviceService().onReadConfiguration("do_it");
//addTryListeners(); //addTryListeners();
@ -358,7 +361,71 @@ public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
} }
}); });
GBApplication.deviceService().onReadConfiguration("do_it"); final Preference heartrateAlarm = findPreference(ZeTimeConstants.PREF_ZETIME_HEARTRATE_ALARM);
heartrateAlarm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ZETIME_HEARTRATE_ALARM);
return true;
}
});
final Preference heartrateAlarmMax = findPreference(ZeTimeConstants.PREF_ZETIME_MAX_HEARTRATE);
heartrateAlarmMax.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ZETIME_MAX_HEARTRATE);
return true;
}
});
final Preference heartrateAlarmMin = findPreference(ZeTimeConstants.PREF_ZETIME_MIN_HEARTRATE);
heartrateAlarmMin.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_ZETIME_MIN_HEARTRATE);
return true;
}
});
final Preference fitnessGoal = findPreference(ZeTimeConstants.PREF_USER_FITNESS_GOAL);
fitnessGoal.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_USER_FITNESS_GOAL);
return true;
}
});
final Preference sleepGoal = findPreference(ZeTimeConstants.PREF_USER_SLEEP_GOAL);
sleepGoal.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_USER_SLEEP_GOAL);
return true;
}
});
final Preference caloriesGoal = findPreference(ZeTimeConstants.PREF_USER_CALORIES_GOAL);
caloriesGoal.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_USER_CALORIES_GOAL);
return true;
}
});
final Preference distanceGoal = findPreference(ZeTimeConstants.PREF_USER_DISTANCE_GOAL);
distanceGoal.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_USER_DISTANCE_GOAL);
return true;
}
});
final Preference activeTimeGoal = findPreference(ZeTimeConstants.PREF_USER_ACTIVETIME_GOAL);
activeTimeGoal.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
GBApplication.deviceService().onSendConfiguration(ZeTimeConstants.PREF_USER_ACTIVETIME_GOAL);
return true;
}
});
} }
/** /**

View File

@ -129,7 +129,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
requestBatteryInfo(builder); requestBatteryInfo(builder);
setUserInfo(builder); setUserInfo(builder);
setUserGoals(builder); setUserGoals(builder);
setHeartRateLimits(builder);
requestActivityInfo(builder); requestActivityInfo(builder);
synchronizeTime(builder); synchronizeTime(builder);
initMusicVolume(builder); initMusicVolume(builder);
@ -188,6 +187,17 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
break; break;
case ZeTimeConstants.PREF_SHOCK_STRENGTH: case ZeTimeConstants.PREF_SHOCK_STRENGTH:
setShockStrength(builder); setShockStrength(builder);
case ZeTimeConstants.PREF_ZETIME_HEARTRATE_ALARM:
case ZeTimeConstants.PREF_ZETIME_MAX_HEARTRATE:
case ZeTimeConstants.PREF_ZETIME_MIN_HEARTRATE:
setHeartRateLimits(builder);
break;
case ZeTimeConstants.PREF_USER_FITNESS_GOAL:
case ZeTimeConstants.PREF_USER_SLEEP_GOAL:
case ZeTimeConstants.PREF_USER_CALORIES_GOAL:
case ZeTimeConstants.PREF_USER_DISTANCE_GOAL:
case ZeTimeConstants.PREF_USER_ACTIVETIME_GOAL:
setUserGoals(builder);
break; break;
} }
builder.queue(getQueue()); builder.queue(getQueue());