forked from upstream-mirrors/OpenTracks
Add the owner of the shared with me tracks.
This commit is contained in:
@@ -74,7 +74,6 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onPrepare(Menu menu, int position, long id) {
|
public void onPrepare(Menu menu, int position, long id) {
|
||||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
|
||||||
menu.findItem(R.id.list_context_menu_share_drive).setVisible(false);
|
menu.findItem(R.id.list_context_menu_share_drive).setVisible(false);
|
||||||
menu.findItem(R.id.list_context_menu_show_on_map).setVisible(true);
|
menu.findItem(R.id.list_context_menu_show_on_map).setVisible(true);
|
||||||
menu.findItem(R.id.list_context_menu_edit).setVisible(!track.isSharedWithMe());
|
menu.findItem(R.id.list_context_menu_edit).setVisible(!track.isSharedWithMe());
|
||||||
@@ -119,7 +118,7 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
private long recordingTrackId = PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
|
private long recordingTrackId = PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
|
||||||
private boolean recordingTrackPaused = PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT;
|
private boolean recordingTrackPaused = PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT;
|
||||||
|
|
||||||
private long trackId = -1;
|
private Track track;
|
||||||
private ResourceCursorAdapter resourceCursorAdapter;
|
private ResourceCursorAdapter resourceCursorAdapter;
|
||||||
|
|
||||||
// UI elements
|
// UI elements
|
||||||
@@ -132,13 +131,14 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
|
|
||||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||||
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||||
trackId = getIntent().getLongExtra(EXTRA_TRACK_ID, -1L);
|
long trackId = getIntent().getLongExtra(EXTRA_TRACK_ID, -1L);
|
||||||
if (trackId == -1L) {
|
if (trackId == -1L) {
|
||||||
Log.d(TAG, "invalid track id");
|
Log.d(TAG, "invalid track id");
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
track = myTracksProviderUtils.getTrack(trackId);
|
||||||
|
|
||||||
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
|
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
|
||||||
|
|
||||||
ListView listView = (ListView) findViewById(R.id.marker_list);
|
ListView listView = (ListView) findViewById(R.id.marker_list);
|
||||||
@@ -165,10 +165,9 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
int iconId = statistics ? R.drawable.yellow_pushpin : R.drawable.blue_pushpin;
|
int iconId = statistics ? R.drawable.yellow_pushpin : R.drawable.blue_pushpin;
|
||||||
String category = statistics ? null : cursor.getString(categoryIndex);
|
String category = statistics ? null : cursor.getString(categoryIndex);
|
||||||
String description = statistics ? null : cursor.getString(descriptionIndex);
|
String description = statistics ? null : cursor.getString(descriptionIndex);
|
||||||
|
|
||||||
ListItemUtils.setListItem(MarkerListActivity.this, view, false, true, iconId,
|
ListItemUtils.setListItem(MarkerListActivity.this, view, false, true, iconId,
|
||||||
R.string.icon_marker, cursor.getString(nameIndex), category, null, null,
|
R.string.icon_marker, cursor.getString(nameIndex), category, null, null,
|
||||||
cursor.getLong(timeIndex), description);
|
cursor.getLong(timeIndex), description, track.getSharedOwner());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
listView.setAdapter(resourceCursorAdapter);
|
listView.setAdapter(resourceCursorAdapter);
|
||||||
@@ -181,7 +180,7 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
|
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
|
||||||
return new CursorLoader(MarkerListActivity.this, WaypointsColumns.CONTENT_URI, PROJECTION,
|
return new CursorLoader(MarkerListActivity.this, WaypointsColumns.CONTENT_URI, PROJECTION,
|
||||||
WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns._ID + "!=?",
|
WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns._ID + "!=?",
|
||||||
new String[] { String.valueOf(trackId), String.valueOf(firstWaypointId) }, null);
|
new String[] { String.valueOf(track.getId()), String.valueOf(firstWaypointId) }, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -232,7 +231,7 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
|
|
||||||
private void updateMenu() {
|
private void updateMenu() {
|
||||||
if (insertMarkerMenuItem != null) {
|
if (insertMarkerMenuItem != null) {
|
||||||
insertMarkerMenuItem.setVisible(trackId == recordingTrackId && !recordingTrackPaused);
|
insertMarkerMenuItem.setVisible(track.getId() == recordingTrackId && !recordingTrackPaused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +240,7 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.marker_list_insert_marker:
|
case R.id.marker_list_insert_marker:
|
||||||
Intent intent = IntentUtils.newIntent(this, MarkerEditActivity.class)
|
Intent intent = IntentUtils.newIntent(this, MarkerEditActivity.class)
|
||||||
.putExtra(MarkerEditActivity.EXTRA_TRACK_ID, trackId);
|
.putExtra(MarkerEditActivity.EXTRA_TRACK_ID, track.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.marker_list_search:
|
case R.id.marker_list_search:
|
||||||
@@ -287,7 +286,7 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.list_context_menu_delete:
|
case R.id.list_context_menu_delete:
|
||||||
DeleteOneMarkerDialogFragment.newInstance(markerId, trackId).show(
|
DeleteOneMarkerDialogFragment.newInstance(markerId, track.getId()).show(
|
||||||
getSupportFragmentManager(),
|
getSupportFragmentManager(),
|
||||||
DeleteOneMarkerDialogFragment.DELETE_ONE_MARKER_DIALOG_TAG);
|
DeleteOneMarkerDialogFragment.DELETE_ONE_MARKER_DIALOG_TAG);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public class SearchListActivity extends AbstractMyTracksActivity
|
|||||||
private static final String TOTAL_DISTANCE_FIELD = "totalDistance";
|
private static final String TOTAL_DISTANCE_FIELD = "totalDistance";
|
||||||
private static final String START_TIME_FIELD = "startTime";
|
private static final String START_TIME_FIELD = "startTime";
|
||||||
private static final String DESCRIPTION_FIELD = "description";
|
private static final String DESCRIPTION_FIELD = "description";
|
||||||
|
private static final String SHARED_OWNER_FIELD = "sharedOwner";
|
||||||
private static final String TRACK_ID_FIELD = "trackId";
|
private static final String TRACK_ID_FIELD = "trackId";
|
||||||
private static final String MARKER_ID_FIELD = "markerId";
|
private static final String MARKER_ID_FIELD = "markerId";
|
||||||
|
|
||||||
@@ -216,10 +217,10 @@ public class SearchListActivity extends AbstractMyTracksActivity
|
|||||||
String totalDistance = (String) resultMap.get(TOTAL_DISTANCE_FIELD);
|
String totalDistance = (String) resultMap.get(TOTAL_DISTANCE_FIELD);
|
||||||
Long startTime = (Long) resultMap.get(START_TIME_FIELD);
|
Long startTime = (Long) resultMap.get(START_TIME_FIELD);
|
||||||
String description = (String) resultMap.get(DESCRIPTION_FIELD);
|
String description = (String) resultMap.get(DESCRIPTION_FIELD);
|
||||||
|
String sharedOwner = (String) resultMap.get(SHARED_OWNER_FIELD);
|
||||||
ListItemUtils.setListItem(SearchListActivity.this, view, isRecording, isPaused, iconId,
|
ListItemUtils.setListItem(SearchListActivity.this, view, isRecording, isPaused, iconId,
|
||||||
iconContentDescriptionId, name, category, totalTime, totalDistance, startTime,
|
iconContentDescriptionId, name, category, totalTime, totalDistance, startTime,
|
||||||
description);
|
description, sharedOwner);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -452,11 +453,13 @@ public class SearchListActivity extends AbstractMyTracksActivity
|
|||||||
* the retrieval phase of the search.
|
* the retrieval phase of the search.
|
||||||
*/
|
*/
|
||||||
String trackName = null;
|
String trackName = null;
|
||||||
|
String sharedOwner = null;
|
||||||
long trackId = waypoint.getTrackId();
|
long trackId = waypoint.getTrackId();
|
||||||
if (trackId != -1L) {
|
if (trackId != -1L) {
|
||||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||||
if (track != null) {
|
if (track != null) {
|
||||||
trackName = track.getName();
|
trackName = track.getName();
|
||||||
|
sharedOwner = track.getSharedOwner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,6 +477,7 @@ public class SearchListActivity extends AbstractMyTracksActivity
|
|||||||
resultMap.put(TOTAL_DISTANCE_FIELD, null);
|
resultMap.put(TOTAL_DISTANCE_FIELD, null);
|
||||||
resultMap.put(START_TIME_FIELD, waypoint.getLocation().getTime());
|
resultMap.put(START_TIME_FIELD, waypoint.getLocation().getTime());
|
||||||
resultMap.put(DESCRIPTION_FIELD, statistics ? null : waypoint.getDescription());
|
resultMap.put(DESCRIPTION_FIELD, statistics ? null : waypoint.getDescription());
|
||||||
|
resultMap.put(SHARED_OWNER_FIELD, sharedOwner);
|
||||||
resultMap.put(TRACK_ID_FIELD, waypoint.getTrackId());
|
resultMap.put(TRACK_ID_FIELD, waypoint.getTrackId());
|
||||||
resultMap.put(MARKER_ID_FIELD, waypoint.getId());
|
resultMap.put(MARKER_ID_FIELD, waypoint.getId());
|
||||||
}
|
}
|
||||||
@@ -500,6 +504,7 @@ public class SearchListActivity extends AbstractMyTracksActivity
|
|||||||
StringUtils.formatDistance(this, tripStatitics.getTotalDistance(), metricUnits));
|
StringUtils.formatDistance(this, tripStatitics.getTotalDistance(), metricUnits));
|
||||||
resultMap.put(START_TIME_FIELD, tripStatitics.getStartTime());
|
resultMap.put(START_TIME_FIELD, tripStatitics.getStartTime());
|
||||||
resultMap.put(DESCRIPTION_FIELD, track.getDescription());
|
resultMap.put(DESCRIPTION_FIELD, track.getDescription());
|
||||||
|
resultMap.put(SHARED_OWNER_FIELD, track.getSharedOwner());
|
||||||
resultMap.put(TRACK_ID_FIELD, track.getId());
|
resultMap.put(TRACK_ID_FIELD, track.getId());
|
||||||
resultMap.put(MARKER_ID_FIELD, null);
|
resultMap.put(MARKER_ID_FIELD, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public class TrackListActivity extends FragmentActivity
|
|||||||
private static final String[] PROJECTION = new String[] { TracksColumns._ID, TracksColumns.NAME,
|
private static final String[] PROJECTION = new String[] { TracksColumns._ID, TracksColumns.NAME,
|
||||||
TracksColumns.DESCRIPTION, TracksColumns.CATEGORY, TracksColumns.STARTTIME,
|
TracksColumns.DESCRIPTION, TracksColumns.CATEGORY, TracksColumns.STARTTIME,
|
||||||
TracksColumns.TOTALDISTANCE, TracksColumns.TOTALTIME, TracksColumns.ICON,
|
TracksColumns.TOTALDISTANCE, TracksColumns.TOTALTIME, TracksColumns.ICON,
|
||||||
TracksColumns.SHAREDWITHME };
|
TracksColumns.SHAREDWITHME, TracksColumns.SHAREDOWNER };
|
||||||
|
|
||||||
// Callback when the trackRecordingServiceConnection binding changes.
|
// Callback when the trackRecordingServiceConnection binding changes.
|
||||||
private final Runnable bindChangedCallback = new Runnable() {
|
private final Runnable bindChangedCallback = new Runnable() {
|
||||||
@@ -391,7 +391,8 @@ public class TrackListActivity extends FragmentActivity
|
|||||||
int totalDistanceIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALDISTANCE);
|
int totalDistanceIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALDISTANCE);
|
||||||
int startTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.STARTTIME);
|
int startTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.STARTTIME);
|
||||||
int descriptionIndex = cursor.getColumnIndex(TracksColumns.DESCRIPTION);
|
int descriptionIndex = cursor.getColumnIndex(TracksColumns.DESCRIPTION);
|
||||||
|
int sharedOwnerIndex = cursor.getColumnIndex(TracksColumns.SHAREDOWNER);
|
||||||
|
|
||||||
boolean isRecording = cursor.getLong(idIndex) == recordingTrackId;
|
boolean isRecording = cursor.getLong(idIndex) == recordingTrackId;
|
||||||
String icon = cursor.getString(iconIndex);
|
String icon = cursor.getString(iconIndex);
|
||||||
int iconId = TrackIconUtils.getIconDrawable(icon);
|
int iconId = TrackIconUtils.getIconDrawable(icon);
|
||||||
@@ -402,10 +403,11 @@ public class TrackListActivity extends FragmentActivity
|
|||||||
TrackListActivity.this, cursor.getDouble(totalDistanceIndex), metricUnits);
|
TrackListActivity.this, cursor.getDouble(totalDistanceIndex), metricUnits);
|
||||||
long startTime = cursor.getLong(startTimeIndex);
|
long startTime = cursor.getLong(startTimeIndex);
|
||||||
String description = cursor.getString(descriptionIndex);
|
String description = cursor.getString(descriptionIndex);
|
||||||
|
String sharedOwner = cursor.getString(sharedOwnerIndex);
|
||||||
|
|
||||||
ListItemUtils.setListItem(TrackListActivity.this, view, isRecording, recordingTrackPaused,
|
ListItemUtils.setListItem(TrackListActivity.this, view, isRecording, recordingTrackPaused,
|
||||||
iconId, R.string.icon_track, name, category, totalTime, totalDistance, startTime,
|
iconId, R.string.icon_track, name, category, totalTime, totalDistance, startTime,
|
||||||
description);
|
description, sharedOwner);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
listView.setAdapter(sectionResourceCursorAdapter);
|
listView.setAdapter(sectionResourceCursorAdapter);
|
||||||
|
|||||||
@@ -120,6 +120,9 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
Log.w(TAG, "Upgrade DB: Adding sharedwithme column.");
|
Log.w(TAG, "Upgrade DB: Adding sharedwithme column.");
|
||||||
db.execSQL("ALTER TABLE " + TracksColumns.TABLE_NAME + " ADD "
|
db.execSQL("ALTER TABLE " + TracksColumns.TABLE_NAME + " ADD "
|
||||||
+ TracksColumns.SHAREDWITHME + " INTEGER");
|
+ TracksColumns.SHAREDWITHME + " INTEGER");
|
||||||
|
Log.w(TAG, "Upgrade DB: Adding sharedowner column.");
|
||||||
|
db.execSQL("ALTER TABLE " + TracksColumns.TABLE_NAME + " ADD " + TracksColumns.SHAREDOWNER
|
||||||
|
+ " STRING");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,10 +90,7 @@ public class SendDriveAsyncTask extends AbstractSendAsyncTask {
|
|||||||
addPermission(drive, driveId);
|
addPermission(drive, driveId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
track.setDriveId("");
|
SyncUtils.updateTrackWithDriveFileInfo(myTracksProviderUtils, track, null);
|
||||||
track.setModifiedTime(-1L);
|
|
||||||
track.setSharedWithMe(false);
|
|
||||||
myTracksProviderUtils.updateTrack(track);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = SyncUtils.insertDriveFile(
|
String id = SyncUtils.insertDriveFile(
|
||||||
|
|||||||
@@ -300,10 +300,7 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter {
|
|||||||
long[] trackIds = kmlImporter.importFile(inputStream);
|
long[] trackIds = kmlImporter.importFile(inputStream);
|
||||||
if (trackIds.length == 1) {
|
if (trackIds.length == 1) {
|
||||||
Track track = myTracksProviderUtils.getTrack(trackIds[0]);
|
Track track = myTracksProviderUtils.getTrack(trackIds[0]);
|
||||||
track.setDriveId(driveFile.getId());
|
SyncUtils.updateTrackWithDriveFileInfo(myTracksProviderUtils, track, driveFile);
|
||||||
track.setModifiedTime(driveFile.getModifiedDate().getValue());
|
|
||||||
track.setSharedWithMe(driveFile.getSharedWithMeDate() != null);
|
|
||||||
myTracksProviderUtils.updateTrack(track);
|
|
||||||
Log.d(TAG, "Add from Google Drive " + track.getName());
|
Log.d(TAG, "Add from Google Drive " + track.getName());
|
||||||
} else {
|
} else {
|
||||||
// Clean up if imported more than one track
|
// Clean up if imported more than one track
|
||||||
@@ -445,10 +442,7 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter {
|
|||||||
long[] trackIds = kmlImporter.importFile(inputStream);
|
long[] trackIds = kmlImporter.importFile(inputStream);
|
||||||
if (trackIds.length == 1) {
|
if (trackIds.length == 1) {
|
||||||
Track newTrack = myTracksProviderUtils.getTrack(trackIds[0]);
|
Track newTrack = myTracksProviderUtils.getTrack(trackIds[0]);
|
||||||
newTrack.setDriveId(driveFile.getId());
|
SyncUtils.updateTrackWithDriveFileInfo(myTracksProviderUtils, newTrack, driveFile);
|
||||||
newTrack.setModifiedTime(driveFile.getModifiedByMeDate().getValue());
|
|
||||||
newTrack.setSharedWithMe(driveFile.getSharedWithMeDate() != null);
|
|
||||||
myTracksProviderUtils.updateTrack(newTrack);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Unable to merge, imported size is not 1");
|
Log.e(TAG, "Unable to merge, imported size is not 1");
|
||||||
|
|||||||
@@ -247,12 +247,8 @@ public class SyncUtils {
|
|||||||
Log.e(TAG, "Unable to add Drive file. Uploaded file is null for track " + track.getName());
|
Log.e(TAG, "Unable to add Drive file. Uploaded file is null for track " + track.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String id = uploadedFile.getId();
|
SyncUtils.updateTrackWithDriveFileInfo(myTracksProviderUtils, track, uploadedFile);
|
||||||
track.setDriveId(id);
|
return uploadedFile.getId();
|
||||||
track.setModifiedTime(uploadedFile.getModifiedDate().getValue());
|
|
||||||
track.setSharedWithMe(false);
|
|
||||||
myTracksProviderUtils.updateTrack(track);
|
|
||||||
return id;
|
|
||||||
} finally {
|
} finally {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
@@ -407,6 +403,24 @@ public class SyncUtils {
|
|||||||
Log.d(TAG, "Unable to get file for track " + track.getName());
|
Log.d(TAG, "Unable to get file for track " + track.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates track with drive file info.
|
||||||
|
*
|
||||||
|
* @param myTracksProviderUtils the myTracksProviderUtils
|
||||||
|
* @param track the track
|
||||||
|
* @param driveFile the drive file
|
||||||
|
*/
|
||||||
|
public static void updateTrackWithDriveFileInfo(
|
||||||
|
MyTracksProviderUtils myTracksProviderUtils, Track track, File driveFile) {
|
||||||
|
track.setDriveId(driveFile != null ? driveFile.getId() : "");
|
||||||
|
track.setModifiedTime(driveFile != null ? driveFile.getModifiedDate().getValue() : -1L);
|
||||||
|
track.setSharedWithMe(driveFile != null ? driveFile.getSharedWithMeDate() != null : false);
|
||||||
|
track.setSharedOwner(driveFile != null && driveFile.getSharedWithMeDate() != null
|
||||||
|
&& driveFile.getOwnerNames().size() > 0 ? driveFile.getOwnerNames().get(0)
|
||||||
|
: "");
|
||||||
|
myTracksProviderUtils.updateTrack(track);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the md5 digest for the file.
|
* Gets the md5 digest for the file.
|
||||||
|
|||||||
@@ -232,10 +232,7 @@ public class GoogleSettingsActivity extends AbstractSettingsActivity {
|
|||||||
if (track.isSharedWithMe()) {
|
if (track.isSharedWithMe()) {
|
||||||
myTracksProviderUtils.deleteTrack(track.getId());
|
myTracksProviderUtils.deleteTrack(track.getId());
|
||||||
} else {
|
} else {
|
||||||
track.setDriveId("");
|
SyncUtils.updateTrackWithDriveFileInfo(myTracksProviderUtils, track, null);
|
||||||
track.setModifiedTime(-1L);
|
|
||||||
track.setSharedWithMe(false);
|
|
||||||
myTracksProviderUtils.updateTrack(track);
|
|
||||||
}
|
}
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ListItemUtils {
|
|||||||
*/
|
*/
|
||||||
public static void setListItem(Context context, View view, boolean isRecording, boolean isPaused,
|
public static void setListItem(Context context, View view, boolean isRecording, boolean isPaused,
|
||||||
int iconId, int iconContentDescriptionId, String name, String category, String totalTime,
|
int iconId, int iconContentDescriptionId, String name, String category, String totalTime,
|
||||||
String totalDistance, long startTime, String description) {
|
String totalDistance, long startTime, String description, String sharedOwner) {
|
||||||
|
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
iconId = isPaused ? R.drawable.track_paused : R.drawable.track_recording;
|
iconId = isPaused ? R.drawable.track_paused : R.drawable.track_recording;
|
||||||
@@ -69,7 +69,8 @@ public class ListItemUtils {
|
|||||||
nameTextView.setText(name);
|
nameTextView.setText(name);
|
||||||
|
|
||||||
TextView timeDistanceTextView = (TextView) view.findViewById(R.id.list_item_time_distance);
|
TextView timeDistanceTextView = (TextView) view.findViewById(R.id.list_item_time_distance);
|
||||||
setTextView(timeDistanceTextView, getTimeDistance(isRecording, totalTime, totalDistance), 0);
|
setTextView(timeDistanceTextView,
|
||||||
|
getTimeDistance(isRecording, sharedOwner, totalTime, totalDistance), 0);
|
||||||
|
|
||||||
String[] startTimeDisplay = getStartTime(isRecording, context, startTime);
|
String[] startTimeDisplay = getStartTime(isRecording, context, startTime);
|
||||||
TextView dateTextView = (TextView) view.findViewById(R.id.list_item_date);
|
TextView dateTextView = (TextView) view.findViewById(R.id.list_item_date);
|
||||||
@@ -95,21 +96,32 @@ public class ListItemUtils {
|
|||||||
* Gets the time/distance text.
|
* Gets the time/distance text.
|
||||||
*
|
*
|
||||||
* @param isRecording true if recording
|
* @param isRecording true if recording
|
||||||
|
* @param sharedOwner the shared owner
|
||||||
* @param totalTime the total time
|
* @param totalTime the total time
|
||||||
* @param totalDistance the total distance
|
* @param totalDistance the total distance
|
||||||
*/
|
*/
|
||||||
private static String getTimeDistance(
|
private static String getTimeDistance(
|
||||||
boolean isRecording, String totalTime, String totalDistance) {
|
boolean isRecording, String sharedOwner, String totalTime, String totalDistance) {
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (totalDistance == null || totalDistance.length() == 0) {
|
StringBuffer buffer = new StringBuffer();
|
||||||
return totalTime;
|
if (sharedOwner != null && sharedOwner.length() != 0) {
|
||||||
|
buffer.append(sharedOwner);
|
||||||
}
|
}
|
||||||
if (totalTime == null || totalTime.length() == 0) {
|
if (totalTime != null && totalTime.length() != 0) {
|
||||||
return totalDistance;
|
if (buffer.length() != 0) {
|
||||||
|
buffer.append(" \u2027" );
|
||||||
|
}
|
||||||
|
buffer.append(totalDistance);
|
||||||
|
}
|
||||||
|
if (totalDistance != null && totalDistance.length() != 0) {
|
||||||
|
if (buffer.length() != 0) {
|
||||||
|
buffer.append(" ");
|
||||||
|
}
|
||||||
|
buffer.append("(" + totalDistance + ")");
|
||||||
}
|
}
|
||||||
return totalTime + " (" + totalDistance + ")";
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+6
-1
@@ -88,7 +88,8 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
int driveIdIndex = cursor.getColumnIndexOrThrow(TracksColumns.DRIVEID);
|
int driveIdIndex = cursor.getColumnIndexOrThrow(TracksColumns.DRIVEID);
|
||||||
int modifiedTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MODIFIEDTIME);
|
int modifiedTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MODIFIEDTIME);
|
||||||
int sharedWithMeIndex = cursor.getColumnIndexOrThrow(TracksColumns.SHAREDWITHME);
|
int sharedWithMeIndex = cursor.getColumnIndexOrThrow(TracksColumns.SHAREDWITHME);
|
||||||
|
int sharedOwnerIndex = cursor.getColumnIndexOrThrow(TracksColumns.SHAREDOWNER);
|
||||||
|
|
||||||
Track track = new Track();
|
Track track = new Track();
|
||||||
TripStatistics tripStatistics = track.getTripStatistics();
|
TripStatistics tripStatistics = track.getTripStatistics();
|
||||||
if (!cursor.isNull(idIndex)) {
|
if (!cursor.isNull(idIndex)) {
|
||||||
@@ -171,6 +172,9 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
if (!cursor.isNull(sharedWithMeIndex)) {
|
if (!cursor.isNull(sharedWithMeIndex)) {
|
||||||
track.setSharedWithMe(cursor.getInt(sharedWithMeIndex) == 1);
|
track.setSharedWithMe(cursor.getInt(sharedWithMeIndex) == 1);
|
||||||
}
|
}
|
||||||
|
if (!cursor.isNull(sharedOwnerIndex)) {
|
||||||
|
track.setSharedOwner(cursor.getString(sharedOwnerIndex));
|
||||||
|
}
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,6 +325,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
values.put(TracksColumns.DRIVEID, track.getDriveId());
|
values.put(TracksColumns.DRIVEID, track.getDriveId());
|
||||||
values.put(TracksColumns.MODIFIEDTIME, track.getModifiedTime());
|
values.put(TracksColumns.MODIFIEDTIME, track.getModifiedTime());
|
||||||
values.put(TracksColumns.SHAREDWITHME, track.isSharedWithMe());
|
values.put(TracksColumns.SHAREDWITHME, track.isSharedWithMe());
|
||||||
|
values.put(TracksColumns.SHAREDOWNER, track.getSharedOwner());
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class Track implements Parcelable {
|
|||||||
private String driveId = "";
|
private String driveId = "";
|
||||||
private long modifiedTime = -1L;
|
private long modifiedTime = -1L;
|
||||||
private boolean sharedWithMe = false;
|
private boolean sharedWithMe = false;
|
||||||
|
private String sharedOwner = "";
|
||||||
|
|
||||||
private TripStatistics tripStatistics = new TripStatistics();
|
private TripStatistics tripStatistics = new TripStatistics();
|
||||||
|
|
||||||
@@ -72,6 +73,7 @@ public class Track implements Parcelable {
|
|||||||
driveId = in.readString();
|
driveId = in.readString();
|
||||||
modifiedTime = in.readLong();
|
modifiedTime = in.readLong();
|
||||||
sharedWithMe = in.readByte() == 1;
|
sharedWithMe = in.readByte() == 1;
|
||||||
|
sharedOwner = in.readString();
|
||||||
|
|
||||||
ClassLoader classLoader = getClass().getClassLoader();
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
tripStatistics = in.readParcelable(classLoader);
|
tripStatistics = in.readParcelable(classLoader);
|
||||||
@@ -102,6 +104,7 @@ public class Track implements Parcelable {
|
|||||||
dest.writeString(driveId);
|
dest.writeString(driveId);
|
||||||
dest.writeLong(modifiedTime);
|
dest.writeLong(modifiedTime);
|
||||||
dest.writeByte((byte) (sharedWithMe ? 1 : 0));
|
dest.writeByte((byte) (sharedWithMe ? 1 : 0));
|
||||||
|
dest.writeString(sharedOwner);
|
||||||
|
|
||||||
dest.writeParcelable(tripStatistics, 0);
|
dest.writeParcelable(tripStatistics, 0);
|
||||||
for (int i = 0; i < numberOfPoints; ++i) {
|
for (int i = 0; i < numberOfPoints; ++i) {
|
||||||
@@ -225,6 +228,14 @@ public class Track implements Parcelable {
|
|||||||
this.sharedWithMe = sharedWithMe;
|
this.sharedWithMe = sharedWithMe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSharedOwner() {
|
||||||
|
return sharedOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSharedOwner(String sharedOwner) {
|
||||||
|
this.sharedOwner = sharedOwner;
|
||||||
|
}
|
||||||
|
|
||||||
public TripStatistics getTripStatistics() {
|
public TripStatistics getTripStatistics() {
|
||||||
return tripStatistics;
|
return tripStatistics;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ public interface TracksColumns extends BaseColumns {
|
|||||||
// 1 if the Google Drive file is from the "Shared with me" directory
|
// 1 if the Google Drive file is from the "Shared with me" directory
|
||||||
public static final String SHAREDWITHME = "sharedwithme";
|
public static final String SHAREDWITHME = "sharedwithme";
|
||||||
|
|
||||||
|
// The owner of the shared with me track
|
||||||
|
public static final String SHAREDOWNER = "sharedOwner";
|
||||||
|
|
||||||
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" // table
|
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" // table
|
||||||
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " // id
|
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " // id
|
||||||
+ NAME + " STRING, " // name
|
+ NAME + " STRING, " // name
|
||||||
@@ -116,7 +119,8 @@ public interface TracksColumns extends BaseColumns {
|
|||||||
+ ICON + " STRING, " // icon
|
+ ICON + " STRING, " // icon
|
||||||
+ DRIVEID + " STRING, " // drive id
|
+ DRIVEID + " STRING, " // drive id
|
||||||
+ MODIFIEDTIME + " INTEGER, " // modified time
|
+ MODIFIEDTIME + " INTEGER, " // modified time
|
||||||
+ SHAREDWITHME + " INTEGER" + ");"; // shared with me
|
+ SHAREDWITHME + " INTEGER, " // shared with me
|
||||||
|
+ SHAREDOWNER + " STRING" + ");"; // shared owner
|
||||||
|
|
||||||
public static final String[] COLUMNS = { _ID, // id
|
public static final String[] COLUMNS = { _ID, // id
|
||||||
NAME, // name
|
NAME, // name
|
||||||
@@ -147,7 +151,8 @@ public interface TracksColumns extends BaseColumns {
|
|||||||
ICON, // icon
|
ICON, // icon
|
||||||
DRIVEID, // drive id
|
DRIVEID, // drive id
|
||||||
MODIFIEDTIME, // modified time
|
MODIFIEDTIME, // modified time
|
||||||
SHAREDWITHME }; // shared with me
|
SHAREDWITHME, // shared with me
|
||||||
|
SHAREDOWNER }; // shared owner
|
||||||
|
|
||||||
public static final byte[] COLUMN_TYPES = { ContentTypeIds.LONG_TYPE_ID, // id
|
public static final byte[] COLUMN_TYPES = { ContentTypeIds.LONG_TYPE_ID, // id
|
||||||
ContentTypeIds.STRING_TYPE_ID, // name
|
ContentTypeIds.STRING_TYPE_ID, // name
|
||||||
@@ -178,6 +183,7 @@ public interface TracksColumns extends BaseColumns {
|
|||||||
ContentTypeIds.STRING_TYPE_ID, // icon
|
ContentTypeIds.STRING_TYPE_ID, // icon
|
||||||
ContentTypeIds.STRING_TYPE_ID, // drive id
|
ContentTypeIds.STRING_TYPE_ID, // drive id
|
||||||
ContentTypeIds.LONG_TYPE_ID, // modified time
|
ContentTypeIds.LONG_TYPE_ID, // modified time
|
||||||
ContentTypeIds.BOOLEAN_TYPE_ID // shared with me
|
ContentTypeIds.BOOLEAN_TYPE_ID, // shared with me
|
||||||
|
ContentTypeIds.STRING_TYPE_ID // shared owner
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user