summaryrefslogtreecommitdiff
path: root/core/java/android/widget/TextView.java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-05-22 20:15:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-05-22 20:15:34 +0000
commit0ac85feb6f82c69053ac00219482401cbafc5451 (patch)
treee20eb5062df641de0a22ed75fb0e256e759dfa7d /core/java/android/widget/TextView.java
parentfc6a0c45193103ed9b3b0657d342199f21ed4fbe (diff)
parent911cb1fa768614732d08ece70cbeab5158ecec15 (diff)
Merge "DO NOT MERGE - Re-add ContentCapture support from standard SDK toolkit." into qt-r1-dev
Diffstat (limited to 'core/java/android/widget/TextView.java')
-rw-r--r--core/java/android/widget/TextView.java39
1 files changed, 34 insertions, 5 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index a9e183ad5bf2..cdbec293a96d 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -162,6 +162,8 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.AnimationUtils;
import android.view.autofill.AutofillManager;
import android.view.autofill.AutofillValue;
+import android.view.contentcapture.ContentCaptureManager;
+import android.view.contentcapture.ContentCaptureSession;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
@@ -977,6 +979,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (getImportantForAutofill() == IMPORTANT_FOR_AUTOFILL_AUTO) {
setImportantForAutofill(IMPORTANT_FOR_AUTOFILL_YES);
}
+ if (getImportantForContentCapture() == IMPORTANT_FOR_CONTENT_CAPTURE_AUTO) {
+ setImportantForContentCapture(IMPORTANT_FOR_CONTENT_CAPTURE_YES);
+ }
setTextInternal("");
@@ -10550,7 +10555,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
/**
- * Notify managers (such as {@link AutofillManager}) that are interested in text changes.
+ * Notify managers (such as {@link AutofillManager} and {@link ContentCaptureManager}) that are
+ * interested on text changes.
*/
private void notifyListeningManagersAfterTextChanged() {
@@ -10566,6 +10572,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
afm.notifyValueChanged(TextView.this);
}
}
+
+ // TODO(b/121045053): should use a flag / boolean to keep status of SHOWN / HIDDEN instead
+ // of using isLaidout(), so it's not called in cases where it's laid out but a
+ // notifyAppeared was not sent.
+
+ // ContentCapture
+ if (isLaidOut() && isImportantForContentCapture() && isTextEditable()) {
+ final ContentCaptureManager cm = mContext.getSystemService(ContentCaptureManager.class);
+ if (cm != null && cm.isContentCaptureEnabled()) {
+ final ContentCaptureSession session = getContentCaptureSession();
+ if (session != null) {
+ // TODO(b/111276913): pass flags when edited by user / add CTS test
+ session.notifyViewTextChanged(getAutofillId(), getText());
+ }
+ }
+ }
}
private boolean isAutofillable() {
@@ -11409,7 +11431,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final boolean isPassword = hasPasswordTransformationMethod()
|| isPasswordInputType(getInputType());
- if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) {
+ if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL
+ || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) {
if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) {
structure.setDataIsSensitive(!mTextSetFromXmlOrResourceId);
}
@@ -11425,8 +11448,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
- if (!isPassword || viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) {
+ if (!isPassword || viewFor == VIEW_STRUCTURE_FOR_AUTOFILL
+ || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) {
if (mLayout == null) {
+ if (viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) {
+ Log.w(LOG_TAG, "onProvideContentCaptureStructure(): calling assumeLayout()");
+ }
assumeLayout();
}
Layout layout = mLayout;
@@ -11514,7 +11541,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
- if (viewFor == VIEW_STRUCTURE_FOR_ASSIST) {
+ if (viewFor == VIEW_STRUCTURE_FOR_ASSIST
+ || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) {
// Extract style information that applies to the TextView as a whole.
int style = 0;
int typefaceStyle = getTypefaceStyle();
@@ -11542,7 +11570,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
structure.setTextStyle(getTextSize(), getCurrentTextColor(),
AssistStructure.ViewNode.TEXT_COLOR_UNDEFINED /* bgColor */, style);
}
- if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) {
+ if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL
+ || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) {
structure.setMinTextEms(getMinEms());
structure.setMaxTextEms(getMaxEms());
int maxLength = -1;