Java Code Examples for android.view.accessibility.AccessibilityNodeInfo#setText()

The following examples show how to use android.view.accessibility.AccessibilityNodeInfo#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccentSwitch.java    From holoaccent with Apache License 2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
	super.onInitializeAccessibilityNodeInfo(info);
	info.setClassName(AccentSwitch.class.getName());
	CharSequence switchText = isChecked() ? mTextOn : mTextOff;
	if (!TextUtils.isEmpty(switchText)) {
		CharSequence oldText = info.getText();
		if (TextUtils.isEmpty(oldText)) {
			info.setText(switchText);
		} else {
			StringBuilder newText = new StringBuilder();
			newText.append(oldText).append(' ').append(switchText);
			info.setText(newText);
		}
	}
}
 
Example 2
Source File: StickerCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info){
    super.onInitializeAccessibilityNodeInfo(info);
    if (sticker == null)
        return;
    String emoji = null;
    for (int a = 0; a < sticker.attributes.size(); a++) {
        TLRPC.DocumentAttribute attribute = sticker.attributes.get(a);
        if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
            emoji = attribute.alt != null && attribute.alt.length() > 0 ? attribute.alt : null;
        }
    }
    if (emoji != null)
        info.setText(emoji + " " + LocaleController.getString("AttachSticker", R.string.AttachSticker));
    else
        info.setText(LocaleController.getString("AttachSticker", R.string.AttachSticker));
    info.setEnabled(true);
}
 
Example 3
Source File: AbstractCustomVirtualView.java    From android-AutofillFramework with Apache License 2.0 6 votes vote down vote up
protected AccessibilityNodeInfo provideAccessibilityNodeInfo(View parent, Context context) {
    final AccessibilityNodeInfo node = AccessibilityNodeInfo.obtain();
    node.setSource(parent, id);
    node.setPackageName(context.getPackageName());
    node.setClassName(getClassName());
    node.setEditable(editable);
    node.setViewIdResourceName(idEntry);
    node.setVisibleToUser(true);
    final Rect absBounds = line.getAbsCoordinates();
    if (absBounds != null) {
        node.setBoundsInScreen(absBounds);
    }
    if (TextUtils.getTrimmedLength(text) > 0) {
        // TODO: Must checked trimmed length because input fields use 8 empty spaces to
        // set width
        node.setText(text);
    }
    return node;
}
 
Example 4
Source File: PhotoAttachPhotoCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setEnabled(true);
    if (photoEntry != null && photoEntry.isVideo) {
        info.setText(LocaleController.getString("AttachVideo", R.string.AttachVideo) + ", " + LocaleController.formatCallDuration(photoEntry.duration));
    } else {
        info.setText(LocaleController.getString("AttachPhoto", R.string.AttachPhoto));
    }
    if (checkBox.isChecked()) {
        info.setSelected(true);
    }
    if (Build.VERSION.SDK_INT >= 21) {
        info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.acc_action_open_photo, LocaleController.getString("Open", R.string.Open)));
    }
}
 
Example 5
Source File: PhotoAttachPhotoCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setEnabled(true);
    if (photoEntry != null && photoEntry.isVideo) {
        info.setText(LocaleController.getString("AttachVideo", R.string.AttachVideo) + ", " + LocaleController.formatCallDuration(photoEntry.duration));
    } else {
        info.setText(LocaleController.getString("AttachPhoto", R.string.AttachPhoto));
    }
    if (checkBox.isChecked()) {
        info.setSelected(true);
    }
    if (Build.VERSION.SDK_INT >= 21) {
        info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.acc_action_open_photo, LocaleController.getString("Open", R.string.Open)));
    }
}
 
Example 6
Source File: SimpleTextView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setVisibleToUser(true);
    info.setClassName("android.widget.TextView");
    info.setText(text);
}
 
Example 7
Source File: ChatActionCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    if (TextUtils.isEmpty(customText) && currentMessageObject == null) {
        return;
    }
    info.setText(!TextUtils.isEmpty(customText) ? customText : currentMessageObject.messageText);
    info.setEnabled(true);
}
 
Example 8
Source File: SharedPhotoVideoCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    if (currentMessageObject.isVideo()) {
        info.setText(LocaleController.getString("AttachVideo", R.string.AttachVideo) + ", " + LocaleController.formatCallDuration(currentMessageObject.getDuration()));
    } else {
        info.setText(LocaleController.getString("AttachPhoto", R.string.AttachPhoto));
    }
    if (checkBox.isChecked()) {
        info.setCheckable(true);
        info.setChecked(true);
    }
}
 
Example 9
Source File: GroupCreateSpan.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setText(nameLayout.getText());
    if (isDeleting() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK.getId(), LocaleController.getString("Delete", R.string.Delete)));
}
 
