Merge "Match Folder Indicator Arrows according to specs." into main

This commit is contained in:
Stefan Andonian
2025-04-09 09:21:39 -07:00
committed by Android (Google) Code Review
4 changed files with 65 additions and 24 deletions
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/folder_arrow_icon_length"
android:height="@dimen/folder_arrow_icon_length"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M464,480L604,620Q622,638 622,664Q622,690 604,708Q586,726 560,726Q534,726 516,708L333,525Q324,516 319,504Q314,492 314,480Q314,468 319,456Q324,444 333,435L516,252Q534,234 560,234Q586,234 604,252Q622,270 622,296Q622,322 604,340L464,480Z"/>
</vector>
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/folder_arrow_icon_length"
android:height="@dimen/folder_arrow_icon_length"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M472,480L332,340Q314,322 314,296Q314,270 332,252Q350,234 376,234Q402,234 420,252L603,435Q612,444 617,456Q622,468 622,480Q622,492 617,504Q612,516 603,525L420,708Q402,726 376,726Q350,726 332,708Q314,690 314,664Q314,638 332,620L472,480Z"/>
</vector>
+2
View File
@@ -323,6 +323,8 @@
<!-- label text size = workspace text size multiplied by this scale -->
<dimen name="folder_label_text_scale">1.14</dimen>
<dimen name="folder_footer_height_default">56dp</dimen>
<dimen name="folder_arrow_gap_width">8dp</dimen>
<dimen name="folder_arrow_icon_length">24dp</dimen>
<dimen name="folder_content_padding_left_right">8dp</dimen>
<dimen name="folder_content_padding_top">16dp</dimen>
@@ -27,9 +27,12 @@ import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.VectorDrawable;
@@ -45,8 +48,10 @@ import android.view.ViewOutlineProvider;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
@@ -63,7 +68,6 @@ import java.util.function.Consumer;
* WorkspacePageIndicator. A lot of the functionality in this class is only used by one UI purpose.
*/
public class PageIndicatorDots extends View implements Insettable, PageIndicator {
private static final float SHIFT_PER_ANIMATION = 0.5f;
private static final float SHIFT_THRESHOLD = (enableLauncherVisualRefresh() ? 0.5f : 0.2f);
private static final long ANIMATION_DURATION = (enableLauncherVisualRefresh() ? 200 : 150);
@@ -71,13 +75,15 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
private static final int PAGINATION_FADE_IN_DURATION = 83;
private static final int PAGINATION_FADE_OUT_DURATION = 167;
private static final int DISABLED_ARROW_OPACITY = 97; // 38%
private static final int ENTER_ANIMATION_START_DELAY = 300;
private static final int ENTER_ANIMATION_STAGGERED_DELAY = 150;
private static final int ENTER_ANIMATION_DURATION = 400;
private static final int HEIGHT_MULTIPLIER = 4;
private static final int WIDTH_MULTIPLIER = 3;
private static final float ARROW_TOUCH_BOX_FACTOR = 5f;
private static final float ARROW_TOUCH_BOX_FACTOR = 2f;
private static final int PAGE_INDICATOR_ALPHA = 255;
private static final int DOT_ALPHA = 128;
@@ -133,8 +139,10 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
private final VectorDrawable mArrowLeft;
private final Rect mArrowRightBounds = new Rect();
private final Rect mArrowLeftBounds = new Rect();
private final int mArrowWidth;
private final int mArrowHeight;
private final int mArrowTouchBoxExtraWidth;
private final int mArrowTouchBoxHeight;
private final int mArrowGapWidth;
private final int mArrowLength;
private int mNumPages;
private int mActivePage;
@@ -186,13 +194,23 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
: DOT_GAP_FACTOR * mDotRadius;
setOutlineProvider(new MyOutlineProver());
mIsRtl = Utilities.isRtl(getResources());
mArrowRight = (VectorDrawable) getResources().getDrawable(R.drawable.ic_chevron_end);
mArrowLeft = (VectorDrawable) getResources().getDrawable(R.drawable.ic_chevron_start);
mArrowRight = setupArrow(R.drawable.ic_chevron_right_rounded_700);
mArrowLeft = setupArrow(R.drawable.ic_chevron_left_rounded_700);
/* the width of the arrows themselves plus extra folder / touch padding. x2 for 2 arrows. */
mArrowWidth = 2 * ((int) ((5.5f) * mGapWidth)
mArrowTouchBoxExtraWidth = 2 * ((int) ((5.5f) * mGapWidth)
+ getResources().getDimensionPixelSize(R.dimen.folder_footer_horiz_padding));
mArrowHeight =
mArrowTouchBoxHeight =
getResources().getDimensionPixelSize(R.dimen.folder_footer_height_default);
mArrowLength = getResources().getDimensionPixelSize(R.dimen.folder_arrow_icon_length);
mArrowGapWidth = getResources().getDimensionPixelSize(R.dimen.folder_arrow_gap_width);
}
private VectorDrawable setupArrow(@DrawableRes int resId) {
VectorDrawable icon = (VectorDrawable) ContextCompat.getDrawable(getContext(), resId);
ColorFilter arrowColorFilter = new PorterDuffColorFilter(mPaginationPaint.getColor(),
PorterDuff.Mode.SRC_ATOP);
icon.setColorFilter(arrowColorFilter);
return icon;
}
@Override
@@ -460,8 +478,8 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
: (int) (HEIGHT_MULTIPLIER * mDotRadius);
if (enableLauncherVisualRefresh() && mOnArrowClickListener != null) {
// Extra height and width and gaps for accessibility arrows.
width += mArrowWidth;
height = mArrowHeight;
width += mArrowTouchBoxExtraWidth;
height = mArrowTouchBoxHeight;
}
setMeasuredDimension(width, height);
}
@@ -554,14 +572,13 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
float bounceProgress = (posDif > 1) ? posDif - 1 : 0;
float bounceAdjustment = Math.abs(currentPosition - boundedPosition) * diameter;
if (mOnArrowClickListener != null && boundedPosition >= 1) {
if (mOnArrowClickListener != null) {
// Here we draw the Left Arrow
mArrowLeft.setAlpha(alpha);
int size = (int) (mGapWidth * 4);
mArrowLeftBounds.left = (int) (sTempRect.left - mGapWidth - size);
mArrowLeftBounds.top = (int) (y - size / 2);
mArrowLeftBounds.right = (int) (sTempRect.left - mGapWidth);
mArrowLeftBounds.bottom = (int) (y + size / 2);
mArrowLeft.setAlpha(boundedPosition == 0 ? DISABLED_ARROW_OPACITY : alpha);
mArrowLeftBounds.left = (int) (sTempRect.left - mArrowGapWidth - mArrowLength);
mArrowLeftBounds.top = (int) (y - (float) mArrowLength / 2);
mArrowLeftBounds.right = mArrowLeftBounds.left + mArrowLength;
mArrowLeftBounds.bottom = mArrowLeftBounds.top + mArrowLength;
mArrowLeft.setBounds(mArrowLeftBounds);
mArrowLeft.draw(canvas);
}
@@ -622,14 +639,14 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
sTempRect.left = sTempRect.right + mGapWidth;
}
if (mOnArrowClickListener != null && boundedPosition <= mNumPages - 2) {
if (mOnArrowClickListener != null) {
// Here we draw the Right Arrow
mArrowRight.setAlpha(alpha);
int size = (int) (mGapWidth * 4);
mArrowRightBounds.left = (int) sTempRect.left;
mArrowRightBounds.top = (int) (y - size / 2);
mArrowRightBounds.right = (int) (int) (sTempRect.left + size);
mArrowRightBounds.bottom = (int) (y + size / 2);
mArrowRight.setAlpha(boundedPosition == (mNumPages - 1)
? DISABLED_ARROW_OPACITY : alpha);
mArrowRightBounds.left = (int) (sTempRect.left - mGapWidth + mArrowGapWidth);
mArrowRightBounds.top = (int) (y - (float) mArrowLength / 2);
mArrowRightBounds.right = mArrowRightBounds.left + mArrowLength;
mArrowRightBounds.bottom = mArrowRightBounds.top + mArrowLength;
mArrowRight.setBounds(mArrowRightBounds);
mArrowRight.draw(canvas);
}