Search in sources :

Example 6 with InputMethodPreference

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

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 PackageManager packageManager = getActivity().getPackageManager();
    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(getInputMethodIcon(packageManager, imi));
        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);
        InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference(pref);
        pref.updatePreferenceViews();
    }
}
Also used : Context(android.content.Context) PackageManager(android.content.pm.PackageManager) InputMethodPreference(com.android.settingslib.inputmethod.InputMethodPreference) InputMethodInfo(android.view.inputmethod.InputMethodInfo) Collator(java.text.Collator)

Example 7 with InputMethodPreference

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

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 8 with InputMethodPreference

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

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 9 with InputMethodPreference

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

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 10 with InputMethodPreference

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

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 PackageManager packageManager = getActivity().getPackageManager();
    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(getInputMethodIcon(packageManager, imi));
        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);
        InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference(pref);
        pref.updatePreferenceViews();
    }
}
Also used : Context(android.content.Context) PackageManager(android.content.pm.PackageManager) 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