mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-25 11:22:20 +00:00
fix spellchecker crash when keyboard has never been initialized, fixes #684
This commit is contained in:
parent
87f1092eac
commit
382bdb6ff6
2 changed files with 9 additions and 5 deletions
|
@ -100,6 +100,7 @@ public final class InputAttributes {
|
|||
final boolean noMicrophone = mIsPasswordField
|
||||
|| InputTypeUtils.isEmailVariation(variation)
|
||||
|| hasNoMicrophoneKeyOption()
|
||||
|| !RichInputMethodManager.isInitialized() // avoid crash when only using spell checker
|
||||
|| !RichInputMethodManager.getInstance().hasShortcutIme();
|
||||
mShouldShowVoiceInputKey = !noMicrophone;
|
||||
|
||||
|
|
|
@ -69,24 +69,27 @@ public class RichInputMethodManager {
|
|||
sInstance.initInternal(context);
|
||||
}
|
||||
|
||||
private boolean isInitialized() {
|
||||
private boolean isInitializedInternal() {
|
||||
return mImm != null;
|
||||
}
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return sInstance.isInitializedInternal();
|
||||
}
|
||||
|
||||
private void checkInitialized() {
|
||||
if (!isInitialized()) {
|
||||
if (!isInitializedInternal()) {
|
||||
throw new RuntimeException(TAG + " is used before initialization");
|
||||
}
|
||||
}
|
||||
|
||||
private void initInternal(final Context context) {
|
||||
if (isInitialized()) {
|
||||
if (isInitializedInternal()) {
|
||||
return;
|
||||
}
|
||||
mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
mContext = context;
|
||||
mInputMethodInfoCache = new InputMethodInfoCache(
|
||||
mImm, context.getPackageName());
|
||||
mInputMethodInfoCache = new InputMethodInfoCache(mImm, context.getPackageName());
|
||||
|
||||
// Initialize subtype utils.
|
||||
SubtypeLocaleUtils.init(context);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue