private static void unsetContentDescription(View view) { view.setContentDescription(null); }
private static void setContentDescription(View view, CharSequence contentDescription) { if (TextUtils.isEmpty(contentDescription)) { return; } view.setContentDescription(contentDescription); }
/** * Add a content description to the specified swatch view. Because the palette get added in a * snaking form, every other row will need to compensate for the fact that the palette are added * in an opposite direction from their left->right/top->bottom order, which is how the system * will arrange them for accessibility purposes. */ private void setSwatchDescription(int rowNumber, int index, int rowElements, boolean selected, View swatch) { int accessibilityIndex; if (rowNumber % 2 == 0) { // We're in a regular-ordered row accessibilityIndex = index; } else { // We're in a backwards-ordered row. int rowMax = ((rowNumber + 1) * mNumColumns); accessibilityIndex = rowMax - rowElements; } String description; if (selected) { description = String.format(mDescriptionSelected, accessibilityIndex); } else { description = String.format(mDescription, accessibilityIndex); } swatch.setContentDescription(description); }
private void updateAmPmDisplay(int amOrPm) { if (amOrPm == AM) { mAmPmTextView.setText(mAmText); Utils.tryAccessibilityAnnounce(mTimePicker, mAmText); mAmPmHitspace.setContentDescription(mAmText); } else if (amOrPm == PM){ mAmPmTextView.setText(mPmText); Utils.tryAccessibilityAnnounce(mTimePicker, mPmText); mAmPmHitspace.setContentDescription(mPmText); } else { mAmPmTextView.setText(mDoublePlaceholderText); } }
private void updateAmPmDisplay(int amOrPm) { if (amOrPm == AM) { mAmPmTextView.setText(mAmText); Utils.tryAccessibilityAnnounce(mTimePicker, mAmText); mAmPmHitspace.setContentDescription(mAmText); } else if (amOrPm == PM) { mAmPmTextView.setText(mPmText); Utils.tryAccessibilityAnnounce(mTimePicker, mPmText); mAmPmHitspace.setContentDescription(mPmText); } else { mAmPmTextView.setText(mDoublePlaceholderText); } }
String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc);
String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc);
@Test public void warningIssue_shouldNotThrow() throws Exception { labeledView.setContentDescription(DUPLICATE_STRING); parentLayout.setContentDescription(DUPLICATE_STRING); parentLayout.setClickable(true); AccessibilityUtil.checkView(parentLayout); }
labeledView.setContentDescription("Something"); labeledView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); labeledView.setClickable(true); unlabeledView.setContentDescription(null); unlabeledView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); unlabeledView.setClickable(true);
/** * Add a content description to the specified swatch view. Because the colors get added in a * snaking form, every other row will need to compensate for the fact that the colors are added * in an opposite direction from their left->right/top->bottom order, which is how the system * will arrange them for accessibility purposes. */ private void setSwatchDescription(int rowNumber, int index, int rowElements, boolean selected, View swatch, String[] contentDescriptions) { String description; if (contentDescriptions != null && contentDescriptions.length > index) { description = contentDescriptions[index]; } else { int accessibilityIndex; if (rowNumber % 2 == 0) { // We're in a regular-ordered row accessibilityIndex = index + 1; } else { // We're in a backwards-ordered row. int rowMax = ((rowNumber + 1) * mNumColumns); accessibilityIndex = rowMax - rowElements; } if (selected) { description = String.format(mDescriptionSelected, accessibilityIndex); } else { description = String.format(mDescription, accessibilityIndex); } } swatch.setContentDescription(description); }
mActionsMenu.findViewById(R.id.fab_expand_menu_button).setContentDescription(getString(R.string.menu_add)); configureFloatingActionsMenu();
String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc);
String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc);
@Override public void setString(V view, String value) { view.setContentDescription(value); } });
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRoot = inflater.inflate(R.layout.tdl_fragment_container, container, false); if (mContentDescription != null) { mRoot.setContentDescription(mContentDescription); } return mRoot; }
public void run(RapidParserObject object, Object view, Var value) { ((View)view).setContentDescription(value.getString()); } }
private void setupButton(int buttonId, String description) { final View button = myWindow.findViewById(buttonId); button.setOnClickListener(this); button.setContentDescription(description); }
private void trySetContentDescription(View root, int viewId, int contDescResId) { View target = root.findViewById(viewId); if (target != null) { target.setContentDescription(getContext().getString(contDescResId)); } }
public void onIndexUpdated(CharSequence label) { if (isNamelessWallpaper()) { mView.setContentDescription(label); } } }
public void announce(CharSequence msg) { mTargetView.setContentDescription(msg); mTargetView.removeCallbacks(this); mTargetView.postDelayed(this, TIMEOUT_SEND_ACCESSIBILITY_EVENT); }