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

Commit e4c0e42c authored by Justin Ghan's avatar Justin Ghan Committed by Android (Google) Code Review
Browse files

Merge "APIs for remove space gesture, and join or split gesture"

parents 0ce0e084 d12fdde3
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -53161,7 +53161,9 @@ package android.view.inputmethod {
    method @Nullable public String getFallbackText();
    field public static final int GESTURE_TYPE_DELETE = 4; // 0x4
    field public static final int GESTURE_TYPE_INSERT = 2; // 0x2
    field public static final int GESTURE_TYPE_JOIN_OR_SPLIT = 16; // 0x10
    field public static final int GESTURE_TYPE_NONE = 0; // 0x0
    field public static final int GESTURE_TYPE_REMOVE_SPACE = 8; // 0x8
    field public static final int GESTURE_TYPE_SELECT = 1; // 0x1
    field public static final int GRANULARITY_CHARACTER = 2; // 0x2
    field public static final int GRANULARITY_WORD = 1; // 0x1
@@ -53502,6 +53504,35 @@ package android.view.inputmethod {
    method @NonNull public android.view.inputmethod.InsertGesture.Builder setTextToInsert(@NonNull String);
  }
  public final class JoinOrSplitGesture extends android.view.inputmethod.HandwritingGesture implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public android.graphics.PointF getJoinOrSplitPoint();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.JoinOrSplitGesture> CREATOR;
  }
  public static final class JoinOrSplitGesture.Builder {
    ctor public JoinOrSplitGesture.Builder();
    method @NonNull public android.view.inputmethod.JoinOrSplitGesture build();
    method @NonNull public android.view.inputmethod.JoinOrSplitGesture.Builder setFallbackText(@Nullable String);
    method @NonNull public android.view.inputmethod.JoinOrSplitGesture.Builder setJoinOrSplitPoint(@NonNull android.graphics.PointF);
  }
  public final class RemoveSpaceGesture extends android.view.inputmethod.HandwritingGesture implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public android.graphics.PointF getEndPoint();
    method @NonNull public android.graphics.PointF getStartPoint();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.RemoveSpaceGesture> CREATOR;
  }
  public static final class RemoveSpaceGesture.Builder {
    ctor public RemoveSpaceGesture.Builder();
    method @NonNull public android.view.inputmethod.RemoveSpaceGesture build();
    method @NonNull public android.view.inputmethod.RemoveSpaceGesture.Builder setFallbackText(@Nullable String);
    method @NonNull public android.view.inputmethod.RemoveSpaceGesture.Builder setPoints(@NonNull android.graphics.PointF, @NonNull android.graphics.PointF);
  }
  public final class SelectGesture extends android.view.inputmethod.HandwritingGesture implements android.os.Parcelable {
    method public int describeContents();
    method public int getGranularity();
+13 −10
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import android.view.inputmethod.HandwritingGesture;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputContentInfo;
import android.view.inputmethod.InsertGesture;
import android.view.inputmethod.JoinOrSplitGesture;
import android.view.inputmethod.RemoveSpaceGesture;
import android.view.inputmethod.SelectGesture;
import android.view.inputmethod.SurroundingText;
import android.view.inputmethod.TextAttribute;
@@ -633,16 +635,11 @@ final class IRemoteInputConnectionInvoker {
    }

    /**
     * Invokes one of {@link IRemoteInputConnection#performHandwritingSelectGesture(
     * InputConnectionCommandHeader, SelectGesture, AndroidFuture)},
     * {@link IRemoteInputConnection#performHandwritingDeleteGesture(InputConnectionCommandHeader,
     * DeleteGesture, AndroidFuture)},
     * {@link IRemoteInputConnection#performHandwritingInsertGesture(InputConnectionCommandHeader,
     * InsertGesture, AndroidFuture)}
     *
     * @param {@code gesture} parameter {@link HandwritingGesture}.
     * @return {@link AndroidFuture<Integer>} that can be used to retrieve the invocation
     *         result. {@link RemoteException} will be treated as an error.
     * Invokes one of {@link IRemoteInputConnection#performHandwritingSelectGesture},
     * {@link IRemoteInputConnection#performHandwritingDeleteGesture},
     * {@link IRemoteInputConnection#performHandwritingInsertGesture},
     * {@link IRemoteInputConnection#performHandwritingRemoveSpaceGesture},
     * {@link IRemoteInputConnection#performHandwritingJoinOrSplitGesture}.
     */
    @AnyThread
    public void performHandwritingGesture(
@@ -664,6 +661,12 @@ final class IRemoteInputConnectionInvoker {
            } else if (gesture instanceof DeleteGesture) {
                mConnection.performHandwritingDeleteGesture(
                        createHeader(), (DeleteGesture) gesture, resultReceiver);
            } else if (gesture instanceof RemoveSpaceGesture) {
                mConnection.performHandwritingRemoveSpaceGesture(
                        createHeader(), (RemoveSpaceGesture) gesture, resultReceiver);
            } else if (gesture instanceof JoinOrSplitGesture) {
                mConnection.performHandwritingJoinOrSplitGesture(
                        createHeader(), (JoinOrSplitGesture) gesture, resultReceiver);
            } else if (consumer != null && executor != null) {
                executor.execute(()
                        -> consumer.accept(InputConnection.HANDWRITING_GESTURE_RESULT_UNSUPPORTED));
+2 −2
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ public final class DeleteGesture extends HandwritingGesture implements Parcelabl
     * Returns the deletion area {@link RectF} in screen coordinates.
     *
     * Getter for deletion area set with {@link DeleteGesture.Builder#setDeletionArea(RectF)}.
     * {@code null} if area was not set.
     */
    @NonNull
    public RectF getDeletionArea() {
@@ -145,7 +144,8 @@ public final class DeleteGesture extends HandwritingGesture implements Parcelabl
    /**
     * Used to make this class parcelable.
     */
    public static final @android.annotation.NonNull Creator<DeleteGesture> CREATOR =
    @NonNull
    public static final Creator<DeleteGesture> CREATOR =
            new Creator<DeleteGesture>() {
        @Override
        public DeleteGesture createFromParcel(Parcel source) {
+12 −0
Original line number Diff line number Diff line
@@ -561,6 +561,10 @@ public class EditorInfo implements InputType, Parcelable {
                supportedTypes |= HandwritingGesture.GESTURE_TYPE_INSERT;
            } else if (gesture.equals(DeleteGesture.class)) {
                supportedTypes |= HandwritingGesture.GESTURE_TYPE_DELETE;
            } else if (gesture.equals(RemoveSpaceGesture.class)) {
                supportedTypes |= HandwritingGesture.GESTURE_TYPE_REMOVE_SPACE;
            } else if (gesture.equals(JoinOrSplitGesture.class)) {
                supportedTypes |= HandwritingGesture.GESTURE_TYPE_JOIN_OR_SPLIT;
            } else {
                throw new IllegalArgumentException("Unknown gesture type: " + gesture);
            }
@@ -595,6 +599,14 @@ public class EditorInfo implements InputType, Parcelable {
                == HandwritingGesture.GESTURE_TYPE_DELETE) {
            list.add(DeleteGesture.class);
        }
        if ((mSupportedHandwritingGestureTypes & HandwritingGesture.GESTURE_TYPE_REMOVE_SPACE)
                == HandwritingGesture.GESTURE_TYPE_REMOVE_SPACE) {
            list.add(RemoveSpaceGesture.class);
        }
        if ((mSupportedHandwritingGestureTypes & HandwritingGesture.GESTURE_TYPE_JOIN_OR_SPLIT)
                == HandwritingGesture.GESTURE_TYPE_JOIN_OR_SPLIT) {
            list.add(JoinOrSplitGesture.class);
        }
        return list;
    }

+15 −5
Original line number Diff line number Diff line
@@ -99,6 +99,12 @@ public abstract class HandwritingGesture {
     */
    public static final int GESTURE_TYPE_DELETE = 1 << 2;

    /** Gesture of type {@link RemoveSpaceGesture} to remove whitespace from text. */
    public static final int GESTURE_TYPE_REMOVE_SPACE = 1 << 3;

    /** Gesture of type {@link JoinOrSplitGesture} to join or split text. */
    public static final int GESTURE_TYPE_JOIN_OR_SPLIT = 1 << 4;

    /**
     * Type of gesture like {@link #GESTURE_TYPE_SELECT}, {@link #GESTURE_TYPE_INSERT},
     * or {@link #GESTURE_TYPE_DELETE}.
@@ -107,7 +113,9 @@ public abstract class HandwritingGesture {
            GESTURE_TYPE_NONE,
            GESTURE_TYPE_SELECT,
            GESTURE_TYPE_INSERT,
                GESTURE_TYPE_DELETE})
            GESTURE_TYPE_DELETE,
            GESTURE_TYPE_REMOVE_SPACE,
            GESTURE_TYPE_JOIN_OR_SPLIT})
    @Retention(RetentionPolicy.SOURCE)
    @interface GestureType{}

@@ -121,7 +129,9 @@ public abstract class HandwritingGesture {
    @IntDef(flag = true, prefix = {"GESTURE_TYPE_"}, value = {
            GESTURE_TYPE_SELECT,
            GESTURE_TYPE_INSERT,
            GESTURE_TYPE_DELETE})
            GESTURE_TYPE_DELETE,
            GESTURE_TYPE_REMOVE_SPACE,
            GESTURE_TYPE_JOIN_OR_SPLIT})
    @Retention(RetentionPolicy.SOURCE)
    public @interface GestureTypeFlags{}

Loading