android.view.inputmethod.InputMethodSubtype Java Examples

The following examples show how to use android.view.inputmethod.InputMethodSubtype. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomInputStylePreference.java    From simple-keyboard with Apache License 2.0 6 votes vote down vote up
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 (subtype.isAsciiCapable()) {
            items.add(new SubtypeLocaleItem(subtype));
        }
    }
    // TODO: Should filter out already existing combinations of locale and layout.
    addAll(items);
}
 
Example #2
Source File: LatinIME.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
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 */);
}
 
Example #3
Source File: RichInputMethodManager.java    From simple-keyboard with Apache License 2.0 6 votes vote down vote up
private void initInternal(final Context context) {
    if (isInitialized()) {
        return;
    }
    mImmService = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
    mContext = context;
    mInputMethodInfoCache = new InputMethodInfoCache(
            mImmService, context.getPackageName());

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

    // Initialize the current input method subtype and the shortcut IME.
    refreshSubtypeCaches();
}
 
Example #4
Source File: CustomInputStyleSettingsFragment.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #5
Source File: ActionTestsBase.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
protected void doTestActionKey(final String tag, final InputMethodSubtype subtype,
        final EditorInfo editorInfo, final ExpectedActionKey expectedKey) {
    // Test text layouts.
    editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
    final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo);
    assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, expectedKey);
    assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, expectedKey);
    assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, expectedKey);
    // Test phone number layouts.
    assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE, expectedKey);
    assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE_SYMBOLS, expectedKey);
    // Test normal number layout.
    assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_NUMBER, expectedKey);
    // Test number password layout.
    editorInfo.inputType =
            InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
    final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo);
    assertActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, expectedKey);
}
 
Example #6
Source File: KlpActionLabelTests.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public void testHinglishActionLabel() {
    final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
    final Locale hi_ZZ = new Locale("hi", "ZZ");
    final InputMethodSubtype hiLatn = richImm.findSubtypeByLocaleAndKeyboardLayoutSet(
            hi_ZZ.toString(), SubtypeLocaleUtils.QWERTY);
    // This is a preliminary subtype and may not exist.
    if (hiLatn == null) {
        return;
    }
    // An action label should be displayed in subtype's locale regardless of the system locale.
    doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, new Locale("hi"));
    doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.US);
    doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.FRENCH);
    doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.ITALIAN);
    doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.JAPANESE);
}
 
Example #7
Source File: RichInputMethodSubtype.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #8
Source File: CustomInputStylePreference.java    From LokiBoard-Android-Keylogger with Apache License 2.0 6 votes vote down vote up
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));
    }
}
 
Example #9
Source File: CustomInputStyleSettingsFragment.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #10
Source File: SubtypeLocaleUtilsTests.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public void testIsRtlLanguage() {
    // Known Right-to-Left language subtypes.
    final InputMethodSubtype ARABIC = mRichImm
            .findSubtypeByLocaleAndKeyboardLayoutSet("ar", "arabic");
    assertNotNull("Arabic", ARABIC);
    final InputMethodSubtype FARSI = mRichImm
            .findSubtypeByLocaleAndKeyboardLayoutSet("fa", "farsi");
    assertNotNull("Farsi", FARSI);
    final InputMethodSubtype HEBREW = mRichImm
            .findSubtypeByLocaleAndKeyboardLayoutSet("iw", "hebrew");
    assertNotNull("Hebrew", HEBREW);

    for (final RichInputMethodSubtype subtype : mSubtypesList) {
        final InputMethodSubtype rawSubtype = subtype.getRawSubtype();
        final String subtypeName = SubtypeLocaleUtils
                .getSubtypeDisplayNameInSystemLocale(rawSubtype);
        if (rawSubtype.equals(ARABIC) || rawSubtype.equals(FARSI)
                || rawSubtype.equals(HEBREW)) {
            assertTrue(subtypeName, subtype.isRtlSubtype());
        } else {
            assertFalse(subtypeName, subtype.isRtlSubtype());
        }
    }
}
 
