Merge branch 'android15-release' into merge-aosp15
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.launcher3;
|
||||
import static com.android.app.animation.Interpolators.SCROLL;
|
||||
import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessibilityEnabled;
|
||||
import static com.android.launcher3.compat.AccessibilityManagerCompat.isObservedEventType;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.SCROLL_FINISHED_MESSAGE;
|
||||
import static com.android.launcher3.touch.OverScroll.OVERSCROLL_DAMP_FACTOR;
|
||||
import static com.android.launcher3.touch.PagedOrientationHandler.VIEW_SCROLL_BY;
|
||||
import static com.android.launcher3.touch.PagedOrientationHandler.VIEW_SCROLL_TO;
|
||||
@@ -119,7 +120,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
private float mTotalMotion;
|
||||
// Used in special cases where the fling checks can be relaxed for an intentional gesture
|
||||
private boolean mAllowEasyFling;
|
||||
protected PagedOrientationHandler mOrientationHandler = PagedOrientationHandler.PORTRAIT;
|
||||
private PagedOrientationHandler mOrientationHandler =
|
||||
PagedOrientationHandler.DEFAULT;
|
||||
|
||||
private final ArrayList<Runnable> mOnPageScrollsInitializedCallbacks = new ArrayList<>();
|
||||
|
||||
@@ -232,6 +234,14 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
return getChildAt(index);
|
||||
}
|
||||
|
||||
protected PagedOrientationHandler getPagedOrientationHandler() {
|
||||
return mOrientationHandler;
|
||||
}
|
||||
|
||||
protected void setOrientationHandler(PagedOrientationHandler orientationHandler) {
|
||||
this.mOrientationHandler = orientationHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the scroll of the current page immediately to its final scroll position. We use this
|
||||
* in CustomizePagedView to allow tabs to share the same PagedView while resetting the scroll of
|
||||
@@ -477,7 +487,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
super.onVisibilityAggregated(isVisible);
|
||||
}
|
||||
|
||||
protected boolean isPageInTransition() {
|
||||
/**
|
||||
* Returns true if the page is in the middle of transition to another page
|
||||
*/
|
||||
public boolean isPageInTransition() {
|
||||
return mIsPageInTransition;
|
||||
}
|
||||
|
||||
@@ -494,7 +507,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
*/
|
||||
protected void onPageEndTransition() {
|
||||
mCurrentPageScrollDiff = 0;
|
||||
AccessibilityManagerCompat.sendScrollFinishedEventToTest(getContext());
|
||||
AccessibilityManagerCompat.sendTestProtocolEventToTest(getContext(),
|
||||
SCROLL_FINISHED_MESSAGE);
|
||||
AccessibilityManagerCompat.sendCustomAccessibilityEvent(getPageAt(mCurrentPage),
|
||||
AccessibilityEvent.TYPE_VIEW_FOCUSED, null);
|
||||
if (mOnPageTransitionEndCallback != null) {
|
||||
@@ -628,6 +642,11 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
mMinFlingVelocity = res.getDimensionPixelSize(R.dimen.min_fling_velocity);
|
||||
mMinSnapVelocity = res.getDimensionPixelSize(R.dimen.min_page_snap_velocity);
|
||||
mPageSnapAnimationDuration = res.getInteger(R.integer.config_pageSnapAnimationDuration);
|
||||
onVelocityValuesUpdated();
|
||||
}
|
||||
|
||||
protected void onVelocityValuesUpdated() {
|
||||
// Overridden in RecentsView
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -771,7 +790,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
if (mScroller.isFinished() && pageScrollChanged) {
|
||||
// TODO(b/246283207): Remove logging once root cause of flake detected.
|
||||
if (Utilities.isRunningInTestHarness() && !(this instanceof Workspace)) {
|
||||
Log.d("b/246283207", this.getClass().getSimpleName() + "#onLayout() -> "
|
||||
Log.d("b/246283207", TAG + "#onLayout() -> "
|
||||
+ "if(mScroller.isFinished() && pageScrollChanged) -> getNextPage(): "
|
||||
+ getNextPage() + ", getScrollForPage(getNextPage()): "
|
||||
+ getScrollForPage(getNextPage()));
|
||||
@@ -812,7 +831,9 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
// or right edge for RTL.
|
||||
final int pageScroll =
|
||||
mIsRtl ? childPrimaryEnd - scrollOffsetEnd : childStart - scrollOffsetStart;
|
||||
if (outPageScrolls[i] != pageScroll) {
|
||||
// If there's more than one panel, only update scroll on leftmost panel.
|
||||
if (outPageScrolls[i] != pageScroll
|
||||
&& (panelCount <= 1 || i == getLeftmostVisiblePageForIndex(i))) {
|
||||
pageScrollChanged = true;
|
||||
outPageScrolls[i] = pageScroll;
|
||||
}
|
||||
@@ -828,7 +849,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
|
||||
if (panelCount > 1) {
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
// In case we have multiple panels, always use left most panel's page scroll for all
|
||||
// In case we have multiple panels, always use leftmost panel's page scroll for all
|
||||
// panels on the screen.
|
||||
int adjustedScroll = outPageScrolls[getLeftmostVisiblePageForIndex(i)];
|
||||
if (outPageScrolls[i] != adjustedScroll) {
|
||||
@@ -1126,7 +1147,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
mEdgeGlowLeft.onPullDistance(0f, 1f - displacement);
|
||||
}
|
||||
if (!mEdgeGlowRight.isFinished()) {
|
||||
mEdgeGlowRight.onPullDistance(0f, displacement);
|
||||
mEdgeGlowRight.onPullDistance(0f, displacement, ev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1306,10 +1327,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
int consumed = 0;
|
||||
if (delta < 0 && mEdgeGlowRight.getDistance() != 0f) {
|
||||
consumed = Math.round(size *
|
||||
mEdgeGlowRight.onPullDistance(delta / size, displacement));
|
||||
mEdgeGlowRight.onPullDistance(delta / size, displacement, ev));
|
||||
} else if (delta > 0 && mEdgeGlowLeft.getDistance() != 0f) {
|
||||
consumed = Math.round(-size *
|
||||
mEdgeGlowLeft.onPullDistance(-delta / size, 1 - displacement));
|
||||
mEdgeGlowLeft.onPullDistance(-delta / size, 1 - displacement, ev));
|
||||
}
|
||||
delta -= consumed;
|
||||
}
|
||||
@@ -1327,14 +1348,14 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
final float pulledToX = oldScroll + delta;
|
||||
|
||||
if (pulledToX < mMinScroll) {
|
||||
mEdgeGlowLeft.onPullDistance(-delta / size, 1.f - displacement);
|
||||
mEdgeGlowLeft.onPullDistance(-delta / size, 1.f - displacement, ev);
|
||||
if (!mEdgeGlowRight.isFinished()) {
|
||||
mEdgeGlowRight.onRelease();
|
||||
mEdgeGlowRight.onRelease(ev);
|
||||
}
|
||||
} else if (pulledToX > mMaxScroll) {
|
||||
mEdgeGlowRight.onPullDistance(delta / size, displacement);
|
||||
mEdgeGlowRight.onPullDistance(delta / size, displacement, ev);
|
||||
if (!mEdgeGlowLeft.isFinished()) {
|
||||
mEdgeGlowLeft.onRelease();
|
||||
mEdgeGlowLeft.onRelease(ev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1342,7 +1363,6 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
postInvalidateOnAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
awakenScrollBars();
|
||||
}
|
||||
@@ -1442,10 +1462,11 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
mEdgeGlowLeft.onFlingVelocity(velocity);
|
||||
mEdgeGlowRight.onFlingVelocity(velocity);
|
||||
}
|
||||
|
||||
mEdgeGlowLeft.onRelease();
|
||||
mEdgeGlowRight.onRelease();
|
||||
mEdgeGlowLeft.onRelease(ev);
|
||||
mEdgeGlowRight.onRelease(ev);
|
||||
// End any intermediate reordering states
|
||||
resetTouchState();
|
||||
break;
|
||||
@@ -1454,8 +1475,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
if (mIsBeingDragged) {
|
||||
runOnPageScrollsInitialized(this::snapToDestination);
|
||||
}
|
||||
mEdgeGlowLeft.onRelease();
|
||||
mEdgeGlowRight.onRelease();
|
||||
mEdgeGlowLeft.onRelease(ev);
|
||||
mEdgeGlowRight.onRelease(ev);
|
||||
resetTouchState();
|
||||
break;
|
||||
|
||||
@@ -1573,7 +1594,9 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
@Override
|
||||
public void requestChildFocus(View child, View focused) {
|
||||
super.requestChildFocus(child, focused);
|
||||
|
||||
if (!shouldHandleRequestChildFocus(child)) {
|
||||
return;
|
||||
}
|
||||
// In case the device is controlled by a controller, mCurrentPage isn't updated properly
|
||||
// which results in incorrect navigation
|
||||
int nextPage = getNextPage();
|
||||
@@ -1587,6 +1610,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean shouldHandleRequestChildFocus(View child) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getDestinationPage() {
|
||||
return getDestinationPage(mOrientationHandler.getPrimaryScroll(this));
|
||||
}
|
||||
@@ -1637,7 +1664,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
}
|
||||
|
||||
protected void snapToDestination() {
|
||||
snapToPage(getDestinationPage(), mPageSnapAnimationDuration);
|
||||
snapToPage(getDestinationPage(), getSnapAnimationDuration());
|
||||
}
|
||||
|
||||
// We want the duration of the page snap animation to be influenced by the distance that
|
||||
@@ -1661,7 +1688,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
if (Math.abs(velocity) < mMinFlingVelocity) {
|
||||
// If the velocity is low enough, then treat this more as an automatic page advance
|
||||
// as opposed to an apparent physical response to flinging
|
||||
return snapToPage(whichPage, mPageSnapAnimationDuration);
|
||||
return snapToPage(whichPage, getSnapAnimationDuration());
|
||||
}
|
||||
|
||||
// Here we compute a "distance" that will be used in the computation of the overall
|
||||
@@ -1683,12 +1710,16 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
return snapToPage(whichPage, delta, duration);
|
||||
}
|
||||
|
||||
protected int getSnapAnimationDuration() {
|
||||
return mPageSnapAnimationDuration;
|
||||
}
|
||||
|
||||
public boolean snapToPage(int whichPage) {
|
||||
return snapToPage(whichPage, mPageSnapAnimationDuration);
|
||||
return snapToPage(whichPage, getSnapAnimationDuration());
|
||||
}
|
||||
|
||||
public boolean snapToPageImmediately(int whichPage) {
|
||||
return snapToPage(whichPage, mPageSnapAnimationDuration, true);
|
||||
return snapToPage(whichPage, getSnapAnimationDuration(), true);
|
||||
}
|
||||
|
||||
public boolean snapToPage(int whichPage, int duration) {
|
||||
|
||||
Reference in New Issue
Block a user