packages/apps/Gallery2
修订版 | 376be105e4396612a28c8911ce98d823a328d407 (tree) |
---|---|
时间 | 2011-08-19 11:45:53 |
作者 | Ray Chen <raychen@goog...> |
Commiter | Ray Chen |
Fix 5179285 "Show on Map" intent for geotagged images mis-formatted in French
Change-Id: I4af6b549b534786163505d41b181888d347743d9
@@ -28,6 +28,7 @@ import com.android.gallery3d.common.Utils; | ||
28 | 28 | import com.android.gallery3d.data.MediaDetails; |
29 | 29 | import com.android.gallery3d.util.Future; |
30 | 30 | import com.android.gallery3d.util.FutureListener; |
31 | +import com.android.gallery3d.util.GalleryUtils; | |
31 | 32 | import com.android.gallery3d.util.ReverseGeocoder; |
32 | 33 | import com.android.gallery3d.util.ThreadPool.Job; |
33 | 34 | import com.android.gallery3d.util.ThreadPool.JobContext; |
@@ -310,7 +311,7 @@ public class DetailsWindow extends GLView { | ||
310 | 311 | } |
311 | 312 | |
312 | 313 | private String getLocationText(double[] latlng) { |
313 | - String text = String.format("(%f, %f)", latlng[0], latlng[1]); | |
314 | + String text = GalleryUtils.formatLatitudeLongitude("(%f,%f)", latlng[0], latlng[1]); | |
314 | 315 | mAddressLookupJob = mContext.getThreadPool().submit( |
315 | 316 | new AddressLookupJob(latlng), |
316 | 317 | new FutureListener<Address>() { |
@@ -43,6 +43,7 @@ import android.view.WindowManager; | ||
43 | 43 | |
44 | 44 | import java.util.Arrays; |
45 | 45 | import java.util.List; |
46 | +import java.util.Locale; | |
46 | 47 | |
47 | 48 | public class GalleryUtils { |
48 | 49 | private static final String TAG = "GalleryUtils"; |
@@ -206,13 +207,21 @@ public class GalleryUtils { | ||
206 | 207 | // TODO: change || to && after we fix the default location issue |
207 | 208 | return (latitude != MediaItem.INVALID_LATLNG || longitude != MediaItem.INVALID_LATLNG); |
208 | 209 | } |
210 | + | |
211 | + public static String formatLatitudeLongitude(String format, double latitude, | |
212 | + double longitude) { | |
213 | + // We need to specify the locale otherwise it may go wrong in some language | |
214 | + // (e.g. Locale.FRENCH) | |
215 | + return String.format(Locale.ENGLISH, format, latitude, longitude); | |
216 | + } | |
217 | + | |
209 | 218 | public static void showOnMap(Context context, double latitude, double longitude) { |
210 | 219 | try { |
211 | 220 | // We don't use "geo:latitude,longitude" because it only centers |
212 | 221 | // the MapView to the specified location, but we need a marker |
213 | 222 | // for further operations (routing to/from). |
214 | 223 | // The q=(lat, lng) syntax is suggested by geo-team. |
215 | - String uri = String.format("http://maps.google.com/maps?f=q&q=(%f,%f)", | |
224 | + String uri = formatLatitudeLongitude("http://maps.google.com/maps?f=q&q=(%f,%f)", | |
216 | 225 | latitude, longitude); |
217 | 226 | ComponentName compName = new ComponentName(MAPS_PACKAGE_NAME, |
218 | 227 | MAPS_CLASS_NAME); |
@@ -222,7 +231,7 @@ public class GalleryUtils { | ||
222 | 231 | } catch (ActivityNotFoundException e) { |
223 | 232 | // Use the "geo intent" if no GMM is installed |
224 | 233 | Log.e(TAG, "GMM activity not found!", e); |
225 | - String url = String.format("geo:%f,%f", latitude, longitude); | |
234 | + String url = formatLatitudeLongitude("geo:%f,%f", latitude, longitude); | |
226 | 235 | Intent mapsIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
227 | 236 | context.startActivity(mapsIntent); |
228 | 237 | } |