diff options
-rw-r--r-- | res/layout-w1024dp/basic_setting_popup.xml | 7 | ||||
-rw-r--r-- | res/layout-w1024dp/other_setting_popup.xml | 7 | ||||
-rw-r--r-- | res/layout-w1024dp/preview_frame.xml | 6 | ||||
-rw-r--r-- | res/layout/basic_setting_popup.xml | 7 | ||||
-rw-r--r-- | res/layout/focus_rect.xml | 25 | ||||
-rw-r--r-- | res/layout/other_setting_popup.xml | 7 | ||||
-rw-r--r-- | res/layout/preview_frame.xml | 5 | ||||
-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 |
10 files changed, 52 insertions, 44 deletions
diff --git a/res/layout-w1024dp/basic_setting_popup.xml b/res/layout-w1024dp/basic_setting_popup.xml index 5dfaabd..8eb64e3 100644 --- a/res/layout-w1024dp/basic_setting_popup.xml +++ b/res/layout-w1024dp/basic_setting_popup.xml @@ -22,12 +22,7 @@ android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" - android:visibility="gone" - android:background="@android:color/transparent"> - <!-- the transparent background here is a workaround of the render issue - happened when the popup window is rotated as the device's orientation - changed. The view looks fine in landscape. After rotation, only center - part of the view is visible. --> + android:visibility="gone"> <LinearLayout android:orientation="vertical" android:layout_width="410dp" diff --git a/res/layout-w1024dp/other_setting_popup.xml b/res/layout-w1024dp/other_setting_popup.xml index 66e0240..4db8689 100644 --- a/res/layout-w1024dp/other_setting_popup.xml +++ b/res/layout-w1024dp/other_setting_popup.xml @@ -23,12 +23,7 @@ android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" - android:visibility="gone" - android:background="@android:color/transparent"> - <!-- the transparent background here is a workaround of the render issue - happened when the popup window is rotated as the device's orientation - changed. The view looks fine in landscape. After rotation, only center - part of the view is visible. --> + android:visibility="gone"> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" diff --git a/res/layout-w1024dp/preview_frame.xml b/res/layout-w1024dp/preview_frame.xml index f6afd9a..6965aed 100644 --- a/res/layout-w1024dp/preview_frame.xml +++ b/res/layout-w1024dp/preview_frame.xml @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> + <com.android.camera.PreviewFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/frame_layout" android:layout_width="match_parent" @@ -28,10 +29,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone"/> - <com.android.camera.ui.FocusRectangle android:id="@+id/focus_rectangle" - android:layout_width="180dp" - android:layout_height="180dp" - android:layout_centerInParent="true"/> + <include layout="@layout/focus_rect"/> <include layout="@layout/priority_indicators"/> <include layout="@layout/review_control"/> <include layout="@layout/tap_to_focus_toast"/> diff --git a/res/layout/basic_setting_popup.xml b/res/layout/basic_setting_popup.xml index 33bff04..9f579de 100644 --- a/res/layout/basic_setting_popup.xml +++ b/res/layout/basic_setting_popup.xml @@ -22,12 +22,7 @@ android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/indicator_control" - android:visibility="gone" - android:background="@android:color/transparent"> - <!-- the transparent background here is a workaround of the render issue - happened when the popup window is rotated as the device's orientation - changed. The view looks fine in landscape. After rotation, only center - part of the view is visible. --> + android:visibility="gone"> <LinearLayout android:orientation="vertical" android:layout_height="wrap_content" diff --git a/res/layout/focus_rect.xml b/res/layout/focus_rect.xml new file mode 100644 index 0000000..f8aef7c --- /dev/null +++ b/res/layout/focus_rect.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<com.android.camera.ui.RotateLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/focus_rect_rotate_layout" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true"> + <com.android.camera.ui.FocusRectangle android:id="@+id/focus_rect" + android:layout_width="120dp" + android:layout_height="120dp"/> +</com.android.camera.ui.RotateLayout> diff --git a/res/layout/other_setting_popup.xml b/res/layout/other_setting_popup.xml index 3c7cfcb..263c938 100644 --- a/res/layout/other_setting_popup.xml +++ b/res/layout/other_setting_popup.xml @@ -23,12 +23,7 @@ android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/indicator_control" - android:visibility="gone" - android:background="@android:color/transparent"> - <!-- the transparent background here is a workaround of the render issue - happened when the popup window is rotated as the device's orientation - changed. The view looks fine in landscape. After rotation, only center - part of the view is visible. --> + android:visibility="gone"> <LinearLayout android:orientation="vertical" android:layout_width="320dp" diff --git a/res/layout/preview_frame.xml b/res/layout/preview_frame.xml index b7685bf..b1deb86 100644 --- a/res/layout/preview_frame.xml +++ b/res/layout/preview_frame.xml @@ -35,10 +35,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone"/> - <com.android.camera.ui.FocusRectangle android:id="@+id/focus_rectangle" - android:layout_width="120dp" - android:layout_height="120dp" - android:layout_centerInParent="true"/> + <include layout="@layout/focus_rect"/> <include layout="@layout/priority_indicators"/> <include layout="@layout/tap_to_focus_toast"/> <include layout="@layout/indicator_bar" /> 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 |