android.view.inputmethod.InputMethodSubtype#getNameResId ( )源码实例Demo

下面列出了android.view.inputmethod.InputMethodSubtype#getNameResId ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openboard   文件: SubtypeLocaleUtils.java
@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);
}
 
private static String getSubtypeDisplayNameInternal(final InputMethodSubtype subtype,
        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);
}
 
源代码3 项目: simple-keyboard   文件: SubtypeLocaleUtils.java
private static String getSubtypeDisplayNameInternal(final InputMethodSubtype subtype,
        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);
}
 
源代码4 项目: AOSP-Kayboard-7.1.2   文件: SubtypeLocaleUtils.java
@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);
}
 
源代码5 项目: Indic-Keyboard   文件: SubtypeLocaleUtils.java
@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);
}
 
源代码6 项目: android_9.0.0_r45   文件: InputMethodService.java
/**
 * Called when the subtype was changed.
 * @param newSubtype the subtype which is being changed to.
 */
protected void onCurrentInputMethodSubtypeChanged(InputMethodSubtype newSubtype) {
    if (DEBUG) {
        int nameResId = newSubtype.getNameResId();
        String mode = newSubtype.getMode();
        String output = "changeInputMethodSubtype:"
            + (nameResId == 0 ? "<none>" : getString(nameResId)) + ","
            + mode + ","
            + newSubtype.getLocale() + "," + newSubtype.getExtraValue();
        Log.v(TAG, "--- " + output);
    }
}
 
源代码7 项目: openboard   文件: AdditionalSubtypeUtils.java
public static InputMethodSubtype[] createAdditionalSubtypesArray(final String prefSubtypes) {
    if (TextUtils.isEmpty(prefSubtypes)) {
        return EMPTY_SUBTYPE_ARRAY;
    }
    final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR);
    final ArrayList<InputMethodSubtype> subtypesList = new ArrayList<>(prefSubtypeArray.length);
    for (final String prefSubtype : prefSubtypeArray) {
        final String[] elems = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
        if (elems.length != LENGTH_WITHOUT_EXTRA_VALUE
                && elems.length != LENGTH_WITH_EXTRA_VALUE) {
            Log.w(TAG, "Unknown additional subtype specified: " + prefSubtype + " in "
                    + prefSubtypes);
            continue;
        }
        final String localeString = elems[INDEX_OF_LOCALE];
        final String keyboardLayoutSetName = elems[INDEX_OF_KEYBOARD_LAYOUT];
        // Here we assume that all the additional subtypes have AsciiCapable and EmojiCapable.
        // This is actually what the setting dialog for additional subtype is doing.
        final InputMethodSubtype subtype = createAsciiEmojiCapableAdditionalSubtype(
                localeString, keyboardLayoutSetName);
        if (subtype.getNameResId() == SubtypeLocaleUtils.UNKNOWN_KEYBOARD_LAYOUT) {
            // Skip unknown keyboard layout subtype. This may happen when predefined keyboard
            // layout has been removed.
            continue;
        }
        subtypesList.add(subtype);
    }
    return subtypesList.toArray(new InputMethodSubtype[subtypesList.size()]);
}
 
public static InputMethodSubtype[] createAdditionalSubtypesArray(final String prefSubtypes) {
    if (TextUtils.isEmpty(prefSubtypes)) {
        return EMPTY_SUBTYPE_ARRAY;
    }
    final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR);
    final ArrayList<InputMethodSubtype> subtypesList = new ArrayList<>(prefSubtypeArray.length);
    for (final String prefSubtype : prefSubtypeArray) {
        final String[] elems = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
        if (elems.length != LENGTH_WITHOUT_EXTRA_VALUE
                && elems.length != LENGTH_WITH_EXTRA_VALUE) {
            Log.w(TAG, "Unknown additional subtype specified: " + prefSubtype + " in "
                    + prefSubtypes);
            continue;
        }
        final String localeString = elems[INDEX_OF_LOCALE];
        final String keyboardLayoutSetName = elems[INDEX_OF_KEYBOARD_LAYOUT];
        // Here we assume that all the additional subtypes have AsciiCapable and EmojiCapable.
        // This is actually what the setting dialog for additional subtype is doing.
        final InputMethodSubtype subtype = createAsciiEmojiCapableAdditionalSubtype(
                localeString, keyboardLayoutSetName);
        if (subtype.getNameResId() == SubtypeLocaleUtils.UNKNOWN_KEYBOARD_LAYOUT) {
            // Skip unknown keyboard layout subtype. This may happen when predefined keyboard
            // layout has been removed.
            continue;
        }
        subtypesList.add(subtype);
    }
    return subtypesList.toArray(new InputMethodSubtype[subtypesList.size()]);
}
 
