OLD | NEW |
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 Loading... |
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 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 public void onViewAttachedToWindow() { | 421 public void onViewAttachedToWindow() { |
421 if (mInputConnectionFactory != null) { | 422 if (mInputConnectionFactory != null) { |
422 mInputConnectionFactory.onViewAttachedToWindow(); | 423 mInputConnectionFactory.onViewAttachedToWindow(); |
423 } | 424 } |
424 } | 425 } |
425 | 426 |
426 /** | 427 /** |
427 * Call this when view is detached from window | 428 * Call this when view is detached from window |
428 */ | 429 */ |
429 public void onViewDetachedFromWindow() { | 430 public void onViewDetachedFromWindow() { |
| 431 resetAndHideKeyboard(); |
430 if (mInputConnectionFactory != null) { | 432 if (mInputConnectionFactory != null) { |
431 mInputConnectionFactory.onViewDetachedFromWindow(); | 433 mInputConnectionFactory.onViewDetachedFromWindow(); |
432 } | 434 } |
433 } | 435 } |
434 | 436 |
435 /** | 437 /** |
436 * Call this when view's focus has changed. | 438 * Call this when view's focus has changed. |
437 * @param gainFocus True if we're gaining focus. | 439 * @param gainFocus True if we're gaining focus. |
438 */ | 440 */ |
439 public void onViewFocusChanged(boolean gainFocus) { | 441 public void onViewFocusChanged(boolean gainFocus) { |
440 if (DEBUG_LOGS) Log.w(TAG, "onViewFocusChanged: gainFocus [%b]", gainFoc
us); | 442 if (DEBUG_LOGS) Log.w(TAG, "onViewFocusChanged: gainFocus [%b]", gainFoc
us); |
441 if (!gainFocus) resetAndHideKeyboard(); | |
442 if (mInputConnectionFactory != null) { | 443 if (mInputConnectionFactory != null) { |
443 mInputConnectionFactory.onViewFocusChanged(gainFocus); | 444 mInputConnectionFactory.onViewFocusChanged(gainFocus); |
444 } | 445 } |
445 } | 446 } |
446 | 447 |
447 /** | 448 /** |
448 * Move cursor to the end of the current selection. | 449 * Move cursor to the end of the current selection. |
449 */ | 450 */ |
450 public void moveCursorToSelectionEnd() { | 451 public void moveCursorToSelectionEnd() { |
451 if (DEBUG_LOGS) Log.w(TAG, "movecursorToEnd"); | 452 if (DEBUG_LOGS) Log.w(TAG, "movecursorToEnd"); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 int before, int after); | 800 int before, int after); |
800 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); | 801 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); |
801 private native boolean nativeRequestTextInputStateUpdate( | 802 private native boolean nativeRequestTextInputStateUpdate( |
802 long nativeImeAdapterAndroid); | 803 long nativeImeAdapterAndroid); |
803 private native boolean nativeBeginBatchEdit(long nativeImeAdapterAndroid); | 804 private native boolean nativeBeginBatchEdit(long nativeImeAdapterAndroid); |
804 private native boolean nativeEndBatchEdit(long nativeImeAdapterAndroid); | 805 private native boolean nativeEndBatchEdit(long nativeImeAdapterAndroid); |
805 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, | 806 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, |
806 boolean immediateRequest, boolean monitorRequest); | 807 boolean immediateRequest, boolean monitorRequest); |
807 private native boolean nativeIsImeThreadEnabled(long nativeImeAdapterAndroid
); | 808 private native boolean nativeIsImeThreadEnabled(long nativeImeAdapterAndroid
); |
808 } | 809 } |
OLD | NEW |