Example usage for android.content Context ACCESSIBILITY_SERVICE

List of usage examples for android.content Context ACCESSIBILITY_SERVICE

Introduction

In this page you can find the example usage for android.content Context ACCESSIBILITY_SERVICE.

Prototype

String ACCESSIBILITY_SERVICE

To view the source code for android.content Context ACCESSIBILITY_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.accessibility.AccessibilityManager for giving the user feedback for UI events through the registered event listeners.

Usage

From source file:com.android.nobug.view.pattern.PatternView.java

public PatternView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PatternView, defStyleAttr, 0);

    mRowCount = a.getInteger(R.styleable.PatternView_rowCount, PATTERN_SIZE_DEFAULT);
    mColumnCount = a.getInteger(R.styleable.PatternView_columnCount, PATTERN_SIZE_DEFAULT);

    final String aspect = a.getString(R.styleable.PatternView_aspect);

    if ("square".equals(aspect)) {
        mAspect = ASPECT_SQUARE;//from   w  w  w.  ja va 2 s.c  o  m
    } else if ("lock_width".equals(aspect)) {
        mAspect = ASPECT_LOCK_WIDTH;
    } else if ("lock_height".equals(aspect)) {
        mAspect = ASPECT_LOCK_HEIGHT;
    } else {
        mAspect = ASPECT_SQUARE;
    }

    setClickable(true);

    mPathPaint.setAntiAlias(true);
    mPathPaint.setDither(true);

    mRegularColor = a.getColor(R.styleable.PatternView_regularColor, mRegularColor);
    mErrorColor = a.getColor(R.styleable.PatternView_errorColor, mErrorColor);
    mSuccessColor = a.getColor(R.styleable.PatternView_successColor, mSuccessColor);

    a.recycle();

    mPathPaint.setStyle(Paint.Style.STROKE);
    mPathPaint.setStrokeJoin(Paint.Join.ROUND);
    mPathPaint.setStrokeCap(Paint.Cap.ROUND);

    mPathWidth = getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_line_width);
    mPathPaint.setStrokeWidth(mPathWidth);

    mDotSize = getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_size);
    mDotSizeActivated = getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_size_activated);

    mPaint.setAntiAlias(true);
    mPaint.setDither(true);

    updatePatternSize();

    mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
    mLinearOutSlowInInterpolator = new LinearOutSlowInInterpolator();
    mExploreByTouchHelper = new PatternExploreByTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, mExploreByTouchHelper);
    mAccessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
}

From source file:me.zhanghai.android.patternlock.PatternView.java

public PatternView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PatternView, defStyleAttr, 0);

    mRowCount = a.getInteger(R.styleable.PatternView_pl_rowCount, PATTERN_SIZE_DEFAULT);
    mColumnCount = a.getInteger(R.styleable.PatternView_pl_columnCount, PATTERN_SIZE_DEFAULT);

    final String aspect = a.getString(R.styleable.PatternView_pl_aspect);

    if ("square".equals(aspect)) {
        mAspect = ASPECT_SQUARE;//from   ww  w .j av  a 2s .  c om
    } else if ("lock_width".equals(aspect)) {
        mAspect = ASPECT_LOCK_WIDTH;
    } else if ("lock_height".equals(aspect)) {
        mAspect = ASPECT_LOCK_HEIGHT;
    } else {
        mAspect = ASPECT_SQUARE;
    }

    setClickable(true);

    mPathPaint.setAntiAlias(true);
    mPathPaint.setDither(true);

    // Removed since every developer should set their own patternViewStyle.
    //mRegularColor = context.getColor(R.color.lock_pattern_view_regular_color);
    //mErrorColor = context.getColor(R.color.lock_pattern_view_error_color);
    //mSuccessColor = context.getColor(R.color.lock_pattern_view_success_color);
    mRegularColor = a.getColor(R.styleable.PatternView_pl_regularColor, mRegularColor);
    mErrorColor = a.getColor(R.styleable.PatternView_pl_errorColor, mErrorColor);
    mSuccessColor = a.getColor(R.styleable.PatternView_pl_successColor, mSuccessColor);

    a.recycle();

    mPathPaint.setStyle(Paint.Style.STROKE);
    mPathPaint.setStrokeJoin(Paint.Join.ROUND);
    mPathPaint.setStrokeCap(Paint.Cap.ROUND);

    mPathWidth = getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_line_width);
    mPathPaint.setStrokeWidth(mPathWidth);

    mDotSize = getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_size);
    mDotSizeActivated = getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_size_activated);

    mPaint.setAntiAlias(true);
    mPaint.setDither(true);

    updatePatternSize();

    mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
    mLinearOutSlowInInterpolator = new LinearOutSlowInInterpolator();
    mExploreByTouchHelper = new PatternExploreByTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, mExploreByTouchHelper);
    mAccessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
}

