From ca575236145d1c739c2b17ba4abc95c0e2c029bc Mon Sep 17 00:00:00 2001 From: Evan Rosky Date: Thu, 26 Oct 2017 12:50:33 -0700 Subject: [DO NOT MERGE] Fix some mouse + list-item selection/scrolling issues Any "touch" interaction now hides selection (since mouse doesn't enable touch-mode, this wasn't happening anymore; also, allowing listview to scroll an actual selection off-screen would be very involved and risky). The selector hilight remains (since mouse doesn't enter touch-mode). This is a new scenario, so this change also makes sure to hide the selector hilight when it's target view is scrolled off-screen. Bug: 67881712 Bug: 67720587 Test: Existing CTS tests still pass. Can now click list items via mouse even when scrolled. Visually checked that that selector hilight is not visible if off-screen. Change-Id: Ia7b0fd7b247e8d9d9e609364a5500717df648fd9 --- core/java/android/widget/AbsListView.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 5476ab216f2f..4ee92b3c3209 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -3873,6 +3873,7 @@ public abstract class AbsListView extends AdapterView implements Te private void onTouchDown(MotionEvent ev) { mHasPerformedLongPress = false; mActivePointerId = ev.getPointerId(0); + hideSelector(); if (mTouchMode == TOUCH_MODE_OVERFLING) { // Stopped the fling. It is a scroll. @@ -5233,17 +5234,21 @@ public abstract class AbsListView extends AdapterView implements Te } mRecycler.fullyDetachScrapViews(); + boolean selectorOnScreen = false; if (!inTouchMode && mSelectedPosition != INVALID_POSITION) { final int childIndex = mSelectedPosition - mFirstPosition; if (childIndex >= 0 && childIndex < getChildCount()) { positionSelector(mSelectedPosition, getChildAt(childIndex)); + selectorOnScreen = true; } } else if (mSelectorPosition != INVALID_POSITION) { final int childIndex = mSelectorPosition - mFirstPosition; if (childIndex >= 0 && childIndex < getChildCount()) { - positionSelector(INVALID_POSITION, getChildAt(childIndex)); + positionSelector(mSelectorPosition, getChildAt(childIndex)); + selectorOnScreen = true; } - } else { + } + if (!selectorOnScreen) { mSelectorRect.setEmpty(); } -- cgit v1.2.3-59-g8ed1b