本文整理汇总了Java中android.view.inputmethod.InputMethodInfo类的典型用法代码示例。如果您正苦于以下问题:Java InputMethodInfo类的具体用法?Java InputMethodInfo怎么用?Java InputMethodInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InputMethodInfo类属于android.view.inputmethod包,在下文中一共展示了InputMethodInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: switchToNextInputMethodAndSubtype
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
private boolean switchToNextInputMethodAndSubtype(final IBinder token) {
final InputMethodManager imm = mImmWrapper.mImm;
final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList();
final int currentIndex = getImiIndexInList(getInputMethodInfoOfThisIme(), enabledImis);
if (currentIndex == INDEX_NOT_FOUND) {
Log.w(TAG, "Can't find current IME in enabled IMEs: IME package="
+ getInputMethodInfoOfThisIme().getPackageName());
return false;
}
final InputMethodInfo nextImi = getNextNonAuxiliaryIme(currentIndex, enabledImis);
final List<InputMethodSubtype> enabledSubtypes = getEnabledInputMethodSubtypeList(nextImi,
true /* allowsImplicitlySelectedSubtypes */);
if (enabledSubtypes.isEmpty()) {
// The next IME has no subtype.
imm.setInputMethod(token, nextImi.getId());
return true;
}
final InputMethodSubtype firstSubtype = enabledSubtypes.get(0);
imm.setInputMethodAndSubtype(token, nextImi.getId(), firstSubtype);
return true;
}
示例2: SubtypeLocaleAdapter
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
public SubtypeLocaleAdapter(final Context context) {
super(context, android.R.layout.simple_spinner_item);
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
final TreeSet<SubtypeLocaleItem> items = new TreeSet<>();
final InputMethodInfo imi = RichInputMethodManager.getInstance()
.getInputMethodInfoOfThisIme();
final int count = imi.getSubtypeCount();
for (int i = 0; i < count; i++) {
final InputMethodSubtype subtype = imi.getSubtypeAt(i);
if (DEBUG_SUBTYPE_ID) {
Log.d(TAG_SUBTYPE, String.format("%-6s 0x%08x %11d %s",
subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype)));
}
if (InputMethodSubtypeCompatUtils.isAsciiCapable(subtype)) {
items.add(new SubtypeLocaleItem(subtype));
}
}
// TODO: Should filter out already existing combinations of locale and layout.
addAll(items);
}
示例3: getEnabledSubtypesLabel
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
private static String getEnabledSubtypesLabel(
Context context, InputMethodManager imm, InputMethodInfo imi) {
if (context == null || imm == null || imi == null) return null;
final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
final StringBuilder sb = new StringBuilder();
final int N = subtypes.size();
for (int i = 0; i < N; ++i) {
final InputMethodSubtype subtype = subtypes.get(i);
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(subtype.getDisplayName(context, imi.getPackageName(),
imi.getServiceInfo().applicationInfo));
}
return sb.toString();
}
示例4: startVoiceRecognition
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
/**
* Switches to Voice IME.
*/
@Override
public void startVoiceRecognition(String language) {
InputMethodManager inputMethodManager = getInputMethodManager(mInputMethodService);
InputMethodInfo inputMethodInfo = getVoiceImeInputMethodInfo(inputMethodManager);
if (inputMethodInfo == null) {
return;
}
inputMethodManager.setInputMethodAndSubtype(mInputMethodService.getWindow().getWindow()
.getAttributes().token,
inputMethodInfo.getId(),
getVoiceImeSubtype(inputMethodManager, inputMethodInfo));
}
示例5: isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() {
final Locale systemLocale = mContext.getResources().getConfiguration().locale;
final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes = new HashSet<>();
final InputMethodManager inputMethodManager = getInputMethodManager();
final List<InputMethodInfo> enabledInputMethodInfoList =
inputMethodManager.getEnabledInputMethodList();
for (final InputMethodInfo info : enabledInputMethodInfoList) {
final List<InputMethodSubtype> enabledSubtypes =
inputMethodManager.getEnabledInputMethodSubtypeList(
info, true /* allowsImplicitlySelectedSubtypes */);
if (enabledSubtypes.isEmpty()) {
// An IME with no subtypes is found.
return false;
}
enabledSubtypesOfEnabledImes.addAll(enabledSubtypes);
}
for (final InputMethodSubtype subtype : enabledSubtypesOfEnabledImes) {
if (!subtype.isAuxiliary() && !subtype.getLocale().isEmpty()
&& !systemLocale.equals(SubtypeLocaleUtils.getSubtypeLocale(subtype))) {
return false;
}
}
return true;
}
示例6: isWebKeyboardEnabled
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
/**
*
* @return
*/
private boolean isWebKeyboardEnabled() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> enabledList = imm.getEnabledInputMethodList();
Iterator<InputMethodInfo> it = enabledList.iterator();
boolean available = false;
while (it.hasNext()) {
available = it.next()
.getServiceName()
.equals(RemoteKeyboardService.class.getCanonicalName());
if (available) {
break;
}
}
return available;
}
示例7: getInputLanguages
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
/**
* Gets input languages
*
* @param context Application context
* @return List of input languages
*/
private static List<String> getInputLanguages(Context context) {
List<String> languages = new ArrayList<>();
try {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> ims = imm.getEnabledInputMethodList();
for (InputMethodInfo method : ims) {
List<InputMethodSubtype> subMethods = imm.getEnabledInputMethodSubtypeList(method, true);
for (InputMethodSubtype subMethod : subMethods) {
if ("keyboard".equals(subMethod.getMode())) {
String currentLocale = subMethod.getLocale();
String language = cleanUpLanguageCode(new Locale(currentLocale).getLanguage());
if (!languages.contains(language)) {
languages.add(language);
}
}
}
}
} catch (Exception ex) {
LOG.warn("Cannot get user input languages\r\n", ex);
}
return languages;
}
示例8: getEnableInputMethodInfor
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
/**
* 获取已激活输入法的详细信息
* @param context
* @param packageName 输入法应用的包名
* @return
*/
public static InputMethodInfo getEnableInputMethodInfor(Context context, String packageName) {
if (packageName == null) {
return null;
}
final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> imeInfoList = imm.getEnabledInputMethodList();
if (imeInfoList != null) {
for (InputMethodInfo imeInfo : imeInfoList) {
if (packageName.equals(imeInfo.getPackageName())) {
return imeInfo;
}
}
}
return null;
}
示例9: getIme
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
@Nullable
public static InputMethodInfo getIme(Context context) {
final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
final InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();
if (ims != null) {
for (InputMethodInfo imi : imm.getEnabledInputMethodList()) {
if (imi == null) {
continue;
}
for (int i = 0; i < imi.getSubtypeCount(); i++) {
if (ims.equals(imi.getSubtypeAt(i))) {
return imi;
}
}
}
}
return null;
}
示例10: getKeyboards
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
public static List<String> getKeyboards(Context context) {
InputMethodManager imeManager = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imeManager == null) {
return Collections.emptyList();
}
List<InputMethodInfo> imesInfo = imeManager.getEnabledInputMethodList();
List<String> keyboards = new ArrayList<>(imesInfo.size());
for (InputMethodInfo imi : imesInfo) {
keyboards.add(imi.getId());
}
return keyboards;
}
示例11: retrieveActiveInputMethod
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
protected ComponentName retrieveActiveInputMethod() {
if (null == mContext) return null;
final String id = Settings.Secure.getString(
mContext.getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD
);
if (TextUtils.isEmpty(id)) return null;
List<InputMethodInfo> mInputMethodProperties = mInputMethodManager.getEnabledInputMethodList();
for (InputMethodInfo mInputMethod : mInputMethodProperties) {
if (id.equals(mInputMethod.getId())) {
return mInputMethod.getComponent();
}
}
return null;
}
示例12: getIMELocales
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
/**
* Gets the set of locales supported by the current enabled Input Methods.
* @param context A {@link Context} instance.
* @return A possibly-empty {@link Set} of locale strings.
*/
public static Set<String> getIMELocales(Context context) {
LinkedHashSet<String> locales = new LinkedHashSet<String>();
InputMethodManager imManager =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> enabledMethods = imManager.getEnabledInputMethodList();
for (int i = 0; i < enabledMethods.size(); i++) {
List<InputMethodSubtype> subtypes =
imManager.getEnabledInputMethodSubtypeList(enabledMethods.get(i), true);
if (subtypes == null) continue;
for (int j = 0; j < subtypes.size(); j++) {
String locale = ApiCompatibilityUtils.getLocale(subtypes.get(j));
if (!TextUtils.isEmpty(locale)) locales.add(locale);
}
}
return locales;
}
示例13: isUsingCustomInputMethod
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
public static boolean isUsingCustomInputMethod(Activity context) {
if (context == null) return false;
InputMethodManager imm = (InputMethodManager) context.getSystemService(
Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> mInputMethodProperties = imm.getEnabledInputMethodList();
final int N = mInputMethodProperties.size();
for (int i = 0; i < N; i++) {
InputMethodInfo imi = mInputMethodProperties.get(i);
if (imi.getId().equals(
Settings.Secure.getString(context.getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD))) {
if ((imi.getServiceInfo().applicationInfo.flags &
ApplicationInfo.FLAG_SYSTEM) == 0) {
return true;
}
}
}
return false;
}
示例14: isKeyboardEnabled
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
private boolean isKeyboardEnabled() {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> inputMethodList = inputMethodManager.getEnabledInputMethodList();
ComponentName ctrlV = new ComponentName(this, CtrlVKeyboard.class);
boolean ctrlVIsEnabled = false;
int i = 0;
while (!ctrlVIsEnabled && i < inputMethodList.size()) {
if (inputMethodList.get(i).getComponent().equals(ctrlV)) {
ctrlVIsEnabled = true;
}
i++;
}
return ctrlVIsEnabled;
}
示例15: switchToNextInputMethodAndSubtype
import android.view.inputmethod.InputMethodInfo; //导入依赖的package包/类
private boolean switchToNextInputMethodAndSubtype(final IBinder token) {
final InputMethodManager imm = mImmWrapper.mImm;
final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList();
final int currentIndex = getImiIndexInList(mInputMethodInfoOfThisIme, enabledImis);
if (currentIndex == INDEX_NOT_FOUND) {
Log.w(TAG, "Can't find current IME in enabled IMEs: IME package="
+ mInputMethodInfoOfThisIme.getPackageName());
return false;
}
final InputMethodInfo nextImi = getNextNonAuxiliaryIme(currentIndex, enabledImis);
final List<InputMethodSubtype> enabledSubtypes = imm.getEnabledInputMethodSubtypeList(
nextImi, true /* allowsImplicitlySelectedSubtypes */);
if (enabledSubtypes.isEmpty()) {
// The next IME has no subtype.
imm.setInputMethod(token, nextImi.getId());
return true;
}
final InputMethodSubtype firstSubtype = enabledSubtypes.get(0);
imm.setInputMethodAndSubtype(token, nextImi.getId(), firstSubtype);
return true;
}