Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a146c6f846 | ||
|
|
40ad937384 | ||
|
|
15b5dd9e3e |
@@ -166,10 +166,6 @@ class AppPrefs : PreferenceModel("florisboard-app-prefs") {
|
||||
key = "devtools__enabled",
|
||||
default = false,
|
||||
)
|
||||
val showLastLayoutComputation = boolean(
|
||||
key = "devtools__show_last_layout_computation",
|
||||
default = false,
|
||||
)
|
||||
val showPrimaryClip = boolean(
|
||||
key = "devtools__show_primary_clip",
|
||||
default = false,
|
||||
|
||||
@@ -43,6 +43,7 @@ import dev.patrickgold.florisboard.app.florisPreferenceModel
|
||||
import dev.patrickgold.florisboard.clipboardManager
|
||||
import dev.patrickgold.florisboard.editorInstance
|
||||
import dev.patrickgold.florisboard.ime.keyboard.CachedLayout
|
||||
import dev.patrickgold.florisboard.ime.keyboard.DebugLayoutComputationResult
|
||||
import dev.patrickgold.florisboard.ime.nlp.NlpInlineAutofill
|
||||
import dev.patrickgold.florisboard.keyboardManager
|
||||
import dev.patrickgold.florisboard.lib.FlorisLocale
|
||||
@@ -65,7 +66,6 @@ fun DevtoolsOverlay(modifier: Modifier = Modifier) {
|
||||
val devtoolsEnabled by prefs.devtools.enabled.observeAsState()
|
||||
val showPrimaryClip by prefs.devtools.showPrimaryClip.observeAsState()
|
||||
val showInputStateOverlay by prefs.devtools.showInputStateOverlay.observeAsState()
|
||||
val showLastLayoutComputation by prefs.devtools.showLastLayoutComputation.observeAsState()
|
||||
val showSpellingOverlay by prefs.devtools.showSpellingOverlay.observeAsState()
|
||||
val showInlineAutofillOverlay by prefs.devtools.showInlineAutofillOverlay.observeAsState()
|
||||
|
||||
@@ -82,8 +82,8 @@ fun DevtoolsOverlay(modifier: Modifier = Modifier) {
|
||||
if (devtoolsEnabled && showInputStateOverlay) {
|
||||
DevtoolsInputStateOverlay()
|
||||
}
|
||||
if (devtoolsEnabled && showLastLayoutComputation || debugLayoutResult?.allLayoutsSuccess() == false) {
|
||||
DevtoolsLastLayoutComputationOverlay()
|
||||
if (debugLayoutResult?.allLayoutsSuccess() == false) {
|
||||
DevtoolsLastLayoutComputationOverlay(debugLayoutResult)
|
||||
}
|
||||
if (devtoolsEnabled && showSpellingOverlay) {
|
||||
DevtoolsSpellingOverlay()
|
||||
@@ -137,13 +137,9 @@ private fun DevtoolsInputStateOverlay() {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun DevtoolsLastLayoutComputationOverlay() {
|
||||
val context = LocalContext.current
|
||||
val keyboardManager by context.keyboardManager()
|
||||
val debugLayoutResult by keyboardManager.layoutManager.debugLayoutComputationResultFlow.collectAsState()
|
||||
|
||||
private fun DevtoolsLastLayoutComputationOverlay(debugLayoutResult: DebugLayoutComputationResult?) {
|
||||
@Composable
|
||||
fun PrintResult(result: Result<CachedLayout>) {
|
||||
fun PrintResult(result: Result<CachedLayout?>) {
|
||||
if (result.isSuccess) {
|
||||
DevtoolsText(text = "loaded: ${result.getOrNull()?.name}")
|
||||
} else {
|
||||
|
||||
@@ -73,12 +73,6 @@ fun DevtoolsScreen() = FlorisScreen {
|
||||
summary = stringRes(R.string.devtools__show_input_state_overlay__summary),
|
||||
enabledIf = { prefs.devtools.enabled isEqualTo true },
|
||||
)
|
||||
SwitchPreference(
|
||||
prefs.devtools.showLastLayoutComputation,
|
||||
title = "Show last layout computation",
|
||||
summary = "Show the last layout computation in a dialog",
|
||||
enabledIf = { prefs.devtools.enabled isEqualTo true },
|
||||
)
|
||||
SwitchPreference(
|
||||
prefs.devtools.showSpellingOverlay,
|
||||
title = stringRes(R.string.devtools__show_spelling_overlay__label),
|
||||
|
||||
@@ -65,9 +65,9 @@ private data class CachedPopupMapping(
|
||||
)
|
||||
|
||||
data class DebugLayoutComputationResult(
|
||||
val main: Result<CachedLayout>,
|
||||
val mod: Result<CachedLayout>,
|
||||
val ext: Result<CachedLayout>,
|
||||
val main: Result<CachedLayout?>,
|
||||
val mod: Result<CachedLayout?>,
|
||||
val ext: Result<CachedLayout?>,
|
||||
) {
|
||||
fun allLayoutsSuccess(): Boolean {
|
||||
return main.isSuccess && mod.isSuccess && ext.isSuccess
|
||||
@@ -96,8 +96,13 @@ class LayoutManager(context: Context) {
|
||||
*
|
||||
* @return A deferred result for a layout.
|
||||
*/
|
||||
private fun loadLayoutAsync(ltn: LTN?) = ioScope.runCatchingAsync {
|
||||
require(ltn != null) { "Invalid argument value for 'ltn': null" }
|
||||
private fun loadLayoutAsync(ltn: LTN?, allowNullLTN: Boolean) = ioScope.runCatchingAsync {
|
||||
if (!allowNullLTN) {
|
||||
requireNotNull(ltn) { "Invalid argument value for 'ltn': null" }
|
||||
}
|
||||
if (ltn == null) {
|
||||
return@runCatchingAsync null
|
||||
}
|
||||
layoutCacheGuard.withLock {
|
||||
val cached = layoutCache[ltn]
|
||||
if (cached != null) {
|
||||
@@ -176,7 +181,7 @@ class LayoutManager(context: Context) {
|
||||
val extendedPopupsDefault = loadPopupMappingAsync()
|
||||
val extendedPopups = loadPopupMappingAsync(subtype)
|
||||
|
||||
val mainLayoutResult = loadLayoutAsync(main).await()
|
||||
val mainLayoutResult = loadLayoutAsync(main, allowNullLTN = false).await()
|
||||
val mainLayout = mainLayoutResult.onFailure {
|
||||
flogWarning { "$keyboardMode - main - $it" }
|
||||
}.getOrNull()
|
||||
@@ -196,11 +201,11 @@ class LayoutManager(context: Context) {
|
||||
} else {
|
||||
modifier
|
||||
}
|
||||
val modifierLayoutResult = loadLayoutAsync(modifierToLoad).await()
|
||||
val modifierLayoutResult = loadLayoutAsync(modifierToLoad, allowNullLTN = true).await()
|
||||
val modifierLayout = modifierLayoutResult.onFailure {
|
||||
flogWarning { "$keyboardMode - mod - $it" }
|
||||
}.getOrNull()
|
||||
val extensionLayoutResult = loadLayoutAsync(extension).await()
|
||||
val extensionLayoutResult = loadLayoutAsync(extension, allowNullLTN = true).await()
|
||||
val extensionLayout = extensionLayoutResult.onFailure {
|
||||
flogWarning { "$keyboardMode - ext - $it" }
|
||||
}.getOrNull()
|
||||
|
||||
@@ -13,5 +13,5 @@ projectCompileSdk=35
|
||||
projectBuildToolsVersion=35.0.0
|
||||
projectNdkVersion=26.1.10909125
|
||||
|
||||
projectVersionCode=102
|
||||
projectVersionName=0.4.4
|
||||
projectVersionCode=103
|
||||
projectVersionName=0.4.5
|
||||
|
||||
Reference in New Issue
Block a user