Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1c1c873 authored by Brandon Dayauon's avatar Brandon Dayauon Committed by Android (Google) Code Review
Browse files

Merge changes from topic "fastScrollerPrivateSpaceDrawableToLetters" into main

* changes:
  Update letter list textview background color to spec.
  Remove color animations when scrolling.
parents b484225c 7e114947
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
  -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="?attr/materialColorSurfaceContainer" />
    <solid android:color="?attr/materialColorSurface" />
    <corners android:radius="100dp"/>
    <size
        android:width="@dimen/bg_letter_list_text_size"
+0 −19
Original line number Diff line number Diff line
@@ -42,8 +42,6 @@ public class LetterListTextView extends TextView {
    private final Drawable mLetterBackground;
    private final int mLetterListTextWidthAndHeight;
    private final int mTextColor;
    private final int mBackgroundColor;
    private final int mSelectedColor;

    public LetterListTextView(Context context) {
        this(context, null, 0);
@@ -59,8 +57,6 @@ public class LetterListTextView extends TextView {
        mLetterListTextWidthAndHeight = context.getResources().getDimensionPixelSize(
                R.dimen.fastscroll_list_letter_size);
        mTextColor = Themes.getAttrColor(context, R.attr.materialColorOnSurface);
        mBackgroundColor = Themes.getAttrColor(context, R.attr.materialColorSurfaceContainer);
        mSelectedColor = Themes.getAttrColor(context, R.attr.materialColorOnSecondary);
    }

    @Override
@@ -101,26 +97,11 @@ public class LetterListTextView extends TextView {
        float cutOffMin = currentFingerY - (getHeight() * 2);
        float cutOffMax = currentFingerY + (getHeight() * 2);
        float cutOffDistance = cutOffMax - cutOffMin;
        // Update the background blend color
        boolean isWithinAnimationBounds = getY() < cutOffMax && getY() > cutOffMin;
        if (isWithinAnimationBounds) {
            getBackground().setColorFilter(new PorterDuffColorFilter(
                    getBlendColorBasedOnYPosition(currentFingerY, cutOffDistance),
                    PorterDuff.Mode.MULTIPLY));
        } else {
            getBackground().setColorFilter(new PorterDuffColorFilter(
                    mBackgroundColor, PorterDuff.Mode.MULTIPLY));
        }
        translateBasedOnYPosition(currentFingerY, cutOffDistance, isWithinAnimationBounds);
        scaleBasedOnYPosition(currentFingerY, cutOffDistance, isWithinAnimationBounds);
    }

    private int getBlendColorBasedOnYPosition(int y, float cutOffDistance) {
        float raisedCosineBlend = (float) Math.cos(((y - getY()) / (cutOffDistance)) * Math.PI);
        float blendRatio = Utilities.boundToRange(raisedCosineBlend, 0f, 1f);
        return ColorUtils.blendARGB(mBackgroundColor, mSelectedColor, blendRatio);
    }

    private void scaleBasedOnYPosition(int y, float cutOffDistance,
            boolean isWithinAnimationBounds) {
        float raisedCosineScale = (float) Math.cos(((y - getY()) / (cutOffDistance)) * Math.PI)