mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-04 16:44:29 +02:00
fix(YouTube/Enable wide search bar): layout breaks on devices above 720 dpi
This commit is contained in:
parent
7dc0108859
commit
6f9a1cb1fe
@ -10,7 +10,6 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
|||||||
import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetActionBarRingoFingerprint
|
import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetActionBarRingoFingerprint
|
||||||
import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetWordMarkHeaderFingerprint
|
import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetWordMarkHeaderFingerprint
|
||||||
import app.revanced.patches.youtube.general.widesearchbar.fingerprints.YouActionBarFingerprint
|
import app.revanced.patches.youtube.general.widesearchbar.fingerprints.YouActionBarFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.LayoutSwitchFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL
|
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
@ -55,11 +54,13 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object WideSearchBarPatch : BytecodePatch(
|
object WideSearchBarPatch : BytecodePatch(
|
||||||
setOf(
|
setOf(
|
||||||
LayoutSwitchFingerprint,
|
|
||||||
SetActionBarRingoFingerprint,
|
SetActionBarRingoFingerprint,
|
||||||
SetWordMarkHeaderFingerprint
|
SetWordMarkHeaderFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
private const val FLAG = "android:paddingStart"
|
||||||
|
private const val TARGET_RESOURCE_PATH = "res/layout/action_bar_ringo_background.xml"
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
// resolves fingerprints
|
// resolves fingerprints
|
||||||
@ -74,22 +75,19 @@ object WideSearchBarPatch : BytecodePatch(
|
|||||||
.nextMethod(1, true)
|
.nextMethod(1, true)
|
||||||
.getMethod() as MutableMethod
|
.getMethod() as MutableMethod
|
||||||
|
|
||||||
targetMethod.injectSearchBarHook()
|
targetMethod.apply {
|
||||||
|
injectSearchBarHook(
|
||||||
|
implementation!!.instructions.size - 1,
|
||||||
|
"enableWideSearchBar"
|
||||||
|
)
|
||||||
|
}
|
||||||
} ?: throw SetWordMarkHeaderFingerprint.exception
|
} ?: throw SetWordMarkHeaderFingerprint.exception
|
||||||
|
|
||||||
LayoutSwitchFingerprint.result?.mutableMethod?.injectSearchBarHook()
|
|
||||||
?: throw LayoutSwitchFingerprint.exception
|
|
||||||
|
|
||||||
YouActionBarFingerprint.result?.let {
|
YouActionBarFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
injectSearchBarHook(
|
||||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
it.scanResult.patternScanResult!!.endIndex,
|
||||||
|
"enableWideSearchBarInYouTab"
|
||||||
addInstructions(
|
|
||||||
insertIndex, """
|
|
||||||
invoke-static {v$insertRegister}, $GENERAL->enableWideSearchBarInYouTab(Z)Z
|
|
||||||
move-result v$insertRegister
|
|
||||||
"""
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: throw YouActionBarFingerprint.exception
|
} ?: throw YouActionBarFingerprint.exception
|
||||||
@ -123,17 +121,19 @@ object WideSearchBarPatch : BytecodePatch(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val FLAG = "android:paddingStart"
|
|
||||||
private const val TARGET_RESOURCE_PATH = "res/layout/action_bar_ringo_background.xml"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects instructions required for certain methods.
|
* Injects instructions required for certain methods.
|
||||||
*/
|
*/
|
||||||
private fun MutableMethod.injectSearchBarHook() {
|
private fun MutableMethod.injectSearchBarHook(
|
||||||
|
insertIndex: Int,
|
||||||
|
descriptor: String
|
||||||
|
) {
|
||||||
|
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
implementation!!.instructions.size - 1, """
|
insertIndex, """
|
||||||
invoke-static {}, $GENERAL->enableWideSearchBar()Z
|
invoke-static {v$insertRegister}, $GENERAL->$descriptor(Z)Z
|
||||||
move-result p0
|
move-result v$insertRegister
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user