Skip to content

Commit

Permalink
chore: reactor ControlsSettingsFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
david-allison authored and mikehardy committed Dec 21, 2023
1 parent 938ac07 commit ddb4487
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ class ControlsSettingsFragment : SettingsFragment() {

@NeedsTest("Keys and titles in the XML layout are the same of the ViewerCommands")
override fun initSubscreen() {
val commands = HashMap<String, ViewerCommand>()
ViewerCommand.entries.forEach { commands[it.preferenceKey] = it }
val commands = ViewerCommand.entries.associateBy { it.preferenceKey }
// set defaultValue in the prefs creation.
// if a preference is empty, it has a value like "1/"
allPreferences()
.filterIsInstance<ControlPreference>()
.forEach { pref ->
if (pref.value == null) {
pref.value = commands[pref.key]?.defaultValue?.toPreferenceString()
}
}
.filter { pref -> pref.value == null }
.forEach { pref -> pref.value = commands[pref.key]?.defaultValue?.toPreferenceString() }
}
}

0 comments on commit ddb4487

Please sign in to comment.