OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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.graphics.Matrix; |
| 8 import android.graphics.RectF; |
| 9 import android.view.inputmethod.CursorAnchorInfo; |
| 10 |
| 11 /** |
| 12 * Wrapper around Android's {@link android.view.inputmethod.CursorAnchorInfo}. |
| 13 * <p>This wrapper class is introduced so that we can write unit test for |
| 14 * {@link CursorAnchorInfoController} without directly depending on {@link Curso
rAnchorInfo}, |
| 15 * which is available on Android 5.0 and later only. We can remove this wrapper
class once |
| 16 * we stop supporting Android 4.4 and prior. |
| 17 */ |
| 18 public interface CursorAnchorInfoWrapper { |
| 19 public static final int FLAG_HAS_VISIBLE_REGION = 0x01; |
| 20 public static final int FLAG_HAS_INVISIBLE_REGION = 0x02; |
| 21 public static final int FLAG_IS_RTL = 0x04; |
| 22 |
| 23 /** |
| 24 * Wrapper around Android's {@link android.view.inputmethod.CursorAnchorInfo
.Builder}. |
| 25 */ |
| 26 interface Builder { |
| 27 Builder setSelectionRange(int newStart, int newEnd); |
| 28 |
| 29 Builder setComposingText(int composingTextStart, CharSequence composingT
ext); |
| 30 |
| 31 Builder setInsertionMarkerLocation(float horizontalPosition, float lineT
op, |
| 32 float lineBaseline, float lineBottom, int flags); |
| 33 |
| 34 Builder addCharacterBounds(int index, float left, float top, float right
, float bottom, |
| 35 int flags); |
| 36 |
| 37 Builder setMatrix(Matrix matrix); |
| 38 |
| 39 CursorAnchorInfoWrapper build(); |
| 40 |
| 41 void reset(); |
| 42 } |
| 43 |
| 44 int getSelectionStart(); |
| 45 |
| 46 int getSelectionEnd(); |
| 47 |
| 48 int getComposingTextStart(); |
| 49 |
| 50 CharSequence getComposingText(); |
| 51 |
| 52 int getInsertionMarkerFlags(); |
| 53 |
| 54 float getInsertionMarkerHorizontal(); |
| 55 |
| 56 float getInsertionMarkerTop(); |
| 57 |
| 58 float getInsertionMarkerBaseline(); |
| 59 |
| 60 float getInsertionMarkerBottom(); |
| 61 |
| 62 RectF getCharacterBounds(final int index); |
| 63 |
| 64 int getCharacterBoundsFlags(final int index); |
| 65 |
| 66 Matrix getMatrix(); |
| 67 |
| 68 /** |
| 69 * @return The real {@link CursorAnchorInfo} object if it is available. Oth
erwise {@code null} |
| 70 * is returned. <p>Note that {@link CursorAnchorInfo} was introduced in Andr
oid 5.0 |
| 71 * (API Level 21) and this method always returns {@code null} on those older
platforms. |
| 72 */ |
| 73 Object unwrap(); |
| 74 } |
OLD | NEW |