OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.content.browser.input; |
| 6 |
| 7 import android.os.Handler; |
| 8 import android.view.KeyEvent; |
| 9 import android.view.View; |
| 10 import android.view.inputmethod.EditorInfo; |
| 11 import android.view.inputmethod.InputConnection; |
| 12 |
| 13 import org.chromium.base.VisibleForTesting; |
| 14 |
| 15 /** |
| 16 * An interface to help switch between AdapterInputConnection and ChromiumInputC
onnection. |
| 17 */ |
| 18 public interface ChromiumBaseInputConnection extends InputConnection { |
| 19 /** |
| 20 * A factory class to create or reuse ChromiumBaseInputConnection. |
| 21 */ |
| 22 public interface Factory { |
| 23 ChromiumBaseInputConnection initializeAndGet(View view, ImeAdapter imeAd
apter, |
| 24 int inputType, int inputFlags, int selectionStart, int selection
End, |
| 25 EditorInfo outAttrs); |
| 26 |
| 27 @VisibleForTesting |
| 28 Handler getHandler(); |
| 29 } |
| 30 |
| 31 /** |
| 32 * Updates the internal representation of the text being edited and its sele
ction and |
| 33 * composition properties. |
| 34 * |
| 35 * @param text The String contents of the field being edited. |
| 36 * @param selectionStart The character offset of the selection start, or the
caret position if |
| 37 * there is no selection. |
| 38 * @param selectionEnd The character offset of the selection end, or the car
et position if there |
| 39 * is no selection. |
| 40 * @param compositionStart The character offset of the composition start, or
-1 if there is no |
| 41 * composition. |
| 42 * @param compositionEnd The character offset of the composition end, or -1
if there is no |
| 43 * selection. |
| 44 * @param isNonImeChange True when the update was caused by non-IME (e.g. Ja
vascript). |
| 45 */ |
| 46 void updateStateOnUiThread(String text, int selectionStart, int selectionEnd
, |
| 47 int compositionStart, int compositionEnd, boolean singleLine, boolea
n isNonImeChange); |
| 48 |
| 49 /** |
| 50 * Send key event on UI thread. |
| 51 * @param event A key event. |
| 52 */ |
| 53 boolean sendKeyEventOnUiThread(KeyEvent event); |
| 54 |
| 55 /** |
| 56 * Call this when restartInput() is called. |
| 57 */ |
| 58 void onRestartInputOnUiThread(); |
| 59 |
| 60 /** |
| 61 * @return The {@link Handler} used for this InputConnection. |
| 62 */ |
| 63 @VisibleForTesting |
| 64 Handler getHandler(); |
| 65 |
| 66 /** |
| 67 * Move cursor to the end of the current selection. |
| 68 */ |
| 69 void moveCursorToSelectionEndOnUiThread(); |
| 70 |
| 71 /** |
| 72 * Unblock thread function if needed, e.g. we found that we will |
| 73 * never get state update. |
| 74 */ |
| 75 void unblockOnUiThread(); |
| 76 } |
OLD | NEW |