Code cleanup. Rename My Maps to Maps.

Did a case insentive search and replacement for
mymap
my_map
my map
This commit is contained in:
Jimmy Shih
2012-01-06 14:24:26 -08:00
parent 4e9fa91f27
commit 9e6e4bc5af
33 changed files with 272 additions and 282 deletions
+2 -2
View File
@@ -139,8 +139,8 @@ limitations under the License.
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="com.google.android.apps.mytracks.MyMapsList" <activity android:name="com.google.android.apps.mytracks.MapsList"
android:label="@string/my_maps_list_title" android:label="@string/maps_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" />

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

+4 -4
View File
@@ -31,7 +31,7 @@ limitations under the License.
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16dip" android:textSize="16dip"
android:textColor="#fff" android:textColor="#fff"
android:text="@string/my_maps_list_pick_map" android:text="@string/maps_list_pick_map"
android:layout_weight="0"/> android:layout_weight="0"/>
</LinearLayout> </LinearLayout>
<ListView android:id="@+id/maplist" <ListView android:id="@+id/maplist"
@@ -47,7 +47,7 @@ limitations under the License.
android:textSize="16dip" android:textSize="16dip"
android:textColor="#c00" android:textColor="#c00"
android:textStyle="bold" android:textStyle="bold"
android:text="@string/my_maps_list_no_maps" android:text="@string/maps_list_no_maps"
android:visibility="gone"/> android:visibility="gone"/>
<TextView android:id="@+id/failed" <TextView android:id="@+id/failed"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@@ -58,7 +58,7 @@ limitations under the License.
android:textSize="16dip" android:textSize="16dip"
android:textColor="#c00" android:textColor="#c00"
android:textStyle="bold" android:textStyle="bold"
android:text="@string/my_maps_list_error" android:text="@string/maps_list_error"
android:visibility="gone"/> android:visibility="gone"/>
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"
@@ -89,7 +89,7 @@ limitations under the License.
android:textSize="16dip" android:textSize="16dip"
android:textColor="#fff" android:textColor="#fff"
android:textStyle="bold" android:textStyle="bold"
android:text="@string/my_maps_list_loading"/> android:text="@string/maps_list_loading"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -39,11 +39,11 @@ limitations under the License.
<!-- Google Maps --> <!-- Google Maps -->
<TableRow android:id="@+id/send_google_maps_row"> <TableRow android:id="@+id/send_google_maps_row">
<ImageView <ImageView
android:src="@drawable/mymaps_icon" android:src="@drawable/maps_icon"
style="@style/SendGoogleImageView"/> style="@style/SendGoogleImageView"/>
<CheckBox <CheckBox
android:id="@+id/send_google_my_maps" android:id="@+id/send_google_maps"
android:text="@string/send_google_my_maps" android:text="@string/send_google_maps"
style="@style/SendGoogleCheckBox"/> style="@style/SendGoogleCheckBox"/>
</TableRow> </TableRow>
<TableRow android:id="@+id/send_google_maps_option_row"> <TableRow android:id="@+id/send_google_maps_option_row">
+2 -2
View File
@@ -130,10 +130,10 @@ limitations under the License.
android:text="@string/welcome_delete_all_answer" android:text="@string/welcome_delete_all_answer"
style="@style/WelcomeTextView"/> style="@style/WelcomeTextView"/>
<TextView <TextView
android:text="@string/welcome_my_maps_sharing_question" android:text="@string/welcome_maps_sharing_question"
style="@style/WelcomeTextView.Question"/> style="@style/WelcomeTextView.Question"/>
<TextView <TextView
android:text="@string/welcome_my_maps_sharing_answer" android:text="@string/welcome_maps_sharing_answer"
style="@style/WelcomeTextView"/> style="@style/WelcomeTextView"/>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
+1 -1
View File
@@ -43,7 +43,7 @@ limitations under the License.
</string> </string>
<string name="send_google_docs_url">docs.google.com</string> <string name="send_google_docs_url">docs.google.com</string>
<string name="send_google_fusion_tables_url">google.com/fusiontables</string> <string name="send_google_fusion_tables_url">google.com/fusiontables</string>
<string name="send_google_my_maps_url">maps.google.com</string> <string name="send_google_maps_url">maps.google.com</string>
<string name="sensor_type_value_ant">ANT</string> <string name="sensor_type_value_ant">ANT</string>
<string name="sensor_type_value_none">NONE</string> <string name="sensor_type_value_none">NONE</string>
<string name="sensor_type_value_polar">POLAR</string> <string name="sensor_type_value_polar">POLAR</string>
+1 -1
View File
@@ -34,7 +34,7 @@ limitations under the License.
<string name="report_speed_key">reportSpeed</string> <string name="report_speed_key">reportSpeed</string>
<string name="send_to_docs_key">sendToDocs</string> <string name="send_to_docs_key">sendToDocs</string>
<string name="send_to_fusion_tables_key">sendToFusionTables</string> <string name="send_to_fusion_tables_key">sendToFusionTables</string>
<string name="send_to_my_maps_key">sendToMyMaps</string> <string name="send_to_maps_key">sendToMaps</string>
<string name="sensor_type_key">sensorType</string> <string name="sensor_type_key">sensorType</string>
<string name="share_url_only_key">shareUrlOnly</string> <string name="share_url_only_key">shareUrlOnly</string>
<string name="split_frequency_key">splitFrequency</string> <string name="split_frequency_key">splitFrequency</string>
+40 -50
View File
@@ -820,6 +820,43 @@ limitations under the License.
Waypoint Waypoint
</string> </string>
<!-- Maps List -->
<string name="maps_list_error"
translation_description="When sending a track to an existing Google Map, the text on the
'Maps' list page informing the user that his maps cannot be loaded at this time.">
Your maps could not be loaded at this time.
</string>
<string name="maps_list_loading"
translation_description="When sending a track to an existing Google Map, the progress dialog
message informing the user that his maps are being loaded.">
Loading maps...
</string>
<string name="maps_list_no_maps"
translation_description="When sending a track to an existing Google Map, the text on the
'Maps' list page informing the user that he doesn't have any maps.">
You don\'t have any maps.
</string>
<string name="maps_list_pick_map"
translation_description="When sending a track to an existing Google Map, the text on the
'Maps' list page asking the user to pick one of his maps.">
Pick a map:
</string>
<string name="maps_list_public_label"
translation_description="When sending a track to an existing Google Map, in the 'Maps'
list page, the label next to the maps that are public, as opposed to being unlisted.">
Public
</string>
<string name="maps_list_title"
translation_description="When sending a track to an existing Google Map, the title of the
page listing the user's maps in Google Maps.">
Your Google Maps
</string>
<string name="maps_list_unlisted_label"
translation_description="When sending a track to an existing Google Map, in the 'Maps'
list page, the label next to the maps that are unlisted, as opposed to being public.">
Unlisted
</string>
<!-- Menu Items --> <!-- Menu Items -->
<string name="menu_aggregated_statistics" <string name="menu_aggregated_statistics"
translation_description="In the menu, to go to the aggregated statistics page. translation_description="In the menu, to go to the aggregated statistics page.
@@ -912,53 +949,6 @@ limitations under the License.
\'Location &amp; security\' settings) &amp; make sure the sky is visible. Try again later. \'Location &amp; security\' settings) &amp; make sure the sky is visible. Try again later.
</string> </string>
<!-- Maps List -->
<string name="my_maps_list_error"
translation_description="When sending a track to an existing Google Map, the text on the
'Maps' list page informing the user that his maps cannot be loaded at this time.">
Your maps could not be loaded at this time.
</string>
<string name="my_maps_list_loading"
translation_description="When sending a track to an existing Google Map, the progress dialog
message informing the user that his maps are being loaded.">
Loading maps...
</string>
<string name="my_maps_list_no_maps"
translation_description="When sending a track to an existing Google Map, the text on the
'Maps' list page informing the user that he doesn't have any maps.
Screenshot: my_maps_list_no_maps.png">
You don\'t have any maps.
</string>
<string name="my_maps_list_pick_map"
translation_description="When sending a track to an existing Google Map, the text on the
'Maps' list page asking the user to pick one of his maps.
Screenshot: my_maps.png">
Pick a map:
</string>
<string name="my_maps_list_public_label"
translation_description="When sending a track to an existing Google Map, in the 'Maps'
list page, the label next to the maps that are public, as opposed to being unlisted.
Screenshot: my_maps.png">
Public
</string>
<string name="my_maps_list_title"
translation_description="When sending a track to an existing Google Map, the title of the
page listing the user's maps in Google Maps.
Screenshot: my_maps.png">
Your Google Maps
</string>
<string name="my_maps_list_unlisted_label"
translation_description="When sending a track to an existing Google Map, in the 'Maps'
list page, the label next to the maps that are unlisted, as opposed to being public.
Screenshot: my_maps.png">
Unlisted
</string>
<!-- My Tracks --> <!-- My Tracks -->
<string name="my_tracks_app_name" <string name="my_tracks_app_name"
translation_description="The My Tracks application name."> translation_description="The My Tracks application name.">
@@ -1139,7 +1129,7 @@ limitations under the License.
Screenshot: send_google_choose_service.png"> Screenshot: send_google_choose_service.png">
Google Fusion Tables Google Fusion Tables
</string> </string>
<string name="send_google_my_maps" <string name="send_google_maps"
translation_description="When sending a track to Google, under the 'Send to...' dialog, the translation_description="When sending a track to Google, under the 'Send to...' dialog, the
checkbox option to send to Google Maps. checkbox option to send to Google Maps.
@@ -3196,7 +3186,7 @@ limitations under the License.
Screenshot: welcome.png"> Screenshot: welcome.png">
How precise are the recorded tracks? How precise are the recorded tracks?
</string> </string>
<string name="welcome_my_maps_sharing_answer" <string name="welcome_maps_sharing_answer"
translation_description="In the 'Welcome' page, the help content answer on Google Maps translation_description="In the 'Welcome' page, the help content answer on Google Maps
visibility. visibility.
@@ -3205,7 +3195,7 @@ limitations under the License.
-> Make new maps public. You can change the visibility of all your maps at My places in Google -> Make new maps public. You can change the visibility of all your maps at My places in Google
Maps. Maps.
</string> </string>
<string name="welcome_my_maps_sharing_question" <string name="welcome_maps_sharing_question"
translation_description="In the 'Welcome' page, the help content question on Google Maps translation_description="In the 'Welcome' page, the help content question on Google Maps
visibility. visibility.
@@ -40,7 +40,7 @@ public abstract class Constants {
public static final int GET_LOGIN = 0; public static final int GET_LOGIN = 0;
public static final int GET_MAP = 1; public static final int GET_MAP = 1;
public static final int SHOW_TRACK = 2; public static final int SHOW_TRACK = 2;
public static final int AUTHENTICATE_TO_MY_MAPS = 3; public static final int AUTHENTICATE_TO_MAPS = 3;
public static final int AUTHENTICATE_TO_FUSION_TABLES = 4; public static final int AUTHENTICATE_TO_FUSION_TABLES = 4;
public static final int AUTHENTICATE_TO_DOCLIST = 5; public static final int AUTHENTICATE_TO_DOCLIST = 5;
public static final int AUTHENTICATE_TO_TRIX = 6; public static final int AUTHENTICATE_TO_TRIX = 6;
@@ -99,7 +99,7 @@ public class ExportAllTracks {
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
new Thread(runner, "SendToMyMaps").start(); new Thread(runner, "ExportAllTracks").start();
} }
}; };
@@ -404,7 +404,7 @@ public class MapActivity extends com.google.android.maps.MapActivity
SendActivity.sendToGoogle(this, dataHub.getSelectedTrackId(), null); SendActivity.sendToGoogle(this, dataHub.getSelectedTrackId(), null);
return true; return true;
case Constants.MENU_SHARE_MAP: case Constants.MENU_SHARE_MAP:
SendActivity.sendToGoogle(this, dataHub.getSelectedTrackId(), SendType.MYMAPS); SendActivity.sendToGoogle(this, dataHub.getSelectedTrackId(), SendType.MAPS);
return true; return true;
case Constants.MENU_SHARE_FUSION_TABLE: case Constants.MENU_SHARE_FUSION_TABLE:
SendActivity.sendToGoogle(this, dataHub.getSelectedTrackId(), SendType.FUSION_TABLES); SendActivity.sendToGoogle(this, dataHub.getSelectedTrackId(), SendType.FUSION_TABLES);
@@ -20,8 +20,8 @@ import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.io.AuthManager; import com.google.android.apps.mytracks.io.AuthManager;
import com.google.android.apps.mytracks.io.AuthManager.AuthCallback; import com.google.android.apps.mytracks.io.AuthManager.AuthCallback;
import com.google.android.apps.mytracks.io.AuthManagerFactory; import com.google.android.apps.mytracks.io.AuthManagerFactory;
import com.google.android.apps.mytracks.io.mymaps.MapsFacade; import com.google.android.apps.mytracks.io.maps.MapsConstants;
import com.google.android.apps.mytracks.io.mymaps.MyMapsConstants; import com.google.android.apps.mytracks.io.maps.MapsFacade;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.app.Activity; import android.app.Activity;
@@ -35,12 +35,12 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
/** /**
* Activity which displays the list of current My Maps tracks for the user. * Activity which displays the list of current Google Maps for the user.
* Returns RESULT_OK if the user picked a map, and returns "mapid" as an extra. * Returns RESULT_OK if the user picked a map, and returns "mapid" as an extra.
* *
* @author Rodrigo Damazio * @author Rodrigo Damazio
*/ */
public class MyMapsList extends Activity implements MapsFacade.MapsListCallback { public class MapsList extends Activity implements MapsFacade.MapsListCallback {
private static final int GET_LOGIN = 1; private static final int GET_LOGIN = 1;
public static final String EXTRA_ACCOUNT_NAME = "accountName"; public static final String EXTRA_ACCOUNT_NAME = "accountName";
@@ -48,7 +48,7 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback
private MapsFacade mapsClient; private MapsFacade mapsClient;
private AuthManager auth; private AuthManager auth;
private MyMapsListAdapter listAdapter; private MapsListAdapter listAdapter;
private final OnItemClickListener clickListener = private final OnItemClickListener clickListener =
new OnItemClickListener() { new OnItemClickListener() {
@@ -68,11 +68,11 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback
super.onCreate(icicle); super.onCreate(icicle);
auth = AuthManagerFactory.getAuthManager(this, GET_LOGIN, null, true, auth = AuthManagerFactory.getAuthManager(this, GET_LOGIN, null, true,
MyMapsConstants.SERVICE_NAME); MapsConstants.SERVICE_NAME);
setContentView(R.layout.list); setContentView(R.layout.list);
listAdapter = new MyMapsListAdapter(this); listAdapter = new MapsListAdapter(this);
ListView list = (ListView) findViewById(R.id.maplist); ListView list = (ListView) findViewById(R.id.maplist);
list.setOnItemClickListener(clickListener); list.setOnItemClickListener(clickListener);
@@ -113,7 +113,7 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback
} }
// Runs in UI thread. // Runs in UI thread.
mapsClient = new MapsFacade(MyMapsList.this, auth); mapsClient = new MapsFacade(MapsList.this, auth);
startLookup(); startLookup();
} }
@@ -127,7 +127,7 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback
public void run() { public void run() {
// Communication with Maps happens in its own thread. // Communication with Maps happens in its own thread.
// This will call onReceivedMapListing below. // This will call onReceivedMapListing below.
final boolean success = mapsClient.getMapsList(MyMapsList.this); final boolean success = mapsClient.getMapsList(MapsList.this);
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
@@ -15,13 +15,13 @@ import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.Vector; import java.util.Vector;
public class MyMapsListAdapter implements ListAdapter { public class MapsListAdapter implements ListAdapter {
private Vector<String[]> mapsList; private Vector<String[]> mapsList;
private Vector<Boolean> publicList; private Vector<Boolean> publicList;
private Set<DataSetObserver> observerSet; private Set<DataSetObserver> observerSet;
private final Activity activity; private final Activity activity;
public MyMapsListAdapter(Activity activity) { public MapsListAdapter(Activity activity) {
this.activity = activity; this.activity = activity;
mapsList = new Vector<String[]>(); mapsList = new Vector<String[]>();
@@ -99,10 +99,10 @@ public class MyMapsListAdapter implements ListAdapter {
(TextView) convertView.findViewById(R.id.maplistpublic); (TextView) convertView.findViewById(R.id.maplistpublic);
if (publicList.get(position)) { if (publicList.get(position)) {
publicUnlisted.setTextColor(Color.RED); publicUnlisted.setTextColor(Color.RED);
publicUnlisted.setText(R.string.my_maps_list_public_label); publicUnlisted.setText(R.string.maps_list_public_label);
} else { } else {
publicUnlisted.setTextColor(Color.GREEN); publicUnlisted.setTextColor(Color.GREEN);
publicUnlisted.setText(R.string.my_maps_list_unlisted_label); publicUnlisted.setText(R.string.maps_list_unlisted_label);
} }
return convertView; return convertView;
@@ -53,7 +53,7 @@ import android.widget.TextView;
/** /**
* A list activity displaying all the recorded tracks. There's a context * A list activity displaying all the recorded tracks. There's a context
* menu (via long press) displaying various options such as showing, editing, * menu (via long press) displaying various options such as showing, editing,
* deleting, sending to MyMaps, or writing to SD card. * deleting, sending to Google, or writing to SD card.
* *
* @author Leif Hendrik Wilden * @author Leif Hendrik Wilden
*/ */
@@ -176,7 +176,7 @@ public class TrackList extends ListActivity
SendActivity.sendToGoogle(this, trackId, null); SendActivity.sendToGoogle(this, trackId, null);
return true; return true;
case Constants.MENU_SHARE_MAP: case Constants.MENU_SHARE_MAP:
SendActivity.sendToGoogle(this, trackId, SendType.MYMAPS); SendActivity.sendToGoogle(this, trackId, SendType.MAPS);
return true; return true;
case Constants.MENU_SHARE_FUSION_TABLE: case Constants.MENU_SHARE_FUSION_TABLE:
SendActivity.sendToGoogle(this, trackId, SendType.FUSION_TABLES); SendActivity.sendToGoogle(this, trackId, SendType.FUSION_TABLES);
@@ -22,7 +22,7 @@ import com.google.android.apps.mytracks.ProgressIndicator;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.io.mymaps.MapsFacade; import com.google.android.apps.mytracks.io.maps.MapsFacade;
import com.google.android.apps.mytracks.io.sendtogoogle.SendType; import com.google.android.apps.mytracks.io.sendtogoogle.SendType;
import com.google.android.apps.mytracks.stats.DoubleBuffer; import com.google.android.apps.mytracks.stats.DoubleBuffer;
import com.google.android.apps.mytracks.stats.TripStatistics; import com.google.android.apps.mytracks.stats.TripStatistics;
@@ -43,7 +43,7 @@ import java.util.List;
import java.util.Vector; import java.util.Vector;
/** /**
* A helper class used to transmit tracks to Google MyMaps. * A helper class used to transmit tracks to Google Maps.
* A new instance should be used for each upload. * A new instance should be used for each upload.
* *
* IMPORTANT: while this code is Apache-licensed, please notice that usage of * IMPORTANT: while this code is Apache-licensed, please notice that usage of
@@ -53,7 +53,7 @@ import java.util.Vector;
* *
* @author Leif Hendrik Wilden * @author Leif Hendrik Wilden
*/ */
public class SendToMyMaps implements Runnable { public class SendToMaps implements Runnable {
public static final String NEW_MAP_ID = "new"; public static final String NEW_MAP_ID = "new";
private static final int MAX_POINTS_PER_UPLOAD = 2048; private static final int MAX_POINTS_PER_UPLOAD = 2048;
@@ -80,7 +80,7 @@ public class SendToMyMaps implements Runnable {
void onSendCompleted(String mapId, boolean success); void onSendCompleted(String mapId, boolean success);
} }
public SendToMyMaps(Activity context, String mapId, AuthManager auth, public SendToMaps(Activity context, String mapId, AuthManager auth,
long trackId, ProgressIndicator progressIndicator, long trackId, ProgressIndicator progressIndicator,
OnSendCompletedListener onCompletion) { OnSendCompletedListener onCompletion) {
this.context = context; this.context = context;
@@ -95,7 +95,7 @@ public class SendToMyMaps implements Runnable {
@Override @Override
public void run() { public void run() {
Log.d(TAG, "Sending to MyMaps: trackId = " + trackId); Log.d(TAG, "Sending to Maps: trackId = " + trackId);
doUpload(); doUpload();
} }
@@ -130,7 +130,7 @@ public class SendToMyMaps implements Runnable {
} }
String creatingFormat = context.getString(R.string.send_google_progress_creating); String creatingFormat = context.getString(R.string.send_google_progress_creating);
String serviceName = context.getString(SendType.MYMAPS.getServiceName()); String serviceName = context.getString(SendType.MAPS.getServiceName());
progressIndicator.setProgressMessage(String.format(creatingFormat, serviceName)); progressIndicator.setProgressMessage(String.format(creatingFormat, serviceName));
StringBuilder mapIdBuilder = new StringBuilder(); StringBuilder mapIdBuilder = new StringBuilder();
@@ -170,11 +170,11 @@ public class SendToMyMaps implements Runnable {
} }
if (!success) { if (!success) {
Log.w(TAG, "SendToMyMaps: upload waypoints failed."); Log.w(TAG, "SendToMaps: upload waypoints failed.");
} }
} }
Log.d(TAG, "SendToMyMaps: Done: " + success); Log.d(TAG, "SendToMaps: Done: " + success);
progressIndicator.setProgressValue(100); progressIndicator.setProgressValue(100);
} finally { } finally {
if (mapsClient != null) { if (mapsClient != null) {
@@ -321,7 +321,7 @@ public class SendToMyMaps implements Runnable {
// Start uploading them // Start uploading them
String sendingFormat = context.getString(R.string.send_google_progress_sending); String sendingFormat = context.getString(R.string.send_google_progress_sending);
String serviceName = context.getString(SendType.MYMAPS.getServiceName()); String serviceName = context.getString(SendType.MAPS.getServiceName());
progressIndicator.setProgressMessage(String.format(sendingFormat, serviceName)); progressIndicator.setProgressMessage(String.format(sendingFormat, serviceName));
for (Track splitTrack : splitTracks) { for (Track splitTrack : splitTracks) {
if (totalSegmentsUploaded > 1) { if (totalSegmentsUploaded > 1) {
@@ -331,13 +331,13 @@ public class SendToMyMaps implements Runnable {
} }
totalSegmentsUploaded++; totalSegmentsUploaded++;
Log.d(TAG, Log.d(TAG,
"SendToMyMaps: Prepared feature for upload w/ " "SendToMaps: Prepared feature for upload w/ "
+ splitTrack.getLocations().size() + " points."); + splitTrack.getLocations().size() + " points.");
// Transmit tracks via GData feed: // Transmit tracks via GData feed:
// ------------------------------- // -------------------------------
Log.d(TAG, Log.d(TAG,
"SendToMyMaps: Uploading to map " + mapId + " w/ auth " + auth); "SendToMaps: Uploading to map " + mapId + " w/ auth " + auth);
if (!mapsClient.uploadTrackPoints(mapId, splitTrack.getName(), splitTrack.getLocations())) { if (!mapsClient.uploadTrackPoints(mapId, splitTrack.getName(), splitTrack.getLocations())) {
Log.e(TAG, "Uploading failed"); Log.e(TAG, "Uploading failed");
return false; return false;
@@ -386,7 +386,7 @@ public class SendToMyMaps implements Runnable {
prepareTrackSegment(segment, splitTracks); prepareTrackSegment(segment, splitTracks);
Log.d(TAG, Log.d(TAG,
"MyTracksSendToMyMaps: Starting new track segment..."); "MyTracksSendToMaps: Starting new track segment...");
startNewTrackSegment = false; startNewTrackSegment = false;
segment = new Track(); segment = new Track();
segment.setId(track.getId()); segment.setId(track.getId());
@@ -1,5 +1,5 @@
// Copyright 2009 Google Inc. All Rights Reserved. // Copyright 2009 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
@@ -1,5 +1,5 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
import com.google.wireless.gdata.data.Entry; import com.google.wireless.gdata.data.Entry;
@@ -1,5 +1,5 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
import com.google.wireless.gdata.client.GDataClient; import com.google.wireless.gdata.client.GDataClient;
import com.google.wireless.gdata.client.GDataParserFactory; import com.google.wireless.gdata.client.GDataParserFactory;
@@ -33,11 +33,11 @@ class MapsClient extends GDataServiceClient {
@Override @Override
public String getServiceName() { public String getServiceName() {
return MyMapsConstants.SERVICE_NAME; return MapsConstants.SERVICE_NAME;
} }
public static String buildMapUrl(String mapId) { public static String buildMapUrl(String mapId) {
return MyMapsConstants.MAPSHOP_BASE_URL + "?msa=0&msid=" + mapId; return MapsConstants.MAPSHOP_BASE_URL + "?msa=0&msid=" + mapId;
} }
public static String getMapsFeed() { public static String getMapsFeed() {
@@ -1,10 +1,10 @@
// Copyright 2009 Google Inc. All Rights Reserved. // Copyright 2009 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
/** /**
* Constants for My Maps. * Constants for Google Maps.
*/ */
public class MyMapsConstants { public class MapsConstants {
static final String TAG = "MapsApi"; static final String TAG = "MapsApi";
static final String MAPSHOP_BASE_URL = static final String MAPSHOP_BASE_URL =
"https://maps.google.com/maps/ms"; "https://maps.google.com/maps/ms";
@@ -13,5 +13,5 @@ public class MyMapsConstants {
/** /**
* Private constructor to prevent instantiation. * Private constructor to prevent instantiation.
*/ */
private MyMapsConstants() { } private MapsConstants() { }
} }
@@ -1,5 +1,5 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.io.AuthManager; import com.google.android.apps.mytracks.io.AuthManager;
@@ -43,19 +43,19 @@ public class MapsFacade {
"http://maps.google.com/mapfiles/ms/micons/green-dot.png"; "http://maps.google.com/mapfiles/ms/micons/green-dot.png";
private final Context context; private final Context context;
private final MyMapsGDataWrapper wrapper; private final MapsGDataWrapper wrapper;
private final MyMapsGDataConverter gdataConverter; private final MapsGDataConverter gdataConverter;
private final String authToken; private final String authToken;
public MapsFacade(Context context, AuthManager auth) { public MapsFacade(Context context, AuthManager auth) {
this.context = context; this.context = context;
this.authToken = auth.getAuthToken(); this.authToken = auth.getAuthToken();
wrapper = new MyMapsGDataWrapper(context, auth); wrapper = new MapsGDataWrapper(context, auth);
wrapper.setRetryOnAuthFailure(true); wrapper.setRetryOnAuthFailure(true);
try { try {
gdataConverter = new MyMapsGDataConverter(); gdataConverter = new MapsGDataConverter();
} catch (XmlPullParserException e) { } catch (XmlPullParserException e) {
throw new IllegalStateException("Unable to create maps data converter", e); throw new IllegalStateException("Unable to create maps data converter", e);
} }
@@ -72,7 +72,7 @@ public class MapsFacade {
* @return true on success, false otherwise * @return true on success, false otherwise
*/ */
public boolean getMapsList(final MapsListCallback callback) { public boolean getMapsList(final MapsListCallback callback) {
return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() { return wrapper.runQuery(new MapsGDataWrapper.QueryFunction() {
@Override @Override
public void query(MapsClient client) throws IOException, Exception { public void query(MapsClient client) throws IOException, Exception {
GDataParser listParser = client.getParserForFeed( GDataParser listParser = client.getParserForFeed(
@@ -81,9 +81,9 @@ public class MapsFacade {
while (listParser.hasMoreData()) { while (listParser.hasMoreData()) {
MapFeatureEntry entry = MapFeatureEntry entry =
(MapFeatureEntry) listParser.readNextEntry(null); (MapFeatureEntry) listParser.readNextEntry(null);
MyMapsMapMetadata metadata = MapsMapMetadata metadata =
MyMapsGDataConverter.getMapMetadataForEntry(entry); MapsGDataConverter.getMapMetadataForEntry(entry);
String mapId = MyMapsGDataConverter.getMapidForEntry(entry); String mapId = MapsGDataConverter.getMapidForEntry(entry);
callback.onReceivedMapListing( callback.onReceivedMapListing(
mapId, metadata.getTitle(), metadata.getDescription(), metadata.getSearchable()); mapId, metadata.getTitle(), metadata.getDescription(), metadata.getSearchable());
@@ -111,24 +111,24 @@ public class MapsFacade {
throw new IllegalArgumentException("mapIdBuilder should be empty"); throw new IllegalArgumentException("mapIdBuilder should be empty");
} }
return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() { return wrapper.runQuery(new MapsGDataWrapper.QueryFunction() {
@Override @Override
public void query(MapsClient client) throws IOException, Exception { public void query(MapsClient client) throws IOException, Exception {
Log.d(MyMapsConstants.TAG, "Creating a new map."); Log.d(MapsConstants.TAG, "Creating a new map.");
String mapFeed = MapsClient.getMapsFeed(); String mapFeed = MapsClient.getMapsFeed();
Log.d(MyMapsConstants.TAG, "Map feed is " + mapFeed); Log.d(MapsConstants.TAG, "Map feed is " + mapFeed);
MyMapsMapMetadata metaData = new MyMapsMapMetadata(); MapsMapMetadata metaData = new MapsMapMetadata();
metaData.setTitle(title); metaData.setTitle(title);
metaData.setDescription(description + " - " metaData.setDescription(description + " - "
+ category + " - " + StringUtils.getCreatedByMyTracks(context, false)); + category + " - " + StringUtils.getCreatedByMyTracks(context, false));
metaData.setSearchable(isPublic); metaData.setSearchable(isPublic);
Entry entry = MyMapsGDataConverter.getMapEntryForMetadata(metaData); Entry entry = MapsGDataConverter.getMapEntryForMetadata(metaData);
Log.d(MyMapsConstants.TAG, "Title: " + entry.getTitle()); Log.d(MapsConstants.TAG, "Title: " + entry.getTitle());
Entry map = client.createEntry(mapFeed, authToken, entry); Entry map = client.createEntry(mapFeed, authToken, entry);
String mapId = MapsClient.getMapIdFromMapEntryId(map.getId()); String mapId = MapsClient.getMapIdFromMapEntryId(map.getId());
mapIdBuilder.append(mapId); mapIdBuilder.append(mapId);
Log.d(MyMapsConstants.TAG, "New map id is: " + mapId); Log.d(MapsConstants.TAG, "New map id is: " + mapId);
} }
}); });
} }
@@ -145,7 +145,7 @@ public class MapsFacade {
*/ */
public boolean uploadMarker(final String mapId, final String trackName, public boolean uploadMarker(final String mapId, final String trackName,
final String trackDescription, final Location loc, final boolean isStart) { final String trackDescription, final Location loc, final boolean isStart) {
return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() { return wrapper.runQuery(new MapsGDataWrapper.QueryFunction() {
@Override @Override
public void query(MapsClient client) public void query(MapsClient client)
throws IOException, Exception { throws IOException, Exception {
@@ -165,34 +165,34 @@ public class MapsFacade {
String trackName, String trackDescription, String trackName, String trackDescription,
GeoPoint geoPoint, GeoPoint geoPoint,
boolean isStart) throws IOException, Exception { boolean isStart) throws IOException, Exception {
MyMapsFeature feature = MapsFeature feature =
buildMyMapsPlacemarkFeature(trackName, trackDescription, geoPoint, isStart); buildMapsPlacemarkFeature(trackName, trackDescription, geoPoint, isStart);
Entry entry = gdataConverter.getEntryForFeature(feature); Entry entry = gdataConverter.getEntryForFeature(feature);
Log.d(MyMapsConstants.TAG, "SendToMyMaps: Creating placemark " Log.d(MapsConstants.TAG, "SendToMaps: Creating placemark "
+ entry.getTitle()); + entry.getTitle());
try { try {
client.createEntry(featureFeed, authToken, entry); client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG, "SendToMyMaps: createEntry success!"); Log.d(MapsConstants.TAG, "SendToMaps: createEntry success!");
} catch (IOException e) { } catch (IOException e) {
Log.w(MyMapsConstants.TAG, Log.w(MapsConstants.TAG,
"SendToMyMaps: createEntry 1st try failed. Trying again."); "SendToMaps: createEntry 1st try failed. Trying again.");
// Retry once (often IOException is thrown on a timeout): // Retry once (often IOException is thrown on a timeout):
client.createEntry(featureFeed, authToken, entry); client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG, Log.d(MapsConstants.TAG,
"SendToMyMaps: createEntry success on 2nd try!"); "SendToMaps: createEntry success on 2nd try!");
} }
} }
/** /**
* Builds a placemark MyMapsFeature from a track. * Builds a placemark MapsFeature from a track.
* *
* @param trackName the track * @param trackName the track
* @param trackDescription the track description * @param trackDescription the track description
* @param geoPoint the geo point * @param geoPoint the geo point
* @param isStart true if it's the start of the track, or false for end * @param isStart true if it's the start of the track, or false for end
* @return a MyMapsFeature * @return a MapsFeature
*/ */
private MyMapsFeature buildMyMapsPlacemarkFeature( private MapsFeature buildMapsPlacemarkFeature(
String trackName, String trackDescription, String trackName, String trackDescription,
GeoPoint geoPoint, boolean isStart) { GeoPoint geoPoint, boolean isStart) {
String iconUrl; String iconUrl;
@@ -205,34 +205,34 @@ public class MapsFacade {
+ (isStart ? context.getString(R.string.marker_label_start) + (isStart ? context.getString(R.string.marker_label_start)
: context.getString(R.string.marker_label_end)); : context.getString(R.string.marker_label_end));
String description = isStart ? "" : trackDescription; String description = isStart ? "" : trackDescription;
return buildMyMapsPlacemarkFeature(title, description, iconUrl, geoPoint); return buildMapsPlacemarkFeature(title, description, iconUrl, geoPoint);
} }
/** /**
* Builds a MyMapsFeature from a waypoint. * Builds a MapsFeature from a waypoint.
* *
* @param title the title * @param title the title
* @param description the description * @param description the description
* @param iconUrl the icon url * @param iconUrl the icon url
* @param geoPoint the waypoint * @param geoPoint the waypoint
* @return a MyMapsFeature * @return a MapsFeature
*/ */
private static MyMapsFeature buildMyMapsPlacemarkFeature( private static MapsFeature buildMapsPlacemarkFeature(
String title, String description, String iconUrl, GeoPoint geoPoint) { String title, String description, String iconUrl, GeoPoint geoPoint) {
MyMapsFeature myMapsFeature = new MyMapsFeature(); MapsFeature mapsFeature = new MapsFeature();
myMapsFeature.generateAndroidId(); mapsFeature.generateAndroidId();
myMapsFeature.setType(MyMapsFeature.MARKER); mapsFeature.setType(MapsFeature.MARKER);
myMapsFeature.setIconUrl(iconUrl); mapsFeature.setIconUrl(iconUrl);
myMapsFeature.setDescription(description); mapsFeature.setDescription(description);
myMapsFeature.addPoint(geoPoint); mapsFeature.addPoint(geoPoint);
if (TextUtils.isEmpty(title)) { if (TextUtils.isEmpty(title)) {
// Features must have a name (otherwise GData upload may fail): // Features must have a name (otherwise GData upload may fail):
myMapsFeature.setTitle("-"); mapsFeature.setTitle("-");
} else { } else {
myMapsFeature.setTitle(title); mapsFeature.setTitle(title);
} }
myMapsFeature.setDescription(description.replaceAll("\n", "<br>")); mapsFeature.setDescription(description.replaceAll("\n", "<br>"));
return myMapsFeature; return mapsFeature;
} }
/** /**
@@ -244,7 +244,7 @@ public class MapsFacade {
*/ */
public boolean uploadWaypoints( public boolean uploadWaypoints(
final String mapId, final Iterable<Waypoint> waypoints) { final String mapId, final Iterable<Waypoint> waypoints) {
return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() { return wrapper.runQuery(new MapsGDataWrapper.QueryFunction() {
public void query(MapsClient client) { public void query(MapsClient client) {
// TODO(rdamazio): Stream through the waypoints in chunks. // TODO(rdamazio): Stream through the waypoints in chunks.
// I am leaving the number of waypoints very high which should not be a // I am leaving the number of waypoints very high which should not be a
@@ -254,33 +254,33 @@ public class MapsFacade {
try { try {
for (Waypoint waypoint : waypoints) { for (Waypoint waypoint : waypoints) {
MyMapsFeature feature = buildMyMapsPlacemarkFeature( MapsFeature feature = buildMapsPlacemarkFeature(
waypoint.getName(), waypoint.getDescription(), waypoint.getIcon(), waypoint.getName(), waypoint.getDescription(), waypoint.getIcon(),
getGeoPoint(waypoint.getLocation())); getGeoPoint(waypoint.getLocation()));
Entry entry = gdataConverter.getEntryForFeature(feature); Entry entry = gdataConverter.getEntryForFeature(feature);
Log.d(MyMapsConstants.TAG, Log.d(MapsConstants.TAG,
"SendToMyMaps: Creating waypoint."); "SendToMaps: Creating waypoint.");
try { try {
client.createEntry(featureFeed, authToken, entry); client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG, Log.d(MapsConstants.TAG,
"SendToMyMaps: createEntry success!"); "SendToMaps: createEntry success!");
} catch (IOException e) { } catch (IOException e) {
Log.w(MyMapsConstants.TAG, Log.w(MapsConstants.TAG,
"SendToMyMaps: createEntry 1st try failed. Retrying."); "SendToMaps: createEntry 1st try failed. Retrying.");
// Retry once (often IOException is thrown on a timeout): // Retry once (often IOException is thrown on a timeout):
client.createEntry(featureFeed, authToken, entry); client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG, Log.d(MapsConstants.TAG,
"SendToMyMaps: createEntry success on 2nd try!"); "SendToMaps: createEntry success on 2nd try!");
} }
} }
} catch (ParseException e) { } catch (ParseException e) {
Log.w(MyMapsConstants.TAG, "ParseException caught.", e); Log.w(MapsConstants.TAG, "ParseException caught.", e);
} catch (HttpException e) { } catch (HttpException e) {
Log.w(MyMapsConstants.TAG, "HttpException caught.", e); Log.w(MapsConstants.TAG, "HttpException caught.", e);
} catch (IOException e) { } catch (IOException e) {
Log.w(MyMapsConstants.TAG, "IOException caught.", e); Log.w(MapsConstants.TAG, "IOException caught.", e);
} }
} }
}); });
@@ -296,12 +296,12 @@ public class MapsFacade {
*/ */
public boolean uploadTrackPoints( public boolean uploadTrackPoints(
final String mapId, final String trackName, final Collection<Location> locations) { final String mapId, final String trackName, final Collection<Location> locations) {
return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() { return wrapper.runQuery(new MapsGDataWrapper.QueryFunction() {
@Override @Override
public void query(MapsClient client) public void query(MapsClient client)
throws IOException, Exception { throws IOException, Exception {
String featureFeed = MapsClient.getFeaturesFeed(mapId); String featureFeed = MapsClient.getFeaturesFeed(mapId);
Log.d(MyMapsConstants.TAG, "Feature feed url: " + featureFeed); Log.d(MapsConstants.TAG, "Feature feed url: " + featureFeed);
uploadTrackPoints(client, featureFeed, trackName, locations); uploadTrackPoints(client, featureFeed, trackName, locations);
} }
}); });
@@ -316,52 +316,52 @@ public class MapsFacade {
int numLocations = locations.size(); int numLocations = locations.size();
if (numLocations < 2) { if (numLocations < 2) {
// Need at least two points for a polyline: // Need at least two points for a polyline:
Log.w(MyMapsConstants.TAG, "Not uploading too few points"); Log.w(MapsConstants.TAG, "Not uploading too few points");
return true; return true;
} }
// Put the line: // Put the line:
entry = gdataConverter.getEntryForFeature( entry = gdataConverter.getEntryForFeature(
buildMyMapsLineFeature(trackName, locations)); buildMapsLineFeature(trackName, locations));
Log.d(MyMapsConstants.TAG, Log.d(MapsConstants.TAG,
"SendToMyMaps: Creating line " + entry.getTitle()); "SendToMaps: Creating line " + entry.getTitle());
try { try {
client.createEntry(featureFeed, authToken, entry); client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG, "SendToMyMaps: createEntry success!"); Log.d(MapsConstants.TAG, "SendToMaps: createEntry success!");
} catch (IOException e) { } catch (IOException e) {
Log.w(MyMapsConstants.TAG, Log.w(MapsConstants.TAG,
"SendToMyMaps: createEntry 1st try failed. Trying again."); "SendToMaps: createEntry 1st try failed. Trying again.");
// Retry once (often IOException is thrown on a timeout): // Retry once (often IOException is thrown on a timeout):
client.createEntry(featureFeed, authToken, entry); client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG, Log.d(MapsConstants.TAG,
"SendToMyMaps: createEntry success on 2nd try!"); "SendToMaps: createEntry success on 2nd try!");
} }
return true; return true;
} }
/** /**
* Builds a MyMapsFeature from a track. * Builds a MapsFeature from a track.
* *
* @param trackName the track name * @param trackName the track name
* @param locations locations on the track * @param locations locations on the track
* @return a MyMapsFeature * @return a MapsFeature
*/ */
private static MyMapsFeature buildMyMapsLineFeature(String trackName, private static MapsFeature buildMapsLineFeature(String trackName,
Iterable<Location> locations) { Iterable<Location> locations) {
MyMapsFeature myMapsFeature = new MyMapsFeature(); MapsFeature mapsFeature = new MapsFeature();
myMapsFeature.generateAndroidId(); mapsFeature.generateAndroidId();
myMapsFeature.setType(MyMapsFeature.LINE); mapsFeature.setType(MapsFeature.LINE);
if (TextUtils.isEmpty(trackName)) { if (TextUtils.isEmpty(trackName)) {
// Features must have a name (otherwise GData upload may fail): // Features must have a name (otherwise GData upload may fail):
myMapsFeature.setTitle("-"); mapsFeature.setTitle("-");
} else { } else {
myMapsFeature.setTitle(trackName); mapsFeature.setTitle(trackName);
} }
myMapsFeature.setColor(0x80FF0000); mapsFeature.setColor(0x80FF0000);
for (Location loc : locations) { for (Location loc : locations) {
myMapsFeature.addPoint(getGeoPoint(loc)); mapsFeature.addPoint(getGeoPoint(loc));
} }
return myMapsFeature; return mapsFeature;
} }
/** /**
@@ -1,5 +1,5 @@
// Copyright 2009 Google Inc. All Rights Reserved. // Copyright 2009 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
@@ -7,12 +7,12 @@ import java.util.Random;
import java.util.Vector; import java.util.Vector;
/** /**
* MyMapsFeature contains all of the data associated with a feature in My Maps, * MapsFeature contains all of the data associated with a feature in Google
* where a feature is a marker, line, or shape. Some of the data is stored in a * Maps, where a feature is a marker, line, or shape. Some of the data is stored
* {@link MyMapsFeatureMetadata} object so that it can be more efficiently * in a {@link MapsFeatureMetadata} object so that it can be more efficiently
* transmitted to other activities. * transmitted to other activities.
*/ */
class MyMapsFeature { class MapsFeature {
private static final long serialVersionUID = 8439035544430497236L; private static final long serialVersionUID = 8439035544430497236L;
@@ -47,7 +47,7 @@ class MyMapsFeature {
private final Vector<Integer> longitudeE6 = new Vector<Integer>(); private final Vector<Integer> longitudeE6 = new Vector<Integer>();
/** The metadata of this feature in a format efficient for transmission. */ /** The metadata of this feature in a format efficient for transmission. */
private MyMapsFeatureMetadata featureInfo = new MyMapsFeatureMetadata(); private MapsFeatureMetadata featureInfo = new MapsFeatureMetadata();
private final Random random = new Random(); private final Random random = new Random();
@@ -56,7 +56,7 @@ class MyMapsFeature {
* {@link #MARKER} with a blue placemark with a dot as an icon at the * {@link #MARKER} with a blue placemark with a dot as an icon at the
* location (0, 0). * location (0, 0).
*/ */
public MyMapsFeature() { public MapsFeature() {
} }
/** /**
@@ -1,10 +1,10 @@
// Copyright 2009 Google Inc. All Rights Reserved. // Copyright 2009 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
/** /**
* Metadata about a maps feature. * Metadata about a maps feature.
*/ */
class MyMapsFeatureMetadata { class MapsFeatureMetadata {
private static final String BLUE_DOT_URL = private static final String BLUE_DOT_URL =
"http://maps.google.com/mapfiles/ms/micons/blue-dot.png"; "http://maps.google.com/mapfiles/ms/micons/blue-dot.png";
@@ -19,10 +19,10 @@ class MyMapsFeatureMetadata {
private int fillColor; private int fillColor;
private String iconUrl; private String iconUrl;
public MyMapsFeatureMetadata() { public MapsFeatureMetadata() {
title = ""; title = "";
description = ""; description = "";
type = MyMapsFeature.MARKER; type = MapsFeature.MARKER;
color = DEFAULT_COLOR; color = DEFAULT_COLOR;
lineWidth = 5; lineWidth = 5;
fillColor = DEFAULT_FILL_COLOR; fillColor = DEFAULT_FILL_COLOR;
@@ -1,5 +1,5 @@
// Copyright 2009 Google Inc. All Rights Reserved. // Copyright 2009 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
import com.google.wireless.gdata.data.Entry; import com.google.wireless.gdata.data.Entry;
import com.google.wireless.gdata.data.StringUtils; import com.google.wireless.gdata.data.StringUtils;
@@ -7,27 +7,27 @@ import com.google.wireless.gdata.data.StringUtils;
import android.graphics.Color; import android.graphics.Color;
import android.util.Log; import android.util.Log;
import java.io.IOException;
import java.io.StringWriter;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory; import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
import java.io.StringWriter;
/** /**
* Converter from GData objects to MyMaps objects. * Converter from GData objects to Maps objects.
*/ */
class MyMapsGDataConverter { class MapsGDataConverter {
private final XmlSerializer xmlSerializer; private final XmlSerializer xmlSerializer;
public MyMapsGDataConverter() throws XmlPullParserException { public MapsGDataConverter() throws XmlPullParserException {
xmlSerializer = XmlPullParserFactory.newInstance().newSerializer(); xmlSerializer = XmlPullParserFactory.newInstance().newSerializer();
} }
public static MyMapsMapMetadata getMapMetadataForEntry( public static MapsMapMetadata getMapMetadataForEntry(
MapFeatureEntry entry) { MapFeatureEntry entry) {
MyMapsMapMetadata metadata = new MyMapsMapMetadata(); MapsMapMetadata metadata = new MapsMapMetadata();
if ("public".equals(entry.getPrivacy())) { if ("public".equals(entry.getPrivacy())) {
metadata.setSearchable(true); metadata.setSearchable(true);
} else { } else {
@@ -52,7 +52,7 @@ class MyMapsGDataConverter {
return MapsClient.getMapIdFromMapEntryId(entry.getId()); return MapsClient.getMapIdFromMapEntryId(entry.getId());
} }
public static Entry getMapEntryForMetadata(MyMapsMapMetadata metadata) { public static Entry getMapEntryForMetadata(MapsMapMetadata metadata) {
MapFeatureEntry entry = new MapFeatureEntry(); MapFeatureEntry entry = new MapFeatureEntry();
entry.setEditUri(metadata.getGDataEditUri()); entry.setEditUri(metadata.getGDataEditUri());
entry.setTitle(metadata.getTitle()); entry.setTitle(metadata.getTitle());
@@ -63,7 +63,7 @@ class MyMapsGDataConverter {
return entry; return entry;
} }
public MapFeatureEntry getEntryForFeature(MyMapsFeature feature) { public MapFeatureEntry getEntryForFeature(MapsFeature feature) {
MapFeatureEntry entry = new MapFeatureEntry(); MapFeatureEntry entry = new MapFeatureEntry();
entry.setTitle(feature.getTitle()); entry.setTitle(feature.getTitle());
entry.setAuthor("android"); entry.setAuthor("android");
@@ -80,7 +80,7 @@ class MyMapsGDataConverter {
xmlSerializer.startTag(null, "Placemark"); xmlSerializer.startTag(null, "Placemark");
xmlSerializer.attribute(null, "xmlns", "http://earth.google.com/kml/2.2"); xmlSerializer.attribute(null, "xmlns", "http://earth.google.com/kml/2.2");
xmlSerializer.startTag(null, "Style"); xmlSerializer.startTag(null, "Style");
if (feature.getType() == MyMapsFeature.MARKER) { if (feature.getType() == MapsFeature.MARKER) {
xmlSerializer.startTag(null, "IconStyle"); xmlSerializer.startTag(null, "IconStyle");
xmlSerializer.startTag(null, "Icon"); xmlSerializer.startTag(null, "Icon");
xmlSerializer.startTag(null, "href"); xmlSerializer.startTag(null, "href");
@@ -102,7 +102,7 @@ class MyMapsGDataConverter {
xmlSerializer.endTag(null, "width"); xmlSerializer.endTag(null, "width");
xmlSerializer.endTag(null, "LineStyle"); xmlSerializer.endTag(null, "LineStyle");
if (feature.getType() == MyMapsFeature.SHAPE) { if (feature.getType() == MapsFeature.SHAPE) {
xmlSerializer.startTag(null, "PolyStyle"); xmlSerializer.startTag(null, "PolyStyle");
xmlSerializer.startTag(null, "color"); xmlSerializer.startTag(null, "color");
int fcolor = feature.getFillColor(); int fcolor = feature.getFillColor();
@@ -137,13 +137,13 @@ class MyMapsGDataConverter {
pointBuilder.append(",0.000000"); pointBuilder.append(",0.000000");
} }
String pointString = pointBuilder.toString(); String pointString = pointBuilder.toString();
if (feature.getType() == MyMapsFeature.MARKER) { if (feature.getType() == MapsFeature.MARKER) {
xmlSerializer.startTag(null, "Point"); xmlSerializer.startTag(null, "Point");
xmlSerializer.startTag(null, "coordinates"); xmlSerializer.startTag(null, "coordinates");
xmlSerializer.text(pointString); xmlSerializer.text(pointString);
xmlSerializer.endTag(null, "coordinates"); xmlSerializer.endTag(null, "coordinates");
xmlSerializer.endTag(null, "Point"); xmlSerializer.endTag(null, "Point");
} else if (feature.getType() == MyMapsFeature.LINE) { } else if (feature.getType() == MapsFeature.LINE) {
xmlSerializer.startTag(null, "LineString"); xmlSerializer.startTag(null, "LineString");
xmlSerializer.startTag(null, "tessellate"); xmlSerializer.startTag(null, "tessellate");
xmlSerializer.text("1"); xmlSerializer.text("1");
@@ -1,5 +1,5 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
import com.google.android.apps.mytracks.io.AuthManager; import com.google.android.apps.mytracks.io.AuthManager;
import com.google.android.apps.mytracks.io.AuthManager.AuthCallback; import com.google.android.apps.mytracks.io.AuthManager.AuthCallback;
@@ -17,12 +17,12 @@ import android.util.Log;
import java.io.IOException; import java.io.IOException;
/** /**
* MyMapsGDataWrapper provides a wrapper around GData operations that maintains * MapsGDataWrapper provides a wrapper around GData operations that maintains
* the GData client, and provides a method to run gdata queries with proper * the GData client, and provides a method to run gdata queries with proper
* error handling. After a query is run, the wrapper can be queried about the * error handling. After a query is run, the wrapper can be queried about the
* error that occurred. * error that occurred.
*/ */
class MyMapsGDataWrapper { class MapsGDataWrapper {
/** /**
* A QueryFunction is passed in when executing a query. The query function * A QueryFunction is passed in when executing a query. The query function
* of the class is called with the GData client as a parameter. The * of the class is called with the GData client as a parameter. The
@@ -67,7 +67,7 @@ class MyMapsGDataWrapper {
private int retriesPending; private int retriesPending;
private boolean cleanupCalled; private boolean cleanupCalled;
public MyMapsGDataWrapper(Context context, AuthManager auth) { public MapsGDataWrapper(Context context, AuthManager auth) {
androidGdataClient = GDataClientFactory.getGDataClient(context); androidGdataClient = GDataClientFactory.getGDataClient(context);
this.auth = auth; this.auth = auth;
client = client =
@@ -92,11 +92,11 @@ class MyMapsGDataWrapper {
errorMessage = null; errorMessage = null;
return true; return true;
} catch (AuthenticationException e) { } catch (AuthenticationException e) {
Log.e(MyMapsConstants.TAG, "Exception", e); Log.e(MapsConstants.TAG, "Exception", e);
errorType = ERROR_AUTH; errorType = ERROR_AUTH;
errorMessage = e.getMessage(); errorMessage = e.getMessage();
} catch (HttpException e) { } catch (HttpException e) {
Log.e(MyMapsConstants.TAG, "HttpException", e); Log.e(MapsConstants.TAG, "HttpException", e);
errorMessage = e.getMessage(); errorMessage = e.getMessage();
if (errorMessage != null && errorMessage.contains("401")) { if (errorMessage != null && errorMessage.contains("401")) {
errorType = ERROR_AUTH; errorType = ERROR_AUTH;
@@ -104,7 +104,7 @@ class MyMapsGDataWrapper {
errorType = ERROR_CONNECTION; errorType = ERROR_CONNECTION;
} }
} catch (IOException e) { } catch (IOException e) {
Log.e(MyMapsConstants.TAG, "Exception", e); Log.e(MapsConstants.TAG, "Exception", e);
errorMessage = e.getMessage(); errorMessage = e.getMessage();
if (errorMessage != null && errorMessage.contains("503")) { if (errorMessage != null && errorMessage.contains("503")) {
errorType = ERROR_INTERNAL; errorType = ERROR_INTERNAL;
@@ -112,20 +112,20 @@ class MyMapsGDataWrapper {
errorType = ERROR_CONNECTION; errorType = ERROR_CONNECTION;
} }
} catch (ParseException e) { } catch (ParseException e) {
Log.e(MyMapsConstants.TAG, "Exception", e); Log.e(MapsConstants.TAG, "Exception", e);
errorType = ERROR_LOCAL; errorType = ERROR_LOCAL;
errorMessage = e.getMessage(); errorMessage = e.getMessage();
} catch (ConflictDetectedException e) { } catch (ConflictDetectedException e) {
Log.e(MyMapsConstants.TAG, "Exception", e); Log.e(MapsConstants.TAG, "Exception", e);
errorType = ERROR_CONFLICT; errorType = ERROR_CONFLICT;
errorMessage = e.getMessage(); errorMessage = e.getMessage();
} catch (Exception e) { } catch (Exception e) {
Log.e(MyMapsConstants.TAG, "Exception", e); Log.e(MapsConstants.TAG, "Exception", e);
errorType = ERROR_UNKNOWN; errorType = ERROR_UNKNOWN;
errorMessage = e.getMessage(); errorMessage = e.getMessage();
e.printStackTrace(); e.printStackTrace();
} }
Log.d(MyMapsConstants.TAG, "GData error encountered: " + errorMessage); Log.d(MapsConstants.TAG, "GData error encountered: " + errorMessage);
if (errorType == ERROR_AUTH && auth != null) { if (errorType == ERROR_AUTH && auth != null) {
AuthCallback whenFinished = null; AuthCallback whenFinished = null;
if (retryOnAuthFailure) { if (retryOnAuthFailure) {
@@ -1,17 +1,17 @@
// Copyright 2009 Google Inc. All Rights Reserved. // Copyright 2009 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
/** /**
* Metadata about a "my maps" map. * Metadata about a Google Maps map.
*/ */
class MyMapsMapMetadata { class MapsMapMetadata {
private String title; private String title;
private String description; private String description;
private String gdataEditUri; private String gdataEditUri;
private boolean searchable; private boolean searchable;
public MyMapsMapMetadata() { public MapsMapMetadata() {
title = ""; title = "";
description = ""; description = "";
gdataEditUri = ""; gdataEditUri = "";
@@ -1,5 +1,5 @@
// Copyright 2009 Google Inc. All Rights Reserved. // Copyright 2009 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
import com.google.wireless.gdata.data.Entry; import com.google.wireless.gdata.data.Entry;
import com.google.wireless.gdata.data.Feed; import com.google.wireless.gdata.data.Feed;
@@ -1,5 +1,5 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
import com.google.wireless.gdata.client.GDataParserFactory; import com.google.wireless.gdata.client.GDataParserFactory;
import com.google.wireless.gdata.data.Entry; import com.google.wireless.gdata.data.Entry;
@@ -1,5 +1,5 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.maps;
import com.google.wireless.gdata.data.StringUtils; import com.google.wireless.gdata.data.StringUtils;
import com.google.wireless.gdata.parser.ParseException; import com.google.wireless.gdata.parser.ParseException;
@@ -20,7 +20,7 @@ import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.analytics.GoogleAnalyticsTracker; import com.google.android.apps.analytics.GoogleAnalyticsTracker;
import com.google.android.apps.mytracks.AccountChooser; import com.google.android.apps.mytracks.AccountChooser;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyMapsList; import com.google.android.apps.mytracks.MapsList;
import com.google.android.apps.mytracks.ProgressIndicator; import com.google.android.apps.mytracks.ProgressIndicator;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.Track;
@@ -31,9 +31,9 @@ import com.google.android.apps.mytracks.io.AuthManagerFactory;
import com.google.android.apps.mytracks.io.SendToDocs; import com.google.android.apps.mytracks.io.SendToDocs;
import com.google.android.apps.mytracks.io.SendToFusionTables; import com.google.android.apps.mytracks.io.SendToFusionTables;
import com.google.android.apps.mytracks.io.SendToFusionTables.OnSendCompletedListener; import com.google.android.apps.mytracks.io.SendToFusionTables.OnSendCompletedListener;
import com.google.android.apps.mytracks.io.SendToMyMaps; import com.google.android.apps.mytracks.io.SendToMaps;
import com.google.android.apps.mytracks.io.mymaps.MapsFacade; import com.google.android.apps.mytracks.io.maps.MapsConstants;
import com.google.android.apps.mytracks.io.mymaps.MyMapsConstants; import com.google.android.apps.mytracks.io.maps.MapsFacade;
import com.google.android.apps.mytracks.util.SystemUtils; import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.apps.mytracks.util.UriUtils; import com.google.android.apps.mytracks.util.UriUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -123,18 +123,18 @@ public class SendActivity extends Activity implements ProgressIndicator {
// Send request information. // Send request information.
private SendType sendType; private SendType sendType;
private long sendTrackId; private long sendTrackId;
private boolean sendToMyMaps; private boolean sendToMaps;
private boolean sendToMyMapsNewMap; private boolean sendToMapsNewMap;
private boolean sendToFusionTables; private boolean sendToFusionTables;
private boolean sendToDocs; private boolean sendToDocs;
// Send result information, used by results dialog. // Send result information, used by results dialog.
private boolean sendToMyMapsSuccess = false; private boolean sendToMapsSuccess = false;
private boolean sendToFusionTablesSuccess = false; private boolean sendToFusionTablesSuccess = false;
private boolean sendToDocsSuccess = false; private boolean sendToDocsSuccess = false;
// Send result information, used to share a link. // Send result information, used to share a link.
private String sendToMyMapsMapId; private String sendToMapsMapId;
private String sendToFusionTablesTableId; private String sendToFusionTablesTableId;
// Current sending state. // Current sending state.
@@ -241,8 +241,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
dialog.dismiss(); dialog.dismiss();
sendToMyMaps = sendDialog.getSendToMyMaps(); sendToMaps = sendDialog.getSendToMaps();
sendToMyMapsNewMap = sendDialog.getCreateNewMap(); sendToMapsNewMap = sendDialog.getCreateNewMap();
sendToFusionTables = sendDialog.getSendToFusionTables(); sendToFusionTables = sendDialog.getSendToFusionTables();
sendToDocs = sendDialog.getSendToDocs(); sendToDocs = sendDialog.getSendToDocs();
@@ -256,15 +256,15 @@ public class SendActivity extends Activity implements ProgressIndicator {
private void restoreInstanceState(Bundle savedInstanceState) { private void restoreInstanceState(Bundle savedInstanceState) {
currentState = SendState.values()[savedInstanceState.getInt(STATE_STATE)]; currentState = SendState.values()[savedInstanceState.getInt(STATE_STATE)];
sendToMyMaps = savedInstanceState.getBoolean(STATE_SEND_TO_MAPS); sendToMaps = savedInstanceState.getBoolean(STATE_SEND_TO_MAPS);
sendToFusionTables = savedInstanceState.getBoolean(STATE_SEND_TO_FUSION_TABLES); sendToFusionTables = savedInstanceState.getBoolean(STATE_SEND_TO_FUSION_TABLES);
sendToDocs = savedInstanceState.getBoolean(STATE_SEND_TO_DOCS); sendToDocs = savedInstanceState.getBoolean(STATE_SEND_TO_DOCS);
sendToMyMapsSuccess = savedInstanceState.getBoolean(STATE_MAPS_SUCCESS); sendToMapsSuccess = savedInstanceState.getBoolean(STATE_MAPS_SUCCESS);
sendToFusionTablesSuccess = savedInstanceState.getBoolean(STATE_FUSION_SUCCESS); sendToFusionTablesSuccess = savedInstanceState.getBoolean(STATE_FUSION_SUCCESS);
sendToDocsSuccess = savedInstanceState.getBoolean(STATE_DOCS_SUCCESS); sendToDocsSuccess = savedInstanceState.getBoolean(STATE_DOCS_SUCCESS);
sendToMyMapsMapId = savedInstanceState.getString(STATE_MAP_ID); sendToMapsMapId = savedInstanceState.getString(STATE_MAP_ID);
sendToFusionTablesTableId = savedInstanceState.getString(STATE_TABLE_ID); sendToFusionTablesTableId = savedInstanceState.getString(STATE_TABLE_ID);
lastAccountName = savedInstanceState.getString(STATE_ACCOUNT_NAME); lastAccountName = savedInstanceState.getString(STATE_ACCOUNT_NAME);
@@ -277,11 +277,11 @@ public class SendActivity extends Activity implements ProgressIndicator {
outState.putInt(STATE_STATE, currentState.ordinal()); outState.putInt(STATE_STATE, currentState.ordinal());
outState.putBoolean(STATE_MAPS_SUCCESS, sendToMyMapsSuccess); outState.putBoolean(STATE_MAPS_SUCCESS, sendToMapsSuccess);
outState.putBoolean(STATE_FUSION_SUCCESS, sendToFusionTablesSuccess); outState.putBoolean(STATE_FUSION_SUCCESS, sendToFusionTablesSuccess);
outState.putBoolean(STATE_DOCS_SUCCESS, sendToDocsSuccess); outState.putBoolean(STATE_DOCS_SUCCESS, sendToDocsSuccess);
outState.putString(STATE_MAP_ID, sendToMyMapsMapId); outState.putString(STATE_MAP_ID, sendToMapsMapId);
outState.putString(STATE_TABLE_ID, sendToFusionTablesTableId); outState.putString(STATE_TABLE_ID, sendToFusionTablesTableId);
outState.putString(STATE_ACCOUNT_NAME, lastAccountName); outState.putString(STATE_ACCOUNT_NAME, lastAccountName);
@@ -373,7 +373,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
private SendState startSend() { private SendState startSend() {
showDialog(PROGRESS_DIALOG); showDialog(PROGRESS_DIALOG);
if (sendToMyMaps) { if (sendToMaps) {
return SendState.AUTHENTICATE_MAPS; return SendState.AUTHENTICATE_MAPS;
} else if (sendToFusionTables) { } else if (sendToFusionTables) {
return SendState.AUTHENTICATE_FUSION_TABLES; return SendState.AUTHENTICATE_FUSION_TABLES;
@@ -400,18 +400,18 @@ public class SendActivity extends Activity implements ProgressIndicator {
private SendState authenticateToGoogleMaps() { private SendState authenticateToGoogleMaps() {
Log.d(TAG, "SendActivity.authenticateToGoogleMaps"); Log.d(TAG, "SendActivity.authenticateToGoogleMaps");
progressDialog.setProgress(0); progressDialog.setProgress(0);
progressDialog.setMessage(getAuthenticatingProgressMessage(SendType.MYMAPS)); progressDialog.setMessage(getAuthenticatingProgressMessage(SendType.MAPS));
authenticate(Constants.AUTHENTICATE_TO_MY_MAPS, MyMapsConstants.SERVICE_NAME); authenticate(Constants.AUTHENTICATE_TO_MAPS, MapsConstants.SERVICE_NAME);
// AUTHENTICATE_TO_MY_MAPS callback calls sendToGoogleMaps // AUTHENTICATE_TO_MAPS callback calls sendToGoogleMaps
return SendState.NOT_READY; return SendState.NOT_READY;
} }
private SendState pickMap() { private SendState pickMap() {
if (!sendToMyMapsNewMap) { if (!sendToMapsNewMap) {
// Ask the user to choose a map to upload into // Ask the user to choose a map to upload into
Intent listIntent = new Intent(this, MyMapsList.class); Intent listIntent = new Intent(this, MapsList.class);
listIntent.putExtra(MyMapsList.EXTRA_ACCOUNT_NAME, lastAccountName); listIntent.putExtra(MapsList.EXTRA_ACCOUNT_NAME, lastAccountName);
listIntent.putExtra(MyMapsList.EXTRA_ACCOUNT_TYPE, lastAccountType); listIntent.putExtra(MapsList.EXTRA_ACCOUNT_TYPE, lastAccountType);
startActivityForResult(listIntent, Constants.GET_MAP); startActivityForResult(listIntent, Constants.GET_MAP);
// The callback for GET_MAP calls authenticateToGoogleMaps // The callback for GET_MAP calls authenticateToGoogleMaps
return SendState.NOT_READY; return SendState.NOT_READY;
@@ -423,12 +423,12 @@ public class SendActivity extends Activity implements ProgressIndicator {
private SendState sendToGoogleMaps() { private SendState sendToGoogleMaps() {
tracker.trackPageView("/send/maps"); tracker.trackPageView("/send/maps");
SendToMyMaps.OnSendCompletedListener onCompletion = new SendToMyMaps.OnSendCompletedListener() { SendToMaps.OnSendCompletedListener onCompletion = new SendToMaps.OnSendCompletedListener() {
@Override @Override
public void onSendCompleted(String mapId, boolean success) { public void onSendCompleted(String mapId, boolean success) {
sendToMyMapsSuccess = success; sendToMapsSuccess = success;
if (sendToMyMapsSuccess) { if (sendToMapsSuccess) {
sendToMyMapsMapId = mapId; sendToMapsMapId = mapId;
// Update the map id for this track: // Update the map id for this track:
try { try {
Track track = providerUtils.getTrack(sendTrackId); Track track = providerUtils.getTrack(sendTrackId);
@@ -449,14 +449,14 @@ public class SendActivity extends Activity implements ProgressIndicator {
} }
}; };
if (sendToMyMapsMapId == null) { if (sendToMapsMapId == null) {
sendToMyMapsMapId = SendToMyMaps.NEW_MAP_ID; sendToMapsMapId = SendToMaps.NEW_MAP_ID;
} }
final SendToMyMaps sender = new SendToMyMaps(this, sendToMyMapsMapId, lastAuth, final SendToMaps sender = new SendToMaps(this, sendToMapsMapId, lastAuth,
sendTrackId, this /*progressIndicator*/, onCompletion); sendTrackId, this /*progressIndicator*/, onCompletion);
new Thread(sender, "SendToMyMaps").start(); new Thread(sender, "SendToMaps").start();
return SendState.NOT_READY; return SendState.NOT_READY;
} }
@@ -611,7 +611,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
// sharing. We won't display a share button. // sharing. We won't display a share button.
List<SendResult> results = makeSendToGoogleResults(); List<SendResult> results = makeSendToGoogleResults();
final boolean canShare = sendToFusionTablesTableId != null || sendToMyMapsMapId != null; final boolean canShare = sendToFusionTablesTableId != null || sendToMapsMapId != null;
final OnClickListener finishListener = new DialogInterface.OnClickListener() { final OnClickListener finishListener = new DialogInterface.OnClickListener() {
@Override @Override
@@ -654,9 +654,9 @@ public class SendActivity extends Activity implements ProgressIndicator {
private SendState shareLink() { private SendState shareLink() {
String url = null; String url = null;
if (sendToMyMaps && sendToMyMapsSuccess) { if (sendToMaps && sendToMapsSuccess) {
// Prefer a link to My Maps // Prefer a link to Maps
url = MapsFacade.buildMapUrl(sendToMyMapsMapId); url = MapsFacade.buildMapUrl(sendToMapsMapId);
} else if (sendToFusionTables && sendToFusionTablesSuccess) { } else if (sendToFusionTables && sendToFusionTablesSuccess) {
// Otherwise try using the link to fusion tables // Otherwise try using the link to fusion tables
url = getFusionTablesUrl(sendTrackId); url = getFusionTablesUrl(sendTrackId);
@@ -672,7 +672,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
} }
/** /**
* Shares a link to a My Map or Fusion Table via external app (email, gmail, ...) * Shares a link to a Map or Fusion Table via external app (email, gmail, ...)
* A chooser with apps that support text/plain will be shown to the user. * A chooser with apps that support text/plain will be shown to the user.
*/ */
private void shareLinkToMap(String url) { private void shareLinkToMap(String url) {
@@ -702,8 +702,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
*/ */
private List<SendResult> makeSendToGoogleResults() { private List<SendResult> makeSendToGoogleResults() {
List<SendResult> results = new ArrayList<SendResult>(); List<SendResult> results = new ArrayList<SendResult>();
if (sendToMyMaps) { if (sendToMaps) {
results.add(new SendResult(SendType.MYMAPS, sendToMyMapsSuccess)); results.add(new SendResult(SendType.MAPS, sendToMapsSuccess));
} }
if (sendToFusionTables) { if (sendToFusionTables) {
results.add(new SendResult(SendType.FUSION_TABLES, results.add(new SendResult(SendType.FUSION_TABLES,
@@ -807,7 +807,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
Log.d(TAG, "Get map result: " + resultCode); Log.d(TAG, "Get map result: " + resultCode);
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
if (results.hasExtra("mapid")) { if (results.hasExtra("mapid")) {
sendToMyMapsMapId = results.getStringExtra("mapid"); sendToMapsMapId = results.getStringExtra("mapid");
} }
nextState = SendState.SEND_TO_MAPS; nextState = SendState.SEND_TO_MAPS;
} else { } else {
@@ -829,8 +829,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
private void onLoginSuccess(int requestCode) { private void onLoginSuccess(int requestCode) {
SendState nextState; SendState nextState;
switch (requestCode) { switch (requestCode) {
case Constants.AUTHENTICATE_TO_MY_MAPS: case Constants.AUTHENTICATE_TO_MAPS:
// Authenticated with Google My Maps // Authenticated with Google Maps
nextState = SendState.PICK_MAP; nextState = SendState.PICK_MAP;
break; break;
case Constants.AUTHENTICATE_TO_FUSION_TABLES: case Constants.AUTHENTICATE_TO_FUSION_TABLES:
@@ -856,12 +856,12 @@ public class SendActivity extends Activity implements ProgressIndicator {
} }
/** /**
* Resets status information for sending to MyMaps/Docs. * Resets status information for sending to Maps/Fusion Tables/Docs.
*/ */
private void resetState() { private void resetState() {
currentState = SendState.SEND_OPTIONS; currentState = SendState.SEND_OPTIONS;
sendToMyMapsMapId = null; sendToMapsMapId = null;
sendToMyMapsSuccess = true; sendToMapsSuccess = true;
sendToFusionTablesSuccess = true; sendToFusionTablesSuccess = true;
sendToDocsSuccess = true; sendToDocsSuccess = true;
sendToFusionTablesTableId = null; sendToFusionTablesTableId = null;
@@ -81,7 +81,7 @@ public class SendDialog extends Dialog {
} }
}; };
mapsCheckBox = (CheckBox) findViewById(R.id.send_google_my_maps); mapsCheckBox = (CheckBox) findViewById(R.id.send_google_maps);
mapsCheckBox.setOnCheckedChangeListener(checkBoxListener); mapsCheckBox.setOnCheckedChangeListener(checkBoxListener);
fusionTablesCheckBox = (CheckBox) findViewById(R.id.send_google_fusion_tables); fusionTablesCheckBox = (CheckBox) findViewById(R.id.send_google_fusion_tables);
@@ -127,7 +127,7 @@ public class SendDialog extends Dialog {
getContext().getString(R.string.pick_existing_map_key), !getCreateNewMap()); getContext().getString(R.string.pick_existing_map_key), !getCreateNewMap());
if (mapsEnabled && fusionTablesEnabled && docsEnabled) { if (mapsEnabled && fusionTablesEnabled && docsEnabled) {
editor.putBoolean( editor.putBoolean(
getContext().getString(R.string.send_to_my_maps_key), getSendToMyMaps()); getContext().getString(R.string.send_to_maps_key), getSendToMaps());
editor.putBoolean( editor.putBoolean(
getContext().getString(R.string.send_to_fusion_tables_key), getSendToFusionTables()); getContext().getString(R.string.send_to_fusion_tables_key), getSendToFusionTables());
editor.putBoolean(getContext().getString(R.string.send_to_docs_key), getSendToDocs()); editor.putBoolean(getContext().getString(R.string.send_to_docs_key), getSendToDocs());
@@ -150,7 +150,7 @@ public class SendDialog extends Dialog {
* Note that sendType can be null, so cannot use a switch statement based on * Note that sendType can be null, so cannot use a switch statement based on
* the sendType. * the sendType.
*/ */
if (sendType == SendType.MYMAPS) { if (sendType == SendType.MAPS) {
mapsEnabled = true; mapsEnabled = true;
fusionTablesEnabled = false; fusionTablesEnabled = false;
docsEnabled = false; docsEnabled = false;
@@ -185,7 +185,7 @@ public class SendDialog extends Dialog {
existingMapRadioButton.setChecked(pickExistingMap); existingMapRadioButton.setChecked(pickExistingMap);
mapsCheckBox.setChecked( mapsCheckBox.setChecked(
prefs.getBoolean(getContext().getString(R.string.send_to_my_maps_key), true)); prefs.getBoolean(getContext().getString(R.string.send_to_maps_key), true));
fusionTablesCheckBox.setChecked( fusionTablesCheckBox.setChecked(
prefs.getBoolean(getContext().getString(R.string.send_to_fusion_tables_key), true)); prefs.getBoolean(getContext().getString(R.string.send_to_fusion_tables_key), true));
docsCheckBox.setChecked( docsCheckBox.setChecked(
@@ -197,8 +197,8 @@ public class SendDialog extends Dialog {
* Updates the UI display based on the current state. * Updates the UI display based on the current state.
*/ */
private void updateDisplay() { private void updateDisplay() {
send.setEnabled(getSendToMyMaps() || getSendToFusionTables() || getSendToDocs()); send.setEnabled(getSendToMaps() || getSendToFusionTables() || getSendToDocs());
mapsOptionTableRow.setVisibility(getSendToMyMaps() ? View.VISIBLE : View.GONE); mapsOptionTableRow.setVisibility(getSendToMaps() ? View.VISIBLE : View.GONE);
} }
public void setOnClickListener(OnClickListener clickListener) { public void setOnClickListener(OnClickListener clickListener) {
@@ -209,7 +209,7 @@ public class SendDialog extends Dialog {
return newMapRadioButton.isChecked(); return newMapRadioButton.isChecked();
} }
public boolean getSendToMyMaps() { public boolean getSendToMaps() {
return mapsEnabled && mapsCheckBox.isChecked(); return mapsEnabled && mapsCheckBox.isChecked();
} }
@@ -26,8 +26,8 @@ import android.os.Parcelable;
* @author Matthew Simmons * @author Matthew Simmons
*/ */
public enum SendType implements Parcelable { public enum SendType implements Parcelable {
MYMAPS(R.string.send_google_my_maps, MAPS(R.string.send_google_maps,
R.string.send_google_my_maps_url), R.string.send_google_maps_url),
FUSION_TABLES(R.string.send_google_fusion_tables, FUSION_TABLES(R.string.send_google_fusion_tables,
R.string.send_google_fusion_tables_url), R.string.send_google_fusion_tables_url),
DOCS(R.string.send_google_docs, DOCS(R.string.send_google_docs,
@@ -59,7 +59,7 @@ public class ResultDialogFactoryTest extends ActivityInstrumentationTestCase2<My
}; };
public void testSuccess_noShare() { public void testSuccess_noShare() {
List<SendResult> results = makeResults(new SendResult(SendType.MYMAPS, true), List<SendResult> results = makeResults(new SendResult(SendType.MAPS, true),
new SendResult(SendType.DOCS, true)); new SendResult(SendType.DOCS, true));
AlertDialog dialog = ResultDialogFactory.makeDialog( AlertDialog dialog = ResultDialogFactory.makeDialog(
@@ -70,7 +70,7 @@ public class ResultDialogFactoryTest extends ActivityInstrumentationTestCase2<My
ListAdapter listAdapter = listView.getAdapter(); ListAdapter listAdapter = listView.getAdapter();
assertEquals(2, listAdapter.getCount()); assertEquals(2, listAdapter.getCount());
assertEquals(SendType.MYMAPS, ((SendResult) listAdapter.getItem(0)).getType()); assertEquals(SendType.MAPS, ((SendResult) listAdapter.getItem(0)).getType());
assertEquals(SendType.DOCS, ((SendResult) listAdapter.getItem(1)).getType()); assertEquals(SendType.DOCS, ((SendResult) listAdapter.getItem(1)).getType());
// Checking the return code of Dialog#getButton doesn't appear to be // Checking the return code of Dialog#getButton doesn't appear to be
@@ -92,7 +92,7 @@ public class ResultDialogFactoryTest extends ActivityInstrumentationTestCase2<My
public void testSuccess_share() { public void testSuccess_share() {
List<SendResult> results = makeResults( List<SendResult> results = makeResults(
new SendResult(SendType.MYMAPS, true), new SendResult(SendType.DOCS, true)); new SendResult(SendType.MAPS, true), new SendResult(SendType.DOCS, true));
AlertDialog dialog = ResultDialogFactory.makeDialog( AlertDialog dialog = ResultDialogFactory.makeDialog(
myTracks, results, clickListener, clickListener, null); myTracks, results, clickListener, clickListener, null);
@@ -103,7 +103,7 @@ public class ResultDialogFactoryTest extends ActivityInstrumentationTestCase2<My
} }
public void testFailure_noShare() { public void testFailure_noShare() {
List<SendResult> results = makeResults(new SendResult(SendType.MYMAPS, true), List<SendResult> results = makeResults(new SendResult(SendType.MAPS, true),
new SendResult(SendType.DOCS, false)); new SendResult(SendType.DOCS, false));
AlertDialog dialog = ResultDialogFactory.makeDialog( AlertDialog dialog = ResultDialogFactory.makeDialog(
@@ -117,7 +117,7 @@ public class ResultDialogFactoryTest extends ActivityInstrumentationTestCase2<My
} }
public void testFailure_share() { public void testFailure_share() {
List<SendResult> results = makeResults(new SendResult(SendType.MYMAPS, true), List<SendResult> results = makeResults(new SendResult(SendType.MAPS, true),
new SendResult(SendType.DOCS, false)); new SendResult(SendType.DOCS, false));
AlertDialog dialog = ResultDialogFactory.makeDialog( AlertDialog dialog = ResultDialogFactory.makeDialog(
@@ -69,7 +69,7 @@ public class ResultListAdapterTest extends AndroidTestCase {
} }
} }
private final SendType sendType = SendType.MYMAPS; private final SendType sendType = SendType.MAPS;
private View inflateContentView(int viewId) { private View inflateContentView(int viewId) {
LayoutInflater layoutInflater LayoutInflater layoutInflater