diff options
author | Tony <twickham@google.com> | 2019-03-25 10:23:39 -0500 |
---|---|---|
committer | Tony <twickham@google.com> | 2019-03-28 15:09:25 -0500 |
commit | e4c2e2b86cf74013efc52f81ac8b1b6d85822646 (patch) | |
tree | 0d59a22b28e87caae6573b7348c0cbb6d341789b | |
parent | 794a68e99850266d92b6daf25793b42308a66a8e (diff) | |
download | android_packages_apps_Trebuchet-e4c2e2b86cf74013efc52f81ac8b1b6d85822646.tar.gz android_packages_apps_Trebuchet-e4c2e2b86cf74013efc52f81ac8b1b6d85822646.tar.bz2 android_packages_apps_Trebuchet-e4c2e2b86cf74013efc52f81ac8b1b6d85822646.zip |
Add QuickSwitchTouchController on home
- Added QuickSwitchState, which we animate to when swiping right
on the nav bar from NORMAL state
- Task launches when the state transition to QuickSwitchState ends
Bug: 126596417
Change-Id: Id66650401d817703fc6d044fb26a25cccbc07e11
15 files changed, 304 insertions, 28 deletions
diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java index eba7f5f22..6730e975e 100644 --- a/go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -100,4 +100,8 @@ public class OverviewState extends LauncherState { public static OverviewState newPeekState(int id) { return new OverviewState(id); } + + public static OverviewState newSwitchState(int id) { + return new OverviewState(id); + } } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java index f5702a73c..d0a2f2716 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java @@ -34,6 +34,7 @@ import com.android.launcher3.uioverrides.touchcontrollers.LandscapeEdgeSwipeCont import com.android.launcher3.uioverrides.touchcontrollers.OverviewToAllAppsTouchController; import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController; import com.android.launcher3.uioverrides.touchcontrollers.StatusBarTouchController; +import com.android.launcher3.uioverrides.touchcontrollers.QuickSwitchTouchController; import com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.UiThreadHelper; @@ -66,6 +67,7 @@ public abstract class RecentsUiFactory { list.add(launcher.getDragController()); if (swipeUpToHome) { + list.add(new QuickSwitchTouchController(launcher)); list.add(new FlingAndHoldTouchController(launcher)); } else { if (launcher.getDeviceProfile().isVerticalBarLayout()) { @@ -74,6 +76,9 @@ public abstract class RecentsUiFactory { } else { list.add(new PortraitStatesTouchController(launcher, swipeUpEnabled /* allowDragToOverview */)); + if (swipeUpEnabled) { + list.add(new QuickSwitchTouchController(launcher)); + } } } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java index 2294d6721..94c154574 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -18,6 +18,7 @@ package com.android.launcher3.uioverrides.states; import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS; import static com.android.launcher3.anim.Interpolators.DEACCEL_2; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; +import static com.android.launcher3.logging.LoggerUtils.getTargetStr; import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; import static com.android.launcher3.states.RotationHelper.REQUEST_ROTATE; @@ -52,7 +53,11 @@ public class OverviewState extends LauncherState { } protected OverviewState(int id, int transitionDuration, int stateFlags) { - super(id, ContainerType.TASKSWITCHER, transitionDuration, stateFlags); + this(id, ContainerType.TASKSWITCHER, transitionDuration, stateFlags); + } + + protected OverviewState(int id, int logContainer, int transitionDuration, int stateFlags) { + super(id, logContainer, transitionDuration, stateFlags); } @Override @@ -92,6 +97,7 @@ public class OverviewState extends LauncherState { DiscoveryBounce.showForOverviewIfNeeded(launcher); } + @Override public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) { return new PageAlphaProvider(DEACCEL_2) { @Override @@ -159,4 +165,8 @@ public class OverviewState extends LauncherState { public static OverviewState newPeekState(int id) { return new OverviewPeekState(id); } + + public static OverviewState newSwitchState(int id) { + return new QuickSwitchState(id); + } } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java new file mode 100644 index 000000000..fa07e27a9 --- /dev/null +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2019 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.launcher3.uioverrides.states; + +import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS; + +import android.graphics.Rect; + +import com.android.launcher3.Launcher; +import com.android.launcher3.userevent.nano.LauncherLogProto; +import com.android.quickstep.util.ClipAnimationHelper; +import com.android.quickstep.views.RecentsView; +import com.android.quickstep.views.TaskThumbnailView; +import com.android.quickstep.views.TaskView; + +/** + * State to indicate we are about to launch a recent task. Note that this state is only used when + * quick switching from launcher; quick switching from an app uses WindowTransformSwipeHelper. + * @see com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget#NEW_TASK + */ +public class QuickSwitchState extends OverviewState { + private static final int STATE_FLAGS = + FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_DISABLE_ACCESSIBILITY; + + public QuickSwitchState(int id) { + super(id, LauncherLogProto.ContainerType.APP, OVERVIEW_TRANSITION_MS, STATE_FLAGS); + } + + @Override + public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) { + RecentsView recentsView = launcher.getOverviewPanel(); + if (recentsView.getTaskViewCount() == 0) { + return super.getOverviewScaleAndTranslation(launcher); + } + // Compute scale and translation y such that the most recent task view fills the screen. + TaskThumbnailView dummyThumbnail = recentsView.getTaskViewAt(0).getThumbnail(); + ClipAnimationHelper clipAnimationHelper = new ClipAnimationHelper(launcher); + clipAnimationHelper.fromTaskThumbnailView(dummyThumbnail, recentsView); + Rect targetRect = new Rect(); + recentsView.getTaskSize(targetRect); + clipAnimationHelper.updateTargetRect(targetRect); + float toScale = clipAnimationHelper.getSourceRect().width() + / clipAnimationHelper.getTargetRect().width(); + float toTranslationY = clipAnimationHelper.getSourceRect().centerY() + - clipAnimationHelper.getTargetRect().centerY(); + return new ScaleAndTranslation(toScale, 0, toTranslationY); + } + + @Override + public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) { + float shiftRange = launcher.getAllAppsController().getShiftRange(); + float shiftProgress = getVerticalProgress(launcher) - NORMAL.getVerticalProgress(launcher); + float translationY = shiftProgress * shiftRange; + return new ScaleAndTranslation(1, 0, translationY); + } + + @Override + public float getVerticalProgress(Launcher launcher) { + return BACKGROUND_APP.getVerticalProgress(launcher); + } + + @Override + public int getVisibleElements(Launcher launcher) { + return NONE; + } + + @Override + public void onStateTransitionEnd(Launcher launcher) { + TaskView tasktolaunch = launcher.<RecentsView>getOverviewPanel().getTaskViewAt(0); + if (tasktolaunch != null) { + tasktolaunch.launchTask(false); + } else { + launcher.getStateManager().goToState(NORMAL); + } + } +} diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java new file mode 100644 index 000000000..91a31ddfe --- /dev/null +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2019 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.launcher3.uioverrides.touchcontrollers; + +import static com.android.launcher3.LauncherState.NORMAL; +import static com.android.launcher3.LauncherState.QUICK_SWITCH; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_FADE; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE_Y; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_TRANSLATE; +import static com.android.launcher3.anim.Interpolators.ACCEL_2; +import static com.android.launcher3.anim.Interpolators.DEACCEL_2; +import static com.android.launcher3.anim.Interpolators.INSTANT; +import static com.android.launcher3.anim.Interpolators.LINEAR; + +import android.view.MotionEvent; + +import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherState; +import com.android.launcher3.LauncherStateManager; +import com.android.launcher3.Utilities; +import com.android.launcher3.anim.AnimatorSetBuilder; +import com.android.launcher3.config.FeatureFlags; +import com.android.launcher3.touch.AbstractStateChangeTouchController; +import com.android.launcher3.touch.SwipeDetector; +import com.android.launcher3.userevent.nano.LauncherLogProto; +import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; +import com.android.quickstep.views.RecentsView; +import com.android.quickstep.views.TaskView; + +import androidx.annotation.Nullable; + +/** + * Handles quick switching to a recent task from the home screen. + */ +public class QuickSwitchTouchController extends AbstractStateChangeTouchController { + + private @Nullable TaskView mTaskToLaunch; + + public QuickSwitchTouchController(Launcher launcher) { + super(launcher, SwipeDetector.HORIZONTAL); + } + + @Override + protected boolean canInterceptTouch(MotionEvent ev) { + if (mCurrentAnimation != null) { + return true; + } + if (!mLauncher.isInState(LauncherState.NORMAL)) { + return false; + } + if ((ev.getEdgeFlags() & Utilities.EDGE_NAV_BAR) == 0) { + return false; + } + return true; + } + + @Override + protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) { + return isDragTowardPositive ? QUICK_SWITCH : NORMAL; + } + + @Override + public void onDragStart(boolean start) { + super.onDragStart(start); + mStartContainerType = LauncherLogProto.ContainerType.NAVBAR; + mTaskToLaunch = mLauncher.<RecentsView>getOverviewPanel().getTaskViewAt(0); + } + + @Override + protected void onSwipeInteractionCompleted(LauncherState targetState, int logAction) { + super.onSwipeInteractionCompleted(targetState, logAction); + mTaskToLaunch = null; + } + + @Override + protected float initCurrentAnimation(int animComponents) { + AnimatorSetBuilder animatorSetBuilder = new AnimatorSetBuilder(); + setupInterpolators(animatorSetBuilder); + long accuracy = (long) (getShiftRange() * 2); + mCurrentAnimation = mLauncher.getStateManager().createAnimationToNewWorkspace(mToState, + animatorSetBuilder, accuracy, this::clearState, LauncherStateManager.ANIM_ALL); + mCurrentAnimation.getAnimationPlayer().addUpdateListener(valueAnimator -> { + updateFullscreenProgress((Float) valueAnimator.getAnimatedValue()); + }); + return 1 / getShiftRange(); + } + + private void setupInterpolators(AnimatorSetBuilder animatorSetBuilder) { + animatorSetBuilder.setInterpolator(ANIM_WORKSPACE_FADE, DEACCEL_2); + animatorSetBuilder.setInterpolator(ANIM_ALL_APPS_FADE, DEACCEL_2); + if (FeatureFlags.SWIPE_HOME.get()) { + // Overview lives to the left of workspace, so translate down later than over + animatorSetBuilder.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCEL_2); + animatorSetBuilder.setInterpolator(ANIM_VERTICAL_PROGRESS, ACCEL_2); + animatorSetBuilder.setInterpolator(ANIM_OVERVIEW_SCALE, ACCEL_2); + animatorSetBuilder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, ACCEL_2); + animatorSetBuilder.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT); + } else { + animatorSetBuilder.setInterpolator(ANIM_WORKSPACE_TRANSLATE, LINEAR); + animatorSetBuilder.setInterpolator(ANIM_VERTICAL_PROGRESS, LINEAR); + } + } + + @Override + protected void updateProgress(float progress) { + super.updateProgress(progress); + updateFullscreenProgress(progress); + } + + private void updateFullscreenProgress(float progress) { + if (mTaskToLaunch != null) { + mTaskToLaunch.setFullscreenProgress(progress); + } + } + + @Override + protected float getShiftRange() { + return mLauncher.getDeviceProfile().widthPx / 2f; + } + + @Override + protected int getLogContainerTypeForNormalState() { + return LauncherLogProto.ContainerType.NAVBAR; + } + + @Override + protected int getDirectionForLog() { + return Utilities.isRtl(mLauncher.getResources()) ? Direction.LEFT : Direction.RIGHT; + } +} diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java index 02ffdb3e1..7794d8d99 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java @@ -19,7 +19,6 @@ import static android.view.MotionEvent.ACTION_CANCEL; import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_UP; - import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; @@ -46,7 +45,7 @@ public class OverviewInputConsumer<T extends BaseDraggingActivity> private final BaseDragLayer mTarget; private final int[] mLocationOnScreen = new int[2]; private final PointF mDownPos = new PointF(); - private final int mTouchSlop; + private final int mTouchSlopSquared; private final boolean mStartingInActivityBounds; @@ -56,7 +55,8 @@ public class OverviewInputConsumer<T extends BaseDraggingActivity> OverviewInputConsumer(T activity, boolean startingInActivityBounds) { mActivity = activity; mTarget = activity.getDragLayer(); - mTouchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop(); + int touchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop(); + mTouchSlopSquared = touchSlop * touchSlop; mStartingInActivityBounds = startingInActivityBounds; } @@ -88,10 +88,11 @@ public class OverviewInputConsumer<T extends BaseDraggingActivity> false /* closeActiveWindows */); break; case ACTION_MOVE: { - float displacement = mActivity.getDeviceProfile().isLandscape ? - ev.getX() - mDownPos.x : ev.getY() - mDownPos.y; - if (Math.abs(displacement) >= mTouchSlop) { - // Start tracking only when mTouchSlop is crossed. + float x = ev.getX() - mDownPos.x; + float y = ev.getY() - mDownPos.y; + double hypotSquared = x * x + y * y; + if (hypotSquared >= mTouchSlopSquared) { + // Start tracking only when touch slop is crossed. startTouchTracking(ev, true /* updateLocationOffset */, true /* closeActiveWindows */); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java index 89093e991..f0204b9ba 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java @@ -19,7 +19,8 @@ package com.android.launcher3.uioverrides; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE; -import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE_X; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE_Y; import static com.android.launcher3.anim.AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW; import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT; import static com.android.launcher3.anim.Interpolators.LINEAR; @@ -96,15 +97,17 @@ public abstract class BaseRecentsViewStateController<T extends View> ScaleAndTranslation scaleAndTranslation = toState.getOverviewScaleAndTranslation(mLauncher); Interpolator scaleInterpolator = builder.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR); setter.setFloat(mRecentsView, SCALE_PROPERTY, scaleAndTranslation.scale, scaleInterpolator); - Interpolator translateInterpolator = builder.getInterpolator( - ANIM_OVERVIEW_TRANSLATE, LINEAR); + Interpolator translateXInterpolator = builder.getInterpolator( + ANIM_OVERVIEW_TRANSLATE_X, LINEAR); + Interpolator translateYInterpolator = builder.getInterpolator( + ANIM_OVERVIEW_TRANSLATE_Y, LINEAR); float translationX = scaleAndTranslation.translationX; if (mRecentsView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { translationX = -translationX; } - setter.setFloat(mRecentsView, View.TRANSLATION_X, translationX, translateInterpolator); + setter.setFloat(mRecentsView, View.TRANSLATION_X, translationX, translateXInterpolator); setter.setFloat(mRecentsView, View.TRANSLATION_Y, scaleAndTranslation.translationY, - translateInterpolator); + translateYInterpolator); setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0, builder.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT)); } diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index 182ed4bc8..c65a871b6 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -23,6 +23,7 @@ import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL; import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL; import static com.android.launcher3.TestProtocol.OVERVIEW_PEEK_STATE_ORDINAL; import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL; +import static com.android.launcher3.TestProtocol.QUICK_SWITCH_STATE_ORDINAL; import static com.android.launcher3.TestProtocol.SPRING_LOADED_STATE_ORDINAL; import static com.android.launcher3.anim.Interpolators.ACCEL_2; import static com.android.launcher3.states.RotationHelper.REQUEST_NONE; @@ -31,9 +32,9 @@ import android.view.animation.Interpolator; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.states.SpringLoadedState; +import com.android.launcher3.uioverrides.UiFactory; import com.android.launcher3.uioverrides.states.AllAppsState; import com.android.launcher3.uioverrides.states.OverviewState; -import com.android.launcher3.uioverrides.UiFactory; import com.android.launcher3.userevent.nano.LauncherLogProto.Action; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; @@ -77,7 +78,7 @@ public class LauncherState { } }; - private static final LauncherState[] sAllStates = new LauncherState[6]; + private static final LauncherState[] sAllStates = new LauncherState[7]; /** * TODO: Create a separate class for NORMAL state. @@ -97,6 +98,8 @@ public class LauncherState { public static final LauncherState OVERVIEW = new OverviewState(OVERVIEW_STATE_ORDINAL); public static final LauncherState OVERVIEW_PEEK = OverviewState.newPeekState(OVERVIEW_PEEK_STATE_ORDINAL); + public static final LauncherState QUICK_SWITCH = + OverviewState.newSwitchState(QUICK_SWITCH_STATE_ORDINAL); public static final LauncherState BACKGROUND_APP = OverviewState.newBackgroundState(BACKGROUND_APP_STATE_ORDINAL); diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java index 19c896fba..5f7538b40 100644 --- a/src/com/android/launcher3/LauncherStateManager.java +++ b/src/com/android/launcher3/LauncherStateManager.java @@ -22,7 +22,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.LauncherState.OVERVIEW_PEEK; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE; -import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE_X; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_SCALE; import static com.android.launcher3.anim.Interpolators.ACCEL; @@ -296,7 +296,7 @@ public class LauncherStateManager { builder.setInterpolator(ANIM_WORKSPACE_SCALE, OVERSHOOT_1_2); builder.setInterpolator(ANIM_WORKSPACE_FADE, OVERSHOOT_1_2); builder.setInterpolator(ANIM_OVERVIEW_SCALE, OVERSHOOT_1_2); - builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE, OVERSHOOT_1_7); + builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_7); builder.setInterpolator(ANIM_OVERVIEW_FADE, OVERSHOOT_1_2); // Start from a higher overview scale, but only if we're invisible so we don't jump. @@ -305,7 +305,7 @@ public class LauncherStateManager { builder.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL); builder.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL); builder.setInterpolator(ANIM_OVERVIEW_SCALE, clampToProgress(ACCEL, 0, 0.9f)); - builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE, ACCEL); + builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, ACCEL); builder.setInterpolator(ANIM_OVERVIEW_FADE, DEACCEL_1_7); Workspace workspace = mLauncher.getWorkspace(); diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java index 0451ceb5f..49a736eed 100644 --- a/src/com/android/launcher3/TestProtocol.java +++ b/src/com/android/launcher3/TestProtocol.java @@ -29,8 +29,9 @@ public final class TestProtocol { public static final int SPRING_LOADED_STATE_ORDINAL = 1; public static final int OVERVIEW_STATE_ORDINAL = 2; public static final int OVERVIEW_PEEK_STATE_ORDINAL = 3; - public static final int ALL_APPS_STATE_ORDINAL = 4; - public static final int BACKGROUND_APP_STATE_ORDINAL = 5; + public static final int QUICK_SWITCH_STATE_ORDINAL = 4; + public static final int ALL_APPS_STATE_ORDINAL = 5; + public static final int BACKGROUND_APP_STATE_ORDINAL = 6; public static final String TEST_INFO_RESPONSE_FIELD = "response"; public static final String REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT = diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index dd755cb97..fd4b5086b 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -308,10 +308,14 @@ public final class Utilities { Log.e(TAG, "mapToRange: range has 0 length"); return toMin; } - float progress = Math.abs(t - fromMin) / Math.abs(fromMax - fromMin); + float progress = getProgress(t, fromMin, fromMax); return mapRange(interpolator.getInterpolation(progress), toMin, toMax); } + public static float getProgress(float current, float min, float max) { + return Math.abs(current - min) / Math.abs(max - min); + } + public static float mapRange(float value, float min, float max) { return min + (value * (max - min)); } diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java index 21fdd3df0..99a880104 100644 --- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java +++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java @@ -21,6 +21,7 @@ import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherState.HOTSEAT_ICONS; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_SCALE; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_TRANSLATE; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.ZOOM_OUT; import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER; @@ -114,7 +115,9 @@ public class WorkspaceStateTransitionAnimation { return; } - Interpolator translationInterpolator = !playAtomicComponent ? LINEAR : ZOOM_OUT; + Interpolator translationInterpolator = !playAtomicComponent + ? LINEAR + : builder.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT); propertySetter.setFloat(mWorkspace, View.TRANSLATION_X, scaleAndTranslation.translationX, translationInterpolator); propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y, diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index a4ecec7b8..4a1d43206 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -205,7 +205,7 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil mAppsView.getSearchUiManager().setContentVisibility(visibleElements, setter, allAppsFade); setter.setInt(mScrimView, ScrimView.DRAG_HANDLE_ALPHA, - (visibleElements & VERTICAL_SWIPE_INDICATOR) != 0 ? 255 : 0, LINEAR); + (visibleElements & VERTICAL_SWIPE_INDICATOR) != 0 ? 255 : 0, allAppsFade); } public AnimatorListenerAdapter getProgressAnimatorListener() { diff --git a/src/com/android/launcher3/anim/AnimatorSetBuilder.java b/src/com/android/launcher3/anim/AnimatorSetBuilder.java index 3ac9d3c27..5c498f8bb 100644 --- a/src/com/android/launcher3/anim/AnimatorSetBuilder.java +++ b/src/com/android/launcher3/anim/AnimatorSetBuilder.java @@ -30,11 +30,13 @@ public class AnimatorSetBuilder { public static final int ANIM_VERTICAL_PROGRESS = 0; public static final int ANIM_WORKSPACE_SCALE = 1; - public static final int ANIM_WORKSPACE_FADE = 2; - public static final int ANIM_OVERVIEW_SCALE = 3; - public static final int ANIM_OVERVIEW_TRANSLATE = 4; - public static final int ANIM_OVERVIEW_FADE = 5; - public static final int ANIM_ALL_APPS_FADE = 6; + public static final int ANIM_WORKSPACE_TRANSLATE = 2; + public static final int ANIM_WORKSPACE_FADE = 3; + public static final int ANIM_OVERVIEW_SCALE = 4; + public static final int ANIM_OVERVIEW_TRANSLATE_X = 5; + public static final int ANIM_OVERVIEW_TRANSLATE_Y = 6; + public static final int ANIM_OVERVIEW_FADE = 7; + public static final int ANIM_ALL_APPS_FADE = 8; public static final int FLAG_DONT_ANIMATE_OVERVIEW = 1 << 0; diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java b/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java index 1b1836d4c..aeba7883b 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java @@ -36,4 +36,8 @@ public class OverviewState extends LauncherState { public static OverviewState newPeekState(int id) { return new OverviewState(id); } + + public static OverviewState newSwitchState(int id) { + return new OverviewState(id); + } } |