summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/View.java25
-rw-r--r--core/java/android/widget/TextView.java13
2 files changed, 23 insertions, 15 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 0657bef2ab69..c513a3a7660c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -104,6 +104,7 @@ import android.view.accessibility.AccessibilityNodeProvider;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Transformation;
+import android.view.autofill.AutoFillManager;
import android.view.autofill.AutoFillType;
import android.view.autofill.AutoFillValue;
import android.view.autofill.VirtualViewDelegate;
@@ -6433,16 +6434,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if (isPressed()) {
setPressed(false);
}
- if (imm != null && mAttachInfo != null
- && mAttachInfo.mHasWindowFocus) {
+ if (imm != null && mAttachInfo != null && mAttachInfo.mHasWindowFocus) {
imm.focusOut(this);
}
onFocusLost();
- } else if (imm != null && mAttachInfo != null
- && mAttachInfo.mHasWindowFocus) {
+ } else if (imm != null && mAttachInfo != null && mAttachInfo.mHasWindowFocus) {
imm.focusIn(this);
}
+ if (isAutoFillable()) {
+ AutoFillManager afm = getAutoFillManager();
+ if (afm != null) {
+ afm.updateAutoFillInput(this, gainFocus
+ ? AutoFillManager.FLAG_UPDATE_UI_SHOW
+ : AutoFillManager.FLAG_UPDATE_UI_HIDE);
+ }
+ }
+
invalidate(true);
ListenerInfo li = mListenerInfo;
if (li != null && li.mOnFocusChangeListener != null) {
@@ -7078,6 +7086,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
return null;
}
+ @Nullable
+ private AutoFillManager getAutoFillManager() {
+ return mContext.getSystemService(AutoFillManager.class);
+ }
+
+ private boolean isAutoFillable() {
+ return getAutoFillType() != null && !isAutoFillBlocked();
+ }
+
private void populateVirtualStructure(ViewStructure structure,
AccessibilityNodeProvider provider, AccessibilityNodeInfo info, int flags) {
// NOTE: currently flags are only used for AutoFill; if they're used for Assist as well,
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index a5fb572ea6ed..51b5b13c10d3 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -9028,14 +9028,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
Spannable sp = (Spannable) mText;
MetaKeyKeyListener.resetMetaState(sp);
}
- } else {
- final AutoFillManager afm = mContext.getSystemService(AutoFillManager.class);
- if (afm != null) {
- if (DEBUG_AUTOFILL) {
- Log.v(LOG_TAG, "onFocusChanged(false): id=" + getAccessibilityViewId());
- }
- afm.updateAutoFillInput(this, AutoFillManager.FLAG_UPDATE_UI_HIDE);
- }
}
startStopMarquee(focused);
@@ -9767,10 +9759,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
@Override
+ @Nullable
public AutoFillType getAutoFillType() {
- // TODO(b/33197203): ideally it should return a constant, but value returned by
- // getInputType() can change.
- return AutoFillType.forText(getInputType());
+ return isTextEditable() ? AutoFillType.forText(getInputType()) : null;
}
/** @hide */