avoid accessing uninitialized RichInputMethodManager, fixes #952

This commit is contained in:
Helium314 2024-07-07 20:23:21 +02:00
parent e5b82b53c4
commit 9f37c5505c
2 changed files with 5 additions and 4 deletions

View file

@ -360,10 +360,11 @@ public class RichInputMethodManager {
mCurrentRichInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
}
public boolean canSwitchLanguage() {
if (Settings.getInstance().getCurrent().mLanguageSwitchKeyToOtherSubtypes && hasMultipleEnabledSubtypesInThisIme(false))
public static boolean canSwitchLanguage() {
if (!isInitialized()) return false;
if (Settings.getInstance().getCurrent().mLanguageSwitchKeyToOtherSubtypes && getInstance().hasMultipleEnabledSubtypesInThisIme(false))
return true;
if (Settings.getInstance().getCurrent().mLanguageSwitchKeyToOtherImes && mImm.getEnabledInputMethodList().size() > 1)
if (Settings.getInstance().getCurrent().mLanguageSwitchKeyToOtherImes && getInstance().mImm.getEnabledInputMethodList().size() > 1)
return true;
return false;
}