/** * Try to speak the specified text, for accessibility. Only available on JB or later. * @param text Text to announce. */ public static void tryAccessibilityAnnounce(View view, CharSequence text) { if (view != null && text != null) { view.announceForAccessibility(text); } }
/** * Try to speak the specified text, for accessibility. Only available on JB or later. * @param text Text to announce. */ @SuppressLint("NewApi") public static void tryAccessibilityAnnounce(View view, CharSequence text) { if (isJellybeanOrLater() && view != null && text != null) { view.announceForAccessibility(text); } }
/** * Try to speak the specified text, for accessibility. Only available on JB or later. * @param text Text to announce. */ @SuppressLint("NewApi") public static void tryAccessibilityAnnounce(View view, CharSequence text) { if (isJellybeanOrLater() && view != null && text != null) { view.announceForAccessibility(text); } }
@Override public void onClick(View v) { if (extra.getVisibility() == View.GONE) { if (preferences.getBoolean("extraBarClosed:" + name, false)) { SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("extraBarClosed:" + name, false); editor.apply(); } view.announceForAccessibility(view.getContext().getString(R.string.expand_bar_expanded)); expand.setImageDrawable(view.getContext().getDrawable(R.drawable.ic_expand_less_black_24dp)); expand.setContentDescription(view.getContext().getString(R.string.expand_bar_toggle_close)); extra.setVisibility(View.VISIBLE); } else { if (!preferences.getBoolean("extraBarClosed:" + name, false)) { SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("extraBarClosed:" + name, true); editor.apply(); } view.announceForAccessibility(view.getContext().getString(R.string.expand_bar_closed)); expand.setImageDrawable(view.getContext().getDrawable(R.drawable.ic_expand_more_black_24dp)); expand.setContentDescription(view.getContext().getString(R.string.expand_bar_toggle_expand)); extra.setVisibility(View.GONE); } } };
/** * Try to speak the specified text, for accessibility. Only available on JB or later. * @param text Text to announce. */ @SuppressLint("NewApi") public static void tryAccessibilityAnnounce(View view, CharSequence text) { if (Build.VERSION.SDK_INT >= 16 && view != null && text != null) { view.announceForAccessibility(text); } } }
/** * Try to speak the specified text, for accessibility. Only available on JB or later. * * @param text Text to announce. */ @SuppressLint("NewApi") public static void tryAccessibilityAnnounce(View view, CharSequence text) { if (view != null && text != null) { view.announceForAccessibility(text); } }
/** * Try to speak the specified text, for accessibility. Only available on JB or later. * @param text Text to announce. */ @SuppressLint("NewApi") public static void tryAccessibilityAnnounce(View view, CharSequence text) { if (isJellybeanOrLater() && view != null && text != null) { view.announceForAccessibility(text); } }
/** * Try to speak the specified text, for accessibility. Only available on JB or later. * @param text Text to announce. */ @SuppressLint("NewApi") public static void tryAccessibilityAnnounce(View view, CharSequence text) { if (isJellybeanOrLater() && view != null && text != null) { view.announceForAccessibility(text); } }
/** * Try to speak the specified text, for accessibility. Only available on JB or later. * @param text Text to announce. */ @SuppressLint("NewApi") public static void tryAccessibilityAnnounce(View view, CharSequence text) { if (isJellybeanOrLater() && view != null && text != null) { view.announceForAccessibility(text); } }
/** * Try to speak the specified text, for accessibility. Only available on JB or later. * @param text Text to announce. */ @SuppressLint("NewApi") public static void tryAccessibilityAnnounce(View view, CharSequence text) { if (isJellybeanOrLater() && view != null && text != null) { view.announceForAccessibility(text); } }
/** * Try to speak the specified text, for accessibility. Only available on JB or later. * @param text Text to announce. */ @SuppressLint("NewApi") public static void tryAccessibilityAnnounce(View view, CharSequence text) { if (isJellybeanOrLater() && view != null && text != null) { view.announceForAccessibility(text); } }
private void selectTile(View v) { if (mSelectedTile != null) { mSelectedTile.setSelected(false); mSelectedTile = null; } mSelectedTile = v; v.setSelected(true); mSelectedIndex = mWallpapersView.indexOfChild(v); // TODO: Remove this once the accessibility framework and // services have better support for selection state. v.announceForAccessibility( getString(R.string.announce_selection, v.getContentDescription())); }
@Thunk void selectTile(View v) { if (mSelectedTile != null) { mSelectedTile.setSelected(false); mSelectedTile = null; } mSelectedTile = v; v.setSelected(true); mSelectedIndex = mWallpapersView.indexOfChild(v); // TODO: Remove this once the accessibility framework and // services have better support for selection state. v.announceForAccessibility( getContext().getString(R.string.announce_selection, v.getContentDescription())); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void announceForAccessibility(View view, CharSequence announcement) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.announceForAccessibility(announcement); } else { Context context = view.getContext(); AccessibilityManager manager = (AccessibilityManager)context.getSystemService( Context.ACCESSIBILITY_SERVICE); if (!manager.isEnabled()) { return; } // According to platform_packages_apps/Camera2 // com.android.camera.util.AccessibilityUtils.java AccessibilityEvent event = AccessibilityEvent.obtain( AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED); event.setSource(view); event.setClassName(view.getClass().getName()); event.setPackageName(context.getPackageName()); event.setEnabled(view.isEnabled()); event.getText().add(announcement); manager.sendAccessibilityEvent(event); } } }