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

Commit c2ddd602 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Introduce new API for floating window support

This CL introduces a new API IMM#updateCursorAnchorInfo for
floating window support.

BUG: 14579622
Change-Id: I61dec2f8fa671ba891da1d4af08975750e3acb04
parent 86e80290
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -12867,6 +12867,7 @@ package android.inputmethodservice {
    method public void onStartInputView(android.view.inputmethod.EditorInfo, boolean);
    method public void onUnbindInput();
    method public void onUpdateCursor(android.graphics.Rect);
    method public void onUpdateCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfo);
    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);
@@ -12916,6 +12917,7 @@ package android.inputmethodservice {
    method public void finishInput();
    method public void toggleSoftInput(int, int);
    method public void updateCursor(android.graphics.Rect);
    method public void updateCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfo);
    method public void updateExtractedText(int, android.view.inputmethod.ExtractedText);
    method public void updateSelection(int, int, int, int, int, int);
    method public void viewClicked(boolean);
@@ -32548,6 +32550,34 @@ package android.view.inputmethod {
    field public static final android.os.Parcelable.Creator CREATOR;
  }
  public final class CursorAnchorInfo implements android.os.Parcelable {
    ctor public CursorAnchorInfo(android.os.Parcel);
    method public int describeContents();
    method public int getCandidatesEnd();
    method public int getCandidatesStart();
    method public android.graphics.RectF getCharacterRect(int);
    method public float getInsertionMarkerBaseline();
    method public float getInsertionMarkerBottom();
    method public float getInsertionMarkerHorizontal();
    method public float getInsertionMarkerTop();
    method public android.graphics.Matrix getMatrix();
    method public int getSelectionEnd();
    method public int getSelectionStart();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
  }
  public static final class CursorAnchorInfo.CursorAnchorInfoBuilder {
    ctor public CursorAnchorInfo.CursorAnchorInfoBuilder();
    method public android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder addCharacterRect(int, float, float, float, float);
    method public android.view.inputmethod.CursorAnchorInfo build();
    method public void reset();
    method public android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder setCandidateRange(int, int);
    method public android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder setInsertionMarkerLocation(float, float, float, float);
    method public android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder setMatrix(android.graphics.Matrix);
    method public android.view.inputmethod.CursorAnchorInfo.CursorAnchorInfoBuilder setSelectionRange(int, int);
  }
  public class EditorInfo implements android.text.InputType android.os.Parcelable {
    ctor public EditorInfo();
    method public int describeContents();
@@ -32756,6 +32786,7 @@ package android.view.inputmethod {
    method public void toggleSoftInput(int, int);
    method public void toggleSoftInputFromWindow(android.os.IBinder, int, int);
    method public void updateCursor(android.view.View, int, int, int, int);
    method public void updateCursorAnchorInfo(android.view.View, android.view.inputmethod.CursorAnchorInfo);
    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);
@@ -32778,6 +32809,7 @@ package android.view.inputmethod {
    method public abstract void finishInput();
    method public abstract void toggleSoftInput(int, int);
    method public abstract void updateCursor(android.graphics.Rect);
    method public abstract void updateCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfo);
    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);
+12 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.view.MotionEvent;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.InputMethodSession;
import android.view.inputmethod.CursorAnchorInfo;

class IInputMethodSessionWrapper extends IInputMethodSession.Stub
        implements HandlerCaller.Callback {
@@ -46,6 +47,7 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
    private static final int DO_UPDATE_EXTRACTED_TEXT = 67;
    private static final int DO_UPDATE_SELECTION = 90;
    private static final int DO_UPDATE_CURSOR = 95;
    private static final int DO_UPDATE_CURSOR_ANCHOR_INFO = 99;
    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;
@@ -108,6 +110,10 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
                mInputMethodSession.updateCursor((Rect)msg.obj);
                return;
            }
            case DO_UPDATE_CURSOR_ANCHOR_INFO: {
                mInputMethodSession.updateCursorAnchorInfo((CursorAnchorInfo)msg.obj);
                return;
            }
            case DO_APP_PRIVATE_COMMAND: {
                SomeArgs args = (SomeArgs)msg.obj;
                mInputMethodSession.appPrivateCommand((String)args.arg1,
@@ -180,6 +186,12 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
                mCaller.obtainMessageO(DO_UPDATE_CURSOR, newCursor));
    }

    @Override
    public void updateCursorAnchorInfo(CursorAnchorInfo cursorAnchorInfo) {
        mCaller.executeOrSendMessage(
                mCaller.obtainMessageO(DO_UPDATE_CURSOR_ANCHOR_INFO, cursorAnchorInfo));
    }

    @Override
    public void appPrivateCommand(String action, Bundle data) {
        mCaller.executeOrSendMessage(
+23 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.view.WindowManager;
import android.view.WindowManager.BadTokenException;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CursorAnchorInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
@@ -545,6 +546,17 @@ public class InputMethodService extends AbstractInputMethodService {
        public void toggleSoftInput(int showFlags, int hideFlags) {
            InputMethodService.this.onToggleSoftInput(showFlags, hideFlags);
        }

        /**
         * Call {@link InputMethodService#onUpdateCursorAnchorInfo
         * InputMethodService.onUpdateCursorAnchorInfo()}.
         */
        public void updateCursorAnchorInfo(CursorAnchorInfo info) {
            if (!isEnabled()) {
                return;
            }
            InputMethodService.this.onUpdateCursorAnchorInfo(info);
        }
    }
    
    /**
@@ -1716,6 +1728,17 @@ public class InputMethodService extends AbstractInputMethodService {
        // Intentionally empty
    }

    /**
     * Called when the application has reported a new location of its text insertion point and
     * characters in the composition string.  This is only called if explicitly requested by the
     * input method. The default implementation does nothing.
     * @param cursorAnchorInfo The positional information of the text insertion point and the
     * composition string.
     */
    public void onUpdateCursorAnchorInfo(CursorAnchorInfo cursorAnchorInfo) {
        // Intentionally empty
    }

    /**
     * Update the cursor/anthor monitor mode.
     */
+9 −10
Original line number Diff line number Diff line
@@ -88,12 +88,11 @@ public final class CorrectionInfo implements Parcelable {
    /**
     * Used to make this class parcelable.
     */
    public static final Parcelable.Creator<CorrectionInfo> CREATOR
            = new Parcelable.Creator<CorrectionInfo>() {
    public static final Parcelable.Creator<CorrectionInfo> CREATOR =
            new Parcelable.Creator<CorrectionInfo>() {
                public CorrectionInfo createFromParcel(Parcel source) {
                    return new CorrectionInfo(source);
                }

                public CorrectionInfo[] newArray(int size) {
                    return new CorrectionInfo[size];
                }
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view.inputmethod;

parcelable CursorAnchorInfo;
Loading