Java Code Examples for android.view.accessibility.AccessibilityManager#isTouchExplorationEnabled()

The following examples show how to use android.view.accessibility.AccessibilityManager#isTouchExplorationEnabled() . 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: DynamicTooltip.java    From dynamic-support with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onHover(View v, MotionEvent event) {
    if (mPopup != null && mFromTouch) {
        return false;
    }

    AccessibilityManager manager = (AccessibilityManager)
            mAnchor.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (manager != null && manager.isEnabled() && manager.isTouchExplorationEnabled()) {
        return false;
    }

    switch (event.getAction()) {
        case MotionEvent.ACTION_HOVER_MOVE:
            if (mAnchor.isEnabled() && mPopup == null && updateAnchorPos(event)) {
                setPendingHandler(this);
            }
            break;
        case MotionEvent.ACTION_HOVER_EXIT:
            clearAnchorPos();
            hide();
            break;
    }

    return false;
}
 
Example 2
Source File: NumberPicker.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void onScrollStateChange(int scrollState) {
    if (mScrollState == scrollState) {
        return;
    }
    mScrollState = scrollState;
    if (mOnScrollListener != null) {
        mOnScrollListener.onScrollStateChange(this, scrollState);
    }
    if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
        AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (am.isTouchExplorationEnabled()) {
            String text = (mDisplayedValues == null) ? formatNumber(mValue) : mDisplayedValues[mValue - mMinValue];
            AccessibilityEvent event = AccessibilityEvent.obtain();
            event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
            event.getText().add(text);
            am.sendAccessibilityEvent(event);
        }
    }
}
 
Example 3
Source File: LockPatternView.java    From GestureLock with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onHoverEvent(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: NumberPicker.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void onScrollStateChange(int scrollState) {
    if (mScrollState == scrollState) {
        return;
    }
    mScrollState = scrollState;
    if (mOnScrollListener != null) {
        mOnScrollListener.onScrollStateChange(this, scrollState);
    }
    if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
        AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (am.isTouchExplorationEnabled()) {
            String text = (mDisplayedValues == null) ? formatNumber(mValue) : mDisplayedValues[mValue - mMinValue];
            AccessibilityEvent event = AccessibilityEvent.obtain();
            event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
            event.getText().add(text);
            am.sendAccessibilityEvent(event);
        }
    }
}
 
Example 5
Source File: FloatingEraseButton.java    From focus-android with Mozilla Public License 2.0 6 votes vote down vote up
public void updateSessionsCount(int tabCount) {
    final CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) getLayoutParams();
    final FloatingActionButtonBehavior behavior = (FloatingActionButtonBehavior) params.getBehavior();
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);

    keepHidden = tabCount != 1;

    if (behavior != null) {
        if (accessibilityManager != null && accessibilityManager.isTouchExplorationEnabled()) {
            // Always display erase button if Talk Back is enabled
            behavior.setEnabled(false);
        } else {
            behavior.setEnabled(!keepHidden);
        }
    }

    if (keepHidden) {
        setVisibility(View.GONE);
    }
}
 
Example 6
Source File: LockPatternView.java    From MHViewer 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 7
Source File: DeviceClassManager.java    From delion with Apache License 2.0 5 votes vote down vote up
public static boolean isAccessibilityModeEnabled(Context context) {
    TraceEvent.begin("DeviceClassManager::isAccessibilityModeEnabled");
    AccessibilityManager manager = (AccessibilityManager)
            context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    boolean enabled = manager != null && manager.isEnabled()
            && manager.isTouchExplorationEnabled();
    TraceEvent.end("DeviceClassManager::isAccessibilityModeEnabled");
    return enabled;
}
 
Example 8
Source File: AccessibilityUtil.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Checks to see that this device has accessibility and touch exploration enabled.
 * @param context A {@link Context} instance.
 * @return        Whether or not accessibility and touch exploration are enabled.
 */
@CalledByNative
public static boolean isAccessibilityEnabled(Context context) {
    AccessibilityManager manager = (AccessibilityManager)
            context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    return manager != null && manager.isEnabled() && manager.isTouchExplorationEnabled();
}
 
