0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-12-03 16:27:25 +00:00

update installation option getter

This commit is contained in:
X1nto 2021-12-04 18:36:22 +04:00
parent e9e4222014
commit 22ac84e448

View file

@ -67,15 +67,17 @@ class AppDtoMapper(
appThemes: List<String>?, appThemes: List<String>?,
appVersions: List<String>?, appVersions: List<String>?,
appLanguages: List<String>?, appLanguages: List<String>?,
) = when (appName) { ) : List<InstallationOption>? = when (appName) {
VANCED_NAME -> listOf( VANCED_NAME -> buildList {
if (appThemes != null) {
add(
InstallationOption.SingleSelect( InstallationOption.SingleSelect(
titleId = R.string.app_installation_options_theme, titleId = R.string.app_installation_options_theme,
getOption = { vancedThemePref }, getOption = { vancedThemePref },
setOption = { setOption = {
vancedThemePref = it vancedThemePref = it
}, },
items = appThemes?.map { theme -> items = appThemes.map { theme ->
InstallationOptionItem( InstallationOptionItem(
displayText = { displayText = {
theme.replaceFirstChar { theme.replaceFirstChar {
@ -84,21 +86,29 @@ class AppDtoMapper(
}, },
key = theme key = theme
) )
} ?: emptyList(), },
), )
)
}
if (appVersions != null) {
add(
InstallationOption.SingleSelect( InstallationOption.SingleSelect(
titleId = R.string.app_installation_options_version, titleId = R.string.app_installation_options_version,
getOption = { vancedVersionPref }, getOption = { vancedVersionPref },
setOption = { setOption = {
vancedVersionPref = it vancedVersionPref = it
}, },
items = appVersions?.map { version -> items = (appVersions.map { version ->
InstallationOptionItem( InstallationOptionItem(
displayText = { "v$version" }, displayText = { "v$version" },
key = version key = version
) )
}?.plus(latestVersionRadioButton)?.reversed() ?: emptyList(), } + latestVersionRadioButton).reversed(),
), )
)
}
if (appLanguages != null) {
add(
InstallationOption.MultiSelect( InstallationOption.MultiSelect(
titleId = R.string.app_installation_options_language, titleId = R.string.app_installation_options_language,
getOption = { vancedLanguagesPref }, getOption = { vancedLanguagesPref },
@ -108,7 +118,7 @@ class AppDtoMapper(
removeOption = { removeOption = {
vancedLanguagesPref = vancedLanguagesPref - it vancedLanguagesPref = vancedLanguagesPref - it
}, },
items = appLanguages?.map { language -> items = appLanguages.map { language ->
InstallationOptionItem( InstallationOptionItem(
displayText = { displayText = {
val locale = Locale(it) val locale = Locale(it)
@ -116,24 +126,31 @@ class AppDtoMapper(
}, },
key = language key = language
) )
} ?: emptyList(), },
),
) )
MUSIC_NAME -> listOf( )
}
}
MUSIC_NAME -> buildList {
if (appVersions != null) {
add(
InstallationOption.SingleSelect( InstallationOption.SingleSelect(
titleId = R.string.app_installation_options_version, titleId = R.string.app_installation_options_version,
getOption = { musicVersionPref }, getOption = { musicVersionPref },
setOption = { setOption = {
musicVersionPref = it musicVersionPref = it
}, },
items = appVersions?.map { version -> items = (appVersions.map { version ->
InstallationOptionItem( InstallationOptionItem(
displayText = { version }, displayText = { "v$version" },
key = version key = version
) )
} ?: emptyList(), } + latestVersionRadioButton).reversed(),
) )
) )
}
}
else -> null else -> null
} }
} }