Example usage for android.view.accessibility AccessibilityEvent getText

List of usage examples for android.view.accessibility AccessibilityEvent getText

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityEvent getText.

Prototype

public List<CharSequence> getText() 

Source Link

Document

Gets the text of the event.

Usage

From source file:android.support.v7.widget.SwitchCompat.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override/*from   w  w w  .j av a2 s.c o m*/
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
    super.onPopulateAccessibilityEvent(event);

    final CharSequence text = isChecked() ? mTextOn : mTextOff;
    if (text != null) {
        event.getText().add(text);
    }
}

From source file:org.mozilla.gecko.GeckoAppShell.java

public static void emitGeckoAccessibilityEvent(int eventType, String role, String text, String description,
        boolean enabled, boolean checked, boolean password) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) GeckoApp.mAppContext
            .getSystemService(Context.ACCESSIBILITY_SERVICE);

    if (!accessibilityManager.isEnabled())
        return;/*from  w  ww  .j a va 2s .  c  o m*/

    LayerController layerController = GeckoApp.mAppContext.getLayerController();
    LayerView layerView = layerController.getView();

    AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setClassName(layerView.getClass().getName() + "$" + role);
    event.setPackageName(GeckoApp.mAppContext.getPackageName());
    event.setEnabled(enabled);
    event.setChecked(checked);
    event.setPassword(password);
    event.setContentDescription(description);
    event.getText().add(text);

    accessibilityManager.sendAccessibilityEvent(event);
}

From source file:cc.flydev.launcher.Folder.java

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);
    }//  w w w .j  av  a 2 s  . c  o  m
}

From source file:com.android.launcher3.Utilities.java

public static void sendCustomAccessibilityEvent(View target, int type, String text) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) target.getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(type);
        target.onInitializeAccessibilityEvent(event);
        event.getText().add(text);
        accessibilityManager.sendAccessibilityEvent(event);
    }/*from www  .  j  a  va2  s .c o  m*/
}

From source file:org.mariotaku.multivalueswitch.library.MultiValueSwitch.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override/*w  w w  .  j av a2s  . c o m*/
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
    super.onPopulateAccessibilityEvent(event);

    final CharSequence text = getEntry(getCheckedPosition());
    if (text != null) {
        event.getText().add(text);
    }
}

From source file:com.llf.android.launcher3.Folder.java

private void sendCustomAccessibilityEvent(int type, String text) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(type);
        // XXX onInitializeAccessibilityEvent(event);
        event.getText().add(text);
        accessibilityManager.sendAccessibilityEvent(event);
    }//  w w w. j a va2  s . co  m
}

From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java

/**
 * ???//from w w w. ja v a 2 s.  c  o  m
 */
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    tag_callback_time = System.currentTimeMillis();
    int eventType = event.getEventType();

    Log.i("Info",
            " eventType: " + eventType + "   getEventTime:  " + event.getEventTime() + "     getAction"
                    + event.getAction() + "getContentChangeTypes:" + event.getContentChangeTypes()
                    + " getText :" + event.getText().toString() + "getPackageName :" + event.getPackageName()
                    + "getRecordCount : " + event.getRecordCount() + "  getClassName:" + event.getClassName()
                    + "  :" + event.getClass() + "   getParcelableData:" + event.getParcelableData());

    switch (eventType) {
    /*??*/
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
        windowContentChanged();
        break;
    //???
    case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
        notificationChanged(event);
        break;
    //Activity???
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        windowChanged(event);
        break;
    }
}

From source file:com.android.incallui.CallCardFragment.java

private void dispatchPopulateAccessibilityEvent(AccessibilityEvent event, View view) {
    if (view == null)
        return;/*from  w w w. j  a  v a  2 s.  c om*/
    final List<CharSequence> eventText = event.getText();
    int size = eventText.size();
    view.dispatchPopulateAccessibilityEvent(event);
    // if no text added write null to keep relative position
    if (size == eventText.size()) {
        eventText.add(null);
    }
}

From source file:com.klinker.deskclock.widget.multiwaveview.GlowPadView.java

private void announceTargets() {
    StringBuilder utterance = new StringBuilder();
    final int targetCount = mTargetDrawables.size();
    for (int i = 0; i < targetCount; i++) {
        String targetDescription = getTargetDescription(i);
        String directionDescription = getDirectionDescription(i);
        if (!TextUtils.isEmpty(targetDescription) && !TextUtils.isEmpty(directionDescription)) {
            String text = String.format(directionDescription, targetDescription);
            utterance.append(text);//from  ww w.ja v  a 2  s .  c o  m
        }
    }
    if (utterance.length() > 0) {
        final AccessibilityManager accessibilityManager = (AccessibilityManager) getContext()
                .getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (accessibilityManager.isEnabled()) {
            if (Build.VERSION.SDK_INT >= 16) {
                announceForAccessibility(utterance.toString());
            } else {
                AccessibilityEvent acc_event = AccessibilityEvent
                        .obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
                AccessibilityRecordCompat arc = new AccessibilityRecordCompat(acc_event);
                arc.setSource(this);
                acc_event.setClassName(this.getClass().getName());
                acc_event.setPackageName(this.getContext().getPackageName());
                acc_event.setEnabled(this.isEnabled());
                acc_event.getText().add(utterance.toString());
                accessibilityManager.sendAccessibilityEvent(acc_event);
            }
        }
    }
}

From source file:com.tr4android.support.extension.picker.time.AppCompatTimePickerDelegate.java

@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
    int flags = DateUtils.FORMAT_SHOW_TIME;
    if (mIs24HourView) {
        flags |= DateUtils.FORMAT_24HOUR;
    } else {/* w w w .  j  a va  2  s.com*/
        flags |= DateUtils.FORMAT_12HOUR;
    }
    mTempCalendar.set(Calendar.HOUR_OF_DAY, getCurrentHour());
    mTempCalendar.set(Calendar.MINUTE, getCurrentMinute());
    String selectedDate = DateUtils.formatDateTime(mContext, mTempCalendar.getTimeInMillis(), flags);
    event.getText().add(selectedDate);
}