summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/widget
diff options
context:
space:
mode:
authorSenpo Hu <senpo@google.com>2015-02-02 12:41:57 -0800
committerSenpo Hu <senpo@google.com>2015-02-04 15:59:06 -0800
commit54ac03ba6ae3e739df74c6d9e35fda9017be07d7 (patch)
tree69ad40b31892176258bd48e340e1d57828bb8c0c /src/com/android/camera/widget
parent67d715c632d3d8261623974247f91fda65c06ebc (diff)
downloadandroid_packages_apps_Camera2-54ac03ba6ae3e739df74c6d9e35fda9017be07d7.tar.gz
android_packages_apps_Camera2-54ac03ba6ae3e739df74c6d9e35fda9017be07d7.tar.bz2
android_packages_apps_Camera2-54ac03ba6ae3e739df74c6d9e35fda9017be07d7.zip
Adjust capture indicator position while open/close mode options.
This CL also fixes the layout issue in landscape mode when mode option indicators are visible. Bug: 18866551 Bug: 18317565 Bug: 18905659 Change-Id: I34ca5aa77aa9d37a7f0ad3d2d7efbed92fe94f2b
Diffstat (limited to 'src/com/android/camera/widget')
-rw-r--r--src/com/android/camera/widget/ModeOptions.java49
-rw-r--r--src/com/android/camera/widget/ModeOptionsOverlay.java28
-rw-r--r--src/com/android/camera/widget/RoundedThumbnailView.java65
3 files changed, 90 insertions, 52 deletions
diff --git a/src/com/android/camera/widget/ModeOptions.java b/src/com/android/camera/widget/ModeOptions.java
index 118359442..647de6bb7 100644
--- a/src/com/android/camera/widget/ModeOptions.java
+++ b/src/com/android/camera/widget/ModeOptions.java
@@ -15,6 +15,8 @@
*/
package com.android.camera.widget;
+import com.google.common.base.Optional;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
@@ -55,7 +57,7 @@ public class ModeOptions extends FrameLayout {
private static final int RADIUS_ANIMATION_TIME = 250;
private static final int SHOW_ALPHA_ANIMATION_TIME = 350;
private static final int HIDE_ALPHA_ANIMATION_TIME = 200;
- private static final int PADDING_ANIMATION_TIME = 350;
+ public static final int PADDING_ANIMATION_TIME = 350;
private ViewGroup mMainBar;
private ViewGroup mActiveBar;
@@ -66,8 +68,47 @@ public class ModeOptions extends FrameLayout {
private boolean mIsPortrait;
private float mRadius = 0f;
+ /**
+ * A class implementing this interface will receive callback events from
+ * mode options.
+ */
+ public interface Listener {
+ /**
+ * Called when about to start animating the mode options from hidden
+ * to visible.
+ */
+ public void onBeginToShowModeOptions();
+
+ /**
+ * Called when about to start animating the mode options from visible
+ * to hidden.
+ */
+ public void onBeginToHideModeOptions();
+ }
+
+ /** The listener. */
+ private Optional<Listener> mListener;
+
public ModeOptions(Context context, AttributeSet attrs) {
super(context, attrs);
+ mListener = Optional.absent();
+ }
+
+ /**
+ * Whether the mode options is hidden or in the middle of fading
+ * out.
+ */
+ public boolean isHiddenOrHiding() {
+ return mIsHiddenOrHiding;
+ }
+
+ /**
+ * Sets the listener.
+ *
+ * @param listener The listener to be set.
+ */
+ public void setListener(Listener listener) {
+ mListener = Optional.of(listener);
}
public void setViewToShowHide(View v) {
@@ -346,6 +387,9 @@ public class ModeOptions extends FrameLayout {
mVisibleAnimator.end();
setVisibility(View.VISIBLE);
mVisibleAnimator.start();
+ if (mListener.isPresent()) {
+ mListener.get().onBeginToShowModeOptions();
+ }
}
mIsHiddenOrHiding = false;
}
@@ -355,6 +399,9 @@ public class ModeOptions extends FrameLayout {
mVisibleAnimator.cancel();
mHiddenAnimator.end();
mHiddenAnimator.start();
+ if (mListener.isPresent()) {
+ mListener.get().onBeginToHideModeOptions();
+ }
}
mIsHiddenOrHiding = true;
}
diff --git a/src/com/android/camera/widget/ModeOptionsOverlay.java b/src/com/android/camera/widget/ModeOptionsOverlay.java
index a4a443495..c38360d43 100644
--- a/src/com/android/camera/widget/ModeOptionsOverlay.java
+++ b/src/com/android/camera/widget/ModeOptionsOverlay.java
@@ -46,8 +46,8 @@ public class ModeOptionsOverlay extends FrameLayout
private final static Log.Tag TAG = new Log.Tag("ModeOptionsOverlay");
private static final int BOTTOMBAR_OPTIONS_TIMEOUT_MS = 2000;
- private final static int BOTTOM_RIGHT = Gravity.BOTTOM | Gravity.RIGHT;
- private final static int TOP_RIGHT = Gravity.TOP | Gravity.RIGHT;
+ private static final int BOTTOM_RIGHT = Gravity.BOTTOM | Gravity.RIGHT;
+ private static final int TOP_RIGHT = Gravity.TOP | Gravity.RIGHT;
private ModeOptions mModeOptions;
// need a reference to set the onClickListener and fix the layout gravity on orientation change
@@ -61,6 +61,21 @@ public class ModeOptionsOverlay extends FrameLayout
}
/**
+ * Whether the mode options are hidden.
+ */
+ public boolean isModeOptionsHidden() {
+ return mModeOptions.isHiddenOrHiding();
+ }
+
+ /**
+ * Gets the current width of the mode options toggle including the three dots and various mode
+ * option indicators.
+ */
+ public float getModeOptionsToggleWidth() {
+ return mModeOptionsToggle.getWidth();
+ }
+
+ /**
* Sets a capture layout helper to query layout rect from.
*/
public void setCaptureLayoutHelper(CaptureLayoutHelper helper) {
@@ -71,6 +86,15 @@ public class ModeOptionsOverlay extends FrameLayout
mModeOptionsToggle.setClickable(clickable);
}
+ /**
+ * Sets the mode options listener.
+ *
+ * @param listener The listener to be set.
+ */
+ public void setModeOptionsListener(ModeOptions.Listener listener) {
+ mModeOptions.setListener(listener);
+ }
+
@Override
public void onFinishInflate() {
mModeOptions = (ModeOptions) findViewById(R.id.mode_options);
diff --git a/src/com/android/camera/widget/RoundedThumbnailView.java b/src/com/android/camera/widget/RoundedThumbnailView.java
index d6a02f875..ca5ffe62c 100644
--- a/src/com/android/camera/widget/RoundedThumbnailView.java
+++ b/src/com/android/camera/widget/RoundedThumbnailView.java
@@ -23,7 +23,6 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.content.Context;
-import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
@@ -36,13 +35,12 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AnimationUtils;
-import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import com.android.camera.async.MainThread;
import com.android.camera.debug.Log;
+import com.android.camera.ui.motion.InterpolatorHelper;
import com.android.camera.util.ApiHelper;
-import com.android.camera.util.CameraUtil;
import com.android.camera2.R;
import com.google.common.base.Optional;
@@ -226,7 +224,6 @@ public class RoundedThumbnailView extends View {
setClickable(true);
setOnClickListener(mOnClickListener);
- // TODO: Adjust layout when mode option overlay is visible.
mThumbnailPadding = getResources().getDimension(R.dimen.rounded_thumbnail_padding);
// Load thumbnail pop-out effect constants.
@@ -331,7 +328,6 @@ public class RoundedThumbnailView extends View {
centerX,
centerY,
thumbnailPaint);
-
}
// Draw the reveal while circle.
@@ -370,44 +366,21 @@ public class RoundedThumbnailView extends View {
}
/**
- * Calculates the desired layout of capture indicator.
+ * Gets the padding size with mode options and preview edges.
*
- * @param parentRect The bound of the view which contains capture indicator.
- * @param uncoveredPreviewRect The uncovered preview bound which contains mode option
- * overlay and capture indicator.
- * @return the desired view bound for capture indicator.
+ * @return The padding size with mode options and preview edges.
*/
- public RectF getDesiredLayout(RectF parentRect, RectF uncoveredPreviewRect) {
- float parentViewWidth = parentRect.right - parentRect.left;
- float x = 0;
- float y = 0;
-
- // The view bound is based on the maximal ripple ring diameter. This is the diff of maximal
- // ripple ring radius and the final thumbnail radius.
- float radius_diff_max_normal = (mRippleRingDiameterEnd - mThumbnailShrinkDiameterEnd) / 2;
- float modeSwitchThreeDotsDiameter = mThumbnailShrinkDiameterEnd;
- float modeSwitchThreeDotsBottomPadding = mThumbnailPadding;
-
- int orientation = getResources().getConfiguration().orientation;
- int rotation = CameraUtil.getDisplayRotation();
- if (orientation == Configuration.ORIENTATION_PORTRAIT) {
- // The view finder of 16:9 aspect ratio might have a black padding.
- float previewRightEdgeGap =
- parentRect.right - uncoveredPreviewRect.right;
- x = parentViewWidth - previewRightEdgeGap - mThumbnailPadding -
- mThumbnailShrinkDiameterEnd - radius_diff_max_normal;
- y = uncoveredPreviewRect.bottom;
- y -= modeSwitchThreeDotsBottomPadding + modeSwitchThreeDotsDiameter +
- mThumbnailPadding + mThumbnailShrinkDiameterEnd + radius_diff_max_normal;
- }
- if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
- float previewTopEdgeGap = uncoveredPreviewRect.top;
- x = uncoveredPreviewRect.right;
- x -= modeSwitchThreeDotsBottomPadding + modeSwitchThreeDotsDiameter +
- mThumbnailPadding + mThumbnailShrinkDiameterEnd + radius_diff_max_normal;
- y = previewTopEdgeGap + mThumbnailPadding - radius_diff_max_normal;
- }
- return new RectF(x, y, x + mRippleRingDiameterEnd, y + mRippleRingDiameterEnd);
+ public float getThumbnailPadding() {
+ return mThumbnailPadding;
+ }
+
+ /**
+ * Gets the diameter of the thumbnail image after the revealing animation.
+ *
+ * @return The diameter of the thumbnail image after the revealing animation.
+ */
+ public float getThumbnailFinalDiameter() {
+ return mThumbnailShrinkDiameterEnd;
}
/**
@@ -559,14 +532,8 @@ public class RoundedThumbnailView extends View {
if (mRippleAnimator == null) {
// Ripple effect uses linear_out_slow_in interpolator.
- Interpolator rippleInterpolator;
- if (ApiHelper.isLOrHigher()) {
- // Both phases use fast_out_flow_in interpolator.
- rippleInterpolator = AnimationUtils.loadInterpolator(
- getContext(), android.R.interpolator.linear_out_slow_in);
- } else {
- rippleInterpolator = new DecelerateInterpolator();
- }
+ Interpolator rippleInterpolator =
+ InterpolatorHelper.getLinearOutSlowInInterpolator(getContext());
// When start shrinking the thumbnail, a ripple effect is triggered at the same time.
mRippleAnimator =