diff options
author | Tony Wickham <twickham@google.com> | 2017-01-23 11:47:51 -0800 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2017-01-25 11:21:47 -0800 |
commit | 540913eadf39f1e8632d2b6f0bc33aa635214198 (patch) | |
tree | d21e8d2212cdd053c2cca3e8f6236fb73cbe5e1e /src/com/android/launcher3/shortcuts/DeepShortcutView.java | |
parent | 43a2f4297893a70ea776f306d3527f05d36c66bd (diff) | |
download | android_packages_apps_Trebuchet-540913eadf39f1e8632d2b6f0bc33aa635214198.tar.gz android_packages_apps_Trebuchet-540913eadf39f1e8632d2b6f0bc33aa635214198.tar.bz2 android_packages_apps_Trebuchet-540913eadf39f1e8632d2b6f0bc33aa635214198.zip |
Refactor DeepShortcutsContainer to PopupContainerWithArrow
- Also added PopupItemView, which takes animation logic from
DeepShortcutView, and which DeepShortcutView now extends.
- Renamed ShortcutFilter to PopupPopulator, which has support
for new item types (not yet used). Also moved populating
logic (e.g. UpdateShortcutChild Runnable) to PopupPopulator.
Bug: 32410600
Change-Id: Ib6e444ac7ca99c80ba438801c26e62d9542e0ad9
Diffstat (limited to 'src/com/android/launcher3/shortcuts/DeepShortcutView.java')
-rw-r--r-- | src/com/android/launcher3/shortcuts/DeepShortcutView.java | 145 |
1 files changed, 5 insertions, 140 deletions
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutView.java b/src/com/android/launcher3/shortcuts/DeepShortcutView.java index 6e9810007..2f07c9ac9 100644 --- a/src/com/android/launcher3/shortcuts/DeepShortcutView.java +++ b/src/com/android/launcher3/shortcuts/DeepShortcutView.java @@ -16,37 +16,27 @@ package com.android.launcher3.shortcuts; -import android.animation.Animator; -import android.animation.ValueAnimator; import android.content.Context; -import android.graphics.Point; import android.graphics.Rect; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; -import android.widget.FrameLayout; import com.android.launcher3.Launcher; -import com.android.launcher3.LogAccelerateInterpolator; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; -import com.android.launcher3.Utilities; -import com.android.launcher3.util.PillRevealOutlineProvider; -import com.android.launcher3.util.PillWidthRevealOutlineProvider; +import com.android.launcher3.popup.PopupContainerWithArrow; +import com.android.launcher3.popup.PopupItemView; /** * A {@link android.widget.FrameLayout} that contains a {@link DeepShortcutView}. * This lets us animate the DeepShortcutView (icon and text) separately from the background. */ -public class DeepShortcutView extends FrameLayout implements ValueAnimator.AnimatorUpdateListener { - - private static final Point sTempPoint = new Point(); +public class DeepShortcutView extends PopupItemView { private final Rect mPillRect; private DeepShortcutTextView mBubbleText; - private View mIconView; - private float mOpenAnimationProgress; private ShortcutInfo mInfo; private ShortcutInfoCompat mDetail; @@ -68,7 +58,6 @@ public class DeepShortcutView extends FrameLayout implements ValueAnimator.Anima @Override protected void onFinishInflate() { super.onFinishInflate(); - mIconView = findViewById(R.id.deep_shortcut_icon); mBubbleText = (DeepShortcutTextView) findViewById(R.id.deep_shortcut); } @@ -91,8 +80,8 @@ public class DeepShortcutView extends FrameLayout implements ValueAnimator.Anima } /** package private **/ - void applyShortcutInfo(ShortcutInfo info, ShortcutInfoCompat detail, - DeepShortcutsContainer container) { + public void applyShortcutInfo(ShortcutInfo info, ShortcutInfoCompat detail, + PopupContainerWithArrow container) { mInfo = info; mDetail = detail; mBubbleText.applyFromShortcutInfo(info); @@ -127,128 +116,4 @@ public class DeepShortcutView extends FrameLayout implements ValueAnimator.Anima public View getIconView() { return mIconView; } - - /** - * Creates an animator to play when the shortcut container is being opened. - */ - public Animator createOpenAnimation(boolean isContainerAboveIcon, boolean pivotLeft) { - Point center = getIconCenter(); - ValueAnimator openAnimator = new ZoomRevealOutlineProvider(center.x, center.y, - mPillRect, this, mIconView, isContainerAboveIcon, pivotLeft) - .createRevealAnimator(this, false); - mOpenAnimationProgress = 0f; - openAnimator.addUpdateListener(this); - return openAnimator; - } - - @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - mOpenAnimationProgress = valueAnimator.getAnimatedFraction(); - } - - public boolean isOpenOrOpening() { - return mOpenAnimationProgress > 0; - } - - /** - * Creates an animator to play when the shortcut container is being closed. - */ - public Animator createCloseAnimation(boolean isContainerAboveIcon, boolean pivotLeft, - long duration) { - Point center = getIconCenter(); - ValueAnimator closeAnimator = new ZoomRevealOutlineProvider(center.x, center.y, - mPillRect, this, mIconView, isContainerAboveIcon, pivotLeft) - .createRevealAnimator(this, true); - // Scale down the duration and interpolator according to the progress - // that the open animation was at when the close started. - closeAnimator.setDuration((long) (duration * mOpenAnimationProgress)); - closeAnimator.setInterpolator(new CloseInterpolator(mOpenAnimationProgress)); - return closeAnimator; - } - - /** - * Creates an animator which clips the container to form a circle around the icon. - */ - public Animator collapseToIcon() { - int halfHeight = getMeasuredHeight() / 2; - int iconCenterX = getIconCenter().x; - return new PillWidthRevealOutlineProvider(mPillRect, - iconCenterX - halfHeight, iconCenterX + halfHeight) - .createRevealAnimator(this, true); - } - - /** - * Returns the position of the center of the icon relative to the container. - */ - public Point getIconCenter() { - sTempPoint.y = sTempPoint.x = getMeasuredHeight() / 2; - if (Utilities.isRtl(getResources())) { - sTempPoint.x = getMeasuredWidth() - sTempPoint.x; - } - return sTempPoint; - } - - /** - * Extension of {@link PillRevealOutlineProvider} which scales the icon based on the height. - */ - private static class ZoomRevealOutlineProvider extends PillRevealOutlineProvider { - - private final View mTranslateView; - private final View mZoomView; - - private final float mFullHeight; - private final float mTranslateYMultiplier; - - private final boolean mPivotLeft; - private final float mTranslateX; - - public ZoomRevealOutlineProvider(int x, int y, Rect pillRect, - View translateView, View zoomView, boolean isContainerAboveIcon, boolean pivotLeft) { - super(x, y, pillRect); - mTranslateView = translateView; - mZoomView = zoomView; - mFullHeight = pillRect.height(); - - mTranslateYMultiplier = isContainerAboveIcon ? 0.5f : -0.5f; - - mPivotLeft = pivotLeft; - mTranslateX = pivotLeft ? pillRect.height() / 2 : pillRect.right - pillRect.height() / 2; - } - - @Override - public void setProgress(float progress) { - super.setProgress(progress); - - mZoomView.setScaleX(progress); - mZoomView.setScaleY(progress); - - float height = mOutline.height(); - mTranslateView.setTranslationY(mTranslateYMultiplier * (mFullHeight - height)); - - float pivotX = mPivotLeft ? (mOutline.left + height / 2) : (mOutline.right - height / 2); - mTranslateView.setTranslationX(mTranslateX - pivotX); - } - } - - /** - * An interpolator that reverses the current open animation progress. - */ - private static class CloseInterpolator extends LogAccelerateInterpolator { - private float mStartProgress; - private float mRemainingProgress; - - /** - * @param openAnimationProgress The progress that the open interpolator ended at. - */ - public CloseInterpolator(float openAnimationProgress) { - super(100, 0); - mStartProgress = 1f - openAnimationProgress; - mRemainingProgress = openAnimationProgress; - } - - @Override - public float getInterpolation(float v) { - return mStartProgress + super.getInterpolation(v) * mRemainingProgress; - } - } } |