mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-06 09:34:37 +02:00
fix(YouTube): Enable wide search bar
and Hide search term thumbnail
patches are not compatible with some versions
This commit is contained in:
parent
fa3acf8ffd
commit
78da7f9ccd
@ -11,7 +11,7 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.utils.fingerprints.CreateSearchSuggestionsFingerprint
|
||||
import app.revanced.patches.youtube.general.searchterm.fingerprints.CreateSearchSuggestionsFingerprint
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.GENERAL
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
@ -1,18 +1,12 @@
|
||||
package app.revanced.patches.youtube.utils.fingerprints
|
||||
package app.revanced.patches.youtube.general.searchterm.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object CreateSearchSuggestionsFingerprint : MethodFingerprint(
|
||||
returnType = "Landroid/view/View;",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("I", "Landroid/view/View;", "Landroid/view/ViewGroup;"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.CONST_4
|
||||
),
|
||||
strings = listOf("ss_rds")
|
||||
)
|
@ -4,7 +4,6 @@ import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
@ -12,7 +11,7 @@ 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.SetWordMarkHeaderFingerprint
|
||||
import app.revanced.patches.youtube.general.widesearchbar.fingerprints.YouActionBarFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.CreateSearchSuggestionsFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.LayoutSwitchFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts
|
||||
@ -57,33 +56,32 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@Suppress("unused")
|
||||
object WideSearchBarPatch : BytecodePatch(
|
||||
setOf(
|
||||
CreateSearchSuggestionsFingerprint,
|
||||
LayoutSwitchFingerprint,
|
||||
SetActionBarRingoFingerprint,
|
||||
SetWordMarkHeaderFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
val result = CreateSearchSuggestionsFingerprint.result
|
||||
?: throw CreateSearchSuggestionsFingerprint.exception
|
||||
|
||||
// resolves fingerprints
|
||||
val parentClassDef = SetActionBarRingoFingerprint.result?.classDef
|
||||
?: throw CreateSearchSuggestionsFingerprint.exception
|
||||
?: throw SetActionBarRingoFingerprint.exception
|
||||
YouActionBarFingerprint.resolve(context, parentClassDef)
|
||||
|
||||
// patch methods
|
||||
mapOf(
|
||||
SetWordMarkHeaderFingerprint to 1,
|
||||
CreateSearchSuggestionsFingerprint to result.scanResult.patternScanResult!!.startIndex
|
||||
).forEach { (fingerprint, callIndex) ->
|
||||
context.walkMutable(callIndex, fingerprint).injectSearchBarHook()
|
||||
}
|
||||
SetWordMarkHeaderFingerprint.result?.let {
|
||||
val targetMethod =
|
||||
context.toMethodWalker(it.method)
|
||||
.nextMethod(1, true)
|
||||
.getMethod() as MutableMethod
|
||||
|
||||
YouActionBarFingerprint.also {
|
||||
it.resolve(
|
||||
context,
|
||||
parentClassDef
|
||||
)
|
||||
}.result?.let {
|
||||
targetMethod.injectSearchBarHook()
|
||||
} ?: throw SetWordMarkHeaderFingerprint.exception
|
||||
|
||||
LayoutSwitchFingerprint.result?.mutableMethod?.injectSearchBarHook()
|
||||
?: throw LayoutSwitchFingerprint.exception
|
||||
|
||||
YouActionBarFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
@ -129,18 +127,6 @@ object WideSearchBarPatch : BytecodePatch(
|
||||
private const val FLAG = "android:paddingStart"
|
||||
private const val TARGET_RESOURCE_PATH = "res/layout/action_bar_ringo_background.xml"
|
||||
|
||||
/**
|
||||
* Walk a fingerprints method at a given index mutably.
|
||||
*
|
||||
* @param index The index to walk at.
|
||||
* @param fromFingerprint The fingerprint to walk the method on.
|
||||
* @return The [MutableMethod] which was walked on.
|
||||
*/
|
||||
private fun BytecodeContext.walkMutable(index: Int, fromFingerprint: MethodFingerprint) =
|
||||
fromFingerprint.result?.let {
|
||||
toMethodWalker(it.method).nextMethod(index, true).getMethod() as MutableMethod
|
||||
} ?: throw fromFingerprint.exception
|
||||
|
||||
/**
|
||||
* Injects instructions required for certain methods.
|
||||
*/
|
||||
|
@ -2,12 +2,9 @@ package app.revanced.patches.youtube.misc.layoutswitch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
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
|
||||
@ -16,8 +13,6 @@ import app.revanced.patches.youtube.misc.layoutswitch.fingerprints.GetFormFactor
|
||||
import app.revanced.patches.youtube.utils.fingerprints.LayoutSwitchFingerprint
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.MISC_PATH
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction10x
|
||||
|
||||
@Patch(
|
||||
name = "Layout switch",
|
||||
|
Loading…
x
Reference in New Issue
Block a user