feat(YouTube/Hide shorts components): remove the Hide toolbar setting and add settings to hide each toolbar button

This commit is contained in:
inotia00 2023-10-19 08:24:31 +09:00
parent e5ce2b707d
commit fed4961f43
8 changed files with 67 additions and 37 deletions

View File

@ -9,7 +9,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.utils.fingerprints.SetToolBarPaddingFingerprint import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetToolBarPaddingFingerprint
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

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.utils.fingerprints package app.revanced.patches.youtube.general.widesearchbar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ToolBarPaddingHome import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ToolBarPaddingHome

View File

@ -22,7 +22,6 @@ import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsPi
import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsRemixFingerprint import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsRemixFingerprint
import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsShareFingerprint import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsShareFingerprint
import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.litho.LithoFilterPatch
import app.revanced.patches.youtube.utils.navbarindex.NavBarIndexHookPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelDynRemix import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelDynRemix
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelDynShare import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelDynShare
@ -46,7 +45,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
description = "Hides other Shorts components.", description = "Hides other Shorts components.",
dependencies = [ dependencies = [
LithoFilterPatch::class, LithoFilterPatch::class,
NavBarIndexHookPatch::class,
SettingsPatch::class, SettingsPatch::class,
SharedResourceIdPatch::class, SharedResourceIdPatch::class,
ShortsNavigationBarPatch::class, ShortsNavigationBarPatch::class,

View File

@ -3,46 +3,46 @@ 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.addInstruction
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.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsCommentFingerprint import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.utils.fingerprints.SetToolBarPaddingFingerprint import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ToolBarBannerFingerprint
import app.revanced.patches.youtube.utils.navbarindex.NavBarIndexHookPatch.injectIndex import app.revanced.patches.youtube.utils.fingerprints.ToolBarPatchFingerprint
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ToolBarPaddingHome
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
object ShortsToolBarPatch : BytecodePatch( object ShortsToolBarPatch : BytecodePatch(
setOf( setOf(
SetToolBarPaddingFingerprint, ToolBarBannerFingerprint,
ShortsCommentFingerprint ToolBarPatchFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
SetToolBarPaddingFingerprint.result?.let { ToolBarBannerFingerprint.result?.let {
val targetIndex = it.mutableMethod.getWideLiteralIndex(ToolBarPaddingHome) + 3 val targetMethod = context
(context.toMethodWalker(it.method) .toMethodWalker(it.method)
.nextMethod(targetIndex, true) .nextMethod(it.scanResult.patternScanResult!!.endIndex, true)
.getMethod() as MutableMethod .getMethod() as MutableMethod
).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( targetMethod.apply {
1, addInstructionsWithLabels(
"invoke-static {v$targetRegister}, $SHORTS->hideShortsPlayerToolBar(Landroid/support/v7/widget/Toolbar;)V" 0, """
) invoke-static {}, $SHORTS->hideShortsToolBarBanner()Z
} move-result v0
if-nez v0, :hide
} ?: throw SetToolBarPaddingFingerprint.exception """, ExternalLabel("hide", getInstruction(implementation!!.instructions.size - 1))
)
ShortsCommentFingerprint.injectIndex(1) }
} ?: throw ToolBarBannerFingerprint.exception
ToolBarPatchFingerprint.result?.let {
it.mutableMethod.apply {
addInstruction(
0,
"invoke-static {p0, p1}, $SHORTS->hideShortsToolBarButton(Ljava/lang/String;Landroid/view/View;)V"
)
}
} ?: throw ToolBarPatchFingerprint.exception
} }
} }

View File

@ -0,0 +1,17 @@
package app.revanced.patches.youtube.shorts.shortscomponent.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import com.android.tools.smali.dexlib2.Opcode
object ToolBarBannerFingerprint : MethodFingerprint(
returnType = "Landroid/view/View;",
opcodes = listOf(
Opcode.IF_NEZ,
Opcode.IGET_OBJECT,
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL
),
strings = listOf("r_pfcv")
)

View File

@ -18,6 +18,7 @@ import app.revanced.util.integrations.Constants.UTILS_PATH
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
object NavBarIndexHookPatch : BytecodePatch( object NavBarIndexHookPatch : BytecodePatch(
setOf( setOf(
MobileTopBarButtonOnClickFingerprint, MobileTopBarButtonOnClickFingerprint,

View File

@ -506,12 +506,21 @@ Only available to some users who can use the speed overlay"</string>
<string name="revanced_hide_shorts_player_subscriptions_button_summary_off">Subscriptions button is shown</string> <string name="revanced_hide_shorts_player_subscriptions_button_summary_off">Subscriptions button is shown</string>
<string name="revanced_hide_shorts_player_subscriptions_button_summary_on">Subscriptions button is hidden</string> <string name="revanced_hide_shorts_player_subscriptions_button_summary_on">Subscriptions button is hidden</string>
<string name="revanced_hide_shorts_player_subscriptions_button_title">Hide subscriptions button</string> <string name="revanced_hide_shorts_player_subscriptions_button_title">Hide subscriptions button</string>
<string name="revanced_hide_shorts_player_toolbar_summary_off">Toolbar is shown</string>
<string name="revanced_hide_shorts_player_toolbar_summary_on">Toolbar is hidden</string>
<string name="revanced_hide_shorts_player_toolbar_title">Hide toolbar</string>
<string name="revanced_hide_shorts_shelf_summary_off">Shorts shelves are shown</string> <string name="revanced_hide_shorts_shelf_summary_off">Shorts shelves are shown</string>
<string name="revanced_hide_shorts_shelf_summary_on">Shorts shelves are hidden</string> <string name="revanced_hide_shorts_shelf_summary_on">Shorts shelves are hidden</string>
<string name="revanced_hide_shorts_shelf_title">Hide shorts shelf</string> <string name="revanced_hide_shorts_shelf_title">Hide shorts shelf</string>
<string name="revanced_hide_shorts_toolbar_banner_summary_off">Banner is shown</string>
<string name="revanced_hide_shorts_toolbar_banner_summary_on">Banner is hidden</string>
<string name="revanced_hide_shorts_toolbar_banner_title">Hide banner</string>
<string name="revanced_hide_shorts_toolbar_camera_button_summary_off">Camera button is shown</string>
<string name="revanced_hide_shorts_toolbar_camera_button_summary_on">Camera button is hidden</string>
<string name="revanced_hide_shorts_toolbar_camera_button_title">Hide camera button</string>
<string name="revanced_hide_shorts_toolbar_menu_button_summary_off">Menu button is shown</string>
<string name="revanced_hide_shorts_toolbar_menu_button_summary_on">Menu button is hidden</string>
<string name="revanced_hide_shorts_toolbar_menu_button_title">Hide menu button</string>
<string name="revanced_hide_shorts_toolbar_search_button_summary_off">Search button is shown</string>
<string name="revanced_hide_shorts_toolbar_search_button_summary_on">Search button is hidden</string>
<string name="revanced_hide_shorts_toolbar_search_button_title">Hide search button</string>
<string name="revanced_hide_snack_bar_summary_off">Snack bar is shown</string> <string name="revanced_hide_snack_bar_summary_off">Snack bar is shown</string>
<string name="revanced_hide_snack_bar_summary_on">Snack bar is hidden</string> <string name="revanced_hide_snack_bar_summary_on">Snack bar is hidden</string>
<string name="revanced_hide_snack_bar_title">Hide snack bar</string> <string name="revanced_hide_snack_bar_title">Hide snack bar</string>
@ -621,6 +630,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_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>
<string name="revanced_skipped_preloaded_buffer">Skipped preloaded buffer</string> <string name="revanced_skipped_preloaded_buffer">Skipped preloaded buffer</string>

View File

@ -614,9 +614,13 @@
<SwitchPreference android:title="@string/revanced_hide_shorts_player_subscriptions_button_title" android:key="revanced_hide_shorts_player_subscriptions_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_player_subscriptions_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_player_subscriptions_button_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_shorts_player_subscriptions_button_title" android:key="revanced_hide_shorts_player_subscriptions_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_player_subscriptions_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_player_subscriptions_button_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_player_thanks_button_title" android:key="revanced_hide_shorts_player_thanks_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_player_thanks_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_player_thanks_button_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_shorts_player_thanks_button_title" android:key="revanced_hide_shorts_player_thanks_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_player_thanks_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_player_thanks_button_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_player_pivot_button_title" android:key="revanced_hide_shorts_player_pivot_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_player_pivot_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_player_pivot_button_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_shorts_player_pivot_button_title" android:key="revanced_hide_shorts_player_pivot_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_player_pivot_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_player_pivot_button_summary_off" />
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_shorts_toolbar_title" />
<SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_banner_title" android:key="revanced_hide_shorts_toolbar_banner" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_toolbar_banner_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_banner_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_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=" " 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" /> <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_toolbar_title" android:key="revanced_hide_shorts_player_toolbar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_player_toolbar_summary_on" android:summaryOff="@string/revanced_hide_shorts_player_toolbar_summary_off" />SETTINGS: HIDE_SHORTS_COMPONENTS -->
<!-- PREFERENCE: SHORTS_SETTINGS <!-- PREFERENCE: SHORTS_SETTINGS
</PreferenceScreen>PREFERENCE: SHORTS_SETTINGS --> </PreferenceScreen>PREFERENCE: SHORTS_SETTINGS -->