Merge "Move autofill-specific logic from EditText to TextView."
This commit is contained in:
committed by
Android (Google) Code Review
commit
904aca762c
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user