use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class View method requestAccessibilityFocus.
/**
* Call this to try to give accessibility focus to this view.
*
* A view will not actually take focus if {@link AccessibilityManager#isEnabled()}
* returns false or the view is no visible or the view already has accessibility
* focus.
*
* See also {@link #focusSearch(int)}, which is what you call to say that you
* have focus, and you want your parent to look for the next one.
*
* @return Whether this view actually took accessibility focus.
*
* @hide
*/
public boolean requestAccessibilityFocus() {
AccessibilityManager manager = AccessibilityManager.getInstance(mContext);
if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) {
return false;
}
if ((mViewFlags & VISIBILITY_MASK) != VISIBLE) {
return false;
}
if ((mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) == 0) {
mPrivateFlags2 |= PFLAG2_ACCESSIBILITY_FOCUSED;
ViewRootImpl viewRootImpl = getViewRootImpl();
if (viewRootImpl != null) {
viewRootImpl.setAccessibilityFocus(this, null);
}
invalidate();
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
return true;
}
return false;
}
use of android.view.accessibility.AccessibilityManager in project Etar-Calendar by Etar-Group.
the class SimpleWeekView method onHoverEvent.
@Override
public boolean onHoverEvent(MotionEvent event) {
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;
}
}
return true;
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by ParanoidAndroid.
the class WebViewClassic method isAccessibilityInjectionEnabled.
private boolean isAccessibilityInjectionEnabled() {
final AccessibilityManager manager = AccessibilityManager.getInstance(mContext);
if (!manager.isEnabled()) {
return false;
}
// Accessibility scripts should be injected only when a speaking service
// is enabled. This may need to change later to accommodate Braille.
final List<AccessibilityServiceInfo> services = manager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN);
if (services.isEmpty()) {
return false;
}
return true;
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by ParanoidAndroid.
the class ViewRootImpl method drawAccessibilityFocusedDrawableIfNeeded.
/**
* We want to draw a highlight around the current accessibility focused.
* Since adding a style for all possible view is not a viable option we
* have this specialized drawing method.
*
* Note: We are doing this here to be able to draw the highlight for
* virtual views in addition to real ones.
*
* @param canvas The canvas on which to draw.
*/
private void drawAccessibilityFocusedDrawableIfNeeded(Canvas canvas) {
AccessibilityManager manager = AccessibilityManager.getInstance(mView.mContext);
if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) {
return;
}
if (mAccessibilityFocusedHost == null || mAccessibilityFocusedHost.mAttachInfo == null) {
return;
}
Drawable drawable = getAccessibilityFocusedDrawable();
if (drawable == null) {
return;
}
AccessibilityNodeProvider provider = mAccessibilityFocusedHost.getAccessibilityNodeProvider();
Rect bounds = mView.mAttachInfo.mTmpInvalRect;
if (provider == null) {
mAccessibilityFocusedHost.getBoundsOnScreen(bounds);
} else {
if (mAccessibilityFocusedVirtualView == null) {
return;
}
mAccessibilityFocusedVirtualView.getBoundsInScreen(bounds);
}
bounds.offset(-mAttachInfo.mWindowLeft, -mAttachInfo.mWindowTop);
bounds.intersect(0, 0, mAttachInfo.mViewRootImpl.mWidth, mAttachInfo.mViewRootImpl.mHeight);
drawable.setBounds(bounds);
drawable.draw(canvas);
}
use of android.view.accessibility.AccessibilityManager in project NewXmPluginSDK by MiEcosystem.
the class NumberPicker method dispatchHoverEvent.
@Override
protected boolean dispatchHoverEvent(MotionEvent event) {
if (!mHasSelectorWheel) {
return super.dispatchHoverEvent(event);
}
AccessibilityManager acm = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (acm.isEnabled()) {
final int eventY = (int) event.getY();
final int hoveredVirtualViewId;
if (eventY < mTopSelectionDividerTop) {
hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_DECREMENT;
} else if (eventY > mBottomSelectionDividerBottom) {
hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INCREMENT;
} else {
hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INPUT;
}
final int action = event.getActionMasked();
AccessibilityNodeProviderImpl provider = (AccessibilityNodeProviderImpl) getAccessibilityNodeProvider();
switch(action) {
case MotionEvent.ACTION_HOVER_ENTER:
{
provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId, AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
provider.performAction(hoveredVirtualViewId, AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
}
break;
case MotionEvent.ACTION_HOVER_MOVE:
{
if (mLastHoveredChildVirtualViewId != hoveredVirtualViewId && mLastHoveredChildVirtualViewId != View.NO_ID) {
provider.sendAccessibilityEventForVirtualView(mLastHoveredChildVirtualViewId, AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId, AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
provider.performAction(hoveredVirtualViewId, AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
}
}
break;
case MotionEvent.ACTION_HOVER_EXIT:
{
provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId, AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
mLastHoveredChildVirtualViewId = View.NO_ID;
}
break;
}
}
return false;
}
Aggregations