forked from upstream-mirrors/OpenTracks
Fix comment on 9399fc25c7ce.
Also define the default values in "do_not_translate.xml" so that can be consistent between the preferences.xml and the java files.
This commit is contained in:
+11
-9
@@ -37,21 +37,22 @@ import android.util.Log;
|
||||
public class DynamicSpeedTrackPathDescriptor
|
||||
implements TrackPathDescriptor, OnSharedPreferenceChangeListener {
|
||||
|
||||
private static int DEFAULT_SPEED_MARGIN = 25;
|
||||
|
||||
private int slowSpeed;
|
||||
private int normalSpeed;
|
||||
private int speedMargin;
|
||||
private final int speedMarginDefault;
|
||||
private double averageMovingSpeed;
|
||||
private final Context context;
|
||||
|
||||
public DynamicSpeedTrackPathDescriptor(Context context){
|
||||
this.context = context;
|
||||
speedMarginDefault = Integer.parseInt(
|
||||
context.getString(R.string.color_mode_dynamic_percentage_default));
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
|
||||
if (prefs == null) {
|
||||
speedMargin = DEFAULT_SPEED_MARGIN;
|
||||
speedMargin = speedMarginDefault;
|
||||
return;
|
||||
}
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
@@ -60,12 +61,13 @@ public class DynamicSpeedTrackPathDescriptor
|
||||
}
|
||||
|
||||
private int getSpeedMargin(SharedPreferences sharedPreferences) {
|
||||
String key = context.getString(R.string.track_color_mode_dynamic_speed_variation_key);
|
||||
String percentage = sharedPreferences.getString(key, DEFAULT_SPEED_MARGIN + "");
|
||||
if (percentage.isEmpty()) {
|
||||
return DEFAULT_SPEED_MARGIN;
|
||||
try {
|
||||
return Integer.parseInt(sharedPreferences.getString(
|
||||
context.getString(R.string.track_color_mode_dynamic_speed_variation_key),
|
||||
speedMarginDefault + ""));
|
||||
} catch (NumberFormatException e) {
|
||||
return speedMarginDefault;
|
||||
}
|
||||
return Integer.parseInt(percentage);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +101,7 @@ public class DynamicSpeedTrackPathDescriptor
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
|
||||
if (prefs == null) {
|
||||
speedMargin = DEFAULT_SPEED_MARGIN;
|
||||
speedMargin = speedMarginDefault;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+17
-12
@@ -34,32 +34,37 @@ import android.util.Log;
|
||||
public class FixedSpeedTrackPathDescriptor implements TrackPathDescriptor, OnSharedPreferenceChangeListener {
|
||||
private int slowSpeed;
|
||||
private int normalSpeed;
|
||||
private final int slowDefault;
|
||||
private final int normalDefault;
|
||||
private final Context context;
|
||||
|
||||
public FixedSpeedTrackPathDescriptor(Context context) {
|
||||
|
||||
this.context = context;
|
||||
slowDefault = Integer.parseInt(context.getString(R.string.color_mode_fixed_slow_default));
|
||||
normalDefault = Integer.parseInt(context.getString(R.string.color_mode_fixed_medium_default));
|
||||
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
if (prefs == null) {
|
||||
slowSpeed = 9;
|
||||
normalSpeed = 17;
|
||||
slowSpeed = slowDefault;
|
||||
normalSpeed = normalDefault;
|
||||
return;
|
||||
}
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
try {
|
||||
slowSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||
R.string.track_color_mode_fixed_speed_slow_key), "9"));
|
||||
R.string.track_color_mode_fixed_speed_slow_key), slowDefault + ""));
|
||||
} catch (NumberFormatException e) {
|
||||
slowSpeed = 9;
|
||||
slowSpeed = slowDefault;
|
||||
}
|
||||
|
||||
try {
|
||||
normalSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||
R.string.track_color_mode_fixed_speed_medium_key), "17"));
|
||||
R.string.track_color_mode_fixed_speed_medium_key), normalDefault + ""));
|
||||
} catch (NumberFormatException e) {
|
||||
normalSpeed = 17;
|
||||
normalSpeed = normalDefault;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,22 +95,22 @@ public class FixedSpeedTrackPathDescriptor implements TrackPathDescriptor, OnSha
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
if (prefs == null) {
|
||||
slowSpeed = 9;
|
||||
normalSpeed = 17;
|
||||
slowSpeed = slowDefault;
|
||||
normalSpeed = normalDefault;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
slowSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||
R.string.track_color_mode_fixed_speed_slow_key), "9"));
|
||||
R.string.track_color_mode_fixed_speed_slow_key), slowDefault + ""));
|
||||
} catch (NumberFormatException e) {
|
||||
slowSpeed = 9;
|
||||
slowSpeed = slowDefault;
|
||||
}
|
||||
try {
|
||||
normalSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||
R.string.track_color_mode_fixed_speed_medium_key), "17"));
|
||||
R.string.track_color_mode_fixed_speed_medium_key), normalDefault + ""));
|
||||
} catch (NumberFormatException e) {
|
||||
normalSpeed = 17;
|
||||
normalSpeed = normalDefault;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user