Example usage for android.support.v4.view.accessibility AccessibilityNodeInfoCompat isPassword

List of usage examples for android.support.v4.view.accessibility AccessibilityNodeInfoCompat isPassword

Introduction

In this page you can find the example usage for android.support.v4.view.accessibility AccessibilityNodeInfoCompat isPassword.

Prototype

public boolean isPassword() 

Source Link

Document

Gets whether this node is a password.

Usage

From source file:com.google.android.marvin.mytalkback.speechrules.RuleEditText.java

/**
 * Inverts the default priorities of text and content description. If the
 * field is a password, only returns the content description or "password".
 *
 * @param context//from  www.  j  av  a  2s  .c o m
 * @param node
 * @return A text description of the editable text area.
 */
private CharSequence getText(Context context, AccessibilityNodeInfoCompat node) {
    final CharSequence text = node.getText();
    final boolean shouldSpeakPasswords = SecureCompatUtils.shouldSpeakPasswords(context);

    if (!TextUtils.isEmpty(text) && (!node.isPassword() || shouldSpeakPasswords)) {
        return text;
    }

    final CharSequence contentDescription = node.getContentDescription();

    if (!TextUtils.isEmpty(contentDescription)) {
        return contentDescription;
    }

    if (node.isPassword() && !shouldSpeakPasswords) {
        return context.getString(R.string.value_password);
    }

    return "";
}

From source file:com.android.screenspeak.speechrules.RuleEditText.java

/**
 * Inverts the default priorities of text and content description. If the
 * field is a password, only returns the content description or "password".
 *
 * @param context current context/*from   w  w w . ja  va  2s. c o  m*/
 * @param node to get text from
 * @return A text description of the editable text area.
 */
private CharSequence getText(Context context, AccessibilityNodeInfoCompat node) {
    final CharSequence text = node.getText();
    final boolean shouldSpeakPasswords = SettingsCompatUtils.SecureCompatUtils.shouldSpeakPasswords(context);

    if (!TextUtils.isEmpty(text) && (!node.isPassword() || shouldSpeakPasswords)) {
        return text;
    }

    final CharSequence contentDescription = node.getContentDescription();

    if (!TextUtils.isEmpty(contentDescription)) {
        return contentDescription;
    }

    if (node.isPassword() && !shouldSpeakPasswords) {
        return context.getString(R.string.value_password);
    }

    return "";
}

From source file:com.android.talkback.speechrules.RuleEditText.java

/**
 * Inverts the default priorities of text and content description.
 * If the field is a password, returns the content description or "password",
 * as well as the length of the password if it's not empty.
 *
 * @param context current context//ww w  . j a va 2 s . com
 * @param node    to get text from
 * @return A text description of the editable text area.
 */
private CharSequence getText(Context context, AccessibilityNodeInfoCompat node) {
    final CharSequence text = node.getText();
    final boolean shouldSpeakPasswords = SettingsCompatUtils.SecureCompatUtils.shouldSpeakPasswords(context);

    if (!TextUtils.isEmpty(text) && (!node.isPassword() || shouldSpeakPasswords)) {
        // Text is potentially user input, so we need to make sure we pronounce input that has
        // only symbols.
        return SpeechCleanupUtils.collapseRepeatedCharactersAndCleanUp(context, text);
    }

    SpannableStringBuilder output = new SpannableStringBuilder();

    final CharSequence contentDescription = node.getContentDescription();

    if (!TextUtils.isEmpty(contentDescription)) {
        // Less likely, but contentDescription is potentially user input, so we need to make
        // sure we pronounce input that has only symbols.
        StringBuilderUtils.append(output,
                SpeechCleanupUtils.collapseRepeatedCharactersAndCleanUp(context, contentDescription));
    } else if (node.isPassword() && !shouldSpeakPasswords) {
        StringBuilderUtils.append(output, context.getString(R.string.value_password));
    }

    if (node.isPassword() && !shouldSpeakPasswords && !TextUtils.isEmpty(text)) {
        // Note: never cleanup password speech because that will mess up the text length.
        StringBuilderUtils.append(output, context.getResources()
                .getQuantityString(R.plurals.template_password_character_count, text.length(), text.length()));
    }

    return output;
}