am 42ddc212: am f930ce12: am 1caa0b71: Merge "Follow up API signature changes of CursorAnchorInfo" into lmp-dev
* commit '42ddc2127deb117a0bb2b7a7797cb8c9ba335f5a': Follow up API signature changes of CursorAnchorInfomain
commit
a48fe12b9c
|
@ -34,10 +34,15 @@ public final class CursorAnchorInfoCompatWrapper {
|
||||||
*/
|
*/
|
||||||
public static final int FLAG_HAS_INVISIBLE_REGION = 0x02;
|
public static final int FLAG_HAS_INVISIBLE_REGION = 0x02;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The insertion marker or character bounds is placed at right-to-left (RTL) character.
|
||||||
|
*/
|
||||||
|
public static final int FLAG_IS_RTL = 0x04;
|
||||||
|
|
||||||
// Note that CursorAnchorInfo has been introduced in API level XX (Build.VERSION_CODE.LXX).
|
// Note that CursorAnchorInfo has been introduced in API level XX (Build.VERSION_CODE.LXX).
|
||||||
private static final CompatUtils.ClassWrapper sCursorAnchorInfoClass;
|
private static final CompatUtils.ClassWrapper sCursorAnchorInfoClass;
|
||||||
private static final CompatUtils.ToObjectMethodWrapper<RectF> sGetCharacterRectMethod;
|
private static final CompatUtils.ToObjectMethodWrapper<RectF> sGetCharacterBoundsMethod;
|
||||||
private static final CompatUtils.ToIntMethodWrapper sGetCharacterRectFlagsMethod;
|
private static final CompatUtils.ToIntMethodWrapper sGetCharacterBoundsFlagsMethod;
|
||||||
private static final CompatUtils.ToObjectMethodWrapper<CharSequence> sGetComposingTextMethod;
|
private static final CompatUtils.ToObjectMethodWrapper<CharSequence> sGetComposingTextMethod;
|
||||||
private static final CompatUtils.ToIntMethodWrapper sGetComposingTextStartMethod;
|
private static final CompatUtils.ToIntMethodWrapper sGetComposingTextStartMethod;
|
||||||
private static final CompatUtils.ToFloatMethodWrapper sGetInsertionMarkerBaselineMethod;
|
private static final CompatUtils.ToFloatMethodWrapper sGetInsertionMarkerBaselineMethod;
|
||||||
|
@ -51,10 +56,10 @@ public final class CursorAnchorInfoCompatWrapper {
|
||||||
static {
|
static {
|
||||||
sCursorAnchorInfoClass = CompatUtils.getClassWrapper(
|
sCursorAnchorInfoClass = CompatUtils.getClassWrapper(
|
||||||
"android.view.inputmethod.CursorAnchorInfo");
|
"android.view.inputmethod.CursorAnchorInfo");
|
||||||
sGetCharacterRectMethod = sCursorAnchorInfoClass.getMethod(
|
sGetCharacterBoundsMethod = sCursorAnchorInfoClass.getMethod(
|
||||||
"getCharacterRect", (RectF)null, int.class);
|
"getCharacterBounds", (RectF)null, int.class);
|
||||||
sGetCharacterRectFlagsMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
sGetCharacterBoundsFlagsMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
||||||
"getCharacterRectFlags", 0, int.class);
|
"getCharacterBoundsFlags", 0, int.class);
|
||||||
sGetComposingTextMethod = sCursorAnchorInfoClass.getMethod(
|
sGetComposingTextMethod = sCursorAnchorInfoClass.getMethod(
|
||||||
"getComposingText", (CharSequence)null);
|
"getComposingText", (CharSequence)null);
|
||||||
sGetComposingTextStartMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
sGetComposingTextStartMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
||||||
|
@ -112,12 +117,12 @@ public final class CursorAnchorInfoCompatWrapper {
|
||||||
return sGetMatrixMethod.invoke(mInstance);
|
return sGetMatrixMethod.invoke(mInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RectF getCharacterRect(final int index) {
|
public RectF getCharacterBounds(final int index) {
|
||||||
return sGetCharacterRectMethod.invoke(mInstance, index);
|
return sGetCharacterBoundsMethod.invoke(mInstance, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCharacterRectFlags(final int index) {
|
public int getCharacterBoundsFlags(final int index) {
|
||||||
return sGetCharacterRectFlagsMethod.invoke(mInstance, index);
|
return sGetCharacterBoundsFlagsMethod.invoke(mInstance, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getInsertionMarkerBaseline() {
|
public float getInsertionMarkerBaseline() {
|
||||||
|
|
|
@ -274,8 +274,8 @@ public class TextDecorator {
|
||||||
}
|
}
|
||||||
final int composingTextStart = info.getComposingTextStart();
|
final int composingTextStart = info.getComposingTextStart();
|
||||||
final int lastCharRectIndex = composingTextStart + composingText.length() - 1;
|
final int lastCharRectIndex = composingTextStart + composingText.length() - 1;
|
||||||
final RectF lastCharRect = info.getCharacterRect(lastCharRectIndex);
|
final RectF lastCharRect = info.getCharacterBounds(lastCharRectIndex);
|
||||||
final int lastCharRectFlag = info.getCharacterRectFlags(lastCharRectIndex);
|
final int lastCharRectFlag = info.getCharacterBoundsFlags(lastCharRectIndex);
|
||||||
final boolean hasInvisibleRegionInLastCharRect =
|
final boolean hasInvisibleRegionInLastCharRect =
|
||||||
(lastCharRectFlag & CursorAnchorInfoCompatWrapper.FLAG_HAS_INVISIBLE_REGION)
|
(lastCharRectFlag & CursorAnchorInfoCompatWrapper.FLAG_HAS_INVISIBLE_REGION)
|
||||||
!= 0;
|
!= 0;
|
||||||
|
@ -285,7 +285,7 @@ public class TextDecorator {
|
||||||
}
|
}
|
||||||
final RectF segmentStartCharRect = new RectF(lastCharRect);
|
final RectF segmentStartCharRect = new RectF(lastCharRect);
|
||||||
for (int i = composingText.length() - 2; i >= 0; --i) {
|
for (int i = composingText.length() - 2; i >= 0; --i) {
|
||||||
final RectF charRect = info.getCharacterRect(composingTextStart + i);
|
final RectF charRect = info.getCharacterBounds(composingTextStart + i);
|
||||||
if (charRect == null) {
|
if (charRect == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue