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

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

Merge "Add InputConnection#performSpellCheck()."

parents 302b4758 e751e103
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -51196,6 +51196,7 @@ package android.view.inputmethod {
    method public boolean performContextMenuAction(int);
    method public boolean performContextMenuAction(int);
    method public boolean performEditorAction(int);
    method public boolean performEditorAction(int);
    method public boolean performPrivateCommand(String, android.os.Bundle);
    method public boolean performPrivateCommand(String, android.os.Bundle);
    method public default boolean performSpellCheck();
    method public boolean reportFullscreenMode(boolean);
    method public boolean reportFullscreenMode(boolean);
    method public boolean requestCursorUpdates(int);
    method public boolean requestCursorUpdates(int);
    method public boolean sendKeyEvent(android.view.KeyEvent);
    method public boolean sendKeyEvent(android.view.KeyEvent);
+14 −0
Original line number Original line Diff line number Diff line
@@ -857,6 +857,20 @@ public interface InputConnection {
     */
     */
    boolean reportFullscreenMode(boolean enabled);
    boolean reportFullscreenMode(boolean enabled);


    /**
     * Have the editor perform spell checking around the current selection.
     *
     * <p>The editor can ignore this method call if it does not support spell checking.
     *
     * @return For editor authors, the return value will always be ignored. For IME authors, this
     *         method returns true if the spell check request was sent (whether or not the
     *         associated editor supports spell checking), false if the input connection is no
     *         longer valid.
     */
    default boolean performSpellCheck() {
        return false;
    }

    /**
    /**
     * API to send private commands from an input method to its
     * API to send private commands from an input method to its
     * connected editor. This can be used to provide domain-specific
     * connected editor. This can be used to provide domain-specific
+9 −0
Original line number Original line Diff line number Diff line
@@ -282,6 +282,15 @@ public class InputConnectionWrapper implements InputConnection {
        return mTarget.reportFullscreenMode(enabled);
        return mTarget.reportFullscreenMode(enabled);
    }
    }


    /**
     * {@inheritDoc}
     * @throws NullPointerException if the target is {@code null}.
     */
    @Override
    public boolean performSpellCheck() {
        return mTarget.performSpellCheck();
    }

    /**
    /**
     * {@inheritDoc}
     * {@inheritDoc}
     * @throws NullPointerException if the target is {@code null}.
     * @throws NullPointerException if the target is {@code null}.
+21 −0
Original line number Original line Diff line number Diff line
@@ -215,6 +215,27 @@ public class SpellChecker implements SpellCheckerSessionListener {
        spellCheck();
        spellCheck();
    }
    }


    void onPerformSpellCheck() {
        final int selectionStart = mTextView.getSelectionStart();
        final int selectionEnd = mTextView.getSelectionEnd();
        final int selectionRangeStart;
        final int selectionRangeEnd;
        if (selectionStart < selectionEnd) {
            selectionRangeStart = selectionStart;
            selectionRangeEnd = selectionEnd;
        } else {
            selectionRangeStart = selectionEnd;
            selectionRangeEnd = selectionStart;
        }
        // Expand the range so that it (hopefully) includes the current sentence.
        final int start = Math.max(0, selectionRangeStart - MIN_SENTENCE_LENGTH);
        final int end = Math.min(mTextView.length(), selectionRangeEnd + MIN_SENTENCE_LENGTH);
        if (DBG) {
            Log.d(TAG, "performSpellCheckAroundSelection: " + start + ", " + end);
        }
        spellCheck(start, end);
    }

    public void spellCheck(int start, int end) {
    public void spellCheck(int start, int end) {
        if (DBG) {
        if (DBG) {
            Log.d(TAG, "Start spell-checking: " + start + ", " + end);
            Log.d(TAG, "Start spell-checking: " + start + ", " + end);
+7 −0
Original line number Original line Diff line number Diff line
@@ -8913,6 +8913,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        // intentionally empty
        // intentionally empty
    }
    }
    /** @hide */
    public void onPerformSpellCheck() {
        if (mEditor != null && mEditor.mSpellChecker != null) {
            mEditor.mSpellChecker.onPerformSpellCheck();
        }
    }
    /**
    /**
     * Called by the framework in response to a private command from the
     * Called by the framework in response to a private command from the
     * current method, provided by it calling
     * current method, provided by it calling
Loading