Finishing Sandor's renaming.

This commit is contained in:
Rodrigo Damazio
2011-03-21 02:19:06 -07:00
parent 5870ba98b4
commit 818b42b97e
45 changed files with 264 additions and 244 deletions
+3 -3
View File
@@ -52,7 +52,7 @@ limitations under the License.
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="com.google.android.apps.mytracks.MyTracksMap" <activity android:name="com.google.android.apps.mytracks.MapActivity"
android:label="MyTracks" android:label="MyTracks"
android:exported="false" /> android:exported="false" />
@@ -73,7 +73,7 @@ limitations under the License.
<activity android:name="com.google.android.apps.mytracks.WaypointDetails" <activity android:name="com.google.android.apps.mytracks.WaypointDetails"
android:label="@string/waypointdetails_title" /> android:label="@string/waypointdetails_title" />
<activity android:name="com.google.android.apps.mytracks.MyTracksSettings" <activity android:name="com.google.android.apps.mytracks.SettingsActivity"
android:label="@string/mytracks_settings" /> android:label="@string/mytracks_settings" />
<activity android:name="com.google.android.apps.mytracks.AggregatedStatsActivity" <activity android:name="com.google.android.apps.mytracks.AggregatedStatsActivity"
@@ -101,7 +101,7 @@ limitations under the License.
android:exported="true" android:exported="true"
android:permission="com.google.android.apps.mytracks.WRITE_TRACK_DATA" /> android:permission="com.google.android.apps.mytracks.WRITE_TRACK_DATA" />
<receiver android:name="com.google.android.apps.mytracks.MyTracksReceiver"> <receiver android:name="com.google.android.apps.mytracks.BootReceiver">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter> </intent-filter>
@@ -67,7 +67,7 @@ public class AggregatedStatsActivity extends Activity implements
sv.setScrollBarStyle(ScrollView.SCROLLBARS_OUTSIDE_INSET); sv.setScrollBarStyle(ScrollView.SCROLLBARS_OUTSIDE_INSET);
SharedPreferences preferences = getSharedPreferences( SharedPreferences preferences = getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
if (preferences != null) { if (preferences != null) {
metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true); metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
preferences.registerOnSharedPreferenceChangeListener(this); preferences.registerOnSharedPreferenceChangeListener(this);
@@ -41,17 +41,17 @@ import android.util.Log;
* *
* @author Bartlomiej Niechwiej * @author Bartlomiej Niechwiej
*/ */
public class MyTracksReceiver extends BroadcastReceiver { public class BootReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Log.d(TAG, "MyTracksReceiver.onReceive: " + intent.getAction()); Log.d(TAG, "BootReceiver.onReceive: " + intent.getAction());
if (ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent startIntent = new Intent(context, TrackRecordingService.class); Intent startIntent = new Intent(context, TrackRecordingService.class);
startIntent.putExtra(RESUME_TRACK_EXTRA_NAME, true); startIntent.putExtra(RESUME_TRACK_EXTRA_NAME, true);
context.startService(startIntent); context.startService(startIntent);
} else { } else {
Log.w(TAG, "MyTracksReceiver: unsupported action"); Log.w(TAG, "BootReceiver: unsupported action");
} }
} }
} }
@@ -27,7 +27,7 @@ import com.google.android.apps.mytracks.services.StatusAnnouncerFactory;
import com.google.android.apps.mytracks.stats.DoubleBuffer; import com.google.android.apps.mytracks.stats.DoubleBuffer;
import com.google.android.apps.mytracks.stats.TripStatisticsBuilder; import com.google.android.apps.mytracks.stats.TripStatisticsBuilder;
import com.google.android.apps.mytracks.util.ApiFeatures; import com.google.android.apps.mytracks.util.ApiFeatures;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.apps.mytracks.util.UnitConversions; import com.google.android.apps.mytracks.util.UnitConversions;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -356,7 +356,7 @@ public class ChartActivity extends Activity implements TrackDataListener {
@Override @Override
public void onNewTrackPoint(Location loc) { public void onNewTrackPoint(Location loc) {
if (MyTracksUtils.isValidLocation(loc)) { if (LocationUtils.isValidLocation(loc)) {
double[] point = new double[6]; double[] point = new double[6];
fillDataPoint(loc, point); fillDataPoint(loc, point);
pendingPoints.add(point); pendingPoints.add(point);
@@ -78,7 +78,7 @@ class CheckUnits {
private static void accept(Context context, SharedPreferences preferences) { private static void accept(Context context, SharedPreferences preferences) {
recordCheckPerformed(preferences); recordCheckPerformed(preferences);
Intent startIntent = new Intent(context, MyTracksSettings.class); Intent startIntent = new Intent(context, SettingsActivity.class);
context.startActivity(startIntent); context.startActivity(startIntent);
} }
@@ -222,6 +222,20 @@ public abstract class Constants {
public static final String MAPSHOP_BASE_URL = public static final String MAPSHOP_BASE_URL =
"http://maps.google.com/maps/ms"; "http://maps.google.com/maps/ms";
/*
* Default values - keep in sync with those in preferences.xml.
*/
public static final int DEFAULT_ANNOUNCEMENT_FREQUENCY = -1;
public static final int DEFAULT_AUTO_RESUME_TRACK_TIMEOUT = 10; // In min.
public static final int DEFAULT_MAX_RECORDING_DISTANCE = 200;
public static final int DEFAULT_MIN_RECORDING_DISTANCE = 5;
public static final int DEFAULT_MIN_RECORDING_INTERVAL = 0;
public static final int DEFAULT_MIN_REQUIRED_ACCURACY = 200;
public static final int DEFAULT_SPLIT_FREQUENCY = 0;
public static final String SETTINGS_NAME = "SettingsActivity";
/** /**
* This is an abstract utility class. * This is an abstract utility class.
*/ */
@@ -61,7 +61,7 @@ public class DeleteAllTracks extends Handler {
Log.w(Constants.TAG, "deleting all!"); Log.w(Constants.TAG, "deleting all!");
MyTracksProviderUtils.Factory.get(context).deleteAllTracks(); MyTracksProviderUtils.Factory.get(context).deleteAllTracks();
SharedPreferences prefs = SharedPreferences prefs =
context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
SharedPreferences.Editor editor = prefs.edit(); SharedPreferences.Editor editor = prefs.edit();
// TODO: Go through data manager // TODO: Go through data manager
editor.putLong(context.getString(R.string.selected_track_key), -1); editor.putLong(context.getString(R.string.selected_track_key), -1);
@@ -20,7 +20,7 @@ import com.google.android.apps.mytracks.content.TracksColumns;
import com.google.android.apps.mytracks.io.TrackWriter; import com.google.android.apps.mytracks.io.TrackWriter;
import com.google.android.apps.mytracks.io.TrackWriterFactory; import com.google.android.apps.mytracks.io.TrackWriterFactory;
import com.google.android.apps.mytracks.io.TrackWriterFactory.TrackFileFormat; import com.google.android.apps.mytracks.io.TrackWriterFactory.TrackFileFormat;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.app.Activity; import android.app.Activity;
@@ -113,14 +113,14 @@ public class ExportAllTracks {
*/ */
private void aquireLocksAndExport() { private void aquireLocksAndExport() {
SharedPreferences prefs = SharedPreferences prefs =
activity.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); activity.getSharedPreferences(Constants.SETTINGS_NAME, 0);
long recordingTrackId = -1; long recordingTrackId = -1;
if (prefs != null) { if (prefs != null) {
recordingTrackId = recordingTrackId =
prefs.getLong(activity.getString(R.string.recording_track_key), -1); prefs.getLong(activity.getString(R.string.recording_track_key), -1);
} }
if (recordingTrackId != -1) { if (recordingTrackId != -1) {
wakeLock = MyTracksUtils.acquireWakeLock(activity, wakeLock); wakeLock = SystemUtils.acquireWakeLock(activity, wakeLock);
} }
// Now we can safely export everything. // Now we can safely export everything.
@@ -18,7 +18,7 @@ package com.google.android.apps.mytracks;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.io.GpxImporter; import com.google.android.apps.mytracks.io.GpxImporter;
import com.google.android.apps.mytracks.util.FileUtils; import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.app.Activity; import android.app.Activity;
@@ -82,13 +82,13 @@ public class ImportAllTracks {
* track. Acquire a wake lock if there is no current track. * track. Acquire a wake lock if there is no current track.
*/ */
private void aquireLocksAndImport() { private void aquireLocksAndImport() {
SharedPreferences prefs = activity.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); SharedPreferences prefs = activity.getSharedPreferences(Constants.SETTINGS_NAME, 0);
long recordingTrackId = -1; long recordingTrackId = -1;
if (prefs != null) { if (prefs != null) {
recordingTrackId = prefs.getLong(activity.getString(R.string.recording_track_key), -1); recordingTrackId = prefs.getLong(activity.getString(R.string.recording_track_key), -1);
} }
if (recordingTrackId != -1) { if (recordingTrackId != -1) {
wakeLock = MyTracksUtils.acquireWakeLock(activity, wakeLock); wakeLock = SystemUtils.acquireWakeLock(activity, wakeLock);
} }
// Now we can safely import everything. // Now we can safely import everything.
@@ -24,9 +24,8 @@ import com.google.android.apps.mytracks.services.StatusAnnouncerFactory;
import com.google.android.apps.mytracks.stats.TripStatistics; import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.ApiFeatures; import com.google.android.apps.mytracks.util.ApiFeatures;
import com.google.android.apps.mytracks.util.GeoRect; import com.google.android.apps.mytracks.util.GeoRect;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController; import com.google.android.maps.MapController;
import com.google.android.maps.MapView; import com.google.android.maps.MapView;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -56,7 +55,7 @@ import android.widget.TextView;
* @author Leif Hendrik Wilden * @author Leif Hendrik Wilden
* @author Rodrigo Damazio * @author Rodrigo Damazio
*/ */
public class MyTracksMap extends MapActivity public class MapActivity extends com.google.android.maps.MapActivity
implements View.OnTouchListener, View.OnClickListener, implements View.OnTouchListener, View.OnClickListener,
TrackDataListener { TrackDataListener {
@@ -85,7 +84,7 @@ public class MyTracksMap extends MapActivity
private RelativeLayout screen; private RelativeLayout screen;
private MapView mapView; private MapView mapView;
private MyTracksOverlay mapOverlay; private MapOverlay mapOverlay;
private LinearLayout messagePane; private LinearLayout messagePane;
private TextView messageText; private TextView messageText;
private LinearLayout busyPane; private LinearLayout busyPane;
@@ -118,7 +117,7 @@ public class MyTracksMap extends MapActivity
@Override @Override
public void onCreate(Bundle bundle) { public void onCreate(Bundle bundle) {
Log.d(TAG, "MyTracksMap.onCreate"); Log.d(TAG, "MapActivity.onCreate");
super.onCreate(bundle); super.onCreate(bundle);
// The volume we want to control is the Text-To-Speech volume // The volume we want to control is the Text-To-Speech volume
@@ -141,7 +140,7 @@ public class MyTracksMap extends MapActivity
screen = (RelativeLayout) findViewById(R.id.screen); screen = (RelativeLayout) findViewById(R.id.screen);
mapView = (MapView) findViewById(R.id.map); mapView = (MapView) findViewById(R.id.map);
mapView.requestFocus(); mapView.requestFocus();
mapOverlay = new MyTracksOverlay(this); mapOverlay = new MapOverlay(this);
mapView.getOverlays().add(mapOverlay); mapView.getOverlays().add(mapOverlay);
mapView.setOnTouchListener(this); mapView.setOnTouchListener(this);
mapView.setBuiltInZoomControls(true); mapView.setBuiltInZoomControls(true);
@@ -156,7 +155,7 @@ public class MyTracksMap extends MapActivity
@Override @Override
protected void onRestoreInstanceState(Bundle bundle) { protected void onRestoreInstanceState(Bundle bundle) {
Log.d(TAG, "MyTracksMap.onRestoreInstanceState"); Log.d(TAG, "MapActivity.onRestoreInstanceState");
if (bundle != null) { if (bundle != null) {
super.onRestoreInstanceState(bundle); super.onRestoreInstanceState(bundle);
keepMyLocationVisible = keepMyLocationVisible =
@@ -174,7 +173,7 @@ public class MyTracksMap extends MapActivity
@Override @Override
protected void onStart() { protected void onStart() {
Log.d(TAG, "MyTracksMap.onStart"); Log.d(TAG, "MapActivity.onStart");
super.onStart(); super.onStart();
dataHub.registerTrackDataListener(this); dataHub.registerTrackDataListener(this);
@@ -182,7 +181,7 @@ public class MyTracksMap extends MapActivity
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
Log.d(TAG, "MyTracksMap.onSaveInstanceState"); Log.d(TAG, "MapActivity.onSaveInstanceState");
outState.putBoolean(KEY_KEEP_MY_LOCATION_VISIBLE, keepMyLocationVisible); outState.putBoolean(KEY_KEEP_MY_LOCATION_VISIBLE, keepMyLocationVisible);
if (currentLocation != null) { if (currentLocation != null) {
outState.putParcelable(KEY_CURRENT_LOCATION, currentLocation); outState.putParcelable(KEY_CURRENT_LOCATION, currentLocation);
@@ -192,7 +191,7 @@ public class MyTracksMap extends MapActivity
@Override @Override
protected void onStop() { protected void onStop() {
Log.d(TAG, "MyTracksMap.onStop"); Log.d(TAG, "MapActivity.onStop");
dataHub.unregisterTrackDataListener(this); dataHub.unregisterTrackDataListener(this);
@@ -236,7 +235,7 @@ public class MyTracksMap extends MapActivity
GeoRect r = new GeoRect(center, latSpan, lonSpan); GeoRect r = new GeoRect(center, latSpan, lonSpan);
r.top += margin; r.top += margin;
GeoPoint geoPoint = MyTracksUtils.getGeoPoint(location); GeoPoint geoPoint = LocationUtils.getGeoPoint(location);
return r.contains(geoPoint); return r.contains(geoPoint);
} }
@@ -251,7 +250,7 @@ public class MyTracksMap extends MapActivity
mapOverlay.setMyLocation(currentLocation); mapOverlay.setMyLocation(currentLocation);
mapView.postInvalidate(); mapView.postInvalidate();
if (keepMyLocationVisible && !locationIsVisible(currentLocation)) { if (keepMyLocationVisible && !locationIsVisible(currentLocation)) {
GeoPoint geoPoint = MyTracksUtils.getGeoPoint(currentLocation); GeoPoint geoPoint = LocationUtils.getGeoPoint(currentLocation);
MapController controller = mapView.getController(); MapController controller = mapView.getController();
controller.animateTo(geoPoint); controller.animateTo(geoPoint);
} }
@@ -290,7 +289,7 @@ public class MyTracksMap extends MapActivity
GeoPoint center = new GeoPoint( GeoPoint center = new GeoPoint(
bottom + latSpanE6 / 2, bottom + latSpanE6 / 2,
left + lonSpanE6 / 2); left + lonSpanE6 / 2);
if (MyTracksUtils.isValidGeoPoint(center)) { if (LocationUtils.isValidGeoPoint(center)) {
mapView.getController().setCenter(center); mapView.getController().setCenter(center);
mapView.getController().zoomToSpan(latSpanE6, lonSpanE6); mapView.getController().zoomToSpan(latSpanE6, lonSpanE6);
} }
@@ -482,7 +481,7 @@ public class MyTracksMap extends MapActivity
messagePane.setVisibility(View.VISIBLE); messagePane.setVisibility(View.VISIBLE);
if (bindClick) { if (bindClick) {
messagePane.setOnClickListener(MyTracksMap.this); messagePane.setOnClickListener(MapActivity.this);
} else { } else {
messagePane.setOnClickListener(null); messagePane.setOnClickListener(null);
} }
@@ -499,7 +498,7 @@ public class MyTracksMap extends MapActivity
public void onCurrentLocationChanged(Location location) { public void onCurrentLocationChanged(Location location) {
if (!location.getProvider().equals(Constants.GPS_PROVIDER)) { if (!location.getProvider().equals(Constants.GPS_PROVIDER)) {
Log.d(TAG, Log.d(TAG,
"MyTracksMap: Network location update received (provider '" + location.getProvider() + "'."); "MapActivity: Network location update received (provider '" + location.getProvider() + "'.");
} }
currentLocation = location; currentLocation = location;
@@ -522,7 +521,7 @@ public class MyTracksMap extends MapActivity
@Override @Override
public void onNewWaypoint(Waypoint waypoint) { public void onNewWaypoint(Waypoint waypoint) {
if (MyTracksUtils.isValidLocation(waypoint.getLocation())) { if (LocationUtils.isValidLocation(waypoint.getLocation())) {
// TODO: Optimize locking inside addWaypoint // TODO: Optimize locking inside addWaypoint
mapOverlay.addWaypoint(waypoint); mapOverlay.addWaypoint(waypoint);
} }
@@ -16,7 +16,7 @@
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.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView; import com.google.android.maps.MapView;
import com.google.android.maps.Overlay; import com.google.android.maps.Overlay;
@@ -45,7 +45,7 @@ import java.util.concurrent.BlockingQueue;
* *
* @author Leif Hendrik Wilden * @author Leif Hendrik Wilden
*/ */
public class MyTracksOverlay extends Overlay { public class MapOverlay extends Overlay {
private final Drawable[] arrows; private final Drawable[] arrows;
private final int arrowWidth, arrowHeight; private final int arrowWidth, arrowHeight;
@@ -92,12 +92,12 @@ public class MyTracksOverlay extends Overlay {
* Constructor for a potentially valid cached location. * Constructor for a potentially valid cached location.
*/ */
public CachedLocation(Location location) { public CachedLocation(Location location) {
this.valid = MyTracksUtils.isValidLocation(location); this.valid = LocationUtils.isValidLocation(location);
this.geoPoint = valid ? MyTracksUtils.getGeoPoint(location) : null; this.geoPoint = valid ? LocationUtils.getGeoPoint(location) : null;
} }
}; };
public MyTracksOverlay(Context context) { public MapOverlay(Context context) {
this.context = context; this.context = context;
this.waypoints = new ArrayList<Waypoint>(); this.waypoints = new ArrayList<Waypoint>();
@@ -278,7 +278,7 @@ public class MyTracksOverlay extends Overlay {
synchronized (waypoints) {; synchronized (waypoints) {;
for (Waypoint wpt : waypoints) { for (Waypoint wpt : waypoints) {
Location loc = wpt.getLocation(); Location loc = wpt.getLocation();
drawElement(canvas, projection, MyTracksUtils.getGeoPoint(loc), drawElement(canvas, projection, LocationUtils.getGeoPoint(loc),
wpt.getType() == Waypoint.TYPE_STATISTICS ? statsMarker wpt.getType() == Waypoint.TYPE_STATISTICS ? statsMarker
: waypointMarker, -(markerWidth / 2) + 3, -markerHeight); : waypointMarker, -(markerWidth / 2) + 3, -markerHeight);
} }
@@ -292,7 +292,7 @@ public class MyTracksOverlay extends Overlay {
} }
Point pt = drawElement(canvas, projection, Point pt = drawElement(canvas, projection,
MyTracksUtils.getGeoPoint(myLocation), arrows[lastHeading], LocationUtils.getGeoPoint(myLocation), arrows[lastHeading],
-(arrowWidth / 2) + 3, -(arrowHeight / 2)); -(arrowWidth / 2) + 3, -(arrowHeight / 2));
// Draw the error circle. // Draw the error circle.
float radius = projection.metersToEquatorPixels(myLocation.getAccuracy()); float radius = projection.metersToEquatorPixels(myLocation.getAccuracy());
@@ -441,7 +441,7 @@ public class MyTracksOverlay extends Overlay {
return false; return false;
} }
final Location tapLocation = MyTracksUtils.getLocation(p); final Location tapLocation = LocationUtils.getLocation(p);
double dmin = Double.MAX_VALUE; double dmin = Double.MAX_VALUE;
Waypoint waypoint = null; Waypoint waypoint = null;
synchronized (waypoints) { synchronized (waypoints) {
@@ -78,7 +78,7 @@ class MenuManager {
return startActivity(SensorStateActivity.class); return startActivity(SensorStateActivity.class);
} }
case R.id.menu_settings: { case R.id.menu_settings: {
return startActivity(MyTracksSettings.class); return startActivity(SettingsActivity.class);
} }
case R.id.menu_aggregated_stats: { case R.id.menu_aggregated_stats: {
return startActivity(AggregatedStatsActivity.class); return startActivity(AggregatedStatsActivity.class);
@@ -47,7 +47,7 @@ import com.google.android.apps.mytracks.services.StatusAnnouncerFactory;
import com.google.android.apps.mytracks.services.TrackRecordingService; import com.google.android.apps.mytracks.services.TrackRecordingService;
import com.google.android.apps.mytracks.util.ApiFeatures; import com.google.android.apps.mytracks.util.ApiFeatures;
import com.google.android.apps.mytracks.util.FileUtils; import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.app.Activity; import android.app.Activity;
@@ -246,14 +246,14 @@ public class MyTracks extends TabActivity implements OnTouchListener,
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
instance = this; instance = this;
ApiFeatures apiFeatures = ApiFeatures.getInstance(); ApiFeatures apiFeatures = ApiFeatures.getInstance();
if (!MyTracksUtils.isRelease(this)) { if (!SystemUtils.isRelease(this)) {
apiFeatures.getApiPlatformAdapter().enableStrictMode(); apiFeatures.getApiPlatformAdapter().enableStrictMode();
} }
providerUtils = MyTracksProviderUtils.Factory.get(this); providerUtils = MyTracksProviderUtils.Factory.get(this);
dataHub = new TrackDataHub(this, providerUtils); dataHub = new TrackDataHub(this, providerUtils);
menuManager = new MenuManager(this); menuManager = new MenuManager(this);
sharedPreferences = getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, 0);
dialogManager = new DialogManager(this); dialogManager = new DialogManager(this);
// The volume we want to control is the Text-To-Speech volume // The volume we want to control is the Text-To-Speech volume
@@ -269,7 +269,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
tabHost.addTab(tabHost.newTabSpec("tab1") tabHost.addTab(tabHost.newTabSpec("tab1")
.setIndicator("Map", res.getDrawable( .setIndicator("Map", res.getDrawable(
android.R.drawable.ic_menu_mapmode)) android.R.drawable.ic_menu_mapmode))
.setContent(new Intent(this, MyTracksMap.class))); .setContent(new Intent(this, MapActivity.class)));
tabHost.addTab(tabHost.newTabSpec("tab2") tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("Stats", res.getDrawable(R.drawable.menu_stats)) .setIndicator("Stats", res.getDrawable(R.drawable.menu_stats))
.setContent(new Intent(this, StatsActivity.class))); .setContent(new Intent(this, StatsActivity.class)));
@@ -462,8 +462,8 @@ public class MyTracks extends TabActivity implements OnTouchListener,
if (results != null) { if (results != null) {
final long waypointId = results.getLongExtra("waypointid", -1); final long waypointId = results.getLongExtra("waypointid", -1);
if (waypointId >= 0) { if (waypointId >= 0) {
MyTracksMap map = MapActivity map =
(MyTracksMap) getLocalActivityManager().getActivity("tab1"); (MapActivity) getLocalActivityManager().getActivity("tab1");
if (map != null) { if (map != null) {
getTabHost().setCurrentTab(0); getTabHost().setCurrentTab(0);
map.showWaypoint(waypointId); map.showWaypoint(waypointId);
@@ -54,28 +54,14 @@ import java.util.Set;
* @author Leif Hendrik Wilden * @author Leif Hendrik Wilden
* @author Rodrigo Damazio * @author Rodrigo Damazio
*/ */
public class MyTracksSettings extends PreferenceActivity { public class SettingsActivity extends PreferenceActivity {
public static final String SETTINGS_NAME = "MyTracksSettings";
/*
* Default values - keep in sync with those in preferences.xml.
*/
public static final int DEFAULT_AUTO_RESUME_TRACK_TIMEOUT = 10; // In min.
public static final int DEFAULT_ANNOUNCEMENT_FREQUENCY = -1;
public static final int DEFAULT_MAX_RECORDING_DISTANCE = 200;
public static final int DEFAULT_MIN_RECORDING_DISTANCE = 5;
public static final int DEFAULT_MIN_RECORDING_INTERVAL = 0;
public static final int DEFAULT_MIN_REQUIRED_ACCURACY = 200;
public static final int DEFAULT_SPLIT_FREQUENCY = 0;
private BackupPreferencesListener backupListener; private BackupPreferencesListener backupListener;
private SharedPreferences preferences; private SharedPreferences preferences;
/** Called when the activity is first created. */ /** Called when the activity is first created. */
@Override @Override
public void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
// The volume we want to control is the Text-To-Speech volume // The volume we want to control is the Text-To-Speech volume
@@ -86,7 +72,7 @@ public class MyTracksSettings extends PreferenceActivity {
// Tell it where to read/write preferences // Tell it where to read/write preferences
PreferenceManager preferenceManager = getPreferenceManager(); PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setSharedPreferencesName(SETTINGS_NAME); preferenceManager.setSharedPreferencesName(Constants.SETTINGS_NAME);
preferenceManager.setSharedPreferencesMode(0); preferenceManager.setSharedPreferencesMode(0);
// Set up automatic preferences backup // Set up automatic preferences backup
@@ -219,7 +205,7 @@ public class MyTracksSettings extends PreferenceActivity {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
BackupActivityHelper backupHelper = BackupActivityHelper backupHelper =
new BackupActivityHelper(MyTracksSettings.this); new BackupActivityHelper(SettingsActivity.this);
backupHelper.writeBackup(); backupHelper.writeBackup();
return true; return true;
} }
@@ -229,7 +215,7 @@ public class MyTracksSettings extends PreferenceActivity {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
BackupActivityHelper backupHelper = BackupActivityHelper backupHelper =
new BackupActivityHelper(MyTracksSettings.this); new BackupActivityHelper(SettingsActivity.this);
backupHelper.restoreBackup(); backupHelper.restoreBackup();
return true; return true;
} }
@@ -373,7 +359,7 @@ public class MyTracksSettings extends PreferenceActivity {
public void run() { public void run() {
// Give feedback to the user. // Give feedback to the user.
Toast.makeText( Toast.makeText(
MyTracksSettings.this, SettingsActivity.this,
R.string.settings_reset_done, R.string.settings_reset_done,
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
@@ -27,7 +27,7 @@ import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.content.WaypointsColumns; import com.google.android.apps.mytracks.content.WaypointsColumns;
import com.google.android.apps.mytracks.services.TrackRecordingService; import com.google.android.apps.mytracks.services.TrackRecordingService;
import com.google.android.apps.mytracks.util.ApiFeatures; import com.google.android.apps.mytracks.util.ApiFeatures;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.content.ContentResolver; import android.content.ContentResolver;
@@ -251,7 +251,7 @@ public class TrackDataHub {
listenerHandlerThread.start(); listenerHandlerThread.start();
listenerHandler = new Handler(listenerHandlerThread.getLooper()); listenerHandler = new Handler(listenerHandlerThread.getLooper());
sharedPreferences = ctx.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); sharedPreferences = ctx.getSharedPreferences(Constants.SETTINGS_NAME, 0);
preferenceListener = new HubSharedPreferenceListener(); preferenceListener = new HubSharedPreferenceListener();
sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE); sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
@@ -286,7 +286,7 @@ public class TrackDataHub {
useMetricUnits = sharedPreferences.getBoolean(METRIC_UNITS_KEY, true); useMetricUnits = sharedPreferences.getBoolean(METRIC_UNITS_KEY, true);
reportSpeed = sharedPreferences.getBoolean(SPEED_REPORTING_KEY, true); reportSpeed = sharedPreferences.getBoolean(SPEED_REPORTING_KEY, true);
minRequiredAccuracy = sharedPreferences.getInt(MIN_REQUIRED_ACCURACY_KEY, minRequiredAccuracy = sharedPreferences.getInt(MIN_REQUIRED_ACCURACY_KEY,
MyTracksSettings.DEFAULT_MIN_REQUIRED_ACCURACY); Constants.DEFAULT_MIN_REQUIRED_ACCURACY);
if (recordingTrackId > 0) { if (recordingTrackId > 0) {
Intent startIntent = new Intent(context, TrackRecordingService.class); Intent startIntent = new Intent(context, TrackRecordingService.class);
@@ -608,7 +608,7 @@ public class TrackDataHub {
recordingTrackId = sharedPreferences.getLong(RECORDING_TRACK_KEY, -1); recordingTrackId = sharedPreferences.getLong(RECORDING_TRACK_KEY, -1);
} else if (key.equals(MIN_REQUIRED_ACCURACY_KEY)) { } else if (key.equals(MIN_REQUIRED_ACCURACY_KEY)) {
minRequiredAccuracy = sharedPreferences.getInt(RECORDING_TRACK_KEY, minRequiredAccuracy = sharedPreferences.getInt(RECORDING_TRACK_KEY,
MyTracksSettings.DEFAULT_MIN_REQUIRED_ACCURACY); Constants.DEFAULT_MIN_REQUIRED_ACCURACY);
} else if (key.equals(METRIC_UNITS_KEY)) { } else if (key.equals(METRIC_UNITS_KEY)) {
useMetricUnits = sharedPreferences.getBoolean(METRIC_UNITS_KEY, true); useMetricUnits = sharedPreferences.getBoolean(METRIC_UNITS_KEY, true);
notifyUnitsChanged(); notifyUnitsChanged();
@@ -805,7 +805,7 @@ public class TrackDataHub {
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
do { do {
Waypoint waypoint = providerUtils.createWaypoint(cursor); Waypoint waypoint = providerUtils.createWaypoint(cursor);
if (!MyTracksUtils.isValidLocation(waypoint.getLocation())) { if (!LocationUtils.isValidLocation(waypoint.getLocation())) {
continue; continue;
} }
@@ -964,7 +964,7 @@ public class TrackDataHub {
int numLoadedPoints, int numLoadedPoints,
int pointSamplingFrequency, int pointSamplingFrequency,
TrackDataListener[] listeners) { TrackDataListener[] listeners) {
boolean isValid = MyTracksUtils.isValidLocation(location); boolean isValid = LocationUtils.isValidLocation(location);
if (isValid) { if (isValid) {
// Include a point if it fits one of the following criteria: // Include a point if it fits one of the following criteria:
// - Has the mod for the sampling frequency (includes first point). // - Has the mod for the sampling frequency (includes first point).
@@ -202,7 +202,7 @@ public class TrackList extends ListActivity
findViewById(R.id.tracklist_btn_import_all).setOnClickListener(this); findViewById(R.id.tracklist_btn_import_all).setOnClickListener(this);
SharedPreferences preferences = SharedPreferences preferences =
getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); getSharedPreferences(Constants.SETTINGS_NAME, 0);
preferences.registerOnSharedPreferenceChangeListener(this); preferences.registerOnSharedPreferenceChangeListener(this);
metricUnits = metricUnits =
preferences.getBoolean(getString(R.string.metric_units_key), true); preferences.getBoolean(getString(R.string.metric_units_key), true);
@@ -65,7 +65,7 @@ public class WaypointDetails extends Activity
utils = new StatsUtilities(this); utils = new StatsUtilities(this);
SharedPreferences preferences = SharedPreferences preferences =
getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); getSharedPreferences(Constants.SETTINGS_NAME, 0);
if (preferences != null) { if (preferences != null) {
boolean useMetric = boolean useMetric =
preferences.getBoolean(getString(R.string.metric_units_key), true); preferences.getBoolean(getString(R.string.metric_units_key), true);
@@ -138,7 +138,7 @@ public class WaypointsList extends ListActivity
(Button) findViewById(R.id.waypointslist_btn_insert_statistics); (Button) findViewById(R.id.waypointslist_btn_insert_statistics);
insertStatisticsButton.setOnClickListener(this); insertStatisticsButton.setOnClickListener(this);
SharedPreferences preferences = SharedPreferences preferences =
getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); getSharedPreferences(Constants.SETTINGS_NAME, 0);
// TODO: Get rid of selected and recording track IDs // TODO: Get rid of selected and recording track IDs
long selectedTrackId = -1; long selectedTrackId = -1;
@@ -15,7 +15,7 @@
*/ */
package com.google.android.apps.mytracks; package com.google.android.apps.mytracks;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.app.Activity; import android.app.Activity;
@@ -82,6 +82,6 @@ public class WelcomeActivity extends Activity {
AlertDialog dialog = builder.create(); AlertDialog dialog = builder.create();
dialog.show(); dialog.show();
((TextView) dialog.findViewById(R.id.about_version_register)). ((TextView) dialog.findViewById(R.id.about_version_register)).
setText(MyTracksUtils.getMyTracksVersion(this)); setText(SystemUtils.getMyTracksVersion(this));
} }
} }
@@ -19,7 +19,7 @@ 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.TripStatisticsBuilder; import com.google.android.apps.mytracks.stats.TripStatisticsBuilder;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.apps.mytracks.util.StringUtils; import com.google.android.apps.mytracks.util.StringUtils;
import android.location.Location; import android.location.Location;
@@ -362,7 +362,7 @@ public class GpxImporter extends DefaultHandler {
* @throws SAXException - thrown if track point is invalid * @throws SAXException - thrown if track point is invalid
*/ */
private void onTrackPointElementEnd() throws SAXException { private void onTrackPointElementEnd() throws SAXException {
if (MyTracksUtils.isValidLocation(location)) { if (LocationUtils.isValidLocation(location)) {
if (statsBuilder == null) { if (statsBuilder == null) {
// first point did not have a time, start stats builder without it // first point did not have a time, start stats builder without it
statsBuilder = new TripStatisticsBuilder(0); statsBuilder = new TripStatisticsBuilder(0);
@@ -17,7 +17,6 @@ package com.google.android.apps.mytracks.io;
import com.google.android.apps.mytracks.MyTracks; import com.google.android.apps.mytracks.MyTracks;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
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.io.docs.DocsHelper; import com.google.android.apps.mytracks.io.docs.DocsHelper;
@@ -73,7 +72,7 @@ public class SendToDocs {
this.trackId = trackId; this.trackId = trackId;
SharedPreferences preferences = activity.getSharedPreferences( SharedPreferences preferences = activity.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
if (preferences != null) { if (preferences != null) {
metricUnits = metricUnits =
preferences.getBoolean(activity.getString(R.string.metric_units_key), preferences.getBoolean(activity.getString(R.string.metric_units_key),
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.io; package com.google.android.apps.mytracks.io;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.apps.mytracks.ProgressIndicator; import com.google.android.apps.mytracks.ProgressIndicator;
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;
@@ -25,8 +24,9 @@ import com.google.android.apps.mytracks.io.gdata.GDataWrapper;
import com.google.android.apps.mytracks.io.gdata.GDataWrapper.QueryFunction; import com.google.android.apps.mytracks.io.gdata.GDataWrapper.QueryFunction;
import com.google.android.apps.mytracks.stats.DoubleBuffer; import com.google.android.apps.mytracks.stats.DoubleBuffer;
import com.google.android.apps.mytracks.stats.TripStatistics; import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.apps.mytracks.util.StringUtils; import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.apps.mytracks.util.UnitConversions; import com.google.android.apps.mytracks.util.UnitConversions;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import com.google.api.client.googleapis.GoogleHeaders; import com.google.api.client.googleapis.GoogleHeaders;
@@ -141,7 +141,7 @@ public class SendToFusionTables implements Runnable {
this.providerUtils = MyTracksProviderUtils.Factory.get(context); this.providerUtils = MyTracksProviderUtils.Factory.get(context);
GoogleHeaders headers = new GoogleHeaders(); GoogleHeaders headers = new GoogleHeaders();
headers.setApplicationName("Google-MyTracks-" + MyTracksUtils.getMyTracksVersion(context)); headers.setApplicationName("Google-MyTracks-" + SystemUtils.getMyTracksVersion(context));
headers.gdataVersion = GDATA_VERSION; headers.gdataVersion = GDATA_VERSION;
transport = new HttpTransport(); transport = new HttpTransport();
@@ -296,7 +296,7 @@ public class SendToFusionTables implements Runnable {
private boolean uploadAllTrackPoints(final Track track, String originalDescription) { private boolean uploadAllTrackPoints(final Track track, String originalDescription) {
SharedPreferences preferences = context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); SharedPreferences preferences = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
boolean metricUnits = true; boolean metricUnits = true;
if (preferences != null) { if (preferences != null) {
metricUnits = preferences.getBoolean(context.getString(R.string.metric_units_key), true); metricUnits = preferences.getBoolean(context.getString(R.string.metric_units_key), true);
@@ -344,7 +344,7 @@ public class SendToFusionTables implements Runnable {
} }
// Add to the elevation profile. // Add to the elevation profile.
if (loc != null && MyTracksUtils.isValidLocation(loc)) { if (loc != null && LocationUtils.isValidLocation(loc)) {
// All points go into the smoothing buffer... // All points go into the smoothing buffer...
elevationBuffer.setNext(metricUnits ? loc.getAltitude() elevationBuffer.setNext(metricUnits ? loc.getAltitude()
: loc.getAltitude() * UnitConversions.M_TO_FT); : loc.getAltitude() * UnitConversions.M_TO_FT);
@@ -566,12 +566,12 @@ public class SendToFusionTables implements Runnable {
* Decimate to 2 meter precision. Fusion tables doesn't like too many * Decimate to 2 meter precision. Fusion tables doesn't like too many
* points: * points:
*/ */
MyTracksUtils.decimate(segment, 2.0); LocationUtils.decimate(segment, 2.0);
/* If the track still has > 2500 points, split it in pieces: */ /* If the track still has > 2500 points, split it in pieces: */
final int maxPoints = 2500; final int maxPoints = 2500;
if (segment.getLocations().size() > maxPoints) { if (segment.getLocations().size() > maxPoints) {
splitTracks.addAll(MyTracksUtils.split(segment, maxPoints)); splitTracks.addAll(LocationUtils.split(segment, maxPoints));
} else if (segment.getLocations().size() >= 2) { } else if (segment.getLocations().size() >= 2) {
splitTracks.add(segment); splitTracks.add(segment);
} }
@@ -17,7 +17,6 @@ package com.google.android.apps.mytracks.io;
import static com.google.android.apps.mytracks.Constants.TAG; import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.apps.mytracks.ProgressIndicator; import com.google.android.apps.mytracks.ProgressIndicator;
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;
@@ -25,7 +24,7 @@ import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.io.mymaps.MapsFacade; import com.google.android.apps.mytracks.io.mymaps.MapsFacade;
import com.google.android.apps.mytracks.stats.DoubleBuffer; import com.google.android.apps.mytracks.stats.DoubleBuffer;
import com.google.android.apps.mytracks.stats.TripStatistics; import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.apps.mytracks.util.StringUtils; import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.apps.mytracks.util.UnitConversions; import com.google.android.apps.mytracks.util.UnitConversions;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -117,7 +116,7 @@ public class SendToMyMaps implements Runnable {
boolean isNewMap = mapId.equals(NEW_MAP_ID); boolean isNewMap = mapId.equals(NEW_MAP_ID);
if (isNewMap) { if (isNewMap) {
SharedPreferences preferences = context.getSharedPreferences( SharedPreferences preferences = context.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
boolean mapPublic = true; boolean mapPublic = true;
if (preferences != null) { if (preferences != null) {
mapPublic = preferences.getBoolean( mapPublic = preferences.getBoolean(
@@ -196,7 +195,7 @@ public class SendToMyMaps implements Runnable {
private boolean uploadAllTrackPoints( private boolean uploadAllTrackPoints(
final Track track, String originalDescription) { final Track track, String originalDescription) {
SharedPreferences preferences = context.getSharedPreferences( SharedPreferences preferences = context.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
boolean metricUnits = true; boolean metricUnits = true;
if (preferences != null) { if (preferences != null) {
metricUnits = metricUnits =
@@ -249,7 +248,7 @@ public class SendToMyMaps implements Runnable {
} }
// Add to the elevation profile. // Add to the elevation profile.
if (loc != null && MyTracksUtils.isValidLocation(loc)) { if (loc != null && LocationUtils.isValidLocation(loc)) {
// All points go into the smoothing buffer... // All points go into the smoothing buffer...
elevationBuffer.setNext(metricUnits ? loc.getAltitude() elevationBuffer.setNext(metricUnits ? loc.getAltitude()
: loc.getAltitude() * UnitConversions.M_TO_FT); : loc.getAltitude() * UnitConversions.M_TO_FT);
@@ -431,11 +430,11 @@ public class SendToMyMaps implements Runnable {
* Decimate to 2 meter precision. Mapshop doesn't like too many * Decimate to 2 meter precision. Mapshop doesn't like too many
* points: * points:
*/ */
MyTracksUtils.decimate(segment, 2.0); LocationUtils.decimate(segment, 2.0);
/* It the track still has > 500 points, split it in pieces: */ /* It the track still has > 500 points, split it in pieces: */
if (segment.getLocations().size() > 500) { if (segment.getLocations().size() > 500) {
splitTracks.addAll(MyTracksUtils.split(segment, 500)); splitTracks.addAll(LocationUtils.split(segment, 500));
} else if (segment.getLocations().size() >= 2) { } else if (segment.getLocations().size() >= 2) {
splitTracks.add(segment); splitTracks.add(segment);
} }
@@ -21,7 +21,7 @@ import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.io.TrackWriterFactory.TrackFileFormat; import com.google.android.apps.mytracks.io.TrackWriterFactory.TrackFileFormat;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.SystemUtils;
import android.content.Context; import android.content.Context;
import android.location.Location; import android.location.Location;
@@ -236,7 +236,7 @@ public class TcxTrackWriter implements TrackFormatWriter {
// it. The TCX schema tightly defined the Version tag, so we can't put it // it. The TCX schema tightly defined the Version tag, so we can't put it
// there. They've similarly constrained the PartNumber tag, so it can't go // there. They've similarly constrained the PartNumber tag, so it can't go
// there either. // there either.
pw.format("<Name>My Tracks %s by Google</Name>\n", MyTracksUtils.getMyTracksVersion(context)); pw.format("<Name>My Tracks %s by Google</Name>\n", SystemUtils.getMyTracksVersion(context));
pw.println("<Build>"); pw.println("<Build>");
@@ -246,11 +246,11 @@ public class TcxTrackWriter implements TrackFormatWriter {
// signify that this build is newer than the one associated with the // signify that this build is newer than the one associated with the
// version code given in VersionMajor. // version code given in VersionMajor.
pw.println("<Version>"); pw.println("<Version>");
pw.format("<VersionMajor>%d</VersionMajor>\n", MyTracksUtils.getMyTracksVersion(context)); pw.format("<VersionMajor>%d</VersionMajor>\n", SystemUtils.getMyTracksVersion(context));
pw.format("<VersionMinor>%d</VersionMinor>\n", MyTracksUtils.isRelease(context) ? 0 : 1); pw.format("<VersionMinor>%d</VersionMinor>\n", SystemUtils.isRelease(context) ? 0 : 1);
pw.println("</Version>"); pw.println("</Version>");
pw.format("<Type>%s</Type>\n", MyTracksUtils.isRelease(context) ? TCX_TYPE_RELEASE pw.format("<Type>%s</Type>\n", SystemUtils.isRelease(context) ? TCX_TYPE_RELEASE
: TCX_TYPE_INTERNAL); : TCX_TYPE_INTERNAL);
pw.println("</Build>"); pw.println("</Build>");
pw.format("<LangID>%s</LangID>\n", Locale.getDefault().getLanguage()); pw.format("<LangID>%s</LangID>\n", Locale.getDefault().getLanguage());
@@ -22,7 +22,7 @@ import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.LocationIterator; import com.google.android.apps.mytracks.content.MyTracksProviderUtils.LocationIterator;
import com.google.android.apps.mytracks.util.FileUtils; import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.app.Activity; import android.app.Activity;
@@ -302,7 +302,7 @@ public class TrackWriter {
while (it.hasNext()) { while (it.hasNext()) {
Location loc = it.next(); Location loc = it.next();
boolean isValid = MyTracksUtils.isValidLocation(loc); boolean isValid = LocationUtils.isValidLocation(loc);
boolean validSegment = isValid && isLastValid; boolean validSegment = isValid && isLastValid;
if (!wroteFirst && validSegment) { if (!wroteFirst && validSegment) {
// Found the first two consecutive points which are valid // Found the first two consecutive points which are valid
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.io.backup; package com.google.android.apps.mytracks.io.backup;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.apps.mytracks.content.TrackPointsColumns; import com.google.android.apps.mytracks.content.TrackPointsColumns;
import com.google.android.apps.mytracks.content.TracksColumns; import com.google.android.apps.mytracks.content.TracksColumns;
import com.google.android.apps.mytracks.content.WaypointsColumns; import com.google.android.apps.mytracks.content.WaypointsColumns;
@@ -201,7 +200,7 @@ class ExternalFileBackup {
// Dump preferences // Dump preferences
SharedPreferences preferences = SharedPreferences preferences =
context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
preferencesHelper.exportPreferences(preferences, outWriter); preferencesHelper.exportPreferences(preferences, outWriter);
} catch (IOException e) { } catch (IOException e) {
// We tried to delete the partially created file, but do nothing // We tried to delete the partially created file, but do nothing
@@ -253,7 +252,7 @@ class ExternalFileBackup {
// Restore preferences // Restore preferences
SharedPreferences preferences = SharedPreferences preferences =
context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
preferencesHelper.importPreferences(reader, preferences); preferencesHelper.importPreferences(reader, preferences);
} finally { } finally {
compressedStream.close(); compressedStream.close();
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.io.backup; package com.google.android.apps.mytracks.io.backup;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import android.app.backup.BackupAgent; import android.app.backup.BackupAgent;
import android.app.backup.BackupDataInput; import android.app.backup.BackupDataInput;
@@ -42,7 +41,7 @@ public class MyTracksBackupAgent extends BackupAgent {
ParcelFileDescriptor newState) throws IOException { ParcelFileDescriptor newState) throws IOException {
Log.i(Constants.TAG, "Performing backup"); Log.i(Constants.TAG, "Performing backup");
SharedPreferences preferences = this.getSharedPreferences( SharedPreferences preferences = this.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
backupPreferences(data, preferences); backupPreferences(data, preferences);
Log.i(Constants.TAG, "Backup complete"); Log.i(Constants.TAG, "Backup complete");
@@ -92,7 +91,7 @@ public class MyTracksBackupAgent extends BackupAgent {
} }
SharedPreferences preferences = this.getSharedPreferences( SharedPreferences preferences = this.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
PreferenceBackupHelper importer = createPreferenceBackupHelper(); PreferenceBackupHelper importer = createPreferenceBackupHelper();
importer.importPreferences(dataBuffer, preferences); importer.importPreferences(dataBuffer, preferences);
} }
@@ -15,9 +15,9 @@
*/ */
package com.google.android.apps.mytracks.io.sendtogoogle; package com.google.android.apps.mytracks.io.sendtogoogle;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.DialogManager; import com.google.android.apps.mytracks.DialogManager;
import com.google.android.apps.mytracks.MyTracks; import com.google.android.apps.mytracks.MyTracks;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.app.Dialog; import android.app.Dialog;
@@ -107,7 +107,7 @@ public class SendDialog extends Dialog {
R.id.sendtogoogle_send_stats_and_points); R.id.sendtogoogle_send_stats_and_points);
SharedPreferences prefs = SharedPreferences prefs =
getContext().getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); getContext().getSharedPreferences(Constants.SETTINGS_NAME, 0);
if (prefs != null) { if (prefs != null) {
sendToMyMapsCheckBox.setChecked( sendToMyMapsCheckBox.setChecked(
prefs.getBoolean( prefs.getBoolean(
@@ -138,7 +138,7 @@ public class SendDialog extends Dialog {
@Override @Override
protected void onStop() { protected void onStop() {
SharedPreferences prefs = SharedPreferences prefs =
getContext().getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); getContext().getSharedPreferences(Constants.SETTINGS_NAME, 0);
if (prefs != null) { if (prefs != null) {
Editor editor = prefs.edit(); Editor editor = prefs.edit();
if (editor != null) { if (editor != null) {
@@ -15,7 +15,7 @@
*/ */
package com.google.android.apps.mytracks.services; package com.google.android.apps.mytracks.services;
import com.google.android.apps.mytracks.MyTracksSettings; import com.google.android.apps.mytracks.Constants;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.content.Context; import android.content.Context;
@@ -58,7 +58,7 @@ class DefaultTrackNameFactory {
/** Determines whether the preferences allow a timestamp-based track name */ /** Determines whether the preferences allow a timestamp-based track name */
protected boolean useTimestampTrackName() { protected boolean useTimestampTrackName() {
SharedPreferences prefs = SharedPreferences prefs =
context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
return prefs.getBoolean( return prefs.getBoolean(
context.getString(R.string.timestamp_track_name_key), true); context.getString(R.string.timestamp_track_name_key), true);
} }
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.services; package com.google.android.apps.mytracks.services;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@@ -45,7 +44,7 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
public PreferenceManager(TrackRecordingService service) { public PreferenceManager(TrackRecordingService service) {
this.service = service; this.service = service;
this.sharedPreferences = service.getSharedPreferences( this.sharedPreferences = service.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
if (sharedPreferences == null) { if (sharedPreferences == null) {
Log.w(Constants.TAG, Log.w(Constants.TAG,
"TrackRecordingService: Couldn't get shared preferences."); "TrackRecordingService: Couldn't get shared preferences.");
@@ -97,7 +96,7 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
service.setMinRecordingDistance( service.setMinRecordingDistance(
sharedPreferences.getInt( sharedPreferences.getInt(
minRecordingDistanceKey, minRecordingDistanceKey,
MyTracksSettings.DEFAULT_MIN_RECORDING_DISTANCE)); Constants.DEFAULT_MIN_RECORDING_DISTANCE));
Log.d(Constants.TAG, Log.d(Constants.TAG,
"TrackRecordingService: minRecordingDistance = " "TrackRecordingService: minRecordingDistance = "
+ service.getMinRecordingDistance()); + service.getMinRecordingDistance());
@@ -105,12 +104,12 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
if (key == null || key.equals(maxRecordingDistanceKey)) { if (key == null || key.equals(maxRecordingDistanceKey)) {
service.setMaxRecordingDistance(sharedPreferences.getInt( service.setMaxRecordingDistance(sharedPreferences.getInt(
maxRecordingDistanceKey, maxRecordingDistanceKey,
MyTracksSettings.DEFAULT_MAX_RECORDING_DISTANCE)); Constants.DEFAULT_MAX_RECORDING_DISTANCE));
} }
if (key == null || key.equals(minRecordingIntervalKey)) { if (key == null || key.equals(minRecordingIntervalKey)) {
int minRecordingInterval = sharedPreferences.getInt( int minRecordingInterval = sharedPreferences.getInt(
minRecordingIntervalKey, minRecordingIntervalKey,
MyTracksSettings.DEFAULT_MIN_RECORDING_INTERVAL); Constants.DEFAULT_MIN_RECORDING_INTERVAL);
switch (minRecordingInterval) { switch (minRecordingInterval) {
case -2: case -2:
// Battery Miser // Battery Miser
@@ -136,7 +135,7 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
if (key == null || key.equals(minRequiredAccuracyKey)) { if (key == null || key.equals(minRequiredAccuracyKey)) {
service.setMinRequiredAccuracy(sharedPreferences.getInt( service.setMinRequiredAccuracy(sharedPreferences.getInt(
minRequiredAccuracyKey, minRequiredAccuracyKey,
MyTracksSettings.DEFAULT_MIN_REQUIRED_ACCURACY)); Constants.DEFAULT_MIN_REQUIRED_ACCURACY));
} }
if (key == null || key.equals(announcementFrequencyKey)) { if (key == null || key.equals(announcementFrequencyKey)) {
service.setAnnouncementFrequency( service.setAnnouncementFrequency(
@@ -145,7 +144,7 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
if (key == null || key.equals(autoResumeTrackTimeoutKey)) { if (key == null || key.equals(autoResumeTrackTimeoutKey)) {
service.setAutoResumeTrackTimeout(sharedPreferences.getInt( service.setAutoResumeTrackTimeout(sharedPreferences.getInt(
autoResumeTrackTimeoutKey, autoResumeTrackTimeoutKey,
MyTracksSettings.DEFAULT_AUTO_RESUME_TRACK_TIMEOUT)); Constants.DEFAULT_AUTO_RESUME_TRACK_TIMEOUT));
} }
if (key == null || key.equals(recordingTrackKey)) { if (key == null || key.equals(recordingTrackKey)) {
long recordingTrackId = sharedPreferences.getLong(recordingTrackKey, -1); long recordingTrackId = sharedPreferences.getLong(recordingTrackKey, -1);
@@ -19,7 +19,6 @@ package com.google.android.apps.mytracks.services;
import static com.google.android.apps.mytracks.Constants.TAG; import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.apps.mytracks.stats.TripStatistics; import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.StringUtils; import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.apps.mytracks.util.UnitConversions; import com.google.android.apps.mytracks.util.UnitConversions;
@@ -176,7 +175,7 @@ public class StatusAnnouncerTask implements PeriodicTask {
// @VisibleForTesting // @VisibleForTesting
protected String getAnnouncement(TripStatistics stats) { protected String getAnnouncement(TripStatistics stats) {
SharedPreferences preferences = SharedPreferences preferences =
context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
boolean metricUnits = true; boolean metricUnits = true;
boolean reportSpeed = true; boolean reportSpeed = true;
if (preferences != null) { if (preferences != null) {
@@ -20,7 +20,6 @@ import static com.google.android.apps.mytracks.Constants.RESUME_TRACK_EXTRA_NAME
import com.google.android.apps.mytracks.MyTracks; import com.google.android.apps.mytracks.MyTracks;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.apps.mytracks.content.MyTracksLocation; import com.google.android.apps.mytracks.content.MyTracksLocation;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Sensor; import com.google.android.apps.mytracks.content.Sensor;
@@ -36,7 +35,7 @@ import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.stats.TripStatisticsBuilder; import com.google.android.apps.mytracks.stats.TripStatisticsBuilder;
import com.google.android.apps.mytracks.util.ApiFeatures; import com.google.android.apps.mytracks.util.ApiFeatures;
import com.google.android.apps.mytracks.util.ApiPlatformAdapter; import com.google.android.apps.mytracks.util.ApiPlatformAdapter;
import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.apps.mytracks.util.StringUtils; import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -81,13 +80,13 @@ public class TrackRecordingService extends Service implements LocationListener {
private WakeLock wakeLock; private WakeLock wakeLock;
private int minRecordingDistance = private int minRecordingDistance =
MyTracksSettings.DEFAULT_MIN_RECORDING_DISTANCE; Constants.DEFAULT_MIN_RECORDING_DISTANCE;
private int maxRecordingDistance = private int maxRecordingDistance =
MyTracksSettings.DEFAULT_MAX_RECORDING_DISTANCE; Constants.DEFAULT_MAX_RECORDING_DISTANCE;
private int minRequiredAccuracy = private int minRequiredAccuracy =
MyTracksSettings.DEFAULT_MIN_REQUIRED_ACCURACY; Constants.DEFAULT_MIN_REQUIRED_ACCURACY;
private int autoResumeTrackTimeout = private int autoResumeTrackTimeout =
MyTracksSettings.DEFAULT_AUTO_RESUME_TRACK_TIMEOUT; Constants.DEFAULT_AUTO_RESUME_TRACK_TIMEOUT;
private long recordingTrackId = -1; private long recordingTrackId = -1;
@@ -215,7 +214,7 @@ public class TrackRecordingService extends Service implements LocationListener {
// Keep track of length along recorded track (needed when a waypoint is // Keep track of length along recorded track (needed when a waypoint is
// inserted): // inserted):
if (MyTracksUtils.isValidLocation(location)) { if (LocationUtils.isValidLocation(location)) {
if (lastValidLocation != null) { if (lastValidLocation != null) {
length += location.distanceTo(lastValidLocation); length += location.distanceTo(lastValidLocation);
} }
@@ -453,7 +452,7 @@ public class TrackRecordingService extends Service implements LocationListener {
if (cursor.moveToLast()) { if (cursor.moveToLast()) {
do { do {
Location location = providerUtils.createLocation(cursor); Location location = providerUtils.createLocation(cursor);
if (MyTracksUtils.isValidLocation(location)) { if (LocationUtils.isValidLocation(location)) {
statsBuilder.addLocation(location, location.getTime()); statsBuilder.addLocation(location, location.getTime());
if (lastValidLocation != null) { if (lastValidLocation != null) {
length += location.distanceTo(lastValidLocation); length += location.distanceTo(lastValidLocation);
@@ -629,7 +628,7 @@ public class TrackRecordingService extends Service implements LocationListener {
} }
private void addLocationToStats(Location location) { private void addLocationToStats(Location location) {
if (MyTracksUtils.isValidLocation(location)) { if (LocationUtils.isValidLocation(location)) {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
statsBuilder.addLocation(location, now); statsBuilder.addLocation(location, now);
waypointStatsBuilder.addLocation(location, now); waypointStatsBuilder.addLocation(location, now);
@@ -836,7 +835,7 @@ public class TrackRecordingService extends Service implements LocationListener {
// Check if we haven't exceeded the maximum number of retry attempts. // Check if we haven't exceeded the maximum number of retry attempts.
SharedPreferences sharedPreferences = SharedPreferences sharedPreferences =
getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); getSharedPreferences(Constants.SETTINGS_NAME, 0);
int retries = sharedPreferences.getInt( int retries = sharedPreferences.getInt(
getString(R.string.auto_resume_track_current_retry_key), 0); getString(R.string.auto_resume_track_current_retry_key), 0);
Log.d(TAG, Log.d(TAG,
@@ -1117,7 +1116,7 @@ public class TrackRecordingService extends Service implements LocationListener {
// Reset the number of auto-resume retries. // Reset the number of auto-resume retries.
setAutoResumeTrackRetries( setAutoResumeTrackRetries(
getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0), 0); getSharedPreferences(Constants.SETTINGS_NAME, 0), 0);
// Persist the current recording track. // Persist the current recording track.
prefManager.setRecordingTrack(recordingTrackId); prefManager.setRecordingTrack(recordingTrackId);
@@ -16,7 +16,8 @@
package com.google.android.apps.mytracks.services.sensors; package com.google.android.apps.mytracks.services.sensors;
import static com.google.android.apps.mytracks.Constants.TAG; import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.Sensor; import com.google.android.apps.mytracks.content.Sensor;
import com.google.android.apps.mytracks.services.sensors.ant.AntChannelIdMessage; import com.google.android.apps.mytracks.services.sensors.ant.AntChannelIdMessage;
import com.google.android.apps.mytracks.services.sensors.ant.AntChannelResponseMessage; import com.google.android.apps.mytracks.services.sensors.ant.AntChannelResponseMessage;
@@ -58,7 +59,7 @@ public class AntDirectSensorManager extends AntSensorManager {
// First read the the device id that we will be pairing with. // First read the the device id that we will be pairing with.
SharedPreferences prefs = context.getSharedPreferences( SharedPreferences prefs = context.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
if (prefs != null) { if (prefs != null) {
deviceNumberHRM = deviceNumberHRM =
(short) prefs.getInt(context.getString(R.string.ant_heart_rate_sensor_id_key), 0); (short) prefs.getInt(context.getString(R.string.ant_heart_rate_sensor_id_key), 0);
@@ -133,7 +134,7 @@ public class AntDirectSensorManager extends AntSensorManager {
Log.i(TAG, "Found device id: " + deviceNumberHRM); Log.i(TAG, "Found device id: " + deviceNumberHRM);
SharedPreferences prefs = context.getSharedPreferences( SharedPreferences prefs = context.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, Context.MODE_PRIVATE); Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit(); SharedPreferences.Editor editor = prefs.edit();
editor.putInt(context.getString(R.string.ant_heart_rate_sensor_id_key), deviceNumberHRM); editor.putInt(context.getString(R.string.ant_heart_rate_sensor_id_key), deviceNumberHRM);
editor.commit(); editor.commit();
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.services.sensors; package com.google.android.apps.mytracks.services.sensors;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.apps.mytracks.content.Sensor; import com.google.android.apps.mytracks.content.Sensor;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -71,7 +70,7 @@ public class AntSRMSensorManager extends AntSensorManager {
// First read the the device id that we will be announcing. // First read the the device id that we will be announcing.
SharedPreferences prefs = context.getSharedPreferences( SharedPreferences prefs = context.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
if (prefs != null) { if (prefs != null) {
deviceId = (byte) prefs.getInt( deviceId = (byte) prefs.getInt(
context.getString(R.string.ant_srm_bridge_sensor_id_key), context.getString(R.string.ant_srm_bridge_sensor_id_key),
@@ -133,7 +132,7 @@ public class AntSRMSensorManager extends AntSensorManager {
Log.i(Constants.TAG, "Found device id: " + deviceId); Log.i(Constants.TAG, "Found device id: " + deviceId);
SharedPreferences prefs = context.getSharedPreferences( SharedPreferences prefs = context.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, Context.MODE_PRIVATE); Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit(); SharedPreferences.Editor editor = prefs.edit();
editor.putInt(context.getString(R.string.ant_srm_bridge_sensor_id_key), deviceId); editor.putInt(context.getString(R.string.ant_srm_bridge_sensor_id_key), deviceId);
editor.commit(); editor.commit();
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.services.sensors; package com.google.android.apps.mytracks.services.sensors;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.apps.mytracks.content.Sensor; import com.google.android.apps.mytracks.content.Sensor;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -82,7 +81,7 @@ public class BluetoothSensorManager extends SensorManager {
return; return;
} }
SharedPreferences prefs = SharedPreferences prefs =
context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
String address = String address =
prefs.getString(context.getString(R.string.bluetooth_sensor_key), null); prefs.getString(context.getString(R.string.bluetooth_sensor_key), null);
if (address == null) { if (address == null) {
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.services.sensors; package com.google.android.apps.mytracks.services.sensors;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.content.Context; import android.content.Context;
@@ -40,7 +39,7 @@ public class SensorManagerFactory {
*/ */
public static SensorManager getSensorManager(Context context) { public static SensorManager getSensorManager(Context context) {
SharedPreferences prefs = SharedPreferences prefs =
context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
if (prefs == null) { if (prefs == null) {
return null; return null;
} }
@@ -19,7 +19,7 @@ package com.google.android.apps.mytracks.stats;
import static com.google.android.apps.mytracks.Constants.TAG; import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings; import com.google.android.apps.mytracks.SettingsActivity;
import android.location.Location; import android.location.Location;
import android.util.Log; import android.util.Log;
@@ -93,7 +93,7 @@ public class TripStatisticsBuilder {
private long totalLocations = 0; private long totalLocations = 0;
private int minRecordingDistance = private int minRecordingDistance =
MyTracksSettings.DEFAULT_MIN_RECORDING_DISTANCE; Constants.DEFAULT_MIN_RECORDING_DISTANCE;
/** /**
* Creates a new trip starting at the given time. * Creates a new trip starting at the given time.
@@ -16,7 +16,7 @@
package com.google.android.apps.mytracks.util; package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.MyTracksSettings; import com.google.android.apps.mytracks.Constants;
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;
@@ -50,7 +50,7 @@ public class ChartURLGenerator {
public static String getChartUrl(Vector<Double> distances, public static String getChartUrl(Vector<Double> distances,
Vector<Double> elevations, Track track, Context context) { Vector<Double> elevations, Track track, Context context) {
SharedPreferences preferences = SharedPreferences preferences =
context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
boolean metricUnits = true; boolean metricUnits = true;
if (preferences != null) { if (preferences != null) {
metricUnits = preferences.getBoolean( metricUnits = preferences.getBoolean(
@@ -21,15 +21,7 @@ import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
import android.location.Location; import android.location.Location;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log; import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
@@ -41,9 +33,7 @@ import java.util.Stack;
* *
* @author Leif Hendrik Wilden * @author Leif Hendrik Wilden
*/ */
public class MyTracksUtils { public class LocationUtils {
private static final int RELEASE_SIGNATURE_HASHCODE = -1855564782;
/** /**
* Computes the distance on the two sphere between the point c0 and the line * Computes the distance on the two sphere between the point c0 and the line
* segment c1 to c2. * segment c1 to c2.
@@ -117,7 +107,7 @@ public class MyTracksUtils {
current = stack.pop(); current = stack.pop();
maxDist = 0; maxDist = 0;
for (idx = current[0] + 1; idx < current[1]; ++idx) { for (idx = current[0] + 1; idx < current[1]; ++idx) {
dist = MyTracksUtils.distance( dist = LocationUtils.distance(
locations.get(idx), locations.get(idx),
locations.get(current[0]), locations.get(current[0]),
locations.get(current[1])); locations.get(current[1]));
@@ -255,80 +245,9 @@ public class MyTracksUtils {
(int) (location.getLongitude() * 1E6)); (int) (location.getLongitude() * 1E6));
} }
/**
* Returns whether or not this is a release build.
*/
public static boolean isRelease(Context context) {
try {
Signature [] sigs = context.getPackageManager().getPackageInfo(
context.getPackageName(), PackageManager.GET_SIGNATURES).signatures;
for (Signature sig : sigs) {
if (sig.hashCode() == RELEASE_SIGNATURE_HASHCODE) {
return true;
}
}
} catch (NameNotFoundException e) {
Log.e(Constants.TAG, "Unable to get signatures", e);
}
return false;
}
/**
* Get the My Tracks version from the manifest.
*
* @return the version, or an empty string in case of failure.
*/
public static String getMyTracksVersion(Context context) {
try {
PackageInfo pi = context.getPackageManager().getPackageInfo(
"com.google.android.maps.mytracks",
PackageManager.GET_META_DATA);
return pi.versionName;
} catch (NameNotFoundException e) {
Log.w(Constants.TAG, "Failed to get version info.", e);
return "";
}
}
/**
* Tries to acquire a partial wake lock if not already acquired. Logs errors
* and gives up trying in case the wake lock cannot be acquired.
*/
public static WakeLock acquireWakeLock(Activity activity, WakeLock wakeLock) {
Log.i(Constants.TAG, "MyTracksUtils: Acquiring wake lock.");
try {
PowerManager pm = (PowerManager) activity
.getSystemService(Context.POWER_SERVICE);
if (pm == null) {
Log.e(Constants.TAG, "MyTracksUtils: Power manager not found!");
return wakeLock;
}
if (wakeLock == null) {
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
Constants.TAG);
if (wakeLock == null) {
Log.e(Constants.TAG,
"MyTracksUtils: Could not create wake lock (null).");
}
return wakeLock;
}
if (!wakeLock.isHeld()) {
wakeLock.acquire();
if (!wakeLock.isHeld()) {
Log.e(Constants.TAG,
"MyTracksUtils: Could not acquire wake lock.");
}
}
} catch (RuntimeException e) {
Log.e(Constants.TAG,
"MyTracksUtils: Caught unexpected exception: " + e.getMessage(), e);
}
return wakeLock;
}
/** /**
* This is a utility class w/ only static members. * This is a utility class w/ only static members.
*/ */
protected MyTracksUtils() { private LocationUtils() {
} }
} }
@@ -15,7 +15,7 @@
*/ */
package com.google.android.apps.mytracks.util; package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.MyTracksSettings; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.DescriptionGenerator; import com.google.android.apps.mytracks.content.DescriptionGenerator;
import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
@@ -245,7 +245,7 @@ public class StringUtils implements DescriptionGenerator {
Vector<Double> elevations) { Vector<Double> elevations) {
boolean displaySpeed = true; boolean displaySpeed = true;
SharedPreferences preferences = SharedPreferences preferences =
context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
if (preferences != null) { if (preferences != null) {
displaySpeed = displaySpeed =
preferences.getBoolean(context.getString(R.string.report_speed_key), true); preferences.getBoolean(context.getString(R.string.report_speed_key), true);
@@ -0,0 +1,111 @@
/*
* 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
* 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.util;
import com.google.android.apps.mytracks.Constants;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
/**
* Utility class for acessing basic Android functionality.
*
* @author Rodrigo Damazio
*/
public class SystemUtils {
private static final int RELEASE_SIGNATURE_HASHCODE = -1855564782;
/**
* Returns whether or not this is a release build.
*/
public static boolean isRelease(Context context) {
try {
Signature [] sigs = context.getPackageManager().getPackageInfo(
context.getPackageName(), PackageManager.GET_SIGNATURES).signatures;
for (Signature sig : sigs) {
if (sig.hashCode() == RELEASE_SIGNATURE_HASHCODE) {
return true;
}
}
} catch (NameNotFoundException e) {
Log.e(Constants.TAG, "Unable to get signatures", e);
}
return false;
}
/**
* Get the My Tracks version from the manifest.
*
* @return the version, or an empty string in case of failure.
*/
public static String getMyTracksVersion(Context context) {
try {
PackageInfo pi = context.getPackageManager().getPackageInfo(
"com.google.android.maps.mytracks",
PackageManager.GET_META_DATA);
return pi.versionName;
} catch (NameNotFoundException e) {
Log.w(Constants.TAG, "Failed to get version info.", e);
return "";
}
}
/**
* Tries to acquire a partial wake lock if not already acquired. Logs errors
* and gives up trying in case the wake lock cannot be acquired.
*/
public static WakeLock acquireWakeLock(Activity activity, WakeLock wakeLock) {
Log.i(Constants.TAG, "LocationUtils: Acquiring wake lock.");
try {
PowerManager pm = (PowerManager) activity
.getSystemService(Context.POWER_SERVICE);
if (pm == null) {
Log.e(Constants.TAG, "LocationUtils: Power manager not found!");
return wakeLock;
}
if (wakeLock == null) {
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
Constants.TAG);
if (wakeLock == null) {
Log.e(Constants.TAG,
"LocationUtils: Could not create wake lock (null).");
}
return wakeLock;
}
if (!wakeLock.isHeld()) {
wakeLock.acquire();
if (!wakeLock.isHeld()) {
Log.e(Constants.TAG,
"LocationUtils: Could not acquire wake lock.");
}
}
} catch (RuntimeException e) {
Log.e(Constants.TAG,
"LocationUtils: Caught unexpected exception: " + e.getMessage(), e);
}
return wakeLock;
}
private SystemUtils() {}
}
@@ -39,17 +39,17 @@ import java.util.List;
* *
* @author Bartlomiej Niechwiej * @author Bartlomiej Niechwiej
*/ */
public class MyTracksOverlayTest 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; private Projection mockProjection;
/** /**
* A mock version of {@code MyTracksOverlay} that does not use * A mock version of {@code MapOverlay} that does not use
* {@class MapView}. * {@class MapView}.
*/ */
private class MockMyTracksOverlay extends MyTracksOverlay { private class MockMyTracksOverlay extends MapOverlay {
public MockMyTracksOverlay(Context context) { public MockMyTracksOverlay(Context context) {
super(context); super(context);
} }
@@ -17,7 +17,7 @@ package com.google.android.apps.mytracks.services;
import static com.google.android.apps.mytracks.Constants.RESUME_TRACK_EXTRA_NAME; import static com.google.android.apps.mytracks.Constants.RESUME_TRACK_EXTRA_NAME;
import com.google.android.apps.mytracks.MyTracksSettings; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.MyTracksProvider; import com.google.android.apps.mytracks.content.MyTracksProvider;
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;
@@ -152,7 +152,7 @@ public class TrackRecordingServiceTest
providerUtils = MyTracksProviderUtils.Factory.get(context); providerUtils = MyTracksProviderUtils.Factory.get(context);
sharedPreferences = context.getSharedPreferences( sharedPreferences = context.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
// Let's use default values. // Let's use default values.
sharedPreferences.edit().clear().commit(); sharedPreferences.edit().clear().commit();
@@ -16,7 +16,7 @@
package com.google.android.apps.mytracks.services.sensors; package com.google.android.apps.mytracks.services.sensors;
import com.dsi.ant.AntMesg; import com.dsi.ant.AntMesg;
import com.google.android.apps.mytracks.MyTracksSettings; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.Sensor; import com.google.android.apps.mytracks.content.Sensor;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -31,7 +31,7 @@ public class AntDirectSensorManagerTest extends AndroidTestCase {
public void setUp() { public void setUp() {
sharedPreferences = getContext().getSharedPreferences( sharedPreferences = getContext().getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
// Let's use default values. // Let's use default values.
sharedPreferences.edit().clear().commit(); sharedPreferences.edit().clear().commit();
manager = new AntDirectSensorManager(getContext()); manager = new AntDirectSensorManager(getContext());
@@ -1,6 +1,6 @@
package com.google.android.apps.mytracks.services.sensors; package com.google.android.apps.mytracks.services.sensors;
import com.google.android.apps.mytracks.MyTracksSettings; import com.google.android.apps.mytracks.Constants;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@@ -16,7 +16,7 @@ public class SensorManagerFactoryTest extends AndroidTestCase {
super.setUp(); super.setUp();
sharedPreferences = getContext().getSharedPreferences( sharedPreferences = getContext().getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0); Constants.SETTINGS_NAME, 0);
// Let's use default values. // Let's use default values.
sharedPreferences.edit().clear().commit(); sharedPreferences.edit().clear().commit();
} }