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

Commit 7eb84256 authored by satok's avatar satok
Browse files

Enhancement of method.xml for Fast IME switching

- (Public API) Add public attrs: imeSubtypeExtraValue, imeSubtypeLanguage, imeSubtypeMode
-- (Public API) Add InputMethodSubtype class
-- (Public API) Add getSubtypes to InputMethodInfo
- Add parser for the enhanced method.xml

Change-Id: Ie7965fd29fd9615ef9c9418075c9f5f1c3365eb6
parent 2b6a6858
Loading
Loading
Loading
Loading
+146 −0
Original line number Diff line number Diff line
@@ -4970,6 +4970,39 @@
 visibility="public"
>
</field>
<field name="imeSubtypeExtraValue"
 type="int"
 transient="false"
 volatile="false"
 value="16843566"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="imeSubtypeLocale"
 type="int"
 transient="false"
 volatile="false"
 value="16843564"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="imeSubtypeMode"
 type="int"
 transient="false"
 volatile="false"
 value="16843565"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="immersive"
 type="int"
 transient="false"
@@ -208770,6 +208803,17 @@
 visibility="public"
>
</method>
<method name="getSubtypes"
 return="java.util.ArrayList&lt;android.view.inputmethod.InputMethodInfo.InputMethodSubtype&gt;"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="loadIcon"
 return="android.graphics.drawable.Drawable"
 abstract="false"
@@ -208822,6 +208866,108 @@
>
</field>
</class>
<class name="InputMethodInfo.InputMethodSubtype"
 extends="java.lang.Object"
 abstract="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.os.Parcelable">
</implements>
<method name="describeContents"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getExtraValue"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getIconId"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getLocale"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getMode"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getName"
 return="java.lang.String"
 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="parcelableFlags" 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="InputMethodManager"
 extends="java.lang.Object"
 abstract="false"
+149 −14
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.util.Printer;
import android.util.Xml;

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

