use of android.view.accessibility.AccessibilityEvent in project platform_frameworks_base by android.
the class View method announceForAccessibility.
/**
* Convenience method for sending a {@link AccessibilityEvent#TYPE_ANNOUNCEMENT}
* {@link AccessibilityEvent} to make an announcement which is related to some
* sort of a context change for which none of the events representing UI transitions
* is a good fit. For example, announcing a new page in a book. If accessibility
* is not enabled this method does nothing.
*
* @param text The announcement text.
*/
public void announceForAccessibility(CharSequence text) {
if (AccessibilityManager.getInstance(mContext).isEnabled() && mParent != null) {
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_ANNOUNCEMENT);
onInitializeAccessibilityEvent(event);
event.getText().add(text);
event.setContentDescription(null);
mParent.requestSendAccessibilityEvent(this, event);
}
}
use of android.view.accessibility.AccessibilityEvent in project robolectric by robolectric.
the class ShadowAccessibilityEventTest method shouldRecordParcelables.
@Test
public void shouldRecordParcelables() {
final Notification notification = new Notification();
event.setParcelableData(notification);
AccessibilityEvent anotherEvent = AccessibilityEvent.obtain(event);
assertThat(anotherEvent.getParcelableData() instanceof Notification).isEqualTo(true);
assertThat(anotherEvent.getParcelableData()).isEqualTo(notification);
anotherEvent.recycle();
}
use of android.view.accessibility.AccessibilityEvent in project Launcher3 by chislon.
the class Folder method sendCustomAccessibilityEvent.
private void sendCustomAccessibilityEvent(int type, String text) {
AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(type);
onInitializeAccessibilityEvent(event);
event.getText().add(text);
accessibilityManager.sendAccessibilityEvent(event);
}
}
use of android.view.accessibility.AccessibilityEvent in project AndroidTraining by mixi-inc.
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 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