summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2010-04-06 17:43:48 -0700
committer Romain Guy <romainguy@google.com> 2010-04-07 10:15:18 -0700
commit7b70f6589205dec10afdb358b7ddef7aa61b7dd8 (patch)
tree66e798a5e40d5efa7e4baa85018a10fa4d57da3c
parent083c715d06a99951429b38c62484f8c3caf43cd1 (diff)
Search for focusable views only after layout has happened when the window is first created.
Bug #2565564 Change-Id: I9eb58bbcba873ac1d6dc0b60b0de99e0e9979398
-rw-r--r--core/java/android/view/ViewRoot.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index bf94707d7839..e56a6fe141f3 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -766,7 +766,7 @@ public final class ViewRoot extends Handler implements ViewParent,
// make sure touch mode code executes by setting cached value
// to opposite of the added touch mode.
mAttachInfo.mInTouchMode = !mAddedTouchMode;
- ensureTouchModeLocally(mAddedTouchMode);
+ ensureTouchModeLocally(mAddedTouchMode, false);
} else {
if (!mAttachInfo.mContentInsets.equals(mPendingContentInsets)) {
mAttachInfo.mContentInsets.set(mPendingContentInsets);
@@ -983,7 +983,7 @@ public final class ViewRoot extends Handler implements ViewParent,
}
boolean focusChangedDueToTouchMode = ensureTouchModeLocally(
- (relayoutResult&WindowManagerImpl.RELAYOUT_IN_TOUCH_MODE) != 0);
+ (relayoutResult&WindowManagerImpl.RELAYOUT_IN_TOUCH_MODE) != 0, true);
if (focusChangedDueToTouchMode || mWidth != host.mMeasuredWidth
|| mHeight != host.mMeasuredHeight || contentInsetsChanged) {
childWidthMeasureSpec = getRootMeasureSpec(mWidth, lp.width);
@@ -1043,6 +1043,13 @@ public final class ViewRoot extends Handler implements ViewParent,
startTime = SystemClock.elapsedRealtime();
}
host.layout(0, 0, host.mMeasuredWidth, host.mMeasuredHeight);
+ if (mFirst) {
+ if (mAddedTouchMode) {
+ enterTouchMode();
+ } else {
+ leaveTouchMode();
+ }
+ }
if (Config.DEBUG && ViewDebug.consistencyCheckEnabled) {
if (!host.dispatchConsistencyCheck(ViewDebug.CONSISTENCY_LAYOUT)) {
@@ -1892,7 +1899,7 @@ public final class ViewRoot extends Handler implements ViewParent,
mAttachInfo.mHasWindowFocus = hasWindowFocus;
if (hasWindowFocus) {
boolean inTouchMode = msg.arg2 != 0;
- ensureTouchModeLocally(inTouchMode);
+ ensureTouchModeLocally(inTouchMode, true);
if (mGlWanted) {
checkEglErrors();
@@ -2002,16 +2009,17 @@ public final class ViewRoot extends Handler implements ViewParent,
}
// handle the change
- return ensureTouchModeLocally(inTouchMode);
+ return ensureTouchModeLocally(inTouchMode, true);
}
/**
* Ensure that the touch mode for this window is set, and if it is changing,
* take the appropriate action.
* @param inTouchMode Whether we want to be in touch mode.
+ * @param dispatchFocus
* @return True if the touch mode changed and focus changed was changed as a result
*/
- private boolean ensureTouchModeLocally(boolean inTouchMode) {
+ private boolean ensureTouchModeLocally(boolean inTouchMode, boolean dispatchFocus) {
if (DBG) Log.d("touchmode", "ensureTouchModeLocally(" + inTouchMode + "), current "
+ "touch mode is " + mAttachInfo.mInTouchMode);
@@ -2020,7 +2028,7 @@ public final class ViewRoot extends Handler implements ViewParent,
mAttachInfo.mInTouchMode = inTouchMode;
mAttachInfo.mTreeObserver.dispatchOnTouchModeChanged(inTouchMode);
- return (inTouchMode) ? enterTouchMode() : leaveTouchMode();
+ return dispatchFocus && (inTouchMode) ? enterTouchMode() : leaveTouchMode();
}
private boolean enterTouchMode() {