summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/View.java5
-rw-r--r--core/java/android/widget/AbsListView.java27
2 files changed, 18 insertions, 14 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 6adf656..b69450c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4325,7 +4325,6 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
if (gainFocus) {
if (AccessibilityManager.getInstance(mContext).isEnabled()) {
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
- requestAccessibilityFocus();
}
}
@@ -6183,8 +6182,6 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
invalidate();
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
notifyAccessibilityStateChanged();
- // Try to give input focus to this view - not a descendant.
- requestFocusNoSearch(View.FOCUS_DOWN, null);
return true;
}
return false;
@@ -6230,11 +6227,13 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
private void requestAccessibilityFocusFromHover() {
if (includeForAccessibility() && isActionableForAccessibility()) {
requestAccessibilityFocus();
+ requestFocusNoSearch(View.FOCUS_DOWN, null);
} else {
if (mParent != null) {
View nextFocus = mParent.findViewToTakeAccessibilityFocusFromHover(this, this);
if (nextFocus != null) {
nextFocus.requestAccessibilityFocus();
+ nextFocus.requestFocusNoSearch(View.FOCUS_DOWN, null);
}
}
}
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index a8e1043..42c4ed6 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -1352,24 +1352,23 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
case ACCESSIBILITY_FOCUS_FORWARD: {
ViewRootImpl viewRootImpl = getViewRootImpl();
if (viewRootImpl == null) {
- break;
+ return null;
}
View currentFocus = viewRootImpl.getAccessibilityFocusedHost();
if (currentFocus == null) {
- break;
+ return super.focusSearch(this, direction);
}
// If we have the focus try giving it to the first child.
if (currentFocus == this) {
- final int firstVisiblePosition = getFirstVisiblePosition();
- if (firstVisiblePosition >= 0) {
+ if (getChildCount() > 0) {
return getChildAt(0);
}
- return null;
+ return super.focusSearch(this, direction);
}
// Find the item that has accessibility focus.
final int currentPosition = getPositionForView(currentFocus);
if (currentPosition < 0 || currentPosition >= getCount()) {
- break;
+ return super.focusSearch(this, direction);
}
// Try to advance focus in the current item.
View currentItem = getChildAt(currentPosition - getFirstVisiblePosition());
@@ -1386,25 +1385,31 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
final int nextPosition = currentPosition - getFirstVisiblePosition() + 1;
if (nextPosition < getChildCount()) {
return getChildAt(nextPosition);
+ } else {
+ return super.focusSearch(this, direction);
}
- } break;
+ }
case ACCESSIBILITY_FOCUS_BACKWARD: {
ViewRootImpl viewRootImpl = getViewRootImpl();
if (viewRootImpl == null) {
- break;
+ return null;
}
View currentFocus = viewRootImpl.getAccessibilityFocusedHost();
if (currentFocus == null) {
- break;
+ return super.focusSearch(this, direction);
}
// If we have the focus do a generic search.
if (currentFocus == this) {
+ final int lastChildIndex = getChildCount() - 1;
+ if (lastChildIndex >= 0) {
+ return getChildAt(lastChildIndex);
+ }
return super.focusSearch(this, direction);
}
// Find the item that has accessibility focus.
final int currentPosition = getPositionForView(currentFocus);
if (currentPosition < 0 || currentPosition >= getCount()) {
- break;
+ return super.focusSearch(this, direction);
}
// Try to advance focus in the current item.
View currentItem = getChildAt(currentPosition - getFirstVisiblePosition());
@@ -1422,7 +1427,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
if (nextPosition >= 0) {
return getChildAt(nextPosition);
} else {
- return this;
+ return super.focusSearch(this, direction);
}
}
}