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

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

Merge "Add an API to set InputMethodAndSubtype"

parents 10656854 28203514
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -221393,6 +221393,23 @@
<parameter name="id" type="java.lang.String">
</parameter>
</method>
<method name="setInputMethodAndSubtype"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="token" type="android.os.IBinder">
</parameter>
<parameter name="id" type="java.lang.String">
</parameter>
<parameter name="subtype" type="android.view.inputmethod.InputMethodSubtype">
</parameter>
</method>
<method name="showInputMethodAndSubtypeEnabler"
 return="void"
 abstract="false"
@@ -249195,7 +249212,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="t" type="T">
<parameter name="arg0" type="T">
</parameter>
</method>
</interface>
+21 −4
Original line number Diff line number Diff line
@@ -1281,7 +1281,7 @@ public final class InputMethodManager {

    /**
     * Force switch to a new input method component. This can only be called
     * from the currently active input method, as validated by the given token.
     * from an application or a service which has a token of the currently active input method.
     * @param token Supplies the identifying token given to an input method
     * when it was started, which allows it to perform this operation on
     * itself.
@@ -1295,6 +1295,23 @@ public final class InputMethodManager {
        }
    }

    /**
     * Force switch to a new input method and subtype. This can only be called
     * from an application or a service which has a token of the currently active input method.
     * @param token Supplies the identifying token given to an input method
     * when it was started, which allows it to perform this operation on
     * itself.
     * @param id The unique identifier for the new input method to be switched to.
     * @param subtype The new subtype of the new input method to be switched to.
     */
    public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) {
        try {
            mService.setInputMethodAndSubtype(token, id, subtype);
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * Close/hide the input method's soft input area, so the user no longer
     * sees it or can interact with it.  This can only be called
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ interface IInputMethodManager {
    void showInputMethodSubtypePickerFromClient(in IInputMethodClient client);
    void showInputMethodAndSubtypeEnablerFromClient(in IInputMethodClient client, String topId);
    void setInputMethod(in IBinder token, String id);
    void setInputMethodAndSubtype(in IBinder token, String id, in InputMethodSubtype subtype);
    void hideMySoftInput(in IBinder token, int flags);
    void showMySoftInput(in IBinder token, int flags);
    void updateStatusIcon(in IBinder token, String packageName, int iconId);
+21 −8
Original line number Diff line number Diff line
@@ -1300,7 +1300,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    }

    public void setInputMethod(IBinder token, String id) {
        setInputMethodWithSubtype(token, id, NOT_A_SUBTYPE_ID);
        setInputMethodWithSubtypeId(token, id, NOT_A_SUBTYPE_ID);
    }

    public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) {
        synchronized (mMethodMap) {
            if (subtype != null) {
                setInputMethodWithSubtypeId(token, id, getSubtypeIdFromHashCode(
                        mMethodMap.get(id), subtype.hashCode()));
            } else {
                setInputMethod(token, id);
            }
        }
    }

    public boolean switchToLastInputMethod(IBinder token) {
@@ -1309,7 +1320,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            if (lastIme != null) {
                InputMethodInfo imi = mMethodMap.get(lastIme.first);
                if (imi != null) {
                    setInputMethodWithSubtype(token, lastIme.first, getSubtypeIdFromHashCode(
                    setInputMethodWithSubtypeId(token, lastIme.first, getSubtypeIdFromHashCode(
                            imi, Integer.valueOf(lastIme.second)));
                    return true;
                }
@@ -1318,7 +1329,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }
    }

    private void setInputMethodWithSubtype(IBinder token, String id, int subtypeId) {
    private void setInputMethodWithSubtypeId(IBinder token, String id, int subtypeId) {
        synchronized (mMethodMap) {
            if (token == null) {
                if (mContext.checkCallingOrSelfPermission(
@@ -1909,6 +1920,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    }

    private int getSubtypeIdFromHashCode(InputMethodInfo imi, int subtypeHashCode) {
        if (imi != null) {
            ArrayList<InputMethodSubtype> subtypes = imi.getSubtypes();
            for (int i = 0; i < subtypes.size(); ++i) {
                InputMethodSubtype ims = subtypes.get(i);
@@ -1916,6 +1928,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    return i;
                }
            }
        }
        return NOT_A_SUBTYPE_ID;
    }