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

Commit e7c6998e authored by satok's avatar satok
Browse files

API to set additional subtypes

Bug: 4321667

- Due to the voice team's strong request

Change-Id: Ia8bbc277c0987bde996e6f65541877cec96a3ca1
parent 3932aa7f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23236,6 +23236,7 @@ package android.view.inputmethod {
    method public boolean isWatchingCursor(android.view.View);
    method public void restartInput(android.view.View);
    method public void sendAppPrivateCommand(android.view.View, java.lang.String, android.os.Bundle);
    method public boolean setAdditionalInputMethodSubtypes(android.os.IBinder, android.view.inputmethod.InputMethodSubtype[]);
    method public boolean setCurrentInputMethodSubtype(android.view.inputmethod.InputMethodSubtype);
    method public void setInputMethod(android.os.IBinder, java.lang.String);
    method public void setInputMethodAndSubtype(android.os.IBinder, java.lang.String, android.view.inputmethod.InputMethodSubtype);
+30 −2
Original line number Diff line number Diff line
@@ -23,9 +23,9 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
@@ -38,6 +38,8 @@ import android.util.Xml;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * This class is used to specify meta information of an input method.
@@ -84,6 +86,21 @@ public final class InputMethodInfo implements Parcelable {
     */
    public InputMethodInfo(Context context, ResolveInfo service)
            throws XmlPullParserException, IOException {
        this(context, service, null);
    }

    /**
     * Constructor.
     *
     * @param context The Context in which we are parsing the input method.
     * @param service The ResolveInfo returned from the package manager about
     * this input method's component.
     * @param additionalSubtypes additional subtypes being added to this InputMethodInfo
     * @hide
     */
    public InputMethodInfo(Context context, ResolveInfo service,
            Map<String, List<InputMethodSubtype>> additionalSubtypesMap)
            throws XmlPullParserException, IOException {
        mService = service;
        ServiceInfo si = service.serviceInfo;
        mId = new ComponentName(si.packageName, si.name).flattenToShortString();
@@ -157,6 +174,17 @@ public final class InputMethodInfo implements Parcelable {
        } finally {
            if (parser != null) parser.close();
        }

        if (additionalSubtypesMap != null && additionalSubtypesMap.containsKey(mId)) {
            final List<InputMethodSubtype> additionalSubtypes = additionalSubtypesMap.get(mId);
            final int N = additionalSubtypes.size();
            for (int i = 0; i < N; ++i) {
                final InputMethodSubtype subtype = additionalSubtypes.get(i);
                if (!mSubtypes.contains(subtype)) {
                    mSubtypes.add(subtype);
                }
            }
        }
        mSettingsActivityName = settingsActivityComponent;
        mIsDefaultResId = isDefaultResId;
    }
+18 −0
Original line number Diff line number Diff line
@@ -1558,6 +1558,24 @@ public final class InputMethodManager {
        }
    }

    /**
     * Set additional input method subtypes.
     * @param imeToken Supplies the identifying token given to an input method.
     * @param subtypes subtypes will be added as additional subtypes of the current input method.
     * @return true if the additional input method subtypes are successfully added.
     */
    public boolean setAdditionalInputMethodSubtypes(
            IBinder imeToken, InputMethodSubtype[] subtypes) {
        synchronized (mH) {
            try {
                return mService.setAdditionalInputMethodSubtypes(imeToken, subtypes);
            } catch (RemoteException e) {
                Log.w(TAG, "IME died: " + mCurId, e);
                return false;
            }
        }
    }

    public InputMethodSubtype getLastInputMethodSubtype() {
        synchronized (mH) {
            try {
+1 −0
Original line number Diff line number Diff line
@@ -68,4 +68,5 @@ interface IInputMethodManager {
    boolean setCurrentInputMethodSubtype(in InputMethodSubtype subtype);
    boolean switchToLastInputMethod(in IBinder token);
    boolean setInputMethodEnabled(String id, boolean enabled);
    boolean setAdditionalInputMethodSubtypes(in IBinder token, in InputMethodSubtype[] subtypes);
}
+252 −6

File changed.

Preview size limit exceeded, changes collapsed.