diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/CustomBrandingIconPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/CustomBrandingIconPatch.kt index 9db6423d9..3f1bdbb75 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/CustomBrandingIconPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/CustomBrandingIconPatch.kt @@ -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) diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/header/ChangeHeaderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/header/ChangeHeaderPatch.kt index 3be7d2c93..7bfae51e2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/header/ChangeHeaderPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/header/ChangeHeaderPatch.kt @@ -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, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt index abdb313a7..f45d688d0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt @@ -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.") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/header/ChangeHeaderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/header/ChangeHeaderPatch.kt index 93ae7b70d..b9c01c833 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/header/ChangeHeaderPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/header/ChangeHeaderPatch.kt @@ -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,