From 4480911e0b056f2148616a0c2af6b4ab7c482c3b Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Fri, 26 May 2023 15:03:44 +0400 Subject: [PATCH] fix(youtube/downloads): rename patch to `external-downloads` (#2274) --- ...y.kt => ExternalDownloadsCompatibility.kt} | 2 +- ...h.kt => ExternalDownloadsBytecodePatch.kt} | 16 +++++----- ...h.kt => ExternalDownloadsResourcePatch.kt} | 32 +++++++------------ .../youtube_controls_bottom_ui_container.xml | 2 +- .../downloads/host/values/strings.xml | 2 +- 5 files changed, 23 insertions(+), 31 deletions(-) rename src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/{DownloadsCompatibility.kt => ExternalDownloadsCompatibility.kt} (83%) rename src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/{DownloadsBytecodePatch.kt => ExternalDownloadsBytecodePatch.kt} (76%) rename src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/{DownloadsResourcePatch.kt => ExternalDownloadsResourcePatch.kt} (80%) diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/DownloadsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/ExternalDownloadsCompatibility.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/DownloadsCompatibility.kt rename to src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/ExternalDownloadsCompatibility.kt index 5e852530..7dc840c6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/DownloadsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/ExternalDownloadsCompatibility.kt @@ -5,5 +5,5 @@ import app.revanced.patcher.annotation.Package @Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) -internal annotation class DownloadsCompatibility +internal annotation class ExternalDownloadsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/DownloadsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/ExternalDownloadsBytecodePatch.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/DownloadsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/ExternalDownloadsBytecodePatch.kt index d296b396..5d5f6965 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/DownloadsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/ExternalDownloadsBytecodePatch.kt @@ -9,20 +9,20 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.youtube.interaction.downloads.annotation.DownloadsCompatibility -import app.revanced.patches.youtube.interaction.downloads.resource.patch.DownloadsResourcePatch +import app.revanced.patches.youtube.interaction.downloads.annotation.ExternalDownloadsCompatibility +import app.revanced.patches.youtube.interaction.downloads.resource.patch.ExternalDownloadsResourcePatch import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch import app.revanced.patches.youtube.video.information.patch.VideoInformationPatch @Patch -@Name("downloads") -@DependsOn([DownloadsResourcePatch::class, PlayerControlsBytecodePatch::class, VideoInformationPatch::class]) -@Description("Adds a download button to the YouTube video player.") -@DownloadsCompatibility +@Name("external-downloads") +@DependsOn([ExternalDownloadsResourcePatch::class, PlayerControlsBytecodePatch::class, VideoInformationPatch::class]) +@Description("Adds support to download and save YouTube videos using an external app.") +@ExternalDownloadsCompatibility @Version("0.0.1") -class DownloadsBytecodePatch : BytecodePatch() { +class ExternalDownloadsBytecodePatch : BytecodePatch() { private companion object { - const val BUTTON_DESCRIPTOR = "Lapp/revanced/integrations/videoplayer/DownloadButton;" + const val BUTTON_DESCRIPTOR = "Lapp/revanced/integrations/videoplayer/ExternalDownloadButton;" } override fun execute(context: BytecodeContext): PatchResult { diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/ExternalDownloadsResourcePatch.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/ExternalDownloadsResourcePatch.kt index 4ab4a883..1a0cad41 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/ExternalDownloadsResourcePatch.kt @@ -14,50 +14,42 @@ import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources import app.revanced.util.resources.ResourceUtils.mergeStrings -@Name("downloads-resource-patch") +@Name("external-downloads-resource-patch") @DependsOn([BottomControlsResourcePatch::class, SettingsPatch::class]) @Version("0.0.1") -class DownloadsResourcePatch : ResourcePatch { +class ExternalDownloadsResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( PreferenceScreen( "revanced_external_downloader_preference_screen", - StringResource("revanced_external_downloader_preference_screen_title", "Download settings"), + StringResource("revanced_external_downloader_preference_screen_title", "External download settings"), listOf( SwitchPreference( "revanced_external_downloader", - StringResource("revanced_external_downloader_title", "Show download button"), - StringResource("revanced_external_downloader_summary_on", "Download button is shown"), - StringResource("revanced_external_downloader_summary_off", "Download button is not shown") + StringResource("revanced_external_downloader_title", "Show external download button"), + StringResource("revanced_external_downloader_summary_on", "Download button shown in player"), + StringResource("revanced_external_downloader_summary_off", "Download button not shown in player") ), TextPreference( "revanced_external_downloader_name", StringResource("revanced_external_downloader_name_title", "Downloader package name"), - StringResource("revanced_external_downloader_name_summary", "Package name of the downloader app such as NewPipe\\'s or PowerTube\\'s"), + StringResource("revanced_external_downloader_name_summary", "Package name of your installed external downloader app, such as NewPipe or PowerTube"), InputType.TEXT ) ), - StringResource("revanced_external_downloader_preference_screen_summary", "Settings related to downloads") + StringResource("revanced_external_downloader_preference_screen_summary", "Settings for using an external downloader") ) ) - /* - * Copy strings - */ - + // Copy strings context.mergeStrings("downloads/host/values/strings.xml") - /* - * Copy resources - */ - + // Copy resources context.copyResources("downloads", ResourceUtils.ResourceGroup("drawable", "revanced_yt_download_button.xml")) - /* - * Add download button node - */ - + // Add download button node BottomControlsResourcePatch.addControls("downloads/host/layout/${BottomControlsResourcePatch.TARGET_RESOURCE_NAME}") return PatchResultSuccess() diff --git a/src/main/resources/downloads/host/layout/youtube_controls_bottom_ui_container.xml b/src/main/resources/downloads/host/layout/youtube_controls_bottom_ui_container.xml index 23254785..419845aa 100644 --- a/src/main/resources/downloads/host/layout/youtube_controls_bottom_ui_container.xml +++ b/src/main/resources/downloads/host/layout/youtube_controls_bottom_ui_container.xml @@ -1,4 +1,4 @@ - + diff --git a/src/main/resources/downloads/host/values/strings.xml b/src/main/resources/downloads/host/values/strings.xml index 957d490f..dcdfd275 100644 --- a/src/main/resources/downloads/host/values/strings.xml +++ b/src/main/resources/downloads/host/values/strings.xml @@ -1,4 +1,4 @@ - is not installed. Please install it. + is not installed. Please install it.