mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
add custom-branding-music-name
patch
This commit is contained in:
@ -0,0 +1,53 @@
|
|||||||
|
package app.revanced.patches.music.layout.branding.name.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.startsWithAny
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.data.ResourceContext
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
|
import app.revanced.patcher.patch.ResourcePatch
|
||||||
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
|
||||||
|
import app.revanced.patches.shared.patch.options.PatchOptions
|
||||||
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
|
@Patch(false)
|
||||||
|
@Name("custom-branding-music-name")
|
||||||
|
@DependsOn([PatchOptions::class])
|
||||||
|
@Description("Changes the Music launcher name to your choice (defaults to RVX Music, ReVanced Extended Music).")
|
||||||
|
@YouTubeMusicCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class CustomBrandingMusicNamePatch : ResourcePatch {
|
||||||
|
override fun execute(context: ResourceContext): PatchResult {
|
||||||
|
|
||||||
|
// App name
|
||||||
|
val resourceFileNames = arrayOf("strings.xml")
|
||||||
|
val fullName = PatchOptions.MusicAppNameFull
|
||||||
|
val shortName = PatchOptions.MusicAppNameShort
|
||||||
|
|
||||||
|
context.forEach {
|
||||||
|
if (!it.name.startsWithAny(*resourceFileNames)) return@forEach
|
||||||
|
|
||||||
|
context.xmlEditor[it.absolutePath].use { editor ->
|
||||||
|
val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element
|
||||||
|
|
||||||
|
for (i in 0 until resourcesNode.childNodes.length) {
|
||||||
|
val node = resourcesNode.childNodes.item(i)
|
||||||
|
if (node !is Element) continue
|
||||||
|
|
||||||
|
val element = resourcesNode.childNodes.item(i) as Element
|
||||||
|
element.textContent = when (element.getAttribute("name")) {
|
||||||
|
"app_name" -> "$fullName"
|
||||||
|
"app_launcher_name" -> "$shortName"
|
||||||
|
else -> continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@ class PatchOptions : ResourcePatch {
|
|||||||
companion object : OptionsContainer() {
|
companion object : OptionsContainer() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom Branding Name
|
* Custom Branding Name (YouTube)
|
||||||
*/
|
*/
|
||||||
internal var YouTubeAppName: String? by option(
|
internal var YouTubeAppName: String? by option(
|
||||||
PatchOption.StringOption(
|
PatchOption.StringOption(
|
||||||
@ -48,6 +48,30 @@ class PatchOptions : ResourcePatch {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom Branding Full Name (YouTube Music)
|
||||||
|
*/
|
||||||
|
internal var MusicAppNameFull: String? by option(
|
||||||
|
PatchOption.StringOption(
|
||||||
|
key = "MusicAppNameFull",
|
||||||
|
default = "ReVanced Extended Music",
|
||||||
|
title = "Application Name of YouTube Music",
|
||||||
|
description = "The name of the YouTube Music it will show on your notification panel."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom Branding Short Name (YouTube Music)
|
||||||
|
*/
|
||||||
|
internal var MusicAppNameShort: String? by option(
|
||||||
|
PatchOption.StringOption(
|
||||||
|
key = "MusicAppNameShort",
|
||||||
|
default = "RVX Music",
|
||||||
|
title = "Application Name of YouTube Music",
|
||||||
|
description = "The name of the YouTube Music it will show on your home screen."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom Package Name (YouTube Music)
|
* Custom Package Name (YouTube Music)
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user