mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-28 12:50:19 +02:00
feat(YouTube/Hide feed components): add Hide feed captions button
settings
This commit is contained in:
parent
4aa0d87a5c
commit
7a60a7a7ba
@ -10,6 +10,8 @@ import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.BreakingNewsFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.CaptionsButtonFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.CaptionsButtonSyntheticFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuTabletFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuTabletSyntheticFingerprint
|
||||
@ -28,10 +30,12 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.FEED_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.navigation.NavigationBarHookPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.CaptionToggleContainer
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
@ -55,6 +59,8 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
fingerprints = setOf(
|
||||
BreakingNewsFingerprint,
|
||||
CaptionsButtonFingerprint,
|
||||
CaptionsButtonSyntheticFingerprint,
|
||||
ChannelListSubMenuFingerprint,
|
||||
ChannelListSubMenuTabletFingerprint,
|
||||
ChannelListSubMenuTabletSyntheticFingerprint,
|
||||
@ -101,6 +107,34 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for hide caption button
|
||||
|
||||
CaptionsButtonFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(CaptionToggleContainer)
|
||||
val insertIndex = getTargetIndexReversed(constIndex, Opcode.IF_EQZ)
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$insertRegister}, $FEED_CLASS_DESCRIPTOR->hideCaptionsButton(Landroid/view/View;)Landroid/view/View;
|
||||
move-result-object v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
CaptionsButtonSyntheticFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(CaptionToggleContainer)
|
||||
val targetIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $FEED_CLASS_DESCRIPTOR->hideCaptionsButtonContainer(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for hide subscriptions channel section for tablet
|
||||
|
||||
arrayOf(
|
||||
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.youtube.feed.components.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.CaptionToggleContainer
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object CaptionsButtonFingerprint : LiteralValueFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
literalSupplier = { CaptionToggleContainer }
|
||||
)
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.youtube.feed.components.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.CaptionToggleContainer
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object CaptionsButtonSyntheticFingerprint : LiteralValueFingerprint(
|
||||
returnType = "Landroid/view/View;",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.BRIDGE or AccessFlags.SYNTHETIC,
|
||||
parameters = listOf("Landroid/content/Context;"),
|
||||
literalSupplier = { CaptionToggleContainer }
|
||||
)
|
@ -32,6 +32,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var BarContainerHeight = -1L
|
||||
var BottomSheetFooterText = -1L
|
||||
var BottomUiContainerStub = -1L
|
||||
var CaptionToggleContainer = -1L
|
||||
var CastMediaRouteButton = -1L
|
||||
var ChannelListSubMenu = -1L
|
||||
var CompactLink = -1L
|
||||
@ -111,6 +112,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
BarContainerHeight = getId(DIMEN, "bar_container_height")
|
||||
BottomSheetFooterText = getId(ID, "bottom_sheet_footer_text")
|
||||
BottomUiContainerStub = getId(ID, "bottom_ui_container_stub")
|
||||
CaptionToggleContainer = getId(ID, "caption_toggle_container")
|
||||
CastMediaRouteButton = getId(LAYOUT, "castmediaroutebutton")
|
||||
ChannelListSubMenu = getId(LAYOUT, "channel_list_sub_menu")
|
||||
CompactLink = getId(LAYOUT, "compact_link")
|
||||
|
@ -97,6 +97,9 @@ Tap here to learn more about DeArrow."</string>
|
||||
<string name="revanced_hide_expandable_chip_title">Hide expandable chip under videos</string>
|
||||
<string name="revanced_hide_expandable_chip_summary_on">Expandable chips are hidden.</string>
|
||||
<string name="revanced_hide_expandable_chip_summary_off">Expandable chips are shown.</string>
|
||||
<string name="revanced_hide_feed_captions_button_title">Hide feed captions button</string>
|
||||
<string name="revanced_hide_feed_captions_button_on">Captions button is hidden.</string>
|
||||
<string name="revanced_hide_feed_captions_button_off">Captions button is shown.</string>
|
||||
<string name="revanced_hide_feed_search_bar_title">Hide feed search bar</string>
|
||||
<string name="revanced_hide_feed_search_bar_summary_on">Feed search bar is hidden.</string>
|
||||
<string name="revanced_hide_feed_search_bar_summary_off">Feed search bar is shown.</string>
|
||||
|
@ -84,6 +84,7 @@
|
||||
<SwitchPreference android:title="@string/revanced_hide_carousel_shelf_title" android:key="revanced_hide_carousel_shelf" android:defaultValue="false" android:summary="@string/revanced_hide_carousel_shelf_summary" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_chips_shelf_title" android:key="revanced_hide_chips_shelf" android:defaultValue="true" android:summaryOn="@string/revanced_hide_chips_shelf_on" android:summaryOff="@string/revanced_hide_chips_shelf_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_expandable_chip_title" android:key="revanced_hide_expandable_chip" android:defaultValue="true" android:summaryOn="@string/revanced_hide_expandable_chip_summary_on" android:summaryOff="@string/revanced_hide_expandable_chip_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_feed_captions_button_title" android:key="revanced_hide_feed_captions_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_feed_captions_button_on" android:summaryOff="@string/revanced_hide_feed_captions_button_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_feed_survey_title" android:key="revanced_hide_feed_survey" android:defaultValue="true" android:summaryOn="@string/revanced_hide_feed_survey_summary_on" android:summaryOff="@string/revanced_hide_feed_survey_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_feed_search_bar_title" android:key="revanced_hide_feed_search_bar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_feed_search_bar_summary_on" android:summaryOff="@string/revanced_hide_feed_search_bar_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_image_shelf_title" android:key="revanced_hide_image_shelf" android:defaultValue="true" android:summaryOn="@string/revanced_hide_image_shelf_summary_on" android:summaryOff="@string/revanced_hide_image_shelf_summary_off" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user