forked from upstream-mirrors/OpenTracks
Suggested corrections made (Pending corrections in halt until getting response from the last revision comments i made)
This commit is contained in:
@@ -7,3 +7,5 @@ syntax:glob
|
|||||||
MyTracksTest/annotations.log
|
MyTracksTest/annotations.log
|
||||||
**/*.pyc
|
**/*.pyc
|
||||||
**/*.pyo
|
**/*.pyo
|
||||||
|
syntax: glob
|
||||||
|
MyTracksTest/hs_err_pid*.log
|
||||||
|
|||||||
@@ -54,11 +54,11 @@ limitations under the License.
|
|||||||
|
|
||||||
<!-- Colors for dynamic track drawing -->
|
<!-- Colors for dynamic track drawing -->
|
||||||
<!-- Green -->
|
<!-- Green -->
|
||||||
<color name="slow_path">#f774DF00</color>
|
<color name="slow_path">#F774DF00</color>
|
||||||
|
|
||||||
<!-- Blue -->
|
<!-- Blue -->
|
||||||
<color name="normal_path">#f75858FA</color>
|
<color name="normal_path">#F75858FA</color>
|
||||||
|
|
||||||
<!-- Red -->
|
<!-- Red -->
|
||||||
<color name="fast_path">#f7DF0101</color>
|
<color name="fast_path">#F7DF0101</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -259,25 +259,8 @@ public class MapOverlay extends Overlay implements OnSharedPreferenceChangeListe
|
|||||||
// Draw the selected track:
|
// Draw the selected track:
|
||||||
drawTrack(canvas, projection, viewRect);
|
drawTrack(canvas, projection, viewRect);
|
||||||
|
|
||||||
// Draw the "End" marker.
|
// Draw the "Start" and "End" markers:
|
||||||
if (showEndMarker) {
|
drawMarkers(canvas, projection);
|
||||||
for (int i = getPoints().size() - 1; i >= 0; --i) {
|
|
||||||
if (getPoints().get(i).valid) {
|
|
||||||
drawElement(canvas, projection, getPoints().get(i).geoPoint, endMarker,
|
|
||||||
-markerWidth / 2, -markerHeight);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the "Start" marker.
|
|
||||||
for (int i = 0; i < getPoints().size(); ++i) {
|
|
||||||
if (getPoints().get(i).valid) {
|
|
||||||
drawElement(canvas, projection, getPoints().get(i).geoPoint, startMarker,
|
|
||||||
-markerWidth / 2, -markerHeight);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the waypoints:
|
// Draw the waypoints:
|
||||||
drawWaypoints(canvas, projection);
|
drawWaypoints(canvas, projection);
|
||||||
@@ -287,6 +270,28 @@ public class MapOverlay extends Overlay implements OnSharedPreferenceChangeListe
|
|||||||
drawMyLocation(canvas, projection);
|
drawMyLocation(canvas, projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawMarkers(Canvas canvas, Projection projection) {
|
||||||
|
// Draw the "End" marker.
|
||||||
|
if (showEndMarker) {
|
||||||
|
for (int i = getPoints().size() - 1; i >= 0; --i) {
|
||||||
|
if (getPoints().get(i).valid) {
|
||||||
|
drawElement(canvas, projection, getPoints().get(i).geoPoint, endMarker,
|
||||||
|
-markerWidth / 2, -markerHeight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw the "Start" marker.
|
||||||
|
for (int i = 0; i < getPoints().size(); ++i) {
|
||||||
|
if (getPoints().get(i).valid) {
|
||||||
|
drawElement(canvas, projection, getPoints().get(i).geoPoint, startMarker,
|
||||||
|
-markerWidth / 2, -markerHeight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Visible for testing.
|
// Visible for testing.
|
||||||
Projection getMapProjection(MapView mapView) {
|
Projection getMapProjection(MapView mapView) {
|
||||||
return mapView.getProjection();
|
return mapView.getProjection();
|
||||||
@@ -306,6 +311,11 @@ public class MapOverlay extends Overlay implements OnSharedPreferenceChangeListe
|
|||||||
return new Path();
|
return new Path();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Visible for testing.
|
||||||
|
public Path getLastPath() {
|
||||||
|
return trackPathPainter.getLastPath();
|
||||||
|
}
|
||||||
|
|
||||||
private void drawWaypoints(Canvas canvas, Projection projection) {
|
private void drawWaypoints(Canvas canvas, Projection projection) {
|
||||||
synchronized (waypoints) {;
|
synchronized (waypoints) {;
|
||||||
for (Waypoint wpt : waypoints) {
|
for (Waypoint wpt : waypoints) {
|
||||||
|
|||||||
@@ -461,14 +461,15 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check if metric is unchecked and in that case convert to english to show it to the user. */
|
/** 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) {
|
private void viewTrackColorModeSettings(EditTextPreference preference, int id) {
|
||||||
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
|
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
|
||||||
getString(R.string.metric_units_key));
|
getString(R.string.metric_units_key));
|
||||||
if(metricUnitsPreference.isChecked()) {
|
if(metricUnitsPreference.isChecked()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Convert miles/h to km/h
|
// Convert miles/h to km/h
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
||||||
String metricspeed = prefs.getString(getString(id), null);
|
String metricspeed = prefs.getString(getString(id), null);
|
||||||
int englishspeed;
|
int englishspeed;
|
||||||
@@ -480,14 +481,15 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
preference.getEditText().setText(String.valueOf(englishspeed));
|
preference.getEditText().setText(String.valueOf(englishspeed));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check if metric is unchecked and in that case convert to metric to save it internaly. */
|
/** Saves the given edit text preference value.
|
||||||
|
If the units are not metric convert the value before saving. */
|
||||||
private void validateTrackColorModeSettings(EditTextPreference preference,
|
private void validateTrackColorModeSettings(EditTextPreference preference,
|
||||||
String newValue, int id) {
|
String newValue, int id) {
|
||||||
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
|
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
|
||||||
getString(R.string.metric_units_key));
|
getString(R.string.metric_units_key));
|
||||||
String metricspeed;
|
String metricspeed;
|
||||||
if(!metricUnitsPreference.isChecked()) {
|
if(!metricUnitsPreference.isChecked()) {
|
||||||
//Convert miles/h to km/h
|
// Convert miles/h to km/h
|
||||||
try {
|
try {
|
||||||
metricspeed = String.valueOf((int) (Double.parseDouble(newValue) * UnitConversions.MPH_TO_KMH) + 1);
|
metricspeed = String.valueOf((int) (Double.parseDouble(newValue) * UnitConversions.MPH_TO_KMH) + 1);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|||||||
+18
-15
@@ -15,16 +15,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences;
|
||||||
import android.util.Log;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,8 +32,8 @@ package com.google.android.apps.mytracks.maps;
|
|||||||
*
|
*
|
||||||
* @author Vangelis S.
|
* @author Vangelis S.
|
||||||
*/
|
*/
|
||||||
public class DynamicSpeedTrackPathDescriptor implements TrackPathDescriptor,
|
public class DynamicSpeedTrackPathDescriptor
|
||||||
OnSharedPreferenceChangeListener {
|
implements TrackPathDescriptor, OnSharedPreferenceChangeListener {
|
||||||
private int slowSpeed;
|
private int slowSpeed;
|
||||||
private int normalSpeed;
|
private int normalSpeed;
|
||||||
private int speedMargin;
|
private int speedMargin;
|
||||||
@@ -41,7 +41,6 @@ public class DynamicSpeedTrackPathDescriptor implements TrackPathDescriptor,
|
|||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
public DynamicSpeedTrackPathDescriptor(Context context){
|
public DynamicSpeedTrackPathDescriptor(Context context){
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
||||||
|
|
||||||
@@ -100,7 +99,8 @@ public class DynamicSpeedTrackPathDescriptor implements TrackPathDescriptor,
|
|||||||
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
||||||
long currentTrackId = prefs.getLong(context.getString(R.string.selected_track_key), -1);
|
long currentTrackId = prefs.getLong(context.getString(R.string.selected_track_key), -1);
|
||||||
if(currentTrackId == -1) {
|
if(currentTrackId == -1) {
|
||||||
return false; //in reality this means something went awry, additional logic to exit or so?
|
// in reality this means something went awry, additional logic to exit or so?
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
Track track = MyTracksProviderUtils.Factory.get(context).getTrack(currentTrackId);
|
Track track = MyTracksProviderUtils.Factory.get(context).getTrack(currentTrackId);
|
||||||
TripStatistics stats = track.getStatistics();
|
TripStatistics stats = track.getStatistics();
|
||||||
@@ -118,7 +118,10 @@ public class DynamicSpeedTrackPathDescriptor implements TrackPathDescriptor,
|
|||||||
} else {
|
} else {
|
||||||
difference = Math.abs(averageMovingSpeed - newaverageSpeed) / difference * 100;
|
difference = Math.abs(averageMovingSpeed - newaverageSpeed) / difference * 100;
|
||||||
}
|
}
|
||||||
averageMovingSpeed = newaverageSpeed;
|
if(difference >= 20) {
|
||||||
return difference >= 20;
|
averageMovingSpeed = newaverageSpeed;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+20
-11
@@ -15,23 +15,24 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Point;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.ColoredPath;
|
import com.google.android.apps.mytracks.ColoredPath;
|
||||||
import com.google.android.apps.mytracks.MapOverlay.CachedLocation;
|
import com.google.android.apps.mytracks.MapOverlay.CachedLocation;
|
||||||
import com.google.android.maps.GeoPoint;
|
import com.google.android.maps.GeoPoint;
|
||||||
import com.google.android.maps.Projection;
|
import com.google.android.maps.Projection;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Path;
|
||||||
|
import android.graphics.Point;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A path painter that variates the path colors based on fixed speeds or average speed margin
|
* A path painter that varies the path colors based on fixed speeds or average speed margin
|
||||||
* depending of the TrackPathDescriptor passed to its constructor.
|
* depending of the TrackPathDescriptor passed to its constructor.
|
||||||
*
|
*
|
||||||
* @author Vangelis S.
|
* @author Vangelis S.
|
||||||
@@ -126,7 +127,15 @@ public class DynamicSpeedTrackPathPainter implements TrackPathPainter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needsRedraw() {
|
public boolean needsRedraw() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return trackPathDescriptor.needsRedraw();
|
return trackPathDescriptor.needsRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Path getLastPath() {
|
||||||
|
Path path = new Path();
|
||||||
|
for(int i = 0; i < coloredPaths.size(); ++i) {
|
||||||
|
path.addPath(coloredPaths.get(i).getPath());
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+6
-6
@@ -37,8 +37,8 @@ public class FixedSpeedTrackPathDescriptor implements TrackPathDescriptor, OnSha
|
|||||||
public FixedSpeedTrackPathDescriptor(Context context){
|
public FixedSpeedTrackPathDescriptor(Context context){
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
context.getSharedPreferences(Constants.SETTINGS_NAME, 0)
|
context.getSharedPreferences(Constants.SETTINGS_NAME, 0)
|
||||||
.registerOnSharedPreferenceChangeListener(this);
|
.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
||||||
if (prefs == null) {
|
if (prefs == null) {
|
||||||
@@ -89,10 +89,10 @@ public class FixedSpeedTrackPathDescriptor implements TrackPathDescriptor, OnSha
|
|||||||
}
|
}
|
||||||
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
||||||
if (prefs == null) {
|
if (prefs == null) {
|
||||||
slowSpeed = 9;
|
slowSpeed = 9;
|
||||||
normalSpeed = 17;
|
normalSpeed = 17;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
slowSpeed = Integer.parseInt(prefs.getString(context.getString(
|
slowSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||||
|
|||||||
+10
-5
@@ -15,7 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
import java.util.List;
|
import com.google.android.apps.mytracks.MapOverlay.CachedLocation;
|
||||||
|
import com.google.android.maps.GeoPoint;
|
||||||
|
import com.google.android.maps.Projection;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
@@ -24,10 +27,7 @@ import android.graphics.Path;
|
|||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.MapOverlay.CachedLocation;
|
import java.util.List;
|
||||||
import com.google.android.maps.GeoPoint;
|
|
||||||
import com.google.android.maps.Projection;
|
|
||||||
import com.google.android.maps.mytracks.R;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,4 +99,9 @@ public class SingleColorTrackPathPainter implements TrackPathPainter {
|
|||||||
public boolean needsRedraw() {
|
public boolean needsRedraw() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Path getLastPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -16,23 +16,23 @@
|
|||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A path descriptor interface as template to each type of path descriptor.
|
* An interface for classes which describe how to draw a track path.
|
||||||
*
|
*
|
||||||
* @author Vangelis S.
|
* @author Vangelis S.
|
||||||
*/
|
*/
|
||||||
public interface TrackPathDescriptor {
|
public interface TrackPathDescriptor {
|
||||||
/**
|
/**
|
||||||
* @return The speed limit considered as slow.
|
* @return The maximum speed which is considered slow.
|
||||||
*/
|
*/
|
||||||
int getSlowSpeed();
|
int getSlowSpeed();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The speed limit considered as normal.
|
* @return The maximum speed which is considered normal.
|
||||||
*/
|
*/
|
||||||
int getNormalSpeed();
|
int getNormalSpeed();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If the path needs to be updated from scratch.
|
* @return True if the path needs to be updated.
|
||||||
*/
|
*/
|
||||||
boolean needsRedraw();
|
boolean needsRedraw();
|
||||||
}
|
}
|
||||||
@@ -15,47 +15,53 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.MapOverlay.CachedLocation;
|
import com.google.android.apps.mytracks.MapOverlay.CachedLocation;
|
||||||
import com.google.android.maps.Projection;
|
import com.google.android.maps.Projection;
|
||||||
|
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Path;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A path painter interface as template to each type of path painter.
|
* An interface for classes which paint the track path.
|
||||||
*
|
*
|
||||||
* @author Vangelis S.
|
* @author Vangelis S.
|
||||||
*/
|
*/
|
||||||
public interface TrackPathPainter {
|
public interface TrackPathPainter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the related data
|
* Clears the related data.
|
||||||
*/
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the path to the canvas
|
* Draws the path to the canvas.
|
||||||
* @param canvas The Canvas to draw upon
|
* @param canvas The Canvas to draw upon
|
||||||
*/
|
*/
|
||||||
void drawTrack(Canvas canvas);
|
void drawTrack(Canvas canvas);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the path
|
* Updates the path.
|
||||||
* @param projection The Canvas to draw upon
|
* @param projection The Canvas to draw upon.
|
||||||
* @param viewRect The Path to be drawn.
|
* @param viewRect The Path to be drawn.
|
||||||
* @param startLocationIdx The start point from where update the path
|
* @param startLocationIdx The start point from where update the path.
|
||||||
* @param alwaysVisible Flag for alwaysvisible
|
* @param alwaysVisible Flag for alwaysvisible.
|
||||||
* @param points The list of points used to update the path
|
* @param points The list of points used to update the path.
|
||||||
*/
|
*/
|
||||||
void updatePath(Projection projection, Rect viewRect, int startLocationIdx,
|
void updatePath(Projection projection, Rect viewRect, int startLocationIdx,
|
||||||
Boolean alwaysVisible, List<CachedLocation> points);
|
Boolean alwaysVisible, List<CachedLocation> points);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If the path needs to be updated from scratch.
|
* @return True if the path needs to be updated.
|
||||||
*/
|
*/
|
||||||
boolean needsRedraw();
|
boolean needsRedraw();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The path being used currently.
|
||||||
|
*/
|
||||||
|
Path getLastPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory of TrackPathPainters.
|
* A factory for TrackPathPainters.
|
||||||
*
|
*
|
||||||
* @author Vangelis S.
|
* @author Vangelis S.
|
||||||
*/
|
*/
|
||||||
@@ -45,9 +45,9 @@ public class TrackPathPainterFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String colorMode = prefs.getString(context.getString(R.string.track_color_mode_key), null);
|
String colorMode = prefs.getString(context.getString(R.string.track_color_mode_key), null);
|
||||||
Log.i(Constants.TAG, "Creating trackpathpainter of type: " + colorMode);
|
Log.i(Constants.TAG, "Creating track path painter of type: " + colorMode);
|
||||||
|
|
||||||
if (colorMode == null) {
|
if (colorMode == null || colorMode.equals(context.getString(R.string.track_color_mode_none))) {
|
||||||
return new SingleColorTrackPathPainter(context);
|
return new SingleColorTrackPathPainter(context);
|
||||||
} else if (colorMode.equals(context.getString(R.string.track_color_mode_fixed))) {
|
} else if (colorMode.equals(context.getString(R.string.track_color_mode_fixed))) {
|
||||||
return new DynamicSpeedTrackPathPainter(context,
|
return new DynamicSpeedTrackPathPainter(context,
|
||||||
@@ -56,6 +56,7 @@ public class TrackPathPainterFactory {
|
|||||||
return new DynamicSpeedTrackPathPainter(context,
|
return new DynamicSpeedTrackPathPainter(context,
|
||||||
new DynamicSpeedTrackPathDescriptor(context));
|
new DynamicSpeedTrackPathDescriptor(context));
|
||||||
} else {
|
} else {
|
||||||
|
Log.i(Constants.TAG, "Unknow colorMode: " + colorMode);
|
||||||
return new SingleColorTrackPathPainter(context);
|
return new SingleColorTrackPathPainter(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ import android.graphics.Paint;
|
|||||||
* @author Vangelis S.
|
* @author Vangelis S.
|
||||||
*/
|
*/
|
||||||
public class TrackPathUtilities {
|
public class TrackPathUtilities {
|
||||||
public static Paint getPaint(int id, Context context)
|
public static Paint getPaint(int id, Context context) {
|
||||||
{
|
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
paint.setColor(context.getResources().getColor(id));
|
paint.setColor(context.getResources().getColor(id));
|
||||||
paint.setStrokeWidth(3);
|
paint.setStrokeWidth(3);
|
||||||
|
|||||||
@@ -16,102 +16,22 @@
|
|||||||
package com.google.android.apps.mytracks;
|
package com.google.android.apps.mytracks;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.Waypoint;
|
import com.google.android.apps.mytracks.content.Waypoint;
|
||||||
import com.google.android.maps.GeoPoint;
|
|
||||||
import com.google.android.maps.MapView;
|
import com.google.android.maps.MapView;
|
||||||
import com.google.android.maps.Projection;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Path;
|
|
||||||
import android.graphics.Point;
|
|
||||||
import android.graphics.PointF;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the MyTracks map overlay.
|
* Tests for the MyTracks map overlay.
|
||||||
*
|
*
|
||||||
* @author Bartlomiej Niechwiej
|
* @author Bartlomiej Niechwiej
|
||||||
|
* @author Vangelis S.
|
||||||
*/
|
*/
|
||||||
public class MapOverlayTest extends AndroidTestCase {
|
public class MapOverlayTest extends AndroidTestCase {
|
||||||
private Canvas canvas;
|
private Canvas canvas;
|
||||||
private MockMyTracksOverlay myTracksOverlay;
|
private MockMyTracksOverlay myTracksOverlay;
|
||||||
private MapView mockView;
|
private MapView mockView;
|
||||||
private Projection mockProjection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A mock version of {@code MapOverlay} that does not use
|
|
||||||
* {@class MapView}.
|
|
||||||
*/
|
|
||||||
private class MockMyTracksOverlay extends MapOverlay {
|
|
||||||
public MockMyTracksOverlay(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
Projection getMapProjection(MapView mapView) {
|
|
||||||
return mockProjection;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
Rect getMapViewRect(MapView mapView) {
|
|
||||||
return new Rect(0, 0, 100, 100);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
Path newPath() {
|
|
||||||
return new MockPath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A mock class that intercepts {@code Path}'s and records calls to
|
|
||||||
* {@code #moveTo()} and {@code #lineTo()}.
|
|
||||||
*/
|
|
||||||
private static 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;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void lineTo(float x, float y) {
|
|
||||||
super.lineTo(x, y);
|
|
||||||
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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A mock {@code Projection} that acts as the identity matrix.
|
|
||||||
*/
|
|
||||||
private static 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
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
@@ -121,7 +41,6 @@ public class MapOverlayTest extends AndroidTestCase {
|
|||||||
// Enable drawing.
|
// Enable drawing.
|
||||||
myTracksOverlay.setTrackDrawingEnabled(true);
|
myTracksOverlay.setTrackDrawingEnabled(true);
|
||||||
mockView = null;
|
mockView = null;
|
||||||
mockProjection = new MockProjection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddLocation() throws Exception {
|
public void testAddLocation() throws Exception {
|
||||||
@@ -137,19 +56,19 @@ public class MapOverlayTest extends AndroidTestCase {
|
|||||||
myTracksOverlay.addLocation(location);
|
myTracksOverlay.addLocation(location);
|
||||||
assertEquals(2, myTracksOverlay.getNumLocations());
|
assertEquals(2, myTracksOverlay.getNumLocations());
|
||||||
assertEquals(0, myTracksOverlay.getNumWaypoints());
|
assertEquals(0, myTracksOverlay.getNumWaypoints());
|
||||||
//assertNull(myTracksOverlay.getLastPath());
|
assertNull(myTracksOverlay.getLastPath());
|
||||||
|
|
||||||
// Draw and make sure that we don't lose any point.
|
// Draw and make sure that we don't lose any point.
|
||||||
myTracksOverlay.draw(canvas, mockView, false);
|
myTracksOverlay.draw(canvas, mockView, false);
|
||||||
assertEquals(2, myTracksOverlay.getNumLocations());
|
assertEquals(2, myTracksOverlay.getNumLocations());
|
||||||
assertEquals(0, myTracksOverlay.getNumWaypoints());
|
assertEquals(0, myTracksOverlay.getNumWaypoints());
|
||||||
//assertNotNull(myTracksOverlay.getLastPath());
|
assertNotNull(myTracksOverlay.getLastPath());
|
||||||
//assertEquals(2, ((MockPath)myTracksOverlay.getLastPath()).totalPoints);
|
assertEquals(2, ((MockPath)myTracksOverlay.getLastPath()).totalPoints);
|
||||||
|
|
||||||
myTracksOverlay.draw(canvas, mockView, true);
|
myTracksOverlay.draw(canvas, mockView, true);
|
||||||
assertEquals(2, myTracksOverlay.getNumLocations());
|
assertEquals(2, myTracksOverlay.getNumLocations());
|
||||||
assertEquals(0, myTracksOverlay.getNumWaypoints());
|
assertEquals(0, myTracksOverlay.getNumWaypoints());
|
||||||
//assertNotNull(myTracksOverlay.getLastPath());
|
assertNotNull(myTracksOverlay.getLastPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClearPoints() throws Exception {
|
public void testClearPoints() throws Exception {
|
||||||
@@ -182,7 +101,7 @@ public class MapOverlayTest extends AndroidTestCase {
|
|||||||
myTracksOverlay.addWaypoint(waypoint);
|
myTracksOverlay.addWaypoint(waypoint);
|
||||||
assertEquals(1, myTracksOverlay.getNumWaypoints());
|
assertEquals(1, myTracksOverlay.getNumWaypoints());
|
||||||
assertEquals(0, myTracksOverlay.getNumLocations());
|
assertEquals(0, myTracksOverlay.getNumLocations());
|
||||||
//assertNull(myTracksOverlay.getLastPath());
|
assertNull(myTracksOverlay.getLastPath());
|
||||||
|
|
||||||
final int waypoints = 10;
|
final int waypoints = 10;
|
||||||
for (int i = 0; i < waypoints; ++i) {
|
for (int i = 0; i < waypoints; ++i) {
|
||||||
@@ -192,7 +111,7 @@ public class MapOverlayTest extends AndroidTestCase {
|
|||||||
}
|
}
|
||||||
assertEquals(1 + waypoints, myTracksOverlay.getNumWaypoints());
|
assertEquals(1 + waypoints, myTracksOverlay.getNumWaypoints());
|
||||||
assertEquals(0, myTracksOverlay.getNumLocations());
|
assertEquals(0, myTracksOverlay.getNumLocations());
|
||||||
//assertNull(myTracksOverlay.getLastPath());
|
assertNull(myTracksOverlay.getLastPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClearWaypoints() throws Exception {
|
public void testClearWaypoints() throws Exception {
|
||||||
@@ -226,18 +145,18 @@ public class MapOverlayTest extends AndroidTestCase {
|
|||||||
// Shadow.
|
// Shadow.
|
||||||
myTracksOverlay.draw(canvas, mockView, true);
|
myTracksOverlay.draw(canvas, mockView, true);
|
||||||
// We don't expect to do anything if
|
// We don't expect to do anything if
|
||||||
//assertNull(myTracksOverlay.getLastPath());
|
assertNull(myTracksOverlay.getLastPath());
|
||||||
assertEquals(40, myTracksOverlay.getNumWaypoints());
|
assertEquals(40, myTracksOverlay.getNumWaypoints());
|
||||||
assertEquals(100, myTracksOverlay.getNumLocations());
|
assertEquals(100, myTracksOverlay.getNumLocations());
|
||||||
|
|
||||||
// No shadow.
|
// No shadow.
|
||||||
myTracksOverlay.draw(canvas, mockView, false);
|
myTracksOverlay.draw(canvas, mockView, false);
|
||||||
//assertNotNull(myTracksOverlay.getLastPath());
|
assertNotNull(myTracksOverlay.getLastPath());
|
||||||
//assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
|
assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
|
||||||
//MockPath path = (MockPath) myTracksOverlay.getLastPath();
|
MockPath path = (MockPath) myTracksOverlay.getLastPath();
|
||||||
assertEquals(40, myTracksOverlay.getNumWaypoints());
|
assertEquals(40, myTracksOverlay.getNumWaypoints());
|
||||||
assertEquals(100, myTracksOverlay.getNumLocations());
|
assertEquals(100, myTracksOverlay.getNumLocations());
|
||||||
//assertEquals(100, path.totalPoints);
|
assertEquals(100, path.totalPoints);
|
||||||
// TODO: Check the points from the path (and the segments).
|
// TODO: Check the points from the path (and the segments).
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 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
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.apps.mytracks;
|
||||||
|
|
||||||
|
import com.google.android.maps.MapView;
|
||||||
|
import com.google.android.maps.Projection;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Path;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Elements for Tests for the MyTracks map overlay.
|
||||||
|
*
|
||||||
|
* @author Bartlomiej Niechwiej
|
||||||
|
* @author Vangelis S.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A mock version of {@code MapOverlay} that does not use
|
||||||
|
* {@class MapView}.
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 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
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.apps.mytracks;
|
||||||
|
|
||||||
|
import android.graphics.Path;
|
||||||
|
import android.graphics.PointF;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Elements for Tests for the MyTracks map overlay.
|
||||||
|
*
|
||||||
|
* @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 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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 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
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.apps.mytracks;
|
||||||
|
|
||||||
|
import com.google.android.maps.GeoPoint;
|
||||||
|
import com.google.android.maps.Projection;
|
||||||
|
|
||||||
|
import android.graphics.Point;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Elements for Tests for the MyTracks map overlay.
|
||||||
|
*
|
||||||
|
* @author Bartlomiej Niechwiej
|
||||||
|
* @author Vangelis S.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 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
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.MockMyTracksOverlay;
|
||||||
|
import com.google.android.maps.MapView;
|
||||||
|
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for the MyTracks map overlay.
|
||||||
|
*
|
||||||
|
* @author Bartlomiej Niechwiej
|
||||||
|
* @author Vangelis S.
|
||||||
|
*/
|
||||||
|
public class TrackPathDescriptorsTest extends AndroidTestCase {
|
||||||
|
private Canvas canvas;
|
||||||
|
private MockMyTracksOverlay myTracksOverlay;
|
||||||
|
private MapView mockView;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
canvas = new Canvas();
|
||||||
|
myTracksOverlay = new MockMyTracksOverlay(getContext());
|
||||||
|
// Enable drawing.
|
||||||
|
myTracksOverlay.setTrackDrawingEnabled(true);
|
||||||
|
mockView = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSimpeColorTrackPathPainter() throws Exception {
|
||||||
|
Location location = new Location("gps");
|
||||||
|
location.setLatitude(10);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; ++i) {
|
||||||
|
location = new Location("gps");
|
||||||
|
location.setLatitude(20 + i / 2);
|
||||||
|
location.setLongitude(150 - i);
|
||||||
|
myTracksOverlay.addLocation(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackPathPainter painter = new SingleColorTrackPathPainter(getContext());
|
||||||
|
int startLocationIdx = 0;
|
||||||
|
Boolean alwaysVisible = true;
|
||||||
|
|
||||||
|
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||||
|
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||||
|
myTracksOverlay.getPoints());
|
||||||
|
painter.drawTrack(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFixedSpeedTrackPathDescriptor() throws Exception {
|
||||||
|
Location location = new Location("gps");
|
||||||
|
location.setLatitude(10);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; ++i) {
|
||||||
|
location = new Location("gps");
|
||||||
|
location.setLatitude(20 + i / 2);
|
||||||
|
location.setLongitude(150 - i);
|
||||||
|
myTracksOverlay.addLocation(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackPathPainter painter = new DynamicSpeedTrackPathPainter(getContext(), new FixedSpeedTrackPathDescriptor(getContext()));
|
||||||
|
int startLocationIdx = 0;
|
||||||
|
Boolean alwaysVisible = true;
|
||||||
|
|
||||||
|
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||||
|
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||||
|
myTracksOverlay.getPoints());
|
||||||
|
painter.drawTrack(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDynamicSpeedTrackPathDescriptor() throws Exception {
|
||||||
|
Location location = new Location("gps");
|
||||||
|
location.setLatitude(10);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; ++i) {
|
||||||
|
location = new Location("gps");
|
||||||
|
location.setLatitude(20 + i / 2);
|
||||||
|
location.setLongitude(150 - i);
|
||||||
|
myTracksOverlay.addLocation(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackPathPainter painter = new DynamicSpeedTrackPathPainter(getContext(), new DynamicSpeedTrackPathDescriptor(getContext()));
|
||||||
|
int startLocationIdx = 0;
|
||||||
|
Boolean alwaysVisible = true;
|
||||||
|
|
||||||
|
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||||
|
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||||
|
myTracksOverlay.getPoints());
|
||||||
|
painter.drawTrack(canvas);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user