feat(YouTube/Quick actions components): add Quick actions top margin settings

This commit is contained in:
inotia00
2023-10-27 13:00:46 +09:00
parent 73c8ad6ea4
commit b021ab9019
4 changed files with 26 additions and 4 deletions

View File

@ -45,6 +45,8 @@ object QuickActionsPatch : BytecodePatch() {
override fun execute(context: BytecodeContext) {
LithoFilterPatch.addFilter("$COMPONENTS_PATH/QuickActionFilter;")
QuickActionsHookPatch.injectQuickActionMargin()
/**
* Add settings
*/

View File

@ -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"
)
}
}
}