From 5c36fb34cb4f8a9836d41180d68784a29436e7b2 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sat, 21 Oct 2023 10:29:22 +0900 Subject: [PATCH] fix(YouTube/Enable wide search bar): wide search bar does not apply to You tab --- .../widesearchbar/WideSearchBarPatch.kt | 23 +++++++++++++++++++ .../fingerprints/YouActionBarFingerprint.kt | 20 ++++++++++++++++ .../youtube/settings/host/values/strings.xml | 5 ++++ .../youtube/settings/xml/revanced_prefs.xml | 3 ++- 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/YouActionBarFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/WideSearchBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/WideSearchBarPatch.kt index d861c02a2..1123bf299 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/WideSearchBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/WideSearchBarPatch.kt @@ -3,17 +3,21 @@ package app.revanced.patches.youtube.general.widesearchbar 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.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch 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.SetToolBarPaddingFingerprint +import app.revanced.patches.youtube.general.widesearchbar.fingerprints.YouActionBarFingerprint 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 import app.revanced.util.integrations.Constants.GENERAL +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( name = "Enable wide search bar", @@ -61,6 +65,25 @@ object WideSearchBarPatch : BytecodePatch( it.injectHook(context) } + YouActionBarFingerprint.also { + it.resolve( + context, + SetActionBarRingoFingerprint.result!!.classDef + ) + }.result?.let { + it.mutableMethod.apply { + val insertIndex = it.scanResult.patternScanResult!!.endIndex + val insertRegister = getInstruction(insertIndex).registerA + + addInstructions( + insertIndex, """ + invoke-static {v$insertRegister}, $GENERAL->enableWideSearchBarInYouTab(Z)Z + move-result v$insertRegister + """ + ) + } + } ?: throw YouActionBarFingerprint.exception + /** * Set Wide SearchBar Start Margin */ diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/YouActionBarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/YouActionBarFingerprint.kt new file mode 100644 index 000000000..ff083e8b2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/YouActionBarFingerprint.kt @@ -0,0 +1,20 @@ +package app.revanced.patches.youtube.general.widesearchbar.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ActionBarRingo +import app.revanced.util.bytecode.isWideLiteralExists +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +object YouActionBarFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, + parameters = listOf("L"), + opcodes = listOf( + Opcode.IGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_EQZ, + ) +) \ No newline at end of file diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 8e0e7d167..b5d46f1eb 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -168,6 +168,11 @@ Wide search bar is disabled Wide search bar is enabled Enable wide search bar + "Enabling this setting will disable the settings button in the You tab + +In this case, please use the following path: +You tab > View channel > Menu > Settings" + Enable wide search bar in You tab Experimental Flags Save your ReVanced Extended settings to file Export settings diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index cf703beec..91cd8b00d 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -161,7 +161,8 @@ SETTINGS: ENABLE_TABLET_MINI_PLAYER --> + + SETTINGS: ENABLE_WIDE_SEARCH_BAR -->