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 | |
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')
-rw-r--r-- | src/com/android/camera/Camera.java | 7 | ||||
-rw-r--r-- | src/com/android/camera/FocusManager.java | 20 | ||||
-rw-r--r-- | src/com/android/camera/ui/RotateLayout.java | 5 |
3 files changed, 20 insertions, 12 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index b5c3650..db0c0fc 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -18,7 +18,6 @@ package com.android.camera; import com.android.camera.ui.CameraPicker; import com.android.camera.ui.FaceView; -import com.android.camera.ui.FocusRectangle; import com.android.camera.ui.IndicatorControlContainer; import com.android.camera.ui.RotateImageView; import com.android.camera.ui.RotateLayout; @@ -166,6 +165,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, private RotateImageView mThumbnailView; private ModePicker mModePicker; private FaceView mFaceView; + private RotateLayout mFocusRectangleRotateLayout; // mCropValue and mSaveUri are used only if isImageCaptureIntent() is true. private String mCropValue; @@ -386,8 +386,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener, mPreviewFrame = findViewById(R.id.camera_preview); mPreviewFrame.setOnTouchListener(this); mPreviewBorder = findViewById(R.id.preview_border); - mFocusManager.initialize((FocusRectangle) findViewById(R.id.focus_rectangle), - mPreviewFrame, mFaceView, this); + mFocusRectangleRotateLayout = (RotateLayout) findViewById(R.id.focus_rect_rotate_layout); + mFocusManager.initialize(mFocusRectangleRotateLayout, mPreviewFrame, mFaceView, this); mFocusManager.initializeToneGenerator(); initializeScreenBrightness(); installIntentFilter(); @@ -1163,6 +1163,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, if (mSharePopup != null) mSharePopup.setOrientation(degree); if (mIndicatorControlContainer != null) mIndicatorControlContainer.setDegree(degree); if (mZoomControl != null) mZoomControl.setDegree(degree); + if (mFocusRectangleRotateLayout != null) mFocusRectangleRotateLayout.setOrientation(degree); } @Override 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); diff --git a/src/com/android/camera/ui/RotateLayout.java b/src/com/android/camera/ui/RotateLayout.java index 13b475d..1dfeae9 100644 --- a/src/com/android/camera/ui/RotateLayout.java +++ b/src/com/android/camera/ui/RotateLayout.java @@ -30,6 +30,11 @@ public class RotateLayout extends ViewGroup { public RotateLayout(Context context, AttributeSet attrs) { super(context, attrs); + // The transparent background here is a workaround of the render issue + // happened when the view is rotated as the device's orientation + // changed. The view looks fine in landscape. After rotation, the view + // is invisible. + setBackgroundResource(android.R.color.transparent); } @Override |