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

Commit c46b5f04 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Rename CursorAnchorInfoBuilder with Builder

Inner Builder class should not inherit full class name of outer
class.

BUG: 15516230
Change-Id: I2d56edebb0c85639db57ca5b2aadb22c67fc5926
parent cbb0213d
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -33917,15 +33917,15 @@ package android.view.inputmethod {
    field public static final android.os.Parcelable.Creator CREATOR;
  }
  public static final class CursorAnchorInfo.CursorAnchorInfoBuilder {
    ctor public CursorAnchorInfo.CursorAnchorInfoBuilder();
    method public android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder addCharacterRect(int, float, float, float, float);
  public static final class CursorAnchorInfo.Builder {
    ctor public CursorAnchorInfo.Builder();
    method public android.view.inputmethod.CursorAnchorInfo.Builder addCharacterRect(int, float, float, float, float);
    method public android.view.inputmethod.CursorAnchorInfo build();
    method public void reset();
    method public android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder setComposingText(int, java.lang.CharSequence);
    method public android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder setInsertionMarkerLocation(float, float, float, float);
    method public android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder setMatrix(android.graphics.Matrix);
    method public android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder setSelectionRange(int, int);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setComposingText(int, java.lang.CharSequence);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setInsertionMarkerLocation(float, float, float, float);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setMatrix(android.graphics.Matrix);
    method public android.view.inputmethod.CursorAnchorInfo.Builder setSelectionRange(int, int);
  }
  public class EditorInfo implements android.text.InputType android.os.Parcelable {
+10 −13
Original line number Diff line number Diff line
@@ -186,12 +186,12 @@ public final class CursorAnchorInfo implements Parcelable {
    /**
     * Builder for {@link CursorAnchorInfo}. This class is not designed to be thread-safe.
     */
    public static final class CursorAnchorInfoBuilder {
    public static final class Builder {
        /**
         * Sets the text range of the selection. Calling this can be skipped if there is no
         * selection.
         */
        public CursorAnchorInfoBuilder setSelectionRange(final int newStart, final int newEnd) {
        public Builder setSelectionRange(final int newStart, final int newEnd) {
            mSelectionStart = newStart;
            mSelectionEnd = newEnd;
            return this;
@@ -205,8 +205,7 @@ public final class CursorAnchorInfo implements Parcelable {
         * @param index index where the composing text starts.
         * @param composingText the entire composing text.
         */
        public CursorAnchorInfoBuilder setComposingText(final int index,
                final CharSequence composingText) {
        public Builder setComposingText(final int index, final CharSequence composingText) {
            mComposingTextStart = index;
            if (composingText == null) {
                mComposingText = null;
@@ -236,9 +235,8 @@ public final class CursorAnchorInfo implements Parcelable {
         * that will be transformed with the transformation matrix when rendered on the screen. This
         * should be calculated or compatible with {@link Layout#getLineBottom(int)}.
         */
        public CursorAnchorInfoBuilder setInsertionMarkerLocation(
                final float horizontalPosition, final float lineTop, final float lineBaseline,
                final float lineBottom){
        public Builder setInsertionMarkerLocation(final float horizontalPosition,
                final float lineTop, final float lineBaseline, final float lineBottom){
            mInsertionMarkerHorizontal = horizontalPosition;
            mInsertionMarkerTop = lineTop;
            mInsertionMarkerBaseline = lineBaseline;
@@ -269,9 +267,8 @@ public final class CursorAnchorInfo implements Parcelable {
         * @throws IllegalArgumentException If the index is a negative value, or not greater than
         * all of the previously called indices.
         */
        public CursorAnchorInfoBuilder addCharacterRect(final int index,
                final float leadingEdgeX, final float leadingEdgeY, final float trailingEdgeX,
                final float trailingEdgeY) {
        public Builder addCharacterRect(final int index, final float leadingEdgeX,
                final float leadingEdgeY, final float trailingEdgeX, final float trailingEdgeY) {
            if (index < 0) {
                throw new IllegalArgumentException("index must not be a negative integer.");
            }
@@ -289,7 +286,7 @@ public final class CursorAnchorInfo implements Parcelable {
         * @param matrix transformation matrix from local coordinates into screen coordinates. null
         * is interpreted as an identity matrix.
         */
        public CursorAnchorInfoBuilder setMatrix(final Matrix matrix) {
        public Builder setMatrix(final Matrix matrix) {
            mMatrix.set(matrix != null ? matrix : Matrix.IDENTITY_MATRIX);
            return this;
        }
@@ -297,7 +294,7 @@ public final class CursorAnchorInfo implements Parcelable {

        /**
         * @return {@link CursorAnchorInfo} using parameters in this
         * {@link CursorAnchorInfoBuilder}.
         * {@link Builder}.
         */
        public CursorAnchorInfo build() {
            return new CursorAnchorInfo(this);
@@ -323,7 +320,7 @@ public final class CursorAnchorInfo implements Parcelable {
        }
    }

    private CursorAnchorInfo(final CursorAnchorInfoBuilder builder) {
    private CursorAnchorInfo(final Builder builder) {
        mSelectionStart = builder.mSelectionStart;
        mSelectionEnd = builder.mSelectionEnd;
        mComposingTextStart = builder.mComposingTextStart;
+2 −3
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.inputmethod.CorrectionInfo;
import android.view.inputmethod.CursorAnchorInfo;
import android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
@@ -3013,7 +3012,7 @@ public class Editor {
     * {@link InputMethodManager#isWatchingCursor(View)} returns false.
     */
    private final class CursorAnchorInfoNotifier implements TextViewPositionListener {
        final CursorAnchorInfoBuilder mSelectionInfoBuilder = new CursorAnchorInfoBuilder();
        final CursorAnchorInfo.Builder mSelectionInfoBuilder = new CursorAnchorInfo.Builder();
        final int[] mTmpIntOffset = new int[2];
        final Matrix mViewToScreenMatrix = new Matrix();

@@ -3037,7 +3036,7 @@ public class Editor {
                return;
            }

            final CursorAnchorInfoBuilder builder = mSelectionInfoBuilder;
            final CursorAnchorInfo.Builder builder = mSelectionInfoBuilder;
            builder.reset();

            final int selectionStart = mTextView.getSelectionStart();
+4 −5
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import android.graphics.RectF;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.CursorAnchorInfo;
import android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder;
import android.view.inputmethod.CursorAnchorInfo.Builder;

public class CursorAnchorInfoTest extends InstrumentationTestCase {
    // null represents a character that is invisible, for example because it's overlapped by some
@@ -64,7 +64,7 @@ public class CursorAnchorInfoTest extends InstrumentationTestCase {
        Matrix TRANSFORM_MATRIX = new Matrix(Matrix.IDENTITY_MATRIX);
        TRANSFORM_MATRIX.setScale(10.0f, 20.0f);

        final CursorAnchorInfoBuilder builder = new CursorAnchorInfoBuilder();
        final Builder builder = new Builder();
        builder.setSelectionRange(SELECTION_START, SELECTION_END)
                .setComposingText(COMPOSING_TEXT_START, COMPOSING_TEXT)
                .setInsertionMarkerLocation(INSERTION_MARKER_HORIZONTAL, INSERTION_MARKER_TOP,
@@ -148,7 +148,7 @@ public class CursorAnchorInfoTest extends InstrumentationTestCase {
        final Matrix MATRIX3 = new Matrix();
        MATRIX3.setTranslate(210.0f, 220.0f);
        final Matrix matrix = new Matrix();
        final CursorAnchorInfoBuilder builder = new CursorAnchorInfoBuilder();
        final Builder builder = new Builder();

        matrix.set(MATRIX1);
        builder.setMatrix(matrix);
@@ -171,7 +171,7 @@ public class CursorAnchorInfoTest extends InstrumentationTestCase {
    public void testBuilderAdd() throws Exception {
        // A negative index should be rejected.
        try {
            new CursorAnchorInfoBuilder().addCharacterRect(-1, 0.0f, 0.0f, 0.0f, 0.0f);
            new Builder().addCharacterRect(-1, 0.0f, 0.0f, 0.0f, 0.0f);
        } catch (IllegalArgumentException ex) {
            assertTrue(true);
        }
@@ -191,4 +191,3 @@ public class CursorAnchorInfoTest extends InstrumentationTestCase {
        }
    }
}