diff --git a/app/src/main/java/helium314/keyboard/latin/LatinIME.kt b/app/src/main/java/helium314/keyboard/latin/LatinIME.kt index ee35b1f67..12fa5e2f7 100644 --- a/app/src/main/java/helium314/keyboard/latin/LatinIME.kt +++ b/app/src/main/java/helium314/keyboard/latin/LatinIME.kt @@ -831,8 +831,13 @@ class LatinIME : InputMethodService(), if (needToCallLoadKeyboardLater) switcher.saveKeyboardState() } else if (restarting) { if (!switcher.isSecondaryViewShowing) { - switcher.resetKeyboardStateToAlphabet(currentAutoCapsState, currentRecapitalizeState) - switcher.requestUpdatingShiftState(currentAutoCapsState, currentRecapitalizeState) + if (isTransientFocusTypeNull(editorInfo)) { + switcher.resetKeyboardStateToAlphabet(Constants.TextUtils.CAP_MODE_OFF, currentRecapitalizeState) + switcher.requestUpdatingShiftState(Constants.TextUtils.CAP_MODE_OFF, currentRecapitalizeState) + } else { + switcher.resetKeyboardStateToAlphabet(currentAutoCapsState, currentRecapitalizeState) + switcher.requestUpdatingShiftState(currentAutoCapsState, currentRecapitalizeState) + } } } diff --git a/app/src/main/java/helium314/keyboard/latin/RichInputConnection.kt b/app/src/main/java/helium314/keyboard/latin/RichInputConnection.kt index 5d98df1cc..f88a193a8 100644 --- a/app/src/main/java/helium314/keyboard/latin/RichInputConnection.kt +++ b/app/src/main/java/helium314/keyboard/latin/RichInputConnection.kt @@ -161,7 +161,6 @@ class RichInputConnection(private val mParent: InputMethodService) : PrivateComm fun endBatchEdit() { if (mNestLevel <= 0) { - Log.e(TAG, "Batch edit not in progress!") mNestLevel = 0 return } @@ -447,12 +446,19 @@ class RichInputConnection(private val mParent: InputMethodService) : PrivateComm return TextUtils.CAP_MODE_CHARACTERS and inputType } - val text = if (InputTypeUtils.isWebEditor(mParent.currentInputEditorInfo)) { - getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE, 0)?.toString() ?: "" + val ei = mParent.currentInputEditorInfo + val text = if (InputTypeUtils.isWebEditor(ei)) { + val t = getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE, 0) + if (t == null) { + Log.d(TAG, "Setting caps mode with default fallback (text cache unavailable).") + return ei?.initialCapsMode ?: Constants.TextUtils.CAP_MODE_OFF + } + t.toString() } else { if (mCommittedTextBeforeComposingText.isEmpty() && mExpectedSelStart != 0) { if (!reloadTextCache()) { Log.d(TAG, "Setting caps mode with default fallback (text cache unavailable).") + return ei?.initialCapsMode ?: Constants.TextUtils.CAP_MODE_OFF } } mCommittedTextBeforeComposingText.toString()