Example 10
Source File: TextPicker.java    From GifAssistant with Apache License 2.0 5 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForVirtualButton(int virtualViewId,
                                                                          String text, int left, int top, int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(Button.class.getName());
    info.setPackageName(getContext().getPackageName());
    info.setSource(TextPicker.this, virtualViewId);
    info.setParent(TextPicker.this);
    info.setText(text);
    info.setClickable(true);
    info.setLongClickable(true);
    info.setEnabled(TextPicker.this.isEnabled());
    Rect boundsInParent = mTempRect;
    boundsInParent.set(left, top, right, bottom);
    // TODO info.setVisibleToUser(isVisibleToUser(boundsInParent));
    info.setBoundsInParent(boundsInParent);
    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    info.setBoundsInScreen(boundsInScreen);

    if (mAccessibilityFocusedView != virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (TextPicker.this.isEnabled()) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
    }

    return info;
}
 
Example 11
Source File: SimpleTextView.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setVisibleToUser(true);
    info.setClassName("android.widget.TextView");
    info.setText(text);
}
 
Example 12
Source File: AudioPlayerCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    if (currentMessageObject.isMusic()) {
        info.setText(LocaleController.formatString("AccDescrMusicInfo", R.string.AccDescrMusicInfo, currentMessageObject.getMusicAuthor(), currentMessageObject.getMusicTitle()));
    } else { // voice message
        info.setText(titleLayout.getText() + ", " + descriptionLayout.getText());
    }
}
 
Example 13
Source File: NumberPicker.java    From zen4android with MIT License 5 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForVirtualButton(int virtualViewId,
        String text, int left, int top, int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(Button.class.getName());
    info.setPackageName(getContext().getPackageName());
    info.setSource(NumberPicker.this, virtualViewId);
    info.setParent(NumberPicker.this);
    info.setText(text);
    info.setClickable(true);
    info.setLongClickable(true);
    info.setEnabled(NumberPicker.this.isEnabled());
    Rect boundsInParent = mTempRect;
    boundsInParent.set(left, top, right, bottom);
    // TODO info.setVisibleToUser(isVisibleToUser(boundsInParent));
    info.setBoundsInParent(boundsInParent);
    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    info.setBoundsInScreen(boundsInScreen);

    if (mAccessibilityFocusedView != virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (NumberPicker.this.isEnabled()) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
    }

    return info;
}
 
Example 14
Source File: UrlBar.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);

    if (mAccessibilityTextOverride != null) {
        info.setText(mAccessibilityTextOverride);
    }
}
 
Example 15
Source File: SimpleMonthView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPopulateNodeForVirtualView(int virtualViewId, AccessibilityNodeInfo node) {
    final boolean hasBounds = getBoundsForDay(virtualViewId, mTempRect);

    if (!hasBounds) {
        // The day is invalid, kill the node.
        mTempRect.setEmpty();
        node.setContentDescription("");
        node.setBoundsInParent(mTempRect);
        node.setVisibleToUser(false);
        return;
    }

    node.setText(getDayText(virtualViewId));
    node.setContentDescription(getDayDescription(virtualViewId));
    node.setBoundsInParent(mTempRect);

    final boolean isDayEnabled = isDayEnabled(virtualViewId);
    if (isDayEnabled) {
        node.addAction(AccessibilityAction.ACTION_CLICK);
    }

    node.setEnabled(isDayEnabled);

    if (virtualViewId == mActivatedDay) {
        // TODO: This should use activated once that's supported.
        node.setChecked(true);
    }

}
 
Example 16
Source File: SharedAudioCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    if (currentMessageObject.isMusic()) {
        info.setText(LocaleController.formatString("AccDescrMusicInfo", R.string.AccDescrMusicInfo, currentMessageObject.getMusicAuthor(), currentMessageObject.getMusicTitle()));
    } else if (titleLayout != null && descriptionLayout != null) {
        info.setText(titleLayout.getText() + ", " + descriptionLayout.getText());
    }
    if (checkBox.isChecked()) {
        info.setCheckable(true);
        info.setChecked(true);
    }
}
 
Example 17
Source File: ProfileSearchCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    StringBuilder builder = new StringBuilder();
    if (nameLayout != null) {
        builder.append(nameLayout.getText());
    }
    if (statusLayout != null) {
        if (builder.length() > 0) {
            builder.append(", ");
        }
        builder.append(statusLayout.getText());
    }
    info.setText(builder.toString());
}
 
Example 18
Source File: Label.java    From Carbon with Apache License 2.0 4 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setClassName(Label.class.getName());
    info.setText(text);
}
 
Example 19
Source File: BotHelpCell.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setText(textLayout.getText());
}
 
Example 20
Source File: BotHelpCell.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setText(textLayout.getText());
}