Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca78969f authored by Jorge Ruesga's avatar Jorge Ruesga
Browse files

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: default avatarJorge Ruesga <jorge@ruesga.com>
parent 3c851e87
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
    }

+2 −1
Original line number Diff line number Diff line
@@ -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) {
+3 −2
Original line number Diff line number Diff line
@@ -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;
+27 −0
Original line number Diff line number Diff line
@@ -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