FileDocCategorySizeDatePackage
Util.javaAPI DocAndroid 5.1 API2832Thu Mar 12 22:22:52 GMT 2015com.android.ex.photo.util

Util

public class Util extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidannounceForAccessibility(android.view.View view, android.view.accessibility.AccessibilityManager accessibilityManager, java.lang.CharSequence text)
Make an announcement which is related to some sort of a context change. Also see {@link android.view.View#announceForAccessibility}

param
view The view that triggered the announcement
param
accessibilityManager AccessibilityManager instance. If it is null, the method can obtain an instance itself.
param
text The announcement text

        // Jelly Bean added support for speaking text verbatim
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            view.announceForAccessibility(text);
            return;
        }

        final Context context = view.getContext().getApplicationContext();
        if (accessibilityManager == null) {
            accessibilityManager = (AccessibilityManager) context.getSystemService(
                    Context.ACCESSIBILITY_SERVICE);
        }

        if (!accessibilityManager.isEnabled()) {
            return;
        }

        final int eventType = AccessibilityEvent.TYPE_VIEW_FOCUSED;

        // Construct an accessibility event with the minimum recommended
        // attributes. An event without a class name or package may be dropped.
        final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        event.getText().add(text);
        event.setEnabled(view.isEnabled());
        event.setClassName(view.getClass().getName());
        event.setPackageName(context.getPackageName());

        // JellyBean MR1 requires a source view to set the window ID.
        final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        record.setSource(view);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            view.getParent().requestSendAccessibilityEvent(view, event);
        } else {
            // Sends the event directly through the accessibility manager.
            accessibilityManager.sendAccessibilityEvent(event);
        }
    
public static booleanisTouchExplorationEnabled(android.view.accessibility.AccessibilityManager accessibilityManager)

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            return accessibilityManager.isTouchExplorationEnabled();
        } else {
            return false;
        }