From 1cf3c6da539c8a9b997befed10aaa658af3f726c Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:10:27 +0900 Subject: [PATCH] fix(YouTube/Hide feed components): `Hide carousel shelf` setting sometimes hides the library shelf --- .../feed/components/FeedComponentsPatch.kt | 3 ++ .../navigation/NavigationBarHookPatch.kt | 29 ++----------------- .../MobileTopBarButtonOnClickFingerprint.kt | 8 ----- ...ettingsActivityOnBackPressedFingerprint.kt | 14 --------- .../youtube/settings/host/values/strings.xml | 2 +- 5 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/utils/navigation/fingerprints/MobileTopBarButtonOnClickFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/utils/navigation/fingerprints/SettingsActivityOnBackPressedFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/feed/components/FeedComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/feed/components/FeedComponentsPatch.kt index 9207a4fabb..a896aef65c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/feed/components/FeedComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/feed/components/FeedComponentsPatch.kt @@ -75,6 +75,8 @@ object FeedComponentsPatch : BaseBytecodePatch( ShowMoreButtonFingerprint ) ) { + private const val CAROUSEL_SHELF_FILTER_CLASS_DESCRIPTOR = + "$COMPONENTS_PATH/CarouselShelfFilter;" private const val FEED_COMPONENTS_FILTER_CLASS_DESCRIPTOR = "$COMPONENTS_PATH/FeedComponentsFilter;" private const val FEED_VIDEO_FILTER_CLASS_DESCRIPTOR = @@ -287,6 +289,7 @@ object FeedComponentsPatch : BaseBytecodePatch( // endregion + LithoFilterPatch.addFilter(CAROUSEL_SHELF_FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FEED_COMPONENTS_FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FEED_VIDEO_FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FEED_VIDEO_VIEWS_FILTER_CLASS_DESCRIPTOR) diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/NavigationBarHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/NavigationBarHookPatch.kt index 92b600ca57..5ea1cb5767 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/NavigationBarHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/NavigationBarHookPatch.kt @@ -2,7 +2,6 @@ package app.revanced.patches.youtube.utils.navigation import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstructions import app.revanced.patcher.patch.BytecodePatch @@ -12,13 +11,11 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.youtube.utils.fingerprints.InitializeButtonsFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH import app.revanced.patches.youtube.utils.mainactivity.MainActivityResolvePatch -import app.revanced.patches.youtube.utils.navigation.fingerprints.MobileTopBarButtonOnClickFingerprint import app.revanced.patches.youtube.utils.navigation.fingerprints.NavigationEnumFingerprint import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsCreateDrawableViewFingerprint import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsCreateResourceViewFingerprint import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsViewSetSelectedFingerprint import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarConstructorFingerprint -import app.revanced.patches.youtube.utils.navigation.fingerprints.SettingsActivityOnBackPressedFingerprint import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.util.getReference @@ -41,13 +38,11 @@ import com.android.tools.smali.dexlib2.util.MethodUtil @Suppress("unused") object NavigationBarHookPatch : BytecodePatch( setOf( - MobileTopBarButtonOnClickFingerprint, NavigationEnumFingerprint, PivotBarButtonsCreateDrawableViewFingerprint, PivotBarButtonsCreateResourceViewFingerprint, PivotBarButtonsViewSetSelectedFingerprint, PivotBarConstructorFingerprint, - SettingsActivityOnBackPressedFingerprint ), ) { private const val INTEGRATIONS_CLASS_DESCRIPTOR = @@ -110,16 +105,11 @@ object NavigationBarHookPatch : BytecodePatch( val instruction = getInstruction(index) val viewRegister = instruction.registerC val isSelectedRegister = instruction.registerD - val freeRegister = implementation!!.registerCount - parameters.size - 2 addInstruction( index + 1, - "invoke-static { v$viewRegister, v$freeRegister, v$isSelectedRegister }, " + - "$INTEGRATIONS_CLASS_DESCRIPTOR->navigationTabSelected(Landroid/view/View;IZ)V", - ) - addInstruction( - 0, - "move/16 v$freeRegister, p1" + "invoke-static { v$viewRegister, v$isSelectedRegister }, " + + "$INTEGRATIONS_CLASS_DESCRIPTOR->navigationTabSelected(Landroid/view/View;Z)V", ) } } @@ -133,21 +123,6 @@ object NavigationBarHookPatch : BytecodePatch( INTEGRATIONS_CLASS_DESCRIPTOR, "onBackPressed" ) - - /** - * Since it is used only after opening the library tab, set index to 3. - */ - arrayOf( - MobileTopBarButtonOnClickFingerprint, - SettingsActivityOnBackPressedFingerprint - ).forEach { fingerprint -> - fingerprint.resultOrThrow().mutableMethod.addInstructions( - 0, """ - const/4 v0, 0x3 - invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->setNavigationTabIndex(I)V - """ - ) - } } val hookNavigationButtonCreated: (String) -> Unit by lazy { diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/fingerprints/MobileTopBarButtonOnClickFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/fingerprints/MobileTopBarButtonOnClickFingerprint.kt deleted file mode 100644 index 48215f9c8e..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/fingerprints/MobileTopBarButtonOnClickFingerprint.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.youtube.utils.navigation.fingerprints - -import app.revanced.patcher.fingerprint.MethodFingerprint - -object MobileTopBarButtonOnClickFingerprint : MethodFingerprint( - strings = listOf("MenuButtonRendererKey"), - customFingerprint = { methodDef, _ -> methodDef.name == "onClick" } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/fingerprints/SettingsActivityOnBackPressedFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/fingerprints/SettingsActivityOnBackPressedFingerprint.kt deleted file mode 100644 index 03fe1c87c0..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/fingerprints/SettingsActivityOnBackPressedFingerprint.kt +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.patches.youtube.utils.navigation.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.MethodFingerprint -import com.android.tools.smali.dexlib2.AccessFlags - -object SettingsActivityOnBackPressedFingerprint : MethodFingerprint( - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - returnType = "V", - customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("/SettingsActivity;") - && methodDef.name == "onBackPressed" - } -) \ No newline at end of file diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index f7b54b1fbb..f107c7ffde 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -105,6 +105,7 @@ Tap here to learn more about DeArrow." Hide album cards Album cards are hidden. Album cards are shown. + Hide carousel shelf "Hides the following shelves: • Breaking news • Continue watching @@ -112,7 +113,6 @@ Tap here to learn more about DeArrow." • Listen again • Shopping • Watch it again" - Hide carousel shelf Hide chips shelf Chips shelf is hidden. Chips shelf is shown.