android.view.accessibility.AccessibilityManager Java Examples

The following examples show how to use android.view.accessibility.AccessibilityManager. 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 check out the related API usage on the sidebar.
Example #1
Source File: LockPatternView.java    From android-lockpattern with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onHoverEvent(MotionEvent event) {
    if (AccessibilityManager.getInstance(mContext).isTouchExplorationEnabled()) {
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_HOVER_ENTER:
                event.setAction(MotionEvent.ACTION_DOWN);
                break;
            case MotionEvent.ACTION_HOVER_MOVE:
                event.setAction(MotionEvent.ACTION_MOVE);
                break;
            case MotionEvent.ACTION_HOVER_EXIT:
                event.setAction(MotionEvent.ACTION_UP);
                break;
        }
        onTouchEvent(event);
        event.setAction(action);
    }
    return super.onHoverEvent(event);
}
 
Example #2
Source File: WeChatFragment.java    From WeChatHongBao with Apache License 2.0 6 votes vote down vote up
private void updateServiceStatus() {
    boolean serviceEnabled = false;

    AccessibilityManager accessibilityManager =
            (AccessibilityManager) baseContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    List<AccessibilityServiceInfo> accessibilityServices =
            accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC);
    for (AccessibilityServiceInfo info : accessibilityServices) {
        if (info.getId().equals(baseContext.getPackageName() + "/.services.HongbaoService")) {
            serviceEnabled = true;
            break;
        }
    }

    if (!serviceEnabled) {
        btn.setText(R.string.service_open);
    } else {
        btn.setText(R.string.service_off);
    }
}
 
Example #3
Source File: LockPatternView.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onHoverEvent(@NonNull MotionEvent event) {
    AccessibilityManager accessibilityManager =
            (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isTouchExplorationEnabled()) {
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_HOVER_ENTER:
                event.setAction(MotionEvent.ACTION_DOWN);
                break;
            case MotionEvent.ACTION_HOVER_MOVE:
                event.setAction(MotionEvent.ACTION_MOVE);
                break;
            case MotionEvent.ACTION_HOVER_EXIT:
                event.setAction(MotionEvent.ACTION_UP);
                break;
        }
        onTouchEvent(event);
        event.setAction(action);
    }
    return super.onHoverEvent(event);
}
 
Example #4
Source File: Utils.java    From Noyze with Apache License 2.0 6 votes vote down vote up
/**
 * API 14+, check if the given {@link AccessibilityService} is enabled.
 *
 * @return True if id is an enabled {@link AccessibilityService}.
 */
public static boolean isAccessibilityServiceEnabled14(Context context, String[] ids) {

    AccessibilityManager aManager = (AccessibilityManager)
            context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (null == aManager || null == ids) return false;

    List<AccessibilityServiceInfo> services = aManager
            .getEnabledAccessibilityServiceList(AccessibilityEvent.TYPES_ALL_MASK);
    for (AccessibilityServiceInfo service : services) {
        if (contains(ids, service.getId())) {
            return true;
        }
    }

    return false;
}
 
Example #5
Source File: DialpadView.java    From android-dialer with Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
  setupKeypad();
  mDigits = (EditText) findViewById(R.id.digits);
  mDelete = (ImageButton) findViewById(R.id.deleteButton);
  mOverflowMenuButton = findViewById(R.id.dialpad_overflow);
  mRateContainer = (ViewGroup) findViewById(R.id.rate_container);
  mIldCountry = (TextView) mRateContainer.findViewById(R.id.ild_country);
  mIldRate = (TextView) mRateContainer.findViewById(R.id.ild_rate);

  AccessibilityManager accessibilityManager =
      (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (accessibilityManager.isEnabled()) {
    // The text view must be selected to send accessibility events.
    mDigits.setSelected(true);
  }
}
 
