mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 13:26:50 +01:00
Activity Card: React to User settings. Unify step length
This commit is contained in:
parent
4398076ecc
commit
468a40c62e
@ -90,7 +90,7 @@ public class SleepAlarmWidget extends AppWidgetProvider {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
super.onReceive(context, intent);
|
super.onReceive(context, intent);
|
||||||
if (ACTION.equals(intent.getAction())) {
|
if (ACTION.equals(intent.getAction())) {
|
||||||
int userSleepDuration = new ActivityUser().getSleepDuration();
|
int userSleepDuration = new ActivityUser().getSleepDurationGoal();
|
||||||
// current timestamp
|
// current timestamp
|
||||||
GregorianCalendar calendar = new GregorianCalendar();
|
GregorianCalendar calendar = new GregorianCalendar();
|
||||||
// add preferred sleep duration
|
// add preferred sleep duration
|
||||||
|
@ -158,11 +158,11 @@ public class Widget extends AppWidgetProvider {
|
|||||||
int sleep = (int) dailyTotals[1];
|
int sleep = (int) dailyTotals[1];
|
||||||
ActivityUser activityUser = new ActivityUser();
|
ActivityUser activityUser = new ActivityUser();
|
||||||
int stepGoal = activityUser.getStepsGoal();
|
int stepGoal = activityUser.getStepsGoal();
|
||||||
int sleepGoal = activityUser.getSleepDuration();
|
int sleepGoal = activityUser.getSleepDurationGoal();
|
||||||
int sleepGoalMinutes = sleepGoal * 60;
|
int sleepGoalMinutes = sleepGoal * 60;
|
||||||
int distanceGoal = activityUser.getDistanceMeters() * 100;
|
int distanceGoal = activityUser.getDistanceGoalMeters() * 100;
|
||||||
int stepLength = activityUser.getStepLengthCm();
|
int stepLength = activityUser.getStepLengthCm();
|
||||||
double distanceMeters = dailyTotals[0] * stepLength / 100;
|
double distanceMeters = dailyTotals[0] * stepLength * 0.01;
|
||||||
double distanceFeet = distanceMeters * 3.28084f;
|
double distanceFeet = distanceMeters * 3.28084f;
|
||||||
double distanceFormatted = 0;
|
double distanceFormatted = 0;
|
||||||
|
|
||||||
|
@ -47,6 +47,12 @@ public class AboutUserPreferencesActivity extends AbstractSettingsActivity {
|
|||||||
addPreferenceHandlerFor(PREF_USER_WEIGHT_KG);
|
addPreferenceHandlerFor(PREF_USER_WEIGHT_KG);
|
||||||
addPreferenceHandlerFor(PREF_USER_GENDER);
|
addPreferenceHandlerFor(PREF_USER_GENDER);
|
||||||
addPreferenceHandlerFor(PREF_USER_STEPS_GOAL);
|
addPreferenceHandlerFor(PREF_USER_STEPS_GOAL);
|
||||||
|
|
||||||
|
addIntentNotificationListener(PREF_USER_STEPS_GOAL);
|
||||||
|
addIntentNotificationListener(PREF_USER_HEIGHT_CM);
|
||||||
|
addIntentNotificationListener(PREF_USER_SLEEP_DURATION);
|
||||||
|
addIntentNotificationListener(PREF_USER_STEP_LENGTH_CM);
|
||||||
|
addIntentNotificationListener(PREF_USER_DISTANCE_METERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -243,4 +244,26 @@ public abstract class AbstractSettingsActivity extends AppCompatPreferenceActivi
|
|||||||
LOG.warn("Could not find preference " + preferenceKey);
|
LOG.warn("Could not find preference " + preferenceKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that the Control center is re-rendered when user preferences change
|
||||||
|
protected void addIntentNotificationListener(final String preferenceKey) {
|
||||||
|
Preference pref = findPreference(preferenceKey);
|
||||||
|
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
|
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
|
||||||
|
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(refreshIntent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
LOG.warn("Could not find preference " + preferenceKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -514,8 +514,8 @@ public class ControlCenterv2 extends AppCompatActivity
|
|||||||
for (GBDevice gbDevice : deviceList) {
|
for (GBDevice gbDevice : deviceList) {
|
||||||
final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
|
final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
|
||||||
if (coordinator.supportsActivityTracking()) {
|
if (coordinator.supportsActivityTracking()) {
|
||||||
long[] steps = getSteps(gbDevice, db);
|
long[] stepsAndSleepData = getSteps(gbDevice, db);
|
||||||
deviceActivityHashMap.put(gbDevice.getAddress(), steps);
|
deviceActivityHashMap.put(gbDevice.getAddress(), stepsAndSleepData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public class WidgetAlarmsActivity extends Activity implements View.OnClickListen
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
setContentView(R.layout.widget_alarms_activity_list);
|
setContentView(R.layout.widget_alarms_activity_list);
|
||||||
int userSleepDuration = new ActivityUser().getSleepDuration();
|
int userSleepDuration = new ActivityUser().getSleepDurationGoal();
|
||||||
textView = findViewById(R.id.alarm5);
|
textView = findViewById(R.id.alarm5);
|
||||||
if (userSleepDuration > 0) {
|
if (userSleepDuration > 0) {
|
||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
@ -117,7 +117,7 @@ public class WidgetAlarmsActivity extends Activity implements View.OnClickListen
|
|||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
calendar.add(Calendar.MINUTE, duration);
|
calendar.add(Calendar.MINUTE, duration);
|
||||||
} else {
|
} else {
|
||||||
int userSleepDuration = new ActivityUser().getSleepDuration();
|
int userSleepDuration = new ActivityUser().getSleepDurationGoal();
|
||||||
// add preferred sleep duration
|
// add preferred sleep duration
|
||||||
if (userSleepDuration > 0) {
|
if (userSleepDuration > 0) {
|
||||||
calendar.add(Calendar.HOUR_OF_DAY, userSleepDuration);
|
calendar.add(Calendar.HOUR_OF_DAY, userSleepDuration);
|
||||||
|
@ -41,8 +41,8 @@ public class ActivityListingAdapter extends AbstractActivityListingAdapter<Activ
|
|||||||
private final int SESSION_EMPTY = ActivitySession.SESSION_EMPTY;
|
private final int SESSION_EMPTY = ActivitySession.SESSION_EMPTY;
|
||||||
ActivityUser activityUser = new ActivityUser();
|
ActivityUser activityUser = new ActivityUser();
|
||||||
int stepsGoal = activityUser.getStepsGoal();
|
int stepsGoal = activityUser.getStepsGoal();
|
||||||
int distanceGoalMeters = activityUser.getDistanceMeters();
|
int distanceGoalMeters = activityUser.getDistanceGoalMeters();
|
||||||
long activeTimeGoalTimeMillis = activityUser.getActiveTimeMinutes() * 60 * 1000L;
|
long activeTimeGoalTimeMillis = activityUser.getActiveTimeGoalMinutes() * 60 * 1000L;
|
||||||
|
|
||||||
public ActivityListingAdapter(Context context) {
|
public ActivityListingAdapter(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -38,20 +38,13 @@ public class StepAnalysis {
|
|||||||
LOG.debug("get all samples activitysessions: " + samples.toArray().length);
|
LOG.debug("get all samples activitysessions: " + samples.toArray().length);
|
||||||
List<ActivitySession> result = new ArrayList<>();
|
List<ActivitySession> result = new ArrayList<>();
|
||||||
ActivityUser activityUser = new ActivityUser();
|
ActivityUser activityUser = new ActivityUser();
|
||||||
double STEP_LENGTH_M;
|
|
||||||
final int MIN_SESSION_LENGTH = 60 * GBApplication.getPrefs().getInt("chart_list_min_session_length", 5);
|
final int MIN_SESSION_LENGTH = 60 * GBApplication.getPrefs().getInt("chart_list_min_session_length", 5);
|
||||||
final int MAX_IDLE_PHASE_LENGTH = 60 * GBApplication.getPrefs().getInt("chart_list_max_idle_phase_length", 5);
|
final int MAX_IDLE_PHASE_LENGTH = 60 * GBApplication.getPrefs().getInt("chart_list_max_idle_phase_length", 5);
|
||||||
final int MIN_STEPS_PER_MINUTE = GBApplication.getPrefs().getInt("chart_list_min_steps_per_minute", 40);
|
final int MIN_STEPS_PER_MINUTE = GBApplication.getPrefs().getInt("chart_list_min_steps_per_minute", 40);
|
||||||
int stepLengthCm = activityUser.getStepLengthCm();
|
int stepLengthCm = activityUser.getStepLengthCm();
|
||||||
int heightCm = activityUser.getHeightCm();
|
final double STEP_LENGTH_M = stepLengthCm * 0.01;
|
||||||
totalDailySteps = 0;
|
|
||||||
|
|
||||||
if (stepLengthCm == 0 && heightCm != 0) {
|
|
||||||
STEP_LENGTH_M = heightCm * 0.43 * 0.01;
|
|
||||||
} else {
|
|
||||||
STEP_LENGTH_M = stepLengthCm * 0.01;
|
|
||||||
}
|
|
||||||
final double MIN_SESSION_INTENSITY = Math.max(0, Math.min(1, MIN_STEPS_PER_MINUTE * 0.01));
|
final double MIN_SESSION_INTENSITY = Math.max(0, Math.min(1, MIN_STEPS_PER_MINUTE * 0.01));
|
||||||
|
totalDailySteps = 0;
|
||||||
|
|
||||||
ActivitySample previousSample = null;
|
ActivitySample previousSample = null;
|
||||||
Date sessionStart = null;
|
Date sessionStart = null;
|
||||||
|
@ -525,8 +525,6 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
|
|||||||
addPreferenceHandlerFor(PREF_GALAXY_BUDS_TOUCH_RIGHT);
|
addPreferenceHandlerFor(PREF_GALAXY_BUDS_TOUCH_RIGHT);
|
||||||
addPreferenceHandlerFor(PREF_GALAXY_BUDS_LIVE_ANC);
|
addPreferenceHandlerFor(PREF_GALAXY_BUDS_LIVE_ANC);
|
||||||
addPreferenceHandlerFor(PREF_GALAXY_BUDS_PRESSURE_RELIEF);
|
addPreferenceHandlerFor(PREF_GALAXY_BUDS_PRESSURE_RELIEF);
|
||||||
addPreferenceHandlerFor(PREFS_DEVICE_CHARTS_TABS);
|
|
||||||
|
|
||||||
|
|
||||||
addPreferenceHandlerFor(PREF_SONY_AMBIENT_SOUND_CONTROL);
|
addPreferenceHandlerFor(PREF_SONY_AMBIENT_SOUND_CONTROL);
|
||||||
addPreferenceHandlerFor(PREF_SONY_FOCUS_VOICE);
|
addPreferenceHandlerFor(PREF_SONY_FOCUS_VOICE);
|
||||||
@ -810,7 +808,7 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
|
|||||||
activityInDeviceSteps,
|
activityInDeviceSteps,
|
||||||
activityInDeviceSleep,
|
activityInDeviceSleep,
|
||||||
activityInDeviceDistance,
|
activityInDeviceDistance,
|
||||||
chartsTabsOrderSelection
|
chartsTabsOrderSelection,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (Preference preferenceInControlCenter : preferencesInControlCenter) {
|
for (Preference preferenceInControlCenter : preferencesInControlCenter) {
|
||||||
|
@ -890,11 +890,11 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
|||||||
int sleep = (int) dailyTotals[1];
|
int sleep = (int) dailyTotals[1];
|
||||||
ActivityUser activityUser = new ActivityUser();
|
ActivityUser activityUser = new ActivityUser();
|
||||||
int stepGoal = activityUser.getStepsGoal();
|
int stepGoal = activityUser.getStepsGoal();
|
||||||
int sleepGoal = activityUser.getSleepDuration();
|
int sleepGoal = activityUser.getSleepDurationGoal();
|
||||||
int sleepGoalMinutes = sleepGoal * 60;
|
int sleepGoalMinutes = sleepGoal * 60;
|
||||||
int distanceGoal = activityUser.getDistanceMeters() * 100;
|
int distanceGoal = activityUser.getDistanceGoalMeters() * 100;
|
||||||
int stepLength = activityUser.getStepLengthCm();
|
int stepLength = activityUser.getStepLengthCm();
|
||||||
double distanceMeters = dailyTotals[0] * stepLength / 100;
|
double distanceMeters = dailyTotals[0] * stepLength * 0.01;
|
||||||
double distanceFeet = distanceMeters * 3.28084f;
|
double distanceFeet = distanceMeters * 3.28084f;
|
||||||
double distanceFormatted = 0;
|
double distanceFormatted = 0;
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ public class DBHelper {
|
|||||||
attributes.setValidFromUTC(now.getTime());
|
attributes.setValidFromUTC(now.getTime());
|
||||||
attributes.setHeightCM(prefsUser.getHeightCm());
|
attributes.setHeightCM(prefsUser.getHeightCm());
|
||||||
attributes.setWeightKG(prefsUser.getWeightKg());
|
attributes.setWeightKG(prefsUser.getWeightKg());
|
||||||
attributes.setSleepGoalHPD(prefsUser.getSleepDuration());
|
attributes.setSleepGoalHPD(prefsUser.getSleepDurationGoal());
|
||||||
attributes.setStepsGoalSPD(prefsUser.getStepsGoal());
|
attributes.setStepsGoalSPD(prefsUser.getStepsGoal());
|
||||||
attributes.setUserId(user.getId());
|
attributes.setUserId(user.getId());
|
||||||
session.getUserAttributesDao().insert(attributes);
|
session.getUserAttributesDao().insert(attributes);
|
||||||
@ -343,8 +343,8 @@ public class DBHelper {
|
|||||||
LOG.info("user changed to " + prefsUser.getWeightKg() + " from " + attr.getWeightKG());
|
LOG.info("user changed to " + prefsUser.getWeightKg() + " from " + attr.getWeightKG());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Integer.valueOf(prefsUser.getSleepDuration()).equals(attr.getSleepGoalHPD())) {
|
if (!Integer.valueOf(prefsUser.getSleepDurationGoal()).equals(attr.getSleepGoalHPD())) {
|
||||||
LOG.info("user sleep goal changed to " + prefsUser.getSleepDuration() + " from " + attr.getSleepGoalHPD());
|
LOG.info("user sleep goal changed to " + prefsUser.getSleepDurationGoal() + " from " + attr.getSleepGoalHPD());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Integer.valueOf(prefsUser.getStepsGoal()).equals(attr.getStepsGoalSPD())) {
|
if (!Integer.valueOf(prefsUser.getStepsGoal()).equals(attr.getStepsGoalSPD())) {
|
||||||
|
@ -39,11 +39,11 @@ public class ActivityUser {
|
|||||||
private int activityUserYearOfBirth;
|
private int activityUserYearOfBirth;
|
||||||
private int activityUserHeightCm;
|
private int activityUserHeightCm;
|
||||||
private int activityUserWeightKg;
|
private int activityUserWeightKg;
|
||||||
private int activityUserSleepDuration;
|
private int activityUserSleepDurationGoal;
|
||||||
private int activityUserStepsGoal;
|
private int activityUserStepsGoal;
|
||||||
private int activityUserCaloriesBurnt;
|
private int activityUserCaloriesBurntGoal;
|
||||||
private int activityUserDistanceMeters;
|
private int activityUserDistanceGoalMeters;
|
||||||
private int activityUserActiveTimeMinutes;
|
private int activityUserActiveTimeGoalMinutes;
|
||||||
private int activityUserStepLengthCm;
|
private int activityUserStepLengthCm;
|
||||||
|
|
||||||
private static final String defaultUserName = "gadgetbridge-user";
|
private static final String defaultUserName = "gadgetbridge-user";
|
||||||
@ -52,11 +52,11 @@ public class ActivityUser {
|
|||||||
public static final int defaultUserAge = 0;
|
public static final int defaultUserAge = 0;
|
||||||
public static final int defaultUserHeightCm = 175;
|
public static final int defaultUserHeightCm = 175;
|
||||||
public static final int defaultUserWeightKg = 70;
|
public static final int defaultUserWeightKg = 70;
|
||||||
public static final int defaultUserSleepDuration = 7;
|
public static final int defaultUserSleepDurationGoal = 7;
|
||||||
public static final int defaultUserStepsGoal = 8000;
|
public static final int defaultUserStepsGoal = 8000;
|
||||||
public static final int defaultUserCaloriesBurnt = 2000;
|
public static final int defaultUserCaloriesBurntGoal = 2000;
|
||||||
public static final int defaultUserDistanceMeters = 5000;
|
public static final int defaultUserDistanceGoalMeters = 5000;
|
||||||
public static final int defaultUserActiveTimeMinutes = 60;
|
public static final int defaultUserActiveTimeGoalMinutes = 60;
|
||||||
public static final int defaultUserStepLengthCm = 0;
|
public static final int defaultUserStepLengthCm = 0;
|
||||||
|
|
||||||
public static final String PREF_USER_NAME = "mi_user_alias";
|
public static final String PREF_USER_NAME = "mi_user_alias";
|
||||||
@ -96,11 +96,26 @@ public class ActivityUser {
|
|||||||
return activityUserYearOfBirth;
|
return activityUserYearOfBirth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the user defined height or a default value when none is set or the stored
|
||||||
|
* value is 0.
|
||||||
|
*/
|
||||||
|
|
||||||
public int getHeightCm() {
|
public int getHeightCm() {
|
||||||
|
if (activityUserHeightCm < 1) {
|
||||||
|
activityUserHeightCm = defaultUserHeightCm;
|
||||||
|
}
|
||||||
return activityUserHeightCm;
|
return activityUserHeightCm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the user defined step length or the calculated default value when none is set or the stored
|
||||||
|
* value is 0.
|
||||||
|
*/
|
||||||
public int getStepLengthCm() {
|
public int getStepLengthCm() {
|
||||||
|
if (activityUserStepLengthCm < 1) {
|
||||||
|
activityUserStepLengthCm = (int) (getHeightCm() * 0.43);
|
||||||
|
}
|
||||||
return activityUserStepLengthCm;
|
return activityUserStepLengthCm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,11 +123,11 @@ public class ActivityUser {
|
|||||||
* @return the user defined sleep duration or the default value when none is set or the stored
|
* @return the user defined sleep duration or the default value when none is set or the stored
|
||||||
* value is out of any logical bounds.
|
* value is out of any logical bounds.
|
||||||
*/
|
*/
|
||||||
public int getSleepDuration() {
|
public int getSleepDurationGoal() {
|
||||||
if (activityUserSleepDuration < 1 || activityUserSleepDuration > 24) {
|
if (activityUserSleepDurationGoal < 1 || activityUserSleepDurationGoal > 24) {
|
||||||
activityUserSleepDuration = defaultUserSleepDuration;
|
activityUserSleepDurationGoal = defaultUserSleepDurationGoal;
|
||||||
}
|
}
|
||||||
return activityUserSleepDuration;
|
return activityUserSleepDurationGoal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStepsGoal() {
|
public int getStepsGoal() {
|
||||||
@ -141,11 +156,11 @@ public class ActivityUser {
|
|||||||
activityUserHeightCm = prefs.getInt(PREF_USER_HEIGHT_CM, defaultUserHeightCm);
|
activityUserHeightCm = prefs.getInt(PREF_USER_HEIGHT_CM, defaultUserHeightCm);
|
||||||
activityUserWeightKg = prefs.getInt(PREF_USER_WEIGHT_KG, defaultUserWeightKg);
|
activityUserWeightKg = prefs.getInt(PREF_USER_WEIGHT_KG, defaultUserWeightKg);
|
||||||
activityUserYearOfBirth = prefs.getInt(PREF_USER_YEAR_OF_BIRTH, defaultUserYearOfBirth);
|
activityUserYearOfBirth = prefs.getInt(PREF_USER_YEAR_OF_BIRTH, defaultUserYearOfBirth);
|
||||||
activityUserSleepDuration = prefs.getInt(PREF_USER_SLEEP_DURATION, defaultUserSleepDuration);
|
activityUserSleepDurationGoal = prefs.getInt(PREF_USER_SLEEP_DURATION, defaultUserSleepDurationGoal);
|
||||||
activityUserStepsGoal = prefs.getInt(PREF_USER_STEPS_GOAL, defaultUserStepsGoal);
|
activityUserStepsGoal = prefs.getInt(PREF_USER_STEPS_GOAL, defaultUserStepsGoal);
|
||||||
activityUserCaloriesBurnt = prefs.getInt(PREF_USER_CALORIES_BURNT, defaultUserCaloriesBurnt);
|
activityUserCaloriesBurntGoal = prefs.getInt(PREF_USER_CALORIES_BURNT, defaultUserCaloriesBurntGoal);
|
||||||
activityUserDistanceMeters = prefs.getInt(PREF_USER_DISTANCE_METERS, defaultUserDistanceMeters);
|
activityUserDistanceGoalMeters = prefs.getInt(PREF_USER_DISTANCE_METERS, defaultUserDistanceGoalMeters);
|
||||||
activityUserActiveTimeMinutes = prefs.getInt(PREF_USER_ACTIVETIME_MINUTES, defaultUserActiveTimeMinutes);
|
activityUserActiveTimeGoalMinutes = prefs.getInt(PREF_USER_ACTIVETIME_MINUTES, defaultUserActiveTimeGoalMinutes);
|
||||||
activityUserStepLengthCm = prefs.getInt(PREF_USER_STEP_LENGTH_CM, defaultUserStepLengthCm);
|
activityUserStepLengthCm = prefs.getInt(PREF_USER_STEP_LENGTH_CM, defaultUserStepLengthCm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,27 +170,27 @@ public class ActivityUser {
|
|||||||
return cal.getTime();
|
return cal.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCaloriesBurnt()
|
public int getCaloriesBurntGoal()
|
||||||
{
|
{
|
||||||
if (activityUserCaloriesBurnt < 1) {
|
if (activityUserCaloriesBurntGoal < 1) {
|
||||||
activityUserCaloriesBurnt = defaultUserCaloriesBurnt;
|
activityUserCaloriesBurntGoal = defaultUserCaloriesBurntGoal;
|
||||||
}
|
}
|
||||||
return activityUserCaloriesBurnt;
|
return activityUserCaloriesBurntGoal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDistanceMeters()
|
public int getDistanceGoalMeters()
|
||||||
{
|
{
|
||||||
if (activityUserDistanceMeters < 1) {
|
if (activityUserDistanceGoalMeters < 1) {
|
||||||
activityUserDistanceMeters = defaultUserDistanceMeters;
|
activityUserDistanceGoalMeters = defaultUserDistanceGoalMeters;
|
||||||
}
|
}
|
||||||
return activityUserDistanceMeters;
|
return activityUserDistanceGoalMeters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getActiveTimeMinutes()
|
public int getActiveTimeGoalMinutes()
|
||||||
{
|
{
|
||||||
if (activityUserActiveTimeMinutes < 1) {
|
if (activityUserActiveTimeGoalMinutes < 1) {
|
||||||
activityUserActiveTimeMinutes = defaultUserActiveTimeMinutes;
|
activityUserActiveTimeGoalMinutes = defaultUserActiveTimeGoalMinutes;
|
||||||
}
|
}
|
||||||
return activityUserActiveTimeMinutes;
|
return activityUserActiveTimeGoalMinutes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ public class SetConfigurationOperation extends AbstractBTLEOperation<CasioGBX10
|
|||||||
if(option == CasioConstants.ConfigurationOption.OPTION_DISTANCE_GOAL || all) {
|
if(option == CasioConstants.ConfigurationOption.OPTION_DISTANCE_GOAL || all) {
|
||||||
// The watch requires a monthly goal, so we multiply that with 30
|
// The watch requires a monthly goal, so we multiply that with 30
|
||||||
// and divide it by 100 because the value is set in 100m units
|
// and divide it by 100 because the value is set in 100m units
|
||||||
int distance = user.getDistanceMeters() * 30;
|
int distance = user.getDistanceGoalMeters() * 30;
|
||||||
distance = distance / 100;
|
distance = distance / 100;
|
||||||
data[6] = (byte)(distance & 0xff);
|
data[6] = (byte)(distance & 0xff);
|
||||||
data[7] = (byte)((distance >> 8) & 0xff);
|
data[7] = (byte)((distance >> 8) & 0xff);
|
||||||
@ -179,7 +179,7 @@ public class SetConfigurationOperation extends AbstractBTLEOperation<CasioGBX10
|
|||||||
|
|
||||||
if(option == CasioConstants.ConfigurationOption.OPTION_ACTIVITY_GOAL || all) {
|
if(option == CasioConstants.ConfigurationOption.OPTION_ACTIVITY_GOAL || all) {
|
||||||
// The watch requires a monthly goal, so we multiply that with 30
|
// The watch requires a monthly goal, so we multiply that with 30
|
||||||
int time = user.getActiveTimeMinutes() * 30;
|
int time = user.getActiveTimeGoalMinutes() * 30;
|
||||||
data[9] = (byte)(time & 0xff);
|
data[9] = (byte)(time & 0xff);
|
||||||
data[10] = (byte)((time >> 8) & 0xff);
|
data[10] = (byte)((time >> 8) & 0xff);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.model.Weather;
|
import nodomain.freeyourgadget.gadgetbridge.model.Weather;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.GattService;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.GattService;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction;
|
||||||
@ -1580,10 +1579,10 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
private void setUserGoals(TransactionBuilder builder) {
|
private void setUserGoals(TransactionBuilder builder) {
|
||||||
ActivityUser activityUser = new ActivityUser();
|
ActivityUser activityUser = new ActivityUser();
|
||||||
int steps = activityUser.getStepsGoal() / 100; // ZeTime expect the steps in 100 increment
|
int steps = activityUser.getStepsGoal() / 100; // ZeTime expect the steps in 100 increment
|
||||||
int calories = activityUser.getCaloriesBurnt();
|
int calories = activityUser.getCaloriesBurntGoal();
|
||||||
int distance = activityUser.getDistanceMeters() / 1000; // ZeTime only accepts km goals
|
int distance = activityUser.getDistanceGoalMeters() / 1000; // ZeTime only accepts km goals
|
||||||
int sleep = activityUser.getSleepDuration();
|
int sleep = activityUser.getSleepDurationGoal();
|
||||||
int activeTime = activityUser.getActiveTimeMinutes();
|
int activeTime = activityUser.getActiveTimeGoalMinutes();
|
||||||
|
|
||||||
// set steps goal
|
// set steps goal
|
||||||
byte[] goal_steps = {ZeTimeConstants.CMD_PREAMBLE,
|
byte[] goal_steps = {ZeTimeConstants.CMD_PREAMBLE,
|
||||||
|
Loading…
Reference in New Issue
Block a user