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 000000000..e0ea1b51a Binary files /dev/null and b/src/main/resources/music/flyout/drawable-hdpi/yt_outline_youtube_logo_icon_black_24.png differ 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 000000000..e4b125349 Binary files /dev/null and b/src/main/resources/music/flyout/drawable-mdpi/yt_outline_youtube_logo_icon_black_24.png differ 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 000000000..fd2d9b86e Binary files /dev/null and b/src/main/resources/music/flyout/drawable-xhdpi/yt_outline_youtube_logo_icon_black_24.png differ diff --git a/src/main/resources/music/flyout/drawable-xxhdpi/yt_outline_youtube_logo_icon_black_24.png b/src/main/resources/music/flyout/drawable-xxhdpi/yt_outline_youtube_logo_icon_black_24.png new file mode 100644 index 000000000..525a20395 Binary files /dev/null and b/src/main/resources/music/flyout/drawable-xxhdpi/yt_outline_youtube_logo_icon_black_24.png differ diff --git a/src/main/resources/music/flyout/drawable-xxxhdpi/yt_outline_youtube_logo_icon_black_24.png b/src/main/resources/music/flyout/drawable-xxxhdpi/yt_outline_youtube_logo_icon_black_24.png new file mode 100644 index 000000000..080c5b490 Binary files /dev/null and b/src/main/resources/music/flyout/drawable-xxxhdpi/yt_outline_youtube_logo_icon_black_24.png differ 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