mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
feat(YouTube/Quick actions components): add Quick actions top margin
settings
This commit is contained in:
@ -45,6 +45,8 @@ object QuickActionsPatch : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
LithoFilterPatch.addFilter("$COMPONENTS_PATH/QuickActionFilter;")
|
||||
|
||||
QuickActionsHookPatch.injectQuickActionMargin()
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
|
@ -6,6 +6,7 @@ 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.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.utils.quickactions.fingerprints.QuickActionsElementFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.QuickActionsElementContainer
|
||||
@ -18,24 +19,39 @@ import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
object QuickActionsHookPatch : BytecodePatch(
|
||||
setOf(QuickActionsElementFingerprint)
|
||||
) {
|
||||
private lateinit var insertMethod: MutableMethod
|
||||
private var insertIndex: Int = 0
|
||||
private var insertRegister: Int = 0
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
QuickActionsElementFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
insertMethod = this
|
||||
for (index in implementation!!.instructions.size - 1 downTo 0) {
|
||||
if (getInstruction(index).opcode == Opcode.CONST && (getInstruction(index) as WideLiteralInstruction).wideLiteral == QuickActionsElementContainer) {
|
||||
val targetRegister =
|
||||
insertIndex = index + 3
|
||||
insertRegister =
|
||||
getInstruction<OneRegisterInstruction>(index + 2).registerA
|
||||
|
||||
addInstruction(
|
||||
index + 3,
|
||||
"invoke-static {v$targetRegister}, $FULLSCREEN->hideQuickActions(Landroid/view/View;)V"
|
||||
insertIndex,
|
||||
"invoke-static {v$insertRegister}, $FULLSCREEN->hideQuickActions(Landroid/view/View;)V"
|
||||
)
|
||||
insertIndex += 2
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} ?: throw QuickActionsElementFingerprint.exception
|
||||
}
|
||||
|
||||
internal fun injectQuickActionMargin() {
|
||||
insertMethod.apply {
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static {v$insertRegister}, $FULLSCREEN->setQuickActionMargin(Landroid/widget/FrameLayout;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user