fix(Custom branding): Patching fails in some environments when the path entered in the patch options contains uppercase letters

This commit is contained in:
inotia00 2024-12-16 12:24:03 +09:00
parent 4e85c77d53
commit e3f5741b06
4 changed files with 19 additions and 9 deletions

View File

@ -17,6 +17,7 @@ import app.revanced.util.copyResources
import app.revanced.util.getAdaptiveIconResourceFile
import app.revanced.util.getResourceGroup
import app.revanced.util.underBarOrThrow
import app.revanced.util.valueOrThrow
import org.w3c.dom.Element
import java.io.File
import java.nio.file.Files
@ -136,7 +137,7 @@ val customBrandingIconPatch = resourcePatch(
execute {
// Check patch options first.
val appIcon = appIconOption.underBarOrThrow()
var appIcon = appIconOption.underBarOrThrow()
val appIconResourcePath = "music/branding/$appIcon"
val youtubeMusicIconResourcePath = "music/branding/youtube_music"
@ -145,6 +146,7 @@ val customBrandingIconPatch = resourcePatch(
// Check if a custom path is used in the patch options.
if (!availableIcon.containsValue(appIcon)) {
appIcon = appIconOption.valueOrThrow()
launcherIconResourceGroups.let { resourceGroups ->
try {
val path = File(appIcon)

View File

@ -14,6 +14,7 @@ import app.revanced.util.copyFile
import app.revanced.util.copyResources
import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
import app.revanced.util.fingerprint.resolvable
import app.revanced.util.underBarOrThrow
import app.revanced.util.valueOrThrow
private const val DEFAULT_HEADER_KEY = "Custom branding icon"
@ -145,15 +146,17 @@ val changeHeaderPatch = resourcePatch(
execute {
// Check patch options first.
val customHeader = customHeaderOption
.valueOrThrow()
var customHeader = customHeaderOption
.underBarOrThrow()
val isPath = customHeader != DEFAULT_HEADER_VALUE
val customBrandingIconType = getIconType()
val customBrandingIconIncluded = customBrandingIconType != "default"
customHeader = customHeaderOption.valueOrThrow()
val warnings = "WARNING: Invalid header path: $customHeader. Does not apply patches."
if (customHeader != DEFAULT_HEADER_VALUE) {
if (isPath) {
copyFile(
headerIconResourceGroups,
customHeader,

View File

@ -18,6 +18,7 @@ import app.revanced.util.copyXmlNode
import app.revanced.util.getAdaptiveIconResourceFile
import app.revanced.util.getResourceGroup
import app.revanced.util.underBarOrThrow
import app.revanced.util.valueOrThrow
import java.nio.file.Files
import java.nio.file.StandardCopyOption
@ -136,13 +137,14 @@ val customBrandingIconPatch = resourcePatch(
execute {
// Check patch options first.
val appIcon = appIconOption.underBarOrThrow()
var appIcon = appIconOption
.underBarOrThrow()
val appIconResourcePath = "youtube/branding/$appIcon"
// Check if a custom path is used in the patch options.
if (!availableIcon.containsValue(appIcon)) {
appIcon = appIconOption.valueOrThrow()
val copiedFiles = copyFile(
launcherIconResourceGroups,
appIcon,
@ -192,7 +194,7 @@ val customBrandingIconPatch = resourcePatch(
"resources"
)
} else {
println("WARNING: Restore old splash animation is not supported in this version. Use YouTube 19.16.39 or earlier.")
println("WARNING: \"Restore old splash animation\" is not supported in this version. Use YouTube 19.16.39 or earlier.")
}
}

View File

@ -11,6 +11,7 @@ import app.revanced.util.Utils.trimIndentMultiline
import app.revanced.util.copyFile
import app.revanced.util.copyResources
import app.revanced.util.underBarOrThrow
import app.revanced.util.valueOrThrow
import java.io.File
import java.nio.file.Files
import kotlin.io.path.copyTo
@ -115,16 +116,18 @@ val changeHeaderPatch = resourcePatch(
execute {
// Check patch options first.
val customHeader = customHeaderOption
var customHeader = customHeaderOption
.underBarOrThrow()
val isPath = customHeader != DEFAULT_HEADER_VALUE
val customBrandingIconType = getIconType()
val customBrandingIconIncluded =
customBrandingIconType != "default" && customBrandingIconType != "custom"
customHeader = customHeaderOption.valueOrThrow()
val warnings = "WARNING: Invalid header path: $customHeader. Does not apply patches."
if (customHeader != DEFAULT_HEADER_VALUE) {
if (isPath) {
copyFile(
headerIconResourceGroups,
customHeader,