am f618f351: am 6e29bf56: am 8c42bf54: Follow API signature change in CursorAnchorInfo
* commit 'f618f351fe9f26929da1e04fe69612ac4406d6fd': Follow API signature change in CursorAnchorInfomain
commit
2d1e86bd10
|
@ -23,34 +23,16 @@ import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
|
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
public final class CursorAnchorInfoCompatWrapper {
|
public final class CursorAnchorInfoCompatWrapper {
|
||||||
public static final int CHARACTER_RECT_TYPE_MASK = 0x0f;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type for {@link #CHARACTER_RECT_TYPE_MASK}: the editor did not specify any type of this
|
* The insertion marker or character bounds have at least one visible region.
|
||||||
* character. Editor authors should not use this flag.
|
|
||||||
*/
|
*/
|
||||||
public static final int CHARACTER_RECT_TYPE_UNSPECIFIED = 0;
|
public static final int FLAG_HAS_VISIBLE_REGION = 0x01;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type for {@link #CHARACTER_RECT_TYPE_MASK}: the character is entirely visible.
|
* The insertion marker or character bounds have at least one invisible (clipped) region.
|
||||||
*/
|
*/
|
||||||
public static final int CHARACTER_RECT_TYPE_FULLY_VISIBLE = 1;
|
public static final int FLAG_HAS_INVISIBLE_REGION = 0x02;
|
||||||
|
|
||||||
/**
|
|
||||||
* Type for {@link #CHARACTER_RECT_TYPE_MASK}: some area of the character is invisible.
|
|
||||||
*/
|
|
||||||
public static final int CHARACTER_RECT_TYPE_PARTIALLY_VISIBLE = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type for {@link #CHARACTER_RECT_TYPE_MASK}: the character is entirely invisible.
|
|
||||||
*/
|
|
||||||
public static final int CHARACTER_RECT_TYPE_INVISIBLE = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type for {@link #CHARACTER_RECT_TYPE_MASK}: the editor gave up to calculate the rectangle
|
|
||||||
* for this character. Input method authors should ignore the returned rectangle.
|
|
||||||
*/
|
|
||||||
public static final int CHARACTER_RECT_TYPE_NOT_FEASIBLE = 4;
|
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -63,7 +45,7 @@ public final class CursorAnchorInfoCompatWrapper {
|
||||||
private static final CompatUtils.ToFloatMethodWrapper sGetInsertionMarkerHorizontalMethod;
|
private static final CompatUtils.ToFloatMethodWrapper sGetInsertionMarkerHorizontalMethod;
|
||||||
private static final CompatUtils.ToFloatMethodWrapper sGetInsertionMarkerTopMethod;
|
private static final CompatUtils.ToFloatMethodWrapper sGetInsertionMarkerTopMethod;
|
||||||
private static final CompatUtils.ToObjectMethodWrapper<Matrix> sGetMatrixMethod;
|
private static final CompatUtils.ToObjectMethodWrapper<Matrix> sGetMatrixMethod;
|
||||||
private static final CompatUtils.ToBooleanMethodWrapper sIsInsertionMarkerClippedMethod;
|
private static final CompatUtils.ToIntMethodWrapper sGetInsertionMarkerFlagsMethod;
|
||||||
|
|
||||||
private static int COMPOSING_TEXT_START_DEFAULT = -1;
|
private static int COMPOSING_TEXT_START_DEFAULT = -1;
|
||||||
static {
|
static {
|
||||||
|
@ -72,7 +54,7 @@ public final class CursorAnchorInfoCompatWrapper {
|
||||||
sGetCharacterRectMethod = sCursorAnchorInfoClass.getMethod(
|
sGetCharacterRectMethod = sCursorAnchorInfoClass.getMethod(
|
||||||
"getCharacterRect", (RectF)null, int.class);
|
"getCharacterRect", (RectF)null, int.class);
|
||||||
sGetCharacterRectFlagsMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
sGetCharacterRectFlagsMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
||||||
"getCharacterRectFlags", CHARACTER_RECT_TYPE_UNSPECIFIED, int.class);
|
"getCharacterRectFlags", 0, int.class);
|
||||||
sGetComposingTextMethod = sCursorAnchorInfoClass.getMethod(
|
sGetComposingTextMethod = sCursorAnchorInfoClass.getMethod(
|
||||||
"getComposingText", (CharSequence)null);
|
"getComposingText", (CharSequence)null);
|
||||||
sGetComposingTextStartMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
sGetComposingTextStartMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
||||||
|
@ -86,8 +68,8 @@ public final class CursorAnchorInfoCompatWrapper {
|
||||||
sGetInsertionMarkerTopMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
sGetInsertionMarkerTopMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
||||||
"getInsertionMarkerTop", 0.0f);
|
"getInsertionMarkerTop", 0.0f);
|
||||||
sGetMatrixMethod = sCursorAnchorInfoClass.getMethod("getMatrix", (Matrix)null);
|
sGetMatrixMethod = sCursorAnchorInfoClass.getMethod("getMatrix", (Matrix)null);
|
||||||
sIsInsertionMarkerClippedMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
sGetInsertionMarkerFlagsMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
|
||||||
"isInsertionMarkerClipped", false);
|
"getInsertionMarkerFlags", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
|
@ -154,7 +136,7 @@ public final class CursorAnchorInfoCompatWrapper {
|
||||||
return sGetInsertionMarkerTopMethod.invoke(mInstance);
|
return sGetInsertionMarkerTopMethod.invoke(mInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInsertionMarkerClipped() {
|
public int getInsertionMarkerFlags() {
|
||||||
return sIsInsertionMarkerClippedMethod.invoke(mInstance);
|
return sGetInsertionMarkerFlagsMethod.invoke(mInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,10 +276,10 @@ public class TextDecorator {
|
||||||
final int lastCharRectIndex = composingTextStart + composingText.length() - 1;
|
final int lastCharRectIndex = composingTextStart + composingText.length() - 1;
|
||||||
final RectF lastCharRect = info.getCharacterRect(lastCharRectIndex);
|
final RectF lastCharRect = info.getCharacterRect(lastCharRectIndex);
|
||||||
final int lastCharRectFlag = info.getCharacterRectFlags(lastCharRectIndex);
|
final int lastCharRectFlag = info.getCharacterRectFlags(lastCharRectIndex);
|
||||||
final int lastCharRectType =
|
final boolean hasInvisibleRegionInLastCharRect =
|
||||||
lastCharRectFlag & CursorAnchorInfoCompatWrapper.CHARACTER_RECT_TYPE_MASK;
|
(lastCharRectFlag & CursorAnchorInfoCompatWrapper.FLAG_HAS_INVISIBLE_REGION)
|
||||||
if (lastCharRect == null || matrix == null || lastCharRectType !=
|
!= 0;
|
||||||
CursorAnchorInfoCompatWrapper.CHARACTER_RECT_TYPE_FULLY_VISIBLE) {
|
if (lastCharRect == null || matrix == null || hasInvisibleRegionInLastCharRect) {
|
||||||
mUiOperator.hideUi();
|
mUiOperator.hideUi();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,8 @@ public class TextDecorator {
|
||||||
}
|
}
|
||||||
// In MODE_ADD_TO_DICTIONARY, we cannot retrieve the character position at all because
|
// In MODE_ADD_TO_DICTIONARY, we cannot retrieve the character position at all because
|
||||||
// of the lack of composing text. We will use the insertion marker position instead.
|
// of the lack of composing text. We will use the insertion marker position instead.
|
||||||
if (info.isInsertionMarkerClipped()) {
|
if ((info.getInsertionMarkerFlags() &
|
||||||
|
CursorAnchorInfoCompatWrapper.FLAG_HAS_INVISIBLE_REGION) != 0) {
|
||||||
mUiOperator.hideUi();
|
mUiOperator.hideUi();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue