Update capture animation
Bug: 8253060
Update preview thumb margins and size
Add touch target for thumbnail
Change-Id: I2b298de330834c42a55b4cb082148d971727f530
diff --git a/res/layout-land/camera_controls.xml b/res/layout-land/camera_controls.xml
index e99c0cb..04841a0 100644
--- a/res/layout-land/camera_controls.xml
+++ b/res/layout-land/camera_controls.xml
@@ -57,4 +57,12 @@
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>
diff --git a/res/layout-port/camera_controls.xml b/res/layout-port/camera_controls.xml
index 77a19e9..4ed9e63 100644
--- a/res/layout-port/camera_controls.xml
+++ b/res/layout-port/camera_controls.xml
@@ -58,4 +58,11 @@
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
diff --git a/res/values-land/dimensions.xml b/res/values-land/dimensions.xml
index b150179..3eae856 100644
--- a/res/values-land/dimensions.xml
+++ b/res/values-land/dimensions.xml
@@ -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
index 0000000..fe3e6f5
--- /dev/null
+++ b/res/values-sw360dp-land/dimensions.xml
@@ -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
index 0000000..b18b934
--- /dev/null
+++ b/res/values-sw360dp/dimensions.xml
@@ -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>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index ce506cc..59d86d9 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -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>
diff --git a/src/com/android/camera/CaptureAnimManager.java b/src/com/android/camera/CaptureAnimManager.java
index b820ac9..f6e112d 100644
--- a/src/com/android/camera/CaptureAnimManager.java
+++ b/src/com/android/camera/CaptureAnimManager.java
@@ -19,7 +19,6 @@
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 @@
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 @@
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;
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 4d3f7fb..5b35271 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -105,6 +105,7 @@
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 @@
R.string.camera_disabled);
break;
}
+ case CAPTURE_ANIMATION_DONE: {
+ mUI.enablePreviewThumb(false);
+ break;
+ }
}
}
}
@@ -809,7 +814,10 @@
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 @@
&& mActivity.mShowCameraAppView) {
// Start capture animation.
((CameraScreenNail) mActivity.mCameraScreenNail).animateFlash(mDisplayRotation);
+ mUI.enablePreviewThumb(true);
+ mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE,
+ CaptureAnimManager.getAnimationDuration());
}
}
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 0949104..bc43f47 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -92,6 +92,7 @@
private int mPreviewWidth = 0;
private int mPreviewHeight = 0;
+ private View mPreviewThumb;
private OnLayoutChangeListener mLayoutListener = new OnLayoutChangeListener() {
@Override
@@ -173,6 +174,7 @@
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 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 @@
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) {
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index 3a5fbde..e5b90dd 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -21,7 +21,6 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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