forked from upstream-mirrors/OpenTracks
Review issues corrected
This commit is contained in:
@@ -189,49 +189,7 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
});
|
||||
updateTrackColorModeSettings(trackColorModePreference.getValue());
|
||||
|
||||
EditTextPreference trackColorModeFixedSlowPreference =
|
||||
(EditTextPreference) findPreference(getString(R.string.track_color_mode_fixed_speed_slow_display_key));
|
||||
trackColorModeFixedSlowPreference.setOnPreferenceChangeListener(
|
||||
new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference,
|
||||
Object newValue) {
|
||||
validateTrackColorModeSettings((EditTextPreference) preference, (String) newValue,
|
||||
R.string.track_color_mode_fixed_speed_slow_key);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
trackColorModeFixedSlowPreference.setOnPreferenceClickListener(
|
||||
new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
viewTrackColorModeSettings((EditTextPreference) preference,
|
||||
R.string.track_color_mode_fixed_speed_slow_key);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
EditTextPreference trackColorModeFixedMediumPreference =
|
||||
(EditTextPreference) findPreference(getString(R.string.track_color_mode_fixed_speed_medium_display_key));
|
||||
trackColorModeFixedMediumPreference.setOnPreferenceChangeListener(
|
||||
new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference,
|
||||
Object newValue) {
|
||||
validateTrackColorModeSettings((EditTextPreference) preference, (String) newValue,
|
||||
R.string.track_color_mode_fixed_speed_slow_key);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
trackColorModeFixedMediumPreference.setOnPreferenceClickListener(
|
||||
new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
viewTrackColorModeSettings((EditTextPreference) preference,
|
||||
R.string.track_color_mode_fixed_speed_medium_key);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
setTrackColorModePreferenceListeners();
|
||||
|
||||
PreferenceCategory speedOptionsCategory =
|
||||
(PreferenceCategory) findPreference(getString(R.string.track_color_mode_fixed_speed_options_key));
|
||||
@@ -461,8 +419,10 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
}.start();
|
||||
}
|
||||
|
||||
/** Set the given edit text preference text.
|
||||
If the units are not metric convert the value before displaying. */
|
||||
/**
|
||||
* Set the given edit text preference text.
|
||||
* If the units are not metric convert the value before displaying.
|
||||
*/
|
||||
private void viewTrackColorModeSettings(EditTextPreference preference, int id) {
|
||||
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
|
||||
getString(R.string.metric_units_key));
|
||||
@@ -481,8 +441,10 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
preference.getEditText().setText(String.valueOf(englishspeed));
|
||||
}
|
||||
|
||||
/** Saves the given edit text preference value.
|
||||
If the units are not metric convert the value before saving. */
|
||||
/**
|
||||
* Saves the given edit text preference value.
|
||||
* If the units are not metric convert the value before saving.
|
||||
*/
|
||||
private void validateTrackColorModeSettings(EditTextPreference preference,
|
||||
String newValue, int id) {
|
||||
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
|
||||
@@ -501,4 +463,53 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
||||
prefs.edit().putString(getString(id), metricspeed).commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the TrackColorMode preference listeners.
|
||||
*/
|
||||
private void setTrackColorModePreferenceListeners() {
|
||||
EditTextPreference trackColorModeFixedSlowPreference =
|
||||
(EditTextPreference) findPreference(getString(R.string.track_color_mode_fixed_speed_slow_display_key));
|
||||
trackColorModeFixedSlowPreference.setOnPreferenceChangeListener(
|
||||
new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference,
|
||||
Object newValue) {
|
||||
validateTrackColorModeSettings((EditTextPreference) preference, (String) newValue,
|
||||
R.string.track_color_mode_fixed_speed_slow_key);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
trackColorModeFixedSlowPreference.setOnPreferenceClickListener(
|
||||
new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
viewTrackColorModeSettings((EditTextPreference) preference,
|
||||
R.string.track_color_mode_fixed_speed_slow_key);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
EditTextPreference trackColorModeFixedMediumPreference =
|
||||
(EditTextPreference) findPreference(getString(R.string.track_color_mode_fixed_speed_medium_display_key));
|
||||
trackColorModeFixedMediumPreference.setOnPreferenceChangeListener(
|
||||
new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference,
|
||||
Object newValue) {
|
||||
validateTrackColorModeSettings((EditTextPreference) preference, (String) newValue,
|
||||
R.string.track_color_mode_fixed_speed_slow_key);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
trackColorModeFixedMediumPreference.setOnPreferenceClickListener(
|
||||
new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
viewTrackColorModeSettings((EditTextPreference) preference,
|
||||
R.string.track_color_mode_fixed_speed_medium_key);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ public class DynamicSpeedTrackPathDescriptor
|
||||
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
||||
long currentTrackId = prefs.getLong(context.getString(R.string.selected_track_key), -1);
|
||||
if(currentTrackId == -1) {
|
||||
// in reality this means something went awry, additional logic to exit or so?
|
||||
// Could not find track.
|
||||
return false;
|
||||
}
|
||||
Track track = MyTracksProviderUtils.Factory.get(context).getTrack(currentTrackId);
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ public class FixedSpeedTrackPathDescriptor implements TrackPathDescriptor, OnSha
|
||||
Log.d(Constants.TAG, "FixedSpeedTrackPathDescriptor: onSharedPreferences changed " + key);
|
||||
if (key == null
|
||||
|| (!key.equals(context.getString(R.string.track_color_mode_fixed_speed_slow_key))
|
||||
&& !key.equals(context.getString(R.string.track_color_mode_fixed_speed_medium_key)))) {
|
||||
&& !key.equals(context.getString(R.string.track_color_mode_fixed_speed_medium_key)))) {
|
||||
return;
|
||||
}
|
||||
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
||||
|
||||
@@ -56,7 +56,7 @@ public class TrackPathPainterFactory {
|
||||
return new DynamicSpeedTrackPathPainter(context,
|
||||
new DynamicSpeedTrackPathDescriptor(context));
|
||||
} else {
|
||||
Log.i(Constants.TAG, "Unknow colorMode: " + colorMode);
|
||||
Log.w(Constants.TAG, "Using default track path painter. Unrecognized painter: " + colorMode);
|
||||
return new SingleColorTrackPathPainter(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.graphics.Paint;
|
||||
* @author Vangelis S.
|
||||
*/
|
||||
public class TrackPathUtilities {
|
||||
|
||||
public static Paint getPaint(int id, Context context) {
|
||||
Paint paint = new Paint();
|
||||
paint.setColor(context.getResources().getColor(id));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
@@ -27,29 +27,31 @@ import android.graphics.Rect;
|
||||
*
|
||||
* @author Bartlomiej Niechwiej
|
||||
* @author Vangelis S.
|
||||
*
|
||||
* A mock version of {@code MapOverlay} that does not use
|
||||
* {@class MapView}.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A mock version of {@code MapOverlay} that does not use
|
||||
* {@class MapView}.
|
||||
*/
|
||||
public class MockMyTracksOverlay extends MapOverlay {
|
||||
public class MockMyTracksOverlay extends MapOverlay {
|
||||
|
||||
private Projection mockProjection;
|
||||
public MockMyTracksOverlay(Context context) {
|
||||
super(context);
|
||||
mockProjection = new MockProjection();
|
||||
}
|
||||
@Override
|
||||
public Projection getMapProjection(MapView mapView) {
|
||||
return mockProjection;
|
||||
}
|
||||
@Override
|
||||
public Rect getMapViewRect(MapView mapView) {
|
||||
return new Rect(0, 0, 100, 100);
|
||||
}
|
||||
@Override
|
||||
public Path newPath() {
|
||||
return new MockPath();
|
||||
}
|
||||
}
|
||||
private Projection mockProjection;
|
||||
|
||||
public MockMyTracksOverlay(Context context) {
|
||||
super(context);
|
||||
mockProjection = new MockProjection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Projection getMapProjection(MapView mapView) {
|
||||
return mockProjection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rect getMapViewRect(MapView mapView) {
|
||||
return new Rect(0, 0, 100, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path newPath() {
|
||||
return new MockPath();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
@@ -30,33 +30,31 @@ import junit.framework.Assert;
|
||||
*
|
||||
* @author Bartlomiej Niechwiej
|
||||
* @author Vangelis S.
|
||||
*
|
||||
* A mock class that intercepts {@code Path}'s and records calls to
|
||||
* {@code #moveTo()} and {@code #lineTo()}.
|
||||
*/
|
||||
public class MockPath extends Path {
|
||||
|
||||
/**
|
||||
* A mock class that intercepts {@code Path}'s and records calls to
|
||||
* {@code #moveTo()} and {@code #lineTo()}.
|
||||
*/
|
||||
public class MockPath extends Path {
|
||||
/** A list of disjoined path segments. */
|
||||
public final List<List<PointF>> segments = new LinkedList<List<PointF>>();
|
||||
/** The total number of points in this path. */
|
||||
public int totalPoints;
|
||||
|
||||
private List<PointF> currentSegment;
|
||||
/** A list of disjoined path segments. */
|
||||
public final List<List<PointF>> segments = new LinkedList<List<PointF>>();
|
||||
/** The total number of points in this path. */
|
||||
public int totalPoints;
|
||||
private List<PointF> currentSegment;
|
||||
|
||||
@Override
|
||||
public void lineTo(float x, float y) {
|
||||
super.lineTo(x, y);
|
||||
|
||||
Assert.assertNotNull(currentSegment);
|
||||
currentSegment.add(new PointF(x, y));
|
||||
totalPoints++;
|
||||
}
|
||||
@Override
|
||||
public void moveTo(float x, float y) {
|
||||
super.moveTo(x, y);
|
||||
segments.add(currentSegment =
|
||||
new ArrayList<PointF>(Arrays.asList(new PointF(x, y))));
|
||||
totalPoints++;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void lineTo(float x, float y) {
|
||||
super.lineTo(x, y);
|
||||
Assert.assertNotNull(currentSegment);
|
||||
currentSegment.add(new PointF(x, y));
|
||||
totalPoints++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveTo(float x, float y) {
|
||||
super.moveTo(x, y);
|
||||
segments.add(currentSegment =
|
||||
new ArrayList<PointF>(Arrays.asList(new PointF(x, y))));
|
||||
totalPoints++;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
@@ -25,22 +25,23 @@ import android.graphics.Point;
|
||||
*
|
||||
* @author Bartlomiej Niechwiej
|
||||
* @author Vangelis S.
|
||||
*
|
||||
* A mock {@code Projection} that acts as the identity matrix.
|
||||
*/
|
||||
public class MockProjection implements Projection {
|
||||
|
||||
/**
|
||||
* A mock {@code Projection} that acts as the identity matrix.
|
||||
*/
|
||||
public class MockProjection implements Projection {
|
||||
@Override
|
||||
public Point toPixels(GeoPoint in, Point out) {
|
||||
return out;
|
||||
}
|
||||
@Override
|
||||
public float metersToEquatorPixels(float meters) {
|
||||
return meters;
|
||||
}
|
||||
@Override
|
||||
public GeoPoint fromPixels(int x, int y) {
|
||||
return new GeoPoint(y, x);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Point toPixels(GeoPoint in, Point out) {
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float metersToEquatorPixels(float meters) {
|
||||
return meters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeoPoint fromPixels(int x, int y) {
|
||||
return new GeoPoint(y, x);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user