use of android.view.inputmethod.InputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class RichInputMethodManager method switchToNextInputMethodAndSubtype.
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);
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;
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class RichInputMethodManager method switchToNextInputSubtypeInThisIme.
private boolean switchToNextInputSubtypeInThisIme(final IBinder token, final boolean onlyCurrentIme) {
final InputMethodManager imm = mImmWrapper.mImm;
final InputMethodSubtype currentSubtype = imm.getCurrentInputMethodSubtype();
final List<InputMethodSubtype> enabledSubtypes = getMyEnabledInputMethodSubtypeList(true);
final int currentIndex = getSubtypeIndexInList(currentSubtype, enabledSubtypes);
if (currentIndex == INDEX_NOT_FOUND) {
Log.w(TAG, "Can't find current subtype in enabled subtypes: subtype=" + SubtypeLocaleUtils.getSubtypeNameForLogging(currentSubtype));
return false;
}
final int nextIndex = (currentIndex + 1) % enabledSubtypes.size();
if (nextIndex <= currentIndex && !onlyCurrentIme) {
// next IME.
return false;
}
final InputMethodSubtype nextSubtype = enabledSubtypes.get(nextIndex);
setInputMethodAndSubtype(token, nextSubtype);
return true;
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class RichInputMethodManager method initInternal.
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();
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class RichInputMethodManager method isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes.
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);
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;
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class SystemBroadcastReceiver method onReceive.
@Override
public void onReceive(final Context context, final Intent intent) {
final String intentAction = intent.getAction();
if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intentAction)) {
Log.i(TAG, "Package has been replaced: " + context.getPackageName());
// Need to restore additional subtypes because system always clears additional
// subtypes when the package is replaced.
RichInputMethodManager.init(context);
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
final InputMethodSubtype[] additionalSubtypes = richImm.getAdditionalSubtypes();
richImm.setAdditionalInputMethodSubtypes(additionalSubtypes);
toggleAppIcon(context);
// Remove all the previously scheduled downloads. This will also makes sure
// that any erroneously stuck downloads will get cleared. (b/21797386)
removeOldDownloads(context);
// b/21797386
// downloadLatestDictionaries(context);
} else if (Intent.ACTION_BOOT_COMPLETED.equals(intentAction)) {
Log.i(TAG, "Boot has been completed");
toggleAppIcon(context);
} else if (Intent.ACTION_LOCALE_CHANGED.equals(intentAction)) {
Log.i(TAG, "System locale changed");
KeyboardLayoutSet.onSystemLocaleChanged();
}
// The process that hosts this broadcast receiver is invoked and remains alive even after
// 1) the package has been re-installed,
// 2) the device has just booted,
// 3) a new user has been created.
// There is no good reason to keep the process alive if this IME isn't a current IME.
final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
// Called to check whether this IME has been triggered by the current user or not
final boolean isInputMethodManagerValidForUserOfThisProcess = !imm.getInputMethodList().isEmpty();
final boolean isCurrentImeOfCurrentUser = isInputMethodManagerValidForUserOfThisProcess && UncachedInputMethodManagerUtils.isThisImeCurrent(context, imm);
if (!isCurrentImeOfCurrentUser) {
final int myPid = Process.myPid();
Log.i(TAG, "Killing my process: pid=" + myPid);
Process.killProcess(myPid);
}
}
Aggregations