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 11917e204..1a993ba7d 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 @@ -10,7 +10,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.patches.youtube.general.widesearchbar.fingerprints.SetActionBarRingoFingerprint -import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetToolBarPaddingFingerprint +import app.revanced.patches.youtube.utils.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 diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/ShortsToolBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/ShortsToolBarPatch.kt index b643d462e..6f2922d28 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/ShortsToolBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/ShortsToolBarPatch.kt @@ -2,19 +2,39 @@ package app.revanced.patches.youtube.shorts.shortscomponent import app.revanced.extensions.exception import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchException 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.shorts.shortscomponent.fingerprints.ShortsCommentFingerprint import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ToolBarBannerFingerprint +import app.revanced.patches.youtube.utils.fingerprints.SetToolBarPaddingFingerprint +import app.revanced.patches.youtube.utils.navbarindex.NavBarIndexHookPatch +import app.revanced.patches.youtube.utils.navbarindex.NavBarIndexHookPatch.injectIndex +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ToolBarPaddingHome import app.revanced.patches.youtube.utils.toolbar.ToolBarHookPatch +import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.SHORTS +import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction +import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -@Patch(dependencies = [ToolBarHookPatch::class]) +@Patch( + dependencies = + [ + NavBarIndexHookPatch::class, + ToolBarHookPatch::class + ] +) object ShortsToolBarPatch : BytecodePatch( - setOf(ToolBarBannerFingerprint) + setOf( + SetToolBarPaddingFingerprint, + ShortsCommentFingerprint, + ToolBarBannerFingerprint + ) ) { override fun execute(context: BytecodeContext) { ToolBarBannerFingerprint.result?.let { @@ -37,5 +57,26 @@ object ShortsToolBarPatch : BytecodePatch( } ?: throw ToolBarBannerFingerprint.exception ToolBarHookPatch.injectCall("$SHORTS->hideShortsToolBarButton") + + SetToolBarPaddingFingerprint.result?.let { + val targetMethod = context + .toMethodWalker(it.method) + .nextMethod(it.mutableMethod.getWideLiteralIndex(ToolBarPaddingHome) + 3, true) + .getMethod() as MutableMethod + + targetMethod.apply { + val targetParameter = getInstruction(0).reference + if (!targetParameter.toString().endsWith("Landroid/support/v7/widget/Toolbar;")) + throw PatchException("Method signature parameter did not match: $targetParameter") + val targetRegister = getInstruction(0).registerA + + addInstruction( + 1, + "invoke-static {v$targetRegister}, $SHORTS->hideShortsToolBar(Landroid/support/v7/widget/Toolbar;)V" + ) + } + } ?: throw SetToolBarPaddingFingerprint.exception + + ShortsCommentFingerprint.injectIndex(1) } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/SetToolBarPaddingFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SetToolBarPaddingFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/SetToolBarPaddingFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SetToolBarPaddingFingerprint.kt index 9f830feaf..52d8a307b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/SetToolBarPaddingFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SetToolBarPaddingFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.general.widesearchbar.fingerprints +package app.revanced.patches.youtube.utils.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ToolBarPaddingHome diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index cdf0b53b6..b7dc62848 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -645,6 +645,7 @@ Tap and hold to set playback speed to 1.0x" Seekbar Shorts Shorts player + To hide the shorts toolbar, hide all settings in the shorts toolbar category Shorts toolbar Known issue: Title disappears when clicked Show fullscreen title diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 666a002f8..36ac17593 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -627,6 +627,7 @@ + SETTINGS: HIDE_SHORTS_COMPONENTS -->