summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Svet Ganov <svetoslavganov@google.com> 2017-05-10 20:06:04 -0700
committer Svet Ganov <svetoslavganov@google.com> 2017-05-10 20:11:45 -0700
commit68f583879ff23f10bb8ce103e91c34a79478c80e (patch)
treef68bb4f6ea708b9a7cced9fddeb13ddfd404b071
parent54a3ce2d0ea0639514ab81a1df233fd12f5eade6 (diff)
Detect isVisibleToUser post layout
Test: MiltipleFragmentsLogin test no longer fails. All auto fill CTS tests pass. bug:38173625 Change-Id: I6e36229bc9517c7339c77cbc5f236e8399ef4283
-rw-r--r--core/java/android/view/View.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 6ee6d637bf79..d16f53c7b371 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2858,6 +2858,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/
static final int PFLAG3_SCROLL_INDICATOR_END = 0x2000;
+ /**
+ * Flag indicating that when layout is completed we should notify
+ * that the view was entered for autofill purposes. To minimize
+ * showing autofill for views not visible to the user we evaluate
+ * user visibility which cannot be done until the view is laid out.
+ */
+ static final int PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT = 0x4000;
+
static final int DRAG_MASK = PFLAG2_DRAG_CAN_ACCEPT | PFLAG2_DRAG_HOVERED;
static final int SCROLL_INDICATORS_NONE = 0x0000;
@@ -6844,8 +6852,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if (isAutofillable() && isAttachedToWindow()) {
AutofillManager afm = getAutofillManager();
if (afm != null) {
- if (enter && hasWindowFocus() && isFocused() && isVisibleToUser()) {
- afm.notifyViewEntered(this);
+ if (enter && hasWindowFocus() && isFocused()) {
+ // We have not been laid out yet, hence cannot evaluate
+ // whether this view is visible to the user, we will do
+ // the evaluation once layout is complete.
+ if (!isLaidOut()) {
+ mPrivateFlags3 |= PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT;
+ } else if (isVisibleToUser()) {
+ afm.notifyViewEntered(this);
+ }
} else if (!hasWindowFocus() || !isFocused()) {
afm.notifyViewExited(this);
}
@@ -19304,6 +19319,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
mPrivateFlags &= ~PFLAG_FORCE_LAYOUT;
mPrivateFlags3 |= PFLAG3_IS_LAID_OUT;
+
+ if ((mPrivateFlags3 & PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT) != 0) {
+ mPrivateFlags3 &= ~PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT;
+ notifyEnterOrExitForAutoFillIfNeeded(true);
+ }
}
/**