Compare commits

...

4 Commits

Author SHA1 Message Date
semantic-release-bot
f23b7fffc8 chore: Release v5.0.3-dev.1 [skip ci]
## [5.0.3-dev.1](https://github.com/ReVanced/revanced-patches/compare/v5.0.2...v5.0.3-dev.1) (2024-11-13)

### Bug Fixes

* **YouTube - Change header:** Apply header changes to A/B layout ([#3907](https://github.com/ReVanced/revanced-patches/issues/3907)) ([69c504c](69c504ca2f))
2024-11-13 13:15:15 +00:00
LisoUseInAIKyrios
69c504ca2f fix(YouTube - Change header): Apply header changes to A/B layout (#3907) 2024-11-13 17:12:26 +04:00
semantic-release-bot
fc4b0d7c39 chore: Release v5.0.2 [skip ci]
## [5.0.2](https://github.com/ReVanced/revanced-patches/compare/v5.0.1...v5.0.2) (2024-11-12)

### Bug Fixes

* **Sync for Reddit - Fix /s/ links:** Fix patch by using correct fingerprints ([68ec011](68ec011003))
* **Sync for Reddit - Spoof client:** Fix patch by using correct fingerprints ([273bedc](273bedc74c))
* **YouTube - Player controls:** Show player control buttons with A/B layout ([#3901](https://github.com/ReVanced/revanced-patches/issues/3901)) ([e441745](e4417455c9))
2024-11-12 13:47:36 +00:00
oSumAtrIX
02e66b3d43 chore: Merge branch dev to main (#3899) 2024-11-12 14:44:18 +01:00
3 changed files with 71 additions and 14 deletions

View File

@@ -1,3 +1,19 @@
## [5.0.3-dev.1](https://github.com/ReVanced/revanced-patches/compare/v5.0.2...v5.0.3-dev.1) (2024-11-13)
### Bug Fixes
* **YouTube - Change header:** Apply header changes to A/B layout ([#3907](https://github.com/ReVanced/revanced-patches/issues/3907)) ([6ccf114](https://github.com/ReVanced/revanced-patches/commit/6ccf11426ec9e9cd9c8e89a2443f0d0645cc78b1))
## [5.0.2](https://github.com/ReVanced/revanced-patches/compare/v5.0.1...v5.0.2) (2024-11-12)
### Bug Fixes
* **Sync for Reddit - Fix /s/ links:** Fix patch by using correct fingerprints ([a0ad07e](https://github.com/ReVanced/revanced-patches/commit/a0ad07ef3170dbe1d91ebd40f11d97b63d1c63d0))
* **Sync for Reddit - Spoof client:** Fix patch by using correct fingerprints ([5776de3](https://github.com/ReVanced/revanced-patches/commit/5776de3cfbfa62360267eb6026525d2da8c45654))
* **YouTube - Player controls:** Show player control buttons with A/B layout ([#3901](https://github.com/ReVanced/revanced-patches/issues/3901)) ([bb526bc](https://github.com/ReVanced/revanced-patches/commit/bb526bc00a384eb808f46267e5802c8e5beaa7d5))
## [5.0.2-dev.2](https://github.com/ReVanced/revanced-patches/compare/v5.0.2-dev.1...v5.0.2-dev.2) (2024-11-12)

View File

@@ -3,4 +3,4 @@ org.gradle.jvmargs = -Xms512M -Xmx2048M
org.gradle.parallel = true
android.useAndroidX = true
kotlin.code.style = official
version = 5.0.2-dev.2
version = 5.0.3-dev.1

View File

@@ -3,9 +3,12 @@ package app.revanced.patches.youtube.layout.branding.header
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.resourcePatch
import app.revanced.patcher.patch.stringOption
import app.revanced.patches.youtube.misc.playservice.is_19_25_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
import app.revanced.util.findElementByAttributeValueOrThrow
import java.io.File
private const val HEADER_FILE_NAME = "yt_wordmark_header"
@@ -34,6 +37,8 @@ val changeHeaderPatch = resourcePatch(
description = "Applies a custom header in the top left corner within the app. Defaults to the ReVanced header.",
use = false,
) {
dependsOn(versionCheckPatch)
compatibleWith("com.google.android.youtube")
val header by stringOption(
@@ -79,7 +84,7 @@ val changeHeaderPatch = resourcePatch(
/**
* A function that overwrites both header variants in the target resource directories.
*/
val overwriteFromTo: (String, String) -> Unit = { from: String, to: String ->
fun overwriteFromTo(from: String, to: String) {
targetResourceDirectories.forEach { directory ->
variants.forEach { variant ->
val fromPath = directory.resolve("${from}_$variant.png")
@@ -91,23 +96,28 @@ val changeHeaderPatch = resourcePatch(
}
// Functions to overwrite the header to the different variants.
val toPremium = { overwriteFromTo(PREMIUM_HEADER_FILE_NAME, HEADER_FILE_NAME) }
val toHeader = { overwriteFromTo(HEADER_FILE_NAME, PREMIUM_HEADER_FILE_NAME) }
val toReVanced = {
fun toPremium() { overwriteFromTo(PREMIUM_HEADER_FILE_NAME, HEADER_FILE_NAME) }
fun toHeader() { overwriteFromTo(HEADER_FILE_NAME, PREMIUM_HEADER_FILE_NAME) }
fun toReVanced() {
// Copy the ReVanced header to the resource directories.
targetResourceFiles.forEach { copyResources("change-header/revanced", it) }
// Overwrite the premium with the custom header as well.
toHeader()
}
val toReVancedBorderless = {
fun toReVancedBorderless() {
// Copy the ReVanced borderless header to the resource directories.
targetResourceFiles.forEach { copyResources("change-header/revanced-borderless", it) }
targetResourceFiles.forEach {
copyResources(
"change-header/revanced-borderless",
it
)
}
// Overwrite the premium with the custom header as well.
toHeader()
}
val toCustom = {
fun toCustom() {
val sourceFolders = File(header!!).listFiles { file -> file.isDirectory }
?: throw PatchException("The provided path is not a directory: $header")
@@ -136,11 +146,42 @@ val changeHeaderPatch = resourcePatch(
}
when (header) {
HEADER_OPTION -> toHeader
PREMIUM_HEADER_OPTION -> toPremium
REVANCED_HEADER_OPTION -> toReVanced
REVANCED_BORDERLESS_HEADER_OPTION -> toReVancedBorderless
else -> toCustom
}()
HEADER_OPTION -> toHeader()
PREMIUM_HEADER_OPTION -> toPremium()
REVANCED_HEADER_OPTION -> toReVanced()
REVANCED_BORDERLESS_HEADER_OPTION -> toReVancedBorderless()
else -> toCustom()
}
// Fix 19.25+ A/B layout with different header icons:
// yt_ringo2_wordmark_header, yt_ringo2_premium_wordmark_header
//
// These images are webp and not png, so overwriting them is not so simple.
// Instead change styles.xml to use the old drawable resources.
if (is_19_25_or_greater) {
document("res/values/styles.xml").use { document ->
arrayOf(
"CairoLightThemeRingo2Updates" to variants[0],
"CairoDarkThemeRingo2Updates" to variants[1]
).forEach { (styleName, theme) ->
val style = document.childNodes.findElementByAttributeValueOrThrow(
"name",
styleName,
)
val drawable = "@drawable/${HEADER_FILE_NAME}_${theme}"
arrayOf(
"ytWordmarkHeader",
"ytPremiumWordmarkHeader"
).forEach { itemName ->
style.childNodes.findElementByAttributeValueOrThrow(
"name",
itemName,
).textContent = drawable
}
}
}
}
}
}