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

Commit cf19ed31 authored by Haoyu Zhang's avatar Haoyu Zhang Committed by Android (Google) Code Review
Browse files

Merge "Address API feedbacks for TextBoundsInfo"

parents 18bd9c45 3b47b248
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -46637,8 +46637,8 @@ package android.text {
    field public static final int DONE = -1; // 0xffffffff
    field public static final int DONE = -1; // 0xffffffff
  }
  }
  public static class SegmentFinder.DefaultSegmentFinder extends android.text.SegmentFinder {
  public static class SegmentFinder.PrescribedSegmentFinder extends android.text.SegmentFinder {
    ctor public SegmentFinder.DefaultSegmentFinder(@NonNull int[]);
    ctor public SegmentFinder.PrescribedSegmentFinder(@NonNull int[]);
    method public int nextEndBoundary(@IntRange(from=0) int);
    method public int nextEndBoundary(@IntRange(from=0) int);
    method public int nextStartBoundary(@IntRange(from=0) int);
    method public int nextStartBoundary(@IntRange(from=0) int);
    method public int previousEndBoundary(@IntRange(from=0) int);
    method public int previousEndBoundary(@IntRange(from=0) int);
@@ -55099,15 +55099,15 @@ package android.view.inputmethod {
  public final class TextBoundsInfo implements android.os.Parcelable {
  public final class TextBoundsInfo implements android.os.Parcelable {
    method public int describeContents();
    method public int describeContents();
    method @IntRange(from=0, to=125) public int getCharacterBidiLevel(int);
    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 getCharacterFlags(int);
    method public int getEnd();
    method public int getEndIndex();
    method @NonNull public android.text.SegmentFinder getGraphemeSegmentFinder();
    method @NonNull public android.text.SegmentFinder getGraphemeSegmentFinder();
    method @NonNull public android.text.SegmentFinder getLineSegmentFinder();
    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 public int getOffsetForPosition(float, float);
    method @Nullable public int[] getRangeForRect(@NonNull android.graphics.RectF, @NonNull android.text.SegmentFinder, @NonNull android.text.Layout.TextInclusionStrategy);
    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 @NonNull public android.text.SegmentFinder getWordSegmentFinder();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.TextBoundsInfo> CREATOR;
    field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.TextBoundsInfo> CREATOR;
@@ -55118,7 +55118,7 @@ package android.view.inputmethod {
  }
  }
  public static final class TextBoundsInfo.Builder {
  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 build();
    method @NonNull public android.view.inputmethod.TextBoundsInfo.Builder clear();
    method @NonNull public android.view.inputmethod.TextBoundsInfo.Builder clear();
    method @NonNull public android.view.inputmethod.TextBoundsInfo.Builder setCharacterBidiLevel(@NonNull int[]);
    method @NonNull public android.view.inputmethod.TextBoundsInfo.Builder setCharacterBidiLevel(@NonNull int[]);
+3 −3
Original line number Original line Diff line number Diff line
@@ -767,20 +767,20 @@ final class IRemoteInputConnectionInvoker {
    /**
    /**
     * Invokes {@link IRemoteInputConnection#requestTextBoundsInfo(InputConnectionCommandHeader,
     * Invokes {@link IRemoteInputConnection#requestTextBoundsInfo(InputConnectionCommandHeader,
     * RectF, ResultReceiver)}
     * 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 executor {@code Executor} parameter to be passed.
     * @param consumer {@code Consumer} parameter to be passed.
     * @param consumer {@code Consumer} parameter to be passed.
     */
     */
    @AnyThread
    @AnyThread
    public void requestTextBoundsInfo(
    public void requestTextBoundsInfo(
            @NonNull RectF rectF, @NonNull @CallbackExecutor Executor executor,
            @NonNull RectF bounds, @NonNull @CallbackExecutor Executor executor,
            @NonNull Consumer<TextBoundsInfoResult> consumer) {
            @NonNull Consumer<TextBoundsInfoResult> consumer) {
        Objects.requireNonNull(executor);
        Objects.requireNonNull(executor);
        Objects.requireNonNull(consumer);
        Objects.requireNonNull(consumer);


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


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


    @AnyThread
    @AnyThread
+2 −2
Original line number Original line Diff line number Diff line
@@ -74,7 +74,7 @@ public abstract class SegmentFinder {
    /**
    /**
     * The default {@link SegmentFinder} implementation based on given segment ranges.
     * 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;
        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
         * @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.
         * given segments are not sorted or there are segments overlap with others.
         */
         */
        public DefaultSegmentFinder(@NonNull int[] segments) {
        public PrescribedSegmentFinder(@NonNull int[] segments) {
            checkSegmentsValid(segments);
            checkSegmentsValid(segments);
            mSegments = segments;
            mSegments = segments;
        }
        }
+4 −4
Original line number Original line 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
     * 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 -
     * method to implement the handwriting gesture API -
     * {@link #performHandwritingGesture(HandwritingGesture, Executor, IntConsumer)}.
     * {@link #performHandwritingGesture(HandwritingGesture, Executor, IntConsumer)}.
     *
     *
     * <p><strong>Editor authors</strong>: It's preferred that the editor returns a
     * <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
     * {@link TextBoundsInfo} of all the text lines whose bounds intersect with the given
     * {@code rectF}.
     * {@code bounds}.
     * </p>
     * </p>
     *
     *
     * <p><strong>IME authors</strong>: This method is expensive when the text is long. Please
     * <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.
     * consuming. It's preferable to only request text bounds in smaller areas.
     * </p>
     * </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.
     *              coordinates.
     * @param executor the executor to run the callback.
     * @param executor the executor to run the callback.
     * @param consumer the callback invoked by editor to return the result. It must return a
     * @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
     * @see android.view.inputmethod.TextBoundsInfoResult
     */
     */
    default void requestTextBoundsInfo(
    default void requestTextBoundsInfo(
            @NonNull RectF rectF, @NonNull @CallbackExecutor Executor executor,
            @NonNull RectF bounds, @NonNull @CallbackExecutor Executor executor,
            @NonNull Consumer<TextBoundsInfoResult> consumer) {
            @NonNull Consumer<TextBoundsInfoResult> consumer) {
        Objects.requireNonNull(executor);
        Objects.requireNonNull(executor);
        Objects.requireNonNull(consumer);
        Objects.requireNonNull(consumer);
Loading