Fix pointer icon handling for invisible and overlapping views

Ignore invisible views. Allow overlapping views to handle
onResolvePointerIcon in top-to-bottom order.

This brings the pointer icon dispatch method in line with
the existing touch and hover dispatch.

Bug: 34114031
Test: android.view.cts.ViewTest#testPointerIconOverlap
Change-Id: I120d7c09f122e49afeeaf8ddad6880951b5ccc2c
This commit is contained in:
Vladislav Kaznacheev
2017-01-05 17:50:38 -08:00
parent 412706458e
commit 3d5cfc0488

View File

@@ -1759,15 +1759,15 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
for (int i = childrenCount - 1; i >= 0; i--) {
final int childIndex = getAndVerifyPreorderedIndex(childrenCount, i, customOrder);
final View child = getAndVerifyPreorderedView(preorderedList, children, childIndex);
final PointF point = getLocalPoint();
if (isTransformedTouchPointInView(x, y, child, point)) {
final PointerIcon pointerIcon =
dispatchResolvePointerIcon(event, pointerIndex, child);
if (pointerIcon != null) {
if (preorderedList != null) preorderedList.clear();
return pointerIcon;
}
break;
if (!canViewReceivePointerEvents(child)
|| !isTransformedTouchPointInView(x, y, child, null)) {
continue;
}
final PointerIcon pointerIcon =
dispatchResolvePointerIcon(event, pointerIndex, child);
if (pointerIcon != null) {
if (preorderedList != null) preorderedList.clear();
return pointerIcon;
}
}
if (preorderedList != null) preorderedList.clear();