Example #6
Source File: BaseWebView.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void disableAccessibility(Context context) {
    if (Build.VERSION.SDK_INT == 17/*4.2 (Build.VERSION_CODES.JELLY_BEAN_MR1)*/) {
        if (context != null) {
            try {
                AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
                if (!am.isEnabled()) {
                    //Not need to disable accessibility
                    return;
                }

                Method setState = am.getClass().getDeclaredMethod("setState", int.class);
                setState.setAccessible(true);
                setState.invoke(am, 0);/**{@link AccessibilityManager#STATE_FLAG_ACCESSIBILITY_ENABLED}*/
            } catch (Exception ignored) {
                ignored.printStackTrace();
            }
        }
    }
}
 
Example #7
Source File: Workspace.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
public ValueAnimator createHotseatAlphaAnimator(float finalValue) {
    if (Float.compare(finalValue, mHotseatAlpha[HOTSEAT_STATE_ALPHA_INDEX]) == 0) {
        // Return a dummy animator to avoid null checks.
        return ValueAnimator.ofFloat(0, 0);
    } else {
        ValueAnimator animator = ValueAnimator
                .ofFloat(mHotseatAlpha[HOTSEAT_STATE_ALPHA_INDEX], finalValue);
        animator.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float value = (Float) valueAnimator.getAnimatedValue();
                setHotseatAlphaAtIndex(value, HOTSEAT_STATE_ALPHA_INDEX);
            }
        });

        AccessibilityManager am = (AccessibilityManager)
                mLauncher.getSystemService(Context.ACCESSIBILITY_SERVICE);
        final boolean accessibilityEnabled = am.isEnabled();
        animator.addUpdateListener(
                new AlphaUpdateListener(mLauncher.getHotseat(), accessibilityEnabled));
        animator.addUpdateListener(
                new AlphaUpdateListener(mPageIndicator, accessibilityEnabled));
        return animator;
    }
}
 
Example #8
Source File: SwitchPreference.java    From holoaccent with Apache License 2.0 6 votes vote down vote up
/** As defined in TwoStatePreference source */
void sendAccessibilityEvent(View view) {
    // Since the view is still not attached we create, populate,
    // and send the event directly since we do not know when it
    // will be attached and posting commands is not as clean.
	AccessibilityManager accessibilityManager =
	        (AccessibilityManager)getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
	if (accessibilityManager == null)
		return;
    if (mSendClickAccessibilityEvent && accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain();
        event.setEventType(AccessibilityEvent.TYPE_VIEW_CLICKED);
        view.onInitializeAccessibilityEvent(event);
        view.dispatchPopulateAccessibilityEvent(event);
        accessibilityManager.sendAccessibilityEvent(event);
    }
    mSendClickAccessibilityEvent = false;
}
 
Example #9
Source File: PPPExtenderBroadcastReceiver.java    From PhoneProfilesPlus with Apache License 2.0 6 votes vote down vote up
static boolean isAccessibilityServiceEnabled(Context context) {
    AccessibilityManager manager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (manager != null) {
        List<AccessibilityServiceInfo> runningServices =
                manager.getEnabledAccessibilityServiceList(AccessibilityEvent.TYPES_ALL_MASK);

        for (AccessibilityServiceInfo service : runningServices) {
            if (service != null) {
                //PPApplication.logE("PPPExtenderBroadcastReceiver.isAccessibilityServiceEnabled", "serviceId=" + service.getId());
                if (PPApplication.EXTENDER_ACCESSIBILITY_SERVICE_ID.equals(service.getId())) {
                    //PPApplication.logE("PPPExtenderBroadcastReceiver.isAccessibilityServiceEnabled", "true");
                    return true;
                }
            }
        }
        //PPApplication.logE("PPPExtenderBroadcastReceiver.isAccessibilityServiceEnabled", "false");
        return false;
    }
    //PPApplication.logE("PPPExtenderBroadcastReceiver.isAccessibilityServiceEnabled", "false");
    return false;
}
 
Example #10
Source File: ContentViewCore.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Constructs a new ContentViewCore. Embedders must call initialize() after constructing
 * a ContentViewCore and before using it.
 *
 * @param context The context used to create this.
 */
