当前位置: 首页>>代码示例>>Java>>正文


Java InputMethodSubtype类代码示例

本文整理汇总了Java中android.view.inputmethod.InputMethodSubtype的典型用法代码示例。如果您正苦于以下问题:Java InputMethodSubtype类的具体用法?Java InputMethodSubtype怎么用?Java InputMethodSubtype使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InputMethodSubtype类属于android.view.inputmethod包,在下文中一共展示了InputMethodSubtype类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readScriptId

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
static int readScriptId(final Resources resources, final InputMethodSubtype subtype) {
    final String layoutSetName = KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX
            + SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
    final int xmlId = getXmlId(resources, layoutSetName);
    final XmlResourceParser parser = resources.getXml(xmlId);
    try {
        while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
            // Bovinate through the XML stupidly searching for TAG_FEATURE, and read
            // the script Id from it.
            parser.next();
            final String tag = parser.getName();
            if (TAG_FEATURE.equals(tag)) {
                return readScriptIdFromTagFeature(resources, parser);
            }
        }
    } catch (final IOException | XmlPullParserException e) {
        throw new RuntimeException(e.getMessage() + " in " + layoutSetName, e);
    } finally {
        parser.close();
    }
    // If the tag is not found, then the default script is Latin.
    return ScriptUtils.SCRIPT_LATIN;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:24,代码来源:KeyboardLayoutSet.java

示例2: setSubtype

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
public void setSubtype(final InputMethodSubtype subtype) {
    mPreviousSubtype = mSubtype;
    mSubtype = subtype;
    if (isIncomplete()) {
        setTitle(null);
        setDialogTitle(R.string.add_style);
        setKey(KEY_NEW_SUBTYPE);
    } else {
        final String displayName =
                SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype);
        setTitle(displayName);
        setDialogTitle(displayName);
        setKey(KEY_PREFIX + subtype.getLocale() + "_"
                + SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype));
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:17,代码来源:CustomInputStylePreference.java

示例3: onSaveCustomInputStyle

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
@Override
public void onSaveCustomInputStyle(final CustomInputStylePreference stylePref) {
    final InputMethodSubtype subtype = stylePref.getSubtype();
    if (!stylePref.hasBeenModified()) {
        return;
    }
    if (findDuplicatedSubtype(subtype) == null) {
        mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
        return;
    }

    // Saved subtype is duplicated.
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    stylePref.revert();
    group.addPreference(stylePref);
    showSubtypeAlreadyExistsToast(subtype);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:19,代码来源:CustomInputStyleSettingsFragment.java

示例4: initInternal

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
private void initInternal(final Context context) {
    if (isInitialized()) {
        return;
    }
    mImmWrapper = new InputMethodManagerCompatWrapper(context);
    mContext = context;
    mInputMethodInfoCache = new InputMethodInfoCache(
            mImmWrapper.mImm, context.getPackageName());

    // Initialize additional subtypes.
    SubtypeLocaleUtils.init(context);
    final InputMethodSubtype[] additionalSubtypes = getAdditionalSubtypes();
    mImmWrapper.mImm.setAdditionalInputMethodSubtypes(
            getInputMethodIdOfThisIme(), additionalSubtypes);

    // Initialize the current input method subtype and the shortcut IME.
    refreshSubtypeCaches();
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:19,代码来源:RichInputMethodManager.java

示例5: switchToNextInputSubtypeInThisIme

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
private boolean switchToNextInputSubtypeInThisIme(final IBinder token,
        final boolean onlyCurrentIme) {
    final InputMethodManager imm = mImmWrapper.mImm;
    final InputMethodSubtype currentSubtype = imm.getCurrentInputMethodSubtype();
    final List<InputMethodSubtype> enabledSubtypes = getMyEnabledInputMethodSubtypeList(
            true /* allowsImplicitlySelectedSubtypes */);
    final int currentIndex = getSubtypeIndexInList(currentSubtype, enabledSubtypes);
    if (currentIndex == INDEX_NOT_FOUND) {
        Log.w(TAG, "Can't find current subtype in enabled subtypes: subtype="
                + SubtypeLocaleUtils.getSubtypeNameForLogging(currentSubtype));
        return false;
    }
    final int nextIndex = (currentIndex + 1) % enabledSubtypes.size();
    if (nextIndex <= currentIndex && !onlyCurrentIme) {
        // The current subtype is the last or only enabled one and it needs to switch to
        // next IME.
        return false;
    }
    final InputMethodSubtype nextSubtype = enabledSubtypes.get(nextIndex);
    setInputMethodAndSubtype(token, nextSubtype);
    return true;
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:23,代码来源:RichInputMethodManager.java

示例6: updateCustomInputStylesSummary

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
static void updateCustomInputStylesSummary(final Preference pref) {
    // When we are called from the Settings application but we are not already running, some
    // singleton and utility classes may not have been initialized.  We have to call
    // initialization method of these classes here. See {@link LatinIME#onCreate()}.
    SubtypeLocaleUtils.init(pref.getContext());

    final Resources res = pref.getContext().getResources();
    final SharedPreferences prefs = pref.getSharedPreferences();
    final String prefSubtype = Settings.readPrefAdditionalSubtypes(prefs, res);
    final InputMethodSubtype[] subtypes =
            AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype);
    final ArrayList<String> subtypeNames = new ArrayList<>();
    for (final InputMethodSubtype subtype : subtypes) {
        subtypeNames.add(SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype));
    }
    // TODO: A delimiter of custom input styles should be localized.
    pref.setSummary(TextUtils.join(", ", subtypeNames));
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:19,代码来源:CustomInputStyleSettingsFragment.java

示例7: getKeyboardLayoutSetName

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
@Nonnull
public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) {
    String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET);
    if (keyboardLayoutSet == null) {
        // This subtype doesn't have a keyboardLayoutSet extra value, so lookup its keyboard
        // layout set in sLocaleAndExtraValueToKeyboardLayoutSetMap to keep it compatible with
        // pre-JellyBean.
        final String key = subtype.getLocale() + ":" + subtype.getExtraValue();
        keyboardLayoutSet = sLocaleAndExtraValueToKeyboardLayoutSetMap.get(key);
    }
    // TODO: Remove this null check when InputMethodManager.getCurrentInputMethodSubtype is
    // fixed.
    if (keyboardLayoutSet == null) {
        Log.w(TAG, "KeyboardLayoutSet not found, use QWERTY: " +
                "locale=" + subtype.getLocale() + " extraValue=" + subtype.getExtraValue());
        return QWERTY;
    }
    return keyboardLayoutSet;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:20,代码来源:SubtypeLocaleUtils.java

示例8: getSubtypeDisplayNameInternal

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
@NonNull
private static String getSubtypeDisplayNameInternal(@NonNull final InputMethodSubtype subtype,
        @NonNull final Locale displayLocale) {
    final String replacementString = getReplacementString(subtype, displayLocale);
    // TODO: rework this for multi-lingual subtypes
    final int nameResId = subtype.getNameResId();
    final RunInLocale<String> getSubtypeName = new RunInLocale<String>() {
        @Override
        protected String job(final Resources res) {
            try {
                return res.getString(nameResId, replacementString);
            } catch (Resources.NotFoundException e) {
                // TODO: Remove this catch when InputMethodManager.getCurrentInputMethodSubtype
                // is fixed.
                Log.w(TAG, "Unknown subtype: mode=" + subtype.getMode()
                        + " nameResId=" + subtype.getNameResId()
                        + " locale=" + subtype.getLocale()
                        + " extra=" + subtype.getExtraValue()
                        + "\n" + DebugLogUtils.getStackTrace());
                return "";
            }
        }
    };
    return StringUtils.capitalizeFirstCodePoint(
            getSubtypeName.runInLocale(sResources, displayLocale), displayLocale);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:27,代码来源:SubtypeLocaleUtils.java

示例9: getKeyboardLayoutSetName

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
@NonNull
public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) {
    String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET);
    if (keyboardLayoutSet == null) {
        // This subtype doesn't have a keyboardLayoutSet extra value, so lookup its keyboard
        // layout set in sLocaleAndExtraValueToKeyboardLayoutSetMap to keep it compatible with
        // pre-JellyBean.
        final String key = subtype.getLocale() + ":" + subtype.getExtraValue();
        keyboardLayoutSet = sLocaleAndExtraValueToKeyboardLayoutSetMap.get(key);
    }
    // TODO: Remove this null check when InputMethodManager.getCurrentInputMethodSubtype is
    // fixed.
    if (keyboardLayoutSet == null) {
        android.util.Log.w(TAG, "KeyboardLayoutSet not found, use QWERTY: " +
                "locale=" + subtype.getLocale() + " extraValue=" + subtype.getExtraValue());
        return QWERTY;
    }
    return keyboardLayoutSet;
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:20,代码来源:SubtypeLocaleUtils.java

示例10: onAddCustomInputStyle

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
@Override
public void onAddCustomInputStyle(final CustomInputStylePreference stylePref) {
    mIsAddingNewSubtype = false;
    final InputMethodSubtype subtype = stylePref.getSubtype();
    if (findDuplicatedSubtype(subtype) == null) {
        mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
        mSubtypePreferenceKeyForSubtypeEnabler = stylePref.getKey();
        mSubtypeEnablerNotificationDialog = createDialog();
        mSubtypeEnablerNotificationDialog.show();
        return;
    }

    // Newly added subtype is duplicated.
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    showSubtypeAlreadyExistsToast(subtype);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:18,代码来源:CustomInputStyleSettingsFragment.java

示例11: switchSubtype

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
public void switchSubtype(final IBinder token, final RichInputMethodManager richImm) {
    final InputMethodSubtype currentSubtype = richImm.getInputMethodManager()
            .getCurrentInputMethodSubtype();
    final InputMethodSubtype lastActiveSubtype = mLastActiveSubtype;
    final boolean currentSubtypeHasBeenUsed = mCurrentSubtypeHasBeenUsed;
    if (currentSubtypeHasBeenUsed) {
        mLastActiveSubtype = currentSubtype;
        mCurrentSubtypeHasBeenUsed = false;
    }
    if (currentSubtypeHasBeenUsed
            && richImm.checkIfSubtypeBelongsToThisImeAndEnabled(lastActiveSubtype)
            && !currentSubtype.equals(lastActiveSubtype)) {
        richImm.setInputMethodAndSubtype(token, lastActiveSubtype);
        return;
    }
    richImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:18,代码来源:LatinIME.java

示例12: getEnabledSubtypesLabel

import android.view.inputmethod.InputMethodSubtype; //导入依赖的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();
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:17,代码来源:InputMethodSettingsImpl.java

示例13: onStartInputInternal

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
void onStartInputInternal(final EditorInfo editorInfo, final boolean restarting) {
    super.onStartInput(editorInfo, restarting);

    // If the primary hint language does not match the current subtype language, then try
    // to switch to the primary hint language.
    // TODO: Support all the locales in EditorInfo#hintLocales.
    final Locale primaryHintLocale = EditorInfoCompatUtils.getPrimaryHintLocale(editorInfo);
    if (primaryHintLocale == null) {
        return;
    }
    final InputMethodSubtype newSubtype = mRichImm.findSubtypeByLocale(primaryHintLocale);
    if (newSubtype == null || newSubtype.equals(mRichImm.getCurrentSubtype().getRawSubtype())) {
        return;
    }
    mHandler.postSwitchLanguage(newSubtype);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:17,代码来源:LatinIME.java

示例14: createAdditionalSubtypeInternal

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
private static InputMethodSubtype createAdditionalSubtypeInternal(
        final String localeString, final String keyboardLayoutSetName,
        final boolean isAsciiCapable, final boolean isEmojiCapable) {
    final int nameId = SubtypeLocaleUtils.getSubtypeNameId(localeString, keyboardLayoutSetName);
    final String platformVersionDependentExtraValues = getPlatformVersionDependentExtraValue(
            localeString, keyboardLayoutSetName, isAsciiCapable, isEmojiCapable);
    final int platformVersionIndependentSubtypeId =
            getPlatformVersionIndependentSubtypeId(localeString, keyboardLayoutSetName);
    // NOTE: In KitKat and later, InputMethodSubtypeBuilder#setIsAsciiCapable is also available.
    // TODO: Use InputMethodSubtypeBuilder#setIsAsciiCapable when appropriate.
    return InputMethodSubtypeCompatUtils.newInputMethodSubtype(nameId,
            R.drawable.ic_ime_switcher_dark, localeString, KEYBOARD_MODE,
            platformVersionDependentExtraValues,
            false /* isAuxiliary */, false /* overrideImplicitlyEnabledSubtype */,
            platformVersionIndependentSubtypeId);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:17,代码来源:AdditionalSubtypeUtils.java

示例15: getNoLanguageSubtype

import android.view.inputmethod.InputMethodSubtype; //导入依赖的package包/类
@Nonnull
public static RichInputMethodSubtype getNoLanguageSubtype() {
    RichInputMethodSubtype noLanguageSubtype = sNoLanguageSubtype;
    if (noLanguageSubtype == null) {
        final InputMethodSubtype rawNoLanguageSubtype = RichInputMethodManager.getInstance()
                .findSubtypeByLocaleAndKeyboardLayoutSet(
                        SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY);
        if (rawNoLanguageSubtype != null) {
            noLanguageSubtype = new RichInputMethodSubtype(rawNoLanguageSubtype);
        }
    }
    if (noLanguageSubtype != null) {
        sNoLanguageSubtype = noLanguageSubtype;
        return noLanguageSubtype;
    }
    Log.w(TAG, "Can't find any language with QWERTY subtype");
    Log.w(TAG, "No input method subtype found; returning dummy subtype: "
            + DUMMY_NO_LANGUAGE_SUBTYPE);
    return DUMMY_NO_LANGUAGE_SUBTYPE;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:21,代码来源:RichInputMethodSubtype.java


注:本文中的android.view.inputmethod.InputMethodSubtype类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。