源代码9 项目: simple-keyboard   文件: AdditionalSubtypeUtils.java
public static InputMethodSubtype[] createAdditionalSubtypesArray(final String prefSubtypes) {
    if (TextUtils.isEmpty(prefSubtypes)) {
        return EMPTY_SUBTYPE_ARRAY;
    }
    final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR);
    final ArrayList<InputMethodSubtype> subtypesList = new ArrayList<>(prefSubtypeArray.length);
    for (final String prefSubtype : prefSubtypeArray) {
        final String[] elems = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
        if (elems.length != LENGTH_WITHOUT_EXTRA_VALUE
                && elems.length != LENGTH_WITH_EXTRA_VALUE) {
            Log.w(TAG, "Unknown additional subtype specified: " + prefSubtype + " in "
                    + prefSubtypes);
            continue;
        }
        final String localeString = elems[INDEX_OF_LOCALE];
        final String keyboardLayoutSetName = elems[INDEX_OF_KEYBOARD_LAYOUT];
        // Here we assume that all the additional subtypes have AsciiCapable and EmojiCapable.
        // This is actually what the setting dialog for additional subtype is doing.
        final InputMethodSubtype subtype = createAdditionalSubtype(
                localeString, keyboardLayoutSetName);
        if (subtype.getNameResId() == SubtypeLocaleUtils.UNKNOWN_KEYBOARD_LAYOUT) {
            // Skip unknown keyboard layout subtype. This may happen when predefined keyboard
            // layout has been removed.
            continue;
        }
        subtypesList.add(subtype);
    }
    return subtypesList.toArray(new InputMethodSubtype[subtypesList.size()]);
}
 
public static InputMethodSubtype[] createAdditionalSubtypesArray(final String prefSubtypes) {
    if (TextUtils.isEmpty(prefSubtypes)) {
        return EMPTY_SUBTYPE_ARRAY;
    }
    final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR);
    final ArrayList<InputMethodSubtype> subtypesList = new ArrayList<>(prefSubtypeArray.length);
    for (final String prefSubtype : prefSubtypeArray) {
        final String elems[] = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
        if (elems.length != LENGTH_WITHOUT_EXTRA_VALUE
                && elems.length != LENGTH_WITH_EXTRA_VALUE) {
            Log.w(TAG, "Unknown additional subtype specified: " + prefSubtype + " in "
                    + prefSubtypes);
            continue;
        }
        final String localeString = elems[INDEX_OF_LOCALE];
        final String keyboardLayoutSetName = elems[INDEX_OF_KEYBOARD_LAYOUT];
        // Here we assume that all the additional subtypes have AsciiCapable and EmojiCapable.
        // This is actually what the setting dialog for additional subtype is doing.
        final InputMethodSubtype subtype = createAsciiEmojiCapableAdditionalSubtype(
                localeString, keyboardLayoutSetName);
        if (subtype.getNameResId() == SubtypeLocaleUtils.UNKNOWN_KEYBOARD_LAYOUT) {
            // Skip unknown keyboard layout subtype. This may happen when predefined keyboard
            // layout has been removed.
            continue;
        }
        subtypesList.add(subtype);
    }
    return subtypesList.toArray(new InputMethodSubtype[subtypesList.size()]);
}
 
源代码11 项目: Indic-Keyboard   文件: AdditionalSubtypeUtils.java
public static InputMethodSubtype[] createAdditionalSubtypesArray(final String prefSubtypes) {
    if (TextUtils.isEmpty(prefSubtypes)) {
        return EMPTY_SUBTYPE_ARRAY;
    }
    final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR);
    final ArrayList<InputMethodSubtype> subtypesList = new ArrayList<>(prefSubtypeArray.length);
    for (final String prefSubtype : prefSubtypeArray) {
        final String elems[] = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
        if (elems.length != LENGTH_WITHOUT_EXTRA_VALUE
                && elems.length != LENGTH_WITH_EXTRA_VALUE) {
            Log.w(TAG, "Unknown additional subtype specified: " + prefSubtype + " in "
                    + prefSubtypes);
            continue;
        }
        final String localeString = elems[INDEX_OF_LOCALE];
        final String keyboardLayoutSetName = elems[INDEX_OF_KEYBOARD_LAYOUT];
        // Here we assume that all the additional subtypes have AsciiCapable and EmojiCapable.
        // This is actually what the setting dialog for additional subtype is doing.
        final InputMethodSubtype subtype = createAsciiEmojiCapableAdditionalSubtype(
                localeString, keyboardLayoutSetName);
        if (subtype.getNameResId() == SubtypeLocaleUtils.UNKNOWN_KEYBOARD_LAYOUT) {
            // Skip unknown keyboard layout subtype. This may happen when predefined keyboard
            // layout has been removed.
            continue;
        }
        subtypesList.add(subtype);
    }
    return subtypesList.toArray(new InputMethodSubtype[subtypesList.size()]);
}