Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98c8b52b authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "TextView should report in an AccessibilityNodeInfo's text its hint if...

Merge "TextView should report in an AccessibilityNodeInfo's text its hint if the View text is empty."
parents 4c949365 ab5a4057
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -8939,14 +8939,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

        final boolean isPassword = hasPasswordTransformationMethod();
        if (!isPassword) {
            CharSequence text = getText();
            if (TextUtils.isEmpty(text)) {
                text = getHint();
            }
            CharSequence text = getTextForAccessibility();
            if (TextUtils.isEmpty(text)) {
                text = getContentDescription();
            }
            if (!TextUtils.isEmpty(text)) {
                event.getText().add(text);
            }
        }
@@ -8972,7 +8966,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

        final boolean isPassword = hasPasswordTransformationMethod();
        if (!isPassword) {
            info.setText(getText());
            info.setText(getTextForAccessibility());
        }
        info.setPassword(isPassword);
    }
@@ -8988,6 +8982,20 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        super.sendAccessibilityEvent(eventType);
    }

    /**
     * Gets the text reported for accessibility purposes. It is the
     * text if not empty or the hint.
     *
     * @return The accessibility text.
     */
    private CharSequence getTextForAccessibility() {
        CharSequence text = getText();
        if (TextUtils.isEmpty(text)) {
            text = getHint();
        }
        return text;
    }

    void sendAccessibilityEventTypeViewTextChanged(CharSequence beforeText,
            int fromIndex, int removedCount, int addedCount) {
        AccessibilityEvent event =