Merge "Entering overview from home focuses on first task" into ub-launcher3-master
This commit is contained in:
@@ -108,7 +108,7 @@ public class OverviewState extends LauncherState {
|
||||
float halfWidth = ws.getExpectedWidth() / 2;
|
||||
float childCenter = halfWidth -
|
||||
scale * (halfWidth - ws.getPaddingLeft() - insets.left - childWidth / 2);
|
||||
float translationX = pageRect.exactCenterX() - childCenter;
|
||||
float translationX = pageRect.centerX() - childCenter;
|
||||
|
||||
if (Utilities.isRtl(launcher.getResources())) {
|
||||
translationX -= offsetX / scale;
|
||||
|
||||
@@ -28,6 +28,7 @@ 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;
|
||||
@@ -40,10 +41,12 @@ public class RecentsViewStateController implements StateHandler {
|
||||
private final RecentsView mRecentsView;
|
||||
private final WorkspaceCard mWorkspaceCard;
|
||||
|
||||
private final AnimatedFloat mTransitionProgress = new AnimatedFloat(this::applyProgress);
|
||||
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::applyProgress);
|
||||
private final AnimatedFloat mVisibilityMultiplier = new AnimatedFloat(this::onVisibilityProgress);
|
||||
|
||||
private boolean mIsRecentsScrollingToFirstTask;
|
||||
|
||||
public RecentsViewStateController(Launcher launcher) {
|
||||
mLauncher = launcher;
|
||||
@@ -64,6 +67,11 @@ public class RecentsViewStateController implements StateHandler {
|
||||
@Override
|
||||
public void setStateWithAnimation(final LauncherState toState,
|
||||
AnimatorSetBuilder builder, AnimationConfig config) {
|
||||
boolean settingEnabled = Utilities.getPrefs(mLauncher)
|
||||
.getBoolean("pref_scroll_to_first_task", false);
|
||||
mIsRecentsScrollingToFirstTask = mLauncher.isInState(NORMAL) && toState == OVERVIEW
|
||||
&& settingEnabled;
|
||||
|
||||
// Scroll to the workspace card before changing to the NORMAL state.
|
||||
int currPage = mRecentsView.getCurrentPage();
|
||||
if (toState == NORMAL && currPage != 0 && !config.userControlled) {
|
||||
@@ -82,12 +90,13 @@ public class RecentsViewStateController implements StateHandler {
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mWorkspaceCard.setWorkspaceScrollingEnabled(false);
|
||||
mWorkspaceCard.setWorkspaceScrollingEnabled(mIsRecentsScrollingToFirstTask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationSuccess(Animator animator) {
|
||||
mWorkspaceCard.setWorkspaceScrollingEnabled(toState == OVERVIEW);
|
||||
mRecentsView.setCurrentPage(mRecentsView.getPageNearestToCenterOfScreen());
|
||||
}
|
||||
});
|
||||
builder.play(progressAnim);
|
||||
@@ -129,6 +138,18 @@ public class RecentsViewStateController implements StateHandler {
|
||||
mTransitionProgress.updateValue(progress);
|
||||
}
|
||||
|
||||
private void onTransitionProgress() {
|
||||
applyProgress();
|
||||
if (mIsRecentsScrollingToFirstTask) {
|
||||
int scrollForFirstTask = mRecentsView.getScrollForPage(mRecentsView.getFirstTaskIndex());
|
||||
mRecentsView.setScrollX((int) (mTransitionProgress.value * scrollForFirstTask));
|
||||
}
|
||||
}
|
||||
|
||||
private void onVisibilityProgress() {
|
||||
applyProgress();
|
||||
}
|
||||
|
||||
private void applyProgress() {
|
||||
mRecentsView.setAlpha(mTransitionProgress.value * mVisibilityMultiplier.value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user