summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-08-31 20:30:08 +0200
committerJorge Ruesga <jorge@ruesga.com>2013-08-31 20:30:08 +0200
commitca78969f3612f2898188b8eb9d2895e1e2285a74 (patch)
treeb7e82f5a5812f9e7d17479e28f0054c63d1b9605
parent3c851e871703761ccbda03ddfe0bd94605af286f (diff)
downloadandroid_packages_apps_Gallery2-ca78969f3612f2898188b8eb9d2895e1e2285a74.tar.gz
android_packages_apps_Gallery2-ca78969f3612f2898188b8eb9d2895e1e2285a74.tar.bz2
android_packages_apps_Gallery2-ca78969f3612f2898188b8eb9d2895e1e2285a74.zip
Gallery: Prevent display "Show on map" menu if no geo view is present
Change-Id: I8520bd227295eaa77fd8d63dbd9b5758dbd7bf01 JIRA: CYAN-2005 Issue: https://jira.cyanogenmod.org/browse/CYAN-2005 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java2
-rw-r--r--src/com/android/gallery3d/ui/ActionModeHandler.java3
-rw-r--r--src/com/android/gallery3d/ui/MenuExecutor.java5
-rw-r--r--src/com/android/gallery3d/util/GalleryUtils.java27
4 files changed, 33 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 506d1ca6f..37d2f9e53 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -789,7 +789,7 @@ public class PhotoPage extends ActivityState implements
} else if (!mHaveImageEditor) {
supportedOperations &= ~MediaObject.SUPPORT_EDIT;
}
- MenuExecutor.updateMenuOperation(menu, supportedOperations);
+ MenuExecutor.updateMenuOperation(mActivity.getAndroidContext(), menu, supportedOperations);
mCurrentPhoto.getPanoramaSupport(mUpdatePanoramaMenuItemsCallback);
}
diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java
index 7191599ad..f66ab7167 100644
--- a/src/com/android/gallery3d/ui/ActionModeHandler.java
+++ b/src/com/android/gallery3d/ui/ActionModeHandler.java
@@ -430,7 +430,8 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
public void run() {
mMenuTask = null;
if (jc.isCancelled()) return;
- MenuExecutor.updateMenuOperation(mMenu, operation);
+ MenuExecutor.updateMenuOperation(
+ mActivity.getAndroidContext(), mMenu, operation);
MenuExecutor.updateMenuForPanorama(mMenu, supportCallback.mAllPanorama360,
supportCallback.mHasPanorama360);
if (mSharePanoramaMenuItem != null) {
diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java
index 4285f449e..3dfd7ee51 100644
--- a/src/com/android/gallery3d/ui/MenuExecutor.java
+++ b/src/com/android/gallery3d/ui/MenuExecutor.java
@@ -156,14 +156,15 @@ public class MenuExecutor {
mHandler.sendMessage(mHandler.obtainMessage(MSG_TASK_COMPLETE, result, 0, listener));
}
- public static void updateMenuOperation(Menu menu, int supported) {
+ public static void updateMenuOperation(Context context, Menu menu, int supported) {
boolean supportDelete = (supported & MediaObject.SUPPORT_DELETE) != 0;
boolean supportRotate = (supported & MediaObject.SUPPORT_ROTATE) != 0;
boolean supportCrop = (supported & MediaObject.SUPPORT_CROP) != 0;
boolean supportTrim = (supported & MediaObject.SUPPORT_TRIM) != 0;
boolean supportShare = (supported & MediaObject.SUPPORT_SHARE) != 0;
boolean supportSetAs = (supported & MediaObject.SUPPORT_SETAS) != 0;
- boolean supportShowOnMap = (supported & MediaObject.SUPPORT_SHOW_ON_MAP) != 0;
+ boolean supportShowOnMap = (supported & MediaObject.SUPPORT_SHOW_ON_MAP) != 0 &
+ GalleryUtils.isGeolocationViewAvailable(context);
boolean supportCache = (supported & MediaObject.SUPPORT_CACHE) != 0;
boolean supportEdit = (supported & MediaObject.SUPPORT_EDIT) != 0;
boolean supportInfo = (supported & MediaObject.SUPPORT_INFO) != 0;
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index 547e2dda0..c0db5e81a 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -297,6 +297,33 @@ public class GalleryUtils {
}
}
+ public static boolean isGeolocationViewAvailable(Context context) {
+ // 1.- GMM with MapView
+ ComponentName gmmCompName = new ComponentName(MAPS_PACKAGE_NAME, MAPS_CLASS_NAME);
+ String gmmUri = formatLatitudeLongitude("http://maps.google.com/maps?f=q&q=(%f,%f)",
+ 0.0d, 0.0d);
+ Intent gmmIntent = new Intent();
+ gmmIntent.setComponent(gmmCompName);
+ gmmIntent.setData(Uri.parse(gmmUri));
+ gmmIntent.setAction(Intent.ACTION_VIEW);
+
+ // 2.- Geolocation content provider
+ String geoUri = formatLatitudeLongitude("geo:%f,%f", 0.0d, 0.0d);
+ Intent geoIntent = new Intent();
+ geoIntent.setData(Uri.parse(geoUri));
+ geoIntent.setAction(Intent.ACTION_VIEW);
+
+ // Should be one of: gmm or geo content provider
+ return isIntentResolved(context, gmmIntent) || isIntentResolved(context, geoIntent);
+ }
+
+ private static boolean isIntentResolved(Context context, Intent intent) {
+ final PackageManager pckMgr = context.getPackageManager();
+ List<ResolveInfo> infos = pckMgr.queryIntentActivities (intent,
+ PackageManager.GET_RESOLVED_FILTER);
+ return infos != null && infos.size() > 0;
+ }
+
public static void setViewPointMatrix(
float matrix[], float x, float y, float z) {
// The matrix is