summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-09-02 03:23:24 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-02 03:23:24 -0700
commitd97d89558a67673396b083f4a75813ffd0b7c87e (patch)
tree4b16ce1137d2a33068ebb40172b37fffcd1382ac
parentea136afa2f4d38428ad486df5fb0a24db8314a3d (diff)
parent20b3c3526ebb8d8a6873f7a1110f23847a843515 (diff)
downloadLegacyCamera-d97d89558a67673396b083f4a75813ffd0b7c87e.zip
LegacyCamera-d97d89558a67673396b083f4a75813ffd0b7c87e.tar.gz
LegacyCamera-d97d89558a67673396b083f4a75813ffd0b7c87e.tar.bz2
Merge "Update focus rectangle assets."
-rw-r--r--res/drawable-hdpi/ic_focus_face_focused.9.pngbin0 -> 432 bytes
-rw-r--r--res/drawable-hdpi/ic_focus_failed.9.pngbin662 -> 530 bytes
-rw-r--r--res/drawable-hdpi/ic_focus_focused.9.pngbin692 -> 559 bytes
-rw-r--r--res/drawable-hdpi/ic_focus_focusing.9.pngbin691 -> 564 bytes
-rw-r--r--res/drawable-mdpi/ic_focus_face_focused.9.pngbin0 -> 335 bytes
-rw-r--r--res/drawable-mdpi/ic_focus_failed.9.pngbin483 -> 366 bytes
-rw-r--r--res/drawable-mdpi/ic_focus_focused.9.pngbin525 -> 420 bytes
-rw-r--r--res/drawable-mdpi/ic_focus_focusing.9.pngbin501 -> 369 bytes
-rw-r--r--res/drawable-xhdpi/ic_focus_face_focused.9.pngbin0 -> 505 bytes
-rw-r--r--res/drawable-xhdpi/ic_focus_failed.9.pngbin913 -> 663 bytes
-rw-r--r--res/drawable-xhdpi/ic_focus_focused.9.pngbin954 -> 687 bytes
-rw-r--r--res/drawable-xhdpi/ic_focus_focusing.9.pngbin965 -> 679 bytes
-rw-r--r--res/layout-w1024dp/preview_frame.xml2
-rw-r--r--res/layout/focus_indicator.xml (renamed from res/layout/focus_rect.xml)4
-rw-r--r--res/layout/preview_frame.xml2
-rw-r--r--src/com/android/camera/Camera.java14
-rw-r--r--src/com/android/camera/FocusManager.java61
-rw-r--r--src/com/android/camera/ui/FaceView.java40
-rw-r--r--src/com/android/camera/ui/FocusIndicator.java24
-rw-r--r--src/com/android/camera/ui/FocusIndicatorView.java (renamed from src/com/android/camera/ui/FocusRectangle.java)10
20 files changed, 106 insertions, 51 deletions
diff --git a/res/drawable-hdpi/ic_focus_face_focused.9.png b/res/drawable-hdpi/ic_focus_face_focused.9.png
new file mode 100644
index 0000000..d19f0e3
--- /dev/null
+++ b/res/drawable-hdpi/ic_focus_face_focused.9.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_focus_failed.9.png b/res/drawable-hdpi/ic_focus_failed.9.png
index 3113301..af464d8 100644
--- a/res/drawable-hdpi/ic_focus_failed.9.png
+++ b/res/drawable-hdpi/ic_focus_failed.9.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_focus_focused.9.png b/res/drawable-hdpi/ic_focus_focused.9.png
index c529e9a..790669c 100644
--- a/res/drawable-hdpi/ic_focus_focused.9.png
+++ b/res/drawable-hdpi/ic_focus_focused.9.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_focus_focusing.9.png b/res/drawable-hdpi/ic_focus_focusing.9.png
index c7e9acc..4f7137b 100644
--- a/res/drawable-hdpi/ic_focus_focusing.9.png
+++ b/res/drawable-hdpi/ic_focus_focusing.9.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_focus_face_focused.9.png b/res/drawable-mdpi/ic_focus_face_focused.9.png
new file mode 100644
index 0000000..1035a01
--- /dev/null
+++ b/res/drawable-mdpi/ic_focus_face_focused.9.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_focus_failed.9.png b/res/drawable-mdpi/ic_focus_failed.9.png
index d781cb3..5d6deab 100644
--- a/res/drawable-mdpi/ic_focus_failed.9.png
+++ b/res/drawable-mdpi/ic_focus_failed.9.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_focus_focused.9.png b/res/drawable-mdpi/ic_focus_focused.9.png
index d81dc28..31ecb1c 100644
--- a/res/drawable-mdpi/ic_focus_focused.9.png
+++ b/res/drawable-mdpi/ic_focus_focused.9.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_focus_focusing.9.png b/res/drawable-mdpi/ic_focus_focusing.9.png
index 4f6f8d1..a5c8331 100644
--- a/res/drawable-mdpi/ic_focus_focusing.9.png
+++ b/res/drawable-mdpi/ic_focus_focusing.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_focus_face_focused.9.png b/res/drawable-xhdpi/ic_focus_face_focused.9.png
new file mode 100644
index 0000000..add24a2
--- /dev/null
+++ b/res/drawable-xhdpi/ic_focus_face_focused.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_focus_failed.9.png b/res/drawable-xhdpi/ic_focus_failed.9.png
index 2b4dc4d..50672f3 100644
--- a/res/drawable-xhdpi/ic_focus_failed.9.png
+++ b/res/drawable-xhdpi/ic_focus_failed.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_focus_focused.9.png b/res/drawable-xhdpi/ic_focus_focused.9.png
index f5b2376..d41d3ac 100644
--- a/res/drawable-xhdpi/ic_focus_focused.9.png
+++ b/res/drawable-xhdpi/ic_focus_focused.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_focus_focusing.9.png b/res/drawable-xhdpi/ic_focus_focusing.9.png
index e4be86c..a99abed 100644
--- a/res/drawable-xhdpi/ic_focus_focusing.9.png
+++ b/res/drawable-xhdpi/ic_focus_focusing.9.png
Binary files differ
diff --git a/res/layout-w1024dp/preview_frame.xml b/res/layout-w1024dp/preview_frame.xml
index d7f00b1..ea57476 100644
--- a/res/layout-w1024dp/preview_frame.xml
+++ b/res/layout-w1024dp/preview_frame.xml
@@ -29,7 +29,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
- <include layout="@layout/focus_rect"/>
+ <include layout="@layout/focus_indicator"/>
<include layout="@layout/priority_indicators"/>
<include layout="@layout/tap_to_focus_toast"/>
</RelativeLayout>
diff --git a/res/layout/focus_rect.xml b/res/layout/focus_indicator.xml
index f8aef7c..0e67061 100644
--- a/res/layout/focus_rect.xml
+++ b/res/layout/focus_indicator.xml
@@ -15,11 +15,11 @@
-->
<com.android.camera.ui.RotateLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/focus_rect_rotate_layout"
+ android:id="@+id/focus_indicator_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"
+ <com.android.camera.ui.FocusIndicatorView android:id="@+id/focus_indicator"
android:layout_width="120dp"
android:layout_height="120dp"/>
</com.android.camera.ui.RotateLayout>
diff --git a/res/layout/preview_frame.xml b/res/layout/preview_frame.xml
index b1deb86..e8afb12 100644
--- a/res/layout/preview_frame.xml
+++ b/res/layout/preview_frame.xml
@@ -35,7 +35,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
- <include layout="@layout/focus_rect"/>
+ <include layout="@layout/focus_indicator"/>
<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 1cc45fd..846af1e 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -163,7 +163,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
private RotateImageView mThumbnailView;
private ModePicker mModePicker;
private FaceView mFaceView;
- private RotateLayout mFocusRectangleRotateLayout;
+ private RotateLayout mFocusIndicator;
// mCropValue and mSaveUri are used only if isImageCaptureIntent() is true.
private String mCropValue;
@@ -384,8 +384,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
mPreviewFrame = findViewById(R.id.camera_preview);
mPreviewFrame.setOnTouchListener(this);
mPreviewBorder = findViewById(R.id.preview_border);
- mFocusRectangleRotateLayout = (RotateLayout) findViewById(R.id.focus_rect_rotate_layout);
- mFocusManager.initialize(mFocusRectangleRotateLayout, mPreviewFrame, mFaceView, this);
+ mFocusIndicator = (RotateLayout) findViewById(R.id.focus_indicator_rotate_layout);
+ mFocusManager.initialize(mFocusIndicator, mPreviewFrame, mFaceView, this);
mFocusManager.initializeToneGenerator();
initializeScreenBrightness();
installIntentFilter();
@@ -524,7 +524,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
public void startFaceDetection() {
if (mParameters.getMaxNumDetectedFaces() > 0) {
mFaceView = (FaceView) findViewById(R.id.face_view);
- mFaceView.clearFaces();
+ mFaceView.clear();
mFaceView.setVisibility(View.VISIBLE);
mFaceView.setDisplayOrientation(mDisplayOrientation);
CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
@@ -540,7 +540,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
if (mParameters.getMaxNumDetectedFaces() > 0) {
mCameraDevice.setFaceDetectionListener(null);
mCameraDevice.stopFaceDetection();
- if (mFaceView != null) mFaceView.clearFaces();
+ if (mFaceView != null) mFaceView.clear();
}
}
@@ -1149,7 +1149,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);
+ if (mFocusIndicator != null) mFocusIndicator.setOrientation(degree);
}
@Override
@@ -1396,7 +1396,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
// Clear UI.
collapseCameraControls();
if (mSharePopup != null) mSharePopup.dismiss();
- if (mFaceView != null) mFaceView.clearFaces();
+ if (mFaceView != null) mFaceView.clear();
if (mFirstTimeInitialized) {
mOrientationListener.disable();
diff --git a/src/com/android/camera/FocusManager.java b/src/com/android/camera/FocusManager.java
index 414d701..05e63e7 100644
--- a/src/com/android/camera/FocusManager.java
+++ b/src/com/android/camera/FocusManager.java
@@ -17,7 +17,8 @@
package com.android.camera;
import com.android.camera.ui.FaceView;
-import com.android.camera.ui.FocusRectangle;
+import com.android.camera.ui.FocusIndicator;
+import com.android.camera.ui.FocusIndicatorView;
import android.graphics.Rect;
import android.hardware.Camera.Area;
@@ -56,8 +57,8 @@ public class FocusManager {
private boolean mFocusAreaSupported;
private boolean mContinuousFocusFail;
private ToneGenerator mFocusToneGenerator;
- private View mFocusRectangleRotateLayout;
- private FocusRectangle mFocusRectangle;
+ private View mFocusIndicatorRotateLayout;
+ private FocusIndicatorView mFocusIndicator;
private View mPreviewFrame;
private FaceView mFaceView;
private List<Area> mTapArea; // focus area in driver format
@@ -105,10 +106,11 @@ public class FocusManager {
mParameters.getSupportedFocusModes()));
}
- public void initialize(View focusRectangleRotate, View previewFrame,
+ public void initialize(View focusIndicatorRotate, View previewFrame,
FaceView faceView, Listener listener) {
- mFocusRectangleRotateLayout = focusRectangleRotate;
- mFocusRectangle = (FocusRectangle) focusRectangleRotate.findViewById(R.id.focus_rect);
+ mFocusIndicatorRotateLayout = focusIndicatorRotate;
+ mFocusIndicator = (FocusIndicatorView) focusIndicatorRotate.findViewById(
+ R.id.focus_indicator);
mPreviewFrame = previewFrame;
mFaceView = faceView;
mListener = listener;
@@ -165,7 +167,6 @@ public class FocusManager {
public void onShutter() {
resetTouchFocus();
updateFocusUI();
- if (mFaceView != null) mFaceView.clearFaces();
}
public void onAutoFocus(boolean focused) {
@@ -224,8 +225,8 @@ public class FocusManager {
// Initialize variables.
int x = Math.round(e.getX());
int y = Math.round(e.getY());
- int focusWidth = mFocusRectangleRotateLayout.getWidth();
- int focusHeight = mFocusRectangleRotateLayout.getHeight();
+ int focusWidth = mFocusIndicatorRotateLayout.getWidth();
+ int focusHeight = mFocusIndicatorRotateLayout.getHeight();
int previewWidth = mPreviewFrame.getWidth();
int previewHeight = mPreviewFrame.getHeight();
if (mTapArea == null) {
@@ -234,7 +235,7 @@ public class FocusManager {
}
// Convert the coordinates to driver format. The actual focus area is two times bigger than
- // UI because a huge rectangle looks strange.
+ // UI because a huge indicator looks strange.
int areaWidth = focusWidth * 2;
int areaHeight = focusHeight * 2;
int areaLeft = Util.clamp(x - areaWidth / 2, 0, previewWidth - areaWidth);
@@ -243,16 +244,16 @@ public class FocusManager {
convertToFocusArea(areaLeft, areaTop, areaWidth, areaHeight, previewWidth, previewHeight,
mTapArea.get(0).rect);
- // Use margin to set the focus rectangle to the touched area.
+ // Use margin to set the focus indicator to the touched area.
RelativeLayout.LayoutParams p =
- (RelativeLayout.LayoutParams) mFocusRectangleRotateLayout.getLayoutParams();
+ (RelativeLayout.LayoutParams) mFocusIndicatorRotateLayout.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;
- mFocusRectangleRotateLayout.requestLayout();
+ mFocusIndicatorRotateLayout.requestLayout();
// Stop face detection because we want to specify focus and metering area.
mListener.stopFaceDetection();
@@ -261,7 +262,7 @@ public class FocusManager {
mListener.setFocusParameters();
if (mFocusAreaSupported && (e.getAction() == MotionEvent.ACTION_UP)) {
autoFocus();
- } else { // Just show the rectangle in all other cases.
+ } else { // Just show the indicator in all other cases.
updateFocusUI();
// Reset the metering area in 3 seconds.
mHandler.removeMessages(RESET_TOUCH_FOCUS);
@@ -368,42 +369,40 @@ public class FocusManager {
public void updateFocusUI() {
if (!mInitialized) return;
- // Set the length of focus rectangle according to preview frame size.
+ // Set the length of focus indicator according to preview frame size.
int len = Math.min(mPreviewFrame.getWidth(), mPreviewFrame.getHeight()) / 4;
- ViewGroup.LayoutParams layout = mFocusRectangleRotateLayout.getLayoutParams();
+ ViewGroup.LayoutParams layout = mFocusIndicatorRotateLayout.getLayoutParams();
layout.width = len;
layout.height = len;
+ // Show only focus indicator or face indicator.
+ boolean faceExists = (mFaceView != null && mFaceView.faceExists());
+ FocusIndicator focusIndicator = (faceExists) ? mFaceView : mFocusIndicator;
+
if (mState == STATE_IDLE) {
if (mTapArea == null) {
- mFocusRectangle.clear();
+ focusIndicator.clear();
} else {
- // Users touch on the preview and the rectangle indicates the
+ // Users touch on the preview and the indicator represents the
// metering area. Either focus area is not supported or
// autoFocus call is not required.
- mFocusRectangle.showStart();
+ focusIndicator.showStart();
}
- return;
- }
-
- // Do not show focus rectangle if there is any face rectangle.
- if (mFaceView != null && mFaceView.faceExists()) return;
-
- if (mState == STATE_FOCUSING || mState == STATE_FOCUSING_SNAP_ON_FINISH) {
- mFocusRectangle.showStart();
+ } else if (mState == STATE_FOCUSING || mState == STATE_FOCUSING_SNAP_ON_FINISH) {
+ focusIndicator.showStart();
} else if (mState == STATE_SUCCESS) {
- mFocusRectangle.showSuccess();
+ focusIndicator.showSuccess();
} else if (mState == STATE_FAIL) {
- mFocusRectangle.showFail();
+ focusIndicator.showFail();
}
}
public void resetTouchFocus() {
if (!mInitialized) return;
- // Put focus rectangle to the center.
+ // Put focus indicator to the center.
RelativeLayout.LayoutParams p =
- (RelativeLayout.LayoutParams) mFocusRectangleRotateLayout.getLayoutParams();
+ (RelativeLayout.LayoutParams) mFocusIndicatorRotateLayout.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/FaceView.java b/src/com/android/camera/ui/FaceView.java
index d5ebe6f..1ad9dfe 100644
--- a/src/com/android/camera/ui/FaceView.java
+++ b/src/com/android/camera/ui/FaceView.java
@@ -29,7 +29,7 @@ import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
-public class FaceView extends View {
+public class FaceView extends View implements FocusIndicator {
private final String TAG = "FaceView";
private final boolean LOGV = false;
private int mDisplayOrientation;
@@ -38,11 +38,17 @@ public class FaceView extends View {
private Matrix mMatrix = new Matrix();
private RectF mRect = new RectF();
private Face[] mFaces;
- private Drawable mFaceRect;
+ private Drawable mFaceIndicator;
+ private final Drawable mDrawableFocusing;
+ private final Drawable mDrawableFocused;
+ private final Drawable mDrawableFocusFailed;
public FaceView(Context context, AttributeSet attrs) {
super(context, attrs);
- mFaceRect = getResources().getDrawable(R.drawable.ic_focus_focusing);
+ mDrawableFocusing = getResources().getDrawable(R.drawable.ic_focus_focusing);
+ mDrawableFocused = getResources().getDrawable(R.drawable.ic_focus_face_focused);
+ mDrawableFocusFailed = getResources().getDrawable(R.drawable.ic_focus_failed);
+ mFaceIndicator = mDrawableFocusing;
}
public void setFaces(Face[] faces) {
@@ -66,7 +72,29 @@ public class FaceView extends View {
return (mFaces != null && mFaces.length > 0);
}
- public void clearFaces() {
+ @Override
+ public void showStart() {
+ mFaceIndicator = mDrawableFocusing;
+ invalidate();
+ }
+
+ @Override
+ public void showSuccess() {
+ mFaceIndicator = mDrawableFocused;
+ invalidate();
+ }
+
+ @Override
+ public void showFail() {
+ mFaceIndicator = mDrawableFocusFailed;
+ invalidate();
+ }
+
+ @Override
+ public void clear() {
+ // Face indicator is displayed during preview. Do not clear the
+ // drawable.
+ mFaceIndicator = mDrawableFocusing;
mFaces = null;
invalidate();
}
@@ -98,9 +126,9 @@ public class FaceView extends View {
mMatrix.mapRect(mRect);
if (LOGV) dumpRect(mRect, "Transformed rect");
- mFaceRect.setBounds(Math.round(mRect.left), Math.round(mRect.top),
+ mFaceIndicator.setBounds(Math.round(mRect.left), Math.round(mRect.top),
Math.round(mRect.right), Math.round(mRect.bottom));
- mFaceRect.draw(canvas);
+ mFaceIndicator.draw(canvas);
}
}
super.onDraw(canvas);
diff --git a/src/com/android/camera/ui/FocusIndicator.java b/src/com/android/camera/ui/FocusIndicator.java
new file mode 100644
index 0000000..d7f78aa
--- /dev/null
+++ b/src/com/android/camera/ui/FocusIndicator.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+package com.android.camera.ui;
+
+public interface FocusIndicator {
+ public void showStart();
+ public void showSuccess();
+ public void showFail();
+ public void clear();
+}
diff --git a/src/com/android/camera/ui/FocusRectangle.java b/src/com/android/camera/ui/FocusIndicatorView.java
index 7deb3bc..48a74df 100644
--- a/src/com/android/camera/ui/FocusRectangle.java
+++ b/src/com/android/camera/ui/FocusIndicatorView.java
@@ -22,9 +22,9 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
-// A square that indicates the focus area or the metering area.
-public class FocusRectangle extends View {
- public FocusRectangle(Context context, AttributeSet attrs) {
+// A view that indicates the focus area or the metering area.
+public class FocusIndicatorView extends View implements FocusIndicator {
+ public FocusIndicatorView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -32,18 +32,22 @@ public class FocusRectangle extends View {
setBackgroundDrawable(getResources().getDrawable(resid));
}
+ @Override
public void showStart() {
setDrawable(R.drawable.ic_focus_focusing);
}
+ @Override
public void showSuccess() {
setDrawable(R.drawable.ic_focus_focused);
}
+ @Override
public void showFail() {
setDrawable(R.drawable.ic_focus_failed);
}
+ @Override
public void clear() {
setBackgroundDrawable(null);
}