diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyMapsList.java b/MyTracks/src/com/google/android/apps/mytracks/MyMapsList.java index 949c90026..bcdbe11f8 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyMapsList.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyMapsList.java @@ -18,9 +18,9 @@ package com.google.android.apps.mytracks; import com.google.android.accounts.Account; import com.google.android.apps.mytracks.io.AuthManager; import com.google.android.apps.mytracks.io.AuthManagerFactory; -import com.google.android.apps.mytracks.io.MyMapsFactory; import com.google.android.apps.mytracks.io.mymaps.MapsFacade; -import com.google.android.apps.mytracks.io.mymaps.MapsService; +import com.google.android.apps.mytracks.io.mymaps.MapsFacadeImpl; +import com.google.android.apps.mytracks.io.mymaps.MyMapsConstants; import com.google.android.maps.mytracks.R; import android.app.Activity; @@ -84,7 +84,7 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback super.onCreate(icicle); auth = AuthManagerFactory.getAuthManager(this, GET_LOGIN, null, true, - MapsService.getServiceName()); + MyMapsConstants.SERVICE_NAME); setContentView(R.layout.list); @@ -125,7 +125,7 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback auth.doLogin(new Runnable() { public void run() { // Runs in UI thread. - mapsClient = MyMapsFactory.newMapsClient(MyMapsList.this, auth); + mapsClient = new MapsFacadeImpl(MyMapsList.this, auth); startLookup(); } @@ -200,7 +200,7 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback shareIntent.putExtra(Intent.EXTRA_TEXT, String.format( getText(R.string.share_map_body_format).toString(), listItem[1], - MapsService.buildMapUrl(listItem[0]))); + MapsFacadeImpl.buildMapUrl(listItem[0]))); startActivity(Intent.createChooser(shareIntent, getText(R.string.share_map).toString())); return true; diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java index f964f2fc0..3050efd94 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java @@ -35,7 +35,8 @@ import com.google.android.apps.mytracks.io.TempFileCleaner; import com.google.android.apps.mytracks.io.TrackWriter; import com.google.android.apps.mytracks.io.TrackWriterFactory; import com.google.android.apps.mytracks.io.TrackWriterFactory.TrackFileFormat; -import com.google.android.apps.mytracks.io.mymaps.MapsService; +import com.google.android.apps.mytracks.io.mymaps.MapsFacadeImpl; +import com.google.android.apps.mytracks.io.mymaps.MyMapsConstants; import com.google.android.apps.mytracks.io.sendtogoogle.ResultDialogFactory; import com.google.android.apps.mytracks.io.sendtogoogle.SendDialog; import com.google.android.apps.mytracks.io.sendtogoogle.SendResult; @@ -606,7 +607,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, Track selectedTrack = providerUtils.getTrack(selectedTrackId); if (selectedTrack != null) { if (!TextUtils.isEmpty(selectedTrack.getMapId())) { - shareLinkToMap(MapsService.buildMapUrl(selectedTrack.getMapId())); + shareLinkToMap(MapsFacadeImpl.buildMapUrl(selectedTrack.getMapId())); } else if (!TextUtils.isEmpty(selectedTrack.getTableId())) { shareLinkToMap(getFusionTablesUrl(selectedTrackId)); } else { @@ -1028,7 +1029,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, setProgressMessage( R.string.progress_message_authenticating_mymaps); authenticate(results, MyTracksConstants.AUTHENTICATE_TO_MY_MAPS, - MapsService.getServiceName()); + MyMapsConstants.SERVICE_NAME); // AUTHENTICATE_TO_MY_MAPS callback calls sendToGoogleMaps } @@ -1225,7 +1226,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, String url = null; if (sentToMyMaps && sendToMyMapsSuccess) { // Prefer a link to My Maps - url = MapsService.buildMapUrl(sendToMyMapsMapId); + url = MapsFacadeImpl.buildMapUrl(sendToMyMapsMapId); } else if (sentToFusionTables && sendToFusionTablesSuccess) { // Otherwise try using the link to fusion tables url = getFusionTablesUrl(sendToTrackId); diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/MyMapsFactory.java b/MyTracks/src/com/google/android/apps/mytracks/io/MyMapsFactory.java deleted file mode 100644 index 5bbce5a50..000000000 --- a/MyTracks/src/com/google/android/apps/mytracks/io/MyMapsFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.google.android.apps.mytracks.io; - -import com.google.android.apps.mytracks.io.gdata.GDataClientFactory; -import com.google.android.apps.mytracks.io.mymaps.MapsFacade; -import com.google.android.apps.mytracks.io.mymaps.MapsService; - -import android.app.Activity; - -/** - * Factory to easily instantiate a {@link MapsFacade}. - * - * @author Rodrigo Damazio - */ -public class MyMapsFactory { - - /** - * Creates a new Maps faŤade interface instance. - * - * @param context current context - * @param auth a valid authentication manager - * @return the faŤade - */ - public static MapsFacade newMapsClient(Activity context, final AuthManager auth) { - MapsFacade client = MapsService.newClient(context, - GDataClientFactory.getGDataClient(context), - auth); - return client; - } - - private MyMapsFactory() {} -} diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/SendToMyMaps.java b/MyTracks/src/com/google/android/apps/mytracks/io/SendToMyMaps.java index 542606426..bff49362a 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/SendToMyMaps.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/SendToMyMaps.java @@ -23,6 +23,7 @@ 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.mymaps.MapsFacade.WaypointData; +import com.google.android.apps.mytracks.io.mymaps.MapsFacadeImpl; import com.google.android.apps.mytracks.stats.DoubleBuffer; import com.google.android.apps.mytracks.stats.TripStatistics; import com.google.android.apps.mytracks.util.MyTracksUtils; @@ -111,7 +112,7 @@ public class SendToMyMaps implements Runnable { track.setDescription("
" + track.getDescription() + "
" + stringUtils.generateTrackDescription(track, null, null) + "
"); - mapsClient = MyMapsFactory.newMapsClient(context, auth); + mapsClient = new MapsFacadeImpl(context, auth); // Create a new map if necessary: boolean isNewMap = mapId.equals(NEW_MAP_ID); diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsClient.java b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsClient.java index bb58c41bf..7d1194b8c 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsClient.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsClient.java @@ -36,6 +36,10 @@ class MapsClient extends GDataServiceClient { return MyMapsConstants.SERVICE_NAME; } + public static String buildMapUrl(String mapId) { + return MyMapsConstants.MAPSHOP_BASE_URL + "?msa=0&msid=" + mapId; + } + public static String getMapsFeed() { if (DEBUG) { Log.d("Maps Client", "Requesting map feed:"); diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsFacadeImpl.java b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsFacadeImpl.java index 2b8007c34..aeb65ea2d 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsFacadeImpl.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsFacadeImpl.java @@ -4,7 +4,6 @@ package com.google.android.apps.mytracks.io.mymaps; import com.google.android.apps.mytracks.io.AuthManager; import com.google.android.maps.GeoPoint; import com.google.android.maps.mytracks.R; -import com.google.wireless.gdata.client.GDataClient; import com.google.wireless.gdata.client.HttpException; import com.google.wireless.gdata.data.Entry; import com.google.wireless.gdata.parser.GDataParser; @@ -15,17 +14,17 @@ import android.location.Location; import android.text.TextUtils; import android.util.Log; -import org.xmlpull.v1.XmlPullParserException; - import java.io.IOException; import java.util.Collection; +import org.xmlpull.v1.XmlPullParserException; + /** * Implementation of the Maps access abstraction. * * @author Rodrigo Damazio */ -class MapsFacadeImpl implements MapsFacade { +public class MapsFacadeImpl implements MapsFacade { private static final String END_ICON_URL = "http://maps.google.com/mapfiles/ms/micons/red-dot.png"; private static final String START_ICON_URL = @@ -36,12 +35,11 @@ class MapsFacadeImpl implements MapsFacade { private final MyMapsGDataConverter gdataConverter; private final String authToken; - public MapsFacadeImpl(Context context, GDataClient gdataClient, - AuthManager auth) { + public MapsFacadeImpl(Context context, AuthManager auth) { this.context = context; this.authToken = auth.getAuthToken(); - wrapper = new MyMapsGDataWrapper(context, gdataClient, auth); + wrapper = new MyMapsGDataWrapper(context, auth); wrapper.setRetryOnAuthFailure(true); try { @@ -51,6 +49,10 @@ class MapsFacadeImpl implements MapsFacade { } } + public static String buildMapUrl(String mapId) { + return MapsClient.buildMapUrl(mapId); + } + @Override public boolean getMapsList(final MapsListCallback callback) { return wrapper.runQuery(new MyMapsGDataWrapper.QueryFunction() { diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsService.java b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsService.java deleted file mode 100644 index 713abda59..000000000 --- a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsService.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2011 Google Inc. All Rights Reserved. -package com.google.android.apps.mytracks.io.mymaps; - -import com.google.android.apps.mytracks.io.AuthManager; -import com.google.wireless.gdata.client.GDataClient; - -import android.app.Activity; - -/** - * Entry point for the maps service library. - * - * @author Rodrigo Damazio - */ -public class MapsService { - private MapsService() {} - - /** - * Creates a new faŤade to access Google Maps. - * - * @param context current context - * @param gDataClient GData client to use for access - * @param stringProvider interface to provide i18n'ed resources - * @param authToken the authentication token to access the service with - * @return the service faŤade - */ - public static MapsFacade newClient( - Activity context, - GDataClient gDataClient, - AuthManager auth) { - return new MapsFacadeImpl(context, gDataClient, auth); - } - - /** Returns the service name to authenticate to for providing the authentication token above. */ - public static String getServiceName() { - return MyMapsConstants.SERVICE_NAME; - } - - /** Builds and returns the user-visible URL for a map given its map ID. */ - public static String buildMapUrl(String mapId) { - return MyMapsConstants.MAPSHOP_BASE_URL + "?msa=0&msid=" + mapId; - } -} diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MyMapsConstants.java b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MyMapsConstants.java index 51ffe0bc4..77cb3a330 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MyMapsConstants.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MyMapsConstants.java @@ -4,9 +4,9 @@ package com.google.android.apps.mytracks.io.mymaps; /** * Constants for My Maps. */ -class MyMapsConstants { - public static final String TAG = "MapsApi"; - public static final String MAPSHOP_BASE_URL = +public class MyMapsConstants { + static final String TAG = "MapsApi"; + static final String MAPSHOP_BASE_URL = "http://maps.google.com/maps/ms"; public static final String SERVICE_NAME = "local"; diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MyMapsGDataWrapper.java b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MyMapsGDataWrapper.java index 01576f05e..3e5cb9c3f 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MyMapsGDataWrapper.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MyMapsGDataWrapper.java @@ -2,6 +2,7 @@ package com.google.android.apps.mytracks.io.mymaps; import com.google.android.apps.mytracks.io.AuthManager; +import com.google.android.apps.mytracks.io.gdata.GDataClientFactory; import com.google.android.common.gdata.AndroidXmlParserFactory; import com.google.wireless.gdata.client.GDataClient; import com.google.wireless.gdata.client.HttpException; @@ -65,8 +66,8 @@ class MyMapsGDataWrapper { private int retriesPending; private boolean cleanupCalled; - public MyMapsGDataWrapper(Context context, GDataClient gdataClient, AuthManager auth) { - androidGdataClient = gdataClient; + public MyMapsGDataWrapper(Context context, AuthManager auth) { + androidGdataClient = GDataClientFactory.getGDataClient(context); this.auth = auth; client = new MapsClient(androidGdataClient, new XmlMapsGDataParserFactory(