Merge changes from topic "presubmit-am-1224af9ca3f341a895e4bc19976e2bb8" into tm-dev am: a78e070a2e am: 08a01f5c41
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/18010518 Change-Id: Ib68de44dfef9ee8c0652e2e86d6b90ade71d5198 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
fa360fb48d
@@ -22,6 +22,7 @@ import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_STATE_HANDLER;
|
||||
import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS;
|
||||
import static com.android.launcher3.PagedView.INVALID_PAGE;
|
||||
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
|
||||
@@ -66,6 +67,7 @@ import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnApplyWindowInsetsListener;
|
||||
@@ -926,7 +928,13 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
mLogDirectionUpOrLeft = velocity.x < 0;
|
||||
}
|
||||
mDownPos = downPos;
|
||||
handleNormalGestureEnd(endVelocity, isFling, velocity, false /* isCancel */);
|
||||
Runnable handleNormalGestureEndCallback = () ->
|
||||
handleNormalGestureEnd(endVelocity, isFling, velocity, /* isCancel= */ false);
|
||||
if (mRecentsView != null) {
|
||||
mRecentsView.runOnPageScrollsInitialized(handleNormalGestureEndCallback);
|
||||
} else {
|
||||
handleNormalGestureEndCallback.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void endRunningWindowAnim(boolean cancel) {
|
||||
@@ -1130,6 +1138,13 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
} else if (endTarget == RECENTS) {
|
||||
if (mRecentsView != null) {
|
||||
int nearestPage = mRecentsView.getDestinationPage();
|
||||
if (nearestPage == INVALID_PAGE) {
|
||||
// Allow the snap to invalid page to catch future error cases.
|
||||
Log.e(TAG,
|
||||
"RecentsView destination page is invalid",
|
||||
new IllegalStateException());
|
||||
}
|
||||
|
||||
boolean isScrolling = false;
|
||||
if (mRecentsView.getNextPage() != nearestPage) {
|
||||
// We shouldn't really scroll to the next page when swiping up to recents.
|
||||
|
||||
@@ -84,6 +84,8 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
|
||||
private STATE_TYPE mTargetState;
|
||||
|
||||
@Nullable private Runnable mOnInitBackgroundStateUICallback = null;
|
||||
|
||||
protected BaseActivityInterface(boolean rotationSupportedByActivity,
|
||||
STATE_TYPE overviewState, STATE_TYPE backgroundState) {
|
||||
this.rotationSupportedByActivity = rotationSupportedByActivity;
|
||||
@@ -408,6 +410,21 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void runOnInitBackgroundStateUI(Runnable callback) {
|
||||
mOnInitBackgroundStateUICallback = callback;
|
||||
ACTIVITY_TYPE activity = getCreatedActivity();
|
||||
if (activity != null && activity.getStateManager().getState() == mBackgroundState) {
|
||||
onInitBackgroundStateUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void onInitBackgroundStateUI() {
|
||||
if (mOnInitBackgroundStateUICallback != null) {
|
||||
mOnInitBackgroundStateUICallback.run();
|
||||
mOnInitBackgroundStateUICallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
public interface AnimationFactory {
|
||||
|
||||
void createActivityInterface(long transitionLength);
|
||||
@@ -447,13 +464,14 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
mStartState = mActivity.getStateManager().getState();
|
||||
}
|
||||
|
||||
protected ACTIVITY_TYPE initUI() {
|
||||
protected ACTIVITY_TYPE initBackgroundStateUI() {
|
||||
STATE_TYPE resetState = mStartState;
|
||||
if (mStartState.shouldDisableRestore()) {
|
||||
resetState = mActivity.getStateManager().getRestState();
|
||||
}
|
||||
mActivity.getStateManager().setRestState(resetState);
|
||||
mActivity.getStateManager().goToState(mBackgroundState, false);
|
||||
onInitBackgroundStateUI();
|
||||
return mActivity;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public final class FallbackActivityInterface extends
|
||||
boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback) {
|
||||
notifyRecentsOfOrientation(deviceState.getRotationTouchHelper());
|
||||
DefaultAnimationFactory factory = new DefaultAnimationFactory(callback);
|
||||
factory.initUI();
|
||||
factory.initBackgroundStateUI();
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public final class LauncherActivityInterface extends
|
||||
}
|
||||
};
|
||||
|
||||
BaseQuickstepLauncher launcher = factory.initUI();
|
||||
BaseQuickstepLauncher launcher = factory.initBackgroundStateUI();
|
||||
// Since all apps is not visible, we can safely reset the scroll position.
|
||||
// This ensures then the next swipe up to all-apps starts from scroll 0.
|
||||
launcher.getAppsView().reset(false /* animate */);
|
||||
|
||||
@@ -217,7 +217,8 @@ public class OverviewCommandHelper {
|
||||
@Override
|
||||
public void onRecentsAnimationStart(RecentsAnimationController controller,
|
||||
RecentsAnimationTargets targets) {
|
||||
interactionHandler.onGestureEnded(0, new PointF(), new PointF());
|
||||
activityInterface.runOnInitBackgroundStateUI(() ->
|
||||
interactionHandler.onGestureEnded(0, new PointF(), new PointF()));
|
||||
cmd.removeListener(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -946,7 +946,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
mHasVisibleTaskData.delete(i);
|
||||
}
|
||||
if (child instanceof GroupedTaskView) {
|
||||
mGroupedTaskViewPool.recycle((GroupedTaskView)taskView);
|
||||
mGroupedTaskViewPool.recycle((GroupedTaskView) taskView);
|
||||
} else {
|
||||
mTaskViewPool.recycle(taskView);
|
||||
}
|
||||
@@ -1855,17 +1855,18 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
if (!mActivity.getDeviceProfile().isTablet) {
|
||||
return super.getDestinationPage(scaledScroll);
|
||||
}
|
||||
|
||||
final int childCount = getChildCount();
|
||||
if (mPageScrolls == null || childCount != mPageScrolls.length) {
|
||||
return -1;
|
||||
if (!pageScrollsInitialized()) {
|
||||
Log.e(TAG,
|
||||
"Cannot get destination page: RecentsView not properly initialized",
|
||||
new IllegalStateException());
|
||||
return INVALID_PAGE;
|
||||
}
|
||||
|
||||
// When in tablet with variable task width, return the page which scroll is closest to
|
||||
// screenStart instead of page nearest to center of screen.
|
||||
int minDistanceFromScreenStart = Integer.MAX_VALUE;
|
||||
int minDistanceFromScreenStartIndex = -1;
|
||||
for (int i = 0; i < childCount; ++i) {
|
||||
int minDistanceFromScreenStartIndex = INVALID_PAGE;
|
||||
for (int i = 0; i < getChildCount(); ++i) {
|
||||
int distanceFromScreenStart = Math.abs(mPageScrolls[i] - scaledScroll);
|
||||
if (distanceFromScreenStart < minDistanceFromScreenStart) {
|
||||
minDistanceFromScreenStart = distanceFromScreenStart;
|
||||
|
||||
Reference in New Issue
Block a user