mirror of
https://github.com/YTVanced/VancedManager
synced 2024-12-03 00:07: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,73 +67,90 @@ 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 {
|
||||||
InstallationOption.SingleSelect(
|
if (appThemes != null) {
|
||||||
titleId = R.string.app_installation_options_theme,
|
add(
|
||||||
getOption = { vancedThemePref },
|
InstallationOption.SingleSelect(
|
||||||
setOption = {
|
titleId = R.string.app_installation_options_theme,
|
||||||
vancedThemePref = it
|
getOption = { vancedThemePref },
|
||||||
},
|
setOption = {
|
||||||
items = appThemes?.map { theme ->
|
vancedThemePref = it
|
||||||
InstallationOptionItem(
|
|
||||||
displayText = {
|
|
||||||
theme.replaceFirstChar {
|
|
||||||
it.titlecase(Locale.getDefault())
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
key = theme
|
items = appThemes.map { theme ->
|
||||||
)
|
InstallationOptionItem(
|
||||||
} ?: emptyList(),
|
displayText = {
|
||||||
),
|
theme.replaceFirstChar {
|
||||||
InstallationOption.SingleSelect(
|
it.titlecase(Locale.getDefault())
|
||||||
titleId = R.string.app_installation_options_version,
|
}
|
||||||
getOption = { vancedVersionPref },
|
},
|
||||||
setOption = {
|
key = theme
|
||||||
vancedVersionPref = it
|
)
|
||||||
},
|
|
||||||
items = appVersions?.map { version ->
|
|
||||||
InstallationOptionItem(
|
|
||||||
displayText = { "v$version" },
|
|
||||||
key = version
|
|
||||||
)
|
|
||||||
}?.plus(latestVersionRadioButton)?.reversed() ?: emptyList(),
|
|
||||||
),
|
|
||||||
InstallationOption.MultiSelect(
|
|
||||||
titleId = R.string.app_installation_options_language,
|
|
||||||
getOption = { vancedLanguagesPref },
|
|
||||||
addOption = {
|
|
||||||
vancedLanguagesPref = vancedLanguagesPref + it
|
|
||||||
},
|
|
||||||
removeOption = {
|
|
||||||
vancedLanguagesPref = vancedLanguagesPref - it
|
|
||||||
},
|
|
||||||
items = appLanguages?.map { language ->
|
|
||||||
InstallationOptionItem(
|
|
||||||
displayText = {
|
|
||||||
val locale = Locale(it)
|
|
||||||
locale.getDisplayName(locale)
|
|
||||||
},
|
},
|
||||||
key = language
|
|
||||||
)
|
)
|
||||||
} ?: emptyList(),
|
)
|
||||||
),
|
}
|
||||||
)
|
if (appVersions != null) {
|
||||||
MUSIC_NAME -> listOf(
|
add(
|
||||||
InstallationOption.SingleSelect(
|
InstallationOption.SingleSelect(
|
||||||
titleId = R.string.app_installation_options_version,
|
titleId = R.string.app_installation_options_version,
|
||||||
getOption = { musicVersionPref },
|
getOption = { vancedVersionPref },
|
||||||
setOption = {
|
setOption = {
|
||||||
musicVersionPref = it
|
vancedVersionPref = it
|
||||||
},
|
},
|
||||||
items = appVersions?.map { version ->
|
items = (appVersions.map { version ->
|
||||||
InstallationOptionItem(
|
InstallationOptionItem(
|
||||||
displayText = { version },
|
displayText = { "v$version" },
|
||||||
key = version
|
key = version
|
||||||
|
)
|
||||||
|
} + latestVersionRadioButton).reversed(),
|
||||||
)
|
)
|
||||||
} ?: emptyList(),
|
)
|
||||||
)
|
}
|
||||||
)
|
if (appLanguages != null) {
|
||||||
|
add(
|
||||||
|
InstallationOption.MultiSelect(
|
||||||
|
titleId = R.string.app_installation_options_language,
|
||||||
|
getOption = { vancedLanguagesPref },
|
||||||
|
addOption = {
|
||||||
|
vancedLanguagesPref = vancedLanguagesPref + it
|
||||||
|
},
|
||||||
|
removeOption = {
|
||||||
|
vancedLanguagesPref = vancedLanguagesPref - it
|
||||||
|
},
|
||||||
|
items = appLanguages.map { language ->
|
||||||
|
InstallationOptionItem(
|
||||||
|
displayText = {
|
||||||
|
val locale = Locale(it)
|
||||||
|
locale.getDisplayName(locale)
|
||||||
|
},
|
||||||
|
key = language
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MUSIC_NAME -> buildList {
|
||||||
|
if (appVersions != null) {
|
||||||
|
add(
|
||||||
|
InstallationOption.SingleSelect(
|
||||||
|
titleId = R.string.app_installation_options_version,
|
||||||
|
getOption = { musicVersionPref },
|
||||||
|
setOption = {
|
||||||
|
musicVersionPref = it
|
||||||
|
},
|
||||||
|
items = (appVersions.map { version ->
|
||||||
|
InstallationOptionItem(
|
||||||
|
displayText = { "v$version" },
|
||||||
|
key = version
|
||||||
|
)
|
||||||
|
} + latestVersionRadioButton).reversed(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue