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

Commit fe41366e authored by satok's avatar satok Committed by Android (Google) Code Review
Browse files

Merge "Add onClickView to InputMethodService"

parents cbd9752e 863fcd62
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -9397,6 +9397,7 @@ package android.inputmethodservice {
    method public void onUpdateExtractingViews(android.view.inputmethod.EditorInfo);
    method public void onUpdateExtractingVisibility(android.view.inputmethod.EditorInfo);
    method public void onUpdateSelection(int, int, int, int, int, int);
    method public void onViewClicked(boolean);
    method public void onWindowHidden();
    method public void onWindowShown();
    method public void requestHideSelf(int);
@@ -9440,6 +9441,7 @@ package android.inputmethodservice {
    method public void updateCursor(android.graphics.Rect);
    method public void updateExtractedText(int, android.view.inputmethod.ExtractedText);
    method public void updateSelection(int, int, int, int, int, int);
    method public void viewClicked(boolean);
  }
  public static final class InputMethodService.Insets {
@@ -23511,6 +23513,7 @@ package android.view.inputmethod {
    method public void updateCursor(android.view.View, int, int, int, int);
    method public void updateExtractedText(android.view.View, int, android.view.inputmethod.ExtractedText);
    method public void updateSelection(android.view.View, int, int, int, int);
    method public void viewClicked(android.view.View);
    field public static final int HIDE_IMPLICIT_ONLY = 1; // 0x1
    field public static final int HIDE_NOT_ALWAYS = 2; // 0x2
    field public static final int RESULT_HIDDEN = 3; // 0x3
@@ -23531,6 +23534,7 @@ package android.view.inputmethod {
    method public abstract void updateCursor(android.graphics.Rect);
    method public abstract void updateExtractedText(int, android.view.inputmethod.ExtractedText);
    method public abstract void updateSelection(int, int, int, int, int, int);
    method public abstract void viewClicked(boolean);
  }
  public static abstract interface InputMethodSession.EventCallback {
+10 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
    private static final int DO_APP_PRIVATE_COMMAND = 100;
    private static final int DO_TOGGLE_SOFT_INPUT = 105;
    private static final int DO_FINISH_SESSION = 110;
    private static final int DO_VIEW_CLICKED = 115;

    HandlerCaller mCaller;
    InputMethodSession mInputMethodSession;
@@ -133,6 +134,10 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
                mInputMethodSession = null;
                return;
            }
            case DO_VIEW_CLICKED: {
                mInputMethodSession.viewClicked(msg.arg1 == 1);
                return;
            }
        }
        Log.w(TAG, "Unhandled message code: " + msg.what);
    }
@@ -168,6 +173,10 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
                candidatesStart, candidatesEnd));
    }

    public void viewClicked(boolean focusChanged) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageI(DO_VIEW_CLICKED, focusChanged ? 1 : 0));
    }

    public void updateCursor(Rect newCursor) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_UPDATE_CURSOR,
                newCursor));
+19 −1
Original line number Diff line number Diff line
@@ -489,6 +489,14 @@ public class InputMethodService extends AbstractInputMethodService {
                    newSelStart, newSelEnd, candidatesStart, candidatesEnd);
        }

        @Override
        public void viewClicked(boolean focusChanged) {
            if (!isEnabled()) {
                return;
            }
            InputMethodService.this.onViewClicked(focusChanged);
        }

        /**
         * Call {@link InputMethodService#onUpdateCursor
         * InputMethodService.onUpdateCursor()}.
@@ -1608,6 +1616,16 @@ public class InputMethodService extends AbstractInputMethodService {
        }
    }

    /**
     * Called when the user tapped or clicked a text view.
     * IMEs can't rely on this method being called because this was not part of the original IME
     * protocol, so applications with custom text editing written before this method appeared will
     * not call to inform the IME of this interaction.
     * @param focusChanged true if the user changed the focused view by this click.
     */
    public void onViewClicked(boolean focusChanged) {
    }

    /**
     * Called when the application has reported a new location of its text
     * cursor.  This is only called if explicitly requested by the input method.
+22 −1
Original line number Diff line number Diff line
@@ -1241,6 +1241,27 @@ public final class InputMethodManager {
        }
    }

    /**
     * Notify the event when the user tapped or clicked the text view.
     */
    public void viewClicked(View view) {
        final boolean focusChanged = mServedView != mNextServedView;
        checkFocus();
        synchronized (mH) {
            if ((mServedView != view && (mServedView == null
                    || !mServedView.checkInputConnectionProxy(view)))
                    || mCurrentTextBoxAttribute == null || mCurMethod == null) {
                return;
            }
            try {
                if (DEBUG) Log.v(TAG, "onViewClicked: " + focusChanged);
                mCurMethod.viewClicked(focusChanged);
            } catch (RemoteException e) {
                Log.w(TAG, "IME died: " + mCurId, e);
            }
        }
    }

    /**
     * Returns true if the current input method wants to watch the location
     * of the input editor's cursor in its window.
+9 −0
Original line number Diff line number Diff line
@@ -62,6 +62,15 @@ public interface InputMethodSession {
            int newSelStart, int newSelEnd,
            int candidatesStart, int candidatesEnd);

    /**
     * This method is called when the user tapped a text view.
     * IMEs can't rely on this method being called because this was not part of the original IME
     * protocol, so applications with custom text editing written before this method appeared will
     * not call to inform the IME of this interaction.
     * @param focusChanged true if the user changed the focused view by this click.
     */
    public void viewClicked(boolean focusChanged);

    /**
     * This method is called when cursor location of the target input field
     * has changed within its window.  This is not normally called, but will
Loading