mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-28 21:00:19 +02:00
refactor(hide-upgrade-button): hide upgrade banner from homepage
This commit is contained in:
parent
6e667c8173
commit
49756a2083
@ -0,0 +1,26 @@
|
|||||||
|
package app.revanced.patches.music.layout.upgradebutton.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch
|
||||||
|
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object NotifierShelfFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.CONST,
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.INVOKE_STATIC,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT
|
||||||
|
),
|
||||||
|
customFingerprint = { methodDef ->
|
||||||
|
methodDef.implementation?.instructions?.any {
|
||||||
|
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||||
|
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.notifierShelfLabelId
|
||||||
|
} == true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
@ -5,27 +5,41 @@ import app.revanced.patcher.annotation.Description
|
|||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.instruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patcher.util.smali.toInstructions
|
import app.revanced.patcher.util.smali.toInstructions
|
||||||
import app.revanced.patches.music.layout.upgradebutton.fingerprints.PivotBarConstructorFingerprint
|
import app.revanced.patches.music.layout.upgradebutton.fingerprints.*
|
||||||
|
import app.revanced.patches.music.misc.integrations.patch.MusicIntegrationsPatch
|
||||||
|
import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch
|
||||||
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
|
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
|
||||||
|
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction22t
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction22t
|
||||||
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22c
|
import org.jf.dexlib2.iface.instruction.formats.Instruction22c
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("hide-upgrade-button")
|
@Name("hide-upgrade-button")
|
||||||
@Description("Removes the upgrade tab from the pivot bar.")
|
@Description("Remove upgrade tab from pivot bar, hide upgrade banner from homepage.")
|
||||||
|
@DependsOn(
|
||||||
|
[
|
||||||
|
MusicIntegrationsPatch::class,
|
||||||
|
SharedResourceIdPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
@YouTubeMusicCompatibility
|
@YouTubeMusicCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class RemoveUpgradeButtonPatch : BytecodePatch(
|
class RemoveUpgradeButtonPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
PivotBarConstructorFingerprint
|
PivotBarConstructorFingerprint,
|
||||||
|
NotifierShelfFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
@ -73,6 +87,18 @@ class RemoveUpgradeButtonPatch : BytecodePatch(
|
|||||||
implementation.addInstructions(
|
implementation.addInstructions(
|
||||||
endIndex, instructionList
|
endIndex, instructionList
|
||||||
)
|
)
|
||||||
|
|
||||||
|
NotifierShelfFingerprint.result?.let {
|
||||||
|
with (it.mutableMethod) {
|
||||||
|
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
|
val targetRegister = (instruction(targetIndex) as OneRegisterInstruction).registerA
|
||||||
|
addInstruction(
|
||||||
|
targetIndex + 1,
|
||||||
|
"invoke-static {v$targetRegister}, $INTEGRATIONS_PATH/adremover/AdRemoverAPI;->HideViewWithLayout1dp(Landroid/view/View;)V"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: return NotifierShelfFingerprint.toErrorResult()
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
var dialogSolidLabelId: Long = -1
|
var dialogSolidLabelId: Long = -1
|
||||||
var disabledIconLabelId: Long = -1
|
var disabledIconLabelId: Long = -1
|
||||||
var isTabletLabelId: Long = -1
|
var isTabletLabelId: Long = -1
|
||||||
|
var notifierShelfLabelId: Long = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun execute(context: ResourceContext): PatchResult {
|
override fun execute(context: ResourceContext): PatchResult {
|
||||||
@ -34,6 +35,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
dialogSolidLabelId = find(STYLE, "Theme.YouTubeMusic.Dialog.Solid")
|
dialogSolidLabelId = find(STYLE, "Theme.YouTubeMusic.Dialog.Solid")
|
||||||
disabledIconLabelId = find(DIMEN, "disabled_icon_alpha")
|
disabledIconLabelId = find(DIMEN, "disabled_icon_alpha")
|
||||||
isTabletLabelId = find(BOOL, "is_tablet")
|
isTabletLabelId = find(BOOL, "is_tablet")
|
||||||
|
notifierShelfLabelId = find(LAYOUT, "music_notifier_shelf")
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user