From source file:android.support.wear.widget.drawer.WearableDrawerLayout.java

public WearableDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    mFlingWatcher = new FlingWatcherFactory(this);
    mTopDrawerDraggerCallback = new TopDrawerDraggerCallback();
    mTopDrawerDragger = ViewDragHelper.create(this, 1f /* sensitivity */, mTopDrawerDraggerCallback);
    mTopDrawerDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP);

    mBottomDrawerDraggerCallback = new BottomDrawerDraggerCallback();
    mBottomDrawerDragger = ViewDragHelper.create(this, 1f /* sensitivity */, mBottomDrawerDraggerCallback);
    mBottomDrawerDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM);

    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics metrics = new DisplayMetrics();
    windowManager.getDefaultDisplay().getMetrics(metrics);
    mNestedScrollSlopPx = Math.round(metrics.density * NESTED_SCROLL_SLOP_DP);

    AccessibilityManager accessibilityManager = (AccessibilityManager) context
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    mIsAccessibilityEnabled = accessibilityManager.isEnabled();
}

From source file:com.aboveware.common.crouton.Manager.java

/**
 * Generates and dispatches an SDK-specific spoken announcement.
 * <p>/*from   w  w w.j av a 2 s. c  o m*/
 * For backwards compatibility, we're constructing an event from scratch
 * using the appropriate event type. If your application only targets SDK
 * 16+, you can just call View.announceForAccessibility(CharSequence).
 * </p>
 *
 * note: AccessibilityManager is only available from API lvl 4.
 *
 * Adapted from https://http://eyes-free.googlecode.com/files/accessibility_codelab_demos_v2_src.zip
 * via https://github.com/coreform/android-formidable-validation
 *
 * @param context Used to get {@link AccessibilityManager}
 * @param text The text to announce.
 */
public static void announceForAccessibilityCompat(Context context, CharSequence text) {
    if (Build.VERSION.SDK_INT >= 4) {
        AccessibilityManager accessibilityManager = (AccessibilityManager) context
                .getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (!accessibilityManager.isEnabled()) {
            return;
        }

        // Prior to SDK 16, announcements could only be made through FOCUSED
        // events. Jelly Bean (SDK 16) added support for speaking text verbatim
        // using the ANNOUNCEMENT event type.
        final int eventType;
        if (Build.VERSION.SDK_INT < 16) {
            eventType = AccessibilityEvent.TYPE_VIEW_FOCUSED;
        } else {
            eventType = AccessibilityEventCompat.TYPE_ANNOUNCEMENT;
        }

        // 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.setClassName(Manager.class.getName());
        event.setPackageName(context.getPackageName());

        // Sends the event directly through the accessibility manager. If your
        // application only targets SDK 14+, you should just call
        // getParent().requestSendAccessibilityEvent(this, event);
        accessibilityManager.sendAccessibilityEvent(event);
    }
}

From source file:com.bliex.android.lockpatternlib.PatternView.java