Example 9
Source File: AccessibilityUtils.java    From litho with Apache License 2.0 5 votes vote down vote up
public static boolean isRunningApplicableAccessibilityService(AccessibilityManager manager) {
  if (manager == null || !manager.isEnabled()) {
    return false;
  }

  return manager.isTouchExplorationEnabled()
      || enabledServiceCanFocusAndRetrieveWindowContent(manager);
}
 
Example 10
Source File: AccessibilityInfoModule.java    From react-native-GPay with MIT License 5 votes vote down vote up
public AccessibilityInfoModule(ReactApplicationContext context) {
    super(context);
    Context appContext = context.getApplicationContext();
    mAccessibilityManager = (AccessibilityManager) appContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    mEnabled = mAccessibilityManager.isTouchExplorationEnabled();
    if (Build.VERSION.SDK_INT >= 19) {
        mTouchExplorationStateChangeListener = new ReactTouchExplorationStateChangeListener();
    }
}
 
Example 11
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 12
Source File: CallSwipeView.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent ev) {
	AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
	if (!isEnabled() || am.isTouchExplorationEnabled()) {
		return super.onTouchEvent(ev);
	}
	if (ev.getAction() == MotionEvent.ACTION_DOWN) {
		if ((!dragFromRight && ev.getX() < getDraggedViewWidth()) || (dragFromRight && ev.getX() > getWidth() - getDraggedViewWidth())) {
			dragging = true;
			dragStartX = ev.getX();
			getParent().requestDisallowInterceptTouchEvent(true);
			listener.onDragStart();
			stopAnimatingArrows();
		}
	} else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
		viewToDrag.setTranslationX(Math.max(dragFromRight ? -(getWidth() - getDraggedViewWidth()) : 0, Math.min(ev.getX() - dragStartX, dragFromRight ? 0 : (getWidth() - getDraggedViewWidth()))));
		invalidate();
	} else if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) {
		if (Math.abs(viewToDrag.getTranslationX()) >= getWidth() - getDraggedViewWidth() && ev.getAction() == MotionEvent.ACTION_UP) {
			listener.onDragComplete();
		} else {
			listener.onDragCancel();
			viewToDrag.animate().translationX(0).setDuration(200).start();
			invalidate();
			startAnimatingArrows();
			dragging = false;
		}
	}
	return dragging;
}
 
Example 13
Source File: Workspace.java    From Trebuchet with GNU General Public License v3.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) {
            mLauncher.showOverviewMode(true);
        }
    };
    return listener;
}
 
Example 14
Source File: CallSwipeView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent ev) {
	AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
	if (!isEnabled() || am.isTouchExplorationEnabled()) {
		return super.onTouchEvent(ev);
	}
	if (ev.getAction() == MotionEvent.ACTION_DOWN) {
		if ((!dragFromRight && ev.getX() < getDraggedViewWidth()) || (dragFromRight && ev.getX() > getWidth() - getDraggedViewWidth())) {
			dragging = true;
			dragStartX = ev.getX();
			getParent().requestDisallowInterceptTouchEvent(true);
			listener.onDragStart();
			stopAnimatingArrows();
		}
	} else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
		viewToDrag.setTranslationX(Math.max(dragFromRight ? -(getWidth() - getDraggedViewWidth()) : 0, Math.min(ev.getX() - dragStartX, dragFromRight ? 0 : (getWidth() - getDraggedViewWidth()))));
		invalidate();
	} else if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) {
		if (Math.abs(viewToDrag.getTranslationX()) >= getWidth() - getDraggedViewWidth() && ev.getAction() == MotionEvent.ACTION_UP) {
			listener.onDragComplete();
		} else {
			listener.onDragCancel();
			viewToDrag.animate().translationX(0).setDuration(200).start();
			invalidate();
			startAnimatingArrows();
			dragging = false;
		}
	}
	return dragging;
}
 
Example 15
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 16
Source File: Utils.java    From Conquer with Apache License 2.0 5 votes vote down vote up
public static boolean isTouchExplorationEnabled(AccessibilityManager accessibilityManager) {
    if (Build.VERSION.SDK_INT >= 14) {
        return accessibilityManager.isTouchExplorationEnabled();
    } else {
        return false;
    }
}
 
