Merge "Change camera theem to Holo.Light." into gb-ub-photos-denali
diff --git a/project.properties b/project.properties
index ce39f2d..4ab1256 100644
--- a/project.properties
+++ b/project.properties
@@ -11,4 +11,4 @@
 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
 
 # Project target.
-target=android-18
+target=android-19
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 02096ad..daf6949 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -214,7 +214,6 @@
 
     private CameraController mCameraController;
     private boolean mPaused;
-    private boolean mUpAsGallery;
     private CameraAppUI mCameraAppUI;
 
     private PeekAnimationHandler mPeekAnimationHandler;
@@ -554,10 +553,6 @@
 
                 @Override
                 public void onEnterFilmstrip(int dataId) {
-                    if (mGalleryIntent != null) {
-                        mActionBar.setDisplayUseLogoEnabled(true);
-                        mUpAsGallery = true;
-                    }
                     if (mFilmstripVisible) {
                         CameraActivity.this.setFilmstripUiVisibility(true);
                     }
@@ -565,10 +560,7 @@
 
                 @Override
                 public void onLeaveFilmstrip(int dataId) {
-                    if (mGalleryIntent != null) {
-                        mActionBar.setDisplayUseLogoEnabled(false);
-                        mUpAsGallery = false;
-                    }
+                    // Do nothing.
                 }
 
                 @Override
@@ -643,8 +635,7 @@
      * @param visible is false, this hides the action bar and switches the
      *            filmstrip UI to lights-out mode.
      */
-    // TODO: This should not be called outside of the activity.
-    public void setFilmstripUiVisibility(boolean visible) {
+    private void setFilmstripUiVisibility(boolean visible) {
         int currentSystemUIVisibility = mAboveFilmstripControlLayout.getSystemUiVisibility();
         int newSystemUIVisibility = (visible ? View.SYSTEM_UI_FLAG_VISIBLE
                 : View.SYSTEM_UI_FLAG_FULLSCREEN);
@@ -1018,7 +1009,7 @@
         // Handle presses on the action bar items
         switch (item.getItemId()) {
             case android.R.id.home:
-                if (mFilmstripVisible && mUpAsGallery && startGallery()) {
+                if (mFilmstripVisible && startGallery()) {
                     return true;
                 }
                 onBackPressed();
@@ -1323,6 +1314,9 @@
                 Log.e(TAG, "Can't get the activity logo");
             }
         }
+        if (mGalleryIntent != null) {
+            mActionBar.setDisplayUseLogoEnabled(true);
+        }
         mActionBar.setLogo(galleryLogo);
         mOrientationManager.resume();
         super.onResume();
@@ -1460,7 +1454,9 @@
         }
     }
 
+    @Override
     public boolean isAutoRotateScreen() {
+        // TODO: Move to OrientationManager.
         return mAutoRotateScreen;
     }
 
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index d72a6ae..5e0ee8b 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -375,6 +375,7 @@
         locationFirstRun();
     }
 
+    @Override
     public void onPreviewInitialDataReceived() {
         startSmartCamera();
     }
@@ -924,7 +925,8 @@
         } else {
             orientation = mOrientation;
         }
-        mJpegRotation = CameraUtil.getJpegRotation(mActivity, mCameraId, orientation);
+        CameraInfo info = mActivity.getCameraProvider().getCameraInfo()[mCameraId];
+        mJpegRotation = CameraUtil.getJpegRotation(info, orientation);
         mParameters.setRotation(mJpegRotation);
         Location loc = mActivity.getLocationManager().getCurrentLocation();
         CameraUtil.setGpsParameters(mParameters, loc);
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 9b32d26..2a4a353 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -387,7 +387,8 @@
             }
 
             // Set rotation and gps data.
-            int rotation = CameraUtil.getJpegRotation(mActivity, mCameraId, mOrientation);
+            CameraInfo info = mActivity.getCameraProvider().getCameraInfo()[mCameraId];
+            int rotation = CameraUtil.getJpegRotation(info, mOrientation);
             mParameters.setRotation(rotation);
             Location loc = mLocationManager.getCurrentLocation();
             CameraUtil.setGpsParameters(mParameters, loc);
