mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-04 16:44:29 +02:00
feat(YouTube Music): add Replace report
patch
This commit is contained in:
parent
b593fa302f
commit
d6a01c6648
@ -0,0 +1,80 @@
|
|||||||
|
package app.revanced.patches.music.flyoutpanel.replace
|
||||||
|
|
||||||
|
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.annotation.CompatiblePackage
|
||||||
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patches.music.flyoutpanel.replace.fingerprints.TouchOutsideFingerprint
|
||||||
|
import app.revanced.patches.music.flyoutpanel.shared.FlyoutPanelMenuItemPatch
|
||||||
|
import app.revanced.patches.music.utils.integrations.Constants.FLYOUT
|
||||||
|
import app.revanced.patches.music.utils.overridespeed.OverrideSpeedHookPatch
|
||||||
|
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
||||||
|
import app.revanced.patches.music.utils.settings.CategoryType
|
||||||
|
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||||
|
import app.revanced.util.exception
|
||||||
|
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
|
||||||
|
@Patch(
|
||||||
|
name = "Replace report",
|
||||||
|
description = "Adds an option to replace \"Report\" with \"Playback speed\" in the flyout menu.",
|
||||||
|
dependencies = [
|
||||||
|
FlyoutPanelMenuItemPatch::class,
|
||||||
|
OverrideSpeedHookPatch::class,
|
||||||
|
ReplaceReportResourcePatch::class,
|
||||||
|
SettingsPatch::class,
|
||||||
|
SharedResourceIdPatch::class
|
||||||
|
],
|
||||||
|
compatiblePackages = [
|
||||||
|
CompatiblePackage(
|
||||||
|
"com.google.android.apps.youtube.music",
|
||||||
|
[
|
||||||
|
"6.21.52",
|
||||||
|
"6.22.52",
|
||||||
|
"6.23.56",
|
||||||
|
"6.25.53",
|
||||||
|
"6.26.51",
|
||||||
|
"6.27.54",
|
||||||
|
"6.28.53",
|
||||||
|
"6.29.58",
|
||||||
|
"6.31.55",
|
||||||
|
"6.33.52"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@Suppress("unused")
|
||||||
|
object ReplaceReportPatch : BytecodePatch(
|
||||||
|
setOf(TouchOutsideFingerprint)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext) {
|
||||||
|
FlyoutPanelMenuItemPatch.replaceComponents()
|
||||||
|
|
||||||
|
TouchOutsideFingerprint.result?.let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val setOnClickListenerIndex = getTargetIndexWithMethodReferenceName("setOnClickListener")
|
||||||
|
val setOnClickListenerRegister = getInstruction<FiveRegisterInstruction>(setOnClickListenerIndex).registerC
|
||||||
|
|
||||||
|
addInstruction(
|
||||||
|
setOnClickListenerIndex + 1,
|
||||||
|
"sput-object v$setOnClickListenerRegister, $FLYOUT->touchOutSideView:Landroid/view/View;"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: throw TouchOutsideFingerprint.exception
|
||||||
|
|
||||||
|
SettingsPatch.addMusicPreference(
|
||||||
|
CategoryType.FLYOUT,
|
||||||
|
"revanced_replace_flyout_panel_report",
|
||||||
|
"true"
|
||||||
|
)
|
||||||
|
SettingsPatch.addMusicPreference(
|
||||||
|
CategoryType.FLYOUT,
|
||||||
|
"revanced_replace_flyout_panel_report_only_player",
|
||||||
|
"true",
|
||||||
|
"revanced_replace_flyout_panel_report"
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package app.revanced.patches.music.flyoutpanel.replace
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.ResourceContext
|
||||||
|
import app.revanced.patcher.patch.ResourcePatch
|
||||||
|
import app.revanced.util.ResourceGroup
|
||||||
|
import app.revanced.util.copyResources
|
||||||
|
|
||||||
|
object ReplaceReportResourcePatch : ResourcePatch() {
|
||||||
|
override fun execute(context: ResourceContext) {
|
||||||
|
|
||||||
|
fun copyResources(resourceGroups: List<ResourceGroup>) {
|
||||||
|
resourceGroups.forEach { context.copyResources("music/flyout", it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
val resourceFileNames = arrayOf(
|
||||||
|
"yt_outline_play_arrow_half_circle_black_24"
|
||||||
|
).map { "$it.png" }.toTypedArray()
|
||||||
|
|
||||||
|
fun createGroup(directory: String) = ResourceGroup(
|
||||||
|
directory, *resourceFileNames
|
||||||
|
)
|
||||||
|
|
||||||
|
arrayOf("xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi")
|
||||||
|
.map { "drawable-$it" }
|
||||||
|
.map(::createGroup)
|
||||||
|
.let(::copyResources)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -195,6 +195,10 @@ This does not bypass the age restriction. It just accepts it automatically."</st
|
|||||||
<string name="revanced_replace_flyout_panel_dismiss_queue_continue_watch_title">Continue watching</string>
|
<string name="revanced_replace_flyout_panel_dismiss_queue_continue_watch_title">Continue watching</string>
|
||||||
<string name="revanced_replace_flyout_panel_dismiss_queue_summary">Replaces \"Dismiss queue\" with \"Watch on YouTube\".</string>
|
<string name="revanced_replace_flyout_panel_dismiss_queue_summary">Replaces \"Dismiss queue\" with \"Watch on YouTube\".</string>
|
||||||
<string name="revanced_replace_flyout_panel_dismiss_queue_title">Replace dismiss queue</string>
|
<string name="revanced_replace_flyout_panel_dismiss_queue_title">Replace dismiss queue</string>
|
||||||
|
<string name="revanced_replace_flyout_panel_report_only_player_summary">Report menu in comments will not be replaced.</string>
|
||||||
|
<string name="revanced_replace_flyout_panel_report_only_player_title">Applies only to player flyout menu</string>
|
||||||
|
<string name="revanced_replace_flyout_panel_report_summary">Replaces \"Report\" with \"Playback speed\".</string>
|
||||||
|
<string name="revanced_replace_flyout_panel_report_title">Replace report</string>
|
||||||
<string name="revanced_replace_player_cast_button_summary">"Replace the cast button in the player with the "Open music" button. (Experimental)
|
<string name="revanced_replace_player_cast_button_summary">"Replace the cast button in the player with the "Open music" button. (Experimental)
|
||||||
Known issue: If one or more music that cannot be played in the playlist, it does not work normally."</string>
|
Known issue: If one or more music that cannot be played in the playlist, it does not work normally."</string>
|
||||||
<string name="revanced_replace_player_cast_button_title">Replace cast button</string>
|
<string name="revanced_replace_player_cast_button_title">Replace cast button</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user