Revert "Merge branch 'ub-launcher3-master' into pi-dev"

Original CL loses the commit history. I believe this is due to doing the merge on master and cherry picking to pi-dev. Tested locally that reverting this results in no conflicts when doing the merge properly on pi-dev.

This reverts commit 3f7df53dda.

Bug: 74794600
Test: manual test
Change-Id: I58f3bb1bd5ce789be380bac9716efd2627a90f92
This commit is contained in:
Jonathan Miranda
2018-03-27 00:10:24 +00:00
committed by Jon
parent 3f7df53dda
commit 6cf6dd8bce
273 changed files with 5529 additions and 4244 deletions
@@ -16,7 +16,7 @@
package com.android.launcher3.uioverrides;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -28,71 +28,84 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.PagedView;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.quickstep.RecentsView;
import com.android.quickstep.TaskView;
public class RecentsViewStateController implements StateHandler {
private final Launcher mLauncher;
private final RecentsView mRecentsView;
private final WorkspaceCard mWorkspaceCard;
private final AnimatedFloat mTransitionProgress = new AnimatedFloat(this::onTransitionProgress);
// The fraction representing the visibility of the RecentsView. This allows delaying the
// overall transition while the RecentsView is being shown or hidden.
private final AnimatedFloat mVisibilityMultiplier = new AnimatedFloat(this::onVisibilityProgress);
private boolean mIsRecentsSlidingInOrOut;
private boolean mIsRecentsScrollingToFirstTask;
public RecentsViewStateController(Launcher launcher) {
mLauncher = launcher;
mRecentsView = launcher.getOverviewPanel();
mRecentsView.setStateController(this);
mWorkspaceCard = (WorkspaceCard) mRecentsView.getChildAt(0);
mWorkspaceCard.setup(launcher);
}
@Override
public void setState(LauncherState state) {
setVisibility(state.overviewUi);
setTransitionProgress(state.overviewUi ? 1 : 0);
if (state.overviewUi) {
mRecentsView.resetTaskVisuals();
mWorkspaceCard.setWorkspaceScrollingEnabled(state == OVERVIEW);
setVisibility(state == OVERVIEW);
setTransitionProgress(state == OVERVIEW ? 1 : 0);
if (state == OVERVIEW) {
for (int i = mRecentsView.getFirstTaskIndex(); i < mRecentsView.getPageCount(); i++) {
((TaskView) mRecentsView.getPageAt(i)).resetVisualProperties();
}
mRecentsView.updateCurveProperties();
}
}
@Override
public void setStateWithAnimation(final LauncherState toState,
AnimatorSetBuilder builder, AnimationConfig config) {
LauncherState fromState = mLauncher.getStateManager().getState();
mIsRecentsSlidingInOrOut = fromState == NORMAL && toState.overviewUi
|| fromState.overviewUi && toState == NORMAL;
boolean settingEnabled = Utilities.getPrefs(mLauncher)
.getBoolean("pref_scroll_to_first_task", false);
mIsRecentsScrollingToFirstTask = mLauncher.isInState(NORMAL) && toState == OVERVIEW
&& settingEnabled;
// TODO: Instead of animating the workspace translationX, move the contents
mWorkspaceCard.setWorkspaceScrollingEnabled(mIsRecentsScrollingToFirstTask);
// Scroll to the workspace card before changing to the NORMAL state.
int currPage = mRecentsView.getCurrentPage();
if (fromState.overviewUi && toState == NORMAL && currPage != 0 && !config.userControlled) {
if (toState == NORMAL && currPage != 0 && !config.userControlled) {
int maxSnapDuration = PagedView.SLOW_PAGE_SNAP_ANIMATION_DURATION;
int durationPerPage = maxSnapDuration / 10;
int snapDuration = Math.min(maxSnapDuration, durationPerPage * currPage);
mRecentsView.snapToPage(0, snapDuration);
// Let the snapping animation play for a bit before we translate off screen.
builder.setStartDelay(snapDuration / 4);
builder.setStartDelay(snapDuration);
}
ObjectAnimator progressAnim =
mTransitionProgress.animateToValue(toState.overviewUi ? 1 : 0);
mTransitionProgress.animateToValue(toState == OVERVIEW ? 1 : 0);
progressAnim.setDuration(config.duration);
progressAnim.setInterpolator(Interpolators.LINEAR);
progressAnim.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
mWorkspaceCard.setWorkspaceScrollingEnabled(toState == OVERVIEW);
mRecentsView.setCurrentPage(mRecentsView.getPageNearestToCenterOfScreen());
}
});
builder.play(progressAnim);
ObjectAnimator visibilityAnim = animateVisibility(toState.overviewUi);
ObjectAnimator visibilityAnim = animateVisibility(toState == OVERVIEW);
visibilityAnim.setDuration(config.duration);
visibilityAnim.setInterpolator(Interpolators.LINEAR);
builder.play(visibilityAnim);
@@ -131,14 +144,11 @@ public class RecentsViewStateController implements StateHandler {
private void onTransitionProgress() {
applyProgress();
if (mIsRecentsSlidingInOrOut) {
float interpolatedProgress = ACCEL.getInterpolation(mTransitionProgress.value);
// Slide in from the side as we swipe.
int translation = mRecentsView.getWidth();
if (mRecentsView.isRtl()) {
translation = -translation;
}
mRecentsView.setTranslationX(translation * (1 - interpolatedProgress));
if (mIsRecentsScrollingToFirstTask) {
int scrollForFirstTask = mRecentsView.getScrollForPage(mRecentsView.getFirstTaskIndex());
int scrollForPage0 = mRecentsView.getScrollForPage(0);
mRecentsView.setScrollX((int) (mTransitionProgress.value * scrollForFirstTask
+ (1 - mTransitionProgress.value) * scrollForPage0));
}
}
@@ -148,9 +158,5 @@ public class RecentsViewStateController implements StateHandler {
private void applyProgress() {
mRecentsView.setAlpha(mTransitionProgress.value * mVisibilityMultiplier.value);
if (mIsRecentsSlidingInOrOut) {
// While animating into recents, update the visible task data as needed
mRecentsView.loadVisibleTaskData();
}
}
}