feat(YouTube Music): add Disable overlay filter patch

This commit is contained in:
inotia00
2024-01-03 20:41:15 +09:00
parent 3b1bad3bab
commit 9f7bf79465
4 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,43 @@
package app.revanced.patches.music.layout.overlayfilter
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.Patch
import app.revanced.patches.music.layout.overlayfilter.fingerprints.DesignBottomSheetDialogFingerprint
import app.revanced.patches.music.utils.integrations.Constants.GENERAL
import app.revanced.patches.music.utils.integrations.IntegrationsPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.util.exception
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Patch(
dependencies = [
IntegrationsPatch::class,
SharedResourceIdPatch::class
],
requiresIntegrations = true
)
object OverlayFilterBytecodePatch : BytecodePatch(
setOf(DesignBottomSheetDialogFingerprint)
) {
override fun execute(context: BytecodeContext) {
DesignBottomSheetDialogFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1
val freeRegister = getInstruction<OneRegisterInstruction>(insertIndex + 1).registerA
addInstructions(
insertIndex, """
invoke-virtual {p0}, $definingClass->getWindow()Landroid/view/Window;
move-result-object v$freeRegister
invoke-static {v$freeRegister}, $GENERAL->disableDimBehind(Landroid/view/Window;)V
"""
)
}
} ?: throw DesignBottomSheetDialogFingerprint.exception
}
}

View File

@ -0,0 +1,29 @@
package app.revanced.patches.music.layout.overlayfilter
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
@Patch(
name = "Disable overlay filter",
description = "Disables dark overlay when comment, share, save to playlist, and flyout panels open.",
dependencies = [OverlayFilterBytecodePatch::class],
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")],
use = false
)
@Suppress("unused")
object OverlayFilterPatch : ResourcePatch() {
override fun execute(context: ResourceContext) {
val styleFile = context["res/values/styles.xml"]
styleFile.writeText(
styleFile.readText()
.replace(
"ytOverlayBackgroundMedium\">@color/yt_black_pure_opacity60",
"ytOverlayBackgroundMedium\">@android:color/transparent"
)
)
}
}

View File

@ -0,0 +1,17 @@
package app.revanced.patches.music.layout.overlayfilter.fingerprints
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.DesignBottomSheetDialog
import app.revanced.util.fingerprint.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.Opcode
object DesignBottomSheetDialogFingerprint : LiteralValueFingerprint(
returnType = "V",
parameters = emptyList(),
opcodes = listOf(
Opcode.IF_NEZ,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
literalSupplier = { DesignBottomSheetDialog }
)

View File

@ -20,6 +20,7 @@ object SharedResourceIdPatch : ResourcePatch() {
var ButtonIconPaddingMedium: Long = -1
var ChipCloud: Long = -1
var ColorGrey: Long = -1
var DesignBottomSheetDialog: Long = -1
var DialogSolid: Long = -1
var FloatingLayout: Long = -1
var HistoryMenuItem: Long = -1
@ -50,6 +51,7 @@ object SharedResourceIdPatch : ResourcePatch() {
ButtonIconPaddingMedium = find(DIMEN, "button_icon_padding_medium")
ChipCloud = find(LAYOUT, "chip_cloud")
ColorGrey = find(COLOR, "ytm_color_grey_12")
DesignBottomSheetDialog = find(LAYOUT, "design_bottom_sheet_dialog")
DialogSolid = find(STYLE, "Theme.YouTubeMusic.Dialog.Solid")
FloatingLayout = find(ID, "floating_layout")
HistoryMenuItem = find(ID, "history_menu_item")