From 376be105e4396612a28c8911ce98d823a328d407 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Fri, 19 Aug 2011 10:45:53 +0800 Subject: [PATCH] Fix 5179285 "Show on Map" intent for geotagged images mis-formatted in French Change-Id: I4af6b549b534786163505d41b181888d347743d9 --- src/com/android/gallery3d/ui/DetailsWindow.java | 3 ++- src/com/android/gallery3d/util/GalleryUtils.java | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/com/android/gallery3d/ui/DetailsWindow.java b/src/com/android/gallery3d/ui/DetailsWindow.java index 03e216922..760b73a91 100644 --- a/src/com/android/gallery3d/ui/DetailsWindow.java +++ b/src/com/android/gallery3d/ui/DetailsWindow.java @@ -28,6 +28,7 @@ import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.MediaDetails; import com.android.gallery3d.util.Future; import com.android.gallery3d.util.FutureListener; +import com.android.gallery3d.util.GalleryUtils; import com.android.gallery3d.util.ReverseGeocoder; import com.android.gallery3d.util.ThreadPool.Job; import com.android.gallery3d.util.ThreadPool.JobContext; @@ -310,7 +311,7 @@ public class DetailsWindow extends GLView { } private String getLocationText(double[] latlng) { - String text = String.format("(%f, %f)", latlng[0], latlng[1]); + String text = GalleryUtils.formatLatitudeLongitude("(%f,%f)", latlng[0], latlng[1]); mAddressLookupJob = mContext.getThreadPool().submit( new AddressLookupJob(latlng), new FutureListener
() { diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java index 2fed46a22..47beb2d09 100644 --- a/src/com/android/gallery3d/util/GalleryUtils.java +++ b/src/com/android/gallery3d/util/GalleryUtils.java @@ -43,6 +43,7 @@ import android.view.WindowManager; import java.util.Arrays; import java.util.List; +import java.util.Locale; public class GalleryUtils { private static final String TAG = "GalleryUtils"; @@ -206,13 +207,21 @@ public class GalleryUtils { // TODO: change || to && after we fix the default location issue return (latitude != MediaItem.INVALID_LATLNG || longitude != MediaItem.INVALID_LATLNG); } + + public static String formatLatitudeLongitude(String format, double latitude, + double longitude) { + // We need to specify the locale otherwise it may go wrong in some language + // (e.g. Locale.FRENCH) + return String.format(Locale.ENGLISH, format, latitude, longitude); + } + public static void showOnMap(Context context, double latitude, double longitude) { try { // We don't use "geo:latitude,longitude" because it only centers // the MapView to the specified location, but we need a marker // for further operations (routing to/from). // The q=(lat, lng) syntax is suggested by geo-team. - String uri = String.format("http://maps.google.com/maps?f=q&q=(%f,%f)", + String uri = formatLatitudeLongitude("http://maps.google.com/maps?f=q&q=(%f,%f)", latitude, longitude); ComponentName compName = new ComponentName(MAPS_PACKAGE_NAME, MAPS_CLASS_NAME); @@ -222,7 +231,7 @@ public class GalleryUtils { } catch (ActivityNotFoundException e) { // Use the "geo intent" if no GMM is installed Log.e(TAG, "GMM activity not found!", e); - String url = String.format("geo:%f,%f", latitude, longitude); + String url = formatLatitudeLongitude("geo:%f,%f", latitude, longitude); Intent mapsIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); context.startActivity(mapsIntent); } -- 2.11.0