From 52083a2fcca3007ddde51ccd166d602d95583bee Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Fri, 27 Apr 2012 16:11:58 +0800 Subject: Fix photo rotates incorrectly in crop image. bug:6399424 Change-Id: Icc0aca5e9abcd643f8e246211e37bd177bf8ff31 --- src/com/android/gallery3d/data/UriSource.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/com/android/gallery3d/data/UriSource.java') diff --git a/src/com/android/gallery3d/data/UriSource.java b/src/com/android/gallery3d/data/UriSource.java index 76f7ac0e5..d37c51d13 100644 --- a/src/com/android/gallery3d/data/UriSource.java +++ b/src/com/android/gallery3d/data/UriSource.java @@ -28,6 +28,8 @@ import java.net.URLEncoder; class UriSource extends MediaSource { @SuppressWarnings("unused") private static final String TAG = "UriSource"; + private static final String IMAGE_TYPE_PREFIX = "image/"; + private static final String IMAGE_TYPE_ANY = "image/*"; private GalleryApp mApplication; @@ -64,11 +66,19 @@ class UriSource extends MediaSource { @Override public Path findPathByUri(Uri uri, String type) { - if (type == null) type = getMimeType(uri); - if (type.startsWith("image/")) { + String mimeType = getMimeType(uri); + + // Try to find a most specific type but it has to be started with "image/" + if ((type == null) || (IMAGE_TYPE_ANY.equals(type) + && mimeType.startsWith(IMAGE_TYPE_PREFIX))) { + type = mimeType; + } + + if (type.startsWith(IMAGE_TYPE_PREFIX)) { return Path.fromString("/uri/" + URLEncoder.encode(uri.toString()) + "/" +URLEncoder.encode(type)); } + // We have no clues that it is an image return null; } } -- cgit v1.2.3