OSDN Git Service

Update capture animation
authorMichael Kolb <kolby@google.com>
Tue, 30 Apr 2013 22:34:19 +0000 (15:34 -0700)
committerMichael Kolb <kolby@google.com>
Wed, 1 May 2013 18:48:02 +0000 (11:48 -0700)
  Bug: 8253060

Update preview thumb margins and size
Add touch target for thumbnail

Change-Id: I2b298de330834c42a55b4cb082148d971727f530

res/layout-land/camera_controls.xml
res/layout-port/camera_controls.xml
res/values-land/dimensions.xml
res/values-sw360dp-land/dimensions.xml [new file with mode: 0644]
res/values-sw360dp/dimensions.xml [new file with mode: 0644]
res/values-sw600dp/dimens.xml
src/com/android/camera/CaptureAnimManager.java
src/com/android/camera/PhotoModule.java
src/com/android/camera/PhotoUI.java
src/com/android/camera/ui/CameraControls.java

index e99c0cb..04841a0 100644 (file)
             android:focusable="true"
             android:scaleType="center"
             android:src="@drawable/btn_new_shutter" />
+
+        <View
+            android:id="@+id/preview_thumb"
+            android:visibility="invisible"
+            android:layout_width="@dimen/capture_size"
+            android:layout_height="@dimen/capture_size"
+            android:layout_gravity="top|right" />
+
 </com.android.camera.ui.CameraControls>
index 77a19e9..4ed9e63 100644 (file)
             android:scaleType="center"
             android:src="@drawable/btn_new_shutter" />
 
+        <View
+            android:id="@+id/preview_thumb"
+            android:visibility="invisible"
+            android:layout_width="@dimen/capture_size"
+            android:layout_height="@dimen/capture_size"
+            android:layout_gravity="top|right" />
+
 </com.android.camera.ui.CameraControls>
\ No newline at end of file
index b150179..3eae856 100644 (file)
@@ -16,5 +16,5 @@
 <resources>
     <!-- for manage cache bar -->
     <dimen name="manage_cache_bottom_height">39dp</dimen>
-    <dimen name="capture_margin_top">8dip</dimen>
+    <dimen name="capture_top_margin">0dip</dimen>
 </resources>
diff --git a/res/values-sw360dp-land/dimensions.xml b/res/values-sw360dp-land/dimensions.xml
new file mode 100644 (file)
index 0000000..fe3e6f5
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+<resources>
+    <dimen name="capture_margin_top">8dip</dimen>
+</resources>
diff --git a/res/values-sw360dp/dimensions.xml b/res/values-sw360dp/dimensions.xml
new file mode 100644 (file)
index 0000000..b18b934
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+<resources>
+    <dimen name="capture_margin_top">16dip</dimen>
+</resources>
index ce506cc..59d86d9 100644 (file)
@@ -20,4 +20,6 @@
     <dimen name="setting_item_icon_width">@dimen/setting_item_icon_width_large</dimen>
     <dimen name="onscreen_indicators_height">@dimen/onscreen_indicators_height_large</dimen>
     <dimen name="shutter_offset">-33dp</dimen>
+    <dimen name="capture_size">80dip</dimen>
+    <dimen name="capture_top_margin">16dip</dimen>
 </resources>
index b820ac9..f6e112d 100644 (file)
@@ -19,7 +19,6 @@ package com.android.camera;
 import android.content.res.Resources;
 import android.graphics.Color;
 import android.os.SystemClock;
-import android.util.Log;
 import android.view.animation.DecelerateInterpolator;
 import android.view.animation.Interpolator;
 
@@ -68,6 +67,10 @@ public class CaptureAnimManager {
     private int mSize;
     private Resources mResources;
 
+    public static int getAnimationDuration() {
+        return TIME_SLIDE2;
+    }
+
     /* preview: camera preview view.
      * review: view of picture just taken.
      */
@@ -124,7 +127,7 @@ public class CaptureAnimManager {
                 break;
             case 90:  // Preview is below.
                 mHoldX = x + mMarginTop;
-                mHoldY = y + mMarginRight + mSize;
+                mHoldY = y + mMarginRight;
                 break;
             case 180:  // Preview on the right.
                 mHoldX = x + mMarginRight;
index 4d3f7fb..5b35271 100644 (file)
@@ -105,6 +105,7 @@ public class PhotoModule
     private static final int START_PREVIEW_DONE = 10;
     private static final int OPEN_CAMERA_FAIL = 11;
     private static final int CAMERA_DISABLED = 12;
+    private static final int CAPTURE_ANIMATION_DONE = 13;
 
     // The subset of parameters we need to update in setCameraParameters().
     private static final int UPDATE_PARAM_INITIALIZE = 1;
@@ -398,6 +399,10 @@ public class PhotoModule
                             R.string.camera_disabled);
                     break;
                 }
+                case CAPTURE_ANIMATION_DONE: {
+                    mUI.enablePreviewThumb(false);
+                    break;
+                }
             }
         }
     }
