Merge changes Ic62822a4,Ie6505c8e into gb-ub-photos-arches

* changes:
  Change how stitched images are inserted into Gallery.
  Move panorama stitch progress outside the image.
diff --git a/src/com/android/gallery3d/app/OrientationManager.java b/src/com/android/gallery3d/app/OrientationManager.java
index f5cbf06..a8ef99a 100644
--- a/src/com/android/gallery3d/app/OrientationManager.java
+++ b/src/com/android/gallery3d/app/OrientationManager.java
@@ -98,13 +98,19 @@
     public void lockOrientation() {
         if (mOrientationLocked) return;
         mOrientationLocked = true;
+        // Display rotation >= 180 means we need to use the REVERSE landscape/portrait
+        boolean standard = getDisplayRotation() < 180;
         if (mActivity.getResources().getConfiguration().orientation
                 == Configuration.ORIENTATION_LANDSCAPE) {
             Log.d(TAG, "lock orientation to landscape");
-            mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+            mActivity.setRequestedOrientation(standard
+                    ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
+                    : ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
         } else {
             Log.d(TAG, "lock orientation to portrait");
-            mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+            mActivity.setRequestedOrientation(standard
+                    ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+                    : ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
         }
         updateCompensation();
     }
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
index c990c18..00a1809 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
@@ -24,7 +24,7 @@
 
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, short []matrix);
 
-    public void apply(Bitmap bitmap) {
+    public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
         int w = bitmap.getWidth();
         int h = bitmap.getHeight();
         float p = mParameter;
@@ -38,5 +38,6 @@
                 (short) (2*sizex),(short) (2*sizey)};
 
         nativeApplyFilter(bitmap, w, h, rect);
+        return bitmap;
     }
 }
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index 3086b24..214d0e0 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -546,6 +546,10 @@
     }
 
     private int getPanoramaRotation() {
+        // Panorama only support rotations of 0 and 90, so if it is greater
+        // than that flip the output surface texture to compensate
+        if (mDisplayRotation > 180)
+            return (mCompensation + 180) % 360;
         return mCompensation;
     }