Merge "Restored focusableViewAvailable logic on visibility change" into pi-dev
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index f6c669b..ea3710c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -13917,11 +13917,15 @@
mAttachInfo.mUnbufferedDispatchRequested = true;
}
+ private boolean hasSize() {
+ return (mBottom > mTop) && (mRight > mLeft);
+ }
+
private boolean canTakeFocus() {
return ((mViewFlags & VISIBILITY_MASK) == VISIBLE)
&& ((mViewFlags & FOCUSABLE) == FOCUSABLE)
&& ((mViewFlags & ENABLED_MASK) == ENABLED)
- && (sCanFocusZeroSized || !isLayoutValid() || (mBottom > mTop) && (mRight > mLeft));
+ && (sCanFocusZeroSized || !isLayoutValid() || hasSize());
}
/**
@@ -13982,7 +13986,7 @@
|| focusableChangedByAuto == 0
|| viewRootImpl == null
|| viewRootImpl.mThread == Thread.currentThread()) {
- shouldNotifyFocusableAvailable = true;
+ shouldNotifyFocusableAvailable = canTakeFocus();
}
}
}
@@ -14001,11 +14005,10 @@
needGlobalAttributesUpdate(true);
- // a view becoming visible is worth notifying the parent
- // about in case nothing has focus. even if this specific view
- // isn't focusable, it may contain something that is, so let
- // the root view try to give this focus if nothing else does.
- shouldNotifyFocusableAvailable = true;
+ // a view becoming visible is worth notifying the parent about in case nothing has
+ // focus. Even if this specific view isn't focusable, it may contain something that
+ // is, so let the root view try to give this focus if nothing else does.
+ shouldNotifyFocusableAvailable = hasSize();
}
}
@@ -14014,16 +14017,14 @@
// a view becoming enabled should notify the parent as long as the view is also
// visible and the parent wasn't already notified by becoming visible during this
// setFlags invocation.
- shouldNotifyFocusableAvailable = true;
+ shouldNotifyFocusableAvailable = canTakeFocus();
} else {
if (isFocused()) clearFocus();
}
}
- if (shouldNotifyFocusableAvailable) {
- if (mParent != null && canTakeFocus()) {
- mParent.focusableViewAvailable(this);
- }
+ if (shouldNotifyFocusableAvailable && mParent != null) {
+ mParent.focusableViewAvailable(this);
}
/* Check if the GONE bit has changed */