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

Commit 3b47b248 authored by Haoyu Zhang's avatar Haoyu Zhang
Browse files

Address API feedbacks for TextBoundsInfo

Bug: 262452997
Bug: 265068032
Test: atest TextBoundsInfoTest
Test: atest TextBoundsInfoMethodTest
Test: atest TextViewTextBoundsInfoTest
Change-Id: I2105efc8a90fee7f11d5c534c18e659d821abf1c
parent 584871ea
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -46612,8 +46612,8 @@ package android.text {
    field public static final int DONE = -1; // 0xffffffff
  }
  public static class SegmentFinder.DefaultSegmentFinder extends android.text.SegmentFinder {
    ctor public SegmentFinder.DefaultSegmentFinder(@NonNull int[]);
  public static class SegmentFinder.PrescribedSegmentFinder extends android.text.SegmentFinder {
    ctor public SegmentFinder.PrescribedSegmentFinder(@NonNull int[]);
    method public int nextEndBoundary(@IntRange(from=0) int);
    method public int nextStartBoundary(@IntRange(from=0) int);
    method public int previousEndBoundary(@IntRange(from=0) int);
@@ -55079,15 +55079,15 @@ package android.view.inputmethod {
  public final class TextBoundsInfo implements android.os.Parcelable {
    method public int describeContents();
    method @IntRange(from=0, to=125) public int getCharacterBidiLevel(int);
    method @NonNull public android.graphics.RectF getCharacterBounds(int);
    method @NonNull public void getCharacterBounds(int, @NonNull android.graphics.RectF);
    method public int getCharacterFlags(int);
    method public int getEnd();
    method public int getEndIndex();
    method @NonNull public android.text.SegmentFinder getGraphemeSegmentFinder();
    method @NonNull public android.text.SegmentFinder getLineSegmentFinder();
    method @NonNull public android.graphics.Matrix getMatrix();
    method @NonNull public void getMatrix(@NonNull android.graphics.Matrix);
    method public int getOffsetForPosition(float, float);
    method @Nullable public int[] getRangeForRect(@NonNull android.graphics.RectF, @NonNull android.text.SegmentFinder, @NonNull android.text.Layout.TextInclusionStrategy);
    method public int getStart();
    method public int getStartIndex();
    method @NonNull public android.text.SegmentFinder getWordSegmentFinder();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.TextBoundsInfo> CREATOR;
@@ -55098,7 +55098,7 @@ package android.view.inputmethod {
  }
  public static final class TextBoundsInfo.Builder {
    ctor public TextBoundsInfo.Builder();
    ctor public TextBoundsInfo.Builder(int, int);
    method @NonNull public android.view.inputmethod.TextBoundsInfo build();
    method @NonNull public android.view.inputmethod.TextBoundsInfo.Builder clear();
    method @NonNull public android.view.inputmethod.TextBoundsInfo.Builder setCharacterBidiLevel(@NonNull int[]);
+3 −3
Original line number Diff line number Diff line
@@ -767,20 +767,20 @@ final class IRemoteInputConnectionInvoker {
    /**
     * Invokes {@link IRemoteInputConnection#requestTextBoundsInfo(InputConnectionCommandHeader,
     * RectF, ResultReceiver)}
     * @param rectF {@code rectF} parameter to be passed.
     * @param bounds {@code rectF} parameter to be passed.
     * @param executor {@code Executor} parameter to be passed.
     * @param consumer {@code Consumer} parameter to be passed.
     */
    @AnyThread
    public void requestTextBoundsInfo(
            @NonNull RectF rectF, @NonNull @CallbackExecutor Executor executor,
            @NonNull RectF bounds, @NonNull @CallbackExecutor Executor executor,
            @NonNull Consumer<TextBoundsInfoResult> consumer) {
        Objects.requireNonNull(executor);
        Objects.requireNonNull(consumer);

        final ResultReceiver resultReceiver = new TextBoundsInfoResultReceiver(executor, consumer);
        try {
            mConnection.requestTextBoundsInfo(createHeader(), rectF, resultReceiver);
            mConnection.requestTextBoundsInfo(createHeader(), bounds, resultReceiver);
        } catch (RemoteException e) {
            executor.execute(() -> consumer.accept(new TextBoundsInfoResult(CODE_CANCELLED)));
        }
+2 −2
Original line number Diff line number Diff line
@@ -476,9 +476,9 @@ final class RemoteInputConnection implements InputConnection {

    @AnyThread
    public void requestTextBoundsInfo(
            @NonNull RectF rectF, @NonNull @CallbackExecutor Executor executor,
            @NonNull RectF bounds, @NonNull @CallbackExecutor Executor executor,
            @NonNull Consumer<TextBoundsInfoResult> consumer) {
        mInvoker.requestTextBoundsInfo(rectF, executor, consumer);
        mInvoker.requestTextBoundsInfo(bounds, executor, consumer);
    }

    @AnyThread
+2 −2
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ public abstract class SegmentFinder {
    /**
     * The default {@link SegmentFinder} implementation based on given segment ranges.
     */
    public static class DefaultSegmentFinder extends SegmentFinder {
    public static class PrescribedSegmentFinder extends SegmentFinder {
        private final int[] mSegments;

        /**
@@ -87,7 +87,7 @@ public abstract class SegmentFinder {
         * @throws IllegalArgumentException if the given segments array's length is not even; the
         * given segments are not sorted or there are segments overlap with others.
         */
        public DefaultSegmentFinder(@NonNull int[] segments) {
        public PrescribedSegmentFinder(@NonNull int[] segments) {
            checkSegmentsValid(segments);
            mSegments = segments;
        }
+4 −4
Original line number Diff line number Diff line
@@ -1262,13 +1262,13 @@ public interface InputConnection {

    /**
     * Called by input method to request the {@link TextBoundsInfo} for a range of text which is
     * covered by or in vicinity of the given {@code RectF}. It can be used as a supplementary
     * covered by or in vicinity of the given {@code bounds}. It can be used as a supplementary
     * method to implement the handwriting gesture API -
     * {@link #performHandwritingGesture(HandwritingGesture, Executor, IntConsumer)}.
     *
     * <p><strong>Editor authors</strong>: It's preferred that the editor returns a
     * {@link TextBoundsInfo} of all the text lines whose bounds intersect with the given
     * {@code rectF}.
     * {@code bounds}.
     * </p>
     *
     * <p><strong>IME authors</strong>: This method is expensive when the text is long. Please
@@ -1276,7 +1276,7 @@ public interface InputConnection {
     * consuming. It's preferable to only request text bounds in smaller areas.
     * </p>
     *
     * @param rectF the interested area where the text bounds are requested, in the screen
     * @param bounds the interested area where the text bounds are requested, in the screen
     *              coordinates.
     * @param executor the executor to run the callback.
     * @param consumer the callback invoked by editor to return the result. It must return a
@@ -1286,7 +1286,7 @@ public interface InputConnection {
     * @see android.view.inputmethod.TextBoundsInfoResult
     */
    default void requestTextBoundsInfo(
            @NonNull RectF rectF, @NonNull @CallbackExecutor Executor executor,
            @NonNull RectF bounds, @NonNull @CallbackExecutor Executor executor,
            @NonNull Consumer<TextBoundsInfoResult> consumer) {
        Objects.requireNonNull(executor);
        Objects.requireNonNull(consumer);
Loading