Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d780ce19 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Android (Google) Code Review
Browse files

Merge "API Review: CursorAnchorInfo" into lmp-dev

parents e8f8bc0a cc24e2b6
Loading
Loading
Loading
Loading
+4 −8
Original line number Original line Diff line number Diff line
@@ -35857,20 +35857,16 @@ package android.view.inputmethod {
    method public int getComposingTextStart();
    method public int getComposingTextStart();
    method public float getInsertionMarkerBaseline();
    method public float getInsertionMarkerBaseline();
    method public float getInsertionMarkerBottom();
    method public float getInsertionMarkerBottom();
    method public int getInsertionMarkerFlags();
    method public float getInsertionMarkerHorizontal();
    method public float getInsertionMarkerHorizontal();
    method public float getInsertionMarkerTop();
    method public float getInsertionMarkerTop();
    method public android.graphics.Matrix getMatrix();
    method public android.graphics.Matrix getMatrix();
    method public int getSelectionEnd();
    method public int getSelectionEnd();
    method public int getSelectionStart();
    method public int getSelectionStart();
    method public boolean isInsertionMarkerClipped();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int CHARACTER_RECT_TYPE_FULLY_VISIBLE = 1; // 0x1
    field public static final int CHARACTER_RECT_TYPE_INVISIBLE = 3; // 0x3
    field public static final int CHARACTER_RECT_TYPE_MASK = 15; // 0xf
    field public static final int CHARACTER_RECT_TYPE_NOT_FEASIBLE = 4; // 0x4
    field public static final int CHARACTER_RECT_TYPE_PARTIALLY_VISIBLE = 2; // 0x2
    field public static final int CHARACTER_RECT_TYPE_UNSPECIFIED = 0; // 0x0
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final int FLAG_HAS_INVISIBLE_REGION = 2; // 0x2
    field public static final int FLAG_HAS_VISIBLE_REGION = 1; // 0x1
  }
  }
  public static final class CursorAnchorInfo.Builder {
  public static final class CursorAnchorInfo.Builder {
@@ -35879,7 +35875,7 @@ package android.view.inputmethod {
    method public android.view.inputmethod.CursorAnchorInfo build();
    method public android.view.inputmethod.CursorAnchorInfo build();
    method public void reset();
    method public void reset();
    method public android.view.inputmethod.CursorAnchorInfo.Builder setComposingText(int, java.lang.CharSequence);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setComposingText(int, java.lang.CharSequence);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setInsertionMarkerLocation(float, float, float, float, boolean);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setInsertionMarkerLocation(float, float, float, float, int);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setMatrix(android.graphics.Matrix);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setMatrix(android.graphics.Matrix);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setSelectionRange(int, int);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setSelectionRange(int, int);
  }
  }
+18 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,24 @@ package android.view {


}
}


package android.view.inputmethod {

  public final class CursorAnchorInfo implements android.os.Parcelable {
    method public boolean isInsertionMarkerClipped();
    field public static final int CHARACTER_RECT_TYPE_FULLY_VISIBLE = 1; // 0x1
    field public static final int CHARACTER_RECT_TYPE_INVISIBLE = 3; // 0x3
    field public static final int CHARACTER_RECT_TYPE_MASK = 15; // 0xf
    field public static final int CHARACTER_RECT_TYPE_NOT_FEASIBLE = 4; // 0x4
    field public static final int CHARACTER_RECT_TYPE_PARTIALLY_VISIBLE = 2; // 0x2
    field public static final int CHARACTER_RECT_TYPE_UNSPECIFIED = 0; // 0x0
  }

  public static final class CursorAnchorInfo.Builder {
    method public android.view.inputmethod.CursorAnchorInfo.Builder setInsertionMarkerLocation(float, float, float, float, boolean);
  }

}

