From 0da866f70a7e5fce6ad5ccbcb731c75607a82616 Mon Sep 17 00:00:00 2001 From: Sebastian Kranz Date: Mon, 4 Mar 2019 07:16:56 +0100 Subject: [PATCH] Change user goal distance preference to use meters instead of km. --- .../devices/zetime/ZeTimeConstants.java | 2 +- .../gadgetbridge/model/ActivityUser.java | 16 ++++++++-------- .../devices/zetime/ZeTimeDeviceSupport.java | 3 ++- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- app/src/main/res/xml/preferences.xml | 6 +++--- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java index 791cbd2b2..3355f3958 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java @@ -177,7 +177,7 @@ public class ZeTimeConstants { 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_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"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityUser.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityUser.java index 1850e5511..a2dacabcc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityUser.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityUser.java @@ -42,7 +42,7 @@ public class ActivityUser { private int activityUserSleepDuration; private int activityUserStepsGoal; private int activityUserCaloriesBurnt; - private int activityUserDistanceKMeters; + private int activityUserDistanceMeters; private int activityUserActiveTimeMinutes; private static final String defaultUserName = "gadgetbridge-user"; @@ -54,7 +54,7 @@ public class ActivityUser { public static final int defaultUserSleepDuration = 7; public static final int defaultUserStepsGoal = 8000; public static final int defaultUserCaloriesBurnt = 2000; - public static final int defaultUserDistanceKMeters = 5; + public static final int defaultUserDistanceMeters = 5000; public static final int defaultUserActiveTimeMinutes = 60; public static final String PREF_USER_NAME = "mi_user_alias"; @@ -65,7 +65,7 @@ public class ActivityUser { public static final String PREF_USER_SLEEP_DURATION = "activity_user_sleep_duration"; public static final String PREF_USER_STEPS_GOAL = "mi_fitness_goal"; // FIXME: for compatibility public static final String PREF_USER_CALORIES_BURNT = "activity_user_calories_burnt"; - public static final String PREF_USER_DISTANCE_KMETERS = "activity_user_distance_kmeters"; + public static final String PREF_USER_DISTANCE_METERS = "activity_user_distance_meters"; public static final String PREF_USER_ACTIVETIME_MINUTES = "activity_user_activetime_minutes"; public ActivityUser() { @@ -137,7 +137,7 @@ public class ActivityUser { activityUserSleepDuration = prefs.getInt(PREF_USER_SLEEP_DURATION, defaultUserSleepDuration); activityUserStepsGoal = prefs.getInt(PREF_USER_STEPS_GOAL, defaultUserStepsGoal); activityUserCaloriesBurnt = prefs.getInt(PREF_USER_CALORIES_BURNT, defaultUserCaloriesBurnt); - activityUserDistanceKMeters = prefs.getInt(PREF_USER_DISTANCE_KMETERS, defaultUserDistanceKMeters); + activityUserDistanceMeters = prefs.getInt(PREF_USER_DISTANCE_METERS, defaultUserDistanceMeters); activityUserActiveTimeMinutes = prefs.getInt(PREF_USER_ACTIVETIME_MINUTES, defaultUserActiveTimeMinutes); } @@ -155,12 +155,12 @@ public class ActivityUser { return activityUserCaloriesBurnt; } - public int getDistanceKMeters() + public int getDistanceMeters() { - if (activityUserDistanceKMeters < 0) { - activityUserDistanceKMeters = defaultUserDistanceKMeters; + if (activityUserDistanceMeters < 0) { + activityUserDistanceMeters = defaultUserDistanceMeters; } - return activityUserDistanceKMeters; + return activityUserDistanceMeters; } public int getActiveTimeMinutes() diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java index e44c3d21b..44b3d189e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java @@ -1537,7 +1537,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { ActivityUser activityUser = new ActivityUser(); int steps = activityUser.getStepsGoal() / 100; // ZeTime expect the steps in 100 increment int calories = activityUser.getCaloriesBurnt(); - int distance = activityUser.getDistanceKMeters(); + int distance = activityUser.getDistanceMeters() / 1000; // ZeTime only accepts km goals int sleep = activityUser.getSleepDuration(); int activeTime = activityUser.getActiveTimeMinutes(); @@ -2193,6 +2193,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { if (getDevice().isBusy()) { getDevice().unsetBusyTask(); getDevice().sendDeviceUpdateIntent(getContext()); + } } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index feebe9de2..b4d3a9449 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -647,7 +647,7 @@ Tägliches Ziel: verbrannte Kalorien - Tägliches Ziel: zurückgelegte Strecke in km + Tägliches Ziel: zurückgelegte Strecke in Meter Tägliches Ziel: aktive Zeit in Minuten diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 603a5556b..c2fff9051 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -558,7 +558,7 @@ Heart rate Daily target: calories burnt - Daily target: distance in km + Daily target: distance in meters Daily target: active time in minutes Store raw record in the database diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 5045def4f..540d5d2e6 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -146,9 +146,9 @@ + android:key="activity_user_distance_meters" + android:maxLength="5" + android:title="@string/activity_prefs_distance_meters" />