Search in sources :

Example 1 with InputMethodInfo

use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.

the class InputMethodsPanel method getEnabledInputMethodAndSubtypeList.

private TreeMap<InputMethodInfo, List<InputMethodSubtype>> getEnabledInputMethodAndSubtypeList() {
    String newEnabledIMIs = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ENABLED_INPUT_METHODS);
    String currentSystemLocaleString = mContext.getResources().getConfiguration().locale.toString();
    if (!TextUtils.equals(mEnabledInputMethodAndSubtypesCacheStr, newEnabledIMIs) || !TextUtils.equals(mLastSystemLocaleString, currentSystemLocaleString) || mPackageChanged) {
        mEnabledInputMethodAndSubtypesCache.clear();
        final List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
        for (InputMethodInfo imi : imis) {
            mEnabledInputMethodAndSubtypesCache.put(imi, mImm.getEnabledInputMethodSubtypeList(imi, true));
        }
        mEnabledInputMethodAndSubtypesCacheStr = newEnabledIMIs;
        mPackageChanged = false;
        mLastSystemLocaleString = currentSystemLocaleString;
    }
    return mEnabledInputMethodAndSubtypesCache;
}
Also used : InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 2 with InputMethodInfo

use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.

the class InputMethodsPanel method getCurrentInputMethodInfo.

private InputMethodInfo getCurrentInputMethodInfo() {
    String curInputMethodId = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
    Set<InputMethodInfo> cachedImiSet = mEnabledInputMethodAndSubtypesCache.keySet();
    // 1. Search IMI in cache
    for (InputMethodInfo imi : cachedImiSet) {
        if (imi.getId().equals(curInputMethodId)) {
            return imi;
        }
    }
    // 2. Get current enabled IMEs and search IMI
    cachedImiSet = getEnabledInputMethodAndSubtypeList().keySet();
    for (InputMethodInfo imi : cachedImiSet) {
        if (imi.getId().equals(curInputMethodId)) {
            return imi;
        }
    }
    return null;
}
Also used : InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 3 with InputMethodInfo

use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.

the class QuickSettingsModel method getCurrentInputMethodName.

private static String getCurrentInputMethodName(Context context, ContentResolver resolver, InputMethodManager imm, List<InputMethodInfo> imis, PackageManager pm) {
    if (resolver == null || imis == null)
        return null;
    final String currentInputMethodId = Settings.Secure.getString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD);
    if (TextUtils.isEmpty(currentInputMethodId))
        return null;
    for (InputMethodInfo imi : imis) {
        if (currentInputMethodId.equals(imi.getId())) {
            final InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype();
            final CharSequence summary = subtype != null ? subtype.getDisplayName(context, imi.getPackageName(), imi.getServiceInfo().applicationInfo) : context.getString(R.string.quick_settings_ime_label);
            return summary.toString();
        }
    }
    return null;
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 4 with InputMethodInfo

use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.

the class QuickSettingsModel method needsToShowImeSwitchOngoingNotification.

/* This implementation is taken from
       InputMethodManagerService.needsToShowImeSwitchOngoingNotification(). */
private boolean needsToShowImeSwitchOngoingNotification(InputMethodManager imm) {
    List<InputMethodInfo> imis = imm.getEnabledInputMethodList();
    final int N = imis.size();
    if (N > 2)
        return true;
    if (N < 1)
        return false;
    int nonAuxCount = 0;
    int auxCount = 0;
    InputMethodSubtype nonAuxSubtype = null;
    InputMethodSubtype auxSubtype = null;
    for (int i = 0; i < N; ++i) {
        final InputMethodInfo imi = imis.get(i);
        final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
        final int subtypeCount = subtypes.size();
        if (subtypeCount == 0) {
            ++nonAuxCount;
        } else {
            for (int j = 0; j < subtypeCount; ++j) {
                final InputMethodSubtype subtype = subtypes.get(j);
                if (!subtype.isAuxiliary()) {
                    ++nonAuxCount;
                    nonAuxSubtype = subtype;
                } else {
                    ++auxCount;
                    auxSubtype = subtype;
                }
            }
        }
    }
    if (nonAuxCount > 1 || auxCount > 1) {
        return true;
    } else if (nonAuxCount == 1 && auxCount == 1) {
        if (nonAuxSubtype != null && auxSubtype != null && (nonAuxSubtype.getLocale().equals(auxSubtype.getLocale()) || auxSubtype.overridesImplicitlyEnabledSubtype() || nonAuxSubtype.overridesImplicitlyEnabledSubtype()) && nonAuxSubtype.containsExtraValueKey(TAG_TRY_SUPPRESSING_IME_SWITCHER)) {
            return false;
        }
        return true;
    }
    return false;
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 5 with InputMethodInfo

use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.

the class InputMethodButton method needsToShowIMEButtonWhenVisibilityAuto.

// Refer to InputMethodManagerService.needsToShowImeSwitchOngoingNotification()
private boolean needsToShowIMEButtonWhenVisibilityAuto() {
    List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
    final int N = imis.size();
    if (N > 2)
        return true;
    if (N < 1)
        return false;
    int nonAuxCount = 0;
    int auxCount = 0;
    InputMethodSubtype nonAuxSubtype = null;
    InputMethodSubtype auxSubtype = null;
    for (int i = 0; i < N; ++i) {
        final InputMethodInfo imi = imis.get(i);
        final List<InputMethodSubtype> subtypes = mImm.getEnabledInputMethodSubtypeList(imi, true);
        final int subtypeCount = subtypes.size();
        if (subtypeCount == 0) {
            ++nonAuxCount;
        } else {
            for (int j = 0; j < subtypeCount; ++j) {
                final InputMethodSubtype subtype = subtypes.get(j);
                if (!subtype.isAuxiliary()) {
                    ++nonAuxCount;
                    nonAuxSubtype = subtype;
                } else {
                    ++auxCount;
                    auxSubtype = subtype;
                }
            }
        }
    }
    if (nonAuxCount > 1 || auxCount > 1) {
        return true;
    } else if (nonAuxCount == 1 && auxCount == 1) {
        if (nonAuxSubtype != null && auxSubtype != null && (nonAuxSubtype.getLocale().equals(auxSubtype.getLocale()) || auxSubtype.overridesImplicitlyEnabledSubtype() || nonAuxSubtype.overridesImplicitlyEnabledSubtype()) && nonAuxSubtype.containsExtraValueKey(TAG_TRY_SUPPRESSING_IME_SWITCHER)) {
            return false;
        }
        return true;
    }
    return false;
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Aggregations

InputMethodInfo (android.view.inputmethod.InputMethodInfo)309 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)113 ArrayList (java.util.ArrayList)80 RemoteException (android.os.RemoteException)53 ServiceInfo (android.content.pm.ServiceInfo)34 ComponentName (android.content.ComponentName)33 Intent (android.content.Intent)33 Context (android.content.Context)32 InputMethodManager (android.view.inputmethod.InputMethodManager)29 ApplicationInfo (android.content.pm.ApplicationInfo)27 PendingIntent (android.app.PendingIntent)24 Test (org.junit.Test)24 ResolveInfo (android.content.pm.ResolveInfo)19 ImeSubtypeListItem (com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem)15 InputMethodPreference (com.android.settingslib.inputmethod.InputMethodPreference)14 List (java.util.List)14 PackageManager (android.content.pm.PackageManager)13 Drawable (android.graphics.drawable.Drawable)13 SmallTest (android.test.suitebuilder.annotation.SmallTest)12 Printer (android.util.Printer)12