add missing debug settings

This commit is contained in:
Helium314 2025-01-30 21:03:00 +01:00
parent f07f139469
commit 0b4bbdfdc9
3 changed files with 48 additions and 10 deletions

View file

@ -30,7 +30,7 @@ import helium314.keyboard.latin.R;
public final class DebugSettingsFragment extends SubScreenFragment public final class DebugSettingsFragment extends SubScreenFragment
implements Preference.OnPreferenceClickListener { implements Preference.OnPreferenceClickListener {
private static final String PREF_KEY_DUMP_DICTS = "dump_dictionaries"; private static final String PREF_KEY_DUMP_DICTS = "dump_dictionaries";
private static final String PREF_KEY_DUMP_DICT_PREFIX = "dump_dictionaries"; public static final String PREF_KEY_DUMP_DICT_PREFIX = "dump_dictionaries";
private boolean mServiceNeedsRestart = false; private boolean mServiceNeedsRestart = false;
private TwoStatePreference mDebugMode; private TwoStatePreference mDebugMode;

View file

@ -13,8 +13,11 @@ import helium314.keyboard.latin.settings.Settings
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
// todo // todo
// test release vs old release for settings start speed
// also when coming from keyboard
// good way to measure startup time? e.g. sth in activity, or in composable, compared to settings button
// check if there are simple ways to improve it (try kicking out "everything" at start)
// more pref screens // more pref screens
// debug
// appearance // appearance
// colors // colors
// personal dictionary // personal dictionary
@ -55,7 +58,8 @@ import kotlinx.coroutines.flow.MutableStateFlow
// -> users confused, but probably better than the 2 above // -> users confused, but probably better than the 2 above
// adjust layout a little, there is too much empty space and titles are too large (dialogs!) // adjust layout a little, there is too much empty space and titles are too large (dialogs!)
// check dialogs have the same colors // check dialogs have the same colors
// list preference -> we can make auto_correct_threshold a float directly // list preference -> we can make auto_correct_threshold a float directly (needs pref upgrade
// actually test all the settings
// maybe later // maybe later
// weird problem with app sometimes closing on back, but that's related to "old" settings (don't care if all are removed) // weird problem with app sometimes closing on back, but that's related to "old" settings (don't care if all are removed)

View file

@ -1,20 +1,28 @@
package helium314.keyboard.settings.screens package helium314.keyboard.settings.screens
import android.content.Context import android.content.Context
import android.content.Intent
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import helium314.keyboard.latin.BuildConfig
import helium314.keyboard.latin.DictionaryDumpBroadcastReceiver
import helium314.keyboard.latin.DictionaryFacilitator
import helium314.keyboard.latin.R import helium314.keyboard.latin.R
import helium314.keyboard.latin.settings.DebugSettings import helium314.keyboard.latin.settings.DebugSettings
import helium314.keyboard.latin.settings.DebugSettingsFragment
import helium314.keyboard.settings.AllPrefs import helium314.keyboard.settings.AllPrefs
import helium314.keyboard.settings.PrefDef import helium314.keyboard.settings.PrefDef
import helium314.keyboard.settings.Preference
import helium314.keyboard.settings.PreferenceCategory import helium314.keyboard.settings.PreferenceCategory
import helium314.keyboard.settings.SearchPrefScreen import helium314.keyboard.settings.SearchPrefScreen
import helium314.keyboard.settings.SettingsActivity2 import helium314.keyboard.settings.SettingsActivity2
import helium314.keyboard.settings.SwitchPreference import helium314.keyboard.settings.SwitchPreference
import helium314.keyboard.settings.Theme import helium314.keyboard.settings.Theme
import helium314.keyboard.settings.prefs
import helium314.keyboard.settings.themeChanged
@Composable @Composable
fun DebugScreen( fun DebugScreen(
@ -30,29 +38,52 @@ fun DebugScreen(
SettingsActivity2.allPrefs.map[DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH]!!.Preference() SettingsActivity2.allPrefs.map[DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH]!!.Preference()
SettingsActivity2.allPrefs.map[DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW]!!.Preference() SettingsActivity2.allPrefs.map[DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW]!!.Preference()
PreferenceCategory(stringResource(R.string.prefs_dump_dynamic_dicts)) { PreferenceCategory(stringResource(R.string.prefs_dump_dynamic_dicts)) {
// todo: fill it DictionaryFacilitator.DYNAMIC_DICTIONARY_TYPES.forEach {
SettingsActivity2.allPrefs.map[DebugSettingsFragment.PREF_KEY_DUMP_DICT_PREFIX + it]!!.Preference()
}
} }
} }
} }
fun createDebugPrefs(context: Context) = listOf( fun createDebugPrefs(context: Context) = listOf(
PrefDef(context, DebugSettings.PREF_SHOW_DEBUG_SETTINGS, R.string.prefs_show_debug_settings) { def -> PrefDef(context, DebugSettings.PREF_SHOW_DEBUG_SETTINGS, R.string.prefs_show_debug_settings) { def ->
SwitchPreference(def, false) val prefs = LocalContext.current.prefs()
SwitchPreference(
name = def.title,
pref = def.key,
default = false,
description = stringResource(R.string.version_text, BuildConfig.VERSION_NAME)
) { if (!it) prefs.edit().putBoolean(DebugSettings.PREF_DEBUG_MODE, false).apply() }
}, },
PrefDef(context, DebugSettings.PREF_DEBUG_MODE, R.string.prefs_debug_mode) { def -> PrefDef(context, DebugSettings.PREF_DEBUG_MODE, R.string.prefs_debug_mode) { def ->
SwitchPreference(def, false) val prefs = LocalContext.current.prefs()
SwitchPreference(def, false) {
needsRestart = true
if (!it) prefs.edit().putBoolean(DebugSettings.PREF_SHOW_SUGGESTION_INFOS, false).apply()
}
}, },
PrefDef(context, DebugSettings.PREF_SHOW_SUGGESTION_INFOS, R.string.prefs_show_suggestion_infos) { def -> PrefDef(context, DebugSettings.PREF_SHOW_SUGGESTION_INFOS, R.string.prefs_show_suggestion_infos) { def ->
SwitchPreference(def, false) SwitchPreference(def, false) { themeChanged = true }
}, },
PrefDef(context, DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH, R.string.prefs_force_non_distinct_multitouch) { def -> PrefDef(context, DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH, R.string.prefs_force_non_distinct_multitouch) { def ->
SwitchPreference(def, false) SwitchPreference(def, false) { needsRestart = true }
}, },
PrefDef(context, DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW, R.string.sliding_key_input_preview, R.string.sliding_key_input_preview_summary) { def -> 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) SwitchPreference(def, false)
}, },
// todo: what about "dump dictionaries"? ) + DictionaryFacilitator.DYNAMIC_DICTIONARY_TYPES.map {
PrefDef(context, DebugSettingsFragment.PREF_KEY_DUMP_DICT_PREFIX + it, R.string.button_default) { def ->
val ctx = LocalContext.current
Preference(
name = "Dump $it dictionary",
onClick = {
val intent = Intent(DictionaryDumpBroadcastReceiver.DICTIONARY_DUMP_INTENT_ACTION)
intent.putExtra(DictionaryDumpBroadcastReceiver.DICTIONARY_NAME_KEY, it)
ctx.sendBroadcast(intent)
}
) )
}
}
@Preview @Preview
@Composable @Composable
@ -64,3 +95,6 @@ private fun Preview() {
} }
} }
} }
// todo: actually use it
var needsRestart = false