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

Commit ca10f8bb authored by Taran Singh's avatar Taran Singh Committed by Android (Google) Code Review
Browse files

Merge "Incorporate API feedback for Companion widget"

parents 6da24eaf 28dd0b1b
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.MotionEvent.ToolType;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewRootImpl;
@@ -947,7 +948,7 @@ public class InputMethodService extends AbstractInputMethodService {
         * @hide
         */
        @Override
        public void updateEditorToolType(int toolType) {
        public void updateEditorToolType(@ToolType int toolType) {
            onUpdateEditorToolType(toolType);
        }

@@ -3079,10 +3080,13 @@ public class InputMethodService extends AbstractInputMethodService {
     * {@link MotionEvent#getToolType(int)} was used to click the editor.
     * e.g. when toolType is {@link MotionEvent#TOOL_TYPE_STYLUS}, IME may choose to show a
     * companion widget instead of normal virtual keyboard.
     * <p> This method is called after {@link #onStartInput(EditorInfo, boolean)} and before
     * {@link #onStartInputView(EditorInfo, boolean)} when editor was clicked with a known tool
     * type.</p>
     * <p> Default implementation does nothing. </p>
     * @param toolType what {@link MotionEvent#getToolType(int)} was used to click on editor.
     */
    public void onUpdateEditorToolType(int toolType) {
    public void onUpdateEditorToolType(@ToolType int toolType) {
        // Intentionally empty
    }

+10 −3
Original line number Diff line number Diff line
@@ -1509,6 +1509,13 @@ public final class MotionEvent extends InputEvent implements Parcelable {
     */
    public static final int TOOL_TYPE_PALM = 5;

    /** @hide */
    @Retention(SOURCE)
    @IntDef(prefix = { "TOOL_TYPE_" }, value = {
            TOOL_TYPE_UNKNOWN, TOOL_TYPE_FINGER, TOOL_TYPE_STYLUS, TOOL_TYPE_MOUSE,
            TOOL_TYPE_ERASER, TOOL_TYPE_PALM})
    public @interface ToolType {};

    // NOTE: If you add a new tool type here you must also add it to:
    //  native/include/android/input.h

@@ -2422,7 +2429,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
     * @see #TOOL_TYPE_STYLUS
     * @see #TOOL_TYPE_MOUSE
     */
    public final int getToolType(int pointerIndex) {
    public @ToolType int getToolType(int pointerIndex) {
        return nativeGetToolType(mNativePtr, pointerIndex);
    }

@@ -3868,7 +3875,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
     * @return The symbolic name of the specified tool type.
     * @hide
     */
    public static String toolTypeToString(int toolType) {
    public static String toolTypeToString(@ToolType int toolType) {
        String symbolicName = TOOL_TYPE_SYMBOLIC_NAMES.get(toolType);
        return symbolicName != null ? symbolicName : Integer.toString(toolType);
    }
@@ -4361,7 +4368,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
         *
         * @see MotionEvent#getToolType(int)
         */
        public int toolType;
        public @ToolType int toolType;

        /**
         * Resets the pointer properties to their initial values.
+4 −4
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.text.TextUtils;
import android.util.Printer;
import android.util.proto.ProtoOutputStream;
import android.view.MotionEvent;
import android.view.MotionEvent.ToolType;
import android.view.View;
import android.view.autofill.AutofillId;

@@ -639,8 +640,7 @@ public class EditorInfo implements InputType, Parcelable {
     * Initial {@link MotionEvent#ACTION_UP} tool type {@link MotionEvent#getToolType(int)} that
     * was used to focus this editor.
     */
    private int mInitialToolType = MotionEvent.TOOL_TYPE_UNKNOWN;

    private @ToolType int mInitialToolType = MotionEvent.TOOL_TYPE_UNKNOWN;

    /**
     * Editors may use this method to provide initial input text to IMEs. As the surrounding text
@@ -1022,7 +1022,7 @@ public class EditorInfo implements InputType, Parcelable {
     * @see InputMethodService#onUpdateEditorToolType(int)
     * @return toolType {@link MotionEvent#getToolType(int)}.
     */
    public int getInitialToolType() {
    public @ToolType int getInitialToolType() {
        return mInitialToolType;
    }

@@ -1034,7 +1034,7 @@ public class EditorInfo implements InputType, Parcelable {
     * @see MotionEvent#getToolType(int)
     * @see InputMethodService#onUpdateEditorToolType(int)
     */
    public void setInitialToolType(int toolType) {
    public void setInitialToolType(@ToolType int toolType) {
        mInitialToolType = toolType;
    }