OSDN Git Service

New focus indicator for touch to focus
authorDoris Liu <tianliu@google.com>
Tue, 11 Feb 2014 01:14:06 +0000 (17:14 -0800)
committerDoris Liu <tianliu@google.com>
Tue, 11 Feb 2014 01:17:31 +0000 (17:17 -0800)
Bug: 12954917
Change-Id: I103c1071c81c48bbbd3a90cce2e2a39df4bd633e

res/drawable/focus_outer_ring.xml [new file with mode: 0644]
res/values/colors.xml
res/values/dimens.xml
src/com/android/camera/ui/FocusOverlay.java

diff --git a/res/drawable/focus_outer_ring.xml b/res/drawable/focus_outer_ring.xml
new file mode 100644 (file)
index 0000000..632fb44
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<shape
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="ring"
+    android:thickness="2dp"
+    android:useLevel="false"
+    android:innerRadius="46dp" >
+
+    <solid
+        android:color="@color/focus_outer_ring_color"/>
+
+    <size
+        android:width="@dimen/focus_outer_ring_size"
+        android:height="@dimen/focus_outer_ring_size" />
+</shape>
\ No newline at end of file
index efeab76..ce54945 100644 (file)
@@ -95,4 +95,5 @@
     <color name="indicators_background_color">#4c000000</color>
 
     <color name="grid_line">#99ffffff</color>
+    <color name="focus_outer_ring_color">#4CFFFFFF</color>
 </resources>
index 0a2a694..16f7760 100644 (file)
     <dimen name="video_capture_circle_diameter">64dp</dimen>
 
     <dimen name="grid_line_width">1dp</dimen>
+    <dimen name="focus_outer_ring_size">96dp</dimen>
+    <dimen name="focus_inner_ring_size">50dp</dimen>
 
 </resources>
index 1b5dcef..d939e19 100644 (file)
@@ -36,19 +36,23 @@ public class FocusOverlay extends View implements FocusOverlayManager.FocusUI {
     private final static int FOCUS_INDICATOR_ROTATION_DEGREES = 50;
 
     private final Drawable mFocusIndicator;
+    private final Drawable mFocusOuterRing;
     private final Rect mBounds = new Rect();
     private final ValueAnimator mFocusAnimation = new ValueAnimator();
 
     private int mPositionX;
     private int mPositionY;
     private int mAngle;
-    // TODO: make this dp in dimens.xml when UI has a spec
-    private final int mFocusIndicatorSize = 200;
+    private final int mFocusIndicatorSize;
     private boolean mShowIndicator;
+    private final int mFocusOuterRingSize;
 
     public FocusOverlay(Context context, AttributeSet attrs) {
         super(context, attrs);
         mFocusIndicator = getResources().getDrawable(R.drawable.focus);
+        mFocusIndicatorSize = getResources().getDimensionPixelSize(R.dimen.focus_inner_ring_size);
+        mFocusOuterRing = getResources().getDrawable(R.drawable.focus_outer_ring);
+        mFocusOuterRingSize = getResources().getDimensionPixelSize(R.dimen.focus_outer_ring_size);
     }
 
     @Override
@@ -69,6 +73,8 @@ public class FocusOverlay extends View implements FocusOverlayManager.FocusUI {
         mBounds.set(x - mFocusIndicatorSize / 2, y - mFocusIndicatorSize / 2,
                 x + mFocusIndicatorSize / 2, y + mFocusIndicatorSize / 2);
         mFocusIndicator.setBounds(mBounds);
+        mFocusOuterRing.setBounds(x - mFocusOuterRingSize / 2, y - mFocusOuterRingSize / 2,
+                x + mFocusOuterRingSize / 2, y + mFocusOuterRingSize / 2);
     }
 
     @Override
@@ -115,6 +121,7 @@ public class FocusOverlay extends View implements FocusOverlayManager.FocusUI {
         super.onDraw(canvas);
 
         if (mShowIndicator) {
+            mFocusOuterRing.draw(canvas);
             canvas.save();
             canvas.rotate(mAngle, mPositionX, mPositionY);
             mFocusIndicator.draw(canvas);