android.view.inputmethod.InputMethodInfo Java Examples

The following examples show how to use android.view.inputmethod.InputMethodInfo. 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 openboard with GNU General Public License v3.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: InputMethodManagerService.java    From TvRemoteControl with Apache License 2.0 6 votes vote down vote up
private void resetSelectedInputMethodAndSubtypeLocked(String newDefaultIme) {
    InputMethodInfo imi = mMethodMap.get(newDefaultIme);
    int lastSubtypeId = NOT_A_SUBTYPE_ID;
    // newDefaultIme is empty when there is no candidate for the selected IME.
    if (imi != null && !TextUtils.isEmpty(newDefaultIme)) {
        String subtypeHashCode = mSettings.getLastSubtypeForInputMethodLocked(newDefaultIme);
        if (subtypeHashCode != null) {
            try {
                lastSubtypeId = InputMethodUtils.getSubtypeIdFromHashCode(
                        imi, Integer.valueOf(subtypeHashCode));
            } catch (NumberFormatException e) {
                Slog.w(TAG, "HashCode for subtype looks broken: " + subtypeHashCode, e);
            }
        }
    }
    setSelectedInputMethodAndSubtypeLocked(imi, lastSubtypeId, false);
}
 
Example #3
Source File: PopupWindowManager.java    From Noyze with Apache License 2.0 6 votes vote down vote up
protected ComponentName retrieveActiveInputMethod() {
       if (null == mContext) return null;
	final String id = Settings.Secure.getString(
		mContext.getContentResolver(), 
		Settings.Secure.DEFAULT_INPUT_METHOD
	);
	
	if (TextUtils.isEmpty(id)) return null;
	List<InputMethodInfo> mInputMethodProperties = mInputMethodManager.getEnabledInputMethodList();
	for (InputMethodInfo mInputMethod : mInputMethodProperties) {
		if (id.equals(mInputMethod.getId())) {
			return mInputMethod.getComponent();
		}
	}
	
	return null;
}
 
Example #4
Source File: RichInputMethodManager.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() {
    final Locale systemLocale = mContext.getResources().getConfiguration().locale;
    final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes = new HashSet<>();
    final InputMethodManager inputMethodManager = getInputMethodManager();
    final List<InputMethodInfo> enabledInputMethodInfoList =
            inputMethodManager.getEnabledInputMethodList();
    for (final InputMethodInfo info : enabledInputMethodInfoList) {
        final List<InputMethodSubtype> enabledSubtypes =
                inputMethodManager.getEnabledInputMethodSubtypeList(
                        info, true /* allowsImplicitlySelectedSubtypes */);
        if (enabledSubtypes.isEmpty()) {
            // An IME with no subtypes is found.
            return false;
        }
        enabledSubtypesOfEnabledImes.addAll(enabledSubtypes);
    }
    for (final InputMethodSubtype subtype : enabledSubtypesOfEnabledImes) {
        if (!subtype.isAuxiliary() && !subtype.getLocale().isEmpty()
                && !systemLocale.equals(SubtypeLocaleUtils.getSubtypeLocale(subtype))) {
            return false;
        }
    }
    return true;
}
 
Example #5
Source File: InputMethodSettingsImpl.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
private static String getEnabledSubtypesLabel(
        Context context, InputMethodManager imm, InputMethodInfo imi) {
    if (context == null || imm == null || imi == null) return null;
    final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
    final StringBuilder sb = new StringBuilder();
    final int N = subtypes.size();
    for (int i = 0; i < N; ++i) {
        final InputMethodSubtype subtype = subtypes.get(i);
        if (sb.length() > 0) {
            sb.append(", ");
        }
        sb.append(subtype.getDisplayName(context, imi.getPackageName(),
                imi.getServiceInfo().applicationInfo));
    }
    return sb.toString();
}
 
Example #6
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 #7
Source File: CustomInputStylePreference.java    From Android-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 (InputMethodSubtypeCompatUtils.isAsciiCapable(subtype)) {
            items.add(new SubtypeLocaleItem(subtype));
        }
    }
    // TODO: Should filter out already existing combinations of locale and layout.
    addAll(items);
}
 
