diff options
author | Angus Kong <shkong@google.com> | 2013-08-12 15:03:45 -0700 |
---|---|---|
committer | Angus Kong <shkong@google.com> | 2013-08-12 16:02:13 -0700 |
commit | c27d21bc3b9322936004827ab005fb7d1facfacf (patch) | |
tree | 9fb03089c5a4fbf43ea90d605a6fec1b1b5babed /src | |
parent | d806e6528092fd309bb2128ad5a539c72f52fd42 (diff) | |
download | android_packages_apps_Snap-c27d21bc3b9322936004827ab005fb7d1facfacf.tar.gz android_packages_apps_Snap-c27d21bc3b9322936004827ab005fb7d1facfacf.tar.bz2 android_packages_apps_Snap-c27d21bc3b9322936004827ab005fb7d1facfacf.zip |
Add local data types.
We need local data types to generate different menus.
bug:10245009
Change-Id: I95f947c11ad3f39172c43f75f4108bf720148278
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/data/CameraPreviewData.java | 9 | ||||
-rw-r--r-- | src/com/android/camera/data/LocalData.java | 23 | ||||
-rw-r--r-- | src/com/android/camera/data/LocalMediaData.java | 32 | ||||
-rw-r--r-- | src/com/android/camera/data/SimpleViewData.java | 9 | ||||
-rw-r--r-- | src/com/android/camera/ui/FilmStripView.java | 31 |
5 files changed, 77 insertions, 27 deletions
diff --git a/src/com/android/camera/data/CameraPreviewData.java b/src/com/android/camera/data/CameraPreviewData.java index a34f5787b..3a4510541 100644 --- a/src/com/android/camera/data/CameraPreviewData.java +++ b/src/com/android/camera/data/CameraPreviewData.java @@ -40,8 +40,13 @@ public class CameraPreviewData extends SimpleViewData { } @Override - public int getType() { - return ImageData.TYPE_CAMERA_PREVIEW; + public int getViewType() { + return ImageData.TYPE_STICKY_VIEW; + } + + @Override + public int getLocalDataType(int dataID) { + return LOCAL_CAMERA_PREVIEW; } @Override diff --git a/src/com/android/camera/data/LocalData.java b/src/com/android/camera/data/LocalData.java index f71abaa0c..7d6dfefc6 100644 --- a/src/com/android/camera/data/LocalData.java +++ b/src/com/android/camera/data/LocalData.java @@ -38,6 +38,18 @@ public interface LocalData extends FilmStripView.ImageData { public static final int ACTION_PLAY = 1; public static final int ACTION_DELETE = (1 << 1); + // Local data types. Returned by getLocalDataType(). + // Camera preview. + public static final int LOCAL_CAMERA_PREVIEW = 1; + // A data for showing an arbitrary view. + public static final int LOCAL_VIEW = 2; + // A still image. + public static final int LOCAL_IMAGE = 3; + // A video. + public static final int LOCAL_VIDEO = 4; + // A still image but with valid PhotoSphere metadata. + public static final int LOCAL_PHOTO_SPHERE = 5; + View getView(Context c, int width, int height, Drawable placeHolder); /** @@ -91,6 +103,16 @@ public interface LocalData extends FilmStripView.ImageData { Uri getContentUri(); /** + * Returns the type of the local data defined by {@link LocalData}. + * + * @param dataID The ID of the data. + * @return The local data type. Could be one of the following: + * {@code LOCAL_CAMERA_PREVIEW}, {@code LOCAL_VIEW}, {@code LOCAL_IMAGE}, + * {@code LOCAL_VIDEO}, and {@code LOCAL_PHOTO_SPHERE}, + */ + int getLocalDataType(int dataID); + + /** * Refresh the data content. * * @param resolver {@link ContentResolver} to refresh the data. @@ -124,6 +146,5 @@ public interface LocalData extends FilmStripView.ImageData { return cmp; } } - } diff --git a/src/com/android/camera/data/LocalMediaData.java b/src/com/android/camera/data/LocalMediaData.java index cd568239d..05b907a1e 100644 --- a/src/com/android/camera/data/LocalMediaData.java +++ b/src/com/android/camera/data/LocalMediaData.java @@ -61,12 +61,15 @@ public abstract class LocalMediaData implements LocalData { protected int height; /** The panorama metadata information of this media data. */ - private PhotoSphereHelper.PanoramaMetadata mPanoramaMetadata; + protected PhotoSphereHelper.PanoramaMetadata mPanoramaMetadata; /** Used to load photo sphere metadata from image files. */ - private PanoramaMetadataLoader mPanoramaMetadataLoader = null; + protected PanoramaMetadataLoader mPanoramaMetadataLoader = null; - // true if this data has a corresponding visible view. + /** + * Used for thumbnail loading optimization. True if this data + * has a corresponding visible view. + */ protected Boolean mUsing = false; @Override @@ -194,7 +197,7 @@ public abstract class LocalMediaData implements LocalData { } @Override - public abstract int getType(); + public abstract int getViewType(); protected abstract BitmapLoadTask getBitmapLoadTask( ImageView v, int decodeWidth, int decodeHeight); @@ -289,8 +292,8 @@ public abstract class LocalMediaData implements LocalData { } @Override - public int getType() { - return TYPE_PHOTO; + public int getViewType() { + return TYPE_REMOVABLE_VIEW; } @Override @@ -317,6 +320,14 @@ public abstract class LocalMediaData implements LocalData { } @Override + public int getLocalDataType(int dataID) { + if (mPanoramaMetadata != null && mPanoramaMetadata.mUsePanoramaViewer) { + return LOCAL_PHOTO_SPHERE; + } + return LOCAL_IMAGE; + } + + @Override public boolean refresh(ContentResolver resolver) { Cursor c = resolver.query( getContentUri(), QUERY_PROJECTION, null, null, null); @@ -458,8 +469,8 @@ public abstract class LocalMediaData implements LocalData { } @Override - public int getType() { - return TYPE_PHOTO; + public int getViewType() { + return TYPE_REMOVABLE_VIEW; } @Override @@ -486,6 +497,11 @@ public abstract class LocalMediaData implements LocalData { } @Override + public int getLocalDataType(int dataID) { + return LOCAL_VIDEO; + } + + @Override public boolean refresh(ContentResolver resolver) { Cursor c = resolver.query( getContentUri(), QUERY_PROJECTION, null, null, null); diff --git a/src/com/android/camera/data/SimpleViewData.java b/src/com/android/camera/data/SimpleViewData.java index 4d64c5360..d6fc1c416 100644 --- a/src/com/android/camera/data/SimpleViewData.java +++ b/src/com/android/camera/data/SimpleViewData.java @@ -71,8 +71,8 @@ public class SimpleViewData implements LocalData { } @Override - public int getType() { - return FilmStripView.ImageData.TYPE_PHOTO; + public int getViewType() { + return FilmStripView.ImageData.TYPE_REMOVABLE_VIEW; } @Override @@ -86,6 +86,11 @@ public class SimpleViewData implements LocalData { } @Override + public int getLocalDataType(int dataID) { + return LOCAL_VIEW; + } + + @Override public boolean refresh(ContentResolver resolver) { return false; } diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java index c11b93fd1..5eceaa4f1 100644 --- a/src/com/android/camera/ui/FilmStripView.java +++ b/src/com/android/camera/ui/FilmStripView.java @@ -98,10 +98,10 @@ public class FilmStripView extends ViewGroup { boolean isPanorama360); } - // Image data types. + // View types. public static final int TYPE_NONE = 0; - public static final int TYPE_CAMERA_PREVIEW = 1; - public static final int TYPE_PHOTO = 2; + public static final int TYPE_STICKY_VIEW = 1; + public static final int TYPE_REMOVABLE_VIEW = 2; // Actions allowed to be performed on the image data. // The actions are defined bit-wise so we can use bit operations like @@ -139,7 +139,7 @@ public class FilmStripView extends ViewGroup { public int getHeight(); /** Returns the image data type */ - public int getType(); + public int getViewType(); /** * Checks if the UI action is supported. @@ -501,7 +501,7 @@ public class FilmStripView extends ViewGroup { return false; } - private int getCurrentType() { + private int getCurrentViewType() { if (mDataAdapter == null) { return ImageData.TYPE_NONE; } @@ -509,7 +509,7 @@ public class FilmStripView extends ViewGroup { if (curr == null) { return ImageData.TYPE_NONE; } - return mDataAdapter.getImageData(curr.getID()).getType(); + return mDataAdapter.getImageData(curr.getID()).getViewType(); } @Override @@ -711,7 +711,7 @@ public class FilmStripView extends ViewGroup { if (mController.isScrolling()) { mController.stopScrolling(); } - if (getCurrentType() == ImageData.TYPE_CAMERA_PREVIEW + if (getCurrentViewType() == ImageData.TYPE_STICKY_VIEW && !mController.isScalling() && mScale != FULLSCREEN_SCALE) { mController.gotoFullScreen(); @@ -890,7 +890,7 @@ public class FilmStripView extends ViewGroup { // Keeps the view in the view hierarchy if it's camera preview. // Remove from the hierarchy otherwise. private void checkForRemoval(ImageData data, View v) { - if (data.getType() != ImageData.TYPE_CAMERA_PREVIEW) { + if (data.getViewType() != ImageData.TYPE_STICKY_VIEW) { removeView(v); data.recycle(); } else { @@ -1147,7 +1147,7 @@ public class FilmStripView extends ViewGroup { public boolean inCameraFullscreen() { return isAnchoredTo(0) && inFullScreen() - && (getCurrentType() == ImageData.TYPE_CAMERA_PREVIEW); + && (getCurrentViewType() == ImageData.TYPE_STICKY_VIEW); } @Override @@ -1270,7 +1270,7 @@ public class FilmStripView extends ViewGroup { if (mViewInfo[mCurrentInfo] == null) { return; } - if (getCurrentType() == ImageData.TYPE_CAMERA_PREVIEW) { + if (getCurrentViewType() == ImageData.TYPE_STICKY_VIEW) { // we are in camera mode by default. mController.lockAtCurrentView(); } @@ -1426,7 +1426,8 @@ public class FilmStripView extends ViewGroup { } float scaledVelocityX = velocityX / mScale; - if (inCameraFullscreen() && scaledVelocityX < 0) { + if (inFullScreen() && getCurrentViewType() == ImageData.TYPE_STICKY_VIEW + && scaledVelocityX < 0) { // Swipe left in camera preview. gotoFilmStrip(); } @@ -1518,8 +1519,8 @@ public class FilmStripView extends ViewGroup { @Override public void gotoCameraFullScreen() { - if (mDataAdapter.getImageData(0).getType() - != ImageData.TYPE_CAMERA_PREVIEW) { + if (mDataAdapter.getImageData(0).getViewType() + != ImageData.TYPE_STICKY_VIEW) { return; } gotoFullScreen(); @@ -1651,7 +1652,9 @@ public class FilmStripView extends ViewGroup { int deltaX = (int) (dx / mScale); if (inFilmStrip()) { if (Math.abs(dx) > Math.abs(dy)) { - if (deltaX > 0 && inCameraFullscreen()) { + if (deltaX > 0 + && inFullScreen() + && getCurrentViewType() == ImageData.TYPE_STICKY_VIEW) { mController.gotoFilmStrip(); } mController.scroll(deltaX); |