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

Commit 01c2bec9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Introduce API to support Stylus Companion widget"

parents ca8747d4 e5f49917
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -18904,6 +18904,7 @@ package android.inputmethodservice {
    method public void onUnbindInput();
    method @Deprecated public void onUpdateCursor(android.graphics.Rect);
    method public void onUpdateCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfo);
    method public void onUpdateEditorToolType(int);
    method public void onUpdateExtractedText(int, android.view.inputmethod.ExtractedText);
    method public void onUpdateExtractingViews(android.view.inputmethod.EditorInfo);
    method public void onUpdateExtractingVisibility(android.view.inputmethod.EditorInfo);
@@ -52968,9 +52969,11 @@ package android.view.inputmethod {
    method @Nullable public android.view.inputmethod.SurroundingText getInitialSurroundingText(@IntRange(from=0) int, @IntRange(from=0) int, int);
    method @Nullable public CharSequence getInitialTextAfterCursor(@IntRange(from=0) int, int);
    method @Nullable public CharSequence getInitialTextBeforeCursor(@IntRange(from=0) int, int);
    method public int getInitialToolType();
    method public final void makeCompatible(int);
    method public void setInitialSurroundingSubText(@NonNull CharSequence, int);
    method public void setInitialSurroundingText(@NonNull CharSequence);
    method public void setInitialToolType(int);
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.EditorInfo> CREATOR;
    field public static final int IME_ACTION_DONE = 6; // 0x6
+13 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ class IInputMethodWrapper extends IInputMethod.Stub
    private static final int DO_START_STYLUS_HANDWRITING = 110;
    private static final int DO_INIT_INK_WINDOW = 120;
    private static final int DO_FINISH_STYLUS_HANDWRITING = 130;
    private static final int DO_UPDATE_TOOL_TYPE = 140;

    final WeakReference<InputMethodServiceInternal> mTarget;
    final Context mContext;
@@ -234,6 +235,10 @@ class IInputMethodWrapper extends IInputMethod.Stub
                inputMethod.canStartStylusHandwriting(msg.arg1);
                return;
            }
            case DO_UPDATE_TOOL_TYPE: {
                inputMethod.updateEditorToolType(msg.arg1);
                return;
            }
            case DO_START_STYLUS_HANDWRITING: {
                final SomeArgs args = (SomeArgs) msg.obj;
                inputMethod.startStylusHandwriting(msg.arg1, (InputChannel) args.arg1,
@@ -400,6 +405,14 @@ class IInputMethodWrapper extends IInputMethod.Stub
                mCaller.obtainMessageI(DO_CAN_START_STYLUS_HANDWRITING, requestId));
    }

    @BinderThread
    @Override
    public void updateEditorToolType(int toolType)
            throws RemoteException {
        mCaller.executeOrSendMessage(
                mCaller.obtainMessageI(DO_UPDATE_TOOL_TYPE, toolType));
    }

    @BinderThread
    @Override
    public void startStylusHandwriting(int requestId, @NonNull InputChannel channel,
+25 −0
Original line number Diff line number Diff line
@@ -948,6 +948,15 @@ public class InputMethodService extends AbstractInputMethodService {
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        }

        /**
         * {@inheritDoc}
         * @hide
         */
        @Override
        public void updateEditorToolType(int toolType) {
            onUpdateEditorToolType(toolType);
        }

        /**
         * {@inheritDoc}
         * @hide
@@ -3012,17 +3021,33 @@ public class InputMethodService extends AbstractInputMethodService {
     * not call to inform the IME of this interaction.
     * @param focusChanged true if the user changed the focused view by this click.
     * @see InputMethodManager#viewClicked(View)
     * @see #onUpdateEditorToolType(int)
     * @deprecated The method may not be called for composite {@link View} that works as a giant
     *             "Canvas", which can host its own UI hierarchy and sub focus state.
     *             {@link android.webkit.WebView} is a good example. Application / IME developers
     *             should not rely on this method. If your goal is just being notified when an
     *             on-going input is interrupted, simply monitor {@link #onFinishInput()}.
     *             If your goal is to know what {@link MotionEvent#getToolType(int)} clicked on
     *             editor, use {@link #onUpdateEditorToolType(int)} instead.
     */
    @Deprecated
    public void onViewClicked(boolean focusChanged) {
        // Intentionally empty
    }

    /**
     * Called when the user tapped or clicked an {@link android.widget.Editor}.
     * This can be useful when IME makes a decision of showing Virtual keyboard based on what
     * {@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> Default implementation does nothing. </p>
     * @param toolType what {@link MotionEvent#getToolType(int)} was used to click on editor.
     */
    public void onUpdateEditorToolType(int toolType) {
        // Intentionally empty
    }

    /**
     * Called when the application has reported a new location of its text
     * cursor.  This is only called if explicitly requested by the input method.
+16 −1
Original line number Diff line number Diff line
@@ -734,6 +734,8 @@ public final class ViewRootImpl implements ViewParent,
    final PointF mDragPoint = new PointF();
    final PointF mLastTouchPoint = new PointF();
    int mLastTouchSource;
    /** Tracks last {@link MotionEvent#getToolType(int)} with {@link MotionEvent#ACTION_UP}. **/
    private int mLastClickToolType;

    private boolean mProfileRendering;
    private Choreographer.FrameCallback mRenderProfiler;
@@ -6417,11 +6419,16 @@ public final class ViewRootImpl implements ViewParent,
                event.offsetLocation(0, mCurScrollY);
            }

            // Remember the touch position for possible drag-initiation.
            if (event.isTouchEvent()) {
                // Remember the touch position for possible drag-initiation.
                mLastTouchPoint.x = event.getRawX();
                mLastTouchPoint.y = event.getRawY();
                mLastTouchSource = event.getSource();

                // Register last ACTION_UP. This will be propagated to IME.
                if (event.getActionMasked() == MotionEvent.ACTION_UP) {
                    mLastClickToolType = event.getToolType(event.getActionIndex());
                }
            }
            return FORWARD;
        }
