am fae01126: am c2cc6fff: Merge "Keep IMM#mCurRootView synchronized with the actual window focus." into mnc-dev
* commit 'fae01126800386a892da70c9b2763843bccff18d': Keep IMM#mCurRootView synchronized with the actual window focus.
This commit is contained in:
@@ -2021,8 +2021,8 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
mLastWasImTarget = imTarget;
|
mLastWasImTarget = imTarget;
|
||||||
InputMethodManager imm = InputMethodManager.peekInstance();
|
InputMethodManager imm = InputMethodManager.peekInstance();
|
||||||
if (imm != null && imTarget) {
|
if (imm != null && imTarget) {
|
||||||
imm.startGettingWindowFocus(mView);
|
imm.onPreWindowFocus(mView, true /* hasWindowFocus */);
|
||||||
imm.onWindowFocus(mView, mView.findFocus(),
|
imm.onPostWindowFocus(mView, mView.findFocus(),
|
||||||
mWindowAttributes.softInputMode,
|
mWindowAttributes.softInputMode,
|
||||||
!mHasHadWindowFocus, mWindowAttributes.flags);
|
!mHasHadWindowFocus, mWindowAttributes.flags);
|
||||||
}
|
}
|
||||||
@@ -3327,11 +3327,10 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
.mayUseInputMethod(mWindowAttributes.flags);
|
.mayUseInputMethod(mWindowAttributes.flags);
|
||||||
|
|
||||||
InputMethodManager imm = InputMethodManager.peekInstance();
|
InputMethodManager imm = InputMethodManager.peekInstance();
|
||||||
|
if (imm != null && mLastWasImTarget && !isInLocalFocusMode()) {
|
||||||
|
imm.onPreWindowFocus(mView, hasWindowFocus);
|
||||||
|
}
|
||||||
if (mView != null) {
|
if (mView != null) {
|
||||||
if (hasWindowFocus && imm != null && mLastWasImTarget &&
|
|
||||||
!isInLocalFocusMode()) {
|
|
||||||
imm.startGettingWindowFocus(mView);
|
|
||||||
}
|
|
||||||
mAttachInfo.mKeyDispatchState.reset();
|
mAttachInfo.mKeyDispatchState.reset();
|
||||||
mView.dispatchWindowFocusChanged(hasWindowFocus);
|
mView.dispatchWindowFocusChanged(hasWindowFocus);
|
||||||
mAttachInfo.mTreeObserver.dispatchOnWindowFocusChange(hasWindowFocus);
|
mAttachInfo.mTreeObserver.dispatchOnWindowFocusChange(hasWindowFocus);
|
||||||
@@ -3341,7 +3340,7 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
// so all of the view state is set up correctly.
|
// so all of the view state is set up correctly.
|
||||||
if (hasWindowFocus) {
|
if (hasWindowFocus) {
|
||||||
if (imm != null && mLastWasImTarget && !isInLocalFocusMode()) {
|
if (imm != null && mLastWasImTarget && !isInLocalFocusMode()) {
|
||||||
imm.onWindowFocus(mView, mView.findFocus(),
|
imm.onPostWindowFocus(mView, mView.findFocus(),
|
||||||
mWindowAttributes.softInputMode,
|
mWindowAttributes.softInputMode,
|
||||||
!mHasHadWindowFocus, mWindowAttributes.flags);
|
!mHasHadWindowFocus, mWindowAttributes.flags);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1289,14 +1289,14 @@ public final class InputMethodManager {
|
|||||||
|
|
||||||
void focusInLocked(View view) {
|
void focusInLocked(View view) {
|
||||||
if (DEBUG) Log.v(TAG, "focusIn: " + view);
|
if (DEBUG) Log.v(TAG, "focusIn: " + view);
|
||||||
|
|
||||||
if (mCurRootView != view.getRootView()) {
|
if (mCurRootView != view.getRootView()) {
|
||||||
// This is a request from a window that isn't in the window with
|
// This is a request from a window that isn't in the window with
|
||||||
// IME focus, so ignore it.
|
// IME focus, so ignore it.
|
||||||
if (DEBUG) Log.v(TAG, "Not IME target window, ignoring");
|
if (DEBUG) Log.v(TAG, "Not IME target window, ignoring");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mNextServedView = view;
|
mNextServedView = view;
|
||||||
scheduleCheckFocusLocked(view);
|
scheduleCheckFocusLocked(view);
|
||||||
}
|
}
|
||||||
@@ -1392,7 +1392,7 @@ public final class InputMethodManager {
|
|||||||
* Called by ViewAncestor when its window gets input focus.
|
* Called by ViewAncestor when its window gets input focus.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void onWindowFocus(View rootView, View focusedView, int softInputMode,
|
public void onPostWindowFocus(View rootView, View focusedView, int softInputMode,
|
||||||
boolean first, int windowFlags) {
|
boolean first, int windowFlags) {
|
||||||
boolean forceNewFocus = false;
|
boolean forceNewFocus = false;
|
||||||
synchronized (mH) {
|
synchronized (mH) {
|
||||||
@@ -1441,14 +1441,27 @@ public final class InputMethodManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void startGettingWindowFocus(View rootView) {
|
public void onPreWindowFocus(View rootView, boolean hasWindowFocus) {
|
||||||
synchronized (mH) {
|
synchronized (mH) {
|
||||||
mCurRootView = rootView;
|
if (rootView == null) {
|
||||||
|
mCurRootView = null;
|
||||||
|
} if (hasWindowFocus) {
|
||||||
|
mCurRootView = rootView;
|
||||||
|
} else if (rootView == mCurRootView) {
|
||||||
|
// If the mCurRootView is losing window focus, release the strong reference to it
|
||||||
|
// so as not to prevent it from being garbage-collected.
|
||||||
|
mCurRootView = null;
|
||||||
|
} else {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.v(TAG, "Ignoring onPreWindowFocus()."
|
||||||
|
+ " mCurRootView=" + mCurRootView + " rootView=" + rootView);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report the current selection range.
|
* Report the current selection range.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -154,9 +154,9 @@ public class FindActionModeCallback implements ActionMode.Callback, TextWatcher,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showSoftInput() {
|
public void showSoftInput() {
|
||||||
mInput.startGettingWindowFocus(mEditText.getRootView());
|
if (mEditText.requestFocus()) {
|
||||||
mInput.focusIn(mEditText);
|
mInput.showSoftInput(mEditText, 0);
|
||||||
mInput.showSoftInput(mEditText, 0);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMatchCount(int matchIndex, int matchCount, boolean isEmptyFind) {
|
public void updateMatchCount(int matchIndex, int matchCount, boolean isEmptyFind) {
|
||||||
|
|||||||
Reference in New Issue
Block a user