mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
feat(YouTube Music): add Hide fullscreen share button
patch
This commit is contained in:
@ -0,0 +1,51 @@
|
||||
package app.revanced.patches.music.player.share
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
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.player.share.fingerprints.RemixGenericButtonFingerprint
|
||||
import app.revanced.patches.music.utils.integrations.Constants.PLAYER
|
||||
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 com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Patch(
|
||||
name = "Hide fullscreen share button",
|
||||
description = "Adds an option to hide the share button in the fullscreen player.",
|
||||
dependencies = [
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
],
|
||||
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object ShareButtonPatch : BytecodePatch(
|
||||
setOf(RemixGenericButtonFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
RemixGenericButtonFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
targetIndex + 1, """
|
||||
invoke-static {v$targetRegister}, $PLAYER->hideFullscreenShareButton(I)I
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw RemixGenericButtonFingerprint.exception
|
||||
|
||||
SettingsPatch.addMusicPreference(
|
||||
CategoryType.PLAYER,
|
||||
"revanced_hide_fullscreen_share_button",
|
||||
"false"
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package app.revanced.patches.music.player.share.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.RemixGenericButtonSize
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object RemixGenericButtonFingerprint : LiteralValueFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
opcodes = listOf(
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.FLOAT_TO_INT
|
||||
),
|
||||
literalSupplier = { RemixGenericButtonSize }
|
||||
)
|
@ -36,6 +36,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var PlayerOverlayChip: Long = -1
|
||||
var PrivacyTosFooter: Long = -1
|
||||
var QualityAuto: Long = -1
|
||||
var RemixGenericButtonSize: Long = -1
|
||||
var Text1: Long = -1
|
||||
var ToolTipContentView: Long = -1
|
||||
var TosFooter: Long = -1
|
||||
@ -68,6 +69,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
PlayerOverlayChip = find(ID, "player_overlay_chip")
|
||||
PrivacyTosFooter = find(ID, "privacy_tos_footer")
|
||||
QualityAuto = find(STRING, "quality_auto")
|
||||
RemixGenericButtonSize = find(DIMEN, "remix_generic_button_size")
|
||||
Text1 = find(ID, "text1")
|
||||
ToolTipContentView = find(LAYOUT, "tooltip_content_view")
|
||||
TosFooter = find(ID, "tos_footer")
|
||||
|
Reference in New Issue
Block a user