Example #8
Source File: InputMethodSettingsImpl.java    From simple-keyboard with Apache License 2.0 6 votes vote down vote up
private static String getEnabledSubtypesLabel(
        Context context, InputMethodManager imm, InputMethodInfo imi) {
    if (context == null || imm == null || imi == null) return null;
    final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
    final StringBuilder sb = new StringBuilder();
    final int N = subtypes.size();
    for (int i = 0; i < N; ++i) {
        final InputMethodSubtype subtype = subtypes.get(i);
        if (sb.length() > 0) {
            sb.append(", ");
        }
        sb.append(subtype.getDisplayName(context, imi.getPackageName(),
                imi.getServiceInfo().applicationInfo));
    }
    return sb.toString();
}
 
Example #9
Source File: InputMethodSettingsImpl.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
private static String getEnabledSubtypesLabel(
        Context context, InputMethodManager imm, InputMethodInfo imi) {
    if (context == null || imm == null || imi == null) return null;
    final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
    final StringBuilder sb = new StringBuilder();
    final int N = subtypes.size();
    for (int i = 0; i < N; ++i) {
        final InputMethodSubtype subtype = subtypes.get(i);
        if (sb.length() > 0) {
            sb.append(", ");
        }
        sb.append(subtype.getDisplayName(context, imi.getPackageName(),
                imi.getServiceInfo().applicationInfo));
    }
    return sb.toString();
}
 
Example #10
Source File: RichInputMethodManager.java    From LokiBoard-Android-Keylogger with Apache License 2.0 6 votes vote down vote up
private boolean switchToNextInputMethodAndSubtype(final IBinder token) {
    final List<InputMethodInfo> enabledImis = mImmService.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.
        mImmService.setInputMethod(token, nextImi.getId());
        return true;
    }
    final InputMethodSubtype firstSubtype = enabledSubtypes.get(0);
    mImmService.setInputMethodAndSubtype(token, nextImi.getId(), firstSubtype);
    return true;
}
 
Example #11
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 #12
Source File: UiUtils.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the set of locales supported by the current enabled Input Methods.
 * @param context A {@link Context} instance.
 * @return A possibly-empty {@link Set} of locale strings.
 */
public static Set<String> getIMELocales(Context context) {
    LinkedHashSet<String> locales = new LinkedHashSet<String>();
    InputMethodManager imManager =
            (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> enabledMethods = imManager.getEnabledInputMethodList();
    for (int i = 0; i < enabledMethods.size(); i++) {
        List<InputMethodSubtype> subtypes =
                imManager.getEnabledInputMethodSubtypeList(enabledMethods.get(i), true);
        if (subtypes == null) continue;
        for (int j = 0; j < subtypes.size(); j++) {
            String locale = ApiCompatibilityUtils.getLocale(subtypes.get(j));
            if (!TextUtils.isEmpty(locale)) locales.add(locale);
        }
    }
    return locales;
}
 
Example #13
Source File: InputMethodManagerService.java    From TvRemoteControl with Apache License 2.0 6 votes vote down vote up
public InputMethodFileManager(HashMap<String, InputMethodInfo> methodMap, int userId) {
    if (methodMap == null) {
        throw new NullPointerException("methodMap is null");
    }
    mMethodMap = methodMap;
    final File systemDir = userId == UserHandle.USER_OWNER
            ? new File(Environment.getDataDirectory(), SYSTEM_PATH)
            : Environment.getUserSystemDirectory(userId);
    final File inputMethodDir = new File(systemDir, INPUT_METHOD_PATH);
    if (!inputMethodDir.mkdirs()) {
        Slog.w(TAG, "Couldn't create dir.: " + inputMethodDir.getAbsolutePath());
    }
    final File subtypeFile = new File(inputMethodDir, ADDITIONAL_SUBTYPES_FILE_NAME);
    mAdditionalInputMethodSubtypeFile = new AtomicFile(subtypeFile);
    if (!subtypeFile.exists()) {
        // If "subtypes.xml" doesn't exist, create a blank file.
        writeAdditionalInputMethodSubtypes(
                mAdditionalSubtypesMap, mAdditionalInputMethodSubtypeFile, methodMap);
    } else {
        readAdditionalInputMethodSubtypes(
                mAdditionalSubtypesMap, mAdditionalInputMethodSubtypeFile);
    }
}
 
Example #14
Source File: DeleteNonRequiredAppsTask.java    From island with Apache License 2.0 6 votes vote down vote up
private Set<String> getSystemInputMethods() {
    // InputMethodManager is final so it cannot be mocked.
    // So, we're using IInputMethodManager directly because it can be mocked.
    List<InputMethodInfo> inputMethods = null;
    try {
        inputMethods = mIInputMethodManager.getInputMethodList();
    } catch (RemoteException e) {
        ProvisionLogger.loge("Could not communicate with IInputMethodManager", e);
        return Collections.<String>emptySet();
    }
    Set<String> systemInputMethods = new HashSet<String>();
    for (InputMethodInfo inputMethodInfo : inputMethods) {
        ApplicationInfo applicationInfo = inputMethodInfo.getServiceInfo().applicationInfo;
        if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
            systemInputMethods.add(inputMethodInfo.getPackageName());
        }
    }
    return systemInputMethods;
}
 
