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:
parent
e9e4222014
commit
22ac84e448
1 changed files with 80 additions and 63 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue