Java Code Examples for android.view.View#announceForAccessibility()

The following examples show how to use android.view.View#announceForAccessibility() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: PersianDateRangePicker   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 2
Source Project: Camera2   File: PreviewOverlay.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * uZooms camera in when in accessibility mode.
 *
 * @param view    is the current view
 * @param maxZoom is the maximum zoom value on the given device
 * @return float representing the current zoom value
 */
public float zoomIn(View view, float maxZoom)
{
    mCurrA11yZoomLevel++;
    mMaxZoom = maxZoom;
    mCurrA11yZoom = getZoomAtLevel(mCurrA11yZoomLevel);
    mZoomListener.onZoomValueChanged(mCurrA11yZoom);
    view.announceForAccessibility(String.format(
            view.getResources().
                    getString(R.string.accessibility_zoom_announcement), mCurrA11yZoom));
    return mCurrA11yZoom;
}
 
Example 3
Source Project: Camera2   File: PreviewOverlay.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Zooms camera out when in accessibility mode.
 *
 * @param view    is the current view
 * @param maxZoom is the maximum zoom value on the given device
 * @return float representing the current zoom value
 */
public float zoomOut(View view, float maxZoom)
{
    mCurrA11yZoomLevel--;
    mMaxZoom = maxZoom;
    mCurrA11yZoom = getZoomAtLevel(mCurrA11yZoomLevel);
    mZoomListener.onZoomValueChanged(mCurrA11yZoom);
    view.announceForAccessibility(String.format(
            view.getResources().
                    getString(R.string.accessibility_zoom_announcement), mCurrA11yZoom));
    return mCurrA11yZoom;
}
 
Example 4
Source Project: AssistantBySDK   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 5
Source Project: narrate-android   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 6
Source Project: ClockPlus   File: Utils.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 7
Source Project: cathode   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 8
/**
 * 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);
    }
}
 
Example 9
Source Project: date_picker_converter   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 10
@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()));
}
 
Example 11
Source Project: DateTimepicker   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 12
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()));
}
 
Example 13
Source Project: Conquer   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 14
/**
 * @param view the View to trigger the accessibility event
 * @param msg text that will be read aloud (if accessibility enabled)
 */
public static void announceForAccessibility(View view, String msg)
{
    if (view != null && msg != null)
    {
        if (Build.VERSION.SDK_INT >= 16)
        {
            view.announceForAccessibility(msg);

        } else {
            Context context = view.getContext();
            if (context != null)
            {
                AccessibilityManager accesibility = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
                if (accesibility != null && accesibility.isEnabled())
                {
                    AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_FOCUSED);
                    event.getText().add(msg);
                    event.setEnabled(view.isEnabled());
                    event.setClassName(view.getClass().getName());
                    event.setPackageName(context.getPackageName());

                    ViewParent parent = view.getParent();
                    if (Build.VERSION.SDK_INT >= 14 && parent != null)
                    {
                        parent.requestSendAccessibilityEvent(view, event);

                    } else {
                        accesibility.sendAccessibilityEvent(event);
                    }
                }
            }
        }
    }
}
 
Example 15
Source Project: StyleableDateTimePicker   File: Utils.java    License: MIT License 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 16
Source Project: AlarmOn   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 17
Source Project: MaterialDateRangePicker   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 18
public static void announceForAccessibility(View view, CharSequence text) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.announceForAccessibility(text);
    } // No-op on versions prior to Jellybean
}
 
Example 19
Source Project: MaterialDateTimePicker   File: Utils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 20
/**
 * Wrapper for {@link View#announceForAccessibility(CharSequence)}.
 * 
 * @param view
 *            a view.
 * @param text
 *            The announcement text.
 * @see View#announceForAccessibility(CharSequence)
 */
public static void announceForAccessibility(View view, CharSequence text) {
    view.announceForAccessibility(text);
}