public ContentViewCore(Context context) {
    mContext = context;

    WeakContext.initializeWeakContext(context);
    HeapStatsLogger.init(mContext.getApplicationContext());
    mAdapterInputConnectionFactory = new AdapterInputConnectionFactory();

    mRenderCoordinates = new RenderCoordinates();
    mRenderCoordinates.setDeviceScaleFactor(
            getContext().getResources().getDisplayMetrics().density);
    mStartHandlePoint = mRenderCoordinates.createNormalizedPoint();
    mEndHandlePoint = mRenderCoordinates.createNormalizedPoint();
    mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint();
    mAccessibilityManager = (AccessibilityManager)
            getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
}
 
Example #11
Source File: Per_App.java    From isu with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isAccessibilityEnabled(Context context, String id) {
    if (id == null) return false;
    AccessibilityManager am = (AccessibilityManager) context
        .getSystemService(Context.ACCESSIBILITY_SERVICE);

    List < AccessibilityServiceInfo > runningServices = am
        .getEnabledAccessibilityServiceList(AccessibilityEvent.TYPES_ALL_MASK);
    for (AccessibilityServiceInfo service: runningServices) {
        if (id.equals(service.getId()))
            return true;
    }

    return false;
}
 
Example #12
Source File: AdapterView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void selectionChanged() {
    // We're about to post or run the selection notifier, so we don't need
    // a pending notifier.
    mPendingSelectionNotifier = null;

    if (mOnItemSelectedListener != null
            || AccessibilityManager.getInstance(mContext).isEnabled()) {
        if (mInLayout || mBlockLayoutRequests) {
            // If we are in a layout traversal, defer notification
            // by posting. This ensures that the view tree is
            // in a consistent state and is able to accommodate
            // new layout or invalidate requests.
            if (mSelectionNotifier == null) {
                mSelectionNotifier = new SelectionNotifier();
            } else {
                removeCallbacks(mSelectionNotifier);
            }
            post(mSelectionNotifier);
        } else {
            dispatchOnItemSelected();
        }
    }
    // Always notify AutoFillManager - it will return right away if autofill is disabled.
    final AutofillManager afm = mContext.getSystemService(AutofillManager.class);
    if (afm != null) {
        afm.notifyValueChanged(this);
    }
}
 
Example #13
Source File: DagashiBar.java    From HgLauncher with GNU General Public License v3.0 5 votes vote down vote up
private DagashiBar(
        ViewGroup parent,
        View content,
        com.google.android.material.snackbar.ContentViewCallback contentViewCallback) {
    super(parent, content, contentViewCallback);
    accessibilityManager =
            (AccessibilityManager) parent.getContext()
                                         .getSystemService(Context.ACCESSIBILITY_SERVICE);
}
 
Example #14
Source File: ViewParentCompat.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean requestSendAccessibilityEvent(ViewParent parent, View child, AccessibilityEvent event) {
    if (child == null) {
        return false;
    }
    ((AccessibilityManager) child.getContext().getSystemService("accessibility")).sendAccessibilityEvent(event);
    return true;
}
 
Example #15
Source File: LauncherClings.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
/** Returns whether the clings are enabled or should be shown */
private boolean areClingsEnabled() {
    if (DISABLE_CLINGS) {
        return false;
    }

    // disable clings when running in a test harness
    if(ActivityManager.isRunningInTestHarness()) return false;

    // Disable clings for accessibility when explore by touch is enabled
    final AccessibilityManager a11yManager = (AccessibilityManager) mLauncher.getSystemService(
            Launcher.ACCESSIBILITY_SERVICE);
    if (a11yManager.isTouchExplorationEnabled()) {
        return false;
    }

    // Restricted secondary users (child mode) will potentially have very few apps
    // seeded when they start up for the first time. Clings won't work well with that
    boolean supportsLimitedUsers =
            android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2;
    Account[] accounts = AccountManager.get(mLauncher).getAccounts();
    if (supportsLimitedUsers && accounts.length == 0) {
        UserManager um = (UserManager) mLauncher.getSystemService(Context.USER_SERVICE);
        Bundle restrictions = um.getUserRestrictions();
        if (restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false)) {
            return false;
        }
    }
    if (Settings.Secure.getInt(mLauncher.getContentResolver(), SKIP_FIRST_USE_HINTS, 0)
            == 1) {
        return false;
    }
    return true;
}
 
