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.INVISIBLE_BY_STATE_HANDLER;
|
||||||
import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS;
|
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.ACCEL_DEACCEL;
|
||||||
import static com.android.launcher3.anim.Interpolators.DEACCEL;
|
import static com.android.launcher3.anim.Interpolators.DEACCEL;
|
||||||
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
|
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.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnApplyWindowInsetsListener;
|
import android.view.View.OnApplyWindowInsetsListener;
|
||||||
@@ -926,7 +928,13 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
|||||||
mLogDirectionUpOrLeft = velocity.x < 0;
|
mLogDirectionUpOrLeft = velocity.x < 0;
|
||||||
}
|
}
|
||||||
mDownPos = downPos;
|
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) {
|
private void endRunningWindowAnim(boolean cancel) {
|
||||||
@@ -1130,6 +1138,13 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
|||||||
} else if (endTarget == RECENTS) {
|
} else if (endTarget == RECENTS) {
|
||||||
if (mRecentsView != null) {
|
if (mRecentsView != null) {
|
||||||
int nearestPage = mRecentsView.getDestinationPage();
|
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;
|
boolean isScrolling = false;
|
||||||
if (mRecentsView.getNextPage() != nearestPage) {
|
if (mRecentsView.getNextPage() != nearestPage) {
|
||||||
// We shouldn't really scroll to the next page when swiping up to recents.
|
// 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;
|
private STATE_TYPE mTargetState;
|
||||||
|
|
||||||
|
@Nullable private Runnable mOnInitBackgroundStateUICallback = null;
|
||||||
|
|
||||||
protected BaseActivityInterface(boolean rotationSupportedByActivity,
|
protected BaseActivityInterface(boolean rotationSupportedByActivity,
|
||||||
STATE_TYPE overviewState, STATE_TYPE backgroundState) {
|
STATE_TYPE overviewState, STATE_TYPE backgroundState) {
|
||||||
this.rotationSupportedByActivity = rotationSupportedByActivity;
|
this.rotationSupportedByActivity = rotationSupportedByActivity;
|
||||||
@@ -408,6 +410,21 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
|||||||
return null;
|
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 {
|
public interface AnimationFactory {
|
||||||
|
|
||||||
void createActivityInterface(long transitionLength);
|
void createActivityInterface(long transitionLength);
|
||||||
@@ -447,13 +464,14 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
|||||||
mStartState = mActivity.getStateManager().getState();
|
mStartState = mActivity.getStateManager().getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ACTIVITY_TYPE initUI() {
|
protected ACTIVITY_TYPE initBackgroundStateUI() {
|
||||||
STATE_TYPE resetState = mStartState;
|
STATE_TYPE resetState = mStartState;
|
||||||
if (mStartState.shouldDisableRestore()) {
|
if (mStartState.shouldDisableRestore()) {
|
||||||
resetState = mActivity.getStateManager().getRestState();
|
resetState = mActivity.getStateManager().getRestState();
|
||||||
}
|
}
|
||||||
mActivity.getStateManager().setRestState(resetState);
|
mActivity.getStateManager().setRestState(resetState);
|
||||||
mActivity.getStateManager().goToState(mBackgroundState, false);
|
mActivity.getStateManager().goToState(mBackgroundState, false);
|
||||||
|
onInitBackgroundStateUI();
|
||||||
return mActivity;
|
return mActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public final class FallbackActivityInterface extends
|
|||||||
boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback) {
|
boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback) {
|
||||||
notifyRecentsOfOrientation(deviceState.getRotationTouchHelper());
|
notifyRecentsOfOrientation(deviceState.getRotationTouchHelper());
|
||||||
DefaultAnimationFactory factory = new DefaultAnimationFactory(callback);
|
DefaultAnimationFactory factory = new DefaultAnimationFactory(callback);
|
||||||
factory.initUI();
|
factory.initBackgroundStateUI();
|
||||||
return factory;
|
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.
|
// 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.
|
// This ensures then the next swipe up to all-apps starts from scroll 0.
|
||||||
launcher.getAppsView().reset(false /* animate */);
|
launcher.getAppsView().reset(false /* animate */);
|
||||||
|
|||||||
@@ -217,7 +217,8 @@ public class OverviewCommandHelper {
|
|||||||
@Override
|
@Override
|
||||||
public void onRecentsAnimationStart(RecentsAnimationController controller,
|
public void onRecentsAnimationStart(RecentsAnimationController controller,
|
||||||
RecentsAnimationTargets targets) {
|
RecentsAnimationTargets targets) {
|
||||||
interactionHandler.onGestureEnded(0, new PointF(), new PointF());
|
activityInterface.runOnInitBackgroundStateUI(() ->
|
||||||
|
interactionHandler.onGestureEnded(0, new PointF(), new PointF()));
|
||||||
cmd.removeListener(this);
|
cmd.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -946,7 +946,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
|||||||
mHasVisibleTaskData.delete(i);
|
mHasVisibleTaskData.delete(i);
|
||||||
}
|
}
|
||||||
if (child instanceof GroupedTaskView) {
|
if (child instanceof GroupedTaskView) {
|
||||||
mGroupedTaskViewPool.recycle((GroupedTaskView)taskView);
|
mGroupedTaskViewPool.recycle((GroupedTaskView) taskView);
|
||||||
} else {
|
} else {
|
||||||
mTaskViewPool.recycle(taskView);
|
mTaskViewPool.recycle(taskView);
|
||||||
}
|
}
|
||||||
@@ -1855,17 +1855,18 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
|||||||
if (!mActivity.getDeviceProfile().isTablet) {
|
if (!mActivity.getDeviceProfile().isTablet) {
|
||||||
return super.getDestinationPage(scaledScroll);
|
return super.getDestinationPage(scaledScroll);
|
||||||
}
|
}
|
||||||
|
if (!pageScrollsInitialized()) {
|
||||||
final int childCount = getChildCount();
|
Log.e(TAG,
|
||||||
if (mPageScrolls == null || childCount != mPageScrolls.length) {
|
"Cannot get destination page: RecentsView not properly initialized",
|
||||||
return -1;
|
new IllegalStateException());
|
||||||
|
return INVALID_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When in tablet with variable task width, return the page which scroll is closest to
|
// When in tablet with variable task width, return the page which scroll is closest to
|
||||||
// screenStart instead of page nearest to center of screen.
|
// screenStart instead of page nearest to center of screen.
|
||||||
int minDistanceFromScreenStart = Integer.MAX_VALUE;
|
int minDistanceFromScreenStart = Integer.MAX_VALUE;
|
||||||
int minDistanceFromScreenStartIndex = -1;
|
int minDistanceFromScreenStartIndex = INVALID_PAGE;
|
||||||
for (int i = 0; i < childCount; ++i) {
|
for (int i = 0; i < getChildCount(); ++i) {
|
||||||
int distanceFromScreenStart = Math.abs(mPageScrolls[i] - scaledScroll);
|
int distanceFromScreenStart = Math.abs(mPageScrolls[i] - scaledScroll);
|
||||||
if (distanceFromScreenStart < minDistanceFromScreenStart) {
|
if (distanceFromScreenStart < minDistanceFromScreenStart) {
|
||||||
minDistanceFromScreenStart = distanceFromScreenStart;
|
minDistanceFromScreenStart = distanceFromScreenStart;
|
||||||
|
|||||||
@@ -1279,13 +1279,16 @@ public class Launcher extends StatefulActivity<LauncherState>
|
|||||||
* @param info The data structure describing the shortcut.
|
* @param info The data structure describing the shortcut.
|
||||||
*/
|
*/
|
||||||
View createShortcut(WorkspaceItemInfo info) {
|
View createShortcut(WorkspaceItemInfo info) {
|
||||||
return createShortcut((ViewGroup) mWorkspace.getChildAt(mWorkspace.getCurrentPage()), info);
|
// This can be called before PagedView#pageScrollsInitialized returns true, so use the
|
||||||
|
// first page, which we always assume to be present.
|
||||||
|
return createShortcut((ViewGroup) mWorkspace.getChildAt(0), info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a view representing a shortcut inflated from the specified resource.
|
* Creates a view representing a shortcut inflated from the specified resource.
|
||||||
*
|
*
|
||||||
* @param parent The group the shortcut belongs to.
|
* @param parent The group the shortcut belongs to. This is not necessarily the group where
|
||||||
|
* the shortcut should be added.
|
||||||
* @param info The data structure describing the shortcut.
|
* @param info The data structure describing the shortcut.
|
||||||
* @return A View inflated from layoutResId.
|
* @return A View inflated from layoutResId.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -129,7 +129,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
|||||||
private boolean mAllowEasyFling;
|
private boolean mAllowEasyFling;
|
||||||
protected PagedOrientationHandler mOrientationHandler = PagedOrientationHandler.PORTRAIT;
|
protected PagedOrientationHandler mOrientationHandler = PagedOrientationHandler.PORTRAIT;
|
||||||
|
|
||||||
protected int[] mPageScrolls;
|
private final ArrayList<Runnable> mOnPageScrollsInitializedCallbacks = new ArrayList<>();
|
||||||
|
|
||||||
|
// We should always check pageScrollsInitialized() is true when using mPageScrolls.
|
||||||
|
@Nullable protected int[] mPageScrolls = null;
|
||||||
private boolean mIsBeingDragged;
|
private boolean mIsBeingDragged;
|
||||||
|
|
||||||
// The amount of movement to begin scrolling
|
// The amount of movement to begin scrolling
|
||||||
@@ -684,14 +687,37 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
|||||||
setMeasuredDimension(widthSize, heightSize);
|
setMeasuredDimension(widthSize, heightSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns true iff this PagedView's scroll amounts are initialized to each page index. */
|
||||||
|
protected boolean pageScrollsInitialized() {
|
||||||
|
return mPageScrolls != null && mPageScrolls.length == getChildCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queues the given callback to be run once {@code mPageScrolls} has been initialized.
|
||||||
|
*/
|
||||||
|
public void runOnPageScrollsInitialized(Runnable callback) {
|
||||||
|
mOnPageScrollsInitializedCallbacks.add(callback);
|
||||||
|
if (pageScrollsInitialized()) {
|
||||||
|
onPageScrollsInitialized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onPageScrollsInitialized() {
|
||||||
|
for (Runnable callback : mOnPageScrollsInitializedCallbacks) {
|
||||||
|
callback.run();
|
||||||
|
}
|
||||||
|
mOnPageScrollsInitializedCallbacks.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("DrawAllocation")
|
@SuppressLint("DrawAllocation")
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
mIsLayoutValid = true;
|
mIsLayoutValid = true;
|
||||||
final int childCount = getChildCount();
|
final int childCount = getChildCount();
|
||||||
|
int[] pageScrolls = mPageScrolls;
|
||||||
boolean pageScrollChanged = false;
|
boolean pageScrollChanged = false;
|
||||||
if (mPageScrolls == null || childCount != mPageScrolls.length) {
|
if (!pageScrollsInitialized()) {
|
||||||
mPageScrolls = new int[childCount];
|
pageScrolls = new int[childCount];
|
||||||
pageScrollChanged = true;
|
pageScrollChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,10 +727,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
|||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "PagedView.onLayout()");
|
if (DEBUG) Log.d(TAG, "PagedView.onLayout()");
|
||||||
|
|
||||||
boolean isScrollChanged = getPageScrolls(mPageScrolls, true, SIMPLE_SCROLL_LOGIC);
|
pageScrollChanged |= getPageScrolls(pageScrolls, true, SIMPLE_SCROLL_LOGIC);
|
||||||
if (isScrollChanged) {
|
mPageScrolls = pageScrolls;
|
||||||
pageScrollChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final LayoutTransition transition = getLayoutTransition();
|
final LayoutTransition transition = getLayoutTransition();
|
||||||
// If the transition is running defer updating max scroll, as some empty pages could
|
// If the transition is running defer updating max scroll, as some empty pages could
|
||||||
@@ -738,6 +762,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
|||||||
if (mScroller.isFinished() && pageScrollChanged) {
|
if (mScroller.isFinished() && pageScrollChanged) {
|
||||||
setCurrentPage(getNextPage());
|
setCurrentPage(getNextPage());
|
||||||
}
|
}
|
||||||
|
onPageScrollsInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -849,8 +874,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
|||||||
@Override
|
@Override
|
||||||
public void onViewRemoved(View child) {
|
public void onViewRemoved(View child) {
|
||||||
super.onViewRemoved(child);
|
super.onViewRemoved(child);
|
||||||
mCurrentPage = validateNewPage(mCurrentPage);
|
runOnPageScrollsInitialized(() -> {
|
||||||
mCurrentScrollOverPage = mCurrentPage;
|
mCurrentPage = validateNewPage(mCurrentPage);
|
||||||
|
mCurrentScrollOverPage = mCurrentPage;
|
||||||
|
});
|
||||||
dispatchPageCountChanged();
|
dispatchPageCountChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1153,7 +1180,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getScrollForPage(int index) {
|
public int getScrollForPage(int index) {
|
||||||
if (mPageScrolls == null || index >= mPageScrolls.length || index < 0) {
|
if (!pageScrollsInitialized() || index >= mPageScrolls.length || index < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return mPageScrolls[index];
|
return mPageScrolls[index];
|
||||||
@@ -1163,7 +1190,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
|||||||
// While layout transitions are occurring, a child's position may stray from its baseline
|
// While layout transitions are occurring, a child's position may stray from its baseline
|
||||||
// position. This method returns the magnitude of this stray at any given time.
|
// position. This method returns the magnitude of this stray at any given time.
|
||||||
public int getLayoutTransitionOffsetForPage(int index) {
|
public int getLayoutTransitionOffsetForPage(int index) {
|
||||||
if (mPageScrolls == null || index >= mPageScrolls.length || index < 0) {
|
if (!pageScrollsInitialized() || index >= mPageScrolls.length || index < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
View child = getChildAt(index);
|
View child = getChildAt(index);
|
||||||
|
|||||||
Reference in New Issue
Block a user