Search in sources :

Example 16 with InputMethodPreference

use of com.android.settingslib.inputmethod.InputMethodPreference in project android_packages_apps_Settings by LineageOS.

the class AvailableVirtualKeyboardFragment method onSaveInputMethodPreference.

@Override
public void onSaveInputMethodPreference(final InputMethodPreference pref) {
    final boolean hasHardwareKeyboard = getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
    InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(), mImm.getInputMethodList(), hasHardwareKeyboard);
    // Update input method settings and preference list.
    mInputMethodSettingValues.refreshAllInputMethodAndSubtypes();
    for (final InputMethodPreference p : mInputMethodPreferenceList) {
        p.updatePreferenceViews();
    }
}
Also used : InputMethodPreference(com.android.settingslib.inputmethod.InputMethodPreference)

Example 17 with InputMethodPreference

use of com.android.settingslib.inputmethod.InputMethodPreference in project android_packages_apps_Settings by crdroidandroid.

the class AvailableVirtualKeyboardFragment method onSaveInputMethodPreference.

@Override
public void onSaveInputMethodPreference(final InputMethodPreference pref) {
    final boolean hasHardwareKeyboard = getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
    InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(), mImm.getInputMethodList(), hasHardwareKeyboard);
    // Update input method settings and preference list.
    mInputMethodSettingValues.refreshAllInputMethodAndSubtypes();
    for (final InputMethodPreference p : mInputMethodPreferenceList) {
        p.updatePreferenceViews();
    }
}
Also used : InputMethodPreference(com.android.settingslib.inputmethod.InputMethodPreference)

Example 18 with InputMethodPreference

use of com.android.settingslib.inputmethod.InputMethodPreference in project android_packages_apps_Settings by SudaMod.

the class VirtualKeyboardFragment method updateInputMethodPreferenceViews.

private void updateInputMethodPreferenceViews() {
    // Clear existing "InputMethodPreference"s
    mInputMethodPreferenceList.clear();
    List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser();
    final Context context = getPrefContext();
    final List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
    final int N = (imis == null ? 0 : imis.size());
    for (int i = 0; i < N; ++i) {
        final InputMethodInfo imi = imis.get(i);
        final boolean isAllowedByOrganization = permittedList == null || permittedList.contains(imi.getPackageName());
        Drawable icon;
        try {
            // TODO: Consider other ways to retrieve an icon to show here.
            icon = getActivity().getPackageManager().getApplicationIcon(imi.getPackageName());
        } catch (Exception e) {
            // TODO: Consider handling the error differently perhaps by showing default icons.
            icon = NO_ICON;
        }
        final InputMethodPreference pref = new InputMethodPreference(context, imi, false, /* isImeEnabler */
        isAllowedByOrganization, null);
        pref.setIcon(icon);
        mInputMethodPreferenceList.add(pref);
    }
    final Collator collator = Collator.getInstance();
    mInputMethodPreferenceList.sort((lhs, rhs) -> lhs.compareTo(rhs, collator));
    getPreferenceScreen().removeAll();
    for (int i = 0; i < N; ++i) {
        final InputMethodPreference pref = mInputMethodPreferenceList.get(i);
        pref.setOrder(i);
        getPreferenceScreen().addPreference(pref);
        InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference(pref);
        pref.updatePreferenceViews();
    }
    mAddVirtualKeyboardScreen.setIcon(R.drawable.ic_add_24dp);
    mAddVirtualKeyboardScreen.setOrder(N);
    getPreferenceScreen().addPreference(mAddVirtualKeyboardScreen);
}
Also used : Context(android.content.Context) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) InputMethodPreference(com.android.settingslib.inputmethod.InputMethodPreference) InputMethodInfo(android.view.inputmethod.InputMethodInfo) Collator(java.text.Collator)

Example 19 with InputMethodPreference

use of com.android.settingslib.inputmethod.InputMethodPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AvailableVirtualKeyboardFragment method onSaveInputMethodPreference.

@Override
public void onSaveInputMethodPreference(final InputMethodPreference pref) {
    final boolean hasHardwareKeyboard = getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
    InputMethodAndSubtypeUtilCompat.saveInputMethodSubtypeList(this, getContentResolver(), mImm.getInputMethodList(), hasHardwareKeyboard);
    // Update input method settings and preference list.
    mInputMethodSettingValues.refreshAllInputMethodAndSubtypes();
    for (final InputMethodPreference p : mInputMethodPreferenceList) {
        p.updatePreferenceViews();
    }
}
Also used : InputMethodPreference(com.android.settingslib.inputmethod.InputMethodPreference)

Example 20 with InputMethodPreference

use of com.android.settingslib.inputmethod.InputMethodPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AvailableVirtualKeyboardFragment method updateInputMethodPreferenceViews.

private void updateInputMethodPreferenceViews() {
    mInputMethodSettingValues.refreshAllInputMethodAndSubtypes();
    // Clear existing "InputMethodPreference"s
    mInputMethodPreferenceList.clear();
    List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser();
    final Context context = getPrefContext();
    final List<InputMethodInfo> imis = mInputMethodSettingValues.getInputMethodList();
    final int numImis = (imis == null ? 0 : imis.size());
    for (int i = 0; i < numImis; ++i) {
        final InputMethodInfo imi = imis.get(i);
        final boolean isAllowedByOrganization = permittedList == null || permittedList.contains(imi.getPackageName());
        final InputMethodPreference pref = new InputMethodPreference(context, imi, true, isAllowedByOrganization, this);
        pref.setIcon(imi.loadIcon(context.getPackageManager()));
        mInputMethodPreferenceList.add(pref);
    }
    final Collator collator = Collator.getInstance();
    mInputMethodPreferenceList.sort((lhs, rhs) -> lhs.compareTo(rhs, collator));
    getPreferenceScreen().removeAll();
    for (int i = 0; i < numImis; ++i) {
        final InputMethodPreference pref = mInputMethodPreferenceList.get(i);
        pref.setOrder(i);
        getPreferenceScreen().addPreference(pref);
        InputMethodAndSubtypeUtilCompat.removeUnnecessaryNonPersistentPreference(pref);
        pref.updatePreferenceViews();
    }
}
Also used : Context(android.content.Context) InputMethodPreference(com.android.settingslib.inputmethod.InputMethodPreference) InputMethodInfo(android.view.inputmethod.InputMethodInfo) Collator(java.text.Collator)

Aggregations

InputMethodPreference (com.android.settingslib.inputmethod.InputMethodPreference)22 InputMethodInfo (android.view.inputmethod.InputMethodInfo)15 Collator (java.text.Collator)15 Context (android.content.Context)14 Drawable (android.graphics.drawable.Drawable)8 ColorDrawable (android.graphics.drawable.ColorDrawable)6 PackageManager (android.content.pm.PackageManager)5 ArrayList (java.util.ArrayList)1