From 1d3a03909b6894e3c760c97144a9b35f0ca7d1d4 Mon Sep 17 00:00:00 2001 From: Benjamin Hardill b hardill Date: Tue, 26 Apr 2011 00:43:20 +0100 Subject: [PATCH] Added Track as an extra to the Intent used with Intent.ACTION_SEND Also removed the Locations ArrayList from the Track writeToParcel and createFromParcel as it's no longer populated --- .../src/com/google/android/apps/mytracks/Constants.java | 8 ++++++++ .../src/com/google/android/apps/mytracks/MyTracks.java | 6 +++++- .../com/google/android/apps/mytracks/content/Track.java | 7 ------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/MyTracks/src/com/google/android/apps/mytracks/Constants.java b/MyTracks/src/com/google/android/apps/mytracks/Constants.java index c3fc58acf..105687c5d 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/Constants.java +++ b/MyTracks/src/com/google/android/apps/mytracks/Constants.java @@ -187,6 +187,14 @@ public abstract class Constants { public static final String RESUME_TRACK_EXTRA_NAME = "com.google.android.apps.mytracks.RESUME_TRACK"; + /** + * The name of the extra intent property that holds the track information + * when sharing with friends + */ + public static final String TRACK_EXTRA = + "com.google.android.apps.mytracks.TRACK"; + + public static int getActionFromMenuId(int menuId) { switch (menuId) { case Constants.MENU_SEND_TO_GOOGLE: diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java index a69eb6910..6795e656f 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java @@ -16,6 +16,7 @@ package com.google.android.apps.mytracks; import static com.google.android.apps.mytracks.Constants.TAG; +import static com.google.android.apps.mytracks.Constants.TRACK_EXTRA; import static com.google.android.apps.mytracks.DialogManager.DIALOG_IMPORT_PROGRESS; import static com.google.android.apps.mytracks.DialogManager.DIALOG_PROGRESS; import static com.google.android.apps.mytracks.DialogManager.DIALOG_SEND_TO_GOOGLE; @@ -1244,7 +1245,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, * * @param trackId The id of the track to be sent */ - public void sendTrack(long trackId, final TrackFileFormat format) { + public void sendTrack(final long trackId, final TrackFileFormat format) { TrackWriter writer = TrackWriterFactory.newWriter(this, providerUtils, trackId, format); FileUtils fileUtils = new FileUtils(); @@ -1272,6 +1273,9 @@ public class MyTracks extends TabActivity implements OnTouchListener, shareIntent.setType(format.getMimeType()); Uri u = Uri.fromFile(new File(writer.getAbsolutePath())); shareIntent.putExtra(Intent.EXTRA_STREAM, u); + MyTracksProviderUtils myTracksProviderUtils = MyTracksProviderUtils.Factory.get(MyTracks.this); + Track track = myTracksProviderUtils.getTrack(trackId); + shareIntent.putExtra(TRACK_EXTRA, track); startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.share_track).toString())); } diff --git a/MyTracksLib/src/com/google/android/apps/mytracks/content/Track.java b/MyTracksLib/src/com/google/android/apps/mytracks/content/Track.java index cf963fff7..f629a73a9 100644 --- a/MyTracksLib/src/com/google/android/apps/mytracks/content/Track.java +++ b/MyTracksLib/src/com/google/android/apps/mytracks/content/Track.java @@ -51,10 +51,6 @@ public class Track implements Parcelable { track.stats = source.readParcelable(classLoader); track.numberOfPoints = source.readInt(); - for (int i = 0; i < track.numberOfPoints; ++i) { - Location loc = source.readParcelable(classLoader); - track.locations.add(loc); - } track.tableId = source.readString(); return track; @@ -103,9 +99,6 @@ public class Track implements Parcelable { dest.writeParcelable(stats, 0); dest.writeInt(numberOfPoints); - for (int i = 0; i < numberOfPoints; ++i) { - dest.writeParcelable(locations.get(i), 0); - } dest.writeString(tableId); }