Android AccessibilityManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AccessibilityManager class.

This code example shows how to use the following methods:isEnabled, isTouchExplorationEnabled
     * that the kill switch is off and system accessibility is turned on. 
     * 
     * @return {@code true} if accessibility is enabled. 
     */ 
    public boolean isAccessibilityEnabled() { 
        return ENABLE_ACCESSIBILITY && mAccessibilityManager.isEnabled();
    } 
 
    /** 
     * Returns {@code true} if touch exploration is enabled. Currently, this 
     * means that the kill switch is off, the device supports touch exploration, 
     * and system accessibility is turned on. 
     * 
     * @return {@code true} if touch exploration is enabled. 
     */ 
    public boolean isTouchExplorationEnabled() { 
        return isAccessibilityEnabled() && mAccessibilityManager.isTouchExplorationEnabled();
    } 
 
    /** 

6
CodeRank
This code example shows how to use the following methods:isEnabled, isTouchExplorationEnabled
        Context context = getContext();
        // only send accessibility events if accessibility and exploration are 
        // on. 
        AccessibilityManager am = (AccessibilityManager) context
                .getSystemService(Service.ACCESSIBILITY_SERVICE);
        if (!am.isEnabled() || !am.isTouchExplorationEnabled()) {
            return super.onHoverEvent(event);
        } 
        if (event.getAction() != MotionEvent.ACTION_HOVER_EXIT) {
            Time hover = getDayFromLocation(event.getX());
            if (hover != null
                    && (mLastHoverTime == null || Time.compare(hover, mLastHoverTime) != 0)) {
                Long millis = hover.toMillis(true);
                String date = Utils.formatDateRange(context, millis, millis,
                        DateUtils.FORMAT_SHOW_DATE);
                AccessibilityEvent accessEvent =
                    AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
                accessEvent.getText().add(date);
                sendAccessibilityEventUnchecked(accessEvent);
                mLastHoverTime = hover;
6
CodeRank
This code example shows how to use the following methods:isEnabled, isTouchExplorationEnabled
 
    @Override 
    public boolean performClick() { 
        // When accessibility is on, simulate press and release to preserve the 
        // semantic meaning of performClick(). Required for Braille support. 
        if (mAccessibilityManager.isEnabled()) {
            // Checking the press state prevents double activation. 
            if (!isPressed()) {
                setPressed(true); 
                setPressed(false); 
            } 
 
            return true; 
        } 
 
        return super.performClick(); 
    } 
 
    @Override 
    public boolean onHoverEvent(MotionEvent event) {

6
CodeRank
This code example shows how to use the following methods:isEnabled, isTouchExplorationEnabled
 
    @Override 
    public boolean onHover(View v, MotionEvent event) {
        // When touch exploration is turned on, lifting a finger while 
        // inside the view bounds should perform a click action. 
        if (mAccessibilityManager.isEnabled()
                && mAccessibilityManager.isTouchExplorationEnabled()) {
            switch (event.getActionMasked()) {
                case MotionEvent.ACTION_HOVER_ENTER:
                    // Lift-to-type temporarily disables double-tap 
                    // activation by setting the view as not clickable. 
                    mCachedClickableState = v.isClickable();
                    v.setClickable(false);
                    break; 
                case MotionEvent.ACTION_HOVER_EXIT:
                    final int x = (int) event.getX();
                    final int y = (int) event.getY();
                    if ((x > v.getPaddingLeft()) && (y > v.getPaddingTop())
                            && (x < v.getWidth() - v.getPaddingRight())
                            && (y < v.getHeight() - v.getPaddingBottom())) {
5
CodeRank
This code example shows how to use the following methods:isEnabled, isTouchExplorationEnabled
        Context context = getContext();
        // only send accessibility events if accessibility and exploration are 
        // on. 
        AccessibilityManager am = (AccessibilityManager) context
                .getSystemService(Service.ACCESSIBILITY_SERVICE);
        if (!am.isEnabled() || !am.isTouchExplorationEnabled()) {
            return super.onHoverEvent(event);
        } 
        if (event.getAction() != MotionEvent.ACTION_HOVER_EXIT) {
            Time hover = getDayFromLocation(event.getX());
            if (hover != null
                    && (mLastHoverTime == null || Time.compare(hover, mLastHoverTime) != 0)) {
                Long millis = hover.toMillis(true);
                String date = formatDateRange(context, millis, millis,
                        DateUtils.FORMAT_SHOW_DATE);
                AccessibilityEvent accessEvent =
                    AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
                accessEvent.getText().add(date);
                sendAccessibilityEventUnchecked(accessEvent);
                mLastHoverTime = hover;
5
CodeRank
This code example shows how to use the following methods:interrupt, isEnabled, sendAccessibilityEvent
This code example shows how to use the following methods:isEnabled, isTouchExplorationEnabled
 
    @Override 
    public boolean onHoverEvent(MotionEvent event) {
        // When touch exploration is turned on, lifting a finger while inside 
        // the button's hover target bounds should perform a click action. 
        if (mAccessibilityManager.isEnabled()
                && mAccessibilityManager.isTouchExplorationEnabled()) {
            switch (event.getActionMasked()) {
                case MotionEvent.ACTION_HOVER_ENTER:
                    // Lift-to-type temporarily disables double-tap activation. 
                    setClickable(false);
                    break; 
                case MotionEvent.ACTION_HOVER_EXIT:
                    if (mHoverBounds.contains((int) event.getX(), (int) event.getY())) {
                        simulateClickForAccessibility(); 
                    } 
                    setClickable(true);
                    break; 
            } 
        } 
5
CodeRank
This code example shows how to use the following methods:isEnabled, isTouchExplorationEnabled
     * 
     * @return {@code true} if touch exploration is enabled. 
     */ 
    public boolean isTouchExplorationEnabled() { 
        return ENABLE_ACCESSIBILITY
                && mAccessibilityManager.isEnabled()
                && mAccessibilityManager.isTouchExplorationEnabled();
    } 
 
    /** 
     * Returns {@true} if the provided event is a touch exploration (e.g. hover) 
     * event. This is used to determine whether the event should be processed by 
     * the touch exploration code within the keyboard. 
     * 
     * @param event The event to check. 
     * @return {@true} is the event is a touch exploration event 
     */ 
    public boolean isTouchExplorationEvent(MotionEvent event) {
        final int action = event.getAction();
 
5
CodeRank
This code example shows how to use the following methods:isTouchExplorationEnabled
         * @param eventType The type of the event to send. 
         */ 
        private void sendAccessibilityEventForVirtualView(VirtualView virtualView, int eventType) {
            // If touch exploration, i.e. the user gets feedback while touching 
            // the screen, is enabled we fire accessibility events. 
            if (mAccessibilityManager.isTouchExplorationEnabled()) {
                AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
                event.setPackageName(getContext().getPackageName());
                event.setClassName(virtualView.getClass().getName());
                event.setSource(VirtualSubtreeRootView.this, virtualView.mId);
                event.getText().add(virtualView.mText);
                getParent().requestSendAccessibilityEvent(VirtualSubtreeRootView.this, event);
            } 
        } 
 
        /** 
         * Finds a virtual view given its id. 
         * 
         * @param id The virtual view id. 
         * @return The found virtual view. 
5
CodeRank
This code example shows how to use the following methods:isEnabled
 
    /** 
     * @see AccessibilityNodeProvider#createAccessibilityNodeInfo(int) 
     */ 
    protected AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
        if (!mAccessibilityManager.isEnabled() || mNativeObj == 0 || !mFrameInfoInitialized) {
            return null; 
        } 
 
        int rootId = nativeGetRootId(mNativeObj);
        if (virtualViewId == View.NO_ID) {
            virtualViewId = rootId;
        } 
        if (mAccessibilityFocusId == View.NO_ID) {
            mAccessibilityFocusId = rootId;
        } 
 
        final AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(mView);
        info.setPackageName(mContentViewCore.getContext().getPackageName());
        info.setSource(mView, virtualViewId);
5
CodeRank

Related Android AccessibilityManager Questions & Answers:

See Code Examples for Android AccessibilityManager Methods: