Fix page indicator bugs for foldable
There are bugs when unfolding the felix device where the page indicator will appear in the wrong place, and have to animate all the way back to where it should go. Here we fix those issues. Fix: 294229186 Fix: 294231977 Flag: no flag Test: n/a Change-Id: I962042efcee6fcea2e46acd585b7f1403078b548
This commit is contained in:
@@ -2325,6 +2325,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
@Override
|
||||
public void bindScreens(IntArray orderedScreenIds) {
|
||||
mWorkspace.mPageIndicator.setAreScreensBinding(true);
|
||||
int firstScreenPosition = 0;
|
||||
if (FeatureFlags.QSB_ON_FIRST_SCREEN &&
|
||||
orderedScreenIds.indexOf(Workspace.FIRST_SCREEN_ID) != firstScreenPosition) {
|
||||
@@ -2822,8 +2823,8 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
getViewCache().setCacheSize(R.layout.folder_page, 2);
|
||||
|
||||
TraceHelper.INSTANCE.endSection();
|
||||
|
||||
mWorkspace.removeExtraEmptyScreen(true);
|
||||
mWorkspace.removeExtraEmptyScreen(/* stripEmptyScreens= */ true);
|
||||
mWorkspace.mPageIndicator.setAreScreensBinding(false);
|
||||
}
|
||||
|
||||
private boolean canAnimatePageChange() {
|
||||
|
||||
@@ -26,6 +26,14 @@ public interface PageIndicator {
|
||||
|
||||
void setMarkersCount(int numMarkers);
|
||||
|
||||
/**
|
||||
* Sets flag to indicate when the screens are in the process of binding so that we don't animate
|
||||
* during that period.
|
||||
*/
|
||||
default void setAreScreensBinding(boolean areScreensBinding) {
|
||||
// No-op by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the flag if the Page Indicator should autohide.
|
||||
*/
|
||||
|
||||
@@ -130,6 +130,7 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
|
||||
*/
|
||||
private float mCurrentPosition;
|
||||
private float mFinalPosition;
|
||||
private boolean mAreScreensBinding;
|
||||
private ObjectAnimator mAnimator;
|
||||
private @Nullable ObjectAnimator mAlphaAnimator;
|
||||
|
||||
@@ -163,7 +164,7 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
|
||||
|
||||
@Override
|
||||
public void setScroll(int currentScroll, int totalScroll) {
|
||||
if (SHOW_DOT_PAGINATION.get() && mActivePage != 0 && currentScroll == 0) {
|
||||
if (SHOW_DOT_PAGINATION.get() && currentScroll == 0 && totalScroll == 0) {
|
||||
CURRENT_POSITION.set(this, (float) mActivePage);
|
||||
return;
|
||||
}
|
||||
@@ -172,6 +173,11 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip scroll update during binding. We will update it when binding completes.
|
||||
if (mAreScreensBinding) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mShouldAutoHide) {
|
||||
animatePaginationToAlpha(VISIBLE_ALPHA);
|
||||
}
|
||||
@@ -358,6 +364,16 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAreScreensBinding(boolean areScreensBinding) {
|
||||
// Reapply correct current position which was skipped during setScroll.
|
||||
if (mAreScreensBinding && !areScreensBinding) {
|
||||
CURRENT_POSITION.set(this, (float) mActivePage);
|
||||
}
|
||||
|
||||
mAreScreensBinding = areScreensBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
// Add extra spacing of mDotRadius on all sides so than entry animation could be run.
|
||||
|
||||
Reference in New Issue
Block a user