diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt index ce1b112d6..6c16d32fc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt @@ -4,9 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.ResourceData -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultError -import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.* import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.impl.ResourcePatch @@ -17,7 +15,7 @@ import java.nio.file.Files @Patch @DependsOn(FixLocaleConfigErrorPatch::class) @Name("custom-branding") -@Description("Changes the YouTube launcher icon to be ReVanced's.") +@Description("Changes the YouTube launcher icon and name to your choice (defaults to ReVanced).") @CustomBrandingCompatibility @Version("0.0.1") class CustomBrandingPatch : ResourcePatch() { @@ -25,6 +23,7 @@ class CustomBrandingPatch : ResourcePatch() { val resDirectory = data["res"] if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.") + // Icon branding val iconNames = arrayOf( "adaptiveproduct_youtube_background_color_108", "adaptiveproduct_youtube_foreground_color_108", @@ -50,6 +49,32 @@ class CustomBrandingPatch : ResourcePatch() { } } + // Name branding + val appName = options[keyAppName].value + + val manifest = data["AndroidManifest.xml"] + manifest.writeText( + manifest.readText() + .replace( + "android:label=\"@string/application_name", + "android:label=\"$appName" + ) + ) + return PatchResultSuccess() } + + override val options = PatchOptions( + PatchOption.StringOption( + key = keyAppName, + default = "YouTube ReVanced", + title = "Application Name", + description = "The name of the application it will show on your home screen.", + required = true + ) + ) + + private companion object { + private const val keyAppName = "appName" + } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt index 05daad446..ac48ad47d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt @@ -11,7 +11,6 @@ import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import app.revanced.patches.youtube.misc.microg.shared.Constants.BASE_MICROG_PACKAGE_NAME -import app.revanced.patches.youtube.misc.microg.shared.Constants.REVANCED_APP_NAME import app.revanced.patches.youtube.misc.microg.shared.Constants.REVANCED_PACKAGE_NAME import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsResourcePatch @@ -48,8 +47,6 @@ class MicroGResourcePatch : ResourcePatch() { manifest.readText() .replace( "package=\"com.google.android.youtube", "package=\"$REVANCED_PACKAGE_NAME" - ).replace( - "android:label=\"@string/application_name", "android:label=\"$REVANCED_APP_NAME" ).replace( "android:authorities=\"com.google.android.youtube", "android:authorities=\"$REVANCED_PACKAGE_NAME" ).replace( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt index 5d56903c9..768101e0a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt @@ -3,5 +3,4 @@ package app.revanced.patches.youtube.misc.microg.shared object Constants { internal const val BASE_MICROG_PACKAGE_NAME = "com.mgoogle" internal const val REVANCED_PACKAGE_NAME = "app.revanced.android.youtube" - internal const val REVANCED_APP_NAME = "YouTube ReVanced" } \ No newline at end of file