summaryrefslogtreecommitdiff
path: root/core/java/android/view/View.java
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2012-06-15 10:31:31 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2012-06-15 10:50:23 -0700
commit8ffe8b304e4778b3c95e57ad5a77cd41c9cf9f7b (patch)
tree273c3b35797aa6502d816bcba01eeadf8f13c3b3 /core/java/android/view/View.java
parent68a808bc702f03536bd0cf3e2556127e364119d6 (diff)
Accessibility focus search and setting it from hover are performed by the client.
1. Currently we are providing accessibility focus search algorithm in the framework and we are also setting accessibility focus from hover. It appears that implementing a focus search strategy that works for all accessibility services is non trivial task if feasible. Based on feedback from the developers of two such services at Google - TalkBack and BarilleBack - the built in focus search does not quite match what they need and they would like to implement a custom strategy. Hence, having APIs for accessibility focus search in the framework does not make. Therefore, we are hiding this APIs and later will take out the focus search logic and allow the accessibility service to implement search. Also putting accessibility focus from hover is tightly integrated with the focus search since the set of views that get accessibility focus from hover should be the same as the set of views returned by the focus search routine. Therefore, we are letting the accessibility service decide where to put accessibility focus when it gets an accessibility hover event. bug:6675330 Change-Id: Ie152230990a6602f3fd1d82de2177d0b1444d654
Diffstat (limited to 'core/java/android/view/View.java')
-rw-r--r--core/java/android/view/View.java44
1 files changed, 41 insertions, 3 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 816b631bf987..db3ba405c271 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1047,36 +1047,50 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
/**
* 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;
@@ -6333,6 +6347,31 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
}
}
+ private void sendAccessibilityHoverEvent(int eventType) {
+ // Since we are not delivering to a client accessibility events from not
+ // important views (unless the clinet request that) we need to fire the
+ // event from the deepest view exposed to the client. As a consequence if
+ // the user crosses a not exposed view the client will see enter and exit
+ // of the exposed predecessor followed by and enter and exit of that same
+ // predecessor when entering and exiting the not exposed descendant. This
+ // is fine since the client has a clear idea which view is hovered at the
+ // price of a couple more events being sent. This is a simple and
+ // working solution.
+ View source = this;
+ while (true) {
+ if (source.includeForAccessibility()) {
+ source.sendAccessibilityEvent(eventType);
+ return;
+ }
+ ViewParent parent = source.getParent();
+ if (parent instanceof View) {
+ source = (View) parent;
+ } else {
+ return;
+ }
+ }
+ }
+
private void requestAccessibilityFocusFromHover() {
if (includeForAccessibility() && isActionableForAccessibility()) {
requestAccessibilityFocus();
@@ -7902,16 +7941,15 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
|| action == MotionEvent.ACTION_HOVER_MOVE)
&& !hasHoveredChild()
&& pointInView(event.getX(), event.getY())) {
- sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
+ sendAccessibilityHoverEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
mSendingHoverAccessibilityEvents = true;
- requestAccessibilityFocusFromHover();
}
} else {
if (action == MotionEvent.ACTION_HOVER_EXIT
|| (action == MotionEvent.ACTION_MOVE
&& !pointInView(event.getX(), event.getY()))) {
mSendingHoverAccessibilityEvents = false;
- sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
+ sendAccessibilityHoverEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
// If the window does not have input focus we take away accessibility
// focus as soon as the user stop hovering over the view.
if (mAttachInfo != null && !mAttachInfo.mHasWindowFocus) {