From 64899e5c8ff7309e3209454fd4833d1b7a4b57be Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Tue, 15 May 2012 21:09:30 -0700 Subject: [PATCH] Accessiblity focus not following input focus and text nav broken. 1. View is checking if the accessibility focus is its descendant it clears the accessibility focus state in ViewRootImpl. The check in View was missing the case that the descendant may be the view itself. In such a case we want the normal clearing code to run. 2. The check whether a view has iterable text for accessibility was inverted and text nav was not working. Change-Id: I1a13b6809fb7f205fff76ca09cd449179d06e530 --- core/java/android/view/View.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index a4fcd41f17db6..53bb3c621010c 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -6159,7 +6159,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal ViewRootImpl viewRootImpl = getViewRootImpl(); if (viewRootImpl != null) { View focusHost = viewRootImpl.getAccessibilityFocusedHost(); - if (focusHost != null && ViewRootImpl.isViewDescendantOf(focusHost, this)) { + if (focusHost != null && focusHost != this + && ViewRootImpl.isViewDescendantOf(focusHost, this)) { viewRootImpl.setAccessibilityFocusedHost(null); } } @@ -6637,7 +6638,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal private boolean nextAtGranularity(int granularity) { CharSequence text = getIterableTextForAccessibility(); - if (text != null && text.length() > 0) { + if (text == null || text.length() == 0) { return false; } TextSegmentIterator iterator = getIteratorForGranularity(granularity); @@ -6661,7 +6662,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal private boolean previousAtGranularity(int granularity) { CharSequence text = getIterableTextForAccessibility(); - if (text != null && text.length() > 0) { + if (text == null || text.length() == 0) { return false; } TextSegmentIterator iterator = getIteratorForGranularity(granularity);