From e47957a0bbe2164467ff6e7a566b0c9e4689cdc9 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Tue, 5 Jun 2012 14:46:50 -0700 Subject: [PATCH] Nodes with contentDescription should always be important for accessibility. 1. Now after setting the content description on a view we mark is as important for accessibility of the current important for accessibility mode of that view is auto. 2. Minor tweak to a touch explorer coefficient to make performing double tapping easier. bug:6615353 Change-Id: I3b477f533a3ebde85d425caf32ace5e851240f88 --- core/java/android/view/View.java | 6 +++++- .../com/android/server/accessibility/TouchExplorer.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 48819a115c03c..7c6a7c520b52d 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -3457,7 +3457,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal } break; case com.android.internal.R.styleable.View_contentDescription: - mContentDescription = a.getString(attr); + setContentDescription(a.getString(attr)); break; case com.android.internal.R.styleable.View_soundEffectsEnabled: if (!a.getBoolean(attr, true)) { @@ -5048,6 +5048,10 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal @RemotableViewMethod public void setContentDescription(CharSequence contentDescription) { mContentDescription = contentDescription; + final boolean nonEmptyDesc = contentDescription != null && contentDescription.length() > 0; + if (nonEmptyDesc && getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) { + setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); + } } /** diff --git a/services/java/com/android/server/accessibility/TouchExplorer.java b/services/java/com/android/server/accessibility/TouchExplorer.java index d97b022381efc..7e8837383a7c5 100644 --- a/services/java/com/android/server/accessibility/TouchExplorer.java +++ b/services/java/com/android/server/accessibility/TouchExplorer.java @@ -100,6 +100,9 @@ public class TouchExplorer { // Temporary array for storing pointer IDs. private final int[] mTempPointerIds = new int[MAX_POINTER_COUNT]; + // Timeout before trying to decide what the user is trying to do. + private final int mDetermineUserIntentTimeout; + // Timeout within which we try to detect a tap. private final int mTapTimeout; @@ -199,6 +202,7 @@ public class TouchExplorer { mInjectedPointerTracker = new InjectedPointerTracker(); mInputFilter = inputFilter; mTapTimeout = ViewConfiguration.getTapTimeout(); + mDetermineUserIntentTimeout = (int) (mTapTimeout * 1.5f); mDoubleTapTimeout = ViewConfiguration.getDoubleTapTimeout(); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mDoubleTapSlop = ViewConfiguration.get(context).getScaledDoubleTapSlop(); @@ -1332,7 +1336,7 @@ public class TouchExplorer { mPrototype = MotionEvent.obtain(prototype); mPointerIdBits = pointerIdBits; mPolicyFlags = policyFlags; - mHandler.postDelayed(this, mTapTimeout); + mHandler.postDelayed(this, mDetermineUserIntentTimeout); } public float getX() {