From d2cf10b01d6edc47b0bf539da0fd7a8d5bc17155 Mon Sep 17 00:00:00 2001 From: inotia00 Date: Wed, 13 Sep 2023 12:43:31 +0900 Subject: [PATCH] feat(music): add `replace-dismiss-queue` patch --- .../replace/patch/ReplaceDismissQueuePatch.kt | 62 ++++++++++++++++++ .../patch/FlyoutButtonItemResourcePatch.kt | 29 ++++++++ .../yt_outline_youtube_logo_icon_black_24.png | Bin 0 -> 303 bytes .../yt_outline_youtube_logo_icon_black_24.png | Bin 0 -> 216 bytes .../yt_outline_youtube_logo_icon_black_24.png | Bin 0 -> 410 bytes .../yt_outline_youtube_logo_icon_black_24.png | Bin 0 -> 565 bytes .../yt_outline_youtube_logo_icon_black_24.png | Bin 0 -> 749 bytes .../music/settings/host/values/strings.xml | 3 + 8 files changed, 94 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/patch/ReplaceDismissQueuePatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/patch/FlyoutButtonItemResourcePatch.kt create mode 100644 src/main/resources/music/flyout/drawable-hdpi/yt_outline_youtube_logo_icon_black_24.png create mode 100644 src/main/resources/music/flyout/drawable-mdpi/yt_outline_youtube_logo_icon_black_24.png create mode 100644 src/main/resources/music/flyout/drawable-xhdpi/yt_outline_youtube_logo_icon_black_24.png create mode 100644 src/main/resources/music/flyout/drawable-xxhdpi/yt_outline_youtube_logo_icon_black_24.png create mode 100644 src/main/resources/music/flyout/drawable-xxxhdpi/yt_outline_youtube_logo_icon_black_24.png diff --git a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/patch/ReplaceDismissQueuePatch.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/patch/ReplaceDismissQueuePatch.kt new file mode 100644 index 000000000..c5457950f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/patch/ReplaceDismissQueuePatch.kt @@ -0,0 +1,62 @@ +package app.revanced.patches.music.flyoutpanel.replace.patch + +import app.revanced.extensions.exception +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.fingerprints.MenuItemFingerprint +import app.revanced.patches.music.flyoutpanel.utils.EnumUtils.getEnumIndex +import app.revanced.patches.music.utils.annotations.MusicCompatibility +import app.revanced.patches.music.utils.flyoutbutton.patch.FlyoutButtonItemResourcePatch +import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch +import app.revanced.patches.music.utils.videoid.patch.VideoIdPatch +import app.revanced.util.enum.CategoryType +import app.revanced.util.integrations.Constants.MUSIC_FLYOUT +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction + +@Patch +@Name("Replace dismiss queue") +@Description("Replace dismiss queue menu to watch on YouTube.") +@DependsOn( + [ + FlyoutButtonItemResourcePatch::class, + SettingsPatch::class, + VideoIdPatch::class + ] +) +@MusicCompatibility +class ReplaceDismissQueuePatch : BytecodePatch( + listOf(MenuItemFingerprint) +) { + override fun execute(context: BytecodeContext) { + MenuItemFingerprint.result?.let { + it.mutableMethod.apply { + val enumIndex = getEnumIndex() + val enumRegister = getInstruction(enumIndex).registerA + + val textViewIndex = it.scanResult.patternScanResult!!.startIndex + val imageViewIndex = it.scanResult.patternScanResult!!.endIndex + + val textViewRegister = getInstruction(textViewIndex).registerA + val imageViewRegister = getInstruction(imageViewIndex).registerA + + addInstruction( + enumIndex + 1, + "invoke-static {v$enumRegister, v$textViewRegister, v$imageViewRegister}, $MUSIC_FLYOUT->replaceDismissQueue(Ljava/lang/Enum;Landroid/widget/TextView;Landroid/widget/ImageView;)V" + ) + } + } ?: throw MenuItemFingerprint.exception + + SettingsPatch.addMusicPreference( + CategoryType.FLYOUT, + "revanced_replace_flyout_panel_dismiss_queue", + "false" + ) + + } +} diff --git a/src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/patch/FlyoutButtonItemResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/patch/FlyoutButtonItemResourcePatch.kt new file mode 100644 index 000000000..1d2b7b1e9 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/patch/FlyoutButtonItemResourcePatch.kt @@ -0,0 +1,29 @@ +package app.revanced.patches.music.utils.flyoutbutton.patch + +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.util.resources.ResourceUtils +import app.revanced.util.resources.ResourceUtils.copyResources + +class FlyoutButtonItemResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext) { + + fun copyResources(resourceGroups: List) { + resourceGroups.forEach { context.copyResources("music/flyout", it) } + } + + val resourceFileNames = arrayOf( + "yt_outline_youtube_logo_icon_black_24" + ).map { "$it.png" }.toTypedArray() + + fun createGroup(directory: String) = ResourceUtils.ResourceGroup( + directory, *resourceFileNames + ) + + arrayOf("xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi") + .map { "drawable-$it" } + .map(::createGroup) + .let(::copyResources) + + } +} \ No newline at end of file diff --git a/src/main/resources/music/flyout/drawable-hdpi/yt_outline_youtube_logo_icon_black_24.png b/src/main/resources/music/flyout/drawable-hdpi/yt_outline_youtube_logo_icon_black_24.png new file mode 100644 index 0000000000000000000000000000000000000000..e0ea1b51a45c50ea1620e2a2c4948d14ee41ba38 GIT binary patch literal 303 zcmV+~0nq-5P)6o#KPFbXRc5nL4f2eN22EUyWJ^~IH8GY`Ak4JPA$#rl>_mcixP#Opp_a!l?$ z?Y)Nw?z#88Flf+AHVa(V`1l0G9~I!^v%zJ7-G;D8DA7HtB*ChKE-22#Z1He$m@%#O zOqt=};;|*>jNa zc7l%NrcshMHfj_n=B=QV(lqYuTR<93Marb{e9zr9Dv}P6M)P3DxOSdU{Rkv>HL+of zJ-^t86k8For4@@2v0xL7+V}9^bcX-BJNyUzp`LmcpbK>#&uahx002ovPDHLkV1f(? Bg)aaA literal 0 HcmV?d00001 diff --git a/src/main/resources/music/flyout/drawable-mdpi/yt_outline_youtube_logo_icon_black_24.png b/src/main/resources/music/flyout/drawable-mdpi/yt_outline_youtube_logo_icon_black_24.png new file mode 100644 index 0000000000000000000000000000000000000000..e4b1253496fc530b8939d5e0ffd9f14bbcf5b1ab GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_+i`JOJ0Ar_~T6C@5E=t~qkT-Wy7 z;YZ^`d!auJV%7&X2&`ao{aM^*!&c5_%*M(VCej?ysFda~(`Eseif*ywCXQW-+$*^F z_>67{T}j{$VP)r+ObJw(EHT5-z< MUHx3vIVCg!0HmQt9{>OV literal 0 HcmV?d00001 diff --git a/src/main/resources/music/flyout/drawable-xhdpi/yt_outline_youtube_logo_icon_black_24.png b/src/main/resources/music/flyout/drawable-xhdpi/yt_outline_youtube_logo_icon_black_24.png new file mode 100644 index 0000000000000000000000000000000000000000..fd2d9b86e14f6786b4dd5aecb54ac9b3d0b85990 GIT binary patch literal 410 zcmV;L0cHM)P) zuWLe46vsa>bVEZCthXScV^@bMWjphKN} zc=8f~k?6Z8pmZ#Kkqu&nhf9|>4JwpzaB#>P-r2pSOoaw*y100(5F3hz1p>s73b zP(^qqJw+5k!rpi!9Z8^on40t);e><<@yY|&Cj}hD+@zO?%n1P@UbyEfR3L*`n)Dil zmf&MMc;+s|GmTiA^cInbC?LcWw?{k^i0v;3STB+FOSb+@t$#G@t-^Y`{M(^IsclV%Q9=!Y_h{HM*~hc1K^hY zr(4bdIN@l(E<0>ev&J%ACK!5;=&{cwd0;Ntr^h22ZHhi=i9Sw;qr*rsNK zRhC#}j?RFJ(keOw=2&EjRW_*E=73`^$X%Q_aZ*K}5U!}1q2i%bF+?J>)JwL-wwf<6+$0!83WY+UP$(1%g+ifFC`{%?mMHse&AJzjTBtt#M-;J)Ilpsty~|+HqY8*+a%8%YzwnOMJ>I>FSl zR2ev9RTE}vj;TkfGH}GIa`rubD^&)z>_^5;rWRtB`q2~v1y;3brtUB`AG4I#d%in2 zkY`mpX6m8++g8Vb7svSG)IiuX56#qLrcNg^5EL78W?(vcFh-m+bv&_w7d+82<+Bq5 zMwu+g0!_+=U2E6!-b$m)>ppP@%*nhNp92y8pui#^X zJt^x6PPi@A?bv`9SNMewv9fkYTVqCq%jnJ~81Ui}GcmGuMm@@iXQpPFWFT1Gerqsm zhFd=W2L{ByLgG8I_+eE1hfMrbLi}V-{B&CUf=2w3Qv9M`{I-htjV`l00000NkvXXu0mjfPxe%( literal 0 HcmV?d00001 diff --git a/src/main/resources/music/settings/host/values/strings.xml b/src/main/resources/music/settings/host/values/strings.xml index 916b90bc7..e00dea332 100644 --- a/src/main/resources/music/settings/host/values/strings.xml +++ b/src/main/resources/music/settings/host/values/strings.xml @@ -49,6 +49,7 @@ %s is not installed. Please install it. Package name of your installed external downloader app, such as NewPipe or Seal External downloader package name + Watch on YouTube Hide labels in button container. Hide button container labels Hides start radio button. @@ -94,6 +95,8 @@ Restart to load the layout normally Refresh and restart Reset + Replaces dismiss queue menu to watch on YouTube. + Replace dismiss queue About Data is provided by the Return YouTube Dislike API. Tap here to learn more. ReturnYouTubeDislike.com