load the correct file when editing symbols layouts, fixes #407

This commit is contained in:
Helium314 2024-01-12 11:05:38 +01:00
parent 095946738e
commit 3b48e49067

View file

@ -98,15 +98,15 @@ class AdvancedSettingsFragment : SubScreenFragment() {
findPreference<Preference>("pref_backup_restore")?.setOnPreferenceClickListener { showBackupRestoreDialog() }
findPreference<Preference>("custom_symbols_layout")?.setOnPreferenceClickListener {
val file = "${CUSTOM_LAYOUT_PREFIX}symbols.txt"
val oldLayout = if (File(file).exists()) null else context.assets.open("layouts${File.separator}symbols.txt").reader().readText()
editCustomLayout(file, context, oldLayout, true)
val layoutName = Settings.readSymbolsLayoutName(context, context.resources.configuration.locale).takeIf { it.startsWith(CUSTOM_LAYOUT_PREFIX) }
val oldLayout = if (layoutName != null) null else context.assets.open("layouts${File.separator}symbols.txt").reader().readText()
editCustomLayout(layoutName ?: "${CUSTOM_LAYOUT_PREFIX}symbols.txt", context, oldLayout, true)
true
}
findPreference<Preference>("custom_shift_symbols_layout")?.setOnPreferenceClickListener {
val file = "${CUSTOM_LAYOUT_PREFIX}shift_symbols.txt"
val oldLayout = if (File(file).exists()) null else context.assets.open("layouts${File.separator}symbols_shifted.txt").reader().readText()
editCustomLayout(file, context, oldLayout, true)
val layoutName = Settings.readShiftedSymbolsLayoutName(context).takeIf { it.startsWith(CUSTOM_LAYOUT_PREFIX) }
val oldLayout = if (layoutName != null) null else context.assets.open("layouts${File.separator}symbols_shifted.txt").reader().readText()
editCustomLayout(layoutName ?: "${CUSTOM_LAYOUT_PREFIX}shift_symbols.txt", context, oldLayout, true)
true
}
}