Skip to content

Commit 961bf0e

Browse files
committed
Accessibility focus on temporary detached view not cleared.
1. When a view that has accessibility focus is temporary detached we try to draw the focus highlight and crash. Since the detached view will be modified and then either attached or detached from the window we should not keep accessibility focus on a temporary detached view. Otherwise, we may have a scenario where the user thinks he is in one item scroll acound and being in completely different item because of the view being recycled but the user has no clue. 2. Clearing accessibility focus when the view is removed from the parent as opposed as when it is detached from the window. Since we may have transitioning views for removal we do not want accessibility focus on such views during the anumation. bug:6457339 Change-Id: I62287a089ec6850fb1d691ae26dea54e1da39c94
1 parent 775bcac commit 961bf0e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

core/java/android/view/View.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6665,6 +6665,7 @@ public TextSegmentIterator getIteratorForGranularity(int granularity) {
66656665
* @hide
66666666
*/
66676667
public void dispatchStartTemporaryDetach() {
6668+
clearAccessibilityFocus();
66686669
onStartTemporaryDetach();
66696670
}
66706671

@@ -11279,7 +11280,6 @@ protected void onDetachedFromWindow() {
1127911280
resetResolvedLayoutDirection();
1128011281
resetResolvedTextAlignment();
1128111282
resetAccessibilityStateChanged();
11282-
clearAccessibilityFocus();
1128311283
}
1128411284

1128511285
/**

core/java/android/view/ViewGroup.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,6 +3586,8 @@ private void removeViewInternal(int index, View view) {
35863586
clearChildFocus = true;
35873587
}
35883588

3589+
view.clearAccessibilityFocus();
3590+
35893591
cancelTouchTarget(view);
35903592
cancelHoverTarget(view);
35913593

@@ -3669,6 +3671,8 @@ private void removeViewsInternal(int start, int count) {
36693671
clearChildFocus = view;
36703672
}
36713673

3674+
view.clearAccessibilityFocus();
3675+
36723676
cancelTouchTarget(view);
36733677
cancelHoverTarget(view);
36743678

@@ -3742,6 +3746,8 @@ public void removeAllViewsInLayout() {
37423746
clearChildFocus = view;
37433747
}
37443748

3749+
view.clearAccessibilityFocus();
3750+
37453751
cancelTouchTarget(view);
37463752
cancelHoverTarget(view);
37473753

@@ -3790,6 +3796,8 @@ protected void removeDetachedView(View child, boolean animate) {
37903796
child.clearFocus();
37913797
}
37923798

3799+
child.clearAccessibilityFocus();
3800+
37933801
cancelTouchTarget(child);
37943802
cancelHoverTarget(child);
37953803

0 commit comments

Comments
 (0)