forked from upstream-mirrors/OpenTracks
Getting rid of the strings provider (we can now reference string resources again)
This commit is contained in:
@@ -2,13 +2,10 @@ package com.google.android.apps.mytracks.io;
|
|||||||
|
|
||||||
import com.google.android.apps.mytracks.io.gdata.GDataClientFactory;
|
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.MapsFacade;
|
||||||
import com.google.android.apps.mytracks.io.mymaps.MapsService;
|
|
||||||
import com.google.android.apps.mytracks.io.mymaps.MapsStringsProvider;
|
|
||||||
import com.google.android.apps.mytracks.io.mymaps.MapsFacade.AuthenticationRefresher;
|
import com.google.android.apps.mytracks.io.mymaps.MapsFacade.AuthenticationRefresher;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.apps.mytracks.io.mymaps.MapsService;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory to easily instantiate a {@link MapsFacade}.
|
* Factory to easily instantiate a {@link MapsFacade}.
|
||||||
@@ -17,32 +14,6 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class MyMapsFactory {
|
public class MyMapsFactory {
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple provider for reading strings from resources.
|
|
||||||
*/
|
|
||||||
private static class MyMapsStringProvider implements MapsStringsProvider {
|
|
||||||
private final Context context;
|
|
||||||
|
|
||||||
public MyMapsStringProvider(Context context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNewMapDescription() {
|
|
||||||
return context.getString(R.string.new_map_description);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getStart() {
|
|
||||||
return context.getString(R.string.start);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEnd() {
|
|
||||||
return context.getString(R.string.end);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Maps fa�ade interface instance.
|
* Creates a new Maps fa�ade interface instance.
|
||||||
*
|
*
|
||||||
@@ -53,7 +24,6 @@ public class MyMapsFactory {
|
|||||||
public static MapsFacade newMapsClient(Activity context, final AuthManager auth) {
|
public static MapsFacade newMapsClient(Activity context, final AuthManager auth) {
|
||||||
MapsFacade client = MapsService.newClient(context,
|
MapsFacade client = MapsService.newClient(context,
|
||||||
GDataClientFactory.getGDataClient(context),
|
GDataClientFactory.getGDataClient(context),
|
||||||
new MyMapsStringProvider(context),
|
|
||||||
auth.getAuthToken());
|
auth.getAuthToken());
|
||||||
client.setAuthenticationRefresher(new AuthenticationRefresher() {
|
client.setAuthenticationRefresher(new AuthenticationRefresher() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
package com.google.android.apps.mytracks.io.mymaps;
|
package com.google.android.apps.mytracks.io.mymaps;
|
||||||
|
|
||||||
import com.google.android.maps.GeoPoint;
|
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.GDataClient;
|
||||||
import com.google.wireless.gdata.client.HttpException;
|
import com.google.wireless.gdata.client.HttpException;
|
||||||
import com.google.wireless.gdata.data.Entry;
|
import com.google.wireless.gdata.data.Entry;
|
||||||
@@ -29,14 +30,14 @@ class MapsFacadeImpl implements MapsFacade {
|
|||||||
private static final String START_ICON_URL =
|
private static final String START_ICON_URL =
|
||||||
"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 MyMapsGDataWrapper wrapper;
|
private final MyMapsGDataWrapper wrapper;
|
||||||
private final MyMapsGDataConverter gdataConverter;
|
private final MyMapsGDataConverter gdataConverter;
|
||||||
private final MapsStringsProvider stringProvider;
|
|
||||||
private final String authToken;
|
private final String authToken;
|
||||||
|
|
||||||
public MapsFacadeImpl(Context context, GDataClient gdataClient,
|
public MapsFacadeImpl(Context context, GDataClient gdataClient,
|
||||||
MapsStringsProvider stringProvider, String authToken) {
|
String authToken) {
|
||||||
this.stringProvider = stringProvider;
|
this.context = context;
|
||||||
this.authToken = authToken;
|
this.authToken = authToken;
|
||||||
|
|
||||||
wrapper = new MyMapsGDataWrapper(context, gdataClient);
|
wrapper = new MyMapsGDataWrapper(context, gdataClient);
|
||||||
@@ -101,7 +102,7 @@ class MapsFacadeImpl implements MapsFacade {
|
|||||||
MyMapsMapMetadata metaData = new MyMapsMapMetadata();
|
MyMapsMapMetadata metaData = new MyMapsMapMetadata();
|
||||||
metaData.setTitle(title);
|
metaData.setTitle(title);
|
||||||
metaData.setDescription(description + " - "
|
metaData.setDescription(description + " - "
|
||||||
+ category + " - " + stringProvider.getNewMapDescription());
|
+ category + " - " + context.getString(R.string.new_map_description));
|
||||||
metaData.setSearchable(isPublic);
|
metaData.setSearchable(isPublic);
|
||||||
Entry entry = MyMapsGDataConverter.getMapEntryForMetadata(metaData);
|
Entry entry = MyMapsGDataConverter.getMapEntryForMetadata(metaData);
|
||||||
Log.d(MyMapsConstants.TAG, "Title: " + entry.getTitle());
|
Log.d(MyMapsConstants.TAG, "Title: " + entry.getTitle());
|
||||||
@@ -172,8 +173,8 @@ class MapsFacadeImpl implements MapsFacade {
|
|||||||
iconUrl = END_ICON_URL;
|
iconUrl = END_ICON_URL;
|
||||||
}
|
}
|
||||||
String title = trackName + " "
|
String title = trackName + " "
|
||||||
+ (isStart ? stringProvider.getStart()
|
+ (isStart ? context.getString(R.string.start)
|
||||||
: stringProvider.getEnd());
|
: context.getString(R.string.end));
|
||||||
String description = isStart ? "" : trackDescription;
|
String description = isStart ? "" : trackDescription;
|
||||||
return buildMyMapsPlacemarkFeature(title, description, iconUrl, geoPoint);
|
return buildMyMapsPlacemarkFeature(title, description, iconUrl, geoPoint);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,8 @@ public class MapsService {
|
|||||||
public static MapsFacade newClient(
|
public static MapsFacade newClient(
|
||||||
Activity context,
|
Activity context,
|
||||||
GDataClient gDataClient,
|
GDataClient gDataClient,
|
||||||
MapsStringsProvider stringProvider,
|
|
||||||
String authToken) {
|
String authToken) {
|
||||||
return new MapsFacadeImpl(context, gDataClient, stringProvider, authToken);
|
return new MapsFacadeImpl(context, gDataClient, authToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the service name to authenticate to for providing the authentication token above. */
|
/** Returns the service name to authenticate to for providing the authentication token above. */
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
|
||||||
package com.google.android.apps.mytracks.io.mymaps;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface to provide i18n'ed string resources to the Maps library.
|
|
||||||
*
|
|
||||||
* @author Rodrigo Damazio
|
|
||||||
*/
|
|
||||||
public interface MapsStringsProvider {
|
|
||||||
/** Returns the contents of R.string.new_map_description. */
|
|
||||||
String getNewMapDescription();
|
|
||||||
|
|
||||||
/** Returns the contents of R.string.start. */
|
|
||||||
String getStart();
|
|
||||||
|
|
||||||
/** Returns the contents of R.string.end. */
|
|
||||||
String getEnd();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user