Skip to content

Commit

Permalink
feat(YouTube - Visual preferences icons): Icon for Extended setting b…
Browse files Browse the repository at this point in the history
…ased on `Custom branding icon`
  • Loading branch information
anddea committed Apr 16, 2024
1 parent 67f3591 commit a674b1a
Show file tree
Hide file tree
Showing 11 changed files with 11,716 additions and 3,286 deletions.
2 changes: 2 additions & 0 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,8 @@ public final class app/revanced/patches/youtube/layout/branding/icon/CustomBrand
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch;
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
public final fun getAppIcon ()Ljava/lang/String;
public final fun setAppIcon (Ljava/lang/String;)V
}

public final class app/revanced/patches/youtube/layout/branding/name/CustomBrandingNamePatch : app/revanced/patches/shared/patch/elements/AbstractRemoveStringsElementsPatch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ object CustomBrandingIconPatch : ResourcePatch() {
"mdpi"
).map { "mipmap-$it" }

private var AppIcon by stringPatchOption(
var AppIcon by stringPatchOption(
key = "AppIcon",
default = DEFAULT_ICON_KEY,
values = availableIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.booleanPatchOption
import app.revanced.patches.youtube.layout.branding.icon.CustomBrandingIconPatch
import app.revanced.util.ResourceGroup
import app.revanced.util.copyResources
import org.w3c.dom.Document
Expand Down Expand Up @@ -32,7 +33,15 @@ object VisualSettingsIconsPatch : ResourcePatch() {
key = "ExtendedSettings",
default = true,
title = "Extended settings",
description = "Apply icons to extended main screen settings",
description = "Apply icons to Extended main screen settings",
required = true
)

private val ExtendedBrand by booleanPatchOption(
key = "ExtendedBrand",
default = false,
title = "Extended brand icon",
description = "Icon for Extended setting based on \"Custom branding icon\". If this option is enabled but \"Custom branding icon\" patch is excluded, it will use default custom branding icon.",
required = true
)

Expand Down Expand Up @@ -122,8 +131,6 @@ object VisualSettingsIconsPatch : ResourcePatch() {
"captions_key",
"accessibility_settings_key",
"about_key",

"revanced_extended_settings_key",
)

val validExtendedTitles = setOf(
Expand All @@ -145,6 +152,10 @@ object VisualSettingsIconsPatch : ResourcePatch() {
"misc",
)

val validExtendedBrand = setOf(
"revanced_extended_settings_key",
)

val emptyTitles = setOf(
"revanced_custom_playback_speeds",
"revanced_custom_playback_speed_panel_type",
Expand Down Expand Up @@ -190,6 +201,7 @@ object VisualSettingsIconsPatch : ResourcePatch() {
}

val validMainTitlesIcons = validMainTitles.associateWith { "${it}_icon" }
val validExtendedBrandIcon = validExtendedBrand.associateWith { "${it}_icon" }

val validExtendedTitlesIcons = validExtendedTitles.associateWith { title ->
when (title) {
Expand All @@ -209,6 +221,23 @@ 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()))

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)
}
} else {
resourcesToCopy.add(ResourceGroup("drawable", *validExtendedBrandIcon.values.map { "$it.xml" }.toTypedArray()))
}
}

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

val tagNames = listOf(
Expand All @@ -235,6 +264,7 @@ object VisualSettingsIconsPatch : ResourcePatch() {
title in validTitles -> validTitlesIcons[title]
MainSettings!! && title in validMainTitles -> validMainTitlesIcons[title]
ExtendedSettings!! && title in validExtendedTitles -> validExtendedTitlesIcons[title]
title in validExtendedBrand -> validExtendedBrandIcon[title]
title in emptyTitles -> emptyIcon
else -> null
}
Expand Down
Loading

2 comments on commit a674b1a

@MoniBlackouts
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now every icons really looking cool. Thanks dev appreciated
and I request you to join extended telegram group.. It helps to discuss.
Thanks

@anddea
Copy link
Owner Author

@anddea anddea commented on a674b1a Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Telegram is gonna be messy, because it's a messenger with so many people and even more messages. It's much better and organized to discuss here (on Github) in discussions or issues. Thank you for your invitation.

Please sign in to comment.