diff options
author | Federico Baron <fbaron@google.com> | 2022-12-08 14:53:46 -0800 |
---|---|---|
committer | Federico Baron <fbaron@google.com> | 2022-12-08 15:00:02 -0800 |
commit | 3f82a06c7fc440fe62262e3c1c53450a4371900b (patch) | |
tree | eccec911a08cd85c0dee094ed1b6aa2a3d0dbb3e /src/com/android/launcher3/pageindicators | |
parent | 9898d7906eb01eb0630c3f6b59d92afa9de796b1 (diff) | |
download | Launcher3-3f82a06c7fc440fe62262e3c1c53450a4371900b.tar.gz |
Remove delightful page indicator
Due to design changes, we are no longer going to use the changes guarded under the flag SHOW_DELIIGHTFUL_PAGINATION, so we remove the flag and the code that was guarded by that flag
Bug: 261904707
Test: verify flag SHOW_DELIGHTFUL_PAGINATION no longer exists and that the regular pagination works without issues after removing all this code
Change-Id: I244b88b98df0357aa99a325a11988e8248a03206
Diffstat (limited to 'src/com/android/launcher3/pageindicators')
-rw-r--r-- | src/com/android/launcher3/pageindicators/PageIndicatorDots.java | 178 |
1 files changed, 21 insertions, 157 deletions
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java index e9b660626b..c324ce3cf5 100644 --- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java +++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java @@ -16,7 +16,6 @@ package com.android.launcher3.pageindicators; -import static com.android.launcher3.config.FeatureFlags.SHOW_DELIGHTFUL_PAGINATION; import static com.android.launcher3.config.FeatureFlags.SHOW_DOT_PAGINATION; import android.animation.Animator; @@ -32,7 +31,6 @@ import android.graphics.Paint; import android.graphics.Paint.Style; import android.graphics.Rect; import android.graphics.RectF; -import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Looper; import android.util.AttributeSet; @@ -48,7 +46,6 @@ import androidx.annotation.Nullable; import com.android.launcher3.Insettable; import com.android.launcher3.R; import com.android.launcher3.Utilities; -import com.android.launcher3.anim.Interpolators; import com.android.launcher3.util.Themes; /** @@ -70,7 +67,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator private static final int PAGE_INDICATOR_ALPHA = 255; private static final int DOT_ALPHA = 128; private static final int DOT_GAP_FACTOR = 3; - private static final float DOT_GAP_FACTOR_FLOAT = 3.8f; private static final int VISIBLE_ALPHA = 1; private static final int INVISIBLE_ALPHA = 0; private Paint mPaginationPaint; @@ -78,8 +74,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator // This value approximately overshoots to 1.5 times the original size. private static final float ENTER_ANIMATION_OVERSHOOT_TENSION = 4.9f; - private static final float INDICATOR_ROTATION = 180f; - private static final RectF sTempRect = new RectF(); private static final FloatProperty<PageIndicatorDots> CURRENT_POSITION = @@ -112,11 +106,8 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator }; private final Handler mDelayedPaginationFadeHandler = new Handler(Looper.getMainLooper()); - private final Drawable mPageIndicatorDrawable; private final float mDotRadius; private final float mCircleGap; - private final float mPageIndicatorSize; - private final float mPageIndicatorRadius; private final boolean mIsRtl; private int mNumPages; @@ -159,31 +150,14 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator mPaginationPaint.setStyle(Style.FILL); mPaginationPaint.setColor(Themes.getAttrColor(context, R.attr.folderPaginationColor)); mDotRadius = getResources().getDimension(R.dimen.page_indicator_dot_size) / 2; - - if (SHOW_DELIGHTFUL_PAGINATION.get()) { - mPageIndicatorSize = getResources().getDimension( - R.dimen.page_indicator_size); - mPageIndicatorRadius = mPageIndicatorSize / 2; - mPageIndicatorDrawable = context.getDrawable(R.drawable.page_indicator); - mPageIndicatorDrawable.setBounds(0, 0, (int) mPageIndicatorSize, - (int) mPageIndicatorSize); - mCircleGap = DOT_GAP_FACTOR_FLOAT * mDotRadius; - - } else { - mPageIndicatorSize = 0; - mPageIndicatorRadius = 0; - mPageIndicatorDrawable = null; - mCircleGap = DOT_GAP_FACTOR * mDotRadius; - } - if (!SHOW_DELIGHTFUL_PAGINATION.get()) { - setOutlineProvider(new MyOutlineProver()); - } + mCircleGap = DOT_GAP_FACTOR * mDotRadius; + setOutlineProvider(new MyOutlineProver()); mIsRtl = Utilities.isRtl(getResources()); } @Override public void setScroll(int currentScroll, int totalScroll) { - if (SHOW_DELIGHTFUL_PAGINATION.get() || SHOW_DOT_PAGINATION.get()) { + if (SHOW_DOT_PAGINATION.get()) { animatePaginationToAlpha(VISIBLE_ALPHA); } @@ -197,16 +171,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator } mTotalScroll = totalScroll; - if (SHOW_DELIGHTFUL_PAGINATION.get()) { - mCurrentScroll = currentScroll; - invalidate(); - - if (mShouldAutoHide - && (getScrollPerPage() == 0 || mCurrentScroll % getScrollPerPage() == 0)) { - hideAfterDelay(); - } - return; - } int scrollPerPage = totalScroll / (mNumPages - 1); int pageToLeft = currentScroll / scrollPerPage; @@ -404,122 +368,45 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator } for (int i = 0; i < mEntryAnimationRadiusFactors.length; i++) { mPaginationPaint.setAlpha(i == mActivePage ? PAGE_INDICATOR_ALPHA : DOT_ALPHA); - if (SHOW_DELIGHTFUL_PAGINATION.get()) { - if (i != mActivePage) { - canvas.drawCircle(x, y, mDotRadius * mEntryAnimationRadiusFactors[i], - mPaginationPaint); - } else { - drawPageIndicator(canvas, mEntryAnimationRadiusFactors[i]); - } - } else { - canvas.drawCircle(x, y, mDotRadius * mEntryAnimationRadiusFactors[i], - mPaginationPaint); - } + canvas.drawCircle(x, y, mDotRadius * mEntryAnimationRadiusFactors[i], + mPaginationPaint); x += circleGap; } } else { // Here we draw the dots mPaginationPaint.setAlpha(DOT_ALPHA); for (int i = 0; i < mNumPages; i++) { - if (SHOW_DELIGHTFUL_PAGINATION.get()) { - canvas.drawCircle(x, y, getRadius(x), mPaginationPaint); - } else { - canvas.drawCircle(x, y, mDotRadius, mPaginationPaint); - } + canvas.drawCircle(x, y, mDotRadius, mPaginationPaint); x += circleGap; } // Here we draw the current page indicator mPaginationPaint.setAlpha(PAGE_INDICATOR_ALPHA); - if (SHOW_DELIGHTFUL_PAGINATION.get()) { - drawPageIndicator(canvas, 1); - } else { - canvas.drawRoundRect(getActiveRect(), mDotRadius, mDotRadius, mPaginationPaint); - } + canvas.drawRoundRect(getActiveRect(), mDotRadius, mDotRadius, mPaginationPaint); } } - /** - * Draws the page indicator, denoting the currently selected page - * - * @param canvas is used to draw the page indicator and to rotate it as we scroll - * @param scale is used to set the scale of our canvas - */ - private void drawPageIndicator(Canvas canvas, float scale) { - RectF currRect = getActiveRect(); - - // saves the canvas so we can later restore it to its original scale - canvas.save(); - - // Moves the canvas to start at the top left corner of the page indicator - canvas.translate(currRect.left, currRect.top); - - // Scales the canvas in place to animate the indicator on entry - canvas.scale(scale, scale, mPageIndicatorRadius, mPageIndicatorRadius); - - int scrollPerPage = getScrollPerPage(); - // This IF is to avoid division by 0 - if (scrollPerPage != 0) { - int delta = mCurrentScroll % scrollPerPage; - canvas.rotate((INDICATOR_ROTATION * delta) / scrollPerPage, - mPageIndicatorRadius, mPageIndicatorRadius); - } - - mPageIndicatorDrawable.draw(canvas); - canvas.restore(); - } - - /** - * Returns the radius of the circle based on how close the page indicator is to it - * - * @param dotPositionX is the position the dot is located at in the x-axis - */ - private float getRadius(float dotPositionX) { - - float startXIndicator = - ((getWidth() - (mNumPages * mCircleGap) + mDotRadius) / 2) - getOffset(); - float indicatorPosition = startXIndicator + getIndicatorScrollDistance() - + mPageIndicatorRadius; - - // If the indicator gets close enough to a dot then we change the radius - // of the dot based on how close the indicator is to it. - float dotDistance = Math.abs(indicatorPosition - dotPositionX); - if (dotDistance <= mCircleGap) { - return Utilities.mapToRange(dotDistance, 0, mCircleGap, 0f, mDotRadius, - Interpolators.LINEAR); - } - return mDotRadius; - } - private RectF getActiveRect() { float startCircle = (int) mCurrentPosition; float delta = mCurrentPosition - startCircle; float diameter = 2 * mDotRadius; float startX; - if (SHOW_DELIGHTFUL_PAGINATION.get()) { - startX = ((getWidth() - (mNumPages * mCircleGap) + mDotRadius) / 2) - getOffset(); - sTempRect.top = (getHeight() - mPageIndicatorSize) * 0.5f; - sTempRect.bottom = (getHeight() + mPageIndicatorSize) * 0.5f; - sTempRect.left = startX + getIndicatorScrollDistance(); - sTempRect.right = sTempRect.left + mPageIndicatorSize; + startX = ((getWidth() - (mNumPages * mCircleGap) + mDotRadius) / 2); + sTempRect.top = (getHeight() * 0.5f) - mDotRadius; + sTempRect.bottom = (getHeight() * 0.5f) + mDotRadius; + sTempRect.left = startX + (startCircle * mCircleGap); + sTempRect.right = sTempRect.left + diameter; + + if (delta < SHIFT_PER_ANIMATION) { + // dot is capturing the right circle. + sTempRect.right += delta * mCircleGap * 2; } else { - startX = ((getWidth() - (mNumPages * mCircleGap) + mDotRadius) / 2); - sTempRect.top = (getHeight() * 0.5f) - mDotRadius; - sTempRect.bottom = (getHeight() * 0.5f) + mDotRadius; - sTempRect.left = startX + (startCircle * mCircleGap); - sTempRect.right = sTempRect.left + diameter; - - if (delta < SHIFT_PER_ANIMATION) { - // dot is capturing the right circle. - sTempRect.right += delta * mCircleGap * 2; - } else { - // Dot is leaving the left circle. - sTempRect.right += mCircleGap; - - delta -= SHIFT_PER_ANIMATION; - sTempRect.left += delta * mCircleGap * 2; - } + // Dot is leaving the left circle. + sTempRect.right += mCircleGap; + + delta -= SHIFT_PER_ANIMATION; + sTempRect.left += delta * mCircleGap * 2; } if (mIsRtl) { @@ -531,29 +418,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator return sTempRect; } - /** - * The offset between the radius of the dot and the midpoint of the indicator so that - * the indicator is centered in with the indicator circles - */ - private float getOffset() { - return mPageIndicatorRadius - mDotRadius; - } - - /** - * Returns an int that is the amount we need to scroll per page - */ - private int getScrollPerPage() { - return mNumPages > 1 ? mTotalScroll / (mNumPages - 1) : 0; - } - - /** - * The current scroll adjusted for the distance the indicator needs to travel on the screen - */ - private float getIndicatorScrollDistance() { - int scrollPerPage = getScrollPerPage(); - return scrollPerPage != 0 ? ((float) mCurrentScroll / scrollPerPage) * mCircleGap : 0; - } - private class MyOutlineProver extends ViewOutlineProvider { @Override |