Merge "Restored focusableViewAvailable logic on visibility change" into pi-dev

am: 4d0a5fd7e7

Change-Id: I4f4805629698d306fbb8f40e3b62e0f2ca99ad8c
This commit is contained in:
Evan Rosky
2018-03-31 00:34:15 +00:00
committed by android-build-merger

View File

@@ -13917,11 +13917,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
mAttachInfo.mUnbufferedDispatchRequested = true; mAttachInfo.mUnbufferedDispatchRequested = true;
} }
private boolean hasSize() {
return (mBottom > mTop) && (mRight > mLeft);
}
private boolean canTakeFocus() { private boolean canTakeFocus() {
return ((mViewFlags & VISIBILITY_MASK) == VISIBLE) return ((mViewFlags & VISIBILITY_MASK) == VISIBLE)
&& ((mViewFlags & FOCUSABLE) == FOCUSABLE) && ((mViewFlags & FOCUSABLE) == FOCUSABLE)
&& ((mViewFlags & ENABLED_MASK) == ENABLED) && ((mViewFlags & ENABLED_MASK) == ENABLED)
&& (sCanFocusZeroSized || !isLayoutValid() || (mBottom > mTop) && (mRight > mLeft)); && (sCanFocusZeroSized || !isLayoutValid() || hasSize());
} }
/** /**
@@ -13982,7 +13986,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|| focusableChangedByAuto == 0 || focusableChangedByAuto == 0
|| viewRootImpl == null || viewRootImpl == null
|| viewRootImpl.mThread == Thread.currentThread()) { || viewRootImpl.mThread == Thread.currentThread()) {
shouldNotifyFocusableAvailable = true; shouldNotifyFocusableAvailable = canTakeFocus();
} }
} }
} }
@@ -14001,11 +14005,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
needGlobalAttributesUpdate(true); needGlobalAttributesUpdate(true);
// a view becoming visible is worth notifying the parent // a view becoming visible is worth notifying the parent about in case nothing has
// about in case nothing has focus. even if this specific view // focus. Even if this specific view isn't focusable, it may contain something that
// isn't focusable, it may contain something that is, so let // is, so let the root view try to give this focus if nothing else does.
// the root view try to give this focus if nothing else does. shouldNotifyFocusableAvailable = hasSize();
shouldNotifyFocusableAvailable = true;
} }
} }
@@ -14014,16 +14017,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
// a view becoming enabled should notify the parent as long as the view is also // 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 // visible and the parent wasn't already notified by becoming visible during this
// setFlags invocation. // setFlags invocation.
shouldNotifyFocusableAvailable = true; shouldNotifyFocusableAvailable = canTakeFocus();
} else { } else {
if (isFocused()) clearFocus(); if (isFocused()) clearFocus();
} }
} }
if (shouldNotifyFocusableAvailable) { if (shouldNotifyFocusableAvailable && mParent != null) {
if (mParent != null && canTakeFocus()) { mParent.focusableViewAvailable(this);
mParent.focusableViewAvailable(this);
}
} }
/* Check if the GONE bit has changed */ /* Check if the GONE bit has changed */