public PatternView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PatternView, defStyleAttr, 0);

    final String aspect = a.getString(R.styleable.PatternView_pl_aspect);

    if ("square".equals(aspect)) {
        mAspect = ASPECT_SQUARE;//from   w  ww .j a va2 s .co m
    } else if ("lock_width".equals(aspect)) {
        mAspect = ASPECT_LOCK_WIDTH;
    } else if ("lock_height".equals(aspect)) {
        mAspect = ASPECT_LOCK_HEIGHT;
    } else {
        mAspect = ASPECT_SQUARE;
    }

    setClickable(true);

    mPathPaint.setAntiAlias(true);
    mPathPaint.setDither(true);

    // Removed since every developer should set their own patternViewStyle.
    //mRegularColor = context.getColor(R.color.lock_pattern_view_regular_color);
    //mErrorColor = context.getColor(R.color.lock_pattern_view_error_color);
    //mSuccessColor = context.getColor(R.color.lock_pattern_view_success_color);
    mRegularColor = a.getColor(R.styleable.PatternView_pl_regularColor, mRegularColor);
    mErrorColor = a.getColor(R.styleable.PatternView_pl_errorColor, mErrorColor);
    mSuccessColor = a.getColor(R.styleable.PatternView_pl_successColor, mSuccessColor);

    a.recycle();

    mPathPaint.setStyle(Paint.Style.STROKE);
    mPathPaint.setStrokeJoin(Paint.Join.ROUND);
    mPathPaint.setStrokeCap(Paint.Cap.ROUND);

    mPathWidth = getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_line_width);
    mPathPaint.setStrokeWidth(mPathWidth);

    mDotSize = getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_size);
    mDotSizeActivated = getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_size_activated);

    mPaint.setAntiAlias(true);
    mPaint.setDither(true);

    mCellStates = new CellState[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            mCellStates[i][j] = new CellState();
            mCellStates[i][j].radius = mDotSize / 2;
            mCellStates[i][j].row = i;
            mCellStates[i][j].col = j;
        }
    }

    mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
    mLinearOutSlowInInterpolator = new LinearOutSlowInInterpolator();
    mExploreByTouchHelper = new PatternExploreByTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, mExploreByTouchHelper);
    mAccessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
}

From source file:com.android.messaging.ui.conversationlist.ConversationListFragment.java

@Override
public void onPrepareOptionsMenu(final Menu menu) {
    super.onPrepareOptionsMenu(menu);
    final MenuItem startNewConversationMenuItem = menu.findItem(R.id.action_start_new_conversation);
    if (startNewConversationMenuItem != null) {
        // It is recommended for the Floating Action button functionality to be duplicated as a
        // menu//from   w  w  w .  j a  v  a 2 s.  c o m
        AccessibilityManager accessibilityManager = (AccessibilityManager) getActivity()
                .getSystemService(Context.ACCESSIBILITY_SERVICE);
        startNewConversationMenuItem.setVisible(accessibilityManager.isTouchExplorationEnabled());
    }

    final MenuItem archive = menu.findItem(R.id.action_show_archived);
    if (archive != null) {
        archive.setVisible(true);
    }
}

From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java

private boolean isTalkbackOnAndOnPreLollipopMr1() {
    return ((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE))
            .isTouchExplorationEnabled() && !CompatUtils.isLollipopMr1Compatible();
}

From source file:com.zwj.customview.gesturelock.PatternView.java