/**
 * This class is used to specify meta information of an input method.
@@ -69,6 +70,107 @@ public final class InputMethodInfo implements Parcelable {
     */
    final int mIsDefaultResId;

    /**
     * InputMethodSubtype is a subtype contained in the input method. Subtype can describe
     * locales (e.g. en_US, fr_FR...) and modes (e.g. voice, keyboard...), and is used for
     * IME switch. The subtype allows the system to call the specified subtype of IME directly.
     */
    public static class InputMethodSubtype implements Parcelable {
        private final String mSubtypeName;
        private final int mSubtypeIconId;
        private final String mSubtypeLocale;
        private final String mSubtypeMode;
        private final String mSubtypeExtraValue;

        /**
         * Constructor
         * @param name The name of the subtype
         * @param iconId The icon of the subtype
         * @param locale The locale supported by the subtype
         * @param mode The mode supported by the subtype
         * @param extraValue The extra value of the subtype
         */
        InputMethodSubtype(String name, int iconId, String locale, String mode,
                String extraValue) {
            mSubtypeName = name;
            mSubtypeIconId = iconId;
            mSubtypeLocale = locale;
            mSubtypeMode = mode;
            mSubtypeExtraValue = extraValue;
        }

        InputMethodSubtype(Parcel source) {
            mSubtypeName = source.readString();
            mSubtypeIconId = source.readInt();
            mSubtypeLocale = source.readString();
            mSubtypeMode = source.readString();
            mSubtypeExtraValue = source.readString();
        }

        /**
         * @return the name of the subtype
         */
        public String getName() {
            return mSubtypeName;
        }

        /**
         * @return the icon of the subtype
         */
        public int getIconId() {
            return mSubtypeIconId;
        }

        /**
         * @return the locale of the subtype
         */
        public String getLocale() {
            return mSubtypeLocale;
        }

        /**
         * @return the mode of the subtype
         */
        public String getMode() {
            return mSubtypeMode;
        }

        /**
         * @return the extra value of the subtype
         */
        public String getExtraValue() {
            return mSubtypeExtraValue;
        }

        public int describeContents() {
            return 0;
        }

        public void writeToParcel(Parcel dest, int parcelableFlags) {
            dest.writeString(mSubtypeName);
            dest.writeInt(mSubtypeIconId);
            dest.writeString(mSubtypeLocale);
            dest.writeString(mSubtypeMode);
            dest.writeString(mSubtypeExtraValue);
        }

        public static final Parcelable.Creator<InputMethodSubtype> CREATOR
                = new Parcelable.Creator<InputMethodSubtype>() {
            public InputMethodSubtype createFromParcel(Parcel source) {
                return new InputMethodSubtype(source);
            }

            public InputMethodSubtype[] newArray(int size) {
                return new InputMethodSubtype[size];
            }
        };
    }

    /**
     * The array of the subtypes.
     */
    private final ArrayList<InputMethodSubtype> mSubtypes = new ArrayList<InputMethodSubtype>();

    /**
     * Constructor.
     * 
@@ -116,13 +218,36 @@ public final class InputMethodInfo implements Parcelable {
            isDefaultResId = sa.getResourceId(
                    com.android.internal.R.styleable.InputMethod_isDefault, 0);
            sa.recycle();

            final int depth = parser.getDepth();
            // Parse all subtypes
            while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
                    && type != XmlPullParser.END_DOCUMENT) {
                nodeName = parser.getName();
                if (!"subtype".equals(nodeName)) {
                    throw new XmlPullParserException(
                        "Meta-data in input-method does not start with subtype tag");
                }
                final TypedArray a = res.obtainAttributes(
                        attrs, com.android.internal.R.styleable.InputMethod_Subtype);
                InputMethodSubtype subtype = new InputMethodSubtype(
                        a.getString(com.android.internal.R.styleable.InputMethod_Subtype_label),
                        a.getResourceId(
                                com.android.internal.R.styleable.InputMethod_Subtype_icon, 0),
                        a.getString(com.android.internal.R.styleable
                                .InputMethod_Subtype_imeSubtypeLocale),
                        a.getString(com.android.internal.R.styleable
                                .InputMethod_Subtype_imeSubtypeMode),
                        a.getString(com.android.internal.R.styleable
                                .InputMethod_Subtype_imeSubtypeExtraValue));
                mSubtypes.add(subtype);
            }
        } catch (NameNotFoundException e) {
            throw new XmlPullParserException(
                    "Unable to create context for: " + si.packageName);
        } finally {
            if (parser != null) parser.close();
        }
        
        mSettingsActivityName = settingsActivityComponent;
        mIsDefaultResId = isDefaultResId;
    }
@@ -132,6 +257,7 @@ public final class InputMethodInfo implements Parcelable {
        mSettingsActivityName = source.readString();
        mIsDefaultResId = source.readInt();
        mService = ResolveInfo.CREATOR.createFromParcel(source);
        source.readTypedList(mSubtypes, InputMethodSubtype.CREATOR);
    }

    /**
@@ -231,6 +357,13 @@ public final class InputMethodInfo implements Parcelable {
        return mSettingsActivityName;
    }

    /**
     * Return the subtypes of Input Method.
     */
    public ArrayList<InputMethodSubtype> getSubtypes() {
        return mSubtypes;
    }

    /**
     * Return the resource identifier of a resource inside of this input
     * method's .apk that determines whether it should be considered a
@@ -285,12 +418,14 @@ public final class InputMethodInfo implements Parcelable {
        dest.writeString(mSettingsActivityName);
        dest.writeInt(mIsDefaultResId);
        mService.writeToParcel(dest, flags);
        dest.writeTypedList(mSubtypes);
    }

    /**
     * Used to make this class parcelable.
     */
    public static final Parcelable.Creator<InputMethodInfo> CREATOR = new Parcelable.Creator<InputMethodInfo>() {
    public static final Parcelable.Creator<InputMethodInfo> CREATOR
            = new Parcelable.Creator<InputMethodInfo>() {
        public InputMethodInfo createFromParcel(Parcel source) {
            return new InputMethodInfo(source);
        }
+22 −0
Original line number Diff line number Diff line
@@ -1550,6 +1550,28 @@
        <attr name="isDefault" format="boolean" />
    </declare-styleable>

    <!-- This is the subtype of InputMethod. Subtype can describe locales (e.g. en_US, fr_FR...)
         and modes (e.g. voice, keyboard...), and is used for IME switch. This subtype allows
         the system to call the specified subtype of the IME directly. -->
    <declare-styleable name="InputMethod_Subtype">
        <!-- The name of the subtype. -->
        <attr name="label" />
        <!-- The icon of the subtype. -->
        <attr name="icon" />
        <!-- The locale of the subtype. This string should be a locale (e.g. en_US, fr_FR...)
             and will be passed to the IME when the framework calls the IME
             with the subtype. This is also used by the framework to know the supported locales
             of the IME.  -->
        <attr name="imeSubtypeLocale" format="string" />
        <!-- The mode of the subtype. This string can be a mode (e.g. voice, keyboard...) and this
             string will be passed to the IME when the framework calls the IME with the
             subtype.  -->
        <attr name="imeSubtypeMode" format="string" />
        <!-- The extra value of the subtype. This string can be any string and will be passed to
             the IME when the framework calls the IME with the subtype.  -->
        <attr name="imeSubtypeExtraValue" format="string" />
    </declare-styleable>

    <!-- =============================== -->
    <!-- Widget package class attributes -->
    <!-- =============================== -->
+3 −0
Original line number Diff line number Diff line
@@ -1321,6 +1321,9 @@
  <public type="attr" name="fragmentCloseEnterAnimation" />
  <public type="attr" name="fragmentCloseExitAnimation" />
  <public type="attr" name="windowActionBarSize" />
  <public type="attr" name="imeSubtypeLocale" />
  <public type="attr" name="imeSubtypeMode" />
  <public type="attr" name="imeSubtypeExtraValue" />

  <public type="anim" name="animator_fade_in" />
  <public type="anim" name="animator_fade_out" />