diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-05-22 16:24:40 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-05-23 15:55:51 -0700 |
commit | 7f28fd55ff383a80caf364408c5c15d978be6c8b (patch) | |
tree | f289883555da479a720c2b49bda250ff16804b3f /quickstep | |
parent | d5377ca4b331e4db72fcb51a7c0791ff5a1d6e02 (diff) | |
download | android_packages_apps_Trebuchet-7f28fd55ff383a80caf364408c5c15d978be6c8b.tar.gz android_packages_apps_Trebuchet-7f28fd55ff383a80caf364408c5c15d978be6c8b.tar.bz2 android_packages_apps_Trebuchet-7f28fd55ff383a80caf364408c5c15d978be6c8b.zip |
Increasing the overview size while in QuickScrub mode
Bug: 80139193
Change-Id: I19ea05d3cc083628364651e9d9f581fe1aaaeaaa
Diffstat (limited to 'quickstep')
10 files changed, 123 insertions, 91 deletions
diff --git a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java index a11625a34..da85990bb 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.uioverrides; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.quickstep.QuickScrubController; import com.android.quickstep.views.RecentsView; @@ -45,6 +46,15 @@ public class FastOverviewState extends OverviewState { @Override public float[] getOverviewScaleAndTranslationYFactor(Launcher launcher) { - return new float[] {1f, 0.5f}; + return new float[] {getOverviewScale(launcher.getDeviceProfile()), 0.5f}; + } + + public static float getOverviewScale(DeviceProfile dp) { + if (dp.isMultiWindowMode || dp.isVerticalBarLayout()) { + return 1f; + } + + // TODO: Calculate it dynamically based on available space + return 1.3f; } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java index e43b24a6a..e3aabd6c8 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.uioverrides; +import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherState.FAST_OVERVIEW; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE; @@ -24,7 +25,6 @@ import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_START_INTERPOLATOR; import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_TRANSLATION_Y_FACTOR; import static com.android.quickstep.views.LauncherRecentsView.TRANSLATION_Y_FACTOR; -import static com.android.quickstep.views.RecentsView.ADJACENT_SCALE; import static com.android.quickstep.views.RecentsViewContainer.CONTENT_ALPHA; import android.animation.ValueAnimator; @@ -59,7 +59,7 @@ public class RecentsViewStateController implements StateHandler { public void setState(LauncherState state) { mRecentsViewContainer.setContentAlpha(state.overviewUi ? 1 : 0); float[] scaleTranslationYFactor = state.getOverviewScaleAndTranslationYFactor(mLauncher); - mRecentsView.setAdjacentScale(scaleTranslationYFactor[0]); + SCALE_PROPERTY.set(mRecentsView, scaleTranslationYFactor[0]); mRecentsView.setTranslationYFactor(scaleTranslationYFactor[1]); if (state.overviewUi) { mRecentsView.updateEmptyMessage(); @@ -77,7 +77,7 @@ public class RecentsViewStateController implements StateHandler { PropertySetter setter = config.getPropertySetter(builder); float[] scaleTranslationYFactor = toState.getOverviewScaleAndTranslationYFactor(mLauncher); Interpolator scaleInterpolator = builder.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR); - setter.setFloat(mRecentsView, ADJACENT_SCALE, scaleTranslationYFactor[0], scaleInterpolator); + setter.setFloat(mRecentsView, SCALE_PROPERTY, scaleTranslationYFactor[0], scaleInterpolator); Interpolator transYInterpolator = scaleInterpolator; if (mLauncher.getStateManager().getState() == OVERVIEW && toState == FAST_OVERVIEW) { transYInterpolator = Interpolators.clampToProgress(QUICK_SCRUB_START_INTERPOLATOR, 0, diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java index 76820b6aa..d0c7b2117 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java @@ -19,6 +19,7 @@ package com.android.launcher3.uioverrides; import static android.view.View.VISIBLE; import static com.android.launcher3.AbstractFloatingView.TYPE_ALL; import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON; +import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; @@ -207,7 +208,7 @@ public class UiFactory { public static void prepareToShowOverview(Launcher launcher) { RecentsView overview = launcher.getOverviewPanel(); if (overview.getVisibility() != VISIBLE || overview.getContentAlpha() == 0) { - overview.setAdjacentScale(1.33f); + SCALE_PROPERTY.set(overview, 1.33f); } } diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java index ae0affee0..d47fec5fc 100644 --- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java +++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java @@ -20,6 +20,8 @@ import static com.android.launcher3.LauncherState.FAST_OVERVIEW; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS; import static com.android.launcher3.anim.Interpolators.LINEAR; +import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL; +import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_BACK; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_ROTATION; @@ -48,9 +50,12 @@ import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.dragndrop.DragLayer; +import com.android.launcher3.uioverrides.FastOverviewState; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; +import com.android.quickstep.TouchConsumer.InteractionType; import com.android.quickstep.util.LayoutUtils; +import com.android.quickstep.util.TransformedRect; import com.android.quickstep.util.RemoteAnimationProvider; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.quickstep.views.LauncherLayoutListener; @@ -83,7 +88,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { void onTransitionCancelled(T activity, boolean activityVisible); - int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect); + int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, + @InteractionType int interactionType, TransformedRect outRect); void onSwipeUpComplete(T activity); @@ -157,14 +163,18 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { } @Override - public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) { - LayoutUtils.calculateLauncherTaskSize(context, dp, outRect); + public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, + @InteractionType int interactionType, TransformedRect outRect) { + LayoutUtils.calculateLauncherTaskSize(context, dp, outRect.rect); + if (interactionType == INTERACTION_QUICK_SCRUB) { + outRect.scale = FastOverviewState.getOverviewScale(dp); + } if (dp.isVerticalBarLayout()) { Rect targetInsets = dp.getInsets(); int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right; return dp.hotseatBarSizePx + dp.hotseatBarSidePaddingPx + hotseatInset; } else { - return dp.heightPx - outRect.bottom; + return dp.heightPx - outRect.rect.bottom; } } @@ -204,9 +214,10 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { return new AnimationFactory() { @Override - public void createActivityController(long transitionLength) { + public void createActivityController(long transitionLength, + @InteractionType int interactionType) { createActivityControllerInternal(activity, activityVisible, startState, - transitionLength, callback); + transitionLength, interactionType, callback); } @Override @@ -218,13 +229,16 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { private void createActivityControllerInternal(Launcher activity, boolean wasVisible, LauncherState startState, long transitionLength, + @InteractionType int interactionType, Consumer<AnimatorPlaybackController> callback) { + LauncherState endState = interactionType == INTERACTION_QUICK_SCRUB + ? FAST_OVERVIEW : OVERVIEW; if (wasVisible) { DeviceProfile dp = activity.getDeviceProfile(); long accuracy = 2 * Math.max(dp.widthPx, dp.heightPx); activity.getStateManager().goToState(startState, false); callback.accept(activity.getStateManager() - .createAnimationToNewWorkspace(OVERVIEW, accuracy)); + .createAnimationToNewWorkspace(endState, accuracy)); return; } @@ -238,7 +252,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { float scrollRange = Math.max(controller.getShiftRange(), 1); float progressDelta = (transitionLength / scrollRange); - float endProgress = OVERVIEW.getVerticalProgress(activity); + float endProgress = endState.getVerticalProgress(activity); float startProgress = endProgress + progressDelta; ObjectAnimator shiftAnim = ObjectAnimator.ofFloat( controller, ALL_APPS_PROGRESS, startProgress, endProgress); @@ -381,14 +395,15 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { } @Override - public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) { - LayoutUtils.calculateFallbackTaskSize(context, dp, outRect); + public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, + @InteractionType int interactionType, TransformedRect outRect) { + LayoutUtils.calculateFallbackTaskSize(context, dp, outRect.rect); if (dp.isVerticalBarLayout()) { Rect targetInsets = dp.getInsets(); int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right; return dp.hotseatBarSizePx + dp.hotseatBarSidePaddingPx + hotseatInset; } else { - return dp.heightPx - outRect.bottom; + return dp.heightPx - outRect.rect.bottom; } } @@ -401,7 +416,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { public AnimationFactory prepareRecentsUI(RecentsActivity activity, boolean activityVisible, Consumer<AnimatorPlaybackController> callback) { if (activityVisible) { - return (transitionLength) -> { }; + return (transitionLength, interactionType) -> { }; } RecentsViewContainer rv = activity.getOverviewPanelContainer(); @@ -418,11 +433,12 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { rv.setContentAlpha(1); } createActivityController(getSwipeUpDestinationAndLength( - activity.getDeviceProfile(), activity, new Rect())); + activity.getDeviceProfile(), activity, INTERACTION_NORMAL, + new TransformedRect()), INTERACTION_NORMAL); } @Override - public void createActivityController(long transitionLength) { + public void createActivityController(long transitionLength, int interactionType) { if (!isAnimatingHome) { return; } @@ -543,7 +559,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { default void onRemoteAnimationReceived(RemoteAnimationTargetSet targets) { } - void createActivityController(long transitionLength); + void createActivityController(long transitionLength, @InteractionType int interactionType); default void onTransitionCancelled() { } } diff --git a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java index 23738fb25..a2aa4b947 100644 --- a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java +++ b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java @@ -326,10 +326,10 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC mPassedInitialSlop = true; } - notifyGestureStarted(); if (mInteractionHandler != null) { mInteractionHandler.updateInteractionType(interactionType); } + notifyGestureStarted(); } @Override diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index 7b2932383..41a45501d 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -21,6 +21,7 @@ import static android.content.Intent.ACTION_PACKAGE_REMOVED; import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR; +import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL; import static com.android.systemui.shared.system.ActivityManagerWrapper .CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import static com.android.systemui.shared.system.PackageManagerWrapper @@ -59,6 +60,7 @@ import com.android.quickstep.ActivityControlHelper.AnimationFactory; import com.android.quickstep.ActivityControlHelper.FallbackActivityControllerHelper; import com.android.quickstep.ActivityControlHelper.LauncherActivityControllerHelper; import com.android.quickstep.util.ClipAnimationHelper; +import com.android.quickstep.util.TransformedRect; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -282,7 +284,7 @@ public class OverviewCommandHelper { }); factory.onRemoteAnimationReceived(null); if (wasVisible) { - factory.createActivityController(RECENTS_LAUNCH_DURATION); + factory.createActivityController(RECENTS_LAUNCH_DURATION, INTERACTION_NORMAL); } mActivity = activity; mRecentsView = mActivity.getOverviewPanel(); @@ -342,9 +344,9 @@ public class OverviewCommandHelper { loc[0] + rootView.getWidth(), loc[1] + rootView.getHeight()); clipHelper.updateSource(homeBounds, runningTaskTarget); - Rect targetRect = new Rect(); - mHelper.getSwipeUpDestinationAndLength( - mActivity.getDeviceProfile(), mActivity, targetRect); + TransformedRect targetRect = new TransformedRect(); + mHelper.getSwipeUpDestinationAndLength(mActivity.getDeviceProfile(), mActivity, + INTERACTION_NORMAL, targetRect); clipHelper.updateTargetRect(targetRect); clipHelper.prepareAnimation(false /* isOpening */); diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index 84b217648..e93c80789 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -65,6 +65,7 @@ import com.android.quickstep.ActivityControlHelper.AnimationFactory; import com.android.quickstep.ActivityControlHelper.LayoutListener; import com.android.quickstep.TouchConsumer.InteractionType; import com.android.quickstep.util.ClipAnimationHelper; +import com.android.quickstep.util.TransformedRect; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; @@ -181,7 +182,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> { private LayoutListener mLayoutListener; private RecentsView mRecentsView; private QuickScrubController mQuickScrubController; - private AnimationFactory mAnimationFactory = (t) -> { }; + private AnimationFactory mAnimationFactory = (t, i) -> { }; private Runnable mLauncherDrawnCallback; @@ -302,9 +303,9 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> { private void initTransitionEndpoints(DeviceProfile dp) { mDp = dp; - Rect tempRect = new Rect(); + TransformedRect tempRect = new TransformedRect(); mTransitionDragLength = mActivityControlHelper - .getSwipeUpDestinationAndLength(dp, mContext, tempRect); + .getSwipeUpDestinationAndLength(dp, mContext, mInteractionType, tempRect); mClipAnimationHelper.updateTargetRect(tempRect); } @@ -488,7 +489,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> { */ public void buildAnimationController() { initTransitionEndpoints(mActivity.getDeviceProfile()); - mAnimationFactory.createActivityController(mTransitionDragLength); + mAnimationFactory.createActivityController(mTransitionDragLength, mInteractionType); } private void onAnimatorPlaybackControllerCreated(AnimatorPlaybackController anim) { @@ -793,13 +794,16 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> { int scrollForFirstTask = mRecentsView.getScrollForPage(0); int scrollForSecondTask = mRecentsView.getChildCount() > 1 ? mRecentsView.getScrollForPage(1) : scrollForFirstTask; - int offsetFromFirstTask = scrollForFirstTask - scrollForSecondTask; - final float interpolation; - if (mRecentsView.getWidth() == 0) { - interpolation = scrollForSecondTask == scrollForFirstTask ? 0 : 1; - } else { - interpolation = (float) offsetFromFirstTask / (mRecentsView.getWidth() / 2); - } + float offsetFromFirstTask = scrollForFirstTask - scrollForSecondTask; + + TransformedRect tempRect = new TransformedRect(); + mActivityControlHelper + .getSwipeUpDestinationAndLength(mDp, mContext, mInteractionType, tempRect); + float distanceToReachEdge = mDp.widthPx / 2 + tempRect.rect.width() / 2 + + mContext.getResources().getDimensionPixelSize(R.dimen.recents_page_spacing); + float interpolation = Math.min(1, + Math.abs(offsetFromFirstTask) / distanceToReachEdge); + mClipAnimationHelper.offsetTarget( firstTask.getCurveScaleForInterpolation(interpolation), offsetFromFirstTask, mActivityControlHelper.getTranslationYForQuickScrub(mActivity), diff --git a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java index 8c7f104a6..cc24f1d8a 100644 --- a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java +++ b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java @@ -80,6 +80,7 @@ public class ClipAnimationHelper { private final RectF mTmpRectF = new RectF(); private float mTargetScale = 1f; + private float mOffsetScale = 1f; private Interpolator mInterpolator = LINEAR; // We translate y slightly faster than the rest of the animation for quick scrub. private Interpolator mOffsetYInterpolator = LINEAR; @@ -106,11 +107,13 @@ public class ClipAnimationHelper { updateSourceStack(target); } - public void updateTargetRect(Rect targetRect) { + public void updateTargetRect(TransformedRect targetRect) { + mOffsetScale = targetRect.scale; mSourceRect.set(mSourceInsets.left, mSourceInsets.top, mSourceStackBounds.width() - mSourceInsets.right, mSourceStackBounds.height() - mSourceInsets.bottom); - mTargetRect.set(targetRect); + mTargetRect.set(targetRect.rect); + Utilities.scaleRectFAboutCenter(mTargetRect, targetRect.scale); mTargetRect.offset(mHomeStackBounds.left - mSourceStackBounds.left, mHomeStackBounds.top - mSourceStackBounds.top); @@ -145,7 +148,8 @@ public class ClipAnimationHelper { synchronized (mTargetOffset) { // Stay lined up with the center of the target, since it moves for quick scrub. - currentRect.offset(mTargetOffset.x * progress, mTargetOffset.y * offsetYProgress); + currentRect.offset(mTargetOffset.x * mOffsetScale * progress, + mTargetOffset.y * offsetYProgress); } mClipRect.left = (int) (mSourceWindowClipInsets.left * progress); @@ -219,8 +223,8 @@ public class ClipAnimationHelper { mSourceInsets.set(activity.getDeviceProfile().getInsets()); } - Rect targetRect = new Rect(); - dl.getDescendantRectRelativeToSelf(ttv, targetRect); + TransformedRect targetRect = new TransformedRect(); + dl.getDescendantRectRelativeToSelf(ttv, targetRect.rect); updateTargetRect(targetRect); // Transform the clip relative to the target rect. diff --git a/quickstep/src/com/android/quickstep/util/TransformedRect.java b/quickstep/src/com/android/quickstep/util/TransformedRect.java new file mode 100644 index 000000000..79f11e405 --- /dev/null +++ b/quickstep/src/com/android/quickstep/util/TransformedRect.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2018 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. + */ +package com.android.quickstep.util; + +import android.graphics.Rect; + +/** + * A wrapper around {@link Rect} with additional transformation properties + */ +public class TransformedRect { + + public final Rect rect = new Rect(); + public float scale = 1; + + public void set(TransformedRect transformedRect) { + rect.set(transformedRect.rect); + scale = transformedRect.scale; + } +} diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 186de3681..4f169fb47 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -47,7 +47,6 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.util.ArraySet; import android.util.AttributeSet; -import android.util.FloatProperty; import android.util.SparseBooleanArray; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -100,18 +99,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl private final Rect mTempRect = new Rect(); - public static final FloatProperty<RecentsView> ADJACENT_SCALE = - new FloatProperty<RecentsView>("adjacentScale") { - @Override - public void setValue(RecentsView recentsView, float v) { - recentsView.setAdjacentScale(v); - } - - @Override - public Float get(RecentsView recentsView) { - return recentsView.mAdjacentScale; - } - }; private static final int DISMISS_TASK_DURATION = 300; // The threshold at which we update the SystemUI flags when animating from the task into the app private static final float UPDATE_SYSUI_FLAGS_THRESHOLD = 0.6f; @@ -122,6 +109,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl private final QuickScrubController mQuickScrubController; private final float mFastFlingVelocity; private final RecentsModel mModel; + private final int mTaskTopMargin; private final ScrollState mScrollState = new ScrollState(); // Keeps track of the previously known visible tasks for purposes of loading/unloading task data @@ -232,8 +220,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl @ViewDebug.ExportedProperty(category = "launcher") private float mContentAlpha = 1; - @ViewDebug.ExportedProperty(category = "launcher") - private float mAdjacentScale = 1; // Keeps track of task views whose visual state should not be reset private ArraySet<TaskView> mIgnoreResetTaskViews = new ArraySet<>(); @@ -271,6 +257,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl mIsRtl = !Utilities.isRtl(getResources()); setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR); + mTaskTopMargin = getResources() + .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin); mEmptyIcon = context.getDrawable(R.drawable.ic_empty_recents); mEmptyIcon.setCallback(this); @@ -518,8 +506,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl DeviceProfile dp = mActivity.getDeviceProfile(); getTaskSize(dp, mTempRect); - mTempRect.top -= getResources() - .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin); + mTempRect.top -= mTaskTopMargin; setPadding(mTempRect.left - mInsets.left, mTempRect.top - mInsets.top, dp.availableWidthPx + mInsets.left - mTempRect.right, dp.availableHeightPx + mInsets.top - mTempRect.bottom); @@ -1038,36 +1025,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl updateClearAllButtonAlpha(); } - public void setAdjacentScale(float adjacentScale) { - if (mAdjacentScale == adjacentScale) { - return; - } - mAdjacentScale = adjacentScale; - TaskView currTask = getPageAt(mCurrentPage); - if (currTask == null) { - return; - } - currTask.setZoomScale(mAdjacentScale); - - if (mCurrentPage - 1 >= 0) { - TaskView adjacentTask = getPageAt(mCurrentPage - 1); - float[] scaleAndTranslation = getAdjacentScaleAndTranslation(currTask, adjacentTask, - mAdjacentScale, 0); - adjacentTask.setZoomScale(scaleAndTranslation[0]); - adjacentTask.setTranslationX(-scaleAndTranslation[1]); - adjacentTask.setTranslationY(scaleAndTranslation[2]); - } - if (mCurrentPage + 1 < getChildCount()) { - TaskView adjacentTask = getPageAt(mCurrentPage + 1); - float[] scaleAndTranslation = getAdjacentScaleAndTranslation(currTask, adjacentTask, - mAdjacentScale, 0); - adjacentTask.setZoomScale(scaleAndTranslation[0]); - adjacentTask.setTranslationX(scaleAndTranslation[1]); - adjacentTask.setTranslationY(scaleAndTranslation[2]); - } - } - - private float[] getAdjacentScaleAndTranslation(TaskView currTask, TaskView adjacentTask, + private float[] getAdjacentScaleAndTranslation(TaskView currTask, float currTaskToScale, float currTaskToTranslationY) { float displacement = currTask.getWidth() * (currTaskToScale - currTask.getCurveScale()); sTempFloatArray[0] = currTaskToScale; @@ -1080,7 +1038,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl public void onViewAdded(View child) { super.onViewAdded(child); child.setAlpha(mContentAlpha); - setAdjacentScale(mAdjacentScale); onChildViewsChanged(); } @@ -1106,6 +1063,12 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); updateEmptyStateUi(changed); + + // Set the pivot points to match the task preview center + setPivotY(((mInsets.top + getPaddingTop() + mTaskTopMargin) + + (getHeight() - mInsets.bottom - getPaddingBottom())) / 2); + setPivotX(((mInsets.left + getPaddingLeft()) + + (getWidth() - mInsets.right - getPaddingRight())) / 2); } private void updateEmptyStateUi(boolean sizeChanged) { @@ -1176,14 +1139,14 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl if (taskIndex - 1 >= 0) { TaskView adjacentTask = getPageAt(taskIndex - 1); float[] scaleAndTranslation = getAdjacentScaleAndTranslation(centerTask, - adjacentTask, toScale, toTranslationY); + toScale, toTranslationY); scaleAndTranslation[1] = -scaleAndTranslation[1]; anim.play(createAnimForChild(adjacentTask, scaleAndTranslation)); } if (taskIndex + 1 < getPageCount()) { TaskView adjacentTask = getPageAt(taskIndex + 1); float[] scaleAndTranslation = getAdjacentScaleAndTranslation(centerTask, - adjacentTask, toScale, toTranslationY); + toScale, toTranslationY); anim.play(createAnimForChild(adjacentTask, scaleAndTranslation)); } } else { |