public PatternView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PatternView, defStyleAttr, 0);

    mRowCount = a.getInteger(R.styleable.PatternView_pl_rowCount, PATTERN_SIZE_DEFAULT);
    mColumnCount = a.getInteger(R.styleable.PatternView_pl_columnCount, PATTERN_SIZE_DEFAULT);

    final String aspect = a.getString(R.styleable.PatternView_pl_aspect);

    if ("square".equals(aspect)) {
        mAspect = ASPECT_SQUARE;//from   w  w  w.  j a  v  a 2 s .  c  om
    } else if ("lock_width".equals(aspect)) {
        mAspect = ASPECT_LOCK_WIDTH;
    } else if ("lock_height".equals(aspect)) {
        mAspect = ASPECT_LOCK_HEIGHT;
    } else {
        mAspect = ASPECT_SQUARE;
    }

    setClickable(true);

    mPathPaint.setAntiAlias(true);
    mPathPaint.setDither(true);

    // Removed since every developer should set their own patternViewStyle.
    //mRegularColor = context.getColor(R.color.lock_pattern_view_regular_color);
    //mErrorColor = context.getColor(R.color.lock_pattern_view_error_color);
    //mSuccessColor = context.getColor(R.color.lock_pattern_view_success_color);
    mRegularColor = a.getColor(R.styleable.PatternView_pl_regularColor, mRegularColor);
    mErrorColor = a.getColor(R.styleable.PatternView_pl_errorColor, mErrorColor);
    mSuccessColor = a.getColor(R.styleable.PatternView_pl_successColor, mSuccessColor);

    // 
    int excircleColor = a.getColor(R.styleable.PatternView_excircle_color, Color.WHITE);

    // ?
    mExcircleRadius = a.getDimensionPixelSize(R.styleable.PatternView_excircle_radius,
            getResources().getDimensionPixelSize(R.dimen.pl_pattern_excircle_radius));

    // TODO ?????View????
    mDotRadius = a.getDimensionPixelSize(R.styleable.PatternView_dot_radius,
            getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_size));

    mDotRadiusActivated = a.getDimensionPixelSize(R.styleable.PatternView_dot_activated_radius,
            getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_size_activated));

    a.recycle();

    mPathPaint.setStyle(Paint.Style.STROKE);
    mPathPaint.setStrokeJoin(Paint.Join.ROUND);
    mPathPaint.setStrokeCap(Paint.Cap.ROUND);

    mPathWidth = getResources().getDimensionPixelSize(R.dimen.pl_pattern_dot_line_width);
    mPathPaint.setStrokeWidth(mPathWidth);

    mPaint.setAntiAlias(true);
    mPaint.setDither(true);

    mPaintExcircle.setAntiAlias(true);
    mPaintExcircle.setDither(true);
    mPaintExcircle.setColor(excircleColor);

    updatePatternSize();

    mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
    mLinearOutSlowInInterpolator = new LinearOutSlowInInterpolator();
    mExploreByTouchHelper = new PatternExploreByTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, mExploreByTouchHelper);
    mAccessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
}

From source file:com.silentcircle.contacts.activities.ScContactDetailActivity.java

/**
 * Setup the activity title and subtitle with contact name and company.
 *///ww  w  . j a  v a 2 s  . co  m
private void setupTitle() {
    CharSequence displayName = ContactDetailDisplayUtils.getDisplayName(this, mContactData);
    String company = ContactDetailDisplayUtils.getCompany(this, mContactData);

    ActionBar actionBar = this.getSupportActionBar();
    actionBar.setTitle(displayName);
    actionBar.setSubtitle(company);

    if (!TextUtils.isEmpty(displayName)) {
        AccessibilityManager accessibilityManager = (AccessibilityManager) this
                .getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (accessibilityManager.isEnabled()) {
            View decorView = getWindow().getDecorView();
            decorView.setContentDescription(displayName);
            decorView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        }
    }
}

From source file:org.chromium.content.browser.accessibility.AccessibilityInjector.java

private AccessibilityManager getAccessibilityManager() {
    if (mAccessibilityManager == null) {
        mAccessibilityManager = (AccessibilityManager) mContentViewCore.getContext()
                .getSystemService(Context.ACCESSIBILITY_SERVICE);
    }/*from   w  w  w  . j  a  v  a  2  s .c o  m*/

    return mAccessibilityManager;
}