Example #11
Source File: AdditionalSubtypeUtilsTests.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
private static void assertEnUsDvorak(InputMethodSubtype subtype) {
    assertEquals("en_US", subtype.getLocale());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        assertEquals(EXTRA_VALUE_EN_US_DVORAK_KITKAT, subtype.getExtraValue());
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        assertEquals(EXTRA_VALUE_EN_US_DVORAK_JELLY_BEAN, subtype.getExtraValue());
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        assertEquals(EXTRA_VALUE_EN_US_DVORAK_ICS, subtype.getExtraValue());
    }
    assertTrue(subtype.containsExtraValueKey(ASCII_CAPABLE));
    assertTrue(InputMethodSubtypeCompatUtils.isAsciiCapable(subtype));
    // TODO: Enable following test
    // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    //    assertTrue(InputMethodSubtypeCompatUtils.isAsciiCapableWithAPI(subtype));
    // }
    assertTrue(subtype.containsExtraValueKey(EMOJI_CAPABLE));
    assertTrue(subtype.containsExtraValueKey(IS_ADDITIONAL_SUBTYPE));
    assertEquals("dvorak", subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET));
    assertEquals("Dvorak", subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME));
    assertEquals(KEYBOARD_MODE, subtype.getMode());
    assertEquals(SUBTYPE_ID_EN_US_DVORAK, subtype.hashCode());
}
 
Example #12
Source File: LatinIME.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #13
Source File: SubtypeLocaleUtils.java    From simple-keyboard with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #14
Source File: RichInputMethodManager.java    From LokiBoard-Android-Keylogger with Apache License 2.0 6 votes vote down vote up
private void initInternal(final Context context) {
    if (isInitialized()) {
        return;
    }
    mImmService = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
    mContext = context;
    mInputMethodInfoCache = new InputMethodInfoCache(
            mImmService, context.getPackageName());

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

    // Initialize the current input method subtype and the shortcut IME.
    refreshSubtypeCaches();
}
 
Example #15
Source File: RichInputMethodManager.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #16
Source File: RichInputMethodManager.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #17
Source File: CustomInputStylePreference.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
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));
    }
}
 
Example #18
Source File: CustomInputStyleSettingsFragment.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
private InputMethodSubtype[] getSubtypes() {
    final PreferenceGroup group = getPreferenceScreen();
    final ArrayList<InputMethodSubtype> subtypes = new ArrayList<>();
    final int count = group.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        final Preference pref = group.getPreference(i);
        if (pref instanceof CustomInputStylePreference) {
            final CustomInputStylePreference subtypePref = (CustomInputStylePreference)pref;
            // We should not save newly adding subtype to preference because it is incomplete.
            if (subtypePref.isIncomplete()) continue;
            subtypes.add(subtypePref.getSubtype());
        }
    }
    return subtypes.toArray(new InputMethodSubtype[subtypes.size()]);
}
 
Example #19
Source File: AdditionalFeaturesSettingUtils.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
@Nonnull
public static RichInputMethodSubtype createRichInputMethodSubtype(
        @Nonnull final RichInputMethodManager imm,
        @Nonnull final InputMethodSubtype subtype,
        final Context context) {
    return new RichInputMethodSubtype(subtype);
}
 
Example #20
Source File: AdditionalSubtypeUtils.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
public static String createPrefSubtypes(final InputMethodSubtype[] subtypes) {
    if (subtypes == null || subtypes.length == 0) {
        return "";
    }
    final StringBuilder sb = new StringBuilder();
    for (final InputMethodSubtype subtype : subtypes) {
        if (sb.length() > 0) {
            sb.append(PREF_SUBTYPE_SEPARATOR);
        }
        sb.append(getPrefSubtype(subtype));
    }
    return sb.toString();
}
 
Example #21
Source File: RichInputMethodManager.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
public void onSubtypeChanged(@Nonnull final InputMethodSubtype newSubtype) {
    updateCurrentSubtype(newSubtype);
    updateShortcutIme();
    if (DEBUG) {
        Log.w(TAG, "onSubtypeChanged: " + mCurrentRichInputMethodSubtype.getNameForLogging());
    }
}
 
Example #22
Source File: SubtypeLocaleUtils.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
@Nonnull
public static String getSubtypeNameForLogging(@Nullable final InputMethodSubtype subtype) {
    if (subtype == null) {
        return "<null subtype>";
    }
    return getSubtypeLocale(subtype) + "/" + getKeyboardLayoutSetName(subtype);
}
 
