Merge "Prevent refocus after entering touch mode" into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
70e907f51f
@@ -4572,10 +4572,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
System.out.println(this + " clearFocus()");
|
System.out.println(this + " clearFocus()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearFocusInternal(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears focus from the view, optionally propagating the change up through
|
||||||
|
* the parent hierarchy and requesting that the root view place new focus.
|
||||||
|
*
|
||||||
|
* @param propagate whether to propagate the change up through the parent
|
||||||
|
* hierarchy
|
||||||
|
* @param refocus when propagate is true, specifies whether to request the
|
||||||
|
* root view place new focus
|
||||||
|
*/
|
||||||
|
void clearFocusInternal(boolean propagate, boolean refocus) {
|
||||||
if ((mPrivateFlags & PFLAG_FOCUSED) != 0) {
|
if ((mPrivateFlags & PFLAG_FOCUSED) != 0) {
|
||||||
mPrivateFlags &= ~PFLAG_FOCUSED;
|
mPrivateFlags &= ~PFLAG_FOCUSED;
|
||||||
|
|
||||||
if (mParent != null) {
|
if (propagate && mParent != null) {
|
||||||
mParent.clearChildFocus(this);
|
mParent.clearChildFocus(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4583,7 +4596,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
|
|
||||||
refreshDrawableState();
|
refreshDrawableState();
|
||||||
|
|
||||||
if (!rootViewRequestFocus()) {
|
if (propagate && (!refocus || !rootViewRequestFocus())) {
|
||||||
notifyGlobalFocusCleared(this);
|
notifyGlobalFocusCleared(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4613,12 +4626,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
System.out.println(this + " unFocus()");
|
System.out.println(this + " unFocus()");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mPrivateFlags & PFLAG_FOCUSED) != 0) {
|
clearFocusInternal(false, false);
|
||||||
mPrivateFlags &= ~PFLAG_FOCUSED;
|
|
||||||
|
|
||||||
onFocusChanged(false, 0, null);
|
|
||||||
refreshDrawableState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3271,9 +3271,9 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
// focus
|
// focus
|
||||||
return ancestorToTakeFocus.requestFocus();
|
return ancestorToTakeFocus.requestFocus();
|
||||||
} else {
|
} else {
|
||||||
// nothing appropriate to have focus in touch mode, clear it
|
// There's nothing to focus. Clear and propagate through the
|
||||||
// out
|
// hierarchy, but don't attempt to place new focus.
|
||||||
focused.clearFocus();
|
focused.clearFocusInternal(true, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user