public class InputMethodUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
InputMethodUtils.InputMethodSettings
Utility class for putting and getting settings for InputMethod
TODO: Move all putters and getters of settings to this class.
|
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
static int |
NOT_A_SUBTYPE_ID |
static String |
SUBTYPE_MODE_ANY |
static String |
SUBTYPE_MODE_KEYBOARD |
static String |
SUBTYPE_MODE_VOICE |
Modifier and Type | Method and Description |
---|---|
static String |
buildInputMethodsAndSubtypesString(ArrayMap<String,ArraySet<String>> map) |
static boolean |
canAddToLastInputMethod(InputMethodSubtype subtype) |
static boolean |
checkIfPackageBelongsToUid(AppOpsManager appOpsManager,
int uid,
String packageName)
Returns true if a package name belongs to a UID.
|
static Locale |
constructLocaleFromString(String localeStr) |
static boolean |
containsSubtypeOf(InputMethodInfo imi,
Locale locale,
boolean checkCountry,
String mode) |
static InputMethodSubtype |
findLastResortApplicableSubtypeLocked(Resources res,
List<InputMethodSubtype> subtypes,
String mode,
String locale,
boolean canIgnoreLocaleAsLastResort)
If there are no selected subtypes, tries finding the most applicable one according to the
given locale.
|
static String |
getApiCallStack() |
static ArrayList<InputMethodInfo> |
getDefaultEnabledImes(Context context,
boolean isSystemReady,
ArrayList<InputMethodInfo> imis) |
static Locale |
getFallbackLocaleForDefaultIme(ArrayList<InputMethodInfo> imis,
Context context) |
static CharSequence |
getImeAndSubtypeDisplayName(Context context,
InputMethodInfo imi,
InputMethodSubtype subtype) |
static ArrayList<InputMethodSubtype> |
getImplicitlyApplicableSubtypesLocked(Resources res,
InputMethodInfo imi) |
static String |
getLanguageFromLocaleString(String locale)
Returns the language component of a given locale string.
|
static InputMethodInfo |
getMostApplicableDefaultIME(List<InputMethodInfo> enabledImes) |
static ArrayList<InputMethodSubtype> |
getOverridingImplicitlyEnabledSubtypes(InputMethodInfo imi,
String mode) |
static int |
getSubtypeIdFromHashCode(InputMethodInfo imi,
int subtypeHashCode) |
static ArrayList<InputMethodSubtype> |
getSubtypes(InputMethodInfo imi) |
static ArrayList<Locale> |
getSuitableLocalesForSpellChecker(Locale systemLocale)
Returns a list of
Locale in the order of appropriateness for the default spell
checker service. |
static Locale |
getSystemLocaleFromContext(Context context) |
static boolean |
isSystemIme(InputMethodInfo inputMethod) |
static boolean |
isSystemImeThatHasSubtypeOf(InputMethodInfo imi,
Context context,
boolean checkDefaultAttribute,
Locale requiredLocale,
boolean checkCountry,
String requiredSubtypeMode) |
static boolean |
isValidSubtypeId(InputMethodInfo imi,
int subtypeHashCode) |
static ArrayMap<String,ArraySet<String>> |
parseInputMethodsAndSubtypesString(String inputMethodsAndSubtypesString)
Parses the setting stored input methods and subtypes string value.
|
static void |
setNonSelectedSystemImesDisabledUntilUsed(IPackageManager packageManager,
List<InputMethodInfo> enabledImis,
int userId,
String callingPackage) |
public static final boolean DEBUG
public static final int NOT_A_SUBTYPE_ID
public static final String SUBTYPE_MODE_ANY
public static final String SUBTYPE_MODE_KEYBOARD
public static final String SUBTYPE_MODE_VOICE
public static String getApiCallStack()
public static boolean isSystemIme(InputMethodInfo inputMethod)
public static boolean isSystemImeThatHasSubtypeOf(InputMethodInfo imi, Context context, boolean checkDefaultAttribute, Locale requiredLocale, boolean checkCountry, String requiredSubtypeMode)
public static Locale getFallbackLocaleForDefaultIme(ArrayList<InputMethodInfo> imis, Context context)
public static ArrayList<InputMethodInfo> getDefaultEnabledImes(Context context, boolean isSystemReady, ArrayList<InputMethodInfo> imis)
public static boolean containsSubtypeOf(InputMethodInfo imi, Locale locale, boolean checkCountry, String mode)
public static ArrayList<InputMethodSubtype> getSubtypes(InputMethodInfo imi)
public static ArrayList<InputMethodSubtype> getOverridingImplicitlyEnabledSubtypes(InputMethodInfo imi, String mode)
public static InputMethodInfo getMostApplicableDefaultIME(List<InputMethodInfo> enabledImes)
public static boolean isValidSubtypeId(InputMethodInfo imi, int subtypeHashCode)
public static int getSubtypeIdFromHashCode(InputMethodInfo imi, int subtypeHashCode)
public static ArrayList<InputMethodSubtype> getImplicitlyApplicableSubtypesLocked(Resources res, InputMethodInfo imi)
public static String getLanguageFromLocaleString(String locale)
Locale.toLanguageTag()
and Locale.forLanguageTag(String)
public static InputMethodSubtype findLastResortApplicableSubtypeLocked(Resources res, List<InputMethodSubtype> subtypes, String mode, String locale, boolean canIgnoreLocaleAsLastResort)
subtypes
- this function will search the most applicable subtype in subtypesmode
- subtypes will be filtered by modelocale
- subtypes will be filtered by localecanIgnoreLocaleAsLastResort
- if this function can't find the most applicable subtype,
it will return the first subtype matched with modepublic static boolean canAddToLastInputMethod(InputMethodSubtype subtype)
public static void setNonSelectedSystemImesDisabledUntilUsed(IPackageManager packageManager, List<InputMethodInfo> enabledImis, int userId, String callingPackage)
public static CharSequence getImeAndSubtypeDisplayName(Context context, InputMethodInfo imi, InputMethodSubtype subtype)
public static boolean checkIfPackageBelongsToUid(AppOpsManager appOpsManager, int uid, String packageName)
This is a simple wrapper of AppOpsManager.checkPackage(int, String)
.
appOpsManager
- the AppOpsManager
object to be used for the validation.uid
- the UID to be validated.packageName
- the package name.true
if the package name belongs to the UID.public static ArrayMap<String,ArraySet<String>> parseInputMethodsAndSubtypesString(String inputMethodsAndSubtypesString)
inputMethodsAndSubtypesString
- The input method subtypes value stored in settings.public static String buildInputMethodsAndSubtypesString(ArrayMap<String,ArraySet<String>> map)
public static ArrayList<Locale> getSuitableLocalesForSpellChecker(Locale systemLocale)
Locale
in the order of appropriateness for the default spell
checker service.
If the system language is English, and the region is also explicitly specified in the system locale, the following fallback order will be applied.
If the system language is English, but no region is specified in the system locale, the following fallback order will be applied.
If the system language is not English, the following fallback order will be applied.
systemLocale
- the current system locale to be taken into consideration.Locale
. The first one is considered to be most appropriate.