Skip to content

Commit

Permalink
fix(YouTube - Visual preferences icons): Fallback to default icon for…
Browse files Browse the repository at this point in the history
… ExtendedBrand if custom branding icon does not exist
  • Loading branch information
anddea committed Apr 17, 2024
1 parent 91a8701 commit c47dc23
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,25 +221,31 @@ object VisualSettingsIconsPatch : ResourcePatch() {
if (MainSettings!!) resourcesToCopy.add(ResourceGroup("drawable", *validMainTitlesIcons.values.map { "$it.xml" }.toTypedArray()))
if (ExtendedSettings!!) resourcesToCopy.add(ResourceGroup("drawable", *validExtendedTitlesIcons.values.map { "$it.xml" }.toTypedArray()))

// Always copy default icon even if ExtendedBrand is true, as a fallback method
resourcesToCopy.add(ResourceGroup("drawable", *validExtendedBrandIcon.values.map { "$it.xml" }.toTypedArray()))
resourcesToCopy.forEach { context.copyResources("youtube/settings", it) }

CustomBrandingIconPatch.AppIcon?.let { appIcon ->
val appIconValue = appIcon.lowercase().replace(" ", "_")
val resourcePath = "youtube/branding/$appIconValue"

if (ExtendedBrand!!) {
arrayOf(
ResourceGroup(
"drawable", "revanced_extended_settings_key_icon.xml"
)
).forEach { resourceGroup ->
context.copyResources("$resourcePath/launcher", resourceGroup)
// Try to copy custom branding icon and override default icon if it exists,
// otherwise it will use a fallback default icon.
try {
arrayOf(
ResourceGroup(
"drawable", "revanced_extended_settings_key_icon.xml"
)
).forEach { resourceGroup ->
context.copyResources("$resourcePath/launcher", resourceGroup)
}
} catch (_: Exception) {
// Icon does not exist, just skip without error as it fallbacks to default
}
} else {
resourcesToCopy.add(ResourceGroup("drawable", *validExtendedBrandIcon.values.map { "$it.xml" }.toTypedArray()))
}
}

resourcesToCopy.forEach { context.copyResources("youtube/settings", it) }

val tagNames = listOf(
"app.revanced.integrations.youtube.settingsmenu.ResettableEditTextPreference",
"ListPreference",
Expand Down

0 comments on commit c47dc23

Please sign in to comment.