feat(YouTube/Hide shorts components): now hiding all shorts toolbar components will hide the entire shorts toolbar

This commit is contained in:
inotia00 2023-10-28 10:01:41 +09:00
parent 12645fe66f
commit 5a11c6ffbb
5 changed files with 47 additions and 4 deletions

View File

@ -10,7 +10,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.patches.youtube.general.widesearchbar.fingerprints.SetActionBarRingoFingerprint 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.general.widesearchbar.fingerprints.YouActionBarFingerprint
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

View File

@ -2,19 +2,39 @@ package app.revanced.patches.youtube.shorts.shortscomponent
import app.revanced.extensions.exception import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext 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.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchException
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.shorts.shortscomponent.fingerprints.ShortsCommentFingerprint
import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ToolBarBannerFingerprint 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.patches.youtube.utils.toolbar.ToolBarHookPatch
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.SHORTS 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( object ShortsToolBarPatch : BytecodePatch(
setOf(ToolBarBannerFingerprint) setOf(
SetToolBarPaddingFingerprint,
ShortsCommentFingerprint,
ToolBarBannerFingerprint
)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ToolBarBannerFingerprint.result?.let { ToolBarBannerFingerprint.result?.let {
@ -37,5 +57,26 @@ object ShortsToolBarPatch : BytecodePatch(
} ?: throw ToolBarBannerFingerprint.exception } ?: throw ToolBarBannerFingerprint.exception
ToolBarHookPatch.injectCall("$SHORTS->hideShortsToolBarButton") 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<ReferenceInstruction>(0).reference
if (!targetParameter.toString().endsWith("Landroid/support/v7/widget/Toolbar;"))
throw PatchException("Method signature parameter did not match: $targetParameter")
val targetRegister = getInstruction<TwoRegisterInstruction>(0).registerA
addInstruction(
1,
"invoke-static {v$targetRegister}, $SHORTS->hideShortsToolBar(Landroid/support/v7/widget/Toolbar;)V"
)
}
} ?: throw SetToolBarPaddingFingerprint.exception
ShortsCommentFingerprint.injectIndex(1)
} }
} }

View File

@ -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.patcher.fingerprint.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ToolBarPaddingHome import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ToolBarPaddingHome

View File

@ -645,6 +645,7 @@ Tap and hold to set playback speed to 1.0x"</string>
<string name="revanced_seekbar">Seekbar</string> <string name="revanced_seekbar">Seekbar</string>
<string name="revanced_shorts">Shorts</string> <string name="revanced_shorts">Shorts</string>
<string name="revanced_shorts_player_title">Shorts player</string> <string name="revanced_shorts_player_title">Shorts player</string>
<string name="revanced_shorts_toolbar_summary">To hide the shorts toolbar, hide all settings in the shorts toolbar category</string>
<string name="revanced_shorts_toolbar_title">Shorts toolbar</string> <string name="revanced_shorts_toolbar_title">Shorts toolbar</string>
<string name="revanced_show_fullscreen_title_summary">Known issue: Title disappears when clicked</string> <string name="revanced_show_fullscreen_title_summary">Known issue: Title disappears when clicked</string>
<string name="revanced_show_fullscreen_title_title">Show fullscreen title</string> <string name="revanced_show_fullscreen_title_title">Show fullscreen title</string>

View File

@ -627,6 +627,7 @@
<SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_camera_button_title" android:key="revanced_hide_shorts_toolbar_camera_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_toolbar_camera_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_camera_button_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_camera_button_title" android:key="revanced_hide_shorts_toolbar_camera_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_toolbar_camera_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_camera_button_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_search_button_title" android:key="revanced_hide_shorts_toolbar_search_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_toolbar_search_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_search_button_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_search_button_title" android:key="revanced_hide_shorts_toolbar_search_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_toolbar_search_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_search_button_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_menu_button_title" android:key="revanced_hide_shorts_toolbar_menu_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_toolbar_menu_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_menu_button_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_menu_button_title" android:key="revanced_hide_shorts_toolbar_menu_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_toolbar_menu_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_menu_button_summary_off" />
<Preference android:title="@string/revanced_inform" android:selectable="false" android:summary="@string/revanced_shorts_toolbar_summary" />
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_experimental_flag" /> <Preference android:title=" " android:selectable="false" android:summary="@string/revanced_experimental_flag" />
<SwitchPreference android:title="@string/revanced_hide_shorts_player_navigation_bar_title" android:key="revanced_hide_shorts_player_navigation_bar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_player_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_shorts_player_navigation_bar_summary_off" />SETTINGS: HIDE_SHORTS_COMPONENTS --> <SwitchPreference android:title="@string/revanced_hide_shorts_player_navigation_bar_title" android:key="revanced_hide_shorts_player_navigation_bar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_player_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_shorts_player_navigation_bar_summary_off" />SETTINGS: HIDE_SHORTS_COMPONENTS -->