summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Salo <asalo@google.com> 2023-09-08 15:49:05 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-09-08 15:49:05 +0000
commit83845538ce33eb44f0b6951092bca7c7bfe79b10 (patch)
tree06e32224bde7c51aaee82d0b70ec298b35d0c941
parent9b366e72639d8ad82330e2804e4ce7f102f09219 (diff)
parent7bdee55970c1740733b77402d2a0d97c1f35a36f (diff)
Merge "Make disabled EditTexts fillable by Autofill" into udc-qpr-dev am: 7bdee55970
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24604704 Change-Id: I48329eae674e39d8b2c5f23475ae7c8401b4fda0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--core/java/android/widget/TextView.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 2ad3f74fcb7b..63e882533a4c 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -12888,6 +12888,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
/**
+ * @return true if this TextView could be filled by an Autofill service. Note that disabled
+ * fields can still be filled.
+ */
+ @UnsupportedAppUsage
+ boolean isTextAutofillable() {
+ return mText instanceof Editable && onCheckIsTextEditor();
+ }
+
+ /**
* Returns true, only while processing a touch gesture, if the initial
* touch down event caused focus to move to the text view and as a result
* its selection changed. Only valid while processing the touch gesture
@@ -13610,7 +13619,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public void autofill(AutofillValue value) {
- if (!isTextEditable()) {
+ if (!isTextAutofillable()) {
Log.w(LOG_TAG, "cannot autofill non-editable TextView: " + this);
return;
}
@@ -13626,7 +13635,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public @AutofillType int getAutofillType() {
- return isTextEditable() ? AUTOFILL_TYPE_TEXT : AUTOFILL_TYPE_NONE;
+ return isTextAutofillable() ? AUTOFILL_TYPE_TEXT : AUTOFILL_TYPE_NONE;
}
/**
@@ -13640,7 +13649,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
@Nullable
public AutofillValue getAutofillValue() {
- if (isTextEditable()) {
+ if (isTextAutofillable()) {
final CharSequence text = TextUtils.trimToParcelableSize(getText());
return AutofillValue.forText(text);
}