Commit f8a39c64 authored by George Mount's avatar George Mount Committed by Android (Google) Code Review
Browse files

Add UriImage support for viewing LightCycle panoramas.

Change-Id: I7f61cef39370fd23b9481708dc3c902c17873074
parent 17ac550d
......@@ -37,7 +37,6 @@ import com.android.gallery3d.ui.SynchronizedHandler;
import com.android.gallery3d.ui.TileImageViewAdapter;
import com.android.gallery3d.util.Future;
import com.android.gallery3d.util.FutureListener;
import com.android.gallery3d.util.LightCycleHelper;
import com.android.gallery3d.util.MediaSetUtils;
import com.android.gallery3d.util.ThreadPool;
import com.android.gallery3d.util.ThreadPool.Job;
......@@ -482,7 +481,7 @@ public class PhotoDataAdapter implements PhotoPage.Model {
MediaItem item = getItem(mCurrentIndex + offset);
boolean usePanoramaViewer = false;
if (item != null) {
usePanoramaViewer = LightCycleHelper.isPanorama(item.getFilePath());
usePanoramaViewer = item.usePanoramaViewer();
}
return usePanoramaViewer;
}
......
......@@ -45,7 +45,6 @@ import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.FilterDeleteSet;
import com.android.gallery3d.data.LocalImage;
import com.android.gallery3d.data.MediaDetails;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
......@@ -887,8 +886,7 @@ public class PhotoPage extends ActivityState implements
if (playVideo) {
playVideo(mActivity, item.getPlayUri(), item.getName());
} else if (viewPanorama) {
LocalImage img = (LocalImage) item;
LightCycleHelper.viewPanorama(mActivity, img.getFilePath());
LightCycleHelper.viewPanorama(mActivity, item.getContentUri());
} else {
toggleBars();
}
......
......@@ -218,7 +218,7 @@ public class SinglePhotoDataAdapter extends TileImageViewAdapter
@Override
public boolean usePanoramaViewer(int offset) {
return LightCycleHelper.isPanorama(mItem.getFilePath());
return mItem.usePanoramaViewer();
}
@Override
......
......@@ -19,6 +19,7 @@ package com.android.gallery3d.data;
import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
......@@ -99,6 +100,9 @@ public class LocalImage extends LocalMediaItem {
public int rotation;
private boolean mUsePanoramaViewer;
private boolean mUsePanoramaViewerInitialized;
public LocalImage(Path path, GalleryApp application, Cursor cursor) {
super(path, nextVersionNumber());
mApplication = application;
......@@ -241,9 +245,7 @@ public class LocalImage extends LocalMediaItem {
operation |= SUPPORT_SHOW_ON_MAP;
}
if (LightCycleHelper.isPanorama(filePath) &&
LightCycleHelper.hasLightCycleView(
mApplication.getAndroidContext())) {
if (usePanoramaViewer()) {
operation |= SUPPORT_VIEW_PANORAMA;
}
return operation;
......@@ -343,4 +345,16 @@ public class LocalImage extends LocalMediaItem {
public String getFilePath() {
return filePath;
}
@Override
public boolean usePanoramaViewer() {
if (!mUsePanoramaViewerInitialized) {
Context context = mApplication.getAndroidContext();
mUsePanoramaViewer = LightCycleHelper.hasLightCycleView(context)
&& LightCycleHelper.isPanorama(mApplication.getContentResolver(),
getContentUri());
mUsePanoramaViewerInitialized = true;
}
return mUsePanoramaViewer;
}
}
......@@ -107,6 +107,10 @@ public abstract class MediaItem extends MediaObject {
return "";
}
public boolean usePanoramaViewer() {
return false;
}
// Returns width and height of the media item.
// Returns 0, 0 if the information is not available.
public abstract int getWidth();
......
......@@ -17,6 +17,7 @@
package com.android.gallery3d.data;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory.Options;
......@@ -27,6 +28,7 @@ import android.os.ParcelFileDescriptor;
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.common.BitmapUtils;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.util.LightCycleHelper;
import com.android.gallery3d.util.ThreadPool.CancelListener;
import com.android.gallery3d.util.ThreadPool.Job;
import com.android.gallery3d.util.ThreadPool.JobContext;
......@@ -54,6 +56,8 @@ public class UriImage extends MediaItem {
private int mWidth;
private int mHeight;
private int mRotation;
private boolean mUsePanoramaViewer;
private boolean mUsePanoramaViewerInitialized;
private GalleryApp mApplication;
......@@ -214,6 +218,9 @@ public class UriImage extends MediaItem {
if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
supported |= SUPPORT_FULL_IMAGE;
}
if (usePanoramaViewer()) {
supported |= SUPPORT_VIEW_PANORAMA;
}
return supported;
}
......@@ -283,4 +290,16 @@ public class UriImage extends MediaItem {
public int getRotation() {
return mRotation;
}
@Override
public boolean usePanoramaViewer() {
if (!mUsePanoramaViewerInitialized) {
Context context = mApplication.getAndroidContext();
mUsePanoramaViewer = LightCycleHelper.hasLightCycleView(context)
&& LightCycleHelper.isPanorama(mApplication.getContentResolver(),
getContentUri());
mUsePanoramaViewerInitialized = true;
}
return mUsePanoramaViewer;
}
}
......@@ -17,8 +17,10 @@
package com.android.gallery3d.util;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.android.camera.CameraModule;
......@@ -36,11 +38,11 @@ public class LightCycleHelper {
return false;
}
public static void viewPanorama(Activity activity, String filePath) {
public static void viewPanorama(Activity activity, Uri uri) {
/* Do nothing */
}
public static boolean isPanorama(String filename) {
public static boolean isPanorama(ContentResolver contentResolver, Uri uri) {
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment