mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 09:04:34 +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.patch.annotation.Patch
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
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.patches.youtube.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.integrations.Constants.GENERAL
|
import app.revanced.util.integrations.Constants.GENERAL
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
@ -52,10 +52,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
|||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SearchTermThumbnailPatch : BytecodePatch(
|
object SearchTermThumbnailPatch : BytecodePatch(
|
||||||
setOf(SearchTermThumbnailFingerprint)
|
setOf(CreateSearchSuggestionsFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
SearchTermThumbnailFingerprint.result?.let { result ->
|
CreateSearchSuggestionsFingerprint.result?.let { result ->
|
||||||
result.mutableMethod.apply {
|
result.mutableMethod.apply {
|
||||||
val instructions = implementation!!.instructions
|
val instructions = implementation!!.instructions
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ object SearchTermThumbnailPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
removeInstruction(replaceIndex)
|
removeInstruction(replaceIndex)
|
||||||
}
|
}
|
||||||
} ?: throw SearchTermThumbnailFingerprint.exception
|
} ?: throw CreateSearchSuggestionsFingerprint.exception
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add settings
|
* Add settings
|
||||||
|
@ -10,8 +10,9 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage
|
|||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
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.YouActionBarFingerprint
|
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.resourceid.SharedResourceIdPatch
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts
|
||||||
@ -55,23 +56,31 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object WideSearchBarPatch : BytecodePatch(
|
object WideSearchBarPatch : BytecodePatch(
|
||||||
setOf(
|
setOf(
|
||||||
|
CreateSearchSuggestionsFingerprint,
|
||||||
SetActionBarRingoFingerprint,
|
SetActionBarRingoFingerprint,
|
||||||
SetToolBarPaddingFingerprint
|
SetWordMarkHeaderFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
arrayOf(
|
val result = CreateSearchSuggestionsFingerprint.result
|
||||||
SetActionBarRingoFingerprint,
|
?: throw CreateSearchSuggestionsFingerprint.exception
|
||||||
SetToolBarPaddingFingerprint
|
|
||||||
).forEach {
|
val parentClassDef = SetActionBarRingoFingerprint.result?.classDef
|
||||||
it.injectHook(context)
|
?: 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 {
|
YouActionBarFingerprint.also {
|
||||||
it.resolve(
|
it.resolve(
|
||||||
context,
|
context,
|
||||||
SetActionBarRingoFingerprint.result!!.classDef
|
parentClassDef
|
||||||
)
|
)
|
||||||
}.result?.let {
|
}.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
@ -119,19 +128,27 @@ object WideSearchBarPatch : BytecodePatch(
|
|||||||
private const val FLAG = "android:paddingStart"
|
private const val FLAG = "android:paddingStart"
|
||||||
private const val TARGET_RESOURCE_PATH = "res/layout/action_bar_ringo_background.xml"
|
private const val TARGET_RESOURCE_PATH = "res/layout/action_bar_ringo_background.xml"
|
||||||
|
|
||||||
private fun MethodFingerprint.injectHook(context: BytecodeContext) {
|
/**
|
||||||
result?.let {
|
* Walk a fingerprints method at a given index mutably.
|
||||||
(context
|
*
|
||||||
.toMethodWalker(it.method)
|
* @param index The index to walk at.
|
||||||
.nextMethod(it.scanResult.patternScanResult!!.endIndex, true)
|
* @param fromFingerprint The fingerprint to walk the method on.
|
||||||
.getMethod() as MutableMethod).apply {
|
* @return The [MutableMethod] which was walked on.
|
||||||
addInstructions(
|
*/
|
||||||
implementation!!.instructions.size - 1, """
|
private fun BytecodeContext.walkMutable(index: Int, fromFingerprint: MethodFingerprint) =
|
||||||
invoke-static {}, $GENERAL->enableWideSearchBar()Z
|
fromFingerprint.result?.let {
|
||||||
move-result p0
|
toMethodWalker(it.method).nextMethod(index, true).getMethod() as MutableMethod
|
||||||
"""
|
} ?: throw fromFingerprint.exception
|
||||||
)
|
|
||||||
}
|
/**
|
||||||
} ?: throw exception
|
* Injects instructions required for certain methods.
|
||||||
|
*/
|
||||||
|
private fun MutableMethod.injectSearchBarHook() {
|
||||||
|
addInstructions(
|
||||||
|
implementation!!.instructions.size - 1, """
|
||||||
|
invoke-static {}, $GENERAL->enableWideSearchBar()Z
|
||||||
|
move-result p0
|
||||||
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
object SearchTermThumbnailFingerprint : MethodFingerprint(
|
object CreateSearchSuggestionsFingerprint : MethodFingerprint(
|
||||||
returnType = "Landroid/view/View;",
|
returnType = "Landroid/view/View;",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("I", "Landroid/view/View;", "Landroid/view/ViewGroup;"),
|
parameters = listOf("I", "Landroid/view/View;", "Landroid/view/ViewGroup;"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_STATIC,
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.CONST_4
|
||||||
|
),
|
||||||
strings = listOf("ss_rds")
|
strings = listOf("ss_rds")
|
||||||
)
|
)
|
Loading…
x
Reference in New Issue
Block a user