@@ -809,7 +814,10 @@ public class PhotoModule
             if (ApiHelper.HAS_SURFACE_TEXTURE && !mIsImageCaptureIntent
                     && mActivity.mShowCameraAppView) {
                 // Finish capture animation
+                mHandler.removeMessages(CAPTURE_ANIMATION_DONE);
                 ((CameraScreenNail) mActivity.mCameraScreenNail).animateSlide();
+                mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE,
+                        CaptureAnimManager.getAnimationDuration());
             }
             mFocusManager.updateFocusUI(); // Ensure focus indicator is hidden.
             if (!mIsImageCaptureIntent) {
@@ -968,6 +976,9 @@ public class PhotoModule
                 && mActivity.mShowCameraAppView) {
             // Start capture animation.
             ((CameraScreenNail) mActivity.mCameraScreenNail).animateFlash(mDisplayRotation);
+            mUI.enablePreviewThumb(true);
+            mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE,
+                    CaptureAnimManager.getAnimationDuration());
         }
     }
 
index 0949104..bc43f47 100644 (file)
@@ -92,6 +92,7 @@ public class PhotoUI implements PieListener,
 
     private int mPreviewWidth = 0;
     private int mPreviewHeight = 0;
+    private View mPreviewThumb;
 
     private OnLayoutChangeListener mLayoutListener = new OnLayoutChangeListener() {
         @Override
@@ -173,6 +174,7 @@ public class PhotoUI implements PieListener,
         mGestures.setRenderOverlay(mRenderOverlay);
         mGestures.addTouchReceiver(mMenuButton);
         mGestures.addUnclickableArea(mBlocker);
+        enablePreviewThumb(false);
         // make sure to add touch targets for image capture
         if (mController.isImageCaptureIntent()) {
             if (mReviewCancelButton != null) {
@@ -201,6 +203,13 @@ public class PhotoUI implements PieListener,
 
     public void initializeControlByIntent() {
         mBlocker = mActivity.findViewById(R.id.blocker);
+        mPreviewThumb = mActivity.findViewById(R.id.preview_thumb);
+        mPreviewThumb.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                mActivity.gotoGallery();
+            }
+        });
         mMenuButton = mActivity.findViewById(R.id.menu);
         mMenuButton.setOnClickListener(new OnClickListener() {
             @Override
@@ -367,6 +376,16 @@ public class PhotoUI implements PieListener,
         if (!full && mCountDownView != null) mCountDownView.cancelCountDown();
     }
 
+    public void enablePreviewThumb(boolean enabled) {
+        if (enabled) {
+            mGestures.addTouchReceiver(mPreviewThumb);
+            mPreviewThumb.setVisibility(View.VISIBLE);
+        } else {
+            mGestures.removeTouchReceiver(mPreviewThumb);
+            mPreviewThumb.setVisibility(View.GONE);
+        }
+    }
+
     public boolean removeTopLevelPopup() {
         // Remove the top level popup or dialog box and return true if there's any
         if (mPopup != null) {
index 3a5fbde..e5b90dd 100644 (file)
@@ -21,7 +21,6 @@ import android.content.Context;
 import android.content.res.Configuration;
 import android.graphics.Rect;
 import android.util.AttributeSet;
-import android.util.Log;
 import android.view.Gravity;
 import android.view.View;
 import android.widget.FrameLayout;
@@ -38,6 +37,7 @@ public class CameraControls extends RotatableLayout {
     private View mSwitcher;
     private View mMenu;
     private View mIndicators;
+    private View mPreview;
 
     public CameraControls(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -61,6 +61,7 @@ public class CameraControls extends RotatableLayout {
         mShutter = findViewById(R.id.shutter_button);
         mMenu = findViewById(R.id.menu);
         mIndicators = findViewById(R.id.on_screen_indicators);
+        mPreview = findViewById(R.id.preview_thumb);
     }
 
     @Override
@@ -75,6 +76,7 @@ public class CameraControls extends RotatableLayout {
         toLeft(mSwitcher, l, t, r, b, orientation, rotation, shutter);
         toRight(mMenu, l, t, r, b, orientation, rotation, shutter);
         toRight(mIndicators, l, t, r, b, orientation, rotation, shutter);
+        topRight(mPreview, l, t, r, b, orientation, rotation);
         View retake = findViewById(R.id.btn_retake);
         if (retake != null) {
             Rect retakeRect = new Rect();
@@ -96,6 +98,7 @@ public class CameraControls extends RotatableLayout {
         }
         return rotation;
     }
+
     private void center(View v, int l, int t, int r, int b, int orientation, int rotation, Rect result) {
         FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
         int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
@@ -209,6 +212,13 @@ public class CameraControls extends RotatableLayout {
         v.layout(result.left, result.top, result.right, result.bottom);
     }
 
+    private void topRight(View v, int l, int t, int r, int b, int orientation, int rotation) {
+        // layout using the specific margins; the rotation code messes up the others
+        int mt = getContext().getResources().getDimensionPixelSize(R.dimen.capture_margin_top);
+        int mr = getContext().getResources().getDimensionPixelSize(R.dimen.capture_margin_right);
+        v.layout(r - v.getMeasuredWidth() - mr, t + mt, r - mr, t + mt + v.getMeasuredHeight());
+    }
+
     // In reverse landscape and reverse portrait, camera controls will be laid out
     // on the wrong side of the screen. We need to make adjustment to move the controls
     // to the USB side