Example #16
Source File: Workspace.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@Override
protected OnClickListener getPageIndicatorClickListener() {
    AccessibilityManager am = (AccessibilityManager)
            getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (!am.isTouchExplorationEnabled()) {
        return null;
    }
    OnClickListener listener = new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            enterOverviewMode();
        }
    };
    return listener;
}
 
Example #17
Source File: MaskService.java    From Blackbulb with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mAccessibilityManager = (AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE);
}
 
Example #18
Source File: NumberPicker.java    From zen4android with MIT License 5 votes vote down vote up
private void sendAccessibilityEventForVirtualButton(int virtualViewId, int eventType,
        String text) {
    if (((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)).isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        event.setClassName(Button.class.getName());
        event.setPackageName(getContext().getPackageName());
        event.getText().add(text);
        event.setEnabled(NumberPicker.this.isEnabled());
        event.setSource(NumberPicker.this, virtualViewId);
        requestSendAccessibilityEvent(NumberPicker.this, event);
    }
}
 
Example #19
Source File: Utils.java    From Noyze with Apache License 2.0 5 votes vote down vote up
/**
 * @return True if system-wide Accessibility is enabled.
 */
public static boolean isAccessibilityEnabled(Context context) {
    // Also see Settings.Secure.ACCESSIBILITY_ENABLED, alternative method.
    AccessibilityManager aManager = (AccessibilityManager)
            context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    return (null != aManager && aManager.isEnabled());
}
 
Example #20
Source File: LockPatternView_v14.java    From Pi-Locker with GNU General Public License v2.0 5 votes vote down vote up
public LockPatternView_v14(Context context, AttributeSet attrs) {
    super(context, attrs);

    mAccessibilityManager = isInEditMode() ? null
            : (AccessibilityManager) context
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
}
 
Example #21
Source File: DragLayer.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
private void sendTapOutsideFolderAccessibilityEvent(boolean isEditingName) {
    AccessibilityManager accessibilityManager = (AccessibilityManager)
            getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close;
        AccessibilityEvent event = AccessibilityEvent.obtain(
                AccessibilityEvent.TYPE_VIEW_FOCUSED);
        onInitializeAccessibilityEvent(event);
        event.getText().add(getContext().getString(stringId));
        accessibilityManager.sendAccessibilityEvent(event);
    }
}
 
Example #22
Source File: DropTargetBar.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
    AccessibilityManager am = (AccessibilityManager)
            getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    boolean accessibilityEnabled = am.isEnabled();
    AlphaUpdateListener.updateVisibility(DropTargetBar.this, accessibilityEnabled);
}
 
Example #23
Source File: DragLayer.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onInterceptHoverEvent(MotionEvent ev) {
    if (mLauncher == null || mLauncher.getWorkspace() == null) {
        return false;
    }
    Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
    if (currentFolder == null) {
        return false;
    } else {
            AccessibilityManager accessibilityManager = (AccessibilityManager)
                    getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (accessibilityManager.isTouchExplorationEnabled()) {
            final int action = ev.getAction();
            boolean isOverFolder;
            switch (action) {
                case MotionEvent.ACTION_HOVER_ENTER:
                    isOverFolder = isEventOverFolder(currentFolder, ev);
                    if (!isOverFolder) {
                        sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
                        mHoverPointClosesFolder = true;
                        return true;
                    }
                    mHoverPointClosesFolder = false;
                    break;
                case MotionEvent.ACTION_HOVER_MOVE:
                    isOverFolder = isEventOverFolder(currentFolder, ev);
                    if (!isOverFolder && !mHoverPointClosesFolder) {
                        sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
                        mHoverPointClosesFolder = true;
                        return true;
                    } else if (!isOverFolder) {
                        return true;
                    }
                    mHoverPointClosesFolder = false;
            }
        }
    }
    return false;
}
 
