mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 00:54:32 +02:00
fix(YouTube/Enable wide search bar): Enable wide search bar
patch restores the old style search bar
This commit is contained in:
parent
05a74cebdd
commit
1bd7eb41f1
@ -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.general.searchterm.fingerprints.SearchTermThumbnailFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.CreateSearchSuggestionsFingerprint
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.GENERAL
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -52,10 +52,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
)
|
||||
@Suppress("unused")
|
||||
object SearchTermThumbnailPatch : BytecodePatch(
|
||||
setOf(SearchTermThumbnailFingerprint)
|
||||
setOf(CreateSearchSuggestionsFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
SearchTermThumbnailFingerprint.result?.let { result ->
|
||||
CreateSearchSuggestionsFingerprint.result?.let { result ->
|
||||
result.mutableMethod.apply {
|
||||
val instructions = implementation!!.instructions
|
||||
|
||||
@ -92,7 +92,7 @@ object SearchTermThumbnailPatch : BytecodePatch(
|
||||
)
|
||||
removeInstruction(replaceIndex)
|
||||
}
|
||||
} ?: throw SearchTermThumbnailFingerprint.exception
|
||||
} ?: throw CreateSearchSuggestionsFingerprint.exception
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
|
@ -10,8 +10,9 @@ 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.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.SetToolBarPaddingFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.CreateSearchSuggestionsFingerprint
|
||||
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
|
||||
@ -55,23 +56,31 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@Suppress("unused")
|
||||
object WideSearchBarPatch : BytecodePatch(
|
||||
setOf(
|
||||
CreateSearchSuggestionsFingerprint,
|
||||
SetActionBarRingoFingerprint,
|
||||
SetToolBarPaddingFingerprint
|
||||
SetWordMarkHeaderFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
arrayOf(
|
||||
SetActionBarRingoFingerprint,
|
||||
SetToolBarPaddingFingerprint
|
||||
).forEach {
|
||||
it.injectHook(context)
|
||||
val result = CreateSearchSuggestionsFingerprint.result
|
||||
?: throw CreateSearchSuggestionsFingerprint.exception
|
||||
|
||||
val parentClassDef = SetActionBarRingoFingerprint.result?.classDef
|
||||
?: throw CreateSearchSuggestionsFingerprint.exception
|
||||
|
||||
// patch methods
|
||||
mapOf(
|
||||
SetWordMarkHeaderFingerprint to 1,
|
||||
CreateSearchSuggestionsFingerprint to result.scanResult.patternScanResult!!.startIndex
|
||||
).forEach { (fingerprint, callIndex) ->
|
||||
context.walkMutable(callIndex, fingerprint).injectSearchBarHook()
|
||||
}
|
||||
|
||||
YouActionBarFingerprint.also {
|
||||
it.resolve(
|
||||
context,
|
||||
SetActionBarRingoFingerprint.result!!.classDef
|
||||
parentClassDef
|
||||
)
|
||||
}.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
@ -119,12 +128,22 @@ object WideSearchBarPatch : BytecodePatch(
|
||||
private const val FLAG = "android:paddingStart"
|
||||
private const val TARGET_RESOURCE_PATH = "res/layout/action_bar_ringo_background.xml"
|
||||
|
||||
private fun MethodFingerprint.injectHook(context: BytecodeContext) {
|
||||
result?.let {
|
||||
(context
|
||||
.toMethodWalker(it.method)
|
||||
.nextMethod(it.scanResult.patternScanResult!!.endIndex, true)
|
||||
.getMethod() as MutableMethod).apply {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
private fun MutableMethod.injectSearchBarHook() {
|
||||
addInstructions(
|
||||
implementation!!.instructions.size - 1, """
|
||||
invoke-static {}, $GENERAL->enableWideSearchBar()Z
|
||||
@ -132,6 +151,4 @@ object WideSearchBarPatch : BytecodePatch(
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw exception
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package app.revanced.patches.youtube.general.widesearchbar.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 SetWordMarkHeaderFingerprint : MethodFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
returnType = "V",
|
||||
parameters = listOf("Landroid/widget/ImageView;"),
|
||||
opcodes = listOf(
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.IGET_BOOLEAN,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_STATIC,
|
||||
)
|
||||
)
|
@ -1,12 +1,18 @@
|
||||
package app.revanced.patches.youtube.general.searchterm.fingerprints
|
||||
package app.revanced.patches.youtube.utils.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 SearchTermThumbnailFingerprint : MethodFingerprint(
|
||||
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")
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user