diff --git a/src/com/android/camera/app/AppController.java b/src/com/android/camera/app/AppController.java
index 21b40c9..04d08a6 100644
--- a/src/com/android/camera/app/AppController.java
+++ b/src/com/android/camera/app/AppController.java
@@ -314,4 +314,7 @@
      * Returns the {@link com.android.camera.ButtonManager}.
      */
     public ButtonManager getButtonManager();
+
+    /** Whether auto-rotate is enabled.*/
+    public boolean isAutoRotateScreen();
 }
diff --git a/src/com/android/camera/ui/PreviewOverlay.java b/src/com/android/camera/ui/PreviewOverlay.java
index f6d43f9..494d382 100644
--- a/src/com/android/camera/ui/PreviewOverlay.java
+++ b/src/com/android/camera/ui/PreviewOverlay.java
@@ -207,6 +207,15 @@
                 if (ev.getPointerCount() > 1) {
                     mDeltaX = ev.getX(1) - ev.getX(0);
                     mDeltaY = ev.getY(1) - ev.getY(0);
+                    if (ev.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
+                        if (!mZoomProcessor.isVisible()) {
+                            mZoomProcessor.showZoomUI();
+                        }
+                    } else if (ev.getActionMasked() == MotionEvent.ACTION_POINTER_UP) {
+                        if (mZoomProcessor.isVisible()) {
+                            mZoomProcessor.hideZoomUI();
+                        }
+                    }
                 }
                 return handled;
             }
@@ -350,6 +359,27 @@
             invalidate();
         }
 
+        public boolean isVisible() {
+            return mVisible;
+        }
+
+        public void showZoomUI() {
+            if (mZoomListener == null) {
+                return;
+            }
+            mVisible = true;
+            mFingerAngle = mScaleDetector.getAngle();
+            invalidate();
+        }
+
+        public void hideZoomUI() {
+            if (mZoomListener == null) {
+                return;
+            }
+            mVisible = false;
+            invalidate();
+        }
+
         private void setupZoom(int zoomMax, int zoom, List<Integer> zoomRatios) {
             mZoomRatios = zoomRatios;
             setZoomMax(zoomMax);
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index 1207519..242deb5 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -769,20 +769,19 @@
         view.setVisibility(View.GONE);
     }
 
-    public static int getJpegRotation(CameraActivity activity, int cameraId, int orientation) {
-        // See android.hardware.Camera.Parameters.setRotation for
-        // documentation.
-        int rotation = 0;
-        if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
-            CameraInfo info = activity.getCameraProvider().getCameraInfo()[cameraId];
-            if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
-                rotation = (info.orientation - orientation + 360) % 360;
-            } else {  // back-facing camera
-                rotation = (info.orientation + orientation) % 360;
-            }
-        }
-        return rotation;
-    }
+    public static int getJpegRotation(CameraInfo info, int orientation) {
+      // See android.hardware.Camera.Parameters.setRotation for
+      // documentation.
+      int rotation = 0;
+      if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
+          if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
+              rotation = (info.orientation - orientation + 360) % 360;
+          } else {  // back-facing camera
+              rotation = (info.orientation + orientation) % 360;
+          }
+      }
+      return rotation;
+  }
 
     /**
      * Down-samples a jpeg byte array.
@@ -946,9 +945,9 @@
      */
     public static int addPixel(int pixel, int newPixel, float weight) {
         // TODO: scale weight to [0, 1024] to avoid casting to float and back to int.
-        int r = ((pixel & 0x00ff0000) + (int) (((float) (newPixel & 0x00ff0000)) * weight)) & 0x00ff0000;
-        int g = ((pixel & 0x0000ff00) + (int) (((float) (newPixel & 0x0000ff00)) * weight)) & 0x0000ff00;
-        int b = ((pixel & 0x000000ff) + (int) (((float) (newPixel & 0x000000ff)) * weight)) & 0x000000ff;
+        int r = ((pixel & 0x00ff0000) + (int) ((newPixel & 0x00ff0000) * weight)) & 0x00ff0000;
+        int g = ((pixel & 0x0000ff00) + (int) ((newPixel & 0x0000ff00) * weight)) & 0x0000ff00;
+        int b = ((pixel & 0x000000ff) + (int) ((newPixel & 0x000000ff) * weight)) & 0x000000ff;
         return 0xff000000 | r | g | b;
     }