Rotate the camera screen nail correctly in gingerbread.

In gingerbread, camera screen nail is a static image.
Handle its rotation like a bitmap screen nail.

bug:6927809

Change-Id: I554483e58fc9e32399acb20f426d7ec35631b7ac
diff --git a/src/com/android/gallery3d/app/AppBridge.java b/src/com/android/gallery3d/app/AppBridge.java
index f89b35a..e3deb81 100644
--- a/src/com/android/gallery3d/app/AppBridge.java
+++ b/src/com/android/gallery3d/app/AppBridge.java
@@ -37,6 +37,7 @@
     //////////////////////////////////////////////////////////////////////////
 
     public abstract boolean isPanorama();
+    public abstract boolean isStaticCamera();
     public abstract ScreenNail attachScreenNail();
     public abstract void detachScreenNail();
 
diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java
index 7b979a7..b61e4f4 100644
--- a/src/com/android/gallery3d/app/PhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java
@@ -150,6 +150,7 @@
     private Path mItemPath;
     private int mCameraIndex;
     private boolean mIsPanorama;
+    private boolean mIsStaticCamera;
     private boolean mIsActive;
     private boolean mNeedFullImage;
     private int mFocusHintDirection = FOCUS_HINT_NEXT;
@@ -170,13 +171,14 @@
     // preview. If cameraIndex < 0, there is no camera preview.
     public PhotoDataAdapter(GalleryActivity activity, PhotoView view,
             MediaSet mediaSet, Path itemPath, int indexHint, int cameraIndex,
-            boolean isPanorama) {
+            boolean isPanorama, boolean isStaticCamera) {
         mSource = Utils.checkNotNull(mediaSet);
         mPhotoView = Utils.checkNotNull(view);
         mItemPath = Utils.checkNotNull(itemPath);
         mCurrentIndex = indexHint;
         mCameraIndex = cameraIndex;
         mIsPanorama = isPanorama;
+        mIsStaticCamera = isStaticCamera;
         mThreadPool = activity.getThreadPool();
         mNeedFullImage = true;
 
@@ -463,6 +465,11 @@
     }
 
     @Override
+    public boolean isStaticCamera(int offset) {
+        return isCamera(offset) && mIsStaticCamera;
+    }
+
+    @Override
     public boolean isVideo(int offset) {
         MediaItem item = getItem(mCurrentIndex + offset);
         return (item == null)
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index c6e7469..8f4fed9 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -229,7 +229,8 @@
             PhotoDataAdapter pda = new PhotoDataAdapter(
                     mActivity, mPhotoView, mMediaSet, itemPath, mCurrentIndex,
                     mAppBridge == null ? -1 : 0,
-                    mAppBridge == null ? false : mAppBridge.isPanorama());
+                    mAppBridge == null ? false : mAppBridge.isPanorama(),
+                    mAppBridge == null ? false : mAppBridge.isStaticCamera());
             mModel = pda;
             mPhotoView.setModel(mModel);
 
diff --git a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
index 6885456..254f672 100644
--- a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
@@ -206,6 +206,11 @@
     }
 
     @Override
+    public boolean isStaticCamera(int offset) {
+        return false;
+    }
+
+    @Override
     public boolean isVideo(int offset) {
         return mItem.getMediaType() == MediaItem.MEDIA_TYPE_VIDEO;
     }
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index c9fefca..0dee1b0 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -78,6 +78,10 @@
         // Returns true if the item is the Panorama.
         public boolean isPanorama(int offset);
 
+        // Returns true if the item is a static image that represents camera
+        // preview.
+        public boolean isStaticCamera(int offset);
+
         // Returns true if the item is a Video.
         public boolean isVideo(int offset);
 
@@ -545,6 +549,7 @@
         private int mRotation;
         private boolean mIsCamera;
         private boolean mIsPanorama;
+        private boolean mIsStaticCamera;
         private boolean mIsVideo;
         private boolean mIsDeletable;
         private int mLoadingState = Model.LOADING_INIT;
@@ -561,6 +566,7 @@
 
             mIsCamera = mModel.isCamera(0);
             mIsPanorama = mModel.isPanorama(0);
+            mIsStaticCamera = mModel.isStaticCamera(0);
             mIsVideo = mModel.isVideo(0);
             mIsDeletable = mModel.isDeletable(0);
             mLoadingState = mModel.getLoadingState(0);
@@ -582,7 +588,7 @@
         private void updateSize() {
             if (mIsPanorama) {
                 mRotation = getPanoramaRotation();
-            } else if (mIsCamera) {
+            } else if (mIsCamera && !mIsStaticCamera) {
                 mRotation = getCameraRotation();
             } else {
                 mRotation = mModel.getImageRotation(0);
@@ -741,6 +747,7 @@
         private ScreenNail mScreenNail;
         private boolean mIsCamera;
         private boolean mIsPanorama;
+        private boolean mIsStaticCamera;
         private boolean mIsVideo;
         private boolean mIsDeletable;
         private int mLoadingState = Model.LOADING_INIT;
@@ -754,6 +761,7 @@
         public void reload() {
             mIsCamera = mModel.isCamera(mIndex);
             mIsPanorama = mModel.isPanorama(mIndex);
+            mIsStaticCamera = mModel.isStaticCamera(mIndex);
             mIsVideo = mModel.isVideo(mIndex);
             mIsDeletable = mModel.isDeletable(mIndex);
             mLoadingState = mModel.getLoadingState(mIndex);
@@ -844,7 +852,7 @@
         private void updateSize() {
             if (mIsPanorama) {
                 mRotation = getPanoramaRotation();
-            } else if (mIsCamera) {
+            } else if (mIsCamera && !mIsStaticCamera) {
                 mRotation = getCameraRotation();
             } else {
                 mRotation = mModel.getImageRotation(mIndex);