Improving intent handling so each activity receives its data type.

This commit is contained in:
Rodrigo Damazio
2011-05-25 19:17:34 -03:00
parent eeaa50ddcb
commit e8a872d351
3 changed files with 87 additions and 12 deletions
+50 -8
View File
@@ -44,6 +44,13 @@ limitations under the License.
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.track" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.ATTACH_DATA" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" /> <data android:scheme="file" />
<data android:mimeType="application/gpx+xml" /> <data android:mimeType="application/gpx+xml" />
<data android:mimeType="application/gpx" /> <data android:mimeType="application/gpx" />
@@ -54,48 +61,83 @@ limitations under the License.
<activity android:name="com.google.android.apps.mytracks.MapActivity" <activity android:name="com.google.android.apps.mytracks.MapActivity"
android:label="MyTracks" android:label="MyTracks"
android:exported="false" /> android:exported="false">
<intent-filter>
<category android:name="android.intent.category.TAB" />
</intent-filter>
</activity>
<activity android:name="com.google.android.apps.mytracks.MyMapsList" <activity android:name="com.google.android.apps.mytracks.MyMapsList"
android:label="@string/map_list_title" android:label="@string/map_list_title"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale"
android:exported="false" /> android:exported="false" />
<!-- TODO: VIEW and PICK for track cursor dir -->
<activity android:name="com.google.android.apps.mytracks.TrackList" <activity android:name="com.google.android.apps.mytracks.TrackList"
android:label="Recorded Tracks" /> android:label="Recorded Tracks" />
<!-- TODO: VIEW and PICK for waypoint cursor dir -->
<activity android:name="com.google.android.apps.mytracks.WaypointsList" <activity android:name="com.google.android.apps.mytracks.WaypointsList"
android:label="Recorded Waypoints" /> android:label="Recorded Waypoints" />
<activity android:name="com.google.android.apps.mytracks.TrackDetails" <activity android:name="com.google.android.apps.mytracks.TrackDetails"
android:label="@string/trackdetails_title" /> android:label="@string/trackdetails_title">
<intent-filter>
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.track" />
</intent-filter>
</activity>
<activity android:name="com.google.android.apps.mytracks.WaypointDetails" <activity android:name="com.google.android.apps.mytracks.WaypointDetails"
android:label="@string/waypointdetails_title" /> android:label="@string/waypointdetails_title">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.waypoint" />
</intent-filter>
</activity>
<activity android:name="com.google.android.apps.mytracks.SettingsActivity" <activity android:name="com.google.android.apps.mytracks.SettingsActivity"
android:label="@string/mytracks_settings" /> android:label="@string/mytracks_settings" >
<intent-filter>
<category android:name="android.intent.category.PREFERENCE" />
</intent-filter>
</activity>
<activity android:name="com.google.android.apps.mytracks.AggregatedStatsActivity" <activity android:name="com.google.android.apps.mytracks.AggregatedStatsActivity"
android:label="@string/aggregated_stats" /> android:label="@string/aggregated_stats" />
<activity android:name="com.google.android.apps.mytracks.StatsActivity" <activity android:name="com.google.android.apps.mytracks.StatsActivity"
android:label="@string/statistics" android:label="@string/statistics"
android:exported="false" /> android:exported="false">
<intent-filter>
<category android:name="android.intent.category.TAB" />
</intent-filter>
</activity>
<activity android:name="com.google.android.apps.mytracks.SensorStateActivity" <activity android:name="com.google.android.apps.mytracks.SensorStateActivity"
android:label="@string/sensor_state" /> android:label="@string/sensor_state" />
<activity android:name="com.google.android.apps.mytracks.ChartActivity" <activity android:name="com.google.android.apps.mytracks.ChartActivity"
android:label="@string/elevation_label" android:label="@string/elevation_label"
android:exported="false" /> android:exported="false">
<intent-filter>
<category android:name="android.intent.category.TAB" />
</intent-filter>
</activity>
<activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.SendActivity" <activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.SendActivity"
android:label="@string/sendtogoogle_title" android:label="@string/sendtogoogle_title"
android:theme="@android:style/Theme.Translucent" /> android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:noHistory="true" />
<activity android:name="com.google.android.apps.mytracks.io.file.SaveActivity" <activity android:name="com.google.android.apps.mytracks.io.file.SaveActivity"
android:label="@string/tracklist_write_to_sd" android:label="@string/tracklist_write_to_sd"
android:theme="@android:style/Theme.Translucent" /> android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:noHistory="true" />
<activity android:name="com.google.android.apps.mytracks.WelcomeActivity" <activity android:name="com.google.android.apps.mytracks.WelcomeActivity"
android:label="@string/welcome" android:label="@string/welcome"
@@ -1,3 +1,18 @@
/*
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.android.apps.mytracks.io.file; package com.google.android.apps.mytracks.io.file;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
@@ -17,6 +32,11 @@ import android.os.Bundle;
import java.io.File; import java.io.File;
/**
* Activity for saving a track to a file (and optionally sending that file).
*
* @author Rodrigo Damazio
*/
public class SaveActivity extends Activity { public class SaveActivity extends Activity {
public static final String EXTRA_TRACK_ID = "track_id"; public static final String EXTRA_TRACK_ID = "track_id";
public static final String EXTRA_SHARE_FILE = "share_file"; public static final String EXTRA_SHARE_FILE = "share_file";
@@ -146,7 +166,6 @@ public class SaveActivity extends Activity {
intent.putExtra(EXTRA_TRACK_ID, trackId); intent.putExtra(EXTRA_TRACK_ID, trackId);
intent.putExtra(EXTRA_FILE_FORMAT, exportFormat.ordinal()); intent.putExtra(EXTRA_FILE_FORMAT, exportFormat.ordinal());
intent.putExtra(EXTRA_SHARE_FILE, shareFile); intent.putExtra(EXTRA_SHARE_FILE, shareFile);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
ctx.startActivity(intent); ctx.startActivity(intent);
} }
} }
@@ -1,3 +1,18 @@
/*
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.android.apps.mytracks.io.sendtogoogle; package com.google.android.apps.mytracks.io.sendtogoogle;
import static com.google.android.apps.mytracks.Constants.TAG; import static com.google.android.apps.mytracks.Constants.TAG;
@@ -39,7 +54,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
* Helper for managing the sending of tracks to Google services. * Helper activity for managing the sending of tracks to Google services.
* *
* @author Rodrigo Damazio * @author Rodrigo Damazio
*/ */
@@ -242,7 +257,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
} }
}; };
final SendToFusionTables sender = new SendToFusionTables(this, lastAuth, final SendToFusionTables sender = new SendToFusionTables(this, lastAuth,
sendTrackId, this/*progressIndicator*/, onCompletion); sendTrackId, this /*progressIndicator*/, onCompletion);
HandlerThread handlerThread = new HandlerThread("SendToFusionTables"); HandlerThread handlerThread = new HandlerThread("SendToFusionTables");
handlerThread.start(); handlerThread.start();
@@ -613,7 +628,6 @@ public class SendActivity extends Activity implements ProgressIndicator {
Intent intent = new Intent(ctx, SendActivity.class); Intent intent = new Intent(ctx, SendActivity.class);
intent.putExtra(SendActivity.EXTRA_TRACK_ID, trackId); intent.putExtra(SendActivity.EXTRA_TRACK_ID, trackId);
intent.putExtra(SendActivity.EXTRA_SHARE_LINK, shareLink); intent.putExtra(SendActivity.EXTRA_SHARE_LINK, shareLink);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
ctx.startActivity(intent); ctx.startActivity(intent);
} }
} }