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>
</activity>
<activity android:name="com.google.android.apps.mytracks.MyMapsList"
android:label="@string/my_maps_list_title"
<activity android:name="com.google.android.apps.mytracks.MapsList"
android:label="@string/maps_list_title"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale"
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:textSize="16dip"
android:textColor="#fff"
android:text="@string/my_maps_list_pick_map"
android:text="@string/maps_list_pick_map"
android:layout_weight="0"/>
</LinearLayout>
<ListView android:id="@+id/maplist"
@@ -47,7 +47,7 @@ limitations under the License.
android:textSize="16dip"
android:textColor="#c00"
android:textStyle="bold"
android:text="@string/my_maps_list_no_maps"
android:text="@string/maps_list_no_maps"
android:visibility="gone"/>
<TextView android:id="@+id/failed"
android:layout_width="fill_parent"
@@ -58,7 +58,7 @@ limitations under the License.
android:textSize="16dip"
android:textColor="#c00"
android:textStyle="bold"
android:text="@string/my_maps_list_error"
android:text="@string/maps_list_error"
android:visibility="gone"/>
<LinearLayout
android:orientation="horizontal"
@@ -89,7 +89,7 @@ limitations under the License.
android:textSize="16dip"
android:textColor="#fff"
android:textStyle="bold"
android:text="@string/my_maps_list_loading"/>
android:text="@string/maps_list_loading"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -39,11 +39,11 @@ limitations under the License.
<!-- Google Maps -->
<TableRow android:id="@+id/send_google_maps_row">
<ImageView
android:src="@drawable/mymaps_icon"
android:src="@drawable/maps_icon"
style="@style/SendGoogleImageView"/>
<CheckBox
android:id="@+id/send_google_my_maps"
android:text="@string/send_google_my_maps"
android:id="@+id/send_google_maps"
android:text="@string/send_google_maps"
style="@style/SendGoogleCheckBox"/>
</TableRow>
<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"
style="@style/WelcomeTextView"/>
<TextView
android:text="@string/welcome_my_maps_sharing_question"
android:text="@string/welcome_maps_sharing_question"
style="@style/WelcomeTextView.Question"/>
<TextView
android:text="@string/welcome_my_maps_sharing_answer"
android:text="@string/welcome_maps_sharing_answer"
style="@style/WelcomeTextView"/>
</LinearLayout>
</ScrollView>
+1 -1
View File
@@ -43,7 +43,7 @@ limitations under the License.
</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_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_none">NONE</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="send_to_docs_key">sendToDocs</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="share_url_only_key">shareUrlOnly</string>
<string name="split_frequency_key">splitFrequency</string>
+40 -50
View File
@@ -820,6 +820,43 @@ limitations under the License.
Waypoint
</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 -->
<string name="menu_aggregated_statistics"
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.
</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 -->
<string name="my_tracks_app_name"
translation_description="The My Tracks application name.">
@@ -1139,7 +1129,7 @@ limitations under the License.
Screenshot: send_google_choose_service.png">
Google Fusion Tables
</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
checkbox option to send to Google Maps.
@@ -3196,7 +3186,7 @@ limitations under the License.
Screenshot: welcome.png">
How precise are the recorded tracks?
</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
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
Maps.
</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
visibility.
@@ -40,7 +40,7 @@ public abstract class Constants {
public static final int GET_LOGIN = 0;
public static final int GET_MAP = 1;
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_DOCLIST = 5;
public static final int AUTHENTICATE_TO_TRIX = 6;
@@ -99,7 +99,7 @@ public class ExportAllTracks {
new DialogInterface.OnClickListener() {
@Override
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);
return true;
case Constants.MENU_SHARE_MAP:
SendActivity.sendToGoogle(this, dataHub.getSelectedTrackId(), SendType.MYMAPS);
SendActivity.sendToGoogle(this, dataHub.getSelectedTrackId(), SendType.MAPS);
return true;
case Constants.MENU_SHARE_FUSION_TABLE:
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.AuthCallback;
import com.google.android.apps.mytracks.io.AuthManagerFactory;
import com.google.android.apps.mytracks.io.mymaps.MapsFacade;
import com.google.android.apps.mytracks.io.mymaps.MyMapsConstants;
import com.google.android.apps.mytracks.io.maps.MapsConstants;
import com.google.android.apps.mytracks.io.maps.MapsFacade;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
@@ -35,12 +35,12 @@ import android.widget.ListView;
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.
*
* @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;
public static final String EXTRA_ACCOUNT_NAME = "accountName";
@@ -48,7 +48,7 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback
private MapsFacade mapsClient;
private AuthManager auth;
private MyMapsListAdapter listAdapter;
private MapsListAdapter listAdapter;
private final OnItemClickListener clickListener =
new OnItemClickListener() {
@@ -68,11 +68,11 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback
super.onCreate(icicle);
auth = AuthManagerFactory.getAuthManager(this, GET_LOGIN, null, true,
MyMapsConstants.SERVICE_NAME);
MapsConstants.SERVICE_NAME);
setContentView(R.layout.list);
listAdapter = new MyMapsListAdapter(this);
listAdapter = new MapsListAdapter(this);
ListView list = (ListView) findViewById(R.id.maplist);
list.setOnItemClickListener(clickListener);
@@ -113,7 +113,7 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback
}
// Runs in UI thread.
mapsClient = new MapsFacade(MyMapsList.this, auth);
mapsClient = new MapsFacade(MapsList.this, auth);
startLookup();
}
@@ -127,7 +127,7 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback
public void run() {
// Communication with Maps happens in its own thread.
// This will call onReceivedMapListing below.
final boolean success = mapsClient.getMapsList(MyMapsList.this);
final boolean success = mapsClient.getMapsList(MapsList.this);
runOnUiThread(new Runnable() {
@Override
@@ -15,13 +15,13 @@ import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
public class MyMapsListAdapter implements ListAdapter {
public class MapsListAdapter implements ListAdapter {
private Vector<String[]> mapsList;
private Vector<Boolean> publicList;
private Set<DataSetObserver> observerSet;
private final Activity activity;
public MyMapsListAdapter(Activity activity) {
public MapsListAdapter(Activity activity) {
this.activity = activity;
mapsList = new Vector<String[]>();
@@ -99,10 +99,10 @@ public class MyMapsListAdapter implements ListAdapter {
(TextView) convertView.findViewById(R.id.maplistpublic);
if (publicList.get(position)) {
publicUnlisted.setTextColor(Color.RED);
publicUnlisted.setText(R.string.my_maps_list_public_label);
publicUnlisted.setText(R.string.maps_list_public_label);
} else {
publicUnlisted.setTextColor(Color.GREEN);
publicUnlisted.setText(R.string.my_maps_list_unlisted_label);
publicUnlisted.setText(R.string.maps_list_unlisted_label);
}
return convertView;
@@ -53,7 +53,7 @@ import android.widget.TextView;
/**
* A list activity displaying all the recorded tracks. There's a context
* 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
*/
@@ -176,7 +176,7 @@ public class TrackList extends ListActivity
SendActivity.sendToGoogle(this, trackId, null);
return true;
case Constants.MENU_SHARE_MAP:
SendActivity.sendToGoogle(this, trackId, SendType.MYMAPS);
SendActivity.sendToGoogle(this, trackId, SendType.MAPS);
return true;
case Constants.MENU_SHARE_FUSION_TABLE:
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.Track;
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.stats.DoubleBuffer;
import com.google.android.apps.mytracks.stats.TripStatistics;
@@ -43,7 +43,7 @@ import java.util.List;
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.
*
* IMPORTANT: while this code is Apache-licensed, please notice that usage of
@@ -53,7 +53,7 @@ import java.util.Vector;
*
* @author Leif Hendrik Wilden
*/
public class SendToMyMaps implements Runnable {
public class SendToMaps implements Runnable {
public static final String NEW_MAP_ID = "new";
private static final int MAX_POINTS_PER_UPLOAD = 2048;
@@ -80,7 +80,7 @@ public class SendToMyMaps implements Runnable {
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,
OnSendCompletedListener onCompletion) {
this.context = context;
@@ -95,7 +95,7 @@ public class SendToMyMaps implements Runnable {
@Override
public void run() {
Log.d(TAG, "Sending to MyMaps: trackId = " + trackId);
Log.d(TAG, "Sending to Maps: trackId = " + trackId);
doUpload();
}
@@ -130,7 +130,7 @@ public class SendToMyMaps implements Runnable {
}
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));
StringBuilder mapIdBuilder = new StringBuilder();
@@ -170,11 +170,11 @@ public class SendToMyMaps implements Runnable {
}
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);
} finally {
if (mapsClient != null) {
@@ -321,7 +321,7 @@ public class SendToMyMaps implements Runnable {
// Start uploading them
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));
for (Track splitTrack : splitTracks) {
if (totalSegmentsUploaded > 1) {
@@ -331,13 +331,13 @@ public class SendToMyMaps implements Runnable {
}
totalSegmentsUploaded++;
Log.d(TAG,
"SendToMyMaps: Prepared feature for upload w/ "
"SendToMaps: Prepared feature for upload w/ "
+ splitTrack.getLocations().size() + " points.");
// Transmit tracks via GData feed:
// -------------------------------
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())) {
Log.e(TAG, "Uploading failed");
return false;
@@ -386,7 +386,7 @@ public class SendToMyMaps implements Runnable {
prepareTrackSegment(segment, splitTracks);
Log.d(TAG,
"MyTracksSendToMyMaps: Starting new track segment...");
"MyTracksSendToMaps: Starting new track segment...");
startNewTrackSegment = false;
segment = new Track();
segment.setId(track.getId());
@@ -1,5 +1,5 @@
// 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;
@@ -1,5 +1,5 @@
// 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;
@@ -1,5 +1,5 @@
// 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.GDataParserFactory;
@@ -33,11 +33,11 @@ class MapsClient extends GDataServiceClient {
@Override
public String getServiceName() {
return MyMapsConstants.SERVICE_NAME;
return MapsConstants.SERVICE_NAME;
}
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() {
@@ -1,10 +1,10 @@
// 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 MAPSHOP_BASE_URL =
"https://maps.google.com/maps/ms";
@@ -13,5 +13,5 @@ public class MyMapsConstants {
/**
* Private constructor to prevent instantiation.
*/
private MyMapsConstants() { }
private MapsConstants() { }
}
@@ -1,5 +1,5 @@
// 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.io.AuthManager;
@@ -43,19 +43,19 @@ public class MapsFacade {
"http://maps.google.com/mapfiles/ms/micons/green-dot.png";
private final Context context;
private final MyMapsGDataWrapper wrapper;
private final MyMapsGDataConverter gdataConverter;
private final MapsGDataWrapper wrapper;
private final MapsGDataConverter gdataConverter;
private final String authToken;
public MapsFacade(Context context, AuthManager auth) {
this.context = context;
this.authToken = auth.getAuthToken();
wrapper = new MyMapsGDataWrapper(context, auth);
wrapper = new MapsGDataWrapper(context, auth);
wrapper.setRetryOnAuthFailure(true);
try {
gdataConverter = new MyMapsGDataConverter();
gdataConverter = new MapsGDataConverter();
} catch (XmlPullParserException e) {
throw new IllegalStateException("Unable to create maps data converter", e);
}
@@ -72,7 +72,7 @@ public class MapsFacade {
* @return true on success, false otherwise
*/
public boolean getMapsList(final MapsListCallback callback) {
return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() {
return wrapper.runQuery(new MapsGDataWrapper.QueryFunction() {
@Override
public void query(MapsClient client) throws IOException, Exception {
GDataParser listParser = client.getParserForFeed(
@@ -81,9 +81,9 @@ public class MapsFacade {
while (listParser.hasMoreData()) {
MapFeatureEntry entry =
(MapFeatureEntry) listParser.readNextEntry(null);
MyMapsMapMetadata metadata =
MyMapsGDataConverter.getMapMetadataForEntry(entry);
String mapId = MyMapsGDataConverter.getMapidForEntry(entry);
MapsMapMetadata metadata =
MapsGDataConverter.getMapMetadataForEntry(entry);
String mapId = MapsGDataConverter.getMapidForEntry(entry);
callback.onReceivedMapListing(
mapId, metadata.getTitle(), metadata.getDescription(), metadata.getSearchable());
@@ -111,24 +111,24 @@ public class MapsFacade {
throw new IllegalArgumentException("mapIdBuilder should be empty");
}
return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() {
return wrapper.runQuery(new MapsGDataWrapper.QueryFunction() {
@Override
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();
Log.d(MyMapsConstants.TAG, "Map feed is " + mapFeed);
MyMapsMapMetadata metaData = new MyMapsMapMetadata();
Log.d(MapsConstants.TAG, "Map feed is " + mapFeed);
MapsMapMetadata metaData = new MapsMapMetadata();
metaData.setTitle(title);
metaData.setDescription(description + " - "
+ category + " - " + StringUtils.getCreatedByMyTracks(context, false));
metaData.setSearchable(isPublic);
Entry entry = MyMapsGDataConverter.getMapEntryForMetadata(metaData);
Log.d(MyMapsConstants.TAG, "Title: " + entry.getTitle());
Entry entry = MapsGDataConverter.getMapEntryForMetadata(metaData);
Log.d(MapsConstants.TAG, "Title: " + entry.getTitle());
Entry map = client.createEntry(mapFeed, authToken, entry);
String mapId = MapsClient.getMapIdFromMapEntryId(map.getId());
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,
final String trackDescription, final Location loc, final boolean isStart) {
return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() {
return wrapper.runQuery(new MapsGDataWrapper.QueryFunction() {
@Override
public void query(MapsClient client)
throws IOException, Exception {
@@ -165,34 +165,34 @@ public class MapsFacade {
String trackName, String trackDescription,
GeoPoint geoPoint,
boolean isStart) throws IOException, Exception {
MyMapsFeature feature =
buildMyMapsPlacemarkFeature(trackName, trackDescription, geoPoint, isStart);
MapsFeature feature =
buildMapsPlacemarkFeature(trackName, trackDescription, geoPoint, isStart);
Entry entry = gdataConverter.getEntryForFeature(feature);
Log.d(MyMapsConstants.TAG, "SendToMyMaps: Creating placemark "
Log.d(MapsConstants.TAG, "SendToMaps: Creating placemark "
+ entry.getTitle());
try {
client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG, "SendToMyMaps: createEntry success!");
Log.d(MapsConstants.TAG, "SendToMaps: createEntry success!");
} catch (IOException e) {
Log.w(MyMapsConstants.TAG,
"SendToMyMaps: createEntry 1st try failed. Trying again.");
Log.w(MapsConstants.TAG,
"SendToMaps: createEntry 1st try failed. Trying again.");
// Retry once (often IOException is thrown on a timeout):
client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG,
"SendToMyMaps: createEntry success on 2nd try!");
Log.d(MapsConstants.TAG,
"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 trackDescription the track description
* @param geoPoint the geo point
* @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,
GeoPoint geoPoint, boolean isStart) {
String iconUrl;
@@ -205,34 +205,34 @@ public class MapsFacade {
+ (isStart ? context.getString(R.string.marker_label_start)
: context.getString(R.string.marker_label_end));
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 description the description
* @param iconUrl the icon url
* @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) {
MyMapsFeature myMapsFeature = new MyMapsFeature();
myMapsFeature.generateAndroidId();
myMapsFeature.setType(MyMapsFeature.MARKER);
myMapsFeature.setIconUrl(iconUrl);
myMapsFeature.setDescription(description);
myMapsFeature.addPoint(geoPoint);
MapsFeature mapsFeature = new MapsFeature();
mapsFeature.generateAndroidId();
mapsFeature.setType(MapsFeature.MARKER);
mapsFeature.setIconUrl(iconUrl);
mapsFeature.setDescription(description);
mapsFeature.addPoint(geoPoint);
if (TextUtils.isEmpty(title)) {
// Features must have a name (otherwise GData upload may fail):
myMapsFeature.setTitle("-");
mapsFeature.setTitle("-");
} else {
myMapsFeature.setTitle(title);
mapsFeature.setTitle(title);
}
myMapsFeature.setDescription(description.replaceAll("\n", "<br>"));
return myMapsFeature;
mapsFeature.setDescription(description.replaceAll("\n", "<br>"));
return mapsFeature;
}
/**
@@ -244,7 +244,7 @@ public class MapsFacade {
*/
public boolean uploadWaypoints(
final String mapId, final Iterable<Waypoint> waypoints) {
return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() {
return wrapper.runQuery(new MapsGDataWrapper.QueryFunction() {
public void query(MapsClient client) {
// TODO(rdamazio): Stream through the waypoints in chunks.
// I am leaving the number of waypoints very high which should not be a
@@ -254,33 +254,33 @@ public class MapsFacade {
try {
for (Waypoint waypoint : waypoints) {
MyMapsFeature feature = buildMyMapsPlacemarkFeature(
MapsFeature feature = buildMapsPlacemarkFeature(
waypoint.getName(), waypoint.getDescription(), waypoint.getIcon(),
getGeoPoint(waypoint.getLocation()));
Entry entry = gdataConverter.getEntryForFeature(feature);
Log.d(MyMapsConstants.TAG,
"SendToMyMaps: Creating waypoint.");
Log.d(MapsConstants.TAG,
"SendToMaps: Creating waypoint.");
try {
client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG,
"SendToMyMaps: createEntry success!");
Log.d(MapsConstants.TAG,
"SendToMaps: createEntry success!");
} catch (IOException e) {
Log.w(MyMapsConstants.TAG,
"SendToMyMaps: createEntry 1st try failed. Retrying.");
Log.w(MapsConstants.TAG,
"SendToMaps: createEntry 1st try failed. Retrying.");
// Retry once (often IOException is thrown on a timeout):
client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG,
"SendToMyMaps: createEntry success on 2nd try!");
Log.d(MapsConstants.TAG,
"SendToMaps: createEntry success on 2nd try!");
}
}
} catch (ParseException e) {
Log.w(MyMapsConstants.TAG, "ParseException caught.", e);
Log.w(MapsConstants.TAG, "ParseException caught.", e);
} catch (HttpException e) {
Log.w(MyMapsConstants.TAG, "HttpException caught.", e);
Log.w(MapsConstants.TAG, "HttpException caught.", 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(
final String mapId, final String trackName, final Collection<Location> locations) {
return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() {
return wrapper.runQuery(new MapsGDataWrapper.QueryFunction() {
@Override
public void query(MapsClient client)
throws IOException, Exception {
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);
}
});
@@ -316,52 +316,52 @@ public class MapsFacade {
int numLocations = locations.size();
if (numLocations < 2) {
// 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;
}
// Put the line:
entry = gdataConverter.getEntryForFeature(
buildMyMapsLineFeature(trackName, locations));
Log.d(MyMapsConstants.TAG,
"SendToMyMaps: Creating line " + entry.getTitle());
buildMapsLineFeature(trackName, locations));
Log.d(MapsConstants.TAG,
"SendToMaps: Creating line " + entry.getTitle());
try {
client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG, "SendToMyMaps: createEntry success!");
Log.d(MapsConstants.TAG, "SendToMaps: createEntry success!");
} catch (IOException e) {
Log.w(MyMapsConstants.TAG,
"SendToMyMaps: createEntry 1st try failed. Trying again.");
Log.w(MapsConstants.TAG,
"SendToMaps: createEntry 1st try failed. Trying again.");
// Retry once (often IOException is thrown on a timeout):
client.createEntry(featureFeed, authToken, entry);
Log.d(MyMapsConstants.TAG,
"SendToMyMaps: createEntry success on 2nd try!");
Log.d(MapsConstants.TAG,
"SendToMaps: createEntry success on 2nd try!");
}
return true;
}
/**
* Builds a MyMapsFeature from a track.
* Builds a MapsFeature from a track.
*
* @param trackName the track name
* @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) {
MyMapsFeature myMapsFeature = new MyMapsFeature();
myMapsFeature.generateAndroidId();
myMapsFeature.setType(MyMapsFeature.LINE);
MapsFeature mapsFeature = new MapsFeature();
mapsFeature.generateAndroidId();
mapsFeature.setType(MapsFeature.LINE);
if (TextUtils.isEmpty(trackName)) {
// Features must have a name (otherwise GData upload may fail):
myMapsFeature.setTitle("-");
mapsFeature.setTitle("-");
} else {
myMapsFeature.setTitle(trackName);
mapsFeature.setTitle(trackName);
}
myMapsFeature.setColor(0x80FF0000);
mapsFeature.setColor(0x80FF0000);
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.
package com.google.android.apps.mytracks.io.mymaps;
package com.google.android.apps.mytracks.io.maps;
import com.google.android.maps.GeoPoint;
@@ -7,12 +7,12 @@ import java.util.Random;
import java.util.Vector;
/**
* MyMapsFeature contains all of the data associated with a feature in My Maps,
* where a feature is a marker, line, or shape. Some of the data is stored in a
* {@link MyMapsFeatureMetadata} object so that it can be more efficiently
* MapsFeature contains all of the data associated with a feature in Google
* Maps, where a feature is a marker, line, or shape. Some of the data is stored
* in a {@link MapsFeatureMetadata} object so that it can be more efficiently
* transmitted to other activities.
*/
class MyMapsFeature {
class MapsFeature {
private static final long serialVersionUID = 8439035544430497236L;
@@ -47,7 +47,7 @@ class MyMapsFeature {
private final Vector<Integer> longitudeE6 = new Vector<Integer>();
/** 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();
@@ -56,7 +56,7 @@ class MyMapsFeature {
* {@link #MARKER} with a blue placemark with a dot as an icon at the
* location (0, 0).
*/
public MyMapsFeature() {
public MapsFeature() {
}
/**
@@ -1,10 +1,10 @@
// 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.
*/
class MyMapsFeatureMetadata {
class MapsFeatureMetadata {
private static final String BLUE_DOT_URL =
"http://maps.google.com/mapfiles/ms/micons/blue-dot.png";
@@ -19,10 +19,10 @@ class MyMapsFeatureMetadata {
private int fillColor;
private String iconUrl;
public MyMapsFeatureMetadata() {
public MapsFeatureMetadata() {
title = "";
description = "";
type = MyMapsFeature.MARKER;
type = MapsFeature.MARKER;
color = DEFAULT_COLOR;
lineWidth = 5;
fillColor = DEFAULT_FILL_COLOR;
@@ -1,5 +1,5 @@
// 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.StringUtils;
@@ -7,27 +7,27 @@ import com.google.wireless.gdata.data.StringUtils;
import android.graphics.Color;
import android.util.Log;
import java.io.IOException;
import java.io.StringWriter;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
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;
public MyMapsGDataConverter() throws XmlPullParserException {
public MapsGDataConverter() throws XmlPullParserException {
xmlSerializer = XmlPullParserFactory.newInstance().newSerializer();
}
public static MyMapsMapMetadata getMapMetadataForEntry(
public static MapsMapMetadata getMapMetadataForEntry(
MapFeatureEntry entry) {
MyMapsMapMetadata metadata = new MyMapsMapMetadata();
MapsMapMetadata metadata = new MapsMapMetadata();
if ("public".equals(entry.getPrivacy())) {
metadata.setSearchable(true);
} else {
@@ -52,7 +52,7 @@ class MyMapsGDataConverter {
return MapsClient.getMapIdFromMapEntryId(entry.getId());
}
public static Entry getMapEntryForMetadata(MyMapsMapMetadata metadata) {
public static Entry getMapEntryForMetadata(MapsMapMetadata metadata) {
MapFeatureEntry entry = new MapFeatureEntry();
entry.setEditUri(metadata.getGDataEditUri());
entry.setTitle(metadata.getTitle());
@@ -63,7 +63,7 @@ class MyMapsGDataConverter {
return entry;
}
public MapFeatureEntry getEntryForFeature(MyMapsFeature feature) {
public MapFeatureEntry getEntryForFeature(MapsFeature feature) {
MapFeatureEntry entry = new MapFeatureEntry();
entry.setTitle(feature.getTitle());
entry.setAuthor("android");
@@ -80,7 +80,7 @@ class MyMapsGDataConverter {
xmlSerializer.startTag(null, "Placemark");
xmlSerializer.attribute(null, "xmlns", "http://earth.google.com/kml/2.2");
xmlSerializer.startTag(null, "Style");
if (feature.getType() == MyMapsFeature.MARKER) {
if (feature.getType() == MapsFeature.MARKER) {
xmlSerializer.startTag(null, "IconStyle");
xmlSerializer.startTag(null, "Icon");
xmlSerializer.startTag(null, "href");
@@ -102,7 +102,7 @@ class MyMapsGDataConverter {
xmlSerializer.endTag(null, "width");
xmlSerializer.endTag(null, "LineStyle");
if (feature.getType() == MyMapsFeature.SHAPE) {
if (feature.getType() == MapsFeature.SHAPE) {
xmlSerializer.startTag(null, "PolyStyle");
xmlSerializer.startTag(null, "color");
int fcolor = feature.getFillColor();
@@ -137,13 +137,13 @@ class MyMapsGDataConverter {
pointBuilder.append(",0.000000");
}
String pointString = pointBuilder.toString();
if (feature.getType() == MyMapsFeature.MARKER) {
if (feature.getType() == MapsFeature.MARKER) {
xmlSerializer.startTag(null, "Point");
xmlSerializer.startTag(null, "coordinates");
xmlSerializer.text(pointString);
xmlSerializer.endTag(null, "coordinates");
xmlSerializer.endTag(null, "Point");
} else if (feature.getType() == MyMapsFeature.LINE) {
} else if (feature.getType() == MapsFeature.LINE) {
xmlSerializer.startTag(null, "LineString");
xmlSerializer.startTag(null, "tessellate");
xmlSerializer.text("1");
@@ -1,5 +1,5 @@
// 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.AuthCallback;
@@ -17,12 +17,12 @@ import android.util.Log;
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
* error handling. After a query is run, the wrapper can be queried about the
* error that occurred.
*/
class MyMapsGDataWrapper {
class MapsGDataWrapper {
/**
* 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
@@ -67,7 +67,7 @@ class MyMapsGDataWrapper {
private int retriesPending;
private boolean cleanupCalled;
public MyMapsGDataWrapper(Context context, AuthManager auth) {
public MapsGDataWrapper(Context context, AuthManager auth) {
androidGdataClient = GDataClientFactory.getGDataClient(context);
this.auth = auth;
client =
@@ -92,11 +92,11 @@ class MyMapsGDataWrapper {
errorMessage = null;
return true;
} catch (AuthenticationException e) {
Log.e(MyMapsConstants.TAG, "Exception", e);
Log.e(MapsConstants.TAG, "Exception", e);
errorType = ERROR_AUTH;
errorMessage = e.getMessage();
} catch (HttpException e) {
Log.e(MyMapsConstants.TAG, "HttpException", e);
Log.e(MapsConstants.TAG, "HttpException", e);
errorMessage = e.getMessage();
if (errorMessage != null && errorMessage.contains("401")) {
errorType = ERROR_AUTH;
@@ -104,7 +104,7 @@ class MyMapsGDataWrapper {
errorType = ERROR_CONNECTION;
}
} catch (IOException e) {
Log.e(MyMapsConstants.TAG, "Exception", e);
Log.e(MapsConstants.TAG, "Exception", e);
errorMessage = e.getMessage();
if (errorMessage != null && errorMessage.contains("503")) {
errorType = ERROR_INTERNAL;
@@ -112,20 +112,20 @@ class MyMapsGDataWrapper {
errorType = ERROR_CONNECTION;
}
} catch (ParseException e) {
Log.e(MyMapsConstants.TAG, "Exception", e);
Log.e(MapsConstants.TAG, "Exception", e);
errorType = ERROR_LOCAL;
errorMessage = e.getMessage();
} catch (ConflictDetectedException e) {
Log.e(MyMapsConstants.TAG, "Exception", e);
Log.e(MapsConstants.TAG, "Exception", e);
errorType = ERROR_CONFLICT;
errorMessage = e.getMessage();
} catch (Exception e) {
Log.e(MyMapsConstants.TAG, "Exception", e);
Log.e(MapsConstants.TAG, "Exception", e);
errorType = ERROR_UNKNOWN;
errorMessage = e.getMessage();
e.printStackTrace();
}
Log.d(MyMapsConstants.TAG, "GData error encountered: " + errorMessage);
Log.d(MapsConstants.TAG, "GData error encountered: " + errorMessage);
if (errorType == ERROR_AUTH && auth != null) {
AuthCallback whenFinished = null;
if (retryOnAuthFailure) {
@@ -1,17 +1,17 @@
// 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 description;
private String gdataEditUri;
private boolean searchable;
public MyMapsMapMetadata() {
public MapsMapMetadata() {
title = "";
description = "";
gdataEditUri = "";
@@ -1,5 +1,5 @@
// 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.Feed;
@@ -1,5 +1,5 @@
// 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.data.Entry;
@@ -1,5 +1,5 @@
// 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.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.mytracks.AccountChooser;
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.content.MyTracksProviderUtils;
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.SendToFusionTables;
import com.google.android.apps.mytracks.io.SendToFusionTables.OnSendCompletedListener;
import com.google.android.apps.mytracks.io.SendToMyMaps;
import com.google.android.apps.mytracks.io.mymaps.MapsFacade;
import com.google.android.apps.mytracks.io.mymaps.MyMapsConstants;
import com.google.android.apps.mytracks.io.SendToMaps;
import com.google.android.apps.mytracks.io.maps.MapsConstants;
import com.google.android.apps.mytracks.io.maps.MapsFacade;
import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.apps.mytracks.util.UriUtils;
import com.google.android.maps.mytracks.R;
@@ -123,18 +123,18 @@ public class SendActivity extends Activity implements ProgressIndicator {
// Send request information.
private SendType sendType;
private long sendTrackId;
private boolean sendToMyMaps;
private boolean sendToMyMapsNewMap;
private boolean sendToMaps;
private boolean sendToMapsNewMap;
private boolean sendToFusionTables;
private boolean sendToDocs;
// Send result information, used by results dialog.
private boolean sendToMyMapsSuccess = false;
private boolean sendToMapsSuccess = false;
private boolean sendToFusionTablesSuccess = false;
private boolean sendToDocsSuccess = false;
// Send result information, used to share a link.
private String sendToMyMapsMapId;
private String sendToMapsMapId;
private String sendToFusionTablesTableId;
// Current sending state.
@@ -241,8 +241,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
dialog.dismiss();
sendToMyMaps = sendDialog.getSendToMyMaps();
sendToMyMapsNewMap = sendDialog.getCreateNewMap();
sendToMaps = sendDialog.getSendToMaps();
sendToMapsNewMap = sendDialog.getCreateNewMap();
sendToFusionTables = sendDialog.getSendToFusionTables();
sendToDocs = sendDialog.getSendToDocs();
@@ -256,15 +256,15 @@ public class SendActivity extends Activity implements ProgressIndicator {
private void restoreInstanceState(Bundle savedInstanceState) {
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);
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);
sendToDocsSuccess = savedInstanceState.getBoolean(STATE_DOCS_SUCCESS);
sendToMyMapsMapId = savedInstanceState.getString(STATE_MAP_ID);
sendToMapsMapId = savedInstanceState.getString(STATE_MAP_ID);
sendToFusionTablesTableId = savedInstanceState.getString(STATE_TABLE_ID);
lastAccountName = savedInstanceState.getString(STATE_ACCOUNT_NAME);
@@ -277,11 +277,11 @@ public class SendActivity extends Activity implements ProgressIndicator {
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_DOCS_SUCCESS, sendToDocsSuccess);
outState.putString(STATE_MAP_ID, sendToMyMapsMapId);
outState.putString(STATE_MAP_ID, sendToMapsMapId);
outState.putString(STATE_TABLE_ID, sendToFusionTablesTableId);
outState.putString(STATE_ACCOUNT_NAME, lastAccountName);
@@ -373,7 +373,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
private SendState startSend() {
showDialog(PROGRESS_DIALOG);
if (sendToMyMaps) {
if (sendToMaps) {
return SendState.AUTHENTICATE_MAPS;
} else if (sendToFusionTables) {
return SendState.AUTHENTICATE_FUSION_TABLES;
@@ -400,18 +400,18 @@ public class SendActivity extends Activity implements ProgressIndicator {
private SendState authenticateToGoogleMaps() {
Log.d(TAG, "SendActivity.authenticateToGoogleMaps");
progressDialog.setProgress(0);
progressDialog.setMessage(getAuthenticatingProgressMessage(SendType.MYMAPS));
authenticate(Constants.AUTHENTICATE_TO_MY_MAPS, MyMapsConstants.SERVICE_NAME);
// AUTHENTICATE_TO_MY_MAPS callback calls sendToGoogleMaps
progressDialog.setMessage(getAuthenticatingProgressMessage(SendType.MAPS));
authenticate(Constants.AUTHENTICATE_TO_MAPS, MapsConstants.SERVICE_NAME);
// AUTHENTICATE_TO_MAPS callback calls sendToGoogleMaps
return SendState.NOT_READY;
}
private SendState pickMap() {
if (!sendToMyMapsNewMap) {
if (!sendToMapsNewMap) {
// Ask the user to choose a map to upload into
Intent listIntent = new Intent(this, MyMapsList.class);
listIntent.putExtra(MyMapsList.EXTRA_ACCOUNT_NAME, lastAccountName);
listIntent.putExtra(MyMapsList.EXTRA_ACCOUNT_TYPE, lastAccountType);
Intent listIntent = new Intent(this, MapsList.class);
listIntent.putExtra(MapsList.EXTRA_ACCOUNT_NAME, lastAccountName);
listIntent.putExtra(MapsList.EXTRA_ACCOUNT_TYPE, lastAccountType);
startActivityForResult(listIntent, Constants.GET_MAP);
// The callback for GET_MAP calls authenticateToGoogleMaps
return SendState.NOT_READY;
@@ -423,12 +423,12 @@ public class SendActivity extends Activity implements ProgressIndicator {
private SendState sendToGoogleMaps() {
tracker.trackPageView("/send/maps");
SendToMyMaps.OnSendCompletedListener onCompletion = new SendToMyMaps.OnSendCompletedListener() {
SendToMaps.OnSendCompletedListener onCompletion = new SendToMaps.OnSendCompletedListener() {
@Override
public void onSendCompleted(String mapId, boolean success) {
sendToMyMapsSuccess = success;
if (sendToMyMapsSuccess) {
sendToMyMapsMapId = mapId;
sendToMapsSuccess = success;
if (sendToMapsSuccess) {
sendToMapsMapId = mapId;
// Update the map id for this track:
try {
Track track = providerUtils.getTrack(sendTrackId);
@@ -449,14 +449,14 @@ public class SendActivity extends Activity implements ProgressIndicator {
}
};
if (sendToMyMapsMapId == null) {
sendToMyMapsMapId = SendToMyMaps.NEW_MAP_ID;
if (sendToMapsMapId == null) {
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);
new Thread(sender, "SendToMyMaps").start();
new Thread(sender, "SendToMaps").start();
return SendState.NOT_READY;
}
@@ -611,7 +611,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
// sharing. We won't display a share button.
List<SendResult> results = makeSendToGoogleResults();
final boolean canShare = sendToFusionTablesTableId != null || sendToMyMapsMapId != null;
final boolean canShare = sendToFusionTablesTableId != null || sendToMapsMapId != null;
final OnClickListener finishListener = new DialogInterface.OnClickListener() {
@Override
@@ -654,9 +654,9 @@ public class SendActivity extends Activity implements ProgressIndicator {
private SendState shareLink() {
String url = null;
if (sendToMyMaps && sendToMyMapsSuccess) {
// Prefer a link to My Maps
url = MapsFacade.buildMapUrl(sendToMyMapsMapId);
if (sendToMaps && sendToMapsSuccess) {
// Prefer a link to Maps
url = MapsFacade.buildMapUrl(sendToMapsMapId);
} else if (sendToFusionTables && sendToFusionTablesSuccess) {
// Otherwise try using the link to fusion tables
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.
*/
private void shareLinkToMap(String url) {
@@ -702,8 +702,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
*/
private List<SendResult> makeSendToGoogleResults() {
List<SendResult> results = new ArrayList<SendResult>();
if (sendToMyMaps) {
results.add(new SendResult(SendType.MYMAPS, sendToMyMapsSuccess));
if (sendToMaps) {
results.add(new SendResult(SendType.MAPS, sendToMapsSuccess));
}
if (sendToFusionTables) {
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);
if (resultCode == RESULT_OK) {
if (results.hasExtra("mapid")) {
sendToMyMapsMapId = results.getStringExtra("mapid");
sendToMapsMapId = results.getStringExtra("mapid");
}
nextState = SendState.SEND_TO_MAPS;
} else {
@@ -829,8 +829,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
private void onLoginSuccess(int requestCode) {
SendState nextState;
switch (requestCode) {
case Constants.AUTHENTICATE_TO_MY_MAPS:
// Authenticated with Google My Maps
case Constants.AUTHENTICATE_TO_MAPS:
// Authenticated with Google Maps
nextState = SendState.PICK_MAP;
break;
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() {
currentState = SendState.SEND_OPTIONS;
sendToMyMapsMapId = null;
sendToMyMapsSuccess = true;
sendToMapsMapId = null;
sendToMapsSuccess = true;
sendToFusionTablesSuccess = true;
sendToDocsSuccess = true;
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);
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());
if (mapsEnabled && fusionTablesEnabled && docsEnabled) {
editor.putBoolean(
getContext().getString(R.string.send_to_my_maps_key), getSendToMyMaps());
getContext().getString(R.string.send_to_maps_key), getSendToMaps());
editor.putBoolean(
getContext().getString(R.string.send_to_fusion_tables_key), getSendToFusionTables());
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
* the sendType.
*/
if (sendType == SendType.MYMAPS) {
if (sendType == SendType.MAPS) {
mapsEnabled = true;
fusionTablesEnabled = false;
docsEnabled = false;
@@ -185,7 +185,7 @@ public class SendDialog extends Dialog {
existingMapRadioButton.setChecked(pickExistingMap);
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(
prefs.getBoolean(getContext().getString(R.string.send_to_fusion_tables_key), true));
docsCheckBox.setChecked(
@@ -197,8 +197,8 @@ public class SendDialog extends Dialog {
* Updates the UI display based on the current state.
*/
private void updateDisplay() {
send.setEnabled(getSendToMyMaps() || getSendToFusionTables() || getSendToDocs());
mapsOptionTableRow.setVisibility(getSendToMyMaps() ? View.VISIBLE : View.GONE);
send.setEnabled(getSendToMaps() || getSendToFusionTables() || getSendToDocs());
mapsOptionTableRow.setVisibility(getSendToMaps() ? View.VISIBLE : View.GONE);
}
public void setOnClickListener(OnClickListener clickListener) {
@@ -209,7 +209,7 @@ public class SendDialog extends Dialog {
return newMapRadioButton.isChecked();
}
public boolean getSendToMyMaps() {
public boolean getSendToMaps() {
return mapsEnabled && mapsCheckBox.isChecked();
}
@@ -26,8 +26,8 @@ import android.os.Parcelable;
* @author Matthew Simmons
*/
public enum SendType implements Parcelable {
MYMAPS(R.string.send_google_my_maps,
R.string.send_google_my_maps_url),
MAPS(R.string.send_google_maps,
R.string.send_google_maps_url),
FUSION_TABLES(R.string.send_google_fusion_tables,
R.string.send_google_fusion_tables_url),
DOCS(R.string.send_google_docs,
@@ -59,7 +59,7 @@ public class ResultDialogFactoryTest extends ActivityInstrumentationTestCase2<My
};
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));
AlertDialog dialog = ResultDialogFactory.makeDialog(
@@ -70,7 +70,7 @@ public class ResultDialogFactoryTest extends ActivityInstrumentationTestCase2<My
ListAdapter listAdapter = listView.getAdapter();
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());
// 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() {
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(
myTracks, results, clickListener, clickListener, null);
@@ -103,7 +103,7 @@ public class ResultDialogFactoryTest extends ActivityInstrumentationTestCase2<My
}
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));
AlertDialog dialog = ResultDialogFactory.makeDialog(
@@ -117,7 +117,7 @@ public class ResultDialogFactoryTest extends ActivityInstrumentationTestCase2<My
}
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));
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) {
LayoutInflater layoutInflater