Example #15
Source File: InputMethodSettingsImpl.java    From AndroidKeyboard with GNU General Public License v3.0 6 votes vote down vote up
private static String getEnabledSubtypesLabel(
        Context context, InputMethodManager imm, InputMethodInfo imi) {
    if (context == null || imm == null || imi == null) return null;
    final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
    final StringBuilder sb = new StringBuilder();
    final int N = subtypes.size();
    for (int i = 0; i < N; ++i) {
        final InputMethodSubtype subtype = subtypes.get(i);
        if (sb.length() > 0) {
            sb.append(", ");
        }
        sb.append(subtype.getDisplayName(context, imi.getPackageName(),
                imi.getServiceInfo().applicationInfo));
    }
    return sb.toString();
}
 
Example #16
Source File: RichInputMethodManager.java    From simple-keyboard with Apache License 2.0 6 votes vote down vote up
private boolean switchToNextInputMethodAndSubtype(final IBinder token) {
    final List<InputMethodInfo> enabledImis = mImmService.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.
        mImmService.setInputMethod(token, nextImi.getId());
        return true;
    }
    final InputMethodSubtype firstSubtype = enabledSubtypes.get(0);
    mImmService.setInputMethodAndSubtype(token, nextImi.getId(), firstSubtype);
    return true;
}
 
Example #17
Source File: PolicyManagementFragment.java    From android-testdpc with Apache License 2.0 5 votes vote down vote up
@Override
protected List<ResolveInfo> getResolveInfoListFromAvailableComponents(
        List<InputMethodInfo> inputMethodsInfoList) {
    List<ResolveInfo> inputMethodsResolveInfoList = new ArrayList<>();
    for (InputMethodInfo inputMethodInfo: inputMethodsInfoList) {
        ResolveInfo resolveInfo = new ResolveInfo();
        resolveInfo.serviceInfo = inputMethodInfo.getServiceInfo();
        resolveInfo.resolvePackageName = inputMethodInfo.getPackageName();
        inputMethodsResolveInfoList.add(resolveInfo);
    }
    return inputMethodsResolveInfoList;
}
 
Example #18
Source File: RichInputMethodManager.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
public synchronized InputMethodInfo getInputMethodOfThisIme() {
    if (mCachedThisImeInfo != null) {
        return mCachedThisImeInfo;
    }
    for (final InputMethodInfo imi : mImm.getInputMethodList()) {
        if (imi.getPackageName().equals(mImePackageName)) {
            mCachedThisImeInfo = imi;
            return imi;
        }
    }
    throw new RuntimeException("Input method id for " + mImePackageName + " not found.");
}
 
