diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsPatch.kt index 34e2232bbe..5eee2b3bcb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsPatch.kt @@ -1,73 +1,13 @@ package app.revanced.patches.youtube.layout.hide.breakingnews -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotation.CompatiblePackage -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.youtube.layout.hide.breakingnews.fingerprints.BreakingNewsFingerprint -import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsPatch -@Patch( - name = "Hide breaking news shelf", - description = "Adds an option to hide the breaking news shelf on the homepage tab.", - dependencies = [ - IntegrationsPatch::class, - BreakingNewsResourcePatch::class - ], - compatiblePackages = [ - CompatiblePackage( - "com.google.android.youtube", - [ - "18.32.39", - "18.37.36", - "18.38.44", - "18.43.45", - "18.44.41", - "18.45.43", - "18.48.39", - "18.49.37", - "19.01.34", - "19.02.39", - "19.03.36", - "19.04.38", - "19.05.36", - "19.06.39", - "19.07.40", - "19.08.36", - "19.09.37" - ] - ) - ] -) -@Suppress("unused") +@Deprecated("This patch has been merged to HideLayoutComponentsPatch.") object BreakingNewsPatch : BytecodePatch( - setOf(BreakingNewsFingerprint) + dependencies = setOf(HideLayoutComponentsPatch::class), ) { override fun execute(context: BytecodeContext) { - BreakingNewsFingerprint.result?.let { - val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1 - val moveResultIndex = insertIndex - 1 - - it.mutableMethod.apply { - val breakingNewsViewRegister = - getInstruction(moveResultIndex).registerA - - addInstruction( - insertIndex, - """ - invoke-static {v$breakingNewsViewRegister}, - Lapp/revanced/integrations/youtube/patches/HideBreakingNewsPatch; - -> - hideBreakingNews(Landroid/view/View;)V - """ - ) - } - - } ?: throw BreakingNewsFingerprint.exception - } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt deleted file mode 100644 index 81b69fe487..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt +++ /dev/null @@ -1,32 +0,0 @@ -package app.revanced.patches.youtube.layout.hide.breakingnews - -import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch -import app.revanced.patches.shared.misc.settings.preference.SwitchPreference -import app.revanced.patches.youtube.misc.settings.SettingsPatch - -@Patch( - dependencies = [ - SettingsPatch::class, - ResourceMappingPatch::class, - AddResourcesPatch::class - ], -) -internal object BreakingNewsResourcePatch : ResourcePatch() { - internal var horizontalCardListId: Long = -1 - - override fun execute(context: ResourceContext) { - AddResourcesPatch(this::class) - - SettingsPatch.PreferenceScreen.FEED.addPreferences( - SwitchPreference("revanced_hide_breaking_news") - ) - - horizontalCardListId = ResourceMappingPatch.resourceMappings.single { - it.type == "layout" && it.name == "horizontal_card_list" - }.id - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/fingerprints/BreakingNewsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/fingerprints/BreakingNewsFingerprint.kt deleted file mode 100644 index a67ad6f05a..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/fingerprints/BreakingNewsFingerprint.kt +++ /dev/null @@ -1,20 +0,0 @@ -package app.revanced.patches.youtube.layout.hide.breakingnews.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patches.youtube.layout.hide.breakingnews.BreakingNewsResourcePatch -import app.revanced.util.patch.LiteralValueFingerprint -import com.android.tools.smali.dexlib2.AccessFlags -import com.android.tools.smali.dexlib2.Opcode - -internal object BreakingNewsFingerprint : LiteralValueFingerprint( - accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, - opcodes = listOf( - Opcode.CONST, - Opcode.CONST_4, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CHECK_CAST, - Opcode.IPUT_OBJECT, - ), - literalSupplier = { BreakingNewsResourcePatch.horizontalCardListId } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index c15078dc48..104fe85e88 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -39,7 +39,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction SettingsPatch::class, AddResourcesPatch::class, HideLayoutComponentsResourcePatch::class, - NavigationBarHookPatch::class // Used by Keyword Content filter. + NavigationBarHookPatch::class, ], compatiblePackages = [ CompatiblePackage( @@ -117,6 +117,7 @@ object HideLayoutComponentsPatch : BytecodePatch( SwitchPreference("revanced_hide_compact_banner"), SwitchPreference("revanced_hide_feed_survey"), SwitchPreference("revanced_hide_for_you_shelf"), + SwitchPreference("revanced_hide_horizontal_shelves"), SwitchPreference("revanced_hide_image_shelf"), SwitchPreference("revanced_hide_latest_posts_ads"), SwitchPreference("revanced_hide_mix_playlists"), @@ -133,9 +134,9 @@ object HideLayoutComponentsPatch : BytecodePatch( SwitchPreference("revanced_hide_keyword_content_subscriptions"), SwitchPreference("revanced_hide_keyword_content_search"), TextPreference("revanced_hide_keyword_content_phrases", inputType = InputType.TEXT_MULTI_LINE), - NonInteractivePreference("revanced_hide_keyword_content_about") - ) - ) + NonInteractivePreference("revanced_hide_keyword_content_about"), + ), + ), ) SettingsPatch.PreferenceScreen.GENERAL_LAYOUT.addPreferences( @@ -216,7 +217,7 @@ object HideLayoutComponentsPatch : BytecodePatch( addInstruction( insertIndex, "invoke-static { v$viewRegister }, " + - "$LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideShowMoreButton(Landroid/view/View;)V" + "$LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideShowMoreButton(Landroid/view/View;)V", ) } } diff --git a/src/main/resources/addresources/values/strings.xml b/src/main/resources/addresources/values/strings.xml index 0cf574e57e..7476e856d5 100644 --- a/src/main/resources/addresources/values/strings.xml +++ b/src/main/resources/addresources/values/strings.xml @@ -92,6 +92,9 @@ Hide channel watermark Watermark is hidden Watermark is shown + Hide horizontal shelves + Shelves are hidden such as:\n• Breaking news\n• Continue watching\n• Explore more channels\n• Shopping\n• Watch it Again + Shelves are shown Hide \'Join\' button @@ -483,11 +486,6 @@ Album cards are hidden Album cards are shown - - Hide breaking news - Breaking news are hidden - Breaking news are shown - Comments Hide or show comments section components