diff --git a/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt b/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt index e34e5d56fe..9a1a08c8e5 100644 --- a/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt @@ -19,10 +19,10 @@ abstract class BaseMainActivityResolvePatch( ) { lateinit var mainActivityMutableClass: MutableClass lateinit var onConfigurationChangedMethod: MutableMethod + lateinit var onCreateMethod: MutableMethod private lateinit var constructorMethod: MutableMethod private lateinit var onBackPressedMethod: MutableMethod - private lateinit var onCreateMethod: MutableMethod private var constructorMethodIndex by Delegates.notNull() private var onBackPressedMethodIndex by Delegates.notNull() 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 742a38879e..a4603d22d1 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 @@ -35,6 +35,7 @@ import app.revanced.patches.youtube.utils.fingerprints.ScrollTopParentFingerprin 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.integrations.Constants.FEED_PATH +import app.revanced.patches.youtube.utils.mainactivity.MainActivityResolvePatch import app.revanced.patches.youtube.utils.navigation.NavigationBarHookPatch import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch @@ -62,6 +63,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.MethodReference +import com.android.tools.smali.dexlib2.iface.reference.StringReference import com.android.tools.smali.dexlib2.util.MethodUtil @Suppress("unused") @@ -70,6 +72,7 @@ object FeedComponentsPatch : BaseBytecodePatch( description = "Adds options to hide components related to feeds.", dependencies = setOf( LithoFilterPatch::class, + MainActivityResolvePatch::class, NavigationBarHookPatch::class, PlayerTypeHookPatch::class, SettingsPatch::class, @@ -175,6 +178,27 @@ object FeedComponentsPatch : BaseBytecodePatch( // endregion + // region patch for hide floating button + + MainActivityResolvePatch.onCreateMethod.apply { + val fabIndex = indexOfFirstInstructionOrThrow { + opcode == Opcode.CONST_STRING && + getReference()?.string == "fab" + } + val fabRegister = getInstruction(fabIndex).registerA + val jumpIndex = indexOfFirstInstructionOrThrow(fabIndex + 1, Opcode.CONST_STRING) + + addInstructionsWithLabels( + fabIndex, """ + invoke-static {}, $FEED_CLASS_DESCRIPTOR->hideFloatingButton()Z + move-result v$fabRegister + if-nez v$fabRegister, :hide + """, ExternalLabel("hide", getInstruction(jumpIndex)) + ) + } + + // endregion + // region patch for hide relative video fun Method.indexOfEngagementPanelBuilderInstruction(targetMethod: MutableMethod) = diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index aabb2dfd03..477ae6d73c 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -141,6 +141,9 @@ Tap here to learn more about DeArrow." Hide feed surveys Feed surveys are hidden. Feed surveys are shown. + Hide floating button + Floating button is hidden. + Floating button is shown. Hide image shelves Image shelves are hidden. Image shelves are shown. diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 4b47c99c9a..0af6960049 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -106,8 +106,9 @@ - + +