OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.annotation.TargetApi; |
| 8 import android.os.Build; |
7 import android.os.Handler; | 9 import android.os.Handler; |
8 import android.os.Looper; | 10 import android.os.Looper; |
9 import android.text.Editable; | 11 import android.text.Editable; |
10 import android.text.Selection; | 12 import android.text.Selection; |
11 import android.view.KeyCharacterMap; | 13 import android.view.KeyCharacterMap; |
12 import android.view.KeyEvent; | 14 import android.view.KeyEvent; |
13 import android.view.View; | 15 import android.view.View; |
14 import android.view.inputmethod.BaseInputConnection; | 16 import android.view.inputmethod.BaseInputConnection; |
15 import android.view.inputmethod.EditorInfo; | 17 import android.view.inputmethod.EditorInfo; |
16 import android.view.inputmethod.ExtractedText; | 18 import android.view.inputmethod.ExtractedText; |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 461 } |
460 | 462 |
461 @Override | 463 @Override |
462 public void unblockOnUiThread() {} | 464 public void unblockOnUiThread() {} |
463 | 465 |
464 @Override | 466 @Override |
465 public Handler getHandler() { | 467 public Handler getHandler() { |
466 return mHandler; | 468 return mHandler; |
467 } | 469 } |
468 | 470 |
| 471 /** |
| 472 * @see BaseInputConnection#requestCursorUpdates(int) |
| 473 */ |
| 474 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 475 @Override |
| 476 public boolean requestCursorUpdates(int cursorUpdateMode) { |
| 477 return mImeAdapter.onRequestCursorUpdates(cursorUpdateMode); |
| 478 } |
| 479 |
469 @VisibleForTesting | 480 @VisibleForTesting |
470 static class ImeState { | 481 static class ImeState { |
471 public final String text; | 482 public final String text; |
472 public final int selectionStart; | 483 public final int selectionStart; |
473 public final int selectionEnd; | 484 public final int selectionEnd; |
474 public final int compositionStart; | 485 public final int compositionStart; |
475 public final int compositionEnd; | 486 public final int compositionEnd; |
476 | 487 |
477 public ImeState(String text, int selectionStart, int selectionEnd, int c
ompositionStart, | 488 public ImeState(String text, int selectionStart, int selectionEnd, int c
ompositionStart, |
478 int compositionEnd) { | 489 int compositionEnd) { |
479 this.text = text; | 490 this.text = text; |
480 this.selectionStart = selectionStart; | 491 this.selectionStart = selectionStart; |
481 this.selectionEnd = selectionEnd; | 492 this.selectionEnd = selectionEnd; |
482 this.compositionStart = compositionStart; | 493 this.compositionStart = compositionStart; |
483 this.compositionEnd = compositionEnd; | 494 this.compositionEnd = compositionEnd; |
484 } | 495 } |
485 } | 496 } |
486 | 497 |
487 @VisibleForTesting | 498 @VisibleForTesting |
488 ImeState getImeStateForTesting() { | 499 ImeState getImeStateForTesting() { |
489 String text = mEditable.toString(); | 500 String text = mEditable.toString(); |
490 int selectionStart = Selection.getSelectionStart(mEditable); | 501 int selectionStart = Selection.getSelectionStart(mEditable); |
491 int selectionEnd = Selection.getSelectionEnd(mEditable); | 502 int selectionEnd = Selection.getSelectionEnd(mEditable); |
492 int compositionStart = getComposingSpanStart(mEditable); | 503 int compositionStart = getComposingSpanStart(mEditable); |
493 int compositionEnd = getComposingSpanEnd(mEditable); | 504 int compositionEnd = getComposingSpanEnd(mEditable); |
494 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); | 505 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); |
495 } | 506 } |
496 } | 507 } |
OLD | NEW |