Example 17
Source File: AccessibilityUtil.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Checks to see that this device has accessibility and touch exploration enabled.
 * @return        Whether or not accessibility and touch exploration are enabled.
 */
public static boolean isAccessibilityEnabled() {
    TraceEvent.begin("AccessibilityManager::isAccessibilityEnabled");
    AccessibilityManager manager =
            (AccessibilityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.ACCESSIBILITY_SERVICE);
    boolean retVal =
            manager != null && manager.isEnabled() && manager.isTouchExplorationEnabled();
    TraceEvent.end("AccessibilityManager::isAccessibilityEnabled");
    return retVal;
}
 
Example 18
Source File: DragLayer.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onInterceptHoverEvent(MotionEvent ev) {
    if (mLauncher == null || mLauncher.getWorkspace() == null) {
        return false;
    }
    Folder currentFolder = Folder.getOpen(mLauncher);
    if (currentFolder == null) {
        return false;
    } else {
            AccessibilityManager accessibilityManager = (AccessibilityManager)
                    getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (accessibilityManager.isTouchExplorationEnabled()) {
            final int action = ev.getAction();
            boolean isOverFolderOrSearchBar;
            switch (action) {
                case MotionEvent.ACTION_HOVER_ENTER:
                    isOverFolderOrSearchBar = isEventOverFolder(currentFolder, ev) ||
                        (isInAccessibleDrag() && isEventOverDropTargetBar(ev));
                    if (!isOverFolderOrSearchBar) {
                        sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
                        mHoverPointClosesFolder = true;
                        return true;
                    }
                    mHoverPointClosesFolder = false;
                    break;
                case MotionEvent.ACTION_HOVER_MOVE:
                    isOverFolderOrSearchBar = isEventOverFolder(currentFolder, ev) ||
                        (isInAccessibleDrag() && isEventOverDropTargetBar(ev));
                    if (!isOverFolderOrSearchBar && !mHoverPointClosesFolder) {
                        sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
                        mHoverPointClosesFolder = true;
                        return true;
                    } else if (!isOverFolderOrSearchBar) {
                        return true;
                    }
                    mHoverPointClosesFolder = false;
            }
        }
    }
    return false;
}
 
Example 19
Source File: AccessibilityManagerCompatIcs.java    From guideshow with MIT License 4 votes vote down vote up
public static boolean isTouchExplorationEnabled(AccessibilityManager manager) {
    return manager.isTouchExplorationEnabled();
}
 
Example 20
Source File: AccessibilityTutorialActivity.java    From talkback with Apache License 2.0 4 votes vote down vote up
@Override
public void onStart() {
  super.onStart();
  activeTutorial = this;

  /*
   * Handle the cases where the tutorial was started with TalkBack in an
   * invalid state (inactive, suspended, or without Explore by Touch
   * enabled).
   */
  final int serviceState = TalkBackService.getServiceState();
  final AccessibilityManager accessibilityManager =
      (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);
  /*
   * Check for suspended state first because touch exploration reports it
   * is disabled when TalkBack is suspended.
   */
  if (serviceState == ServiceStateListener.SERVICE_STATE_SUSPENDED) {
    showAlertDialogAndFinish(
        R.string.tutorial_service_suspended_title, R.string.tutorial_service_suspended_message);
    return;
  } else if ((serviceState == ServiceStateListener.SERVICE_STATE_INACTIVE)) {
    showAlertDialogAndFinish(
        R.string.tutorial_service_inactive_title, R.string.tutorial_service_inactive_message);
    return;
  } else if (!accessibilityManager.isTouchExplorationEnabled()) {
    showAlertDialogAndFinish(
        R.string.tutorial_no_touch_explore_title, R.string.tutorial_no_touch_explore_message);
    return;
  }

  TalkBackService service = TalkBackService.getInstance();
  if (service != null) {
    service.setMenuManagerToList();
  }

  SharedPreferences preferences =
      SharedPreferencesUtils.getSharedPreferences(getApplicationContext());

  if (preferences.getBoolean(TalkBackService.PREF_FIRST_TIME_USER, true)) {
    final SharedPreferences.Editor editor = preferences.edit();
    editor.putBoolean(TalkBackService.PREF_FIRST_TIME_USER, false);
    editor.apply();
    onFirstTimeLaunch();
  }
}