diff --git a/core/java/android/view/AccessibilityInteractionController.java b/core/java/android/view/AccessibilityInteractionController.java index 0aabc44a5a99d..4de0b01bb466f 100644 --- a/core/java/android/view/AccessibilityInteractionController.java +++ b/core/java/android/view/AccessibilityInteractionController.java @@ -574,38 +574,9 @@ final class AccessibilityInteractionController { root = mViewRootImpl.mView; } if (root != null && isShown(root)) { - if ((direction & View.FOCUS_ACCESSIBILITY) == View.FOCUS_ACCESSIBILITY) { - AccessibilityNodeProvider provider = root.getAccessibilityNodeProvider(); - if (provider != null) { - next = provider.accessibilityFocusSearch(direction, virtualDescendantId); - if (next != null) { - return; - } - } - View nextView = root.focusSearch(direction); - while (nextView != null) { - // If the focus search reached a node with a provider - // we delegate to the provider to find the next one. - // If the provider does not return a virtual view to - // take accessibility focus we try the next view found - // by the focus search algorithm. - provider = nextView.getAccessibilityNodeProvider(); - if (provider != null) { - next = provider.accessibilityFocusSearch(direction, View.NO_ID); - if (next != null) { - break; - } - nextView = nextView.focusSearch(direction); - } else { - next = nextView.createAccessibilityNodeInfo(); - break; - } - } - } else { - View nextView = root.focusSearch(direction); - if (nextView != null) { - next = nextView.createAccessibilityNodeInfo(); - } + View nextView = root.focusSearch(direction); + if (nextView != null) { + next = nextView.createAccessibilityNodeInfo(); } } } finally { diff --git a/core/java/android/view/FocusFinder.java b/core/java/android/view/FocusFinder.java index 31a9f05a10540..351c5c31f2707 100644 --- a/core/java/android/view/FocusFinder.java +++ b/core/java/android/view/FocusFinder.java @@ -79,17 +79,9 @@ public class FocusFinder { } private View findNextFocus(ViewGroup root, View focused, Rect focusedRect, int direction) { - if ((direction & View.FOCUS_ACCESSIBILITY) != View.FOCUS_ACCESSIBILITY) { - return findNextInputFocus(root, focused, focusedRect, direction); - } else { - return findNextAccessibilityFocus(root, focused, focusedRect, direction); - } - } - - private View findNextInputFocus(ViewGroup root, View focused, Rect focusedRect, int direction) { View next = null; if (focused != null) { - next = findNextUserSpecifiedInputFocus(root, focused, direction); + next = findNextUserSpecifiedFocus(root, focused, direction); } if (next != null) { return next; @@ -107,7 +99,7 @@ public class FocusFinder { return next; } - private View findNextUserSpecifiedInputFocus(ViewGroup root, View focused, int direction) { + private View findNextUserSpecifiedFocus(ViewGroup root, View focused, int direction) { // check for user specified next focus View userSetNextFocus = focused.findUserSetNextFocus(root, direction); if (userSetNextFocus != null && userSetNextFocus.isFocusable() @@ -120,7 +112,6 @@ public class FocusFinder { private View findNextFocus(ViewGroup root, View focused, Rect focusedRect, int direction, ArrayList focusables) { - final int directionMasked = (direction & ~View.FOCUS_ACCESSIBILITY); if (focused != null) { if (focusedRect == null) { focusedRect = mFocusedRect; @@ -132,7 +123,7 @@ public class FocusFinder { if (focusedRect == null) { focusedRect = mFocusedRect; // make up a rect at top left or bottom right of root - switch (directionMasked) { + switch (direction) { case View.FOCUS_RIGHT: case View.FOCUS_DOWN: setFocusTopLeft(root, focusedRect); @@ -160,37 +151,23 @@ public class FocusFinder { } } - switch (directionMasked) { + switch (direction) { case View.FOCUS_FORWARD: case View.FOCUS_BACKWARD: - return findNextInputFocusInRelativeDirection(focusables, root, focused, focusedRect, - directionMasked); + return findNextFocusInRelativeDirection(focusables, root, focused, focusedRect, + direction); case View.FOCUS_UP: case View.FOCUS_DOWN: case View.FOCUS_LEFT: case View.FOCUS_RIGHT: - return findNextInputFocusInAbsoluteDirection(focusables, root, focused, - focusedRect, directionMasked); + return findNextFocusInAbsoluteDirection(focusables, root, focused, + focusedRect, direction); default: - throw new IllegalArgumentException("Unknown direction: " + directionMasked); + throw new IllegalArgumentException("Unknown direction: " + direction); } } - private View findNextAccessibilityFocus(ViewGroup root, View focused, - Rect focusedRect, int direction) { - ArrayList focusables = mTempList; - try { - focusables.clear(); - root.addFocusables(focusables, direction, View.FOCUSABLES_ACCESSIBILITY); - View next = findNextFocus(root, focused, focusedRect, direction, - focusables); - return next; - } finally { - focusables.clear(); - } - } - - private View findNextInputFocusInRelativeDirection(ArrayList focusables, ViewGroup root, + private View findNextFocusInRelativeDirection(ArrayList focusables, ViewGroup root, View focused, Rect focusedRect, int direction) { try { // Note: This sort is stable. @@ -222,7 +199,7 @@ public class FocusFinder { focusedRect.set(rootLeft, rootTop, rootLeft, rootTop); } - View findNextInputFocusInAbsoluteDirection(ArrayList focusables, ViewGroup root, View focused, + View findNextFocusInAbsoluteDirection(ArrayList focusables, ViewGroup root, View focused, Rect focusedRect, int direction) { // initialize the best candidate to something impossible // (so the first plausible view will become the best choice) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index b6f0aa2c9eeea..3af1a3ecdb24d 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -1006,14 +1006,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ public static final int FOCUSABLES_TOUCH_MODE = 0x00000001; - /** - * View flag indicating whether {@link #addFocusables(ArrayList, int, int)} - * should add only accessibility focusable Views. - * - * @hide - */ - public static final int FOCUSABLES_ACCESSIBILITY = 0x00000002; - /** * Use with {@link #focusSearch(int)}. Move focus to the previous selectable * item. @@ -1046,58 +1038,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ public static final int FOCUS_DOWN = 0x00000082; - // Accessibility focus directions. - - /** - * The accessibility focus which is the current user position when - * interacting with the accessibility framework. - * - * @hide - */ - public static final int FOCUS_ACCESSIBILITY = 0x00001000; - - /** - * Use with {@link #focusSearch(int)}. Move acessibility focus left. - * - * @hide - */ - public static final int ACCESSIBILITY_FOCUS_LEFT = FOCUS_LEFT | FOCUS_ACCESSIBILITY; - - /** - * Use with {@link #focusSearch(int)}. Move acessibility focus up. - * - * @hide - */ - public static final int ACCESSIBILITY_FOCUS_UP = FOCUS_UP | FOCUS_ACCESSIBILITY; - - /** - * Use with {@link #focusSearch(int)}. Move acessibility focus right. - * - * @hide - */ - public static final int ACCESSIBILITY_FOCUS_RIGHT = FOCUS_RIGHT | FOCUS_ACCESSIBILITY; - - /** - * Use with {@link #focusSearch(int)}. Move acessibility focus down. - * - * @hide - */ - public static final int ACCESSIBILITY_FOCUS_DOWN = FOCUS_DOWN | FOCUS_ACCESSIBILITY; - - /** - * Use with {@link #focusSearch(int)}. Move acessibility focus forward. - * - * @hide - */ - public static final int ACCESSIBILITY_FOCUS_FORWARD = FOCUS_FORWARD | FOCUS_ACCESSIBILITY; - - /** - * Use with {@link #focusSearch(int)}. Move acessibility focus backward. - * - * @hide - */ - public static final int ACCESSIBILITY_FOCUS_BACKWARD = FOCUS_BACKWARD | FOCUS_ACCESSIBILITY; - /** * Bits of {@link #getMeasuredWidthAndState()} and * {@link #getMeasuredWidthAndState()} that provide the actual measured size. @@ -2135,71 +2075,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ static final int VIEW_QUICK_REJECTED = 0x10000000; - // Accessiblity constants for mPrivateFlags2 - - /** - * Shift for the bits in {@link #mPrivateFlags2} related to the - * "accessibilityFocusable" attribute. - */ - static final int ACCESSIBILITY_FOCUSABLE_SHIFT = 29; - - /** - * The system determines whether the view can take accessibility focus - default (recommended). - *

- * Such a view is consideted by the focus search if it is: - *

    - *
  • - * Important for accessibility and actionable (clickable, long clickable, focusable) - *
  • - *
  • - * Important for accessibility, not actionable (clickable, long clickable, focusable), - * and does not have an actionable predecessor. - *
  • - *
- * An accessibility srvice can request putting accessibility focus on such a view. - *

- * - * @hide - */ - public static final int ACCESSIBILITY_FOCUSABLE_AUTO = 0x00000000; - - /** - * The view can take accessibility focus. - *

- * A view that can take accessibility focus is always considered during focus - * search and an accessibility service can request putting accessibility focus - * on it. - *

- * - * @hide - */ - public static final int ACCESSIBILITY_FOCUSABLE_YES = 0x00000001; - - /** - * The view can not take accessibility focus. - *

- * A view that can not take accessibility focus is never considered during focus - * search and an accessibility service can not request putting accessibility focus - * on it. - *

- * - * @hide - */ - public static final int ACCESSIBILITY_FOCUSABLE_NO = 0x00000002; - - /** - * The default whether the view is accessiblity focusable. - */ - static final int ACCESSIBILITY_FOCUSABLE_DEFAULT = ACCESSIBILITY_FOCUSABLE_AUTO; - - /** - * Mask for obtainig the bits which specifies how to determine - * whether a view is accessibility focusable. - */ - static final int ACCESSIBILITY_FOCUSABLE_MASK = (ACCESSIBILITY_FOCUSABLE_AUTO - | ACCESSIBILITY_FOCUSABLE_YES | ACCESSIBILITY_FOCUSABLE_NO) - << ACCESSIBILITY_FOCUSABLE_SHIFT; - + // There are a couple of flags left in mPrivateFlags2 /* End of masks for mPrivateFlags2 */ @@ -3216,8 +3092,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mPrivateFlags2 = (LAYOUT_DIRECTION_DEFAULT << LAYOUT_DIRECTION_MASK_SHIFT) | (TEXT_DIRECTION_DEFAULT << TEXT_DIRECTION_MASK_SHIFT) | (TEXT_ALIGNMENT_DEFAULT << TEXT_ALIGNMENT_MASK_SHIFT) | - (IMPORTANT_FOR_ACCESSIBILITY_DEFAULT << IMPORTANT_FOR_ACCESSIBILITY_SHIFT) | - (ACCESSIBILITY_FOCUSABLE_DEFAULT << ACCESSIBILITY_FOCUSABLE_SHIFT); + (IMPORTANT_FOR_ACCESSIBILITY_DEFAULT << IMPORTANT_FOR_ACCESSIBILITY_SHIFT); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); setOverScrollMode(OVER_SCROLL_IF_CONTENT_SCROLLS); mUserPaddingStart = -1; @@ -4860,10 +4735,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } if (!isAccessibilityFocused()) { - final int mode = getAccessibilityFocusable(); - if (mode == ACCESSIBILITY_FOCUSABLE_YES || mode == ACCESSIBILITY_FOCUSABLE_AUTO) { - info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); - } + info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } else { info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS); } @@ -6166,12 +6038,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (views == null) { return; } - if ((focusableMode & FOCUSABLES_ACCESSIBILITY) == FOCUSABLES_ACCESSIBILITY) { - if (isAccessibilityFocusable()) { - views.add(this); - return; - } - } if (!isFocusable()) { return; } @@ -6336,29 +6202,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } - private void requestAccessibilityFocusFromHover() { - if (includeForAccessibility() && isActionableForAccessibility()) { - requestAccessibilityFocus(); - } else { - if (mParent != null) { - View nextFocus = mParent.findViewToTakeAccessibilityFocusFromHover(this, this); - if (nextFocus != null) { - nextFocus.requestAccessibilityFocus(); - } - } - } - } - - private boolean canTakeAccessibilityFocusFromHover() { - if (includeForAccessibility() && isActionableForAccessibility()) { - return true; - } - if (mParent != null) { - return (mParent.findViewToTakeAccessibilityFocusFromHover(this, this) == this); - } - return false; - } - /** * Clears accessibility focus without calling any callback methods * normally invoked in {@link #clearAccessibilityFocus()}. This method @@ -6573,73 +6416,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } - /** - * Gets the mode for determining whether this View can take accessibility focus. - * - * @return The mode for determining whether a View can take accessibility focus. - * - * @attr ref android.R.styleable#View_accessibilityFocusable - * - * @see #ACCESSIBILITY_FOCUSABLE_YES - * @see #ACCESSIBILITY_FOCUSABLE_NO - * @see #ACCESSIBILITY_FOCUSABLE_AUTO - * - * @hide - */ - @ViewDebug.ExportedProperty(category = "accessibility", mapping = { - @ViewDebug.IntToString(from = ACCESSIBILITY_FOCUSABLE_AUTO, to = "auto"), - @ViewDebug.IntToString(from = ACCESSIBILITY_FOCUSABLE_YES, to = "yes"), - @ViewDebug.IntToString(from = ACCESSIBILITY_FOCUSABLE_NO, to = "no") - }) - public int getAccessibilityFocusable() { - return (mPrivateFlags2 & ACCESSIBILITY_FOCUSABLE_MASK) >>> ACCESSIBILITY_FOCUSABLE_SHIFT; - } - - /** - * Sets how to determine whether this view can take accessibility focus. - * - * @param mode How to determine whether this view can take accessibility focus. - * - * @attr ref android.R.styleable#View_accessibilityFocusable - * - * @see #ACCESSIBILITY_FOCUSABLE_YES - * @see #ACCESSIBILITY_FOCUSABLE_NO - * @see #ACCESSIBILITY_FOCUSABLE_AUTO - * - * @hide - */ - public void setAccessibilityFocusable(int mode) { - if (mode != getAccessibilityFocusable()) { - mPrivateFlags2 &= ~ACCESSIBILITY_FOCUSABLE_MASK; - mPrivateFlags2 |= (mode << ACCESSIBILITY_FOCUSABLE_SHIFT) - & ACCESSIBILITY_FOCUSABLE_MASK; - notifyAccessibilityStateChanged(); - } - } - - /** - * Gets whether this view can take accessibility focus. - * - * @return Whether the view can take accessibility focus. - * - * @hide - */ - public boolean isAccessibilityFocusable() { - final int mode = (mPrivateFlags2 & ACCESSIBILITY_FOCUSABLE_MASK) - >>> ACCESSIBILITY_FOCUSABLE_SHIFT; - switch (mode) { - case ACCESSIBILITY_FOCUSABLE_YES: - return true; - case ACCESSIBILITY_FOCUSABLE_NO: - return false; - case ACCESSIBILITY_FOCUSABLE_AUTO: - return canTakeAccessibilityFocusFromHover() - || getAccessibilityNodeProvider() != null; - default: - throw new IllegalArgumentException("Unknow accessibility focusable mode: " + mode); - } - } - /** * Gets the parent for accessibility purposes. Note that the parent for * accessibility is not necessary the immediate parent. It is the first @@ -6821,10 +6597,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } break; case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS: { - final int mode = getAccessibilityFocusable(); - if (!isAccessibilityFocused() - && (mode == ACCESSIBILITY_FOCUSABLE_YES - || mode == ACCESSIBILITY_FOCUSABLE_AUTO)) { + if (!isAccessibilityFocused()) { return requestAccessibilityFocus(); } } break; diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index f66c4dedda8bb..102b504ce394a 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -624,11 +624,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * FOCUS_RIGHT, or 0 for not applicable. */ public View focusSearch(View focused, int direction) { - // If we are moving accessibility focus we want to consider all - // views no matter if they are on the screen. It is responsibility - // of the accessibility service to check whether the result is in - // the screen. - if (isRootNamespace() && (direction & FOCUS_ACCESSIBILITY) == 0) { + if (isRootNamespace()) { // root namespace means we should consider ourselves the top of the // tree for focus searching; otherwise we could be focus searching // into other tabs. see LocalActivityManager and TabHost for more info @@ -863,8 +859,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager final int descendantFocusability = getDescendantFocusability(); - if (descendantFocusability != FOCUS_BLOCK_DESCENDANTS - || (focusableMode & FOCUSABLES_ACCESSIBILITY) == FOCUSABLES_ACCESSIBILITY) { + if (descendantFocusability != FOCUS_BLOCK_DESCENDANTS) { final int count = mChildrenCount; final View[] children = mChildren; @@ -882,9 +877,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // among the focusable children would be more interesting. if (descendantFocusability != FOCUS_AFTER_DESCENDANTS // No focusable descendants - || (focusableCount == views.size()) - // We are collecting accessibility focusables. - || (focusableMode & FOCUSABLES_ACCESSIBILITY) == FOCUSABLES_ACCESSIBILITY) { + || (focusableCount == views.size())) { super.addFocusables(views, direction, focusableMode); } } @@ -1653,20 +1646,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } } - /** - * @hide - */ - @Override - public View findViewToTakeAccessibilityFocusFromHover(View child, View descendant) { - if (includeForAccessibility() && isActionableForAccessibility()) { - return this; - } - if (mParent != null) { - return mParent.findViewToTakeAccessibilityFocusFromHover(this, descendant); - } - return null; - } - /** * Implement this method to intercept hover events before they are handled * by child views. diff --git a/core/java/android/view/ViewParent.java b/core/java/android/view/ViewParent.java index d93b996085786..ddff91de0ac92 100644 --- a/core/java/android/view/ViewParent.java +++ b/core/java/android/view/ViewParent.java @@ -295,16 +295,4 @@ public interface ViewParent { * @hide */ public void childAccessibilityStateChanged(View child); - - /** - * A descendant requests this view to find a candidate to take accessibility - * focus from hover. - * - * @param child The child making the call. - * @param descendant The descendant that made the initial request. - * @return A view to take accessibility focus. - * - * @hide - */ - public View findViewToTakeAccessibilityFocusFromHover(View child, View descendant); } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 17783a49c9eae..e03c7d3fc59e4 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -76,7 +76,6 @@ import android.widget.Scroller; import com.android.internal.R; import com.android.internal.policy.PolicyManager; import com.android.internal.view.BaseSurfaceHolder; -import com.android.internal.view.IInputMethodSession; import com.android.internal.view.RootViewSurfaceTaker; import java.io.IOException; @@ -2278,14 +2277,6 @@ public final class ViewRootImpl implements ViewParent, return true; } - @Override - public View findViewToTakeAccessibilityFocusFromHover(View child, View descendant) { - if (descendant.includeForAccessibility()) { - return descendant; - } - return null; - } - /** * We want to draw a highlight around the current accessibility focused. * Since adding a style for all possible view is not a viable option we diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index 3ad3a5557053f..68983e2ff9b68 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -1343,12 +1343,6 @@ public class AccessibilityNodeInfo implements Parcelable { case View.FOCUS_RIGHT: case View.FOCUS_FORWARD: case View.FOCUS_BACKWARD: - case View.ACCESSIBILITY_FOCUS_DOWN: - case View.ACCESSIBILITY_FOCUS_UP: - case View.ACCESSIBILITY_FOCUS_LEFT: - case View.ACCESSIBILITY_FOCUS_RIGHT: - case View.ACCESSIBILITY_FOCUS_FORWARD: - case View.ACCESSIBILITY_FOCUS_BACKWARD: return; default: throw new IllegalArgumentException("Unknown direction: " + direction); diff --git a/core/java/android/view/accessibility/AccessibilityNodeProvider.java b/core/java/android/view/accessibility/AccessibilityNodeProvider.java index b3f3cee430a7d..688cbdf3c9f7a 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeProvider.java +++ b/core/java/android/view/accessibility/AccessibilityNodeProvider.java @@ -132,60 +132,4 @@ public abstract class AccessibilityNodeProvider { int virtualViewId) { return null; } - - /** - * Finds the accessibility focused {@link AccessibilityNodeInfo}. The search is - * relative to the virtual view, i.e. a descendant of the host View, with the - * given virtualViewId or the host View itself - * virtualViewId equals to {@link View#NO_ID}. - * - * Note: Normally the system is responsible to transparently find - * accessibility focused view starting from a given root but for virtual view - * hierarchies it is a responsibility of this provider's implementor to find - * the accessibility focused virtual view. - * - * @param virtualViewId A client defined virtual view id which defined - * the root of the tree in which to perform the search. - * @return A list of node info. - * - * @see #createAccessibilityNodeInfo(int) - * @see AccessibilityNodeInfo - * - * @hide - */ - public AccessibilityNodeInfo findAccessibilityFocus(int virtualViewId) { - return null; - } - - /** - * Finds {@link AccessibilityNodeInfo} to take accessibility focus in the given - * direction. The search is relative to the virtual view, i.e. a - * descendant of the host View, with the given virtualViewId or - * the host View itself virtualViewId equals to {@link View#NO_ID}. - * - * Note: Normally the system is responsible to transparently find - * the next view to take accessibility focus but for virtual view hierarchies - * it is a responsibility of this provider's implementor to compute the next - * focusable. - * - * @param direction The direction in which to search for a focus candidate. - * Values are - * {@link View#ACCESSIBILITY_FOCUS_FORWARD}, - * {@link View#ACCESSIBILITY_FOCUS_BACKWARD}, - * {@link View#ACCESSIBILITY_FOCUS_UP}, - * {@link View#ACCESSIBILITY_FOCUS_DOWN}, - * {@link View#ACCESSIBILITY_FOCUS_LEFT}, - * {@link View#ACCESSIBILITY_FOCUS_RIGHT}. - * @param virtualViewId A client defined virtual view id which defined - * the root of the tree in which to perform the search. - * @return A list of node info. - * - * @see #createAccessibilityNodeInfo(int) - * @see AccessibilityNodeInfo - * - * @hide - */ - public AccessibilityNodeInfo accessibilityFocusSearch(int direction, int virtualViewId) { - return null; - } } diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 19aef8eaf0546..130f0eeaac3f4 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -42,7 +42,6 @@ import android.util.SparseBooleanArray; import android.util.StateSet; import android.view.ActionMode; import android.view.ContextMenu.ContextMenuInfo; -import android.view.FocusFinder; import android.view.Gravity; import android.view.HapticFeedbackConstants; import android.view.InputDevice; @@ -1328,150 +1327,6 @@ public abstract class AbsListView extends AdapterView implements Te onScrollChanged(0, 0, 0, 0); // dummy values, View's implementation does not use these. } - @Override - public void addFocusables(ArrayList views, int direction, int focusableMode) { - if ((focusableMode & FOCUSABLES_ACCESSIBILITY) == FOCUSABLES_ACCESSIBILITY) { - switch(direction) { - case ACCESSIBILITY_FOCUS_BACKWARD: { - View focusable = (getChildCount() > 0) ? getChildAt(getChildCount() - 1) : this; - if (focusable.isAccessibilityFocusable()) { - views.add(focusable); - } - } return; - case ACCESSIBILITY_FOCUS_FORWARD: { - if (isAccessibilityFocusable()) { - views.add(this); - } - } return; - } - } - super.addFocusables(views, direction, focusableMode); - } - - @Override - public View focusSearch(int direction) { - return focusSearch(this, direction); - } - - @Override - public View focusSearch(View focused, int direction) { - switch (direction) { - case ACCESSIBILITY_FOCUS_FORWARD: { - // If we are the focused view try giving it to the first child. - if (focused == this) { - final int childCount = getChildCount(); - for (int i = 0; i < childCount; i++) { - View child = getChildAt(i); - if (child.getVisibility() == View.VISIBLE) { - return child; - } - } - return super.focusSearch(this, direction); - } - // Find the item that has the focused view. - final int currentPosition = getPositionForView(focused); - if (currentPosition < 0 || currentPosition >= getCount()) { - return super.focusSearch(this, direction); - } - // Try to advance focus in the current item. - View currentItem = getChildAt(currentPosition - getFirstVisiblePosition()); - if (currentItem.getVisibility() == View.VISIBLE) { - if (currentItem instanceof ViewGroup) { - ViewGroup currentItemGroup = (ViewGroup) currentItem; - View nextFocus = FocusFinder.getInstance().findNextFocus(currentItemGroup, - focused, direction); - if (nextFocus != null && nextFocus != currentItemGroup - && nextFocus != focused) { - return nextFocus; - } - } - } - // Try to move focus to the next item. - final int nextPosition = currentPosition - getFirstVisiblePosition() + 1; - for (int i = nextPosition; i < getChildCount(); i++) { - View child = getChildAt(i); - if (child.getVisibility() == View.VISIBLE) { - return child; - } - } - // No next item start searching from the list. - return super.focusSearch(this, direction); - } - case ACCESSIBILITY_FOCUS_BACKWARD: { - // If we are the focused search from the view that is - // as closer to the bottom as possible. - if (focused == this) { - final int childCount = getChildCount(); - for (int i = childCount - 1; i >= 0; i--) { - View child = getChildAt(i); - if (child.getVisibility() == View.VISIBLE) { - return super.focusSearch(child, direction); - } - } - return super.focusSearch(this, direction); - } - // Find the item that has the focused view. - final int currentPosition = getPositionForView(focused); - if (currentPosition < 0 || currentPosition >= getCount()) { - return super.focusSearch(this, direction); - } - - View currentItem = getChildAt(currentPosition - getFirstVisiblePosition()); - - // If a list item is the focused view we try to find a view - // in the previous item since in reverse the item contents - // get accessibility focus before the item itself. - if (currentItem == focused) { - currentItem = null; - focused = null; - // This list gets accessibility focus after the last item. - final int previousPosition = currentPosition - getFirstVisiblePosition() - 1; - for (int i = previousPosition; i >= 0; i--) { - View child = getChildAt(i); - if (child.getVisibility() == View.VISIBLE) { - currentItem = child; - break; - } - } - if (currentItem == null) { - return this; - } - } - - if (currentItem.getVisibility() == View.VISIBLE) { - // Search into the item. - if (currentItem instanceof ViewGroup) { - ViewGroup currentItemGroup = (ViewGroup) currentItem; - View nextFocus = FocusFinder.getInstance().findNextFocus(currentItemGroup, - focused, direction); - if (nextFocus != null && nextFocus != currentItemGroup - && nextFocus != focused) { - return nextFocus; - } - } - - // If not item content wants focus we give it to the item. - return currentItem; - } - - return super.focusSearch(this, direction); - } - } - return super.focusSearch(focused, direction); - } - - /** - * @hide - */ - @Override - public View findViewToTakeAccessibilityFocusFromHover(View child, View descendant) { - final int position = getPositionForView(child); - if (position != INVALID_POSITION) { - return getChildAt(position - mFirstPosition); - } - return super.findViewToTakeAccessibilityFocusFromHover(child, descendant); - } - @Override public void sendAccessibilityEvent(int eventType) { // Since this class calls onScrollChanged even if the mFirstPosition and the diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index a458f57d7de24..02bcf1e4c0697 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -1416,19 +1416,6 @@ public class NumberPicker extends LinearLayout { } } - @Override - public void addFocusables(ArrayList views, int direction, int focusableMode) { - // We do not want the real descendant to be considered focus search - // since it is managed by the accessibility node provider. - if ((focusableMode & FOCUSABLES_ACCESSIBILITY) == FOCUSABLES_ACCESSIBILITY) { - if (isAccessibilityFocusable()) { - views.add(this); - return; - } - } - super.addFocusables(views, direction, focusableMode); - } - @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); @@ -2297,78 +2284,6 @@ public class NumberPicker extends LinearLayout { return super.performAction(virtualViewId, action, arguments); } - @Override - public AccessibilityNodeInfo findAccessibilityFocus(int virtualViewId) { - return createAccessibilityNodeInfo(mAccessibilityFocusedView); - } - - @Override - public AccessibilityNodeInfo accessibilityFocusSearch(int direction, int virtualViewId) { - switch (direction) { - case View.ACCESSIBILITY_FOCUS_DOWN: - case View.ACCESSIBILITY_FOCUS_FORWARD: { - switch (mAccessibilityFocusedView) { - case UNDEFINED: { - return createAccessibilityNodeInfo(View.NO_ID); - } - case View.NO_ID: { - if (hasVirtualDecrementButton()) { - return createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_DECREMENT); - } - } - //$FALL-THROUGH$ - case VIRTUAL_VIEW_ID_DECREMENT: { - return createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_INPUT); - } - case VIRTUAL_VIEW_ID_INPUT: { - if (hasVirtualIncrementButton()) { - return createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_INCREMENT); - } - } - //$FALL-THROUGH$ - case VIRTUAL_VIEW_ID_INCREMENT: { - View nextFocus = NumberPicker.this.focusSearch(direction); - if (nextFocus != null) { - return nextFocus.createAccessibilityNodeInfo(); - } - return null; - } - } - } break; - case View.ACCESSIBILITY_FOCUS_UP: - case View.ACCESSIBILITY_FOCUS_BACKWARD: { - switch (mAccessibilityFocusedView) { - case UNDEFINED: { - return createAccessibilityNodeInfo(View.NO_ID); - } - case View.NO_ID: { - if (hasVirtualIncrementButton()) { - return createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_INCREMENT); - } - } - //$FALL-THROUGH$ - case VIRTUAL_VIEW_ID_INCREMENT: { - return createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_INPUT); - } - case VIRTUAL_VIEW_ID_INPUT: { - if (hasVirtualDecrementButton()) { - return createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_DECREMENT); - } - } - //$FALL-THROUGH$ - case VIRTUAL_VIEW_ID_DECREMENT: { - View nextFocus = NumberPicker.this.focusSearch(direction); - if (nextFocus != null) { - return nextFocus.createAccessibilityNodeInfo(); - } - return null; - } - } - } break; - } - return null; - } - public void sendAccessibilityEventForVirtualView(int virtualViewId, int eventType) { switch (virtualViewId) { case VIRTUAL_VIEW_ID_DECREMENT: { diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index aa8b643960566..0477ecaedfd37 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2154,40 +2154,6 @@ - - - - - - - - - -