diff --git a/src/main/kotlin/app/revanced/patches/music/actionbar/component/ActionBarComponentPatch.kt b/src/main/kotlin/app/revanced/patches/music/actionbar/component/ActionBarComponentPatch.kt index f6a0725bf..908caf265 100644 --- a/src/main/kotlin/app/revanced/patches/music/actionbar/component/ActionBarComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/actionbar/component/ActionBarComponentPatch.kt @@ -10,12 +10,16 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.music.actionbar.component.fingerprints.ActionBarComponentFingerprint +import app.revanced.patches.music.actionbar.component.fingerprints.LikeDislikeContainerFingerprint import app.revanced.patches.music.utils.integrations.Constants.ACTIONBAR import app.revanced.patches.music.utils.intenthook.IntentHookPatch +import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch +import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.LikeDislikeContainer import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.video.information.VideoInformationPatch import app.revanced.util.exception +import app.revanced.util.getWideLiteralInstructionIndex import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @@ -30,13 +34,17 @@ import kotlin.math.min dependencies = [ IntentHookPatch::class, SettingsPatch::class, + SharedResourceIdPatch::class, VideoInformationPatch::class ], compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")] ) @Suppress("unused") object ActionBarComponentPatch : BytecodePatch( - setOf(ActionBarComponentFingerprint) + setOf( + ActionBarComponentFingerprint, + LikeDislikeContainerFingerprint + ) ) { private var spannedReference = "" @@ -124,6 +132,18 @@ object ActionBarComponentPatch : BytecodePatch( } } ?: throw ActionBarComponentFingerprint.exception + LikeDislikeContainerFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = getWideLiteralInstructionIndex(LikeDislikeContainer) + 2 + val insertRegister = getInstruction(insertIndex).registerA + + addInstruction( + insertIndex + 1, + "invoke-static {v$insertRegister}, $ACTIONBAR->hideLikeDislikeButton(Landroid/view/View;)V" + ) + } + } ?: throw LikeDislikeContainerFingerprint.exception + SettingsPatch.addMusicPreference( CategoryType.ACTION_BAR, "revanced_hide_action_button_add_to_playlist", @@ -144,6 +164,11 @@ object ActionBarComponentPatch : BytecodePatch( "revanced_hide_action_button_label", "false" ) + SettingsPatch.addMusicPreference( + CategoryType.ACTION_BAR, + "revanced_hide_action_button_like_dislike", + "false" + ) SettingsPatch.addMusicPreference( CategoryType.ACTION_BAR, "revanced_hide_action_button_radio", diff --git a/src/main/kotlin/app/revanced/patches/music/actionbar/component/fingerprints/LikeDislikeContainerFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/actionbar/component/fingerprints/LikeDislikeContainerFingerprint.kt new file mode 100644 index 000000000..df1542262 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/actionbar/component/fingerprints/LikeDislikeContainerFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.music.actionbar.component.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.LikeDislikeContainer +import app.revanced.util.fingerprint.LiteralValueFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +object LikeDislikeContainerFingerprint : LiteralValueFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + literalSupplier = { LikeDislikeContainer } +) diff --git a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt index 1adf8a3e4..a436f29b6 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt @@ -27,6 +27,7 @@ object SharedResourceIdPatch : ResourcePatch() { var InlineTimeBarAdBreakMarkerColor: Long = -1 var InterstitialsContainer: Long = -1 var IsTablet: Long = -1 + var LikeDislikeContainer: Long = -1 var MenuEntry: Long = -1 var MusicMenuLikeButtons: Long = -1 var MusicNotifierShelf: Long = -1 @@ -58,6 +59,7 @@ object SharedResourceIdPatch : ResourcePatch() { InlineTimeBarAdBreakMarkerColor = find(COLOR, "inline_time_bar_ad_break_marker_color") InterstitialsContainer = find(ID, "interstitials_container") IsTablet = find(BOOL, "is_tablet") + LikeDislikeContainer = find(ID, "like_dislike_container") MenuEntry = find(LAYOUT, "menu_entry") MusicMenuLikeButtons = find(LAYOUT, "music_menu_like_buttons") MusicNotifierShelf = find(LAYOUT, "music_notifier_shelf") diff --git a/src/main/resources/music/settings/host/values/strings.xml b/src/main/resources/music/settings/host/values/strings.xml index 9b5c23b88..0f900ac03 100644 --- a/src/main/resources/music/settings/host/values/strings.xml +++ b/src/main/resources/music/settings/host/values/strings.xml @@ -101,6 +101,8 @@ WARNING: Do not enable "New player background" while this is enabled." Hide download button Hides labels in action buttons. Hide action button labels + Hides the like and dislike buttons. It does not work in the old player layout. + Hide like and dislike buttons Hides start radio button. Hide radio button Hides share button.