@@ -8017,6 +8024,14 @@ public final class ViewRootImpl implements ViewParent,
        return mLastTouchSource;
    }

    /**
     * Used by InputMethodManager.
     * @hide
     */
    public int getLastClickToolType() {
        return mLastClickToolType;
    }

    public void setDragFocus(View newDragTarget, DragEvent event) {
        if (mCurrentDragView != newDragTarget && !View.sCascadedDragDrop) {
            // Send EXITED and ENTERED notifications to the old and new drag focus views.
+37 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.content.res.Configuration;
import android.inputmethodservice.InputMethodService;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.LocaleList;
@@ -40,6 +41,7 @@ import android.text.InputType;
import android.text.TextUtils;
import android.util.Printer;
import android.util.proto.ProtoOutputStream;
import android.view.MotionEvent;
import android.view.View;
import android.view.autofill.AutofillId;

@@ -564,6 +566,12 @@ public class EditorInfo implements InputType, Parcelable {
    @Nullable
    private SurroundingText mInitialSurroundingText = null;

    /**
     * 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;


    /**
     * Editors may use this method to provide initial input text to IMEs. As the surrounding text
@@ -936,6 +944,31 @@ public class EditorInfo implements InputType, Parcelable {
        }
    }

    /**
     * Returns the initial {@link MotionEvent#ACTION_UP} tool type
     * {@link MotionEvent#getToolType(int)} responsible for focus on the current editor.
     *
     * @see #setInitialToolType(int)
     * @see MotionEvent#getToolType(int)
     * @see InputMethodService#onUpdateEditorToolType(int)
     * @return toolType {@link MotionEvent#getToolType(int)}.
     */
    public int getInitialToolType() {
        return mInitialToolType;
    }

    /**
     * Set the initial {@link MotionEvent#ACTION_UP} tool type {@link MotionEvent#getToolType(int)}.
     * that brought focus to the view.
     *
     * @see #getInitialToolType()
     * @see MotionEvent#getToolType(int)
     * @see InputMethodService#onUpdateEditorToolType(int)
     */
    public void setInitialToolType(int toolType) {
        mInitialToolType = toolType;
    }

    /**
     * Export the state of {@link EditorInfo} into a protocol buffer output stream.
     *
@@ -972,6 +1005,7 @@ public class EditorInfo implements InputType, Parcelable {
                + " actionId=" + actionId);
        pw.println(prefix + "initialSelStart=" + initialSelStart
                + " initialSelEnd=" + initialSelEnd
                + " initialToolType=" + mInitialToolType
                + " initialCapsMode=0x"
                + Integer.toHexString(initialCapsMode));
        pw.println(prefix + "hintText=" + hintText
@@ -1006,6 +1040,7 @@ public class EditorInfo implements InputType, Parcelable {
        newEditorInfo.initialSelStart = initialSelStart;
        newEditorInfo.initialSelEnd = initialSelEnd;
        newEditorInfo.initialCapsMode = initialCapsMode;
        newEditorInfo.mInitialToolType = mInitialToolType;
        newEditorInfo.hintText = TextUtils.stringOrSpannedString(hintText);
        newEditorInfo.label = TextUtils.stringOrSpannedString(label);
        newEditorInfo.packageName = packageName;
@@ -1036,6 +1071,7 @@ public class EditorInfo implements InputType, Parcelable {
        dest.writeInt(initialSelStart);
        dest.writeInt(initialSelEnd);
        dest.writeInt(initialCapsMode);
        dest.writeInt(mInitialToolType);
        TextUtils.writeToParcel(hintText, dest, flags);
        TextUtils.writeToParcel(label, dest, flags);
        dest.writeString(packageName);
@@ -1072,6 +1108,7 @@ public class EditorInfo implements InputType, Parcelable {
                    res.initialSelStart = source.readInt();
                    res.initialSelEnd = source.readInt();
                    res.initialCapsMode = source.readInt();
                    res.mInitialToolType = source.readInt();
                    res.hintText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
                    res.label = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
                    res.packageName = source.readString();
Loading