mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-25 19:29:27 +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
|
final boolean noMicrophone = mIsPasswordField
|
||||||
|| InputTypeUtils.isEmailVariation(variation)
|
|| InputTypeUtils.isEmailVariation(variation)
|
||||||
|| hasNoMicrophoneKeyOption()
|
|| hasNoMicrophoneKeyOption()
|
||||||
|
|| !RichInputMethodManager.isInitialized() // avoid crash when only using spell checker
|
||||||
|| !RichInputMethodManager.getInstance().hasShortcutIme();
|
|| !RichInputMethodManager.getInstance().hasShortcutIme();
|
||||||
mShouldShowVoiceInputKey = !noMicrophone;
|
mShouldShowVoiceInputKey = !noMicrophone;
|
||||||
|
|
||||||
|
|
|
@ -69,24 +69,27 @@ public class RichInputMethodManager {
|
||||||
sInstance.initInternal(context);
|
sInstance.initInternal(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInitialized() {
|
private boolean isInitializedInternal() {
|
||||||
return mImm != null;
|
return mImm != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isInitialized() {
|
||||||
|
return sInstance.isInitializedInternal();
|
||||||
|
}
|
||||||
|
|
||||||
private void checkInitialized() {
|
private void checkInitialized() {
|
||||||
if (!isInitialized()) {
|
if (!isInitializedInternal()) {
|
||||||
throw new RuntimeException(TAG + " is used before initialization");
|
throw new RuntimeException(TAG + " is used before initialization");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initInternal(final Context context) {
|
private void initInternal(final Context context) {
|
||||||
if (isInitialized()) {
|
if (isInitializedInternal()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mInputMethodInfoCache = new InputMethodInfoCache(
|
mInputMethodInfoCache = new InputMethodInfoCache(mImm, context.getPackageName());
|
||||||
mImm, context.getPackageName());
|
|
||||||
|
|
||||||
// Initialize subtype utils.
|
// Initialize subtype utils.
|
||||||
SubtypeLocaleUtils.init(context);
|
SubtypeLocaleUtils.init(context);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue