feat(music): add replace-dismiss-queue patch

This commit is contained in:
inotia00 2023-09-13 12:43:31 +09:00
parent a93365acb3
commit d2cf10b01d
8 changed files with 94 additions and 0 deletions

View File

@ -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<OneRegisterInstruction>(enumIndex).registerA
val textViewIndex = it.scanResult.patternScanResult!!.startIndex
val imageViewIndex = it.scanResult.patternScanResult!!.endIndex
val textViewRegister = getInstruction<OneRegisterInstruction>(textViewIndex).registerA
val imageViewRegister = getInstruction<OneRegisterInstruction>(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"
)
}
}

View File

@ -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<ResourceUtils.ResourceGroup>) {
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)
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

View File

@ -49,6 +49,7 @@
<string name="revanced_external_downloader_not_installed_warning" formatted="false">%s is not installed. Please install it.</string>
<string name="revanced_external_downloader_package_name_summary">Package name of your installed external downloader app, such as NewPipe or Seal</string>
<string name="revanced_external_downloader_package_name_title">External downloader package name</string>
<string name="revanced_flyout_panel_watch_on_youtube">Watch on YouTube</string>
<string name="revanced_hide_button_container_label_summary">Hide labels in button container.</string>
<string name="revanced_hide_button_container_label_title">Hide button container labels</string>
<string name="revanced_hide_button_container_radio_summary">Hides start radio button.</string>
@ -94,6 +95,8 @@
<string name="revanced_reboot_first_run">Restart to load the layout normally</string>
<string name="revanced_reboot_message">Refresh and restart</string>
<string name="revanced_reset">Reset</string>
<string name="revanced_replace_flyout_panel_dismiss_queue_summary">Replaces dismiss queue menu to watch on YouTube.</string>
<string name="revanced_replace_flyout_panel_dismiss_queue_title">Replace dismiss queue</string>
<string name="revanced_ryd_about">About</string>
<string name="revanced_ryd_attribution_summary">Data is provided by the Return YouTube Dislike API. Tap here to learn more.</string>
<string name="revanced_ryd_attribution_title">ReturnYouTubeDislike.com</string>