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

Commit cf9cf2f4 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

New API in InputConnection to signal IME's text correction.

Scafolding so that the IME team can start working on this feature.

The animation part in the TextView is missing.

Change-Id: I8225538564370fba1500e3539742a8ab79bdd199
parent 70e81ba9
Loading
Loading
Loading
Loading
+146 −0
Original line number Diff line number Diff line
@@ -219732,6 +219732,19 @@
<parameter name="text" type="android.view.inputmethod.CompletionInfo">
</parameter>
</method>
<method name="commitCorrection"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="correctionInfo" type="android.view.inputmethod.CorrectionInfo">
</parameter>
</method>
<method name="commitText"
 return="boolean"
 abstract="false"
@@ -220152,6 +220165,100 @@
>
</field>
</class>
<class name="CorrectionInfo"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.os.Parcelable">
</implements>
<constructor name="CorrectionInfo"
 type="android.view.inputmethod.CorrectionInfo"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="offset" type="int">
</parameter>
<parameter name="oldText" type="java.lang.CharSequence">
</parameter>
<parameter name="newText" type="java.lang.CharSequence">
</parameter>
</constructor>
<method name="describeContents"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getNewText"
 return="java.lang.CharSequence"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getOffset"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getOldText"
 return="java.lang.CharSequence"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="writeToParcel"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="dest" type="android.os.Parcel">
</parameter>
<parameter name="flags" type="int">
</parameter>
</method>
<field name="CREATOR"
 type="android.os.Parcelable.Creator"
 transient="false"
 volatile="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<class name="EditorInfo"
 extends="java.lang.Object"
 abstract="false"
@@ -220958,6 +221065,19 @@
<parameter name="text" type="android.view.inputmethod.CompletionInfo">
</parameter>
</method>
<method name="commitCorrection"
 return="boolean"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="correctionInfo" type="android.view.inputmethod.CorrectionInfo">
</parameter>
</method>
<method name="commitText"
 return="boolean"
 abstract="true"
@@ -221275,6 +221395,19 @@
<parameter name="text" type="android.view.inputmethod.CompletionInfo">
</parameter>
</method>
<method name="commitCorrection"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="correctionInfo" type="android.view.inputmethod.CorrectionInfo">
</parameter>
</method>
<method name="commitText"
 return="boolean"
 abstract="false"
@@ -247819,6 +247952,19 @@
<parameter name="text" type="android.view.inputmethod.CompletionInfo">
</parameter>
</method>
<method name="onCommitCorrection"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="info" type="android.view.inputmethod.CorrectionInfo">
</parameter>
</method>
<method name="onEditorAction"
 return="void"
 abstract="false"
+8 −1
Original line number Diff line number Diff line
@@ -164,12 +164,19 @@ public class BaseInputConnection implements InputConnection {
    }

    /**
     * Default implementation does nothing.
     * Default implementation does nothing and returns false.
     */
    public boolean commitCompletion(CompletionInfo text) {
        return false;
    }

    /**
     * Default implementation does nothing and returns false.
     */
    public boolean commitCorrection(CorrectionInfo correctionInfo) {
        return false;
    }

    /**
     * Default implementation replaces any existing composing text with
     * the given text.  In addition, only if dummy mode, a key event is
+7 −9
Original line number Diff line number Diff line
@@ -25,12 +25,10 @@ import android.text.TextUtils;
 * an input method.
 */
public final class CompletionInfo implements Parcelable {
    static final String TAG = "CompletionInfo";
    
    final long mId;
    final int mPosition;
    final CharSequence mText;
    final CharSequence mLabel;
    private final long mId;
    private final int mPosition;
    private final CharSequence mText;
    private final CharSequence mLabel;

    /**
     * Create a simple completion with just text, no label.
@@ -52,7 +50,7 @@ public final class CompletionInfo implements Parcelable {
        mLabel = label;
    }

    CompletionInfo(Parcel source) {
    private CompletionInfo(Parcel source) {
        mId = source.readLong();
        mPosition = source.readInt();
        mText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 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 CorrectionInfo;
+105 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007-2010 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;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

/**
 * Information about a single text correction that an editor has reported to
 * an input method.
 */
public final class CorrectionInfo implements Parcelable {
    private final int mOffset;
    private final CharSequence mOldText;
    private final CharSequence mNewText;

    /**
     * @param offset The offset in the edited text where the old and new text start.
     * @param oldText The old text that has been replaced.
     * @param newText The replacement text.
     */
    public CorrectionInfo(int offset, CharSequence oldText, CharSequence newText) {
        mOffset = offset;
        mOldText = oldText;
        mNewText = newText;
    }

    private CorrectionInfo(Parcel source) {
        mOffset = source.readInt();
        mOldText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mNewText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
    }

    /**
     * Return the offset position of this correction in the text. Both the {@link #getOldText()} and
     * {@link #getNewText()} start at this offset.
     */
    public int getOffset() {
        return mOffset;
    }

    /**
     * Return the text that has actually been typed by the user, and which has been corrected.
     */
    public CharSequence getOldText() {
        return mOldText;
    }

    /**
     * Return the new text that corrects what was typed by the user.
     */
    public CharSequence getNewText() {
        return mNewText;
    }

    @Override
    public String toString() {
        return "CorrectionInfo{#" + mOffset + " \"" + mOldText + "\" -> \"" + mNewText + "\"}";
    }

    /**
     * Used to package this object into a {@link Parcel}.
     *
     * @param dest The {@link Parcel} to be written.
     * @param flags The flags used for parceling.
     */
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mOffset);
        TextUtils.writeToParcel(mOldText, dest, flags);
        TextUtils.writeToParcel(mNewText, dest, flags);
    }

    /**
     * Used to make this class parcelable.
     */
    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];
        }
    };

    public int describeContents() {
        return 0;
    }
}
Loading