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

Commit fbfa7336 authored by Chih-Chung Chang's avatar Chih-Chung Chang Committed by Android Git Automerger
Browse files

am bd47a5c6: Fix 5352588: Accept view intent without URI.

* commit 'bd47a5c6':
  Fix 5352588: Accept view intent without URI.
parents 2a622069 bd47a5c6
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -152,7 +152,14 @@ public final class Gallery extends AbstractGalleryActivity {
                finish();
                return;
            }
            if (contentType.startsWith(
            if (uri == null) {
                int typeBits = GalleryUtils.determineTypeBits(this, intent);
                data.putInt(KEY_TYPE_BITS, typeBits);
                data.putString(AlbumSetPage.KEY_MEDIA_PATH,
                        getDataManager().getTopSetPath(typeBits));
                getStateManager().setLaunchGalleryOnTop(true);
                getStateManager().startState(AlbumSetPage.class, data);
            } else if (contentType.startsWith(
                    ContentResolver.CURSOR_DIR_BASE_TYPE)) {
                int mediaType = intent.getIntExtra(KEY_MEDIA_TYPES, 0);
                if (mediaType != 0) {
@@ -160,11 +167,19 @@ public final class Gallery extends AbstractGalleryActivity {
                            KEY_MEDIA_TYPES, String.valueOf(mediaType))
                            .build();
                }
                Path albumPath = dm.findPathByUri(uri);
                if (albumPath != null) {
                    MediaSet mediaSet = (MediaSet) dm.getMediaObject(albumPath);
                    data.putString(AlbumPage.KEY_MEDIA_PATH, albumPath.toString());
                Path setPath = dm.findPathByUri(uri);
                MediaSet mediaSet = null;
                if (setPath != null) {
                    mediaSet = (MediaSet) dm.getMediaObject(setPath);
                }
                if (mediaSet != null) {
                    if (mediaSet.isLeafAlbum()) {
                        data.putString(AlbumPage.KEY_MEDIA_PATH, setPath.toString());
                        getStateManager().startState(AlbumPage.class, data);
                    } else {
                        data.putString(AlbumSetPage.KEY_MEDIA_PATH, setPath.toString());
                        getStateManager().startState(AlbumSetPage.class, data);
                    }
                } else {
                    startDefaultPage();
                }
+16 −16
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ public class GalleryUtils {
    private static final String MIME_TYPE_IMAGE = "image/*";
    private static final String MIME_TYPE_VIDEO = "video/*";
    private static final String MIME_TYPE_ALL = "*/*";
    private static final String DIR_TYPE_IMAGE = "vnd.android.cursor.dir/image";
    private static final String DIR_TYPE_VIDEO = "vnd.android.cursor.dir/video";

    private static final String PREFIX_PHOTO_EDITOR_UPDATE = "editor-update-";
    private static final String PREFIX_HAS_PHOTO_EDITOR = "has-editor-";
@@ -277,24 +279,22 @@ public class GalleryUtils {
    public static int determineTypeBits(Context context, Intent intent) {
        int typeBits = 0;
        String type = intent.resolveType(context);
        if (intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false)) {
            if (MIME_TYPE_ALL.equals(type)) {
                typeBits = DataManager.INCLUDE_LOCAL_ALL_ONLY;
            } else if (MIME_TYPE_IMAGE.equals(type)) {
                typeBits = DataManager.INCLUDE_LOCAL_IMAGE_ONLY;
            } else if (MIME_TYPE_VIDEO.equals(type)) {
                typeBits = DataManager.INCLUDE_LOCAL_VIDEO_ONLY;
            }
        } else {

        if (MIME_TYPE_ALL.equals(type)) {
            typeBits = DataManager.INCLUDE_ALL;
            } else if (MIME_TYPE_IMAGE.equals(type)) {
        } else if (MIME_TYPE_IMAGE.equals(type) ||
                DIR_TYPE_IMAGE.equals(type)) {
            typeBits = DataManager.INCLUDE_IMAGE;
            } else if (MIME_TYPE_VIDEO.equals(type)) {
        } else if (MIME_TYPE_VIDEO.equals(type) ||
                DIR_TYPE_VIDEO.equals(type)) {
            typeBits = DataManager.INCLUDE_VIDEO;
        } else {
            typeBits = DataManager.INCLUDE_ALL;
        }

        if (intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false)) {
            typeBits |= DataManager.INCLUDE_LOCAL_ONLY;
        }
        if (typeBits == 0) typeBits = DataManager.INCLUDE_ALL;

        return typeBits;
    }