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

Commit 904aca76 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move autofill-specific logic from EditText to TextView."

parents c68b3419 31e89394
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
@@ -24,10 +24,7 @@ import android.text.TextUtils;
import android.text.method.ArrowKeyMovementMethod;
import android.text.method.MovementMethod;
import android.util.AttributeSet;
import android.util.Log;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.autofill.AutoFillType;
import android.view.autofill.AutoFillValue;

/*
 * This is supposed to be a *very* thin veneer over TextView.
@@ -158,24 +155,4 @@ public class EditText extends TextView {
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_TEXT);
        }
    }

    // TODO(b/33197203): add unit/CTS tests for auto-fill methods

    @Override
    public void autoFill(AutoFillValue value) {
        final CharSequence text = value.getTextValue();

        if (text == null) {
            Log.w(VIEW_LOG_TAG, "EditText.autoFill(): no text on AutoFillValue");
            return;
        }
        setText(text);
    }

    @Override
    public AutoFillType getAutoFillType() {
        // TODO(b/33197203): ideally it should return a constant, but value returned by
        // getInputType() can change.
        return AutoFillType.forText(getInputType());
    }
}
+20 −0
Original line number Diff line number Diff line
@@ -137,6 +137,8 @@ import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.AnimationUtils;
import android.view.autofill.AutoFillManager;
import android.view.autofill.AutoFillType;
import android.view.autofill.AutoFillValue;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
@@ -9753,6 +9755,24 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        structure.setHint(getHint());
    }

    // TODO(b/33197203): add unit/CTS tests for auto-fill methods

    @Override
    public void autoFill(AutoFillValue value) {
        final CharSequence text = value.getTextValue();

        if (text != null && isTextEditable()) {
            setText(text);
        }
    }

    @Override
    public AutoFillType getAutoFillType() {
        // TODO(b/33197203): ideally it should return a constant, but value returned by
        // getInputType() can change.
        return AutoFillType.forText(getInputType());
    }

    /** @hide */
    @Override
    public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) {