Example #23
Source File: LxxActionGoTests.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
public void testActionGo() {
    final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey(
            KeyboardIconsSet.NAME_GO_KEY);
    for (final InputMethodSubtype subtype : getAllSubtypesList()) {
        final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
        doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_GO, expectedKey);
    }
}
 
Example #24
Source File: AdditionalSubtypeUtils.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
public static String createPrefSubtypes(final InputMethodSubtype[] subtypes) {
    if (subtypes == null || subtypes.length == 0) {
        return "";
    }
    final StringBuilder sb = new StringBuilder();
    for (final InputMethodSubtype subtype : subtypes) {
        if (sb.length() > 0) {
            sb.append(PREF_SUBTYPE_SEPARATOR);
        }
        sb.append(getPrefSubtype(subtype));
    }
    return sb.toString();
}
 
Example #25
Source File: KeyboardLayoutSetTestsBase.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();
    final Context context = getContext();
    final Resources res = context.getResources();
    RichInputMethodManager.init(context);
    mRichImm = RichInputMethodManager.getInstance();

    // Save and reset additional subtypes preference.
    mSavedAdditionalSubtypes = mRichImm.getAdditionalSubtypes();
    final InputMethodSubtype[] predefinedAdditionalSubtypes =
            AdditionalSubtypeUtils.createAdditionalSubtypesArray(
                    AdditionalSubtypeUtils.createPrefSubtypes(
                            res.getStringArray(R.array.predefined_subtypes)));
    mRichImm.setAdditionalInputMethodSubtypes(predefinedAdditionalSubtypes);

    final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById(
            getKeyboardThemeForTests(), KeyboardTheme.KEYBOARD_THEMES);
    setContext(new ContextThemeWrapper(getContext(), keyboardTheme.mStyleId));
    KeyboardLayoutSet.onKeyboardThemeChanged();

    mScreenMetrics = Settings.readScreenMetrics(res);

    final InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme();
    final int subtypeCount = imi.getSubtypeCount();
    for (int index = 0; index < subtypeCount; index++) {
        mAllSubtypesList.add(imi.getSubtypeAt(index));
    }
}
 
Example #26
Source File: RichInputMethodManager.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
public void onSubtypeChanged(final InputMethodSubtype newSubtype) {
    updateCurrentSubtype(newSubtype);
    updateShortcutIme();
    if (DEBUG) {
        Log.w(TAG, "onSubtypeChanged: " + mCurrentRichInputMethodSubtype.getNameForLogging());
    }
}
 
Example #27
Source File: AdditionalSubtypeUtils.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
public static String createPrefSubtypes(final InputMethodSubtype[] subtypes) {
    if (subtypes == null || subtypes.length == 0) {
        return "";
    }
    final StringBuilder sb = new StringBuilder();
    for (final InputMethodSubtype subtype : subtypes) {
        if (sb.length() > 0) {
            sb.append(PREF_SUBTYPE_SEPARATOR);
        }
        sb.append(getPrefSubtype(subtype));
    }
    return sb.toString();
}
 
Example #28
Source File: RichInputMethodManager.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
private static boolean isAuxiliaryIme(final InputMethodInfo imi) {
    final int count = imi.getSubtypeCount();
    if (count == 0) {
        return false;
    }
    for (int index = 0; index < count; index++) {
        final InputMethodSubtype subtype = imi.getSubtypeAt(index);
        if (!subtype.isAuxiliary()) {
            return false;
        }
    }
    return true;
}
 
Example #29
Source File: RichInputMethodManager.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
private void switchToTargetIME(final String imiId, final InputMethodSubtype subtype,
        final InputMethodService context) {
    final IBinder token = context.getWindow().getWindow().getAttributes().token;
    if (token == null) {
        return;
    }
    final InputMethodManager imm = getInputMethodManager();
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            imm.setInputMethodAndSubtype(token, imiId, subtype);
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #30
Source File: KlpActionNoneTests.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
public void testActionNone() {
    final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey(
            KeyboardIconsSet.NAME_ENTER_KEY);
    for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) {
        final String tag = "none " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
        doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_NONE, expectedKey);
    }
}