Add one shot flag to the subtype
Bug: 4257258
Change-Id: I21da9e11c882eea056beb84a2dfb0f28da8a98b1
diff --git a/api/current.txt b/api/current.txt
index 1b71805..1f6d673 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -22794,6 +22794,7 @@
method public java.lang.String getLocale();
method public java.lang.String getMode();
method public int getNameResId();
+ method public boolean isAuxiliary();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator CREATOR;
}
diff --git a/core/java/android/view/inputmethod/InputMethodSubtype.java b/core/java/android/view/inputmethod/InputMethodSubtype.java
index 807f6ce..de38fbe 100644
--- a/core/java/android/view/inputmethod/InputMethodSubtype.java
+++ b/core/java/android/view/inputmethod/InputMethodSubtype.java
@@ -38,12 +38,13 @@
private static final String EXTRA_VALUE_PAIR_SEPARATOR = ",";
private static final String EXTRA_VALUE_KEY_VALUE_SEPARATOR = "=";
- private final int mSubtypeNameResId;
+ private final boolean mIsAuxiliary;
+ private final int mSubtypeHashCode;
private final int mSubtypeIconResId;
+ private final int mSubtypeNameResId;
private final String mSubtypeLocale;
private final String mSubtypeMode;
private final String mSubtypeExtraValue;
- private final int mSubtypeHashCode;
private HashMap<String, String> mExtraValueHashMapCache;
/**
@@ -55,12 +56,27 @@
* @param extraValue The extra value of the subtype
*/
InputMethodSubtype(int nameId, int iconId, String locale, String mode, String extraValue) {
+ this(nameId, iconId, locale, mode, extraValue, false);
+ }
+
+ /**
+ * Constructor
+ * @param nameId The name of the subtype
+ * @param iconId The icon of the subtype
+ * @param locale The locale supported by the subtype
+ * @param modeId The mode supported by the subtype
+ * @param extraValue The extra value of the subtype
+ * @param isAuxiliary true when this subtype is one shot subtype.
+ */
+ InputMethodSubtype(int nameId, int iconId, String locale, String mode, String extraValue,
+ boolean isAuxiliary) {
mSubtypeNameResId = nameId;
mSubtypeIconResId = iconId;
mSubtypeLocale = locale != null ? locale : "";
mSubtypeMode = mode != null ? mode : "";
mSubtypeExtraValue = extraValue != null ? extraValue : "";
mSubtypeHashCode = hashCodeInternal(mSubtypeLocale, mSubtypeMode, mSubtypeExtraValue);
+ mIsAuxiliary = isAuxiliary;
}
InputMethodSubtype(Parcel source) {
@@ -74,6 +90,7 @@
s = source.readString();
mSubtypeExtraValue = s != null ? s : "";
mSubtypeHashCode = hashCodeInternal(mSubtypeLocale, mSubtypeMode, mSubtypeExtraValue);
+ mIsAuxiliary = (source.readInt() == 1);
}
/**
@@ -111,6 +128,15 @@
return mSubtypeExtraValue;
}
+ /**
+ * @return true if this subtype is one shot subtype. One shot subtype will not be shown in the
+ * ime switch list when this subtype is implicitly enabled. The framework will never
+ * switch the current ime to this subtype by switchToLastInputMethod in InputMethodManager.
+ */
+ public boolean isAuxiliary() {
+ return mIsAuxiliary;
+ }
+
private HashMap<String, String> getExtraValueHashMap() {
if (mExtraValueHashMapCache == null) {
mExtraValueHashMapCache = new HashMap<String, String>();
@@ -170,24 +196,29 @@
return false;
}
+ @Override
public int describeContents() {
return 0;
}
+ @Override
public void writeToParcel(Parcel dest, int parcelableFlags) {
dest.writeInt(mSubtypeNameResId);
dest.writeInt(mSubtypeIconResId);
dest.writeString(mSubtypeLocale);
dest.writeString(mSubtypeMode);
dest.writeString(mSubtypeExtraValue);
+ dest.writeInt(mIsAuxiliary ? 1 : 0);
}
public static final Parcelable.Creator<InputMethodSubtype> CREATOR
= new Parcelable.Creator<InputMethodSubtype>() {
+ @Override
public InputMethodSubtype createFromParcel(Parcel source) {
return new InputMethodSubtype(source);
}
+ @Override
public InputMethodSubtype[] newArray(int size) {
return new InputMethodSubtype[size];
}