summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author Stefan Andonian <andonian@google.com> 2025-03-13 10:42:49 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-13 10:42:49 -0700
commitd84dbe35d8b9a1d85e543e42d34f455b3522c44a (patch)
tree5196b85176eb524325ff18d072d4568d681613dd /src
parenta29ec52ccec438e4a7de77a19d7dffba70f3d129 (diff)
parentdb74d32103fcf18bd0d29263e16d6cb7f893a252 (diff)
Merge "Fix Page Indicator Dots Arrow Clicks in RTL Mode" into main
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/pageindicators/PageIndicatorDots.java46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
index 211263835c..ab55317b16 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
@@ -130,10 +130,10 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
private final float mGapWidth;
private final float mCircleGap;
private final boolean mIsRtl;
- private final VectorDrawable mArrowEnd;
- private final VectorDrawable mArrowStart;
- private final Rect mArrowEndBounds = new Rect();
- private final Rect mArrowStartBounds = new Rect();
+ private final VectorDrawable mArrowRight;
+ private final VectorDrawable mArrowLeft;
+ private final Rect mArrowRightBounds = new Rect();
+ private final Rect mArrowLeftBounds = new Rect();
private int mNumPages;
private int mActivePage;
@@ -185,8 +185,8 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
: DOT_GAP_FACTOR * mDotRadius;
setOutlineProvider(new MyOutlineProver());
mIsRtl = Utilities.isRtl(getResources());
- mArrowEnd = (VectorDrawable) getResources().getDrawable(R.drawable.ic_chevron_end);
- mArrowStart = (VectorDrawable) getResources().getDrawable(R.drawable.ic_chevron_start);
+ mArrowRight = (VectorDrawable) getResources().getDrawable(R.drawable.ic_chevron_end);
+ mArrowLeft = (VectorDrawable) getResources().getDrawable(R.drawable.ic_chevron_start);
}
@Override
@@ -514,14 +514,14 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
if (mOnArrowClickListener != null && boundedPosition >= 1) {
// Here we draw the Left Arrow
- mArrowStart.setAlpha(alpha);
+ mArrowLeft.setAlpha(alpha);
int size = (int) (mGapWidth * 4);
- mArrowStartBounds.left = (int) (sTempRect.left - mGapWidth - size);
- mArrowStartBounds.top = (int) (y - size / 2);
- mArrowStartBounds.right = (int) (sTempRect.left - mGapWidth);
- mArrowStartBounds.bottom = (int) (y + size / 2);
- mArrowStart.setBounds(mArrowStartBounds);
- mArrowStart.draw(canvas);
+ 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.setBounds(mArrowLeftBounds);
+ mArrowLeft.draw(canvas);
}
// Here we draw the dots, one at a time from the left-most dot to the right-most dot
@@ -575,14 +575,14 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
if (mOnArrowClickListener != null && boundedPosition <= mNumPages - 2) {
// Here we draw the Right Arrow
- mArrowEnd.setAlpha(alpha);
+ mArrowRight.setAlpha(alpha);
int size = (int) (mGapWidth * 4);
- mArrowEndBounds.left = (int) sTempRect.left;
- mArrowEndBounds.top = (int) (y - size / 2);
- mArrowEndBounds.right = (int) (int) (sTempRect.left + size);
- mArrowEndBounds.bottom = (int) (y + size / 2);
- mArrowEnd.setBounds(mArrowEndBounds);
- mArrowEnd.draw(canvas);
+ 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.setBounds(mArrowRightBounds);
+ mArrowRight.draw(canvas);
}
} else {
// Here we draw the dots
@@ -606,9 +606,11 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
public boolean onTouchEvent(MotionEvent ev) {
if (mOnArrowClickListener == null) {
// No - Op. Don't care about touch events
- } else if (withinExpandedBounds(mArrowStartBounds, ev)) {
+ } else if ((mIsRtl && withinExpandedBounds(mArrowRightBounds, ev))
+ || (!mIsRtl && withinExpandedBounds(mArrowLeftBounds, ev))) {
mOnArrowClickListener.accept(Direction.START);
- } else if (withinExpandedBounds(mArrowEndBounds, ev)) {
+ } else if ((mIsRtl && withinExpandedBounds(mArrowLeftBounds, ev))
+ || (!mIsRtl && withinExpandedBounds(mArrowRightBounds, ev))) {
mOnArrowClickListener.accept(Direction.END);
}
return super.onTouchEvent(ev);