add incomplete debug screen

This commit is contained in:
Helium314 2025-01-29 23:34:21 +01:00
parent 5ddfd63392
commit f07f139469
6 changed files with 92 additions and 3 deletions

View file

@ -11,6 +11,7 @@ import helium314.keyboard.latin.utils.DeviceProtectedUtils
import helium314.keyboard.settings.screens.createAboutPrefs
import helium314.keyboard.settings.screens.createAdvancedPrefs
import helium314.keyboard.settings.screens.createCorrectionPrefs
import helium314.keyboard.settings.screens.createDebugPrefs
import helium314.keyboard.settings.screens.createGestureTypingPrefs
import helium314.keyboard.settings.screens.createPreferencesPrefs
import helium314.keyboard.settings.screens.createToolbarPrefs
@ -57,7 +58,7 @@ class PrefDef(
private fun createPrefDefs(context: Context) = createAboutPrefs(context) +
createCorrectionPrefs(context) + createPreferencesPrefs(context) + createToolbarPrefs(context) +
createGestureTypingPrefs(context) + createAdvancedPrefs(context)
createGestureTypingPrefs(context) + createAdvancedPrefs(context) + createDebugPrefs(context)
// todo: move somewhere else
fun Context.getActivity(): ComponentActivity? {

View file

@ -69,6 +69,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
// try getting rid of appcompat stuff (activity, dialogs, ...)
// re-organize screens, no need to keep exactly the same arrangement
// use simple list picker
// exclude all debug settings from search results if they are not enabled
// preliminary results:
// looks ok (ugly M3 switches)

View file

@ -54,6 +54,7 @@ fun SettingsNavHost(
onClickToolbar = { navController.navigate(SettingsDestination.Toolbar) },
onClickGestureTyping = { navController.navigate(SettingsDestination.GestureTyping) },
onClickAdvanced = { navController.navigate(SettingsDestination.Advanced) },
onClickAppearance = { navController.navigate(SettingsDestination.Appearance) },
onClickBack = ::goBack,
)
}
@ -88,7 +89,22 @@ fun SettingsNavHost(
)
}
composable(SettingsDestination.Debug) {
// DebugSettingsScreen(
DebugSettingsScreen(
onClickBack = ::goBack
)
}
composable(SettingsDestination.Appearance) {
// AppearanceSettingsScreen(
// onClickBack = ::goBack
// )
}
composable(SettingsDestination.PersonalDictionary) {
// PersonalDictionarySettingsScreen(
// onClickBack = ::goBack
// )
}
composable(SettingsDestination.Languages) {
// LanguagesSettingsScreen(
// onClickBack = ::goBack
// )
}
@ -104,6 +120,10 @@ object SettingsDestination {
const val GestureTyping = "gesture_typing"
const val Advanced = "advanced"
const val Debug = "debug"
const val Appearance = "appearance"
// const val Colors = "colors" todo: can't simply do this with the day/night approach (maybe colors and colorsNight?)
const val PersonalDictionary = "personal_dictionary"
const val Languages = "languages"
val navTarget = MutableStateFlow(Settings)
private val navScope = CoroutineScope(Dispatchers.Default)

View file

@ -60,7 +60,7 @@ fun AdvancedSettingsScreen(
SettingsActivity2.allPrefs.map[NonSettingsPrefs.CUSTOM_FUNCTIONAL_LAYOUTS]!!.Preference()
SettingsActivity2.allPrefs.map[NonSettingsPrefs.BACKUP_RESTORE]!!.Preference()
if (BuildConfig.DEBUG || prefs.getBoolean(DebugSettings.PREF_SHOW_DEBUG_SETTINGS, false))
SettingsActivity2.allPrefs.map[NonSettingsPrefs.DEBUG_SETTINGS]!!.Preference()
SettingsActivity2.allPrefs.map[NonSettingsPrefs.DEBUG_SETTINGS]!!.Preference() // todo: maybe move to main screen?
PreferenceCategory(
stringResource(R.string.settings_category_experimental)
) {

View file

@ -0,0 +1,66 @@
package helium314.keyboard.settings.screens
import android.content.Context
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import helium314.keyboard.latin.R
import helium314.keyboard.latin.settings.DebugSettings
import helium314.keyboard.settings.AllPrefs
import helium314.keyboard.settings.PrefDef
import helium314.keyboard.settings.PreferenceCategory
import helium314.keyboard.settings.SearchPrefScreen
import helium314.keyboard.settings.SettingsActivity2
import helium314.keyboard.settings.SwitchPreference
import helium314.keyboard.settings.Theme
@Composable
fun DebugScreen(
onClickBack: () -> Unit,
) {
SearchPrefScreen(
onClickBack = onClickBack,
title = stringResource(R.string.settings_screen_toolbar),
) {
SettingsActivity2.allPrefs.map[DebugSettings.PREF_SHOW_DEBUG_SETTINGS]!!.Preference()
SettingsActivity2.allPrefs.map[DebugSettings.PREF_DEBUG_MODE]!!.Preference()
SettingsActivity2.allPrefs.map[DebugSettings.PREF_SHOW_SUGGESTION_INFOS]!!.Preference()
SettingsActivity2.allPrefs.map[DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH]!!.Preference()
SettingsActivity2.allPrefs.map[DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW]!!.Preference()
PreferenceCategory(stringResource(R.string.prefs_dump_dynamic_dicts)) {
// todo: fill it
}
}
}
fun createDebugPrefs(context: Context) = listOf(
PrefDef(context, DebugSettings.PREF_SHOW_DEBUG_SETTINGS, R.string.prefs_show_debug_settings) { def ->
SwitchPreference(def, false)
},
PrefDef(context, DebugSettings.PREF_DEBUG_MODE, R.string.prefs_debug_mode) { def ->
SwitchPreference(def, false)
},
PrefDef(context, DebugSettings.PREF_SHOW_SUGGESTION_INFOS, R.string.prefs_show_suggestion_infos) { def ->
SwitchPreference(def, false)
},
PrefDef(context, DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH, R.string.prefs_force_non_distinct_multitouch) { def ->
SwitchPreference(def, false)
},
PrefDef(context, DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW, R.string.sliding_key_input_preview, R.string.sliding_key_input_preview_summary) { def ->
SwitchPreference(def, false)
},
// todo: what about "dump dictionaries"?
)
@Preview
@Composable
private fun Preview() {
SettingsActivity2.allPrefs = AllPrefs(LocalContext.current)
Theme(true) {
Surface {
DebugScreen { }
}
}
}

View file

@ -39,6 +39,7 @@ fun MainSettingsScreen(
onClickToolbar: () -> Unit,
onClickGestureTyping: () -> Unit,
onClickAdvanced: () -> Unit,
onClickAppearance: () -> Unit,
onClickBack: () -> Unit,
) {
val ctx = LocalContext.current