fix(youtube/downloads): rename patch to external-downloads (#2274)

This commit is contained in:
LisoUseInAIKyrios 2023-05-26 15:03:44 +04:00 committed by GitHub
parent e0b1b35fb3
commit 4480911e0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 31 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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()

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:yt="http://schemas.android.com/apk/res-auto" android:id="@+id/youtube_controls_bottom_ui_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layoutDirection="ltr">
<com.google.android.libraries.youtube.common.ui.TouchImageView android:id="@+id/download_button" android:paddingLeft="12dp" android:paddingTop="22dp" android:paddingRight="12dp" android:paddingBottom="16dp" android:longClickable="false" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/revanced_yt_download_button" android:scaleType="center" yt:layout_constraintBottom_toTopOf="@+id/quick_actions_container" yt:layout_constraintRight_toLeftOf="@+id/fullscreen_button" style="@style/YouTubePlayerButton"/>
<com.google.android.libraries.youtube.common.ui.TouchImageView android:id="@+id/external_download_button" android:paddingLeft="12dp" android:paddingTop="22dp" android:paddingRight="12dp" android:paddingBottom="16dp" android:longClickable="false" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/revanced_yt_download_button" android:scaleType="center" yt:layout_constraintBottom_toTopOf="@+id/quick_actions_container" yt:layout_constraintRight_toLeftOf="@+id/fullscreen_button" style="@style/YouTubePlayerButton"/>
</android.support.constraint.ConstraintLayout>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="downloader_not_installed_warning">is not installed. Please install it.</string>
<string name="external_downloader_not_installed_warning">is not installed. Please install it.</string>
</resources>