mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Fix theme update bug
This commit is contained in:
parent
d81d79ea67
commit
62ff4f47e4
@ -32,6 +32,7 @@ import org.futo.inputmethod.keyboard.emoji.EmojiPalettesView;
|
|||||||
import org.futo.inputmethod.keyboard.internal.KeyboardState;
|
import org.futo.inputmethod.keyboard.internal.KeyboardState;
|
||||||
import org.futo.inputmethod.keyboard.internal.KeyboardTextsSet;
|
import org.futo.inputmethod.keyboard.internal.KeyboardTextsSet;
|
||||||
import org.futo.inputmethod.latin.InputView;
|
import org.futo.inputmethod.latin.InputView;
|
||||||
|
import org.futo.inputmethod.latin.LatinIME;
|
||||||
import org.futo.inputmethod.latin.LatinIMELegacy;
|
import org.futo.inputmethod.latin.LatinIMELegacy;
|
||||||
import org.futo.inputmethod.latin.R;
|
import org.futo.inputmethod.latin.R;
|
||||||
import org.futo.inputmethod.latin.RichInputMethodManager;
|
import org.futo.inputmethod.latin.RichInputMethodManager;
|
||||||
@ -92,8 +93,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||||||
final boolean themeUpdated = updateKeyboardThemeAndContextThemeWrapper(
|
final boolean themeUpdated = updateKeyboardThemeAndContextThemeWrapper(
|
||||||
displayContext, KeyboardTheme.getKeyboardTheme(displayContext /* context */));
|
displayContext, KeyboardTheme.getKeyboardTheme(displayContext /* context */));
|
||||||
if (themeUpdated && mKeyboardView != null) {
|
if (themeUpdated && mKeyboardView != null) {
|
||||||
mLatinIMELegacy.setInputView(
|
((LatinIME)mLatinIMELegacy.getInputMethodService()).updateLegacyView(onCreateInputView(
|
||||||
onCreateInputView(displayContext, mIsHardwareAcceleratedDrawingEnabled));
|
displayContext, mIsHardwareAcceleratedDrawingEnabled));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,11 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.key
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.layout.onSizeChanged
|
import androidx.compose.ui.layout.onSizeChanged
|
||||||
import androidx.compose.ui.platform.ComposeView
|
import androidx.compose.ui.platform.ComposeView
|
||||||
@ -105,6 +110,12 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save
|
|||||||
this@LatinIME.setOwners()
|
this@LatinIME.setOwners()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setContent()
|
||||||
|
|
||||||
|
return composeView!!
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setContent() {
|
||||||
composeView?.setContent {
|
composeView?.setContent {
|
||||||
Column {
|
Column {
|
||||||
Spacer(modifier = Modifier.weight(1.0f))
|
Spacer(modifier = Modifier.weight(1.0f))
|
||||||
@ -112,15 +123,24 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save
|
|||||||
touchableHeight = it.height
|
touchableHeight = it.height
|
||||||
}, color = MaterialTheme.colorScheme.surface) {
|
}, color = MaterialTheme.colorScheme.surface) {
|
||||||
Column {
|
Column {
|
||||||
AndroidView(factory = {
|
key(legacyInputView) {
|
||||||
legacyInputView!!
|
AndroidView(factory = {
|
||||||
}, update = { })
|
legacyInputView!!
|
||||||
|
}, update = { })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return composeView!!
|
// necessary for when KeyboardSwitcher updates the theme
|
||||||
|
fun updateLegacyView(newView: View) {
|
||||||
|
legacyInputView = newView
|
||||||
|
setContent()
|
||||||
|
|
||||||
|
latinIMELegacy.setComposeInputView(composeView!!)
|
||||||
|
latinIMELegacy.setInputView(legacyInputView)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setInputView(view: View?) {
|
override fun setInputView(view: View?) {
|
||||||
|
Loading…
Reference in New Issue
Block a user