Merge branch 'android15-release' into merge-aosp15

This commit is contained in:
MrSluffy committed 2024-09-14 17:29:57 +08:00
commit eeb7416bfe
1401 files changed
+86072 -39248

No files matched your search

@@ -30,7 +30,7 @@ import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Property;
@@ -40,7 +40,6 @@ import android.view.ViewConfiguration;
import android.view.WindowInsets;
import android.widget.TextView;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;
import com.android.launcher3.FastScrollRecyclerView;
@@ -112,6 +111,13 @@ public class RecyclerViewFastScroller extends View {
private float mLastTouchY;
private boolean mIsDragging;
/**
* Tracks whether a keyboard hide request has been sent due to downward scrolling.
* <p>
* Set to true when scrolling down and reset when scrolling up to prevents redundant hide
* requests during continuous downward scrolls.
*/
private boolean mRequestedHideKeyboard;
private boolean mIsThumbDetached;
private final boolean mCanThumbDetach;
private boolean mIgnoreDragGesture;
@@ -125,11 +131,12 @@ public class RecyclerViewFastScroller extends View {
// Fast scroller popup
private TextView mPopupView;
private boolean mPopupVisible;
private String mPopupSectionName;
private CharSequence mPopupSectionName;
private Insets mSystemGestureInsets;
protected FastScrollRecyclerView mRv;
private RecyclerView.OnScrollListener mOnScrollListener;
private final ActivityContext mActivityContext;
private int mDownX;
private int mDownY;
@@ -166,7 +173,7 @@ public class RecyclerViewFastScroller extends View {
mDeltaThreshold = res.getDisplayMetrics().density * SCROLL_DELTA_THRESHOLD_DP;
mScrollbarLeftOffsetTouchDelegate = res.getDisplayMetrics().density
* SCROLLBAR_LEFT_OFFSET_TOUCH_DELEGATE_DP;
mActivityContext = ActivityContext.lookupContext(context);
TypedArray ta =
context.obtainStyledAttributes(attrs, R.styleable.RecyclerViewFastScroller, defStyleAttr, 0);
mCanThumbDetach = ta.getBoolean(R.styleable.RecyclerViewFastScroller_canThumbDetach, false);
@@ -251,6 +258,7 @@ public class RecyclerViewFastScroller extends View {
mDownX = x;
mDownY = mLastY = y;
mDownTimeStampMillis = ev.getDownTime();
mRequestedHideKeyboard = false;
if ((Math.abs(mDy) < mDeltaThreshold &&
mRv.getScrollState() != SCROLL_STATE_IDLE)) {
@@ -263,6 +271,7 @@ public class RecyclerViewFastScroller extends View {
}
break;
case MotionEvent.ACTION_MOVE:
boolean isScrollingDown = y > mLastY;
mLastY = y;
int absDeltaY = Math.abs(y - mDownY);
int absDeltaX = Math.abs(x - mDownX);
@@ -278,6 +287,14 @@ public class RecyclerViewFastScroller extends View {
}
}
if (mIsDragging) {
if (isScrollingDown) {
if (!mRequestedHideKeyboard) {
mActivityContext.hideKeyboard();
}
mRequestedHideKeyboard = true;
} else {
mRequestedHideKeyboard = false;
}
updateFastScrollSectionNameAndThumbOffset(y);
}
break;
@@ -297,7 +314,6 @@ public class RecyclerViewFastScroller extends View {
}
private void calcTouchOffsetAndPrepToFastScroll(int downY, int lastY) {
ActivityContext.lookupContext(getContext()).hideKeyboard();
mIsDragging = true;
if (mCanThumbDetach) {
mIsThumbDetached = true;
@@ -311,13 +327,13 @@ public class RecyclerViewFastScroller extends View {
// Update the fastscroller section name at this touch position
int bottom = mRv.getScrollbarTrackHeight() - mThumbHeight;
float boundedY = (float) Math.max(0, Math.min(bottom, y - mTouchOffsetY));
String sectionName = mRv.scrollToPositionAtProgress(boundedY / bottom);
CharSequence sectionName = mRv.scrollToPositionAtProgress(boundedY / bottom);
if (!sectionName.equals(mPopupSectionName)) {
mPopupSectionName = sectionName;
mPopupView.setText(sectionName);
performHapticFeedback(CLOCK_TICK);
}
animatePopupVisibility(!sectionName.isEmpty());
animatePopupVisibility(!TextUtils.isEmpty(sectionName));
mLastTouchY = boundedY;
setThumbOffsetY((int) mLastTouchY);
}
@@ -354,26 +370,21 @@ public class RecyclerViewFastScroller extends View {
float r = getScrollThumbRadius();
mThumbBounds.set(-halfW, 0, halfW, mThumbHeight);
canvas.drawRoundRect(mThumbBounds, r, r, mThumbPaint);
if (Utilities.ATLEAST_Q) {
mThumbBounds.roundOut(SYSTEM_GESTURE_EXCLUSION_RECT.get(0));
// swiping very close to the thumb area (not just within it's bound)
// will also prevent back gesture
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).offset(mThumbDrawOffset.x, mThumbDrawOffset.y);
if (Utilities.ATLEAST_Q && mSystemGestureInsets != null) {
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).left =
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).right - mSystemGestureInsets.right;
}
setSystemGestureExclusionRects(SYSTEM_GESTURE_EXCLUSION_RECT);
mThumbBounds.roundOut(SYSTEM_GESTURE_EXCLUSION_RECT.get(0));
// swiping very close to the thumb area (not just within it's bound)
// will also prevent back gesture
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).offset(mThumbDrawOffset.x, mThumbDrawOffset.y);
if (mSystemGestureInsets != null) {
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).left =
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).right - mSystemGestureInsets.right;
}
setSystemGestureExclusionRects(SYSTEM_GESTURE_EXCLUSION_RECT);
canvas.restoreToCount(saveCount);
}
@Override
@RequiresApi(Build.VERSION_CODES.Q)
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
if (Utilities.ATLEAST_Q) {
mSystemGestureInsets = insets.getSystemGestureInsets();
}
mSystemGestureInsets = insets.getSystemGestureInsets();
return super.onApplyWindowInsets(insets);
}