From da95c69668a2271063f03a829158acf7df6e29e6 Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Fri, 27 Sep 2024 18:44:36 +0300 Subject: [PATCH] Remove InputView parent to mitigate crash when changing keyboard size --- java/src/org/futo/inputmethod/latin/LatinIME.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/src/org/futo/inputmethod/latin/LatinIME.kt b/java/src/org/futo/inputmethod/latin/LatinIME.kt index d215cfc45..814cd2f16 100644 --- a/java/src/org/futo/inputmethod/latin/LatinIME.kt +++ b/java/src/org/futo/inputmethod/latin/LatinIME.kt @@ -12,6 +12,7 @@ import android.os.Bundle import android.util.Log import android.view.KeyEvent import android.view.View +import android.view.ViewGroup import android.view.inputmethod.CompletionInfo import android.view.inputmethod.EditorInfo import android.view.inputmethod.InlineSuggestionsRequest @@ -511,7 +512,9 @@ class LatinIME : InputMethodServiceCompose(), LatinIMELegacy.SuggestionStripCont key(legacyInputView) { AndroidView(factory = { - legacyInputView!! + legacyInputView!!.also { + if(it.parent != null) (it.parent as ViewGroup).removeView(it) + } }, modifier = modifier, onRelease = { val view = it as InputView view.deallocateMemory()