Skip to content

Commit cab5b8a

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Nodes with contentDescription should always be important for accessibility." into jb-dev
2 parents 35b691f + e47957a commit cab5b8a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

core/java/android/view/View.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3457,7 +3457,7 @@ public View(Context context, AttributeSet attrs, int defStyle) {
34573457
}
34583458
break;
34593459
case com.android.internal.R.styleable.View_contentDescription:
3460-
mContentDescription = a.getString(attr);
3460+
setContentDescription(a.getString(attr));
34613461
break;
34623462
case com.android.internal.R.styleable.View_soundEffectsEnabled:
34633463
if (!a.getBoolean(attr, true)) {
@@ -5048,6 +5048,10 @@ public CharSequence getContentDescription() {
50485048
@RemotableViewMethod
50495049
public void setContentDescription(CharSequence contentDescription) {
50505050
mContentDescription = contentDescription;
5051+
final boolean nonEmptyDesc = contentDescription != null && contentDescription.length() > 0;
5052+
if (nonEmptyDesc && getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
5053+
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
5054+
}
50515055
}
50525056

50535057
/**

services/java/com/android/server/accessibility/TouchExplorer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public class TouchExplorer {
100100
// Temporary array for storing pointer IDs.
101101
private final int[] mTempPointerIds = new int[MAX_POINTER_COUNT];
102102

103+
// Timeout before trying to decide what the user is trying to do.
104+
private final int mDetermineUserIntentTimeout;
105+
103106
// Timeout within which we try to detect a tap.
104107
private final int mTapTimeout;
105108

@@ -199,6 +202,7 @@ public TouchExplorer(InputFilter inputFilter, Context context,
199202
mInjectedPointerTracker = new InjectedPointerTracker();
200203
mInputFilter = inputFilter;
201204
mTapTimeout = ViewConfiguration.getTapTimeout();
205+
mDetermineUserIntentTimeout = (int) (mTapTimeout * 1.5f);
202206
mDoubleTapTimeout = ViewConfiguration.getDoubleTapTimeout();
203207
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
204208
mDoubleTapSlop = ViewConfiguration.get(context).getScaledDoubleTapSlop();
@@ -1332,7 +1336,7 @@ public void post(MotionEvent prototype, int pointerIdBits, int policyFlags) {
13321336
mPrototype = MotionEvent.obtain(prototype);
13331337
mPointerIdBits = pointerIdBits;
13341338
mPolicyFlags = policyFlags;
1335-
mHandler.postDelayed(this, mTapTimeout);
1339+
mHandler.postDelayed(this, mDetermineUserIntentTimeout);
13361340
}
13371341

13381342
public float getX() {

0 commit comments

Comments
 (0)