Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java

Issue 2290133002: Make WebView keep keyboard when losing focus (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser.input; 5 package org.chromium.content.browser.input;
6 6
7 import android.content.res.Configuration; 7 import android.content.res.Configuration;
8 import android.os.Build; 8 import android.os.Build;
9 import android.os.ResultReceiver; 9 import android.os.ResultReceiver;
10 import android.os.SystemClock; 10 import android.os.SystemClock;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (mNativeImeAdapterAndroid != 0) { 340 if (mNativeImeAdapterAndroid != 0) {
341 nativeResetImeAdapter(mNativeImeAdapterAndroid); 341 nativeResetImeAdapter(mNativeImeAdapterAndroid);
342 } 342 }
343 if (nativeImeAdapter != 0) { 343 if (nativeImeAdapter != 0) {
344 nativeAttachImeAdapter(nativeImeAdapter); 344 nativeAttachImeAdapter(nativeImeAdapter);
345 } 345 }
346 mNativeImeAdapterAndroid = nativeImeAdapter; 346 mNativeImeAdapterAndroid = nativeImeAdapter;
347 if (nativeImeAdapter != 0) { 347 if (nativeImeAdapter != 0) {
348 createInputConnectionFactory(); 348 createInputConnectionFactory();
349 } 349 }
350 resetAndHideKeyboard();
350 } 351 }
351 352
352 /** 353 /**
353 * Show soft keyboard only if it is the current keyboard configuration. 354 * Show soft keyboard only if it is the current keyboard configuration.
354 */ 355 */
355 private void showSoftKeyboard() { 356 private void showSoftKeyboard() {
356 if (DEBUG_LOGS) Log.w(TAG, "showSoftKeyboard"); 357 if (DEBUG_LOGS) Log.w(TAG, "showSoftKeyboard");
357 mInputMethodManagerWrapper.showSoftInput( 358 mInputMethodManagerWrapper.showSoftInput(
358 mViewEmbedder.getAttachedView(), 0, mViewEmbedder.getNewShowKeyb oardReceiver()); 359 mViewEmbedder.getAttachedView(), 0, mViewEmbedder.getNewShowKeyb oardReceiver());
359 if (mViewEmbedder.getAttachedView().getResources().getConfiguration().ke yboard 360 if (mViewEmbedder.getAttachedView().getResources().getConfiguration().ke yboard
360 != Configuration.KEYBOARD_NOKEYS) { 361 != Configuration.KEYBOARD_NOKEYS) {
361 mViewEmbedder.onKeyboardBoundsUnchanged(); 362 mViewEmbedder.onKeyboardBoundsUnchanged();
362 } 363 }
363 } 364 }
364 365
365 /** 366 /**
366 * Hide soft keyboard. 367 * Hide soft keyboard.
367 */ 368 */
368 private void hideKeyboard() { 369 private void hideKeyboard() {
369 if (DEBUG_LOGS) Log.w(TAG, "hideKeyboard"); 370 if (DEBUG_LOGS) Log.w(TAG, "hideKeyboard");
370 View view = mViewEmbedder.getAttachedView(); 371 View view = mViewEmbedder.getAttachedView();
371 if (mInputMethodManagerWrapper.isActive(view)) { 372 // NOTE: we should not set ResultReceiver here. Otherwise, IMM will own ContentViewCore
Changwan Ryu 2016/10/19 05:10:21 Is this really causing flakiness in test with onDe
yabinh 2016/10/24 01:40:57 Still flaky, but it's because of the test itself,
372 // NOTE: we should not set ResultReceiver here. Otherwise, IMM will own ContentViewCore 373 // and ImeAdapter even after input method goes away and result gets rece ived.
373 // and ImeAdapter even after input method goes away and result gets received. 374 mInputMethodManagerWrapper.hideSoftInputFromWindow(view.getWindowToken() , 0, null);
374 mInputMethodManagerWrapper.hideSoftInputFromWindow(view.getWindowTok en(), 0, null);
375 }
376 // Detach input connection by returning null from onCreateInputConnectio n(). 375 // Detach input connection by returning null from onCreateInputConnectio n().
377 if (mTextInputType == TextInputType.NONE && mInputConnection != null) { 376 if (mTextInputType == TextInputType.NONE && mInputConnection != null) {
378 restartInput(); 377 restartInput();
379 } 378 }
380 } 379 }
381 380
382 /** 381 /**
383 * Call this when keyboard configuration has changed. 382 * Call this when keyboard configuration has changed.
384 */ 383 */
385 public void onKeyboardConfigurationChanged(Configuration newConfig) { 384 public void onKeyboardConfigurationChanged(Configuration newConfig) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 public void onViewAttachedToWindow() { 419 public void onViewAttachedToWindow() {
421 if (mInputConnectionFactory != null) { 420 if (mInputConnectionFactory != null) {
422 mInputConnectionFactory.onViewAttachedToWindow(); 421 mInputConnectionFactory.onViewAttachedToWindow();
423 } 422 }
424 } 423 }
425 424
426 /** 425 /**
427 * Call this when view is detached from window 426 * Call this when view is detached from window
428 */ 427 */
429 public void onViewDetachedFromWindow() { 428 public void onViewDetachedFromWindow() {
429 resetAndHideKeyboard();
Changwan Ryu 2016/10/19 05:10:21 As we talked offline, I now prefer this approach b
430 if (mInputConnectionFactory != null) { 430 if (mInputConnectionFactory != null) {
431 mInputConnectionFactory.onViewDetachedFromWindow(); 431 mInputConnectionFactory.onViewDetachedFromWindow();
432 } 432 }
433 } 433 }
434 434
435 /** 435 /**
436 * Call this when view's focus has changed. 436 * Call this when view's focus has changed.
437 * @param gainFocus True if we're gaining focus. 437 * @param gainFocus True if we're gaining focus.
438 */ 438 */
439 public void onViewFocusChanged(boolean gainFocus) { 439 public void onViewFocusChanged(boolean gainFocus) {
440 if (DEBUG_LOGS) Log.w(TAG, "onViewFocusChanged: gainFocus [%b]", gainFoc us); 440 if (DEBUG_LOGS) Log.w(TAG, "onViewFocusChanged: gainFocus [%b]", gainFoc us);
441 if (!gainFocus) resetAndHideKeyboard();
442 if (mInputConnectionFactory != null) { 441 if (mInputConnectionFactory != null) {
443 mInputConnectionFactory.onViewFocusChanged(gainFocus); 442 mInputConnectionFactory.onViewFocusChanged(gainFocus);
444 } 443 }
445 } 444 }
446 445
447 /** 446 /**
448 * Move cursor to the end of the current selection. 447 * Move cursor to the end of the current selection.
449 */ 448 */
450 public void moveCursorToSelectionEnd() { 449 public void moveCursorToSelectionEnd() {
451 if (DEBUG_LOGS) Log.w(TAG, "movecursorToEnd"); 450 if (DEBUG_LOGS) Log.w(TAG, "movecursorToEnd");
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 int before, int after); 798 int before, int after);
800 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); 799 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid);
801 private native boolean nativeRequestTextInputStateUpdate( 800 private native boolean nativeRequestTextInputStateUpdate(
802 long nativeImeAdapterAndroid); 801 long nativeImeAdapterAndroid);
803 private native boolean nativeBeginBatchEdit(long nativeImeAdapterAndroid); 802 private native boolean nativeBeginBatchEdit(long nativeImeAdapterAndroid);
804 private native boolean nativeEndBatchEdit(long nativeImeAdapterAndroid); 803 private native boolean nativeEndBatchEdit(long nativeImeAdapterAndroid);
805 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, 804 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid,
806 boolean immediateRequest, boolean monitorRequest); 805 boolean immediateRequest, boolean monitorRequest);
807 private native boolean nativeIsImeThreadEnabled(long nativeImeAdapterAndroid ); 806 private native boolean nativeIsImeThreadEnabled(long nativeImeAdapterAndroid );
808 } 807 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698