package com.android.internal {
package com.android.internal {


  public static final class R.attr {
  public static final class R.attr {
+64 −26
Original line number Original line Diff line number Diff line
@@ -45,9 +45,9 @@ public final class CursorAnchorInfo implements Parcelable {
    private final CharSequence mComposingText;
    private final CharSequence mComposingText;


    /**
    /**
     * {@code True} if the insertion marker is partially or entirely clipped by other UI elements.
     * Flags of the insertion marker. See {@link #FLAG_HAS_VISIBLE_REGION} for example.
     */
     */
    private final boolean mInsertionMarkerClipped;
    private final int mInsertionMarkerFlags;
    /**
    /**
     * Horizontal position of the insertion marker, in the local coordinates that will be
     * Horizontal position of the insertion marker, in the local coordinates that will be
     * transformed with the transformation matrix when rendered on the screen. This should be
     * transformed with the transformation matrix when rendered on the screen. This should be
@@ -90,27 +90,47 @@ public final class CursorAnchorInfo implements Parcelable {
     */
     */
    private final Matrix mMatrix;
    private final Matrix mMatrix;


    /**
     * Flag for {@link #getInsertionMarkerFlags()} and {@link #getCharacterRectFlags(int)}: the
     * insertion marker or character bounds have at least one visible region.
     */
    public static final int FLAG_HAS_VISIBLE_REGION = 0x01;

    /**
     * Flag for {@link #getInsertionMarkerFlags()} and {@link #getCharacterRectFlags(int)}: the
     * insertion marker or character bounds have at least one invisible (clipped) region.
     */
    public static final int FLAG_HAS_INVISIBLE_REGION = 0x02;

    /**
     * @removed
     */
    public static final int CHARACTER_RECT_TYPE_MASK = 0x0f;
    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
     * Type for {@link #CHARACTER_RECT_TYPE_MASK}: the editor did not specify any type of this
     * character. Editor authors should not use this flag.
     * character. Editor authors should not use this flag.
     * @removed
     */
     */
    public static final int CHARACTER_RECT_TYPE_UNSPECIFIED = 0;
    public static final int CHARACTER_RECT_TYPE_UNSPECIFIED = 0;
    /**
    /**
     * Type for {@link #CHARACTER_RECT_TYPE_MASK}: the character is entirely visible.
     * Type for {@link #CHARACTER_RECT_TYPE_MASK}: the character is entirely visible.
     * @removed
     */
     */
    public static final int CHARACTER_RECT_TYPE_FULLY_VISIBLE = 1;
    public static final int CHARACTER_RECT_TYPE_FULLY_VISIBLE = 1;
    /**
    /**
     * Type for {@link #CHARACTER_RECT_TYPE_MASK}: some area of the character is invisible.
     * Type for {@link #CHARACTER_RECT_TYPE_MASK}: some area of the character is invisible.
     * @removed
     */
     */
    public static final int CHARACTER_RECT_TYPE_PARTIALLY_VISIBLE = 2;
    public static final int CHARACTER_RECT_TYPE_PARTIALLY_VISIBLE = 2;
    /**
    /**
     * Type for {@link #CHARACTER_RECT_TYPE_MASK}: the character is entirely invisible.
     * Type for {@link #CHARACTER_RECT_TYPE_MASK}: the character is entirely invisible.
     * @removed
     */
     */
    public static final int CHARACTER_RECT_TYPE_INVISIBLE = 3;
    public static final int CHARACTER_RECT_TYPE_INVISIBLE = 3;
    /**
    /**
     * Type for {@link #CHARACTER_RECT_TYPE_MASK}: the editor gave up to calculate the rectangle
     * 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.
     * for this character. Input method authors should ignore the returned rectangle.
     * @removed
     */
     */
    public static final int CHARACTER_RECT_TYPE_NOT_FEASIBLE = 4;
    public static final int CHARACTER_RECT_TYPE_NOT_FEASIBLE = 4;


@@ -119,7 +139,7 @@ public final class CursorAnchorInfo implements Parcelable {
        mSelectionEnd = source.readInt();
        mSelectionEnd = source.readInt();
        mComposingTextStart = source.readInt();
        mComposingTextStart = source.readInt();
        mComposingText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mComposingText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mInsertionMarkerClipped = (source.readInt() != 0);
        mInsertionMarkerFlags = source.readInt();
        mInsertionMarkerHorizontal = source.readFloat();
        mInsertionMarkerHorizontal = source.readFloat();
        mInsertionMarkerTop = source.readFloat();
        mInsertionMarkerTop = source.readFloat();
        mInsertionMarkerBaseline = source.readFloat();
        mInsertionMarkerBaseline = source.readFloat();
@@ -141,7 +161,7 @@ public final class CursorAnchorInfo implements Parcelable {
        dest.writeInt(mSelectionEnd);
        dest.writeInt(mSelectionEnd);
        dest.writeInt(mComposingTextStart);
        dest.writeInt(mComposingTextStart);
        TextUtils.writeToParcel(mComposingText, dest, flags);
        TextUtils.writeToParcel(mComposingText, dest, flags);
        dest.writeInt(mInsertionMarkerClipped ? 1 : 0);
        dest.writeInt(mInsertionMarkerFlags);
        dest.writeFloat(mInsertionMarkerHorizontal);
        dest.writeFloat(mInsertionMarkerHorizontal);
        dest.writeFloat(mInsertionMarkerTop);
        dest.writeFloat(mInsertionMarkerTop);
        dest.writeFloat(mInsertionMarkerBaseline);
        dest.writeFloat(mInsertionMarkerBaseline);
@@ -159,7 +179,7 @@ public final class CursorAnchorInfo implements Parcelable {
                + mInsertionMarkerBaseline + mInsertionMarkerBottom;
                + mInsertionMarkerBaseline + mInsertionMarkerBottom;
        int hash = floatHash > 0 ? (int) floatHash : (int)(-floatHash);
        int hash = floatHash > 0 ? (int) floatHash : (int)(-floatHash);
        hash *= 31;
        hash *= 31;
        hash += (mInsertionMarkerClipped ? 2 : 1);
        hash += mInsertionMarkerFlags;
        hash *= 31;
        hash *= 31;
        hash += mSelectionStart + mSelectionEnd + mComposingTextStart;
        hash += mSelectionStart + mSelectionEnd + mComposingTextStart;
        hash *= 31;
        hash *= 31;
@@ -204,7 +224,7 @@ public final class CursorAnchorInfo implements Parcelable {
                || !Objects.equals(mComposingText, that.mComposingText)) {
                || !Objects.equals(mComposingText, that.mComposingText)) {
            return false;
            return false;
        }
        }
        if (mInsertionMarkerClipped != that.mInsertionMarkerClipped
        if (mInsertionMarkerFlags != that.mInsertionMarkerFlags
                || !areSameFloatImpl(mInsertionMarkerHorizontal, that.mInsertionMarkerHorizontal)
                || !areSameFloatImpl(mInsertionMarkerHorizontal, that.mInsertionMarkerHorizontal)
                || !areSameFloatImpl(mInsertionMarkerTop, that.mInsertionMarkerTop)
                || !areSameFloatImpl(mInsertionMarkerTop, that.mInsertionMarkerTop)
                || !areSameFloatImpl(mInsertionMarkerBaseline, that.mInsertionMarkerBaseline)
                || !areSameFloatImpl(mInsertionMarkerBaseline, that.mInsertionMarkerBaseline)
@@ -225,7 +245,7 @@ public final class CursorAnchorInfo implements Parcelable {
        return "SelectionInfo{mSelection=" + mSelectionStart + "," + mSelectionEnd
        return "SelectionInfo{mSelection=" + mSelectionStart + "," + mSelectionEnd
                + " mComposingTextStart=" + mComposingTextStart
                + " mComposingTextStart=" + mComposingTextStart
                + " mComposingText=" + Objects.toString(mComposingText)
                + " mComposingText=" + Objects.toString(mComposingText)
                + " mInsertionMarkerClipped=" + mInsertionMarkerClipped
                + " mInsertionMarkerFlags=" + mInsertionMarkerFlags
                + " mInsertionMarkerHorizontal=" + mInsertionMarkerHorizontal
                + " mInsertionMarkerHorizontal=" + mInsertionMarkerHorizontal
                + " mInsertionMarkerTop=" + mInsertionMarkerTop
                + " mInsertionMarkerTop=" + mInsertionMarkerTop
                + " mInsertionMarkerBaseline=" + mInsertionMarkerBaseline
                + " mInsertionMarkerBaseline=" + mInsertionMarkerBaseline
@@ -271,6 +291,20 @@ public final class CursorAnchorInfo implements Parcelable {
        private int mComposingTextStart = -1;
        private int mComposingTextStart = -1;
        private CharSequence mComposingText = null;
        private CharSequence mComposingText = null;


        /**
         * @removed
         */
        public Builder setInsertionMarkerLocation(final float horizontalPosition,
                final float lineTop, final float lineBaseline, final float lineBottom,
                final boolean clipped){
            mInsertionMarkerHorizontal = horizontalPosition;
            mInsertionMarkerTop = lineTop;
            mInsertionMarkerBaseline = lineBaseline;
            mInsertionMarkerBottom = lineBottom;
            mInsertionMarkerFlags = clipped ? FLAG_HAS_INVISIBLE_REGION : 0;
            return this;
        }

        /**
        /**
         * Sets the location of the text insertion point (zero width cursor) as a rectangle in
         * Sets the location of the text insertion point (zero width cursor) as a rectangle in
         * local coordinates. Calling this can be skipped when there is no text insertion point;
         * local coordinates. Calling this can be skipped when there is no text insertion point;
@@ -288,24 +322,24 @@ public final class CursorAnchorInfo implements Parcelable {
         * @param lineBottom vertical position of the insertion marker, in the local coordinates
         * @param lineBottom vertical position of the insertion marker, in the local coordinates
         * that will be transformed with the transformation matrix when rendered on the screen. This
         * that will be transformed with the transformation matrix when rendered on the screen. This
         * should be calculated or compatible with {@link Layout#getLineBottom(int)}.
         * should be calculated or compatible with {@link Layout#getLineBottom(int)}.
         * @param clipped {@code true} is the insertion marker is partially or entierly clipped by
         * @param flags flags of the insertion marker. See {@link #FLAG_HAS_VISIBLE_REGION} for
         * other UI elements.
         * example.
         */
         */
        public Builder setInsertionMarkerLocation(final float horizontalPosition,
        public Builder setInsertionMarkerLocation(final float horizontalPosition,
                final float lineTop, final float lineBaseline, final float lineBottom,
                final float lineTop, final float lineBaseline, final float lineBottom,
                final boolean clipped){
                final int flags){
            mInsertionMarkerHorizontal = horizontalPosition;
            mInsertionMarkerHorizontal = horizontalPosition;
            mInsertionMarkerTop = lineTop;
            mInsertionMarkerTop = lineTop;
            mInsertionMarkerBaseline = lineBaseline;
            mInsertionMarkerBaseline = lineBaseline;
            mInsertionMarkerBottom = lineBottom;
            mInsertionMarkerBottom = lineBottom;
            mInsertionMarkerClipped = clipped;
            mInsertionMarkerFlags = flags;
            return this;
            return this;
        }
        }
        private float mInsertionMarkerHorizontal = Float.NaN;
        private float mInsertionMarkerHorizontal = Float.NaN;
        private float mInsertionMarkerTop = Float.NaN;
        private float mInsertionMarkerTop = Float.NaN;
        private float mInsertionMarkerBaseline = Float.NaN;
        private float mInsertionMarkerBaseline = Float.NaN;
        private float mInsertionMarkerBottom = Float.NaN;
        private float mInsertionMarkerBottom = Float.NaN;
        private boolean mInsertionMarkerClipped = false;
        private int mInsertionMarkerFlags = 0;


        /**
        /**
         * Adds the bounding box of the character specified with the index.
         * Adds the bounding box of the character specified with the index.
@@ -320,8 +354,8 @@ public final class CursorAnchorInfo implements Parcelable {
         * coordinates, that is, right edge for LTR text and left edge for RTL text.
         * coordinates, that is, right edge for LTR text and left edge for RTL text.
         * @param trailingEdgeY y coordinate of the trailing edge of the character in local
         * @param trailingEdgeY y coordinate of the trailing edge of the character in local
         * coordinates.
         * coordinates.
         * @param flags type and flags for this character. See
         * @param flags flags for this character rect. See {@link #FLAG_HAS_VISIBLE_REGION} for
         * {@link #CHARACTER_RECT_TYPE_FULLY_VISIBLE} for example.
         * example.
         * @throws IllegalArgumentException If the index is a negative value, or not greater than
         * @throws IllegalArgumentException If the index is a negative value, or not greater than
         * all of the previously called indices.
         * all of the previously called indices.
         */
         */
@@ -331,11 +365,6 @@ public final class CursorAnchorInfo implements Parcelable {
            if (index < 0) {
            if (index < 0) {
                throw new IllegalArgumentException("index must not be a negative integer.");
                throw new IllegalArgumentException("index must not be a negative integer.");
            }
            }
            final int type = flags & CHARACTER_RECT_TYPE_MASK;
            if (type == CHARACTER_RECT_TYPE_UNSPECIFIED) {
                throw new IllegalArgumentException("Type except for "
                        + "CHARACTER_RECT_TYPE_UNSPECIFIED must be specified.");
            }
            if (mCharacterRectBuilder == null) {
            if (mCharacterRectBuilder == null) {
                mCharacterRectBuilder = new SparseRectFArrayBuilder();
                mCharacterRectBuilder = new SparseRectFArrayBuilder();
            }
            }
@@ -388,7 +417,7 @@ public final class CursorAnchorInfo implements Parcelable {
            mSelectionEnd = -1;
            mSelectionEnd = -1;
            mComposingTextStart = -1;
            mComposingTextStart = -1;
            mComposingText = null;
            mComposingText = null;
            mInsertionMarkerClipped = false;
            mInsertionMarkerFlags = 0;
            mInsertionMarkerHorizontal = Float.NaN;
            mInsertionMarkerHorizontal = Float.NaN;
            mInsertionMarkerTop = Float.NaN;
            mInsertionMarkerTop = Float.NaN;
            mInsertionMarkerBaseline = Float.NaN;
            mInsertionMarkerBaseline = Float.NaN;
@@ -406,7 +435,7 @@ public final class CursorAnchorInfo implements Parcelable {
        mSelectionEnd = builder.mSelectionEnd;
        mSelectionEnd = builder.mSelectionEnd;
        mComposingTextStart = builder.mComposingTextStart;
        mComposingTextStart = builder.mComposingTextStart;
        mComposingText = builder.mComposingText;
        mComposingText = builder.mComposingText;
        mInsertionMarkerClipped = builder.mInsertionMarkerClipped;
        mInsertionMarkerFlags = builder.mInsertionMarkerFlags;
        mInsertionMarkerHorizontal = builder.mInsertionMarkerHorizontal;
        mInsertionMarkerHorizontal = builder.mInsertionMarkerHorizontal;
        mInsertionMarkerTop = builder.mInsertionMarkerTop;
        mInsertionMarkerTop = builder.mInsertionMarkerTop;
        mInsertionMarkerBaseline = builder.mInsertionMarkerBaseline;
        mInsertionMarkerBaseline = builder.mInsertionMarkerBaseline;
@@ -448,12 +477,21 @@ public final class CursorAnchorInfo implements Parcelable {
        return mComposingText;
        return mComposingText;
    }
    }


    /**
     * Returns the flag of the insertion marker.
     * @return the flag of the insertion marker. {@code 0} if no flag is specified.
     */
    public int getInsertionMarkerFlags() {
        return mInsertionMarkerFlags;
    }

    /**
    /**
     * Returns the visibility of the insertion marker.
     * Returns the visibility of the insertion marker.
     * @return {@code true} if the insertion marker is partially or entirely clipped.
     * @return {@code true} if the insertion marker is partially or entirely clipped.
     * @removed
     */
     */
    public boolean isInsertionMarkerClipped() {
    public boolean isInsertionMarkerClipped() {
        return mInsertionMarkerClipped;
        return (mInsertionMarkerFlags & FLAG_HAS_VISIBLE_REGION) != 0;
    }
    }


    /**
    /**
@@ -522,17 +560,17 @@ public final class CursorAnchorInfo implements Parcelable {
    }
    }


    /**
    /**
     * Returns the flags associated with the character specified with the index.
     * Returns the flags associated with the character rect specified with the index.
     * @param index index of the character in a Java chars.
     * @param index index of the character in a Java chars.
     * @return {@link #CHARACTER_RECT_TYPE_UNSPECIFIED} if no flag is specified.
     * @return {@code 0} if no flag is specified.
     */
     */
    // TODO: Prepare a document about the expected behavior for surrogate pairs, combining
    // TODO: Prepare a document about the expected behavior for surrogate pairs, combining
    // characters, and non-graphical chars.
    // characters, and non-graphical chars.
    public int getCharacterRectFlags(final int index) {
    public int getCharacterRectFlags(final int index) {
        if (mCharacterRects == null) {
        if (mCharacterRects == null) {
            return CHARACTER_RECT_TYPE_UNSPECIFIED;
            return 0;
        }
        }
        return mCharacterRects.getFlags(index, CHARACTER_RECT_TYPE_UNSPECIFIED);
        return mCharacterRects.getFlags(index, 0);
    }
    }


    /**
    /**
+18 −11
Original line number Original line Diff line number Diff line
@@ -3089,13 +3089,12 @@ public class Editor {
                    final boolean isLeadingEdgeTopVisible = isPositionVisible(leadingEdgeX, top);
                    final boolean isLeadingEdgeTopVisible = isPositionVisible(leadingEdgeX, top);
                    final boolean isTrailingEdgeBottomVisible =
                    final boolean isTrailingEdgeBottomVisible =
                            isPositionVisible(trailingEdgeX, bottom);
                            isPositionVisible(trailingEdgeX, bottom);
                    final int characterRectFlags;
                    int characterRectFlags = 0;
                    if (isLeadingEdgeTopVisible && isTrailingEdgeBottomVisible) {
                    if (isLeadingEdgeTopVisible || isTrailingEdgeBottomVisible) {
                        characterRectFlags = CursorAnchorInfo.CHARACTER_RECT_TYPE_FULLY_VISIBLE;
                        characterRectFlags |= CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION;
                    } else if (isLeadingEdgeTopVisible || isTrailingEdgeBottomVisible) {
                    }
                        characterRectFlags = CursorAnchorInfo.CHARACTER_RECT_TYPE_PARTIALLY_VISIBLE;
                    if (!isLeadingEdgeTopVisible || !isTrailingEdgeBottomVisible) {
                    } else {
                        characterRectFlags |= CursorAnchorInfo.FLAG_HAS_INVISIBLE_REGION;
                        characterRectFlags = CursorAnchorInfo.CHARACTER_RECT_TYPE_INVISIBLE;
                    }
                    }
                    // Here offset is the index in Java chars.
                    // Here offset is the index in Java chars.
                    // TODO: We must have a well-defined specification. For example, how
                    // TODO: We must have a well-defined specification. For example, how
@@ -3117,11 +3116,19 @@ public class Editor {
                        + viewportToContentVerticalOffset;
                        + viewportToContentVerticalOffset;
                final float insertionMarkerBottom = layout.getLineBottom(line)
                final float insertionMarkerBottom = layout.getLineBottom(line)
                        + viewportToContentVerticalOffset;
                        + viewportToContentVerticalOffset;
                // Take TextView's padding and scroll into account.
                final boolean isTopVisible =
                final boolean isClipped = !isPositionVisible(insertionMarkerX, insertionMarkerTop)
                        isPositionVisible(insertionMarkerX, insertionMarkerTop);
                        || !isPositionVisible(insertionMarkerX, insertionMarkerBottom);
                final boolean isBottomVisible =
                        isPositionVisible(insertionMarkerX, insertionMarkerBottom);
                int insertionMarkerFlags = 0;
                if (isTopVisible || isBottomVisible) {
                    insertionMarkerFlags |= CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION;
                }
                if (!isTopVisible || !isBottomVisible) {
                    insertionMarkerFlags |= CursorAnchorInfo.FLAG_HAS_INVISIBLE_REGION;
                }
                builder.setInsertionMarkerLocation(insertionMarkerX, insertionMarkerTop,
                builder.setInsertionMarkerLocation(insertionMarkerX, insertionMarkerTop,
                        insertionMarkerBaseline, insertionMarkerBottom, isClipped);
                        insertionMarkerBaseline, insertionMarkerBottom, insertionMarkerFlags);
            }
            }


            imm.updateCursorAnchorInfo(mTextView, builder.build());
            imm.updateCursorAnchorInfo(mTextView, builder.build());