use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by AOSPA.
the class View method sendViewTextTraversedAtGranularityEvent.
private void sendViewTextTraversedAtGranularityEvent(int action, int granularity, int fromIndex, int toIndex) {
if (mParent == null) {
return;
}
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY);
onInitializeAccessibilityEvent(event);
onPopulateAccessibilityEvent(event);
event.setFromIndex(fromIndex);
event.setToIndex(toIndex);
event.setAction(action);
event.setMovementGranularity(granularity);
mParent.requestSendAccessibilityEvent(this, event);
}
use of android.view.accessibility.AccessibilityEvent in project android_packages_apps_Dialer by LineageOS.
the class CallCardPresenter method sendAccessibilityEvent.
static boolean sendAccessibilityEvent(Context context, InCallScreen inCallScreen) {
AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (!am.isEnabled()) {
LogUtil.w("CallCardPresenter.sendAccessibilityEvent", "accessibility is off");
return false;
}
if (inCallScreen == null) {
LogUtil.w("CallCardPresenter.sendAccessibilityEvent", "incallscreen is null");
return false;
}
Fragment fragment = inCallScreen.getInCallScreenFragment();
if (fragment == null || fragment.getView() == null || fragment.getView().getParent() == null) {
LogUtil.w("CallCardPresenter.sendAccessibilityEvent", "fragment/view/parent is null");
return false;
}
DisplayManager displayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
boolean screenIsOn = display.getState() == Display.STATE_ON;
LogUtil.d("CallCardPresenter.sendAccessibilityEvent", "screen is on: %b", screenIsOn);
if (!screenIsOn) {
return false;
}
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_ANNOUNCEMENT);
inCallScreen.dispatchPopulateAccessibilityEvent(event);
View view = inCallScreen.getInCallScreenFragment().getView();
view.getParent().requestSendAccessibilityEvent(view, event);
return true;
}
use of android.view.accessibility.AccessibilityEvent in project MDM-Android-Agent by wso2-attic.
the class IcsAdapterView method onRequestSendAccessibilityEvent.
@Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
if (super.onRequestSendAccessibilityEvent(child, event)) {
// Add a record for ourselves as well.
AccessibilityEvent record = AccessibilityEvent.obtain();
onInitializeAccessibilityEvent(record);
// Populate with the text of the requesting child.
child.dispatchPopulateAccessibilityEvent(record);
event.appendRecord(record);
return true;
}
return false;
}
use of android.view.accessibility.AccessibilityEvent in project android_packages_apps_Snap by LineageOS.
the class AccessibilityUtils method makeAnnouncement.
public static void makeAnnouncement(View view, CharSequence announcement) {
if (view == null)
return;
if (ApiHelper.HAS_ANNOUNCE_FOR_ACCESSIBILITY) {
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 = new AccessibilityRecordCompat(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.AccessibilityEvent in project Fairphone by Kwamecorp.
the class DragLayer method sendTapOutsideFolderAccessibilityEvent.
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);
}
}
Aggregations