Remove InputView parent to mitigate crash when changing keyboard size

This commit is contained in:
Aleksandras Kostarevas 2024-09-27 18:44:36 +03:00
parent a668a3c801
commit da95c69668

View File

@ -12,6 +12,7 @@ import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.CompletionInfo import android.view.inputmethod.CompletionInfo
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InlineSuggestionsRequest import android.view.inputmethod.InlineSuggestionsRequest
@ -511,7 +512,9 @@ class LatinIME : InputMethodServiceCompose(), LatinIMELegacy.SuggestionStripCont
key(legacyInputView) { key(legacyInputView) {
AndroidView(factory = { AndroidView(factory = {
legacyInputView!! legacyInputView!!.also {
if(it.parent != null) (it.parent as ViewGroup).removeView(it)
}
}, modifier = modifier, onRelease = { }, modifier = modifier, onRelease = {
val view = it as InputView val view = it as InputView
view.deallocateMemory() view.deallocateMemory()