OSDN Git Service

Fix 5179285 "Show on Map" intent for geotagged images mis-formatted in French
authorRay Chen <raychen@google.com>
Fri, 19 Aug 2011 02:45:53 +0000 (10:45 +0800)
committerRay Chen <raychen@google.com>
Fri, 19 Aug 2011 02:45:53 +0000 (10:45 +0800)
Change-Id: I4af6b549b534786163505d41b181888d347743d9

src/com/android/gallery3d/ui/DetailsWindow.java
src/com/android/gallery3d/util/GalleryUtils.java

index 03e2169..760b73a 100644 (file)
@@ -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<Address>() {
index 2fed46a..47beb2d 100644 (file)
@@ -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);
         }