mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-03 21:42:55 +01:00
fix(YouTube - Enable tablet layout): Respect the original device layout
This commit is contained in:
parent
da81a19d74
commit
b2c5babf3f
@ -2,8 +2,11 @@ package app.revanced.patches.youtube.layout.tablet
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
@ -13,6 +16,8 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.layout.tablet.fingerprints.GetFormFactorFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction10x
|
||||
|
||||
@Patch(
|
||||
name = "Enable tablet layout",
|
||||
@ -37,18 +42,28 @@ object EnableTabletLayoutPatch : BytecodePatch(
|
||||
|
||||
GetFormFactorFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val returnLargeFormFactorIndex = it.scanResult.patternScanResult!!.endIndex - 4
|
||||
val returnCurrentFormFactorIndex = getInstructions().lastIndex - 2
|
||||
|
||||
val returnIsLargeFormFactorLabel = getInstruction(returnCurrentFormFactorIndex - 2)
|
||||
val returnFormFactorIndex = getInstruction(returnCurrentFormFactorIndex)
|
||||
|
||||
val insertIndex = returnCurrentFormFactorIndex + 1
|
||||
|
||||
// Replace the labeled instruction with a nop and add the preserved instructions back
|
||||
replaceInstruction(returnCurrentFormFactorIndex, BuilderInstruction10x(Opcode.NOP))
|
||||
addInstruction(insertIndex, returnFormFactorIndex)
|
||||
|
||||
// Because the labeled instruction is now a nop, we can add our own instructions right after it
|
||||
addInstructionsWithLabels(
|
||||
0,
|
||||
insertIndex,
|
||||
"""
|
||||
invoke-static {}, Lapp/revanced/integrations/patches/EnableTabletLayoutPatch;->enableTabletLayout()Z
|
||||
move-result v0
|
||||
invoke-static { }, Lapp/revanced/integrations/patches/EnableTabletLayoutPatch;->enableTabletLayout()Z
|
||||
move-result v0 # Free register
|
||||
if-nez v0, :is_large_form_factor
|
||||
""",
|
||||
ExternalLabel(
|
||||
"is_large_form_factor",
|
||||
getInstruction(returnLargeFormFactorIndex)
|
||||
returnIsLargeFormFactorLabel
|
||||
)
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user