am 3dd6bdf9: Merge "Add InputMethodSubtypeCompatUtils.isAsciiCapable()"
* commit '3dd6bdf9312007ed43827975d121e972b98ab5e3': Add InputMethodSubtypeCompatUtils.isAsciiCapable()main
commit
93441101ac
|
@ -19,7 +19,10 @@ package com.android.inputmethod.compat;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public final class InputMethodSubtypeCompatUtils {
|
public final class InputMethodSubtypeCompatUtils {
|
||||||
private static final String TAG = InputMethodSubtypeCompatUtils.class.getSimpleName();
|
private static final String TAG = InputMethodSubtypeCompatUtils.class.getSimpleName();
|
||||||
|
@ -37,6 +40,12 @@ public final class InputMethodSubtypeCompatUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note that {@link InputMethodSubtype#isAsciiCapable()} has been introduced in API level 19
|
||||||
|
// (Build.VERSION_CODE.KITKAT).
|
||||||
|
private static final Method METHOD_isAsciiCapable = CompatUtils.getMethod(
|
||||||
|
InputMethodSubtype.class, "isAsciiCapable");
|
||||||
|
|
||||||
private InputMethodSubtypeCompatUtils() {
|
private InputMethodSubtypeCompatUtils() {
|
||||||
// This utility class is not publicly instantiable.
|
// This utility class is not publicly instantiable.
|
||||||
}
|
}
|
||||||
|
@ -53,4 +62,9 @@ public final class InputMethodSubtypeCompatUtils {
|
||||||
nameId, iconId, locale, mode, extraValue, isAuxiliary,
|
nameId, iconId, locale, mode, extraValue, isAuxiliary,
|
||||||
overridesImplicitlyEnabledSubtype, id);
|
overridesImplicitlyEnabledSubtype, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAsciiCapable(final InputMethodSubtype subtype) {
|
||||||
|
return (Boolean)CompatUtils.invoke(subtype, false, METHOD_isAsciiCapable)
|
||||||
|
|| subtype.containsExtraValueKey(Constants.Subtype.ExtraValue.ASCII_CAPABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import static com.android.inputmethod.latin.Constants.ImeOption.FORCE_ASCII;
|
||||||
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE;
|
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE;
|
||||||
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE_COMPAT;
|
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE_COMPAT;
|
||||||
import static com.android.inputmethod.latin.Constants.ImeOption.NO_SETTINGS_KEY;
|
import static com.android.inputmethod.latin.Constants.ImeOption.NO_SETTINGS_KEY;
|
||||||
import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.ASCII_CAPABLE;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
@ -34,6 +33,7 @@ import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.EditorInfoCompatUtils;
|
import com.android.inputmethod.compat.EditorInfoCompatUtils;
|
||||||
|
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
|
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
||||||
import com.android.inputmethod.keyboard.internal.KeysCache;
|
import com.android.inputmethod.keyboard.internal.KeysCache;
|
||||||
|
@ -248,7 +248,7 @@ public final class KeyboardLayoutSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setSubtype(final InputMethodSubtype subtype) {
|
public Builder setSubtype(final InputMethodSubtype subtype) {
|
||||||
final boolean asciiCapable = subtype.containsExtraValueKey(ASCII_CAPABLE);
|
final boolean asciiCapable = InputMethodSubtypeCompatUtils.isAsciiCapable(subtype);
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
final boolean deprecatedForceAscii = InputAttributes.inPrivateImeOptions(
|
final boolean deprecatedForceAscii = InputAttributes.inPrivateImeOptions(
|
||||||
mPackageName, FORCE_ASCII, mParams.mEditorInfo);
|
mPackageName, FORCE_ASCII, mParams.mEditorInfo);
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.settings;
|
package com.android.inputmethod.latin.settings;
|
||||||
|
|
||||||
import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.ASCII_CAPABLE;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -44,6 +42,8 @@ import android.widget.Spinner;
|
||||||
import android.widget.SpinnerAdapter;
|
import android.widget.SpinnerAdapter;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.RichInputMethodManager;
|
import com.android.inputmethod.latin.RichInputMethodManager;
|
||||||
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
|
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
|
||||||
|
@ -111,7 +111,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
|
||||||
subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
|
subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
|
||||||
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype)));
|
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype)));
|
||||||
}
|
}
|
||||||
if (subtype.containsExtraValueKey(ASCII_CAPABLE)) {
|
if (InputMethodSubtypeCompatUtils.isAsciiCapable(subtype)) {
|
||||||
items.add(createItem(context, subtype.getLocale()));
|
items.add(createItem(context, subtype.getLocale()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
|
||||||
final KeyboardLayoutSetItem layout =
|
final KeyboardLayoutSetItem layout =
|
||||||
(KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem();
|
(KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem();
|
||||||
final InputMethodSubtype subtype = AdditionalSubtypeUtils.createAdditionalSubtype(
|
final InputMethodSubtype subtype = AdditionalSubtypeUtils.createAdditionalSubtype(
|
||||||
locale.first, layout.first, ASCII_CAPABLE);
|
locale.first, layout.first, Constants.Subtype.ExtraValue.ASCII_CAPABLE);
|
||||||
setSubtype(subtype);
|
setSubtype(subtype);
|
||||||
notifyChanged();
|
notifyChanged();
|
||||||
if (isEditing) {
|
if (isEditing) {
|
||||||
|
|
Loading…
Reference in New Issue