diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-08-30 15:29:15 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2011-08-30 17:02:16 +0800 |
commit | d4832351874aa6eb2cd5e312c21bd4ec607ff3a4 (patch) | |
tree | 756a0b706fe396f003175164d1edec3cbf43e3ac /src/com/android/camera/FocusManager.java | |
parent | 2a1e44382f6a4fc70e4a89e3d183503a2255826f (diff) | |
download | LegacyCamera-d4832351874aa6eb2cd5e312c21bd4ec607ff3a4.zip LegacyCamera-d4832351874aa6eb2cd5e312c21bd4ec607ff3a4.tar.gz LegacyCamera-d4832351874aa6eb2cd5e312c21bd4ec607ff3a4.tar.bz2 |
Rotate the focus rectangle in different orientations.
The new focus assets look different in portrait and landscape.
Rotate the drawable so the orientation looks correct.
bug:5223866
Change-Id: I5e5ebbcbaca95b118e051fbf6131c1a12584b2f2
Diffstat (limited to 'src/com/android/camera/FocusManager.java')
-rw-r--r-- | src/com/android/camera/FocusManager.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/com/android/camera/FocusManager.java b/src/com/android/camera/FocusManager.java index 94093e6..414d701 100644 --- a/src/com/android/camera/FocusManager.java +++ b/src/com/android/camera/FocusManager.java @@ -16,8 +16,8 @@ package com.android.camera; -import com.android.camera.ui.FocusRectangle; import com.android.camera.ui.FaceView; +import com.android.camera.ui.FocusRectangle; import android.graphics.Rect; import android.hardware.Camera.Area; @@ -56,6 +56,7 @@ public class FocusManager { private boolean mFocusAreaSupported; private boolean mContinuousFocusFail; private ToneGenerator mFocusToneGenerator; + private View mFocusRectangleRotateLayout; private FocusRectangle mFocusRectangle; private View mPreviewFrame; private FaceView mFaceView; @@ -104,9 +105,10 @@ public class FocusManager { mParameters.getSupportedFocusModes())); } - public void initialize(FocusRectangle focusRectangle, View previewFrame, + public void initialize(View focusRectangleRotate, View previewFrame, FaceView faceView, Listener listener) { - mFocusRectangle = focusRectangle; + mFocusRectangleRotateLayout = focusRectangleRotate; + mFocusRectangle = (FocusRectangle) focusRectangleRotate.findViewById(R.id.focus_rect); mPreviewFrame = previewFrame; mFaceView = faceView; mListener = listener; @@ -222,8 +224,8 @@ public class FocusManager { // Initialize variables. int x = Math.round(e.getX()); int y = Math.round(e.getY()); - int focusWidth = mFocusRectangle.getWidth(); - int focusHeight = mFocusRectangle.getHeight(); + int focusWidth = mFocusRectangleRotateLayout.getWidth(); + int focusHeight = mFocusRectangleRotateLayout.getHeight(); int previewWidth = mPreviewFrame.getWidth(); int previewHeight = mPreviewFrame.getHeight(); if (mTapArea == null) { @@ -243,14 +245,14 @@ public class FocusManager { // Use margin to set the focus rectangle to the touched area. RelativeLayout.LayoutParams p = - (RelativeLayout.LayoutParams) mFocusRectangle.getLayoutParams(); + (RelativeLayout.LayoutParams) mFocusRectangleRotateLayout.getLayoutParams(); int left = Util.clamp(x - focusWidth / 2, 0, previewWidth - focusWidth); int top = Util.clamp(y - focusHeight / 2, 0, previewHeight - focusHeight); p.setMargins(left, top, 0, 0); // Disable "center" rule because we no longer want to put it in the center. int[] rules = p.getRules(); rules[RelativeLayout.CENTER_IN_PARENT] = 0; - mFocusRectangle.requestLayout(); + mFocusRectangleRotateLayout.requestLayout(); // Stop face detection because we want to specify focus and metering area. mListener.stopFaceDetection(); @@ -368,7 +370,7 @@ public class FocusManager { // Set the length of focus rectangle according to preview frame size. int len = Math.min(mPreviewFrame.getWidth(), mPreviewFrame.getHeight()) / 4; - ViewGroup.LayoutParams layout = mFocusRectangle.getLayoutParams(); + ViewGroup.LayoutParams layout = mFocusRectangleRotateLayout.getLayoutParams(); layout.width = len; layout.height = len; @@ -401,7 +403,7 @@ public class FocusManager { // Put focus rectangle to the center. RelativeLayout.LayoutParams p = - (RelativeLayout.LayoutParams) mFocusRectangle.getLayoutParams(); + (RelativeLayout.LayoutParams) mFocusRectangleRotateLayout.getLayoutParams(); int[] rules = p.getRules(); rules[RelativeLayout.CENTER_IN_PARENT] = RelativeLayout.TRUE; p.setMargins(0, 0, 0, 0); |