diff options
author | sgurun@chromium.org <sgurun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-14 19:21:44 +0000 |
---|---|---|
committer | sgurun@chromium.org <sgurun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-14 19:21:44 +0000 |
commit | ab80d87f898bea5577c1bcea5836fa2859523375 (patch) | |
tree | 910b83a4dc4c00981d4d01e935ef9f28830c72ca | |
parent | 891fa8e84764201e56d0dc2d0c61742fbc6670cd (diff) | |
download | chromium_src-ab80d87f898bea5577c1bcea5836fa2859523375.zip chromium_src-ab80d87f898bea5577c1bcea5836fa2859523375.tar.gz chromium_src-ab80d87f898bea5577c1bcea5836fa2859523375.tar.bz2 |
Merge 248903 "hide the input method window when the user is done..."
> hide the input method window when the user is done typing
>
> BUG=340100
>
> Review URL: https://codereview.chromium.org/132913007
TBR=hush@chromium.org
Review URL: https://codereview.chromium.org/166273003
git-svn-id: svn://svn.chromium.org/chrome/branches/1750/src@251386 0039d316-1c4b-4281-b951-d872f2087c98
2 files changed, 42 insertions, 1 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java index 05d04c1b..369d5edd 100644 --- a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java +++ b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java @@ -225,6 +225,13 @@ public class AdapterInputConnection extends BaseInputConnection { mImeAdapter.sendKeyEventWithKeyCode(KeyEvent.KEYCODE_ENTER, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE | KeyEvent.FLAG_EDITOR_ACTION); + + if ((actionCode == EditorInfo.IME_ACTION_GO || actionCode == EditorInfo.IME_ACTION_DONE + || actionCode == EditorInfo.IME_ACTION_SEARCH) && isActive()) { + // User is done typing, hide the keyboard. + InputMethodManagerWrapper wrapper = getInputMethodManagerWrapper(); + wrapper.hideSoftInputFromWindow(mInternalView.getWindowToken(), 0, null); + } } return true; } diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java index 9dcce92..9321bc5 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java @@ -78,6 +78,32 @@ public class AdapterInputConnectionTest extends ContentShellTestBase { mWrapper.verifyUpdateSelectionCall(0, 4, 4, 0 ,4); } + @MediumTest + @Feature({"TextInput", "Main"}) + public void testDismissInputMethodWindowAfterFinishingTyping() throws Throwable { + assertEquals(false, mWrapper.isHidden()); + + mConnection.performEditorAction(EditorInfo.IME_ACTION_NEXT); + assertEquals(false, mWrapper.isHidden()); + mWrapper.showSoftInput(null, 0, null); + + mConnection.performEditorAction(EditorInfo.IME_ACTION_SEND); + assertEquals(false, mWrapper.isHidden()); + mWrapper.showSoftInput(null, 0, null); + + mConnection.performEditorAction(EditorInfo.IME_ACTION_GO); + assertEquals(true, mWrapper.isHidden()); + mWrapper.showSoftInput(null, 0, null); + + mConnection.performEditorAction(EditorInfo.IME_ACTION_DONE); + assertEquals(true, mWrapper.isHidden()); + mWrapper.showSoftInput(null, 0, null); + + mConnection.performEditorAction(EditorInfo.IME_ACTION_SEARCH); + assertEquals(true, mWrapper.isHidden()); + mWrapper.showSoftInput(null, 0, null); + } + private static class TestImeAdapter extends ImeAdapter { public TestImeAdapter(InputMethodManagerWrapper wrapper, ImeAdapterDelegate embedder) { super(wrapper, embedder); @@ -86,6 +112,7 @@ public class AdapterInputConnectionTest extends ContentShellTestBase { private static class TestInputMethodManagerWrapper extends InputMethodManagerWrapper { private final ArrayList<ImeState> mUpdates = new ArrayList<ImeState>(); + private boolean hidden = false; public TestInputMethodManagerWrapper(Context context) { super(context); @@ -95,7 +122,9 @@ public class AdapterInputConnectionTest extends ContentShellTestBase { public void restartInput(View view) {} @Override - public void showSoftInput(View view, int flags, ResultReceiver resultReceiver) {} + public void showSoftInput(View view, int flags, ResultReceiver resultReceiver) { + hidden = false; + } @Override public boolean isActive(View view) { @@ -105,6 +134,7 @@ public class AdapterInputConnectionTest extends ContentShellTestBase { @Override public boolean hideSoftInputFromWindow(IBinder windowToken, int flags, ResultReceiver resultReceiver) { + hidden = true; return true; } @@ -127,6 +157,10 @@ public class AdapterInputConnectionTest extends ContentShellTestBase { state.compositionStart); assertEquals("Composition end did not match", compositionEnd, state.compositionEnd); } + + public boolean isHidden() { + return hidden; + } } private static class TestImeAdapterDelegate implements ImeAdapterDelegate { |