Skip to content

Commit

Permalink
fix(YouTube - Custom branding): Change icon correctly on 19.34+ (ReVa…
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Nov 6, 2024
1 parent b0ac6ce commit 2e47903
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package app.revanced.patches.youtube.layout.branding

import app.revanced.patcher.patch.resourcePatch
import app.revanced.patcher.patch.stringOption
import app.revanced.patches.youtube.misc.playservice.is_19_34_or_greater
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
import app.revanced.util.ResourceGroup
import app.revanced.util.Utils.trimIndentMultiline
import app.revanced.util.copyResources
Expand All @@ -18,6 +20,11 @@ private val iconResourceFileNames = arrayOf(
"ic_launcher_round",
).map { "$it.png" }.toTypedArray()

private val iconResourceFileNamesNew = mapOf(
"adaptiveproduct_youtube_foreground_color_108" to "adaptiveproduct_youtube_2024_q4_foreground_color_108",
"adaptiveproduct_youtube_background_color_108" to "adaptiveproduct_youtube_2024_q4_background_color_108",
)

private val mipmapDirectories = arrayOf(
"xxxhdpi",
"xxhdpi",
Expand All @@ -32,6 +39,8 @@ val customBrandingPatch = resourcePatch(
description = "Applies a custom app name and icon. Defaults to \"YouTube ReVanced\" and the ReVanced logo.",
use = false,
) {
dependsOn(versionCheckPatch)

compatibleWith("com.google.android.youtube")

val appName by stringOption(
Expand Down Expand Up @@ -93,6 +102,21 @@ val customBrandingPatch = resourcePatch(
resourceGroups.forEach { copyResources("custom-branding", it) }
}
}

if (is_19_34_or_greater) {
val resourceDirectory = get("res")

mipmapDirectories.forEach { directory ->
val targetDirectory = resourceDirectory.resolve(directory)

iconResourceFileNamesNew.forEach { (old, new) ->
val oldFile = targetDirectory.resolve("$old.png")
val newFile = targetDirectory.resolve("$new.png")

Files.write(newFile.toPath(), oldFile.readBytes())
}
}
}
}

appName?.let { name ->
Expand Down

0 comments on commit 2e47903

Please sign in to comment.