Example #24
Source File: GestureOverlay.java    From brailleback with Apache License 2.0 5 votes vote down vote up
private void initAccessibilitySettings(Context context) {
    // Check is touch exploration is on
    accessibilityManager = (AccessibilityManager) context.getSystemService(
            Context.ACCESSIBILITY_SERVICE);

    try {
        if (AccessibilityManager_isTouchExplorationEnabled != null) {
            Object retobj = AccessibilityManager_isTouchExplorationEnabled
                    .invoke(accessibilityManager);
            touchExploring = (Boolean) retobj;
        }
    } catch (Exception e) {
        Log.e("GestureOverlay", "Failed to get Accessibility Manager " + e.toString());
    }
}
 
Example #25
Source File: ChartView.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
  super.onWindowFocusChanged(hasWindowFocus);
  if (hasWindowFocus) {
    // The user could have changed the accessibility mode while we were in the background,
    // so just get it when window focus changes.
    exploreByTouchEnabled =
        ((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE))
            .isTouchExplorationEnabled();
  }
}
 
Example #26
Source File: ExploreByTouchHelper.java    From guideshow with MIT License 5 votes vote down vote up
/**
 * Factory method to create a new {@link ExploreByTouchHelper}.
 *
 * @param forView View whose logical children are exposed by this helper.
 */
public ExploreByTouchHelper(View forView) {
    if (forView == null) {
        throw new IllegalArgumentException("View may not be null");
    }

    mView = forView;
    final Context context = forView.getContext();
    mManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
}
 
Example #27
Source File: DragLayer.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onInterceptHoverEvent(MotionEvent ev) {
    if (mLauncher == null || mLauncher.getWorkspace() == null) {
        return false;
    }
    Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
    if (currentFolder == null) {
        return false;
    } else {
            AccessibilityManager accessibilityManager = (AccessibilityManager)
                    getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (accessibilityManager.isTouchExplorationEnabled()) {
            final int action = ev.getAction();
            boolean isOverFolder;
            switch (action) {
                case MotionEvent.ACTION_HOVER_ENTER:
                    isOverFolder = isEventOverFolder(currentFolder, ev);
                    if (!isOverFolder) {
                        sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
                        mHoverPointClosesFolder = true;
                        return true;
                    }
                    mHoverPointClosesFolder = false;
                    break;
                case MotionEvent.ACTION_HOVER_MOVE:
                    isOverFolder = isEventOverFolder(currentFolder, ev);
                    if (!isOverFolder && !mHoverPointClosesFolder) {
                        sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
                        mHoverPointClosesFolder = true;
                        return true;
                    } else if (!isOverFolder) {
                        return true;
                    }
                    mHoverPointClosesFolder = false;
            }
        }
    }
    return false;
}
 
Example #28
Source File: AccessibilityManagerCompat.java    From android-recipes-app with Apache License 2.0 4 votes vote down vote up
@Override
public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(
        AccessibilityManager manager, int feedbackTypeFlags) {
    return AccessibilityManagerCompatIcs.getEnabledAccessibilityServiceList(manager,
            feedbackTypeFlags);
}
 
Example #29
Source File: AccessibilityManagerCompat.java    From letv with Apache License 2.0 4 votes vote down vote up
public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(AccessibilityManager manager, int feedbackTypeFlags) {
    return Collections.emptyList();
}
 
Example #30
Source File: AccessibilityManagerCompat.java    From guideshow with MIT License 4 votes vote down vote up
public boolean addAccessibilityStateChangeListener(AccessibilityManager manager,
AccessibilityStateChangeListenerCompat listener);