use of android.view.accessibility.AccessibilityManager in project Launcher3 by chislon.
the class LauncherTransitionable method isClingsEnabled.
/* Cling related */
private boolean isClingsEnabled() {
if (DISABLE_CLINGS) {
return false;
}
// For now, limit only to phones
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
if (grid.isTablet()) {
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) getSystemService(ACCESSIBILITY_SERVICE);
if (a11yManager.isTouchExplorationEnabled()) {
return false;
}
// }
return true;
}
use of android.view.accessibility.AccessibilityManager in project Launcher3 by chislon.
the class PagedView method sendScrollAccessibilityEvent.
private void sendScrollAccessibilityEvent() {
AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (am.isEnabled()) {
AccessibilityEvent ev = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED);
ev.setItemCount(getChildCount());
ev.setFromIndex(mCurrentPage);
final int action;
if (getNextPage() >= mCurrentPage) {
action = AccessibilityNodeInfo.ACTION_SCROLL_FORWARD;
} else {
action = AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD;
}
ev.setAction(action);
sendAccessibilityEventUnchecked(ev);
}
}
use of android.view.accessibility.AccessibilityManager in project platform_frameworks_base by android.
the class ExploreByTouchHelper method requestAccessibilityFocus.
/**
* Attempts to give accessibility focus to a virtual view.
* <p>
* A virtual view will not actually take focus if
* {@link AccessibilityManager#isEnabled()} returns false,
* {@link AccessibilityManager#isTouchExplorationEnabled()} returns false,
* or the view already has accessibility focus.
*
* @param virtualViewId The id of the virtual view on which to place
* accessibility focus.
* @return Whether this virtual view actually took accessibility focus.
*/
private boolean requestAccessibilityFocus(int virtualViewId) {
final AccessibilityManager accessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (!mManager.isEnabled() || !accessibilityManager.isTouchExplorationEnabled()) {
return false;
}
// TODO: Check virtual view visibility.
if (!isAccessibilityFocused(virtualViewId)) {
// Clear focus from the previously focused view, if applicable.
if (mFocusedVirtualViewId != INVALID_ID) {
sendEventForVirtualView(mFocusedVirtualViewId, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
}
// Set focus on the new view.
mFocusedVirtualViewId = virtualViewId;
// TODO: Only invalidate virtual view bounds.
mView.invalidate();
sendEventForVirtualView(virtualViewId, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
return true;
}
return false;
}
use of android.view.accessibility.AccessibilityManager in project SublimePicker by vikramkakkar.
the class AccessibilityUtils method makeAnnouncement.
public static void makeAnnouncement(View view, CharSequence announcement) {
if (view == null)
return;
if (SUtils.isApi_16_OrHigher()) {
view.announceForAccessibility(announcement);
} else {
// For API 15 and earlier, we need to construct an accessibility event
Context ctx = view.getContext();
AccessibilityManager am = (AccessibilityManager) ctx.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (!am.isEnabled())
return;
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
AccessibilityRecordCompat arc = AccessibilityEventCompat.asRecord(event);
arc.setSource(view);
event.setClassName(view.getClass().getName());
event.setPackageName(view.getContext().getPackageName());
event.setEnabled(view.isEnabled());
event.getText().add(announcement);
am.sendAccessibilityEvent(event);
}
}
use of android.view.accessibility.AccessibilityManager in project AndroidChromium by JackyAndroid.
the class DeviceClassManager method isAccessibilityModeEnabled.
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;
}
Aggregations