forked from upstream-mirrors/OpenTracks
(Re-)Enabled SaveActivity.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
import com.google.android.apps.mytracks.util.StatsUtils;
|
||||
@@ -50,7 +50,7 @@ public class AggregatedStatsActivity extends AbstractActivity {
|
||||
* there is no track.
|
||||
*/
|
||||
private TripStatistics getTripStatistics() {
|
||||
List<Track> tracks = MyTracksProviderUtils.Factory.get(this).getAllTracks();
|
||||
List<Track> tracks = ContentProviderUtils.Factory.get(this).getAllTracks();
|
||||
TripStatistics tripStatistics = null;
|
||||
if (!tracks.isEmpty()) {
|
||||
tripStatistics = new TripStatistics(tracks.iterator().next().getTripStatistics());
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.google.android.apps.mytracks;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
|
||||
/**
|
||||
* Async Task to delete tracks.
|
||||
@@ -70,16 +70,16 @@ public class DeleteAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
MyTracksProviderUtils myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
|
||||
ContentProviderUtils contentProviderUtils = ContentProviderUtils.Factory.get(context);
|
||||
|
||||
if (trackIds.length == 1 && trackIds[0] == -1L) {
|
||||
myTracksProviderUtils.deleteAllTracks(context);
|
||||
contentProviderUtils.deleteAllTracks(context);
|
||||
} else {
|
||||
for (long id : trackIds) {
|
||||
if (isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
myTracksProviderUtils.deleteTrack(context, id);
|
||||
contentProviderUtils.deleteTrack(context, id);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@ import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.fragments.DeleteMarkerDialogFragment.DeleteMarkerCaller;
|
||||
import com.google.android.apps.mytracks.fragments.MarkerDetailFragment;
|
||||
@@ -56,20 +56,20 @@ public class MarkerDetailActivity extends AbstractActivity implements DeleteMark
|
||||
return;
|
||||
}
|
||||
|
||||
MyTracksProviderUtils myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||
Waypoint waypoint = myTracksProviderUtils.getWaypoint(markerId);
|
||||
ContentProviderUtils contentProviderUtils = ContentProviderUtils.Factory.get(this);
|
||||
Waypoint waypoint = contentProviderUtils.getWaypoint(markerId);
|
||||
|
||||
markerIds = new ArrayList<>();
|
||||
int markerIndex = -1;
|
||||
|
||||
try (Cursor cursor = myTracksProviderUtils.getWaypointCursor(waypoint.getTrackId(), -1L, -1)) {
|
||||
try (Cursor cursor = contentProviderUtils.getWaypointCursor(waypoint.getTrackId(), -1L, -1)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
/*
|
||||
* Yes, this will skip the first waypoint and that is intentional as the
|
||||
* first waypoint holds the stats for the track.
|
||||
*/
|
||||
while (cursor.moveToNext()) {
|
||||
Waypoint current = myTracksProviderUtils.createWaypoint(cursor);
|
||||
Waypoint current = contentProviderUtils.createWaypoint(cursor);
|
||||
|
||||
markerIds.add(current.getId());
|
||||
if (current.getId() == markerId) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
||||
@@ -130,7 +130,7 @@ public class MarkerEditActivity extends AbstractActivity {
|
||||
statisticsSection.setVisibility(View.GONE);
|
||||
waypointSection.setVisibility(View.VISIBLE);
|
||||
int nextWaypointNumber = trackId == -1L ? -1
|
||||
: MyTracksProviderUtils.Factory.get(this).getNextWaypointNumber(trackId, WaypointType.WAYPOINT);
|
||||
: ContentProviderUtils.Factory.get(this).getNextWaypointNumber(trackId, WaypointType.WAYPOINT);
|
||||
if (nextWaypointNumber == -1) {
|
||||
nextWaypointNumber = 0;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class MarkerEditActivity extends AbstractActivity {
|
||||
waypointMarkerType.setText("");
|
||||
waypointDescription.setText("");
|
||||
} else {
|
||||
waypoint = MyTracksProviderUtils.Factory.get(this).getWaypoint(markerId);
|
||||
waypoint = ContentProviderUtils.Factory.get(this).getWaypoint(markerId);
|
||||
if (waypoint == null) {
|
||||
Log.d(TAG, "waypoint is null");
|
||||
finish();
|
||||
@@ -186,6 +186,6 @@ public class MarkerEditActivity extends AbstractActivity {
|
||||
waypoint.setCategory(waypointMarkerType.getText().toString());
|
||||
waypoint.setDescription(waypointDescription.getText().toString());
|
||||
}
|
||||
MyTracksProviderUtils.Factory.get(this).updateWaypoint(waypoint);
|
||||
ContentProviderUtils.Factory.get(this).updateWaypoint(waypoint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import androidx.loader.app.LoaderManager.LoaderCallbacks;
|
||||
import androidx.loader.content.CursorLoader;
|
||||
import androidx.loader.content.Loader;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.content.WaypointsColumns;
|
||||
@@ -116,7 +116,7 @@ public class MarkerListActivity extends AbstractActivity implements DeleteMarker
|
||||
}
|
||||
};
|
||||
|
||||
private MyTracksProviderUtils myTracksProviderUtils;
|
||||
private ContentProviderUtils contentProviderUtils;
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
private long recordingTrackId = PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
|
||||
@@ -134,12 +134,12 @@ public class MarkerListActivity extends AbstractActivity implements DeleteMarker
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||
contentProviderUtils = ContentProviderUtils.Factory.get(this);
|
||||
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
|
||||
long trackId = getIntent().getLongExtra(EXTRA_TRACK_ID, -1L);
|
||||
track = trackId != -1L ? myTracksProviderUtils.getTrack(trackId) : null;
|
||||
final long trackFirstWaypointId = trackId != -1 ? myTracksProviderUtils.getFirstWaypointId(trackId) : -1;
|
||||
track = trackId != -1L ? contentProviderUtils.getTrack(trackId) : null;
|
||||
final long trackFirstWaypointId = trackId != -1 ? contentProviderUtils.getFirstWaypointId(trackId) : -1;
|
||||
|
||||
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import android.widget.ListView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.SearchEngine;
|
||||
import com.google.android.apps.mytracks.content.SearchEngine.ScoredResult;
|
||||
import com.google.android.apps.mytracks.content.SearchEngine.SearchQuery;
|
||||
@@ -133,7 +133,7 @@ public class SearchListActivity extends AbstractTrackActivity implements DeleteM
|
||||
if (isSingleSelection) {
|
||||
Map<String, Object> item = arrayAdapter.getItem(positions[0]);
|
||||
Long trackId = (Long) item.get(TRACK_ID_FIELD);
|
||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
|
||||
isSingleSelectionTrack = item.get(MARKER_ID_FIELD) == null;
|
||||
} else {
|
||||
@@ -154,7 +154,7 @@ public class SearchListActivity extends AbstractTrackActivity implements DeleteM
|
||||
}
|
||||
};
|
||||
|
||||
private MyTracksProviderUtils myTracksProviderUtils;
|
||||
private ContentProviderUtils contentProviderUtils;
|
||||
private SharedPreferences sharedPreferences;
|
||||
private TrackRecordingServiceConnection trackRecordingServiceConnection;
|
||||
private SearchEngine searchEngine;
|
||||
@@ -170,10 +170,10 @@ public class SearchListActivity extends AbstractTrackActivity implements DeleteM
|
||||
super.onCreate(savedInstanceState);
|
||||
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
|
||||
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||
contentProviderUtils = ContentProviderUtils.Factory.get(this);
|
||||
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, null);
|
||||
searchEngine = new SearchEngine(myTracksProviderUtils);
|
||||
searchEngine = new SearchEngine(contentProviderUtils);
|
||||
searchRecentSuggestions = SearchEngineProvider.newHelper(this);
|
||||
|
||||
arrayAdapter = new ArrayAdapter<Map<String, Object>>(this, R.layout.list_item, R.id.list_item_name) {
|
||||
@@ -430,7 +430,7 @@ public class SearchListActivity extends AbstractTrackActivity implements DeleteM
|
||||
String trackName = null;
|
||||
long trackId = waypoint.getTrackId();
|
||||
if (trackId != -1L) {
|
||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
if (track != null) {
|
||||
trackName = track.getName();
|
||||
}
|
||||
@@ -477,7 +477,7 @@ public class SearchListActivity extends AbstractTrackActivity implements DeleteM
|
||||
resultMap.put(NAME_FIELD, track.getName());
|
||||
resultMap.put(TOTAL_TIME_FIELD, StringUtils.formatElapsedTime(tripStatitics.getTotalTime()));
|
||||
resultMap.put(TOTAL_DISTANCE_FIELD, StringUtils.formatDistance(this, tripStatitics.getTotalDistance(), metricUnits));
|
||||
resultMap.put(MARKER_COUNT_FIELD, myTracksProviderUtils.getWaypointCount(track.getId()));
|
||||
resultMap.put(MARKER_COUNT_FIELD, contentProviderUtils.getWaypointCount(track.getId()));
|
||||
resultMap.put(START_TIME_FIELD, tripStatitics.getStartTime());
|
||||
resultMap.put(CATEGORY_FIELD, category);
|
||||
resultMap.put(DESCRIPTION_FIELD, track.getDescription());
|
||||
|
||||
@@ -41,7 +41,7 @@ import androidx.core.app.TaskStackBuilder;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.TrackDataHub;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
@@ -93,7 +93,7 @@ public class TrackDetailActivity extends AbstractTrackActivity implements Choose
|
||||
private boolean hasCamera;
|
||||
private Uri photoUri;
|
||||
private boolean hasPhoto;
|
||||
private MyTracksProviderUtils myTracksProviderUtils;
|
||||
private ContentProviderUtils contentProviderUtils;
|
||||
private SharedPreferences sharedPreferences;
|
||||
private TrackRecordingServiceConnection trackRecordingServiceConnection;
|
||||
private TrackDataHub trackDataHub;
|
||||
@@ -197,7 +197,7 @@ public class TrackDetailActivity extends AbstractTrackActivity implements Choose
|
||||
photoUri = savedInstanceState != null ? (Uri) savedInstanceState.getParcelable(PHOTO_URI_KEY) : null;
|
||||
hasPhoto = savedInstanceState != null && savedInstanceState.getBoolean(HAS_PHOTO_KEY, false);
|
||||
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||
contentProviderUtils = ContentProviderUtils.Factory.get(this);
|
||||
handleIntent(getIntent());
|
||||
|
||||
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
@@ -458,7 +458,7 @@ public class TrackDetailActivity extends AbstractTrackActivity implements Choose
|
||||
long markerId = intent.getLongExtra(EXTRA_MARKER_ID, -1L);
|
||||
if (markerId != -1L) {
|
||||
// Use the trackId from the marker
|
||||
Waypoint waypoint = myTracksProviderUtils.getWaypoint(markerId);
|
||||
Waypoint waypoint = contentProviderUtils.getWaypoint(markerId);
|
||||
if (waypoint == null) {
|
||||
finish();
|
||||
return;
|
||||
@@ -469,11 +469,11 @@ public class TrackDetailActivity extends AbstractTrackActivity implements Choose
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
if (track == null) {
|
||||
// Use the last track if markerId is not set
|
||||
if (markerId == -1L) {
|
||||
track = myTracksProviderUtils.getLastTrack();
|
||||
track = contentProviderUtils.getLastTrack();
|
||||
if (track != null) {
|
||||
trackId = track.getId();
|
||||
return;
|
||||
@@ -497,7 +497,7 @@ public class TrackDetailActivity extends AbstractTrackActivity implements Choose
|
||||
if (isRecording()) {
|
||||
title = getString(isPaused ? R.string.generic_paused : R.string.generic_recording);
|
||||
} else {
|
||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
title = track != null ? track.getName() : "";
|
||||
}
|
||||
setTitle(title);
|
||||
@@ -509,9 +509,9 @@ public class TrackDetailActivity extends AbstractTrackActivity implements Choose
|
||||
|
||||
@Override
|
||||
public void onChooseActivityTypeDone(String iconValue) {
|
||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
String category = getString(TrackIconUtils.getIconActivityType(iconValue));
|
||||
TrackUtils.updateTrack(this, track, null, category, null, myTracksProviderUtils);
|
||||
TrackUtils.updateTrack(this, track, null, category, null, contentProviderUtils);
|
||||
}
|
||||
|
||||
private boolean isRecording() {
|
||||
|
||||
@@ -28,7 +28,7 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller;
|
||||
@@ -53,7 +53,7 @@ public class TrackEditActivity extends AbstractActivity implements ChooseActivit
|
||||
private static final String ICON_VALUE_KEY = "icon_value_key";
|
||||
|
||||
private TrackRecordingServiceConnection trackRecordingServiceConnection;
|
||||
private MyTracksProviderUtils myTracksProviderUtils;
|
||||
private ContentProviderUtils contentProviderUtils;
|
||||
private Track track;
|
||||
private String iconValue;
|
||||
|
||||
@@ -74,8 +74,8 @@ public class TrackEditActivity extends AbstractActivity implements ChooseActivit
|
||||
return;
|
||||
}
|
||||
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||
track = myTracksProviderUtils.getTrack(trackId);
|
||||
contentProviderUtils = ContentProviderUtils.Factory.get(this);
|
||||
track = contentProviderUtils.getTrack(trackId);
|
||||
if (track == null) {
|
||||
Log.e(TAG, "No track for " + trackId);
|
||||
finish();
|
||||
@@ -150,7 +150,7 @@ public class TrackEditActivity extends AbstractActivity implements ChooseActivit
|
||||
public void onClick(View v) {
|
||||
TrackUtils.updateTrack(TrackEditActivity.this, track, name.getText().toString(),
|
||||
activityType.getText().toString(), description.getText().toString(),
|
||||
myTracksProviderUtils);
|
||||
contentProviderUtils);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ import androidx.loader.app.LoaderManager.LoaderCallbacks;
|
||||
import androidx.loader.content.CursorLoader;
|
||||
import androidx.loader.content.Loader;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||
import com.google.android.apps.mytracks.fragments.ConfirmDeleteDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.FileTypeDialogFragment;
|
||||
@@ -242,7 +242,7 @@ public class TrackListActivity extends AbstractTrackActivity implements FileType
|
||||
};
|
||||
|
||||
// The following are set in onCreate
|
||||
private MyTracksProviderUtils myTracksProviderUtils;
|
||||
private ContentProviderUtils contentProviderUtils;
|
||||
private SharedPreferences sharedPreferences;
|
||||
private TrackRecordingServiceConnection trackRecordingServiceConnection;
|
||||
private TrackController trackController;
|
||||
@@ -281,7 +281,7 @@ public class TrackListActivity extends AbstractTrackActivity implements FileType
|
||||
.build());
|
||||
}
|
||||
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||
contentProviderUtils = ContentProviderUtils.Factory.get(this);
|
||||
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
|
||||
trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, bindChangedCallback);
|
||||
@@ -326,7 +326,7 @@ public class TrackListActivity extends AbstractTrackActivity implements FileType
|
||||
String name = cursor.getString(nameIndex);
|
||||
String totalTime = StringUtils.formatElapsedTime(cursor.getLong(totalTimeIndex));
|
||||
String totalDistance = StringUtils.formatDistance(TrackListActivity.this, cursor.getDouble(totalDistanceIndex), metricUnits);
|
||||
int markerCount = myTracksProviderUtils.getWaypointCount(trackId);
|
||||
int markerCount = contentProviderUtils.getWaypointCount(trackId);
|
||||
long startTime = cursor.getLong(startTimeIndex);
|
||||
String category = icon != null && !icon.equals("") ? null : cursor.getString(categoryIndex);
|
||||
String description = cursor.getString(descriptionIndex);
|
||||
|
||||
+8
-8
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public interface MyTracksProviderUtils {
|
||||
public interface ContentProviderUtils {
|
||||
|
||||
/**
|
||||
* The authority (the first part of the URI) for the My Tracks content
|
||||
@@ -350,12 +350,12 @@ public interface MyTracksProviderUtils {
|
||||
LocationFactory DEFAULT_LOCATION_FACTORY = new LocationFactory() {
|
||||
@Override
|
||||
public Location createLocation() {
|
||||
return new MyTracksLocation(LocationManager.GPS_PROVIDER);
|
||||
return new SensorDataSetLocation(LocationManager.GPS_PROVIDER);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A factory which can produce instances of {@link MyTracksProviderUtils}, and
|
||||
* A factory which can produce instances of {@link ContentProviderUtils}, and
|
||||
* can be overridden for testing.
|
||||
*/
|
||||
class Factory {
|
||||
@@ -363,11 +363,11 @@ public interface MyTracksProviderUtils {
|
||||
private static Factory instance = new Factory();
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link MyTracksProviderUtils}.
|
||||
* Creates an instance of {@link ContentProviderUtils}.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static MyTracksProviderUtils get(Context context) {
|
||||
public static ContentProviderUtils get(Context context) {
|
||||
return instance.newForContext(context);
|
||||
}
|
||||
|
||||
@@ -389,13 +389,13 @@ public interface MyTracksProviderUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link MyTracksProviderUtils}. Allows subclasses
|
||||
* Creates an instance of {@link ContentProviderUtils}. Allows subclasses
|
||||
* to override for testing.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
protected MyTracksProviderUtils newForContext(Context context) {
|
||||
return new MyTracksProviderUtilsImpl(context.getContentResolver());
|
||||
protected ContentProviderUtils newForContext(Context context) {
|
||||
return new ContentProviderUtilsImpl(context.getContentResolver());
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-14
@@ -35,20 +35,20 @@ import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* {@link MyTracksProviderUtils} implementation.
|
||||
* {@link ContentProviderUtils} implementation.
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
*/
|
||||
public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
public class ContentProviderUtilsImpl implements ContentProviderUtils {
|
||||
|
||||
private static final String TAG = MyTracksProviderUtilsImpl.class.getSimpleName();
|
||||
private static final String TAG = ContentProviderUtilsImpl.class.getSimpleName();
|
||||
|
||||
private static final int MAX_LATITUDE = 90000000;
|
||||
|
||||
private final ContentResolver contentResolver;
|
||||
private int defaultCursorBatchSize = 2000;
|
||||
|
||||
public MyTracksProviderUtilsImpl(ContentResolver contentResolver) {
|
||||
public ContentProviderUtilsImpl(ContentResolver contentResolver) {
|
||||
this.contentResolver = contentResolver;
|
||||
}
|
||||
|
||||
@@ -734,7 +734,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
|
||||
@Override
|
||||
public Location createTrackPoint(Cursor cursor) {
|
||||
Location location = new MyTracksLocation("");
|
||||
Location location = new SensorDataSetLocation("");
|
||||
fillTrackPoint(cursor, new CachedTrackPointsIndexes(cursor), location);
|
||||
return location;
|
||||
}
|
||||
@@ -999,17 +999,17 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
}
|
||||
|
||||
//SensorData
|
||||
if (location instanceof MyTracksLocation) {
|
||||
MyTracksLocation myTracksLocation = (MyTracksLocation) location;
|
||||
SensorDataSet sensorDataSet = myTracksLocation.getSensorDataSet();
|
||||
if (location instanceof SensorDataSetLocation) {
|
||||
SensorDataSetLocation sensorDataSetLocation = (SensorDataSetLocation) location;
|
||||
SensorDataSet sensorDataSet = sensorDataSetLocation.getSensorDataSet();
|
||||
if (sensorDataSet != null && sensorDataSet.hasHeartRate()) {
|
||||
values.put(TrackPointsColumns.SENSOR_HEARTRATE, myTracksLocation.getSensorDataSet().getHeartRate());
|
||||
values.put(TrackPointsColumns.SENSOR_HEARTRATE, sensorDataSetLocation.getSensorDataSet().getHeartRate());
|
||||
}
|
||||
if (sensorDataSet != null && sensorDataSet.hasCadence()) {
|
||||
values.put(TrackPointsColumns.SENSOR_CADENCE, myTracksLocation.getSensorDataSet().getCadence());
|
||||
values.put(TrackPointsColumns.SENSOR_CADENCE, sensorDataSetLocation.getSensorDataSet().getCadence());
|
||||
}
|
||||
if (sensorDataSet != null && sensorDataSet.hasPower()) {
|
||||
values.put(TrackPointsColumns.SENSOR_POWER, myTracksLocation.getSensorDataSet().getPower());
|
||||
values.put(TrackPointsColumns.SENSOR_POWER, sensorDataSetLocation.getSensorDataSet().getPower());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
@@ -1046,14 +1046,14 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
if (!cursor.isNull(indexes.bearingIndex)) {
|
||||
location.setBearing(cursor.getFloat(indexes.bearingIndex));
|
||||
}
|
||||
if (location instanceof MyTracksLocation) {
|
||||
MyTracksLocation myTracksLocation = (MyTracksLocation) location;
|
||||
if (location instanceof SensorDataSetLocation) {
|
||||
SensorDataSetLocation sensorDataSetLocation = (SensorDataSetLocation) location;
|
||||
|
||||
float heartRate = cursor.isNull(indexes.sensorHeartRateIndex) ? SensorDataSet.DATA_UNAVAILABLE : cursor.getFloat(indexes.sensorHeartRateIndex);
|
||||
float cadence = cursor.isNull(indexes.sensorCadenceIndex) ? SensorDataSet.DATA_UNAVAILABLE : cursor.getFloat(indexes.sensorCadenceIndex);
|
||||
float power = cursor.isNull(indexes.sensorPowerIndex) ? SensorDataSet.DATA_UNAVAILABLE : cursor.getFloat(indexes.sensorPowerIndex);
|
||||
|
||||
myTracksLocation.setSensorDataSet(new SensorDataSet(heartRate, cadence, power, SensorDataSet.DATA_UNAVAILABLE, location.getTime()));
|
||||
sensorDataSetLocation.setSensorDataSet(new SensorDataSet(heartRate, cadence, power, SensorDataSet.DATA_UNAVAILABLE, location.getTime()));
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -47,9 +47,9 @@ import java.io.FileNotFoundException;
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
*/
|
||||
public class MyTracksProvider extends ContentProvider {
|
||||
public class CustomContentProvider extends ContentProvider {
|
||||
|
||||
private static final String TAG = MyTracksProvider.class.getSimpleName();
|
||||
private static final String TAG = CustomContentProvider.class.getSimpleName();
|
||||
|
||||
@VisibleForTesting
|
||||
static final int DATABASE_VERSION = 23;
|
||||
@@ -97,14 +97,14 @@ public class MyTracksProvider extends ContentProvider {
|
||||
private final UriMatcher uriMatcher;
|
||||
private SQLiteDatabase db;
|
||||
|
||||
public MyTracksProvider() {
|
||||
public CustomContentProvider() {
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI(MyTracksProviderUtils.AUTHORITY, TrackPointsColumns.TABLE_NAME, UrlType.TRACKPOINTS.ordinal());
|
||||
uriMatcher.addURI(MyTracksProviderUtils.AUTHORITY, TrackPointsColumns.TABLE_NAME + "/#", UrlType.TRACKPOINTS_ID.ordinal());
|
||||
uriMatcher.addURI(MyTracksProviderUtils.AUTHORITY, TracksColumns.TABLE_NAME, UrlType.TRACKS.ordinal());
|
||||
uriMatcher.addURI(MyTracksProviderUtils.AUTHORITY, TracksColumns.TABLE_NAME + "/#", UrlType.TRACKS_ID.ordinal());
|
||||
uriMatcher.addURI(MyTracksProviderUtils.AUTHORITY, WaypointsColumns.TABLE_NAME, UrlType.WAYPOINTS.ordinal());
|
||||
uriMatcher.addURI(MyTracksProviderUtils.AUTHORITY, WaypointsColumns.TABLE_NAME + "/#", UrlType.WAYPOINTS_ID.ordinal());
|
||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, TrackPointsColumns.TABLE_NAME, UrlType.TRACKPOINTS.ordinal());
|
||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, TrackPointsColumns.TABLE_NAME + "/#", UrlType.TRACKPOINTS_ID.ordinal());
|
||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, TracksColumns.TABLE_NAME, UrlType.TRACKS.ordinal());
|
||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, TracksColumns.TABLE_NAME + "/#", UrlType.TRACKS_ID.ordinal());
|
||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, WaypointsColumns.TABLE_NAME, UrlType.WAYPOINTS.ordinal());
|
||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, WaypointsColumns.TABLE_NAME + "/#", UrlType.WAYPOINTS_ID.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,9 +151,9 @@ public class SearchEngine {
|
||||
}
|
||||
};
|
||||
|
||||
private final MyTracksProviderUtils providerUtils;
|
||||
private final ContentProviderUtils providerUtils;
|
||||
|
||||
public SearchEngine(MyTracksProviderUtils providerUtils) {
|
||||
public SearchEngine(ContentProviderUtils providerUtils) {
|
||||
this.providerUtils = providerUtils;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -24,7 +24,7 @@ import com.google.android.apps.mytracks.content.sensor.SensorDataSet;
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public class MyTracksLocation extends Location {
|
||||
public class SensorDataSetLocation extends Location {
|
||||
|
||||
private SensorDataSet sensorDataSet = null;
|
||||
|
||||
@@ -33,12 +33,12 @@ public class MyTracksLocation extends Location {
|
||||
*/
|
||||
private int id = -1;
|
||||
|
||||
public MyTracksLocation(Location location, SensorDataSet sensorDataSet) {
|
||||
public SensorDataSetLocation(Location location, SensorDataSet sensorDataSet) {
|
||||
super(location);
|
||||
this.sensorDataSet = sensorDataSet;
|
||||
}
|
||||
|
||||
public MyTracksLocation(String provider) {
|
||||
public SensorDataSetLocation(String provider) {
|
||||
super(provider);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.LocationIterator;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils.LocationIterator;
|
||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
@@ -58,7 +58,7 @@ public class TrackDataHub implements DataSourceListener {
|
||||
|
||||
private final Context context;
|
||||
private final TrackDataManager trackDataManager;
|
||||
private final MyTracksProviderUtils myTracksProviderUtils;
|
||||
private final ContentProviderUtils contentProviderUtils;
|
||||
private final int targetNumPoints;
|
||||
|
||||
private boolean started;
|
||||
@@ -85,7 +85,7 @@ public class TrackDataHub implements DataSourceListener {
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public synchronized static TrackDataHub newInstance(Context context) {
|
||||
return new TrackDataHub(context, new TrackDataManager(), MyTracksProviderUtils.Factory.get(
|
||||
return new TrackDataHub(context, new TrackDataManager(), ContentProviderUtils.Factory.get(
|
||||
context), TARGET_DISPLAYED_TRACK_POINTS);
|
||||
}
|
||||
|
||||
@@ -94,15 +94,15 @@ public class TrackDataHub implements DataSourceListener {
|
||||
*
|
||||
* @param context the context
|
||||
* @param trackDataManager the track data manager
|
||||
* @param myTracksProviderUtils the my tracks provider utils
|
||||
* @param contentProviderUtils the my tracks provider utils
|
||||
* @param targetNumPoints the target number of points
|
||||
*/
|
||||
@VisibleForTesting
|
||||
TrackDataHub(Context context, TrackDataManager trackDataManager,
|
||||
MyTracksProviderUtils myTracksProviderUtils, int targetNumPoints) {
|
||||
ContentProviderUtils contentProviderUtils, int targetNumPoints) {
|
||||
this.context = context;
|
||||
this.trackDataManager = trackDataManager;
|
||||
this.myTracksProviderUtils = myTracksProviderUtils;
|
||||
this.contentProviderUtils = contentProviderUtils;
|
||||
this.targetNumPoints = targetNumPoints;
|
||||
resetSamplingState();
|
||||
}
|
||||
@@ -408,7 +408,7 @@ public class TrackDataHub implements DataSourceListener {
|
||||
if (trackDataListeners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Track track = myTracksProviderUtils.getTrack(selectedTrackId);
|
||||
Track track = contentProviderUtils.getTrack(selectedTrackId);
|
||||
for (TrackDataListener trackDataListener : trackDataListeners) {
|
||||
trackDataListener.onTrackUpdated(track);
|
||||
}
|
||||
@@ -430,11 +430,11 @@ public class TrackDataHub implements DataSourceListener {
|
||||
trackDataListener.clearWaypoints();
|
||||
}
|
||||
|
||||
try (Cursor cursor = myTracksProviderUtils.getWaypointCursor(
|
||||
try (Cursor cursor = contentProviderUtils.getWaypointCursor(
|
||||
selectedTrackId, -1L, MAX_DISPLAYED_WAYPOINTS)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
do {
|
||||
Waypoint waypoint = myTracksProviderUtils.createWaypoint(cursor);
|
||||
Waypoint waypoint = contentProviderUtils.createWaypoint(cursor);
|
||||
if (!LocationUtils.isValidLocation(waypoint.getLocation())) {
|
||||
continue;
|
||||
}
|
||||
@@ -477,14 +477,14 @@ public class TrackDataHub implements DataSourceListener {
|
||||
long localLastSeenLocationId = updateSamplingState ? lastSeenLocationId : -1L;
|
||||
long maxPointId = updateSamplingState ? -1L : lastSeenLocationId;
|
||||
|
||||
long lastTrackPointId = myTracksProviderUtils.getLastTrackPointId(selectedTrackId);
|
||||
long lastTrackPointId = contentProviderUtils.getLastTrackPointId(selectedTrackId);
|
||||
int samplingFrequency = -1;
|
||||
boolean includeNextPoint = false;
|
||||
LocationIterator locationIterator = null;
|
||||
|
||||
try {
|
||||
locationIterator = myTracksProviderUtils.getTrackPointLocationIterator(selectedTrackId,
|
||||
localLastSeenLocationId + 1, false, MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||
locationIterator = contentProviderUtils.getTrackPointLocationIterator(selectedTrackId,
|
||||
localLastSeenLocationId + 1, false, ContentProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||
|
||||
while (locationIterator.hasNext()) {
|
||||
Location location = locationIterator.next();
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
package com.google.android.apps.mytracks.content;
|
||||
parcelable WaypointCreationRequest;
|
||||
+1
-1
@@ -29,7 +29,7 @@ import androidx.fragment.app.DialogFragment;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public abstract class AbstractMyTracksDialogFragment extends DialogFragment {
|
||||
public abstract class AbstractDialogFragment extends DialogFragment {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@@ -31,7 +31,7 @@ import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.google.android.apps.mytracks.ChartView;
|
||||
import com.google.android.apps.mytracks.TrackDetailActivity;
|
||||
import com.google.android.apps.mytracks.content.MyTracksLocation;
|
||||
import com.google.android.apps.mytracks.content.SensorDataSetLocation;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.TrackDataHub;
|
||||
import com.google.android.apps.mytracks.content.TrackDataListener;
|
||||
@@ -470,8 +470,8 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
||||
}
|
||||
pace = speed == 0 ? 0.0 : 60.0 / speed;
|
||||
}
|
||||
if (location instanceof MyTracksLocation && ((MyTracksLocation) location).getSensorDataSet() != null) {
|
||||
SensorDataSet sensorDataSet = ((MyTracksLocation) location).getSensorDataSet();
|
||||
if (location instanceof SensorDataSetLocation && ((SensorDataSetLocation) location).getSensorDataSet() != null) {
|
||||
SensorDataSet sensorDataSet = ((SensorDataSetLocation) location).getSensorDataSet();
|
||||
if (sensorDataSet.hasHeartRate()) {
|
||||
heartRate = sensorDataSet.getHeartRate();
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import com.google.android.maps.mytracks.R;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class ConfirmDeleteDialogFragment extends AbstractMyTracksDialogFragment {
|
||||
public class ConfirmDeleteDialogFragment extends AbstractDialogFragment {
|
||||
|
||||
/**
|
||||
* Interface for caller of this dialog fragment.
|
||||
|
||||
+4
-4
@@ -24,7 +24,7 @@ import android.os.Bundle;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.util.DialogUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.google.android.maps.mytracks.R;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class DeleteMarkerDialogFragment extends AbstractMyTracksDialogFragment {
|
||||
public class DeleteMarkerDialogFragment extends AbstractDialogFragment {
|
||||
|
||||
/**
|
||||
* Interface for caller of this dialog fragment.
|
||||
@@ -94,10 +94,10 @@ public class DeleteMarkerDialogFragment extends AbstractMyTracksDialogFragment {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MyTracksProviderUtils myTracksProviderUtils = MyTracksProviderUtils.Factory.get(
|
||||
ContentProviderUtils contentProviderUtils = ContentProviderUtils.Factory.get(
|
||||
fragmentActivity);
|
||||
for (long markerId : markerIds) {
|
||||
myTracksProviderUtils.deleteWaypoint(fragmentActivity,
|
||||
contentProviderUtils.deleteWaypoint(fragmentActivity,
|
||||
markerId, new DescriptionGeneratorImpl(fragmentActivity));
|
||||
}
|
||||
caller.onDeleteMarkerDone();
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import com.google.android.maps.mytracks.R;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class FileTypeDialogFragment extends AbstractMyTracksDialogFragment {
|
||||
public class FileTypeDialogFragment extends AbstractDialogFragment {
|
||||
|
||||
/**
|
||||
* Interface for caller of this dialog fragment.
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import androidx.fragment.app.FragmentActivity;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class FrequencyDialogFragment extends AbstractMyTracksDialogFragment {
|
||||
public class FrequencyDialogFragment extends AbstractDialogFragment {
|
||||
|
||||
public static final String FREQUENCY_DIALOG_TAG = "frequencyDialog";
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.google.android.apps.mytracks.MarkerEditActivity;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
@@ -72,7 +72,7 @@ public class MarkerDetailFragment extends Fragment {
|
||||
private static final String KEY_TITLE = "title";
|
||||
private static final long HIDE_TEXT_DELAY = 4000L; // 4 seconds
|
||||
|
||||
private MyTracksProviderUtils myTracksProviderUtils;
|
||||
private ContentProviderUtils contentProviderUtils;
|
||||
private Handler handler;
|
||||
private ImageView photo;
|
||||
private ImageView textGradient;
|
||||
@@ -112,7 +112,7 @@ public class MarkerDetailFragment extends Fragment {
|
||||
getFragmentManager().popBackStack();
|
||||
return;
|
||||
}
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(getActivity());
|
||||
contentProviderUtils = ContentProviderUtils.Factory.get(getActivity());
|
||||
handler = new Handler();
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
@@ -214,7 +214,7 @@ public class MarkerDetailFragment extends Fragment {
|
||||
*/
|
||||
private void updateWaypoint(boolean refresh) {
|
||||
if (refresh || waypoint == null) {
|
||||
waypoint = myTracksProviderUtils.getWaypoint(getArguments().getLong(KEY_MARKER_ID));
|
||||
waypoint = contentProviderUtils.getWaypoint(getArguments().getLong(KEY_MARKER_ID));
|
||||
if (waypoint == null) {
|
||||
Log.d(TAG, "waypoint is null");
|
||||
getFragmentManager().popBackStack();
|
||||
@@ -259,7 +259,7 @@ public class MarkerDetailFragment extends Fragment {
|
||||
|
||||
setLocation(R.id.marker_detail_statistics_location, false);
|
||||
|
||||
Track track = myTracksProviderUtils.getTrack(waypoint.getTrackId());
|
||||
Track track = contentProviderUtils.getTrack(waypoint.getTrackId());
|
||||
StatsUtils.setTripStatisticsValues(getActivity(), null, getView(), waypoint.getTripStatistics(), null);
|
||||
StatsUtils.setLocationValues(getActivity(), null, getView(), waypoint.getLocation(), false);
|
||||
}
|
||||
|
||||
+14
-14
@@ -17,9 +17,9 @@
|
||||
package com.google.android.apps.mytracks.io.file.exporter;
|
||||
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.content.MyTracksLocation;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.LocationIterator;
|
||||
import com.google.android.apps.mytracks.content.SensorDataSetLocation;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils.LocationIterator;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||
@@ -40,7 +40,7 @@ public class FileTrackExporter implements TrackExporter {
|
||||
|
||||
private static final String TAG = FileTrackExporter.class.getSimpleName();
|
||||
|
||||
private final MyTracksProviderUtils myTracksProviderUtils;
|
||||
private final ContentProviderUtils contentProviderUtils;
|
||||
private final Track[] tracks;
|
||||
private final TrackWriter trackWriter;
|
||||
private final TrackExporterListener trackExporterListener;
|
||||
@@ -48,14 +48,14 @@ public class FileTrackExporter implements TrackExporter {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param myTracksProviderUtils the my tracks provider utils
|
||||
* @param contentProviderUtils the my tracks provider utils
|
||||
* @param tracks the tracks
|
||||
* @param trackWriter the track writer
|
||||
* @param trackExporterListener the track export listener
|
||||
*/
|
||||
public FileTrackExporter(MyTracksProviderUtils myTracksProviderUtils, Track[] tracks,
|
||||
TrackWriter trackWriter, TrackExporterListener trackExporterListener) {
|
||||
this.myTracksProviderUtils = myTracksProviderUtils;
|
||||
public FileTrackExporter(ContentProviderUtils contentProviderUtils, Track[] tracks,
|
||||
TrackWriter trackWriter, TrackExporterListener trackExporterListener) {
|
||||
this.contentProviderUtils = contentProviderUtils;
|
||||
this.tracks = tracks;
|
||||
this.trackWriter = trackWriter;
|
||||
this.trackExporterListener = trackExporterListener;
|
||||
@@ -95,7 +95,7 @@ public class FileTrackExporter implements TrackExporter {
|
||||
* load them into objects all at the same time.
|
||||
*/
|
||||
boolean hasWaypoints = false;
|
||||
try (Cursor cursor = myTracksProviderUtils.getWaypointCursor(
|
||||
try (Cursor cursor = contentProviderUtils.getWaypointCursor(
|
||||
track.getId(), -1L, Constants.MAX_LOADED_WAYPOINTS_POINTS)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
/*
|
||||
@@ -110,7 +110,7 @@ public class FileTrackExporter implements TrackExporter {
|
||||
trackWriter.writeBeginWaypoints(track);
|
||||
hasWaypoints = true;
|
||||
}
|
||||
Waypoint waypoint = myTracksProviderUtils.createWaypoint(cursor);
|
||||
Waypoint waypoint = contentProviderUtils.createWaypoint(cursor);
|
||||
trackWriter.writeWaypoint(waypoint);
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class FileTrackExporter implements TrackExporter {
|
||||
LocationIterator locationIterator = null;
|
||||
|
||||
try {
|
||||
locationIterator = myTracksProviderUtils.getTrackPointLocationIterator(
|
||||
locationIterator = contentProviderUtils.getTrackPointLocationIterator(
|
||||
track.getId(), -1L, false, locationFactory);
|
||||
|
||||
while (locationIterator.hasNext()) {
|
||||
@@ -178,7 +178,7 @@ public class FileTrackExporter implements TrackExporter {
|
||||
}
|
||||
|
||||
if (wroteTrack) {
|
||||
Location lastValidTrackPoint = myTracksProviderUtils.getLastValidTrackPoint(track.getId());
|
||||
Location lastValidTrackPoint = contentProviderUtils.getLastValidTrackPoint(track.getId());
|
||||
setLocationTime(lastValidTrackPoint, offset);
|
||||
trackWriter.writeEndTrack(track, lastValidTrackPoint);
|
||||
} else {
|
||||
@@ -210,14 +210,14 @@ public class FileTrackExporter implements TrackExporter {
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
private class TrackWriterLocationFactory implements MyTracksProviderUtils.LocationFactory {
|
||||
private class TrackWriterLocationFactory implements ContentProviderUtils.LocationFactory {
|
||||
Location currentLocation;
|
||||
Location lastLocation;
|
||||
|
||||
@Override
|
||||
public Location createLocation() {
|
||||
if (currentLocation == null) {
|
||||
currentLocation = new MyTracksLocation("");
|
||||
currentLocation = new SensorDataSetLocation("");
|
||||
}
|
||||
return currentLocation;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.google.android.apps.mytracks.content.DescriptionGenerator;
|
||||
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
|
||||
import com.google.android.apps.mytracks.content.MyTracksLocation;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.SensorDataSetLocation;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
@@ -71,7 +71,7 @@ public class KmlTrackWriter implements TrackWriter {
|
||||
private final boolean multiple;
|
||||
private final boolean playTrack;
|
||||
private final DescriptionGenerator descriptionGenerator;
|
||||
private final MyTracksProviderUtils myTracksProviderUtils;
|
||||
private final ContentProviderUtils contentProviderUtils;
|
||||
|
||||
private PrintWriter printWriter;
|
||||
private ArrayList<Float> powerList = new ArrayList<>();
|
||||
@@ -91,7 +91,7 @@ public class KmlTrackWriter implements TrackWriter {
|
||||
this.multiple = multiple;
|
||||
this.playTrack = playTrack;
|
||||
this.descriptionGenerator = descriptionGenerator;
|
||||
this.myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
|
||||
this.contentProviderUtils = ContentProviderUtils.Factory.get(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,8 +261,8 @@ public class KmlTrackWriter implements TrackWriter {
|
||||
printWriter.println(
|
||||
"<when>" + StringUtils.formatDateTimeIso8601(location.getTime()) + "</when>");
|
||||
printWriter.println("<gx:coord>" + getCoordinates(location, " ") + "</gx:coord>");
|
||||
if (location instanceof MyTracksLocation) {
|
||||
SensorDataSet sensorDataSet = ((MyTracksLocation) location).getSensorDataSet();
|
||||
if (location instanceof SensorDataSetLocation) {
|
||||
SensorDataSet sensorDataSet = ((SensorDataSetLocation) location).getSensorDataSet();
|
||||
if (sensorDataSet != null) {
|
||||
if (sensorDataSet.hasHeartRate()) {
|
||||
heartRateList.add(sensorDataSet.getHeartRate());
|
||||
@@ -377,17 +377,17 @@ public class KmlTrackWriter implements TrackWriter {
|
||||
* @param location the location
|
||||
*/
|
||||
private float getHeading(long trackId, Location location) {
|
||||
long trackPointId = myTracksProviderUtils.getTrackPointId(trackId, location);
|
||||
long trackPointId = contentProviderUtils.getTrackPointId(trackId, location);
|
||||
if (trackPointId == -1L) {
|
||||
return location.getBearing();
|
||||
}
|
||||
Location viewLocation;
|
||||
try (Cursor cursor = myTracksProviderUtils.getTrackPointCursor(trackId, trackPointId, 10, true)) {
|
||||
try (Cursor cursor = contentProviderUtils.getTrackPointCursor(trackId, trackPointId, 10, true)) {
|
||||
if (cursor == null || cursor.getCount() == 0) {
|
||||
return location.getBearing();
|
||||
}
|
||||
cursor.moveToPosition(cursor.getCount() - 1);
|
||||
viewLocation = myTracksProviderUtils.createTrackPoint(cursor);
|
||||
viewLocation = contentProviderUtils.createTrackPoint(cursor);
|
||||
}
|
||||
return viewLocation.bearingTo(location);
|
||||
}
|
||||
|
||||
+8
-8
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.android.apps.mytracks.io.file.exporter;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
@@ -50,7 +50,7 @@ public class KmzTrackExporter implements TrackExporter {
|
||||
private static final String TAG = KmzTrackExporter.class.getSimpleName();
|
||||
private static final int BUFFER_SIZE = 4096;
|
||||
|
||||
private final MyTracksProviderUtils myTracksProviderUtils;
|
||||
private final ContentProviderUtils contentProviderUtils;
|
||||
private final FileTrackExporter fileTrackExporter;
|
||||
private final Track[] tracks;
|
||||
private final long photoSize;
|
||||
@@ -58,14 +58,14 @@ public class KmzTrackExporter implements TrackExporter {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param myTracksProviderUtils the my tracks provider utils
|
||||
* @param contentProviderUtils the my tracks provider utils
|
||||
* @param fileTrackExporter the file track exporter
|
||||
* @param tracks the tracks to export
|
||||
* @param context the context
|
||||
*/
|
||||
public KmzTrackExporter(MyTracksProviderUtils myTracksProviderUtils,
|
||||
FileTrackExporter fileTrackExporter, Track[] tracks, Context context) {
|
||||
this.myTracksProviderUtils = myTracksProviderUtils;
|
||||
public KmzTrackExporter(ContentProviderUtils contentProviderUtils,
|
||||
FileTrackExporter fileTrackExporter, Track[] tracks, Context context) {
|
||||
this.contentProviderUtils = contentProviderUtils;
|
||||
this.fileTrackExporter = fileTrackExporter;
|
||||
this.tracks = tracks;
|
||||
this.photoSize = PreferencesUtils.getInt(
|
||||
@@ -111,7 +111,7 @@ public class KmzTrackExporter implements TrackExporter {
|
||||
|
||||
private void addImages(ZipOutputStream zipOutputStream) throws InterruptedException, IOException {
|
||||
for (Track track : tracks) {
|
||||
try (Cursor cursor = myTracksProviderUtils.getWaypointCursor(track.getId(), -1L, -1)) {
|
||||
try (Cursor cursor = contentProviderUtils.getWaypointCursor(track.getId(), -1L, -1)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
/*
|
||||
* Yes, this will skip the first waypoint and that is intentional as
|
||||
@@ -121,7 +121,7 @@ public class KmzTrackExporter implements TrackExporter {
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
Waypoint waypoint = myTracksProviderUtils.createWaypoint(cursor);
|
||||
Waypoint waypoint = contentProviderUtils.createWaypoint(cursor);
|
||||
if (waypoint.hasPhoto()) {
|
||||
addImage(zipOutputStream, waypoint.getPhotoUrl());
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import android.os.AsyncTask;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||
import com.google.android.apps.mytracks.io.file.TrackFileFormat;
|
||||
@@ -52,7 +52,7 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
private final boolean playTrack;
|
||||
private final File directory;
|
||||
private final Context context;
|
||||
private final MyTracksProviderUtils myTracksProviderUtils;
|
||||
private final ContentProviderUtils contentProviderUtils;
|
||||
|
||||
private WakeLock wakeLock;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
this.playTrack = playTrack;
|
||||
this.directory = directory;
|
||||
context = saveActivity.getApplicationContext();
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
|
||||
contentProviderUtils = ContentProviderUtils.Factory.get(context);
|
||||
|
||||
completed = false;
|
||||
successCount = 0;
|
||||
@@ -128,7 +128,7 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
totalCount = 1;
|
||||
Track[] tracks = new Track[trackIds.length];
|
||||
for (int i = 0; i < trackIds.length; i++) {
|
||||
tracks[i] = myTracksProviderUtils.getTrack(trackIds[i]);
|
||||
tracks[i] = contentProviderUtils.getTrack(trackIds[i]);
|
||||
if (tracks[i] == null) {
|
||||
Log.d(TAG, "No track for " + trackIds[i]);
|
||||
return false;
|
||||
@@ -184,7 +184,7 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
Track track = tracks[0];
|
||||
boolean useKmz = trackFileFormat == TrackFileFormat.KML && !playTrack;
|
||||
String extension = useKmz ? KmzTrackExporter.KMZ_EXTENSION : trackFileFormat.getExtension();
|
||||
FileTrackExporter fileTrackExporter = new FileTrackExporter(myTracksProviderUtils, tracks,
|
||||
FileTrackExporter fileTrackExporter = new FileTrackExporter(contentProviderUtils, tracks,
|
||||
trackFileFormat.newTrackWriter(context, tracks.length > 1, playTrack),
|
||||
new TrackExporterListener() {
|
||||
|
||||
@@ -200,7 +200,7 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
}
|
||||
});
|
||||
|
||||
TrackExporter trackExporter = useKmz ? new KmzTrackExporter(myTracksProviderUtils, fileTrackExporter, tracks, context) : fileTrackExporter;
|
||||
TrackExporter trackExporter = useKmz ? new KmzTrackExporter(contentProviderUtils, fileTrackExporter, tracks, context) : fileTrackExporter;
|
||||
|
||||
String fileName = FileUtils.buildUniqueFileName(directory, track.getName(), extension);
|
||||
File file = new File(directory, fileName);
|
||||
@@ -235,7 +235,7 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
* Saves all the tracks.
|
||||
*/
|
||||
private Boolean saveAllTracks() {
|
||||
try (Cursor cursor = myTracksProviderUtils.getTrackCursor(null, null, TracksColumns._ID)) {
|
||||
try (Cursor cursor = contentProviderUtils.getTrackCursor(null, null, TracksColumns._ID)) {
|
||||
if (cursor == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
return false;
|
||||
}
|
||||
cursor.moveToPosition(i);
|
||||
Track track = myTracksProviderUtils.createTrack(cursor);
|
||||
Track track = contentProviderUtils.createTrack(cursor);
|
||||
if (track != null && saveTracks(new Track[]{track})) {
|
||||
successCount++;
|
||||
}
|
||||
|
||||
+17
-17
@@ -23,8 +23,8 @@ import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.LocationIterator;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils.LocationIterator;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
@@ -104,7 +104,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
|
||||
private final Context context;
|
||||
private final long importTrackId;
|
||||
private final MyTracksProviderUtils myTracksProviderUtils;
|
||||
private final ContentProviderUtils contentProviderUtils;
|
||||
private final int recordingDistanceInterval;
|
||||
private final List<Long> trackIds;
|
||||
private final List<Waypoint> waypoints;
|
||||
@@ -136,10 +136,10 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
* track.
|
||||
*/
|
||||
AbstractFileTrackImporter(
|
||||
Context context, long importTrackId, MyTracksProviderUtils myTracksProviderUtils) {
|
||||
Context context, long importTrackId, ContentProviderUtils contentProviderUtils) {
|
||||
this.context = context;
|
||||
this.importTrackId = importTrackId;
|
||||
this.myTracksProviderUtils = myTracksProviderUtils;
|
||||
this.contentProviderUtils = contentProviderUtils;
|
||||
this.recordingDistanceInterval = PreferencesUtils.getInt(context,
|
||||
R.string.recording_distance_interval_key,
|
||||
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT);
|
||||
@@ -206,7 +206,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
return;
|
||||
}
|
||||
long trackId = trackIds.get(size - 1);
|
||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
if (track == null) {
|
||||
return;
|
||||
}
|
||||
@@ -221,8 +221,8 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
LocationIterator locationIterator = null;
|
||||
|
||||
try {
|
||||
locationIterator = myTracksProviderUtils.getTrackPointLocationIterator(
|
||||
track.getId(), -1L, false, MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||
locationIterator = contentProviderUtils.getTrackPointLocationIterator(
|
||||
track.getId(), -1L, false, ContentProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||
|
||||
while (true) {
|
||||
if (waypoint == null) {
|
||||
@@ -283,7 +283,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
Waypoint newWaypoint = new Waypoint(waypoint.getName(), waypointDescription,
|
||||
waypoint.getCategory(), icon, track.getId(), waypoint.getType(), length, duration,
|
||||
-1L, -1L, location, tripStatistics, waypoint.getPhotoUrl());
|
||||
myTracksProviderUtils.insertWaypoint(newWaypoint);
|
||||
contentProviderUtils.insertWaypoint(newWaypoint);
|
||||
}
|
||||
|
||||
// Load the next waypoint
|
||||
@@ -304,7 +304,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
trackData = new TrackData();
|
||||
long trackId;
|
||||
if (importTrackId == -1L) {
|
||||
Uri uri = myTracksProviderUtils.insertTrack(trackData.track);
|
||||
Uri uri = contentProviderUtils.insertTrack(trackData.track);
|
||||
trackId = Long.parseLong(uri.getLastPathSegment());
|
||||
} else {
|
||||
if (trackIds.size() > 0) {
|
||||
@@ -312,7 +312,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
"Cannot import more than one track to an existing track " + importTrackId));
|
||||
}
|
||||
trackId = importTrackId;
|
||||
myTracksProviderUtils.clearTrack(context, trackId);
|
||||
contentProviderUtils.clearTrack(context, trackId);
|
||||
}
|
||||
trackIds.add(trackId);
|
||||
trackData.track.setId(trackId);
|
||||
@@ -339,7 +339,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
}
|
||||
trackData.track.setTripStatistics(trackData.tripStatisticsUpdater.getTripStatistics());
|
||||
trackData.track.setNumberOfPoints(trackData.numberOfLocations);
|
||||
myTracksProviderUtils.updateTrack(trackData.track);
|
||||
contentProviderUtils.updateTrack(trackData.track);
|
||||
insertFirstWaypoint(trackData.track);
|
||||
}
|
||||
|
||||
@@ -574,13 +574,13 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
if (data.numBufferedLocations <= 0) {
|
||||
return;
|
||||
}
|
||||
myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
contentProviderUtils.bulkInsertTrackPoint(
|
||||
data.bufferedLocations, data.numBufferedLocations, data.track.getId());
|
||||
data.numBufferedLocations = 0;
|
||||
if (data.track.getStartId() == -1L) {
|
||||
data.track.setStartId(myTracksProviderUtils.getFirstTrackPointId(data.track.getId()));
|
||||
data.track.setStartId(contentProviderUtils.getFirstTrackPointId(data.track.getId()));
|
||||
}
|
||||
data.track.setStopId(myTracksProviderUtils.getLastTrackPointId(data.track.getId()));
|
||||
data.track.setStopId(contentProviderUtils.getLastTrackPointId(data.track.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -605,7 +605,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
Waypoint waypoint = new Waypoint(waypointName, waypointDescription, waypointCategory, icon,
|
||||
track.getId(), WaypointType.STATISTICS, length, duration, -1L, -1L, waypointLocation,
|
||||
tripStatistics, "");
|
||||
myTracksProviderUtils.insertWaypoint(waypoint);
|
||||
contentProviderUtils.insertWaypoint(waypoint);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -613,7 +613,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
*/
|
||||
private void cleanImport() {
|
||||
for (long trackId : trackIds) {
|
||||
myTracksProviderUtils.deleteTrack(context, trackId);
|
||||
contentProviderUtils.deleteTrack(context, trackId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -20,7 +20,7 @@ import android.content.Context;
|
||||
import android.location.Location;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
@@ -54,12 +54,12 @@ public class GpxFileTrackImporter extends AbstractFileTrackImporter {
|
||||
* @param context the context
|
||||
*/
|
||||
public GpxFileTrackImporter(Context context) {
|
||||
this(context, MyTracksProviderUtils.Factory.get(context));
|
||||
this(context, ContentProviderUtils.Factory.get(context));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
GpxFileTrackImporter(Context context, MyTracksProviderUtils myTracksProviderUtils) {
|
||||
super(context, -1L, myTracksProviderUtils);
|
||||
GpxFileTrackImporter(Context context, ContentProviderUtils contentProviderUtils) {
|
||||
super(context, -1L, contentProviderUtils);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.android.apps.mytracks.io.file.importer;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.io.file.TrackFileFormat;
|
||||
import com.google.android.apps.mytracks.io.file.exporter.KmzTrackExporter;
|
||||
@@ -182,8 +182,8 @@ public class ImportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
if (TrackFileFormat.KML.getExtension().equals(extension)) {
|
||||
trackImporter = new KmlFileTrackImporter(context, -1L);
|
||||
} else {
|
||||
MyTracksProviderUtils myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
|
||||
Uri uri = myTracksProviderUtils.insertTrack(new Track());
|
||||
ContentProviderUtils contentProviderUtils = ContentProviderUtils.Factory.get(context);
|
||||
Uri uri = contentProviderUtils.insertTrack(new Track());
|
||||
long newId = Long.parseLong(uri.getLastPathSegment());
|
||||
|
||||
trackImporter = new KmzTrackImporter(context, newId);
|
||||
|
||||
+7
-7
@@ -22,8 +22,8 @@ import android.net.Uri;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksLocation;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.SensorDataSetLocation;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.content.sensor.SensorDataSet;
|
||||
|
||||
@@ -78,13 +78,13 @@ public class KmlFileTrackImporter extends AbstractFileTrackImporter {
|
||||
* @param importTrackId track id to import to. -1L to import to a new track.
|
||||
*/
|
||||
public KmlFileTrackImporter(Context context, long importTrackId) {
|
||||
this(context, importTrackId, MyTracksProviderUtils.Factory.get(context));
|
||||
this(context, importTrackId, ContentProviderUtils.Factory.get(context));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
KmlFileTrackImporter(
|
||||
Context context, long importTrackId, MyTracksProviderUtils myTracksProviderUtils) {
|
||||
super(context, importTrackId, myTracksProviderUtils);
|
||||
Context context, long importTrackId, ContentProviderUtils contentProviderUtils) {
|
||||
super(context, importTrackId, contentProviderUtils);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -246,8 +246,8 @@ public class KmlFileTrackImporter extends AbstractFileTrackImporter {
|
||||
float cadence = hasHeartRate ? cadenceList.get(i) : SensorDataSet.DATA_UNAVAILABLE;
|
||||
float power = hasHeartRate ? powerList.get(i) : SensorDataSet.DATA_UNAVAILABLE;
|
||||
|
||||
MyTracksLocation myTracksLocation = new MyTracksLocation(location, new SensorDataSet(heartrate, cadence, power, SensorDataSet.DATA_UNAVAILABLE, location.getTime()));
|
||||
insertTrackPoint(myTracksLocation);
|
||||
SensorDataSetLocation sensorDataSetLocation = new SensorDataSetLocation(location, new SensorDataSet(heartrate, cadence, power, SensorDataSet.DATA_UNAVAILABLE, location.getTime()));
|
||||
insertTrackPoint(sensorDataSetLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.android.apps.mytracks.io.file.importer;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.io.file.exporter.KmzTrackExporter;
|
||||
import com.google.android.apps.mytracks.util.FileUtils;
|
||||
|
||||
@@ -111,8 +111,8 @@ public class KmzTrackImporter implements TrackImporter {
|
||||
*/
|
||||
private void cleanImport(long trackId) {
|
||||
if (trackId != -1L) {
|
||||
MyTracksProviderUtils myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
|
||||
myTracksProviderUtils.deleteTrack(context, trackId);
|
||||
ContentProviderUtils contentProviderUtils = ContentProviderUtils.Factory.get(context);
|
||||
contentProviderUtils.deleteTrack(context, trackId);
|
||||
}
|
||||
|
||||
if (importTrackId != -1L) {
|
||||
|
||||
+3
-4
@@ -24,12 +24,11 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
/**
|
||||
* My Tracks Location Manager. Applies Google location settings before allowing
|
||||
* access to {@link LocationManager}.
|
||||
* Handles connection to {@link LocationManager}.
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class MyTracksLocationManager {
|
||||
public class LocationManagerConnector {
|
||||
|
||||
private final Handler handler;
|
||||
private final LocationManager locationManager;
|
||||
@@ -38,7 +37,7 @@ public class MyTracksLocationManager {
|
||||
private float requestLocationUpdatesDistance;
|
||||
private long requestLocationUpdatesTime;
|
||||
|
||||
public MyTracksLocationManager(Context context, Looper looper) {
|
||||
public LocationManagerConnector(Context context, Looper looper) {
|
||||
this.handler = new Handler(looper);
|
||||
|
||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
+35
-35
@@ -45,10 +45,10 @@ import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.TrackDetailActivity;
|
||||
import com.google.android.apps.mytracks.TrackListActivity;
|
||||
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
|
||||
import com.google.android.apps.mytracks.content.MyTracksLocation;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProvider;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.LocationIterator;
|
||||
import com.google.android.apps.mytracks.content.SensorDataSetLocation;
|
||||
import com.google.android.apps.mytracks.content.CustomContentProvider;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils.LocationIterator;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
@@ -76,7 +76,7 @@ import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* A background service that registers a location listener and records track
|
||||
* points. Track points are saved to the {@link MyTracksProvider}.
|
||||
* points. Track points are saved to the {@link CustomContentProvider}.
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
*/
|
||||
@@ -107,9 +107,9 @@ public class TrackRecordingService extends Service {
|
||||
// The following variables are set in onCreate:
|
||||
private ExecutorService executorService;
|
||||
private Context context;
|
||||
private MyTracksProviderUtils myTracksProviderUtils;
|
||||
private ContentProviderUtils contentProviderUtils;
|
||||
private Handler handler;
|
||||
private MyTracksLocationManager myTracksLocationManager;
|
||||
private LocationManagerConnector locationManagerConnector;
|
||||
private PeriodicTaskExecutor voiceExecutor;
|
||||
private PeriodicTaskExecutor splitExecutor;
|
||||
private SharedPreferences sharedPreferences;
|
||||
@@ -198,7 +198,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(final Location location) {
|
||||
if (myTracksLocationManager == null
|
||||
if (locationManagerConnector == null
|
||||
|| executorService == null
|
||||
|| executorService.isShutdown()
|
||||
|| executorService.isTerminated()) {
|
||||
@@ -250,9 +250,9 @@ public class TrackRecordingService extends Service {
|
||||
super.onCreate();
|
||||
executorService = Executors.newSingleThreadExecutor();
|
||||
context = this;
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||
contentProviderUtils = ContentProviderUtils.Factory.get(this);
|
||||
handler = new Handler();
|
||||
myTracksLocationManager = new MyTracksLocationManager(this, handler.getLooper());
|
||||
locationManagerConnector = new LocationManagerConnector(this, handler.getLooper());
|
||||
voiceExecutor = new PeriodicTaskExecutor(this, new AnnouncementPeriodicTaskFactory());
|
||||
splitExecutor = new PeriodicTaskExecutor(this, new SplitPeriodicTaskFactory());
|
||||
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
@@ -270,7 +270,7 @@ public class TrackRecordingService extends Service {
|
||||
* Try to restart the previous recording track in case the service has been
|
||||
* restarted by the system, which can sometimes happen.
|
||||
*/
|
||||
Track track = myTracksProviderUtils.getTrack(recordingTrackId);
|
||||
Track track = contentProviderUtils.getTrack(recordingTrackId);
|
||||
if (track != null) {
|
||||
restartTrack(track);
|
||||
} else {
|
||||
@@ -328,8 +328,8 @@ public class TrackRecordingService extends Service {
|
||||
voiceExecutor = null;
|
||||
}
|
||||
|
||||
myTracksLocationManager = null;
|
||||
myTracksProviderUtils = null;
|
||||
locationManagerConnector = null;
|
||||
contentProviderUtils = null;
|
||||
|
||||
binder.detachFromService();
|
||||
binder = null;
|
||||
@@ -388,7 +388,7 @@ public class TrackRecordingService extends Service {
|
||||
if (waypointCreationRequest.getName() != null) {
|
||||
name = waypointCreationRequest.getName();
|
||||
} else {
|
||||
int nextWaypointNumber = myTracksProviderUtils.getNextWaypointNumber(recordingTrackId, waypointType);
|
||||
int nextWaypointNumber = contentProviderUtils.getNextWaypointNumber(recordingTrackId, waypointType);
|
||||
if (nextWaypointNumber == -1) {
|
||||
nextWaypointNumber = 0;
|
||||
}
|
||||
@@ -440,7 +440,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
// Insert waypoint
|
||||
Waypoint waypoint = new Waypoint(name, description, category, icon, recordingTrackId, waypointType, length, duration, -1L, -1L, location, tripStatistics, photoUrl);
|
||||
Uri uri = myTracksProviderUtils.insertWaypoint(waypoint);
|
||||
Uri uri = contentProviderUtils.insertWaypoint(waypoint);
|
||||
return Long.parseLong(uri.getLastPathSegment());
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ public class TrackRecordingService extends Service {
|
||||
* Returns true if should resume.
|
||||
*/
|
||||
private boolean shouldResumeTrack() {
|
||||
Track track = myTracksProviderUtils.getTrack(recordingTrackId);
|
||||
Track track = contentProviderUtils.getTrack(recordingTrackId);
|
||||
|
||||
if (track == null) {
|
||||
Log.d(TAG, "Not resuming. Track is null.");
|
||||
@@ -541,7 +541,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
// Insert a track
|
||||
Track track = new Track();
|
||||
Uri uri = myTracksProviderUtils.insertTrack(track);
|
||||
Uri uri = contentProviderUtils.insertTrack(track);
|
||||
long trackId = Long.parseLong(uri.getLastPathSegment());
|
||||
|
||||
// Update shared preferences
|
||||
@@ -557,7 +557,7 @@ public class TrackRecordingService extends Service {
|
||||
track.setCategory(category);
|
||||
track.setIcon(TrackIconUtils.getIconValue(this, category));
|
||||
track.setTripStatistics(trackTripStatisticsUpdater.getTripStatistics());
|
||||
myTracksProviderUtils.updateTrack(track);
|
||||
contentProviderUtils.updateTrack(track);
|
||||
insertWaypoint(WaypointCreationRequest.DEFAULT_START_TRACK);
|
||||
|
||||
startRecording(true);
|
||||
@@ -576,7 +576,7 @@ public class TrackRecordingService extends Service {
|
||||
trackTripStatisticsUpdater = new TripStatisticsUpdater(tripStatistics.getStartTime());
|
||||
|
||||
long markerStartTime;
|
||||
Waypoint waypoint = myTracksProviderUtils.getLastWaypoint(recordingTrackId, WaypointType.STATISTICS);
|
||||
Waypoint waypoint = contentProviderUtils.getLastWaypoint(recordingTrackId, WaypointType.STATISTICS);
|
||||
if (waypoint != null && waypoint.getTripStatistics() != null) {
|
||||
markerStartTime = waypoint.getTripStatistics().getStopTime();
|
||||
} else {
|
||||
@@ -586,7 +586,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
LocationIterator locationIterator = null;
|
||||
try {
|
||||
locationIterator = myTracksProviderUtils.getTrackPointLocationIterator(track.getId(), -1L, false, MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||
locationIterator = contentProviderUtils.getTrackPointLocationIterator(track.getId(), -1L, false, ContentProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||
|
||||
while (locationIterator.hasNext()) {
|
||||
Location location = locationIterator.next();
|
||||
@@ -619,7 +619,7 @@ public class TrackRecordingService extends Service {
|
||||
PreferencesUtils.setBoolean(this, R.string.recording_track_paused_key, false);
|
||||
|
||||
// Update database
|
||||
Track track = myTracksProviderUtils.getTrack(recordingTrackId);
|
||||
Track track = contentProviderUtils.getTrack(recordingTrackId);
|
||||
if (track != null) {
|
||||
Location resume = new Location(LocationManager.GPS_PROVIDER);
|
||||
resume.setLongitude(0);
|
||||
@@ -678,20 +678,20 @@ public class TrackRecordingService extends Service {
|
||||
updateRecordingState(PreferencesUtils.RECORDING_TRACK_ID_DEFAULT, true);
|
||||
|
||||
// Update database
|
||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
if (track != null) {
|
||||
// If not paused, add the last location
|
||||
if (!paused) {
|
||||
insertLocation(track, lastLocation, getLastValidTrackPointInCurrentSegment(trackId));
|
||||
|
||||
// Update the recording track time
|
||||
updateRecordingTrack(track, myTracksProviderUtils.getLastTrackPointId(trackId), false);
|
||||
updateRecordingTrack(track, contentProviderUtils.getLastTrackPointId(trackId), false);
|
||||
}
|
||||
|
||||
String trackName = TrackNameUtils.getTrackName(this, trackId, track.getTripStatistics().getStartTime(), myTracksProviderUtils.getFirstValidTrackPoint(trackId));
|
||||
String trackName = TrackNameUtils.getTrackName(this, trackId, track.getTripStatistics().getStartTime(), contentProviderUtils.getFirstValidTrackPoint(trackId));
|
||||
if (trackName != null && !trackName.equals(track.getName())) {
|
||||
track.setName(trackName);
|
||||
myTracksProviderUtils.updateTrack(track);
|
||||
contentProviderUtils.updateTrack(track);
|
||||
}
|
||||
}
|
||||
endRecording(true, trackId);
|
||||
@@ -711,7 +711,7 @@ public class TrackRecordingService extends Service {
|
||||
PreferencesUtils.setBoolean(this, R.string.recording_track_paused_key, true);
|
||||
|
||||
// Update database
|
||||
Track track = myTracksProviderUtils.getTrack(recordingTrackId);
|
||||
Track track = contentProviderUtils.getTrack(recordingTrackId);
|
||||
if (track != null) {
|
||||
insertLocation(track, lastLocation, getLastValidTrackPointInCurrentSegment(track.getId()));
|
||||
|
||||
@@ -771,7 +771,7 @@ public class TrackRecordingService extends Service {
|
||||
if (!currentSegmentHasLocation) {
|
||||
return null;
|
||||
}
|
||||
return myTracksProviderUtils.getLastValidTrackPoint(trackId);
|
||||
return contentProviderUtils.getLastValidTrackPoint(trackId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -799,7 +799,7 @@ public class TrackRecordingService extends Service {
|
||||
return;
|
||||
}
|
||||
|
||||
Track track = myTracksProviderUtils.getTrack(recordingTrackId);
|
||||
Track track = contentProviderUtils.getTrack(recordingTrackId);
|
||||
if (track == null) {
|
||||
Log.w(TAG, "Ignore onLocationChangedAsync. No track.");
|
||||
return;
|
||||
@@ -833,7 +833,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
SensorDataSet sensorDataSet = getSensorDataSet();
|
||||
if (sensorDataSet != null) {
|
||||
location = new MyTracksLocation(location, sensorDataSet);
|
||||
location = new SensorDataSetLocation(location, sensorDataSet);
|
||||
}
|
||||
|
||||
// Always insert the first segment location
|
||||
@@ -910,7 +910,7 @@ public class TrackRecordingService extends Service {
|
||||
}
|
||||
|
||||
try {
|
||||
Uri uri = myTracksProviderUtils.insertTrackPoint(location, track.getId());
|
||||
Uri uri = contentProviderUtils.insertTrackPoint(location, track.getId());
|
||||
long trackPointId = Long.parseLong(uri.getLastPathSegment());
|
||||
trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval);
|
||||
markerTripStatisticsUpdater.addLocation(location, recordingDistanceInterval);
|
||||
@@ -949,7 +949,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
trackTripStatisticsUpdater.updateTime(System.currentTimeMillis());
|
||||
track.setTripStatistics(trackTripStatisticsUpdater.getTripStatistics());
|
||||
myTracksProviderUtils.updateTrack(track);
|
||||
contentProviderUtils.updateTrack(track);
|
||||
}
|
||||
|
||||
private SensorDataSet getSensorDataSet() {
|
||||
@@ -963,13 +963,13 @@ public class TrackRecordingService extends Service {
|
||||
* Registers the location listener.
|
||||
*/
|
||||
private void registerLocationListener() {
|
||||
if (myTracksLocationManager == null) {
|
||||
if (locationManagerConnector == null) {
|
||||
Log.e(TAG, "locationManager is null.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
long interval = locationListenerPolicy.getDesiredPollingInterval();
|
||||
myTracksLocationManager.requestLocationUpdates(interval, locationListenerPolicy.getMinDistance(), locationListener);
|
||||
locationManagerConnector.requestLocationUpdates(interval, locationListenerPolicy.getMinDistance(), locationListener);
|
||||
currentRecordingInterval = interval;
|
||||
} catch (RuntimeException e) {
|
||||
Log.e(TAG, "Could not register location listener.", e);
|
||||
@@ -980,11 +980,11 @@ public class TrackRecordingService extends Service {
|
||||
* Unregisters the location manager.
|
||||
*/
|
||||
private void unregisterLocationListener() {
|
||||
if (myTracksLocationManager == null) {
|
||||
if (locationManagerConnector == null) {
|
||||
Log.e(TAG, "locationManager is null.");
|
||||
return;
|
||||
}
|
||||
myTracksLocationManager.removeLocationUpdates(locationListener);
|
||||
locationManagerConnector.removeLocationUpdates(locationListener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 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.settings;
|
||||
|
||||
import com.google.android.apps.mytracks.util.DialogUtils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
/**
|
||||
* My Tracks edit text preference.
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class MyTracksEditTextPreference extends EditTextPreference {
|
||||
|
||||
public MyTracksEditTextPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public MyTracksEditTextPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showDialog(Bundle state) {
|
||||
super.showDialog(state);
|
||||
DialogUtils.setDialogTitleDivider(getContext(), getDialog());
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.io.file.TrackFileFormat;
|
||||
@@ -60,7 +60,7 @@ public class IntentUtils {
|
||||
* @param trackFileFormat the track file format
|
||||
*/
|
||||
public static Intent newShareFileIntent(Context context, long trackId, String filePath, TrackFileFormat trackFileFormat) {
|
||||
Track track = MyTracksProviderUtils.Factory.get(context).getTrack(trackId);
|
||||
Track track = ContentProviderUtils.Factory.get(context).getTrack(trackId);
|
||||
String trackDescription = track == null ? "" : new DescriptionGeneratorImpl(context).generateTrackDescription(track, null, null, false);
|
||||
|
||||
return new Intent(Intent.ACTION_SEND)
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SystemUtils {
|
||||
*
|
||||
* @return the version, or an empty string in case of failure.
|
||||
*/
|
||||
public static String getMyTracksVersion(Context context) {
|
||||
public static String getAppVersion(Context context) {
|
||||
try {
|
||||
PackageInfo pi = context.getPackageManager()
|
||||
.getPackageInfo("com.google.android.maps.mytracks", PackageManager.GET_META_DATA);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.android.apps.mytracks.util;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TrackUtils {
|
||||
|
||||
public static String TRACK_SORT_ORDER = TracksColumns.STARTTIME + " DESC";
|
||||
|
||||
public static void updateTrack(Context context, Track track, String name, String category, String description, MyTracksProviderUtils myTracksProviderUtils) {
|
||||
public static void updateTrack(Context context, Track track, String name, String category, String description, ContentProviderUtils contentProviderUtils) {
|
||||
if (name != null) {
|
||||
track.setName(name);
|
||||
}
|
||||
@@ -46,6 +46,6 @@ public class TrackUtils {
|
||||
track.setDescription(description);
|
||||
}
|
||||
track.setModifiedTime(System.currentTimeMillis());
|
||||
myTracksProviderUtils.updateTrack(track);
|
||||
contentProviderUtils.updateTrack(track);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.google.android.apps.mytracks.widgets;
|
||||
|
||||
import com.google.android.apps.mytracks.TrackDetailActivity;
|
||||
import com.google.android.apps.mytracks.TrackListActivity;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.ContentProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.services.ControlRecordingService;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
@@ -207,12 +207,12 @@ public class TrackWidgetProvider extends AppWidgetProvider {
|
||||
context, R.string.track_widget_item2, PreferencesUtils.TRACK_WIDGET_ITEM2_DEFAULT);
|
||||
|
||||
// Get track and trip statistics
|
||||
MyTracksProviderUtils myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
|
||||
ContentProviderUtils contentProviderUtils = ContentProviderUtils.Factory.get(context);
|
||||
if (trackId == -1L) {
|
||||
trackId = recordingTrackId;
|
||||
}
|
||||
Track track = trackId != -1L ? myTracksProviderUtils.getTrack(trackId)
|
||||
: myTracksProviderUtils.getLastTrack();
|
||||
Track track = trackId != -1L ? contentProviderUtils.getTrack(trackId)
|
||||
: contentProviderUtils.getLastTrack();
|
||||
TripStatistics tripStatistics = track == null ? null : track.getTripStatistics();
|
||||
|
||||
updateStatisticsContainer(context, remoteViews, track);
|
||||
|
||||
Reference in New Issue
Block a user