Example #19
Source File: SetupWizardActivity.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
void invokeSubtypeEnablerOfThisIme() {
    final InputMethodInfo imi =
            UncachedInputMethodManagerUtils.getInputMethodInfoOf(getPackageName(), mImm);
    if (imi == null) {
        return;
    }
    final Intent intent = new Intent();
    intent.setAction(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, imi.getId());
    startActivity(intent);
}
 
Example #20
Source File: RichInputMethodManager.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
public synchronized InputMethodInfo getInputMethodOfThisIme() {
    if (mCachedThisImeInfo != null) {
        return mCachedThisImeInfo;
    }
    for (final InputMethodInfo imi : mImm.getInputMethodList()) {
        if (imi.getPackageName().equals(mImePackageName)) {
            mCachedThisImeInfo = imi;
            return imi;
        }
    }
    throw new RuntimeException("Input method id for " + mImePackageName + " not found.");
}
 
Example #21
Source File: RichInputMethodManager.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
public synchronized boolean isInputMethodOfThisImeEnabled() {
    for (final InputMethodInfo imi : mImm.getEnabledInputMethodList()) {
        if (imi.getPackageName().equals(mImePackageName)) {
            return true;
        }
    }
    return false;
}
 
Example #22
Source File: PackageUtils.java    From prevent with Do What The F*ck You Want To Public License 5 votes vote down vote up
private static void initInputMethods(Context context) {
    InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> inputMethods = inputMethodManager.getEnabledInputMethodList();
    final int count = inputMethods == null ? 0 : inputMethods.size();
    for (int i = 0; i < count; ++i) {
        inputMethodPackages.add(inputMethods.get(i).getPackageName());
    }
}
 
Example #23
Source File: UncachedInputMethodManagerUtils.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
/**
 * Check if the IME specified by the context is enabled.
 * CAVEAT: This may cause a round trip IPC.
 *
 * @param context package context of the IME to be checked.
 * @param imm the {@link InputMethodManager}.
 * @return true if this IME is enabled.
 */
public static boolean isThisImeEnabled(final Context context,
        final InputMethodManager imm) {
    final String packageName = context.getPackageName();
    for (final InputMethodInfo imi : imm.getEnabledInputMethodList()) {
        if (packageName.equals(imi.getPackageName())) {
            return true;
        }
    }
    return false;
}
 
Example #24
Source File: UncachedInputMethodManagerUtils.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
/**
 * Get {@link InputMethodInfo} of the IME specified by the package name.
 * CAVEAT: This may cause a round trip IPC.
 *
 * @param packageName package name of the IME.
 * @param imm the {@link InputMethodManager}.
 * @return the {@link InputMethodInfo} of the IME specified by the <code>packageName</code>,
 * or null if not found.
 */
public static InputMethodInfo getInputMethodInfoOf(final String packageName,
        final InputMethodManager imm) {
    for (final InputMethodInfo imi : imm.getInputMethodList()) {
        if (packageName.equals(imi.getPackageName())) {
            return imi;
        }
    }
    return null;
}
 
Example #25
Source File: RichInputMethodManager.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
private static int getImiIndexInList(final InputMethodInfo inputMethodInfo,
        final List<InputMethodInfo> imiList) {
    final int count = imiList.size();
    for (int index = 0; index < count; index++) {
        final InputMethodInfo imi = imiList.get(index);
        if (imi.equals(inputMethodInfo)) {
            return index;
        }
    }
    return INDEX_NOT_FOUND;
}
 
Example #26
Source File: InputMethodManagerService.java    From TvRemoteControl with Apache License 2.0 5 votes vote down vote up
public ImeSubtypeListItem getNextInputMethod(
        boolean onlyCurrentIme, InputMethodInfo imi, InputMethodSubtype subtype) {
    if (imi == null) {
        return null;
    }
    final List<ImeSubtypeListItem> imList = getSortedInputMethodAndSubtypeList();
    if (imList.size() <= 1) {
        return null;
    }
    final int N = imList.size();
    final int currentSubtypeId = subtype != null
            ? InputMethodUtils.getSubtypeIdFromHashCode(imi, subtype.hashCode())
            : NOT_A_SUBTYPE_ID;
    for (int i = 0; i < N; ++i) {
        final ImeSubtypeListItem isli = imList.get(i);
        if (isli.mImi.equals(imi) && isli.mSubtypeId == currentSubtypeId) {
            if (!onlyCurrentIme) {
                return imList.get((i + 1) % N);
            }
            for (int j = 0; j < N - 1; ++j) {
                final ImeSubtypeListItem candidate = imList.get((i + j + 1) % N);
                if (candidate.mImi.equals(imi)) {
                    return candidate;
                }
            }
            return null;
        }
    }
    return null;
}
 
Example #27
Source File: Environment.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public static boolean isEnableIME(Context context){
    try {
        InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
        List<InputMethodInfo> inputs = imm.getEnabledInputMethodList();
        boolean flag = false;
        for(InputMethodInfo input : inputs){
            if(input.getPackageName().equals(IMEService.class.getPackage().getName())){
                return true;
            }
        }
    }catch (Exception ignored){ }
    return false;
}
 
Example #28
Source File: XposedTimeCat.java    From timecat with Apache License 2.0 5 votes vote down vote up
private Set<String> getInputMethodAsWhiteList(Context context) {
    HashSet<String> packages = new HashSet<>();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> methodList = imm.getInputMethodList();
    for (InputMethodInfo info : methodList) {
        packages.add(info.getPackageName());
    }
    return packages;
}
 
Example #29
Source File: CustomApplicationHelper.java    From AndroidTVWidget with Apache License 2.0 5 votes vote down vote up
public void setDefaultInputMethod(InputMethodInfo info) {
	// 设置默认输入法.
	String packName = info.getPackageName();
	String serviceName = info.getServiceName();
	int lastIndex = serviceName.lastIndexOf(".");
	if (lastIndex != -1) {
		String setInfo = packName + "/" + serviceName.substring(lastIndex);
		Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD,
				"" + setInfo);
	}
}
 
Example #30
Source File: RichInputMethodManager.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
private void updateShortcutIme() {
    if (DEBUG) {
        Log.d(TAG, "Update shortcut IME from : "
                + (mShortcutInputMethodInfo == null
                        ? "<null>" : mShortcutInputMethodInfo.getId()) + ", "
                + (mShortcutSubtype == null ? "<null>" : (
                        mShortcutSubtype.getLocale() + ", " + mShortcutSubtype.getMode())));
    }
    final RichInputMethodSubtype richSubtype = mCurrentRichInputMethodSubtype;
    final boolean implicitlyEnabledSubtype = checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(
            richSubtype.getRawSubtype());
    final Locale systemLocale = mContext.getResources().getConfiguration().locale;
    LanguageOnSpacebarUtils.onSubtypeChanged(
            richSubtype, implicitlyEnabledSubtype, systemLocale);
    LanguageOnSpacebarUtils.setEnabledSubtypes(getMyEnabledInputMethodSubtypeList(
            true /* allowsImplicitlySelectedSubtypes */));

    // TODO: Update an icon for shortcut IME
    final Map<InputMethodInfo, List<InputMethodSubtype>> shortcuts =
            getInputMethodManager().getShortcutInputMethodsAndSubtypes();
    mShortcutInputMethodInfo = null;
    mShortcutSubtype = null;
    for (final InputMethodInfo imi : shortcuts.keySet()) {
        final List<InputMethodSubtype> subtypes = shortcuts.get(imi);
        // TODO: Returns the first found IMI for now. Should handle all shortcuts as
        // appropriate.
        mShortcutInputMethodInfo = imi;
        // TODO: Pick up the first found subtype for now. Should handle all subtypes
        // as appropriate.
        mShortcutSubtype = subtypes.size() > 0 ? subtypes.get(0) : null;
        break;
    }
    if (DEBUG) {
        Log.d(TAG, "Update shortcut IME to : "
                + (mShortcutInputMethodInfo == null
                        ? "<null>" : mShortcutInputMethodInfo.getId()) + ", "
                + (mShortcutSubtype == null ? "<null>" : (
                        mShortcutSubtype.getLocale() + ", " + mShortcutSubtype.getMode())));
    }
}