diff options
| author | Jin Cao <jinyan@google.com> | 2014-09-23 00:10:53 +0000 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2014-09-23 00:10:53 +0000 |
| commit | ce2449a76afa3396248fd844044f503faf66b134 (patch) | |
| tree | 617593c68d3f004514b09c9b3492614ba01b5fd7 | |
| parent | 606824489f1698ff157864bb964c9ddbe14dacce (diff) | |
| parent | 04f06ea723b0445428d3f563334d653299a73a74 (diff) | |
| download | android_frameworks_opt_chips-ce2449a76afa3396248fd844044f503faf66b134.tar.gz android_frameworks_opt_chips-ce2449a76afa3396248fd844044f503faf66b134.tar.bz2 android_frameworks_opt_chips-ce2449a76afa3396248fd844044f503faf66b134.zip | |
am 04f06ea7: Don\'t use announceForAccessibility
* commit '04f06ea723b0445428d3f563334d653299a73a74':
Don't use announceForAccessibility
| -rw-r--r-- | src/com/android/ex/chips/RecipientEditTextView.java | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java index f13b0d0..3bf9461 100644 --- a/src/com/android/ex/chips/RecipientEditTextView.java +++ b/src/com/android/ex/chips/RecipientEditTextView.java @@ -76,6 +76,8 @@ import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewParent; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; import android.widget.AdapterView; @@ -183,6 +185,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements private ReplacementDrawableSpan mMoreChip; private TextView mMoreItem; + private boolean mIsAccessibilityOn; private int mCurrentSuggestionCount; // VisibleForTesting @@ -299,6 +302,15 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements setDropdownChipLayouter(new DropdownChipLayouter(LayoutInflater.from(context), context)); } + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + + final AccessibilityManager accessibilityManager = + (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); + mIsAccessibilityOn = accessibilityManager.isEnabled(); + } + private int calculateTextHeight() { final Rect textBounds = new Rect(); final TextPaint paint = getPaint(); @@ -512,7 +524,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements // the count at the bottom of this function. if (mCurrentSuggestionCount == 0) { // Announce the new number of possible choices for accessibility. - announceForAccessibility(getContext().getString( + announceForAccessibilityCompat(getContext().getString( R.string.accessbility_suggestion_dropdown_opened)); } } @@ -529,6 +541,20 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements baseAdapter.setDropdownChipLayouter(mDropdownChipLayouter); } + private void announceForAccessibilityCompat(String text) { + if (mIsAccessibilityOn && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + final ViewParent parent = getParent(); + if (parent != null) { + AccessibilityEvent event = AccessibilityEvent.obtain( + AccessibilityEvent.TYPE_ANNOUNCEMENT); + onInitializeAccessibilityEvent(event); + event.getText().add(text); + event.setContentDescription(null); + parent.requestSendAccessibilityEvent(this, event); + } + } + } + protected void scrollBottomIntoView() { if (mScrollView != null && mShouldShrink) { final int[] location = new int[2]; |
