Skip to content

Commit

Permalink
feat(YouTube/Hide feed components): add Hide floating button setting
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Oct 26, 2024
1 parent dc379e5 commit e644186
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int>()
private var onBackPressedMethodIndex by Delegates.notNull<Int>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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,
Expand Down Expand Up @@ -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<StringReference>()?.string == "fab"
}
val fabRegister = getInstruction<OneRegisterInstruction>(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) =
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/youtube/settings/host/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ Tap here to learn more about DeArrow."</string>
<string name="revanced_hide_feed_survey_title">Hide feed surveys</string>
<string name="revanced_hide_feed_survey_summary_on">Feed surveys are hidden.</string>
<string name="revanced_hide_feed_survey_summary_off">Feed surveys are shown.</string>
<string name="revanced_hide_floating_button_title">Hide floating button</string>
<string name="revanced_hide_floating_button_summary_on">Floating button is hidden.</string>
<string name="revanced_hide_floating_button_summary_off">Floating button is shown.</string>
<string name="revanced_hide_image_shelf_title">Hide image shelves</string>
<string name="revanced_hide_image_shelf_summary_on">Image shelves are hidden.</string>
<string name="revanced_hide_image_shelf_summary_off">Image shelves are shown.</string>
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/youtube/settings/xml/revanced_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@
<SwitchPreference android:title="@string/revanced_hide_expandable_chip_title" android:key="revanced_hide_expandable_chip" android:summaryOn="@string/revanced_hide_expandable_chip_summary_on" android:summaryOff="@string/revanced_hide_expandable_chip_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_expandable_shelf_title" android:key="revanced_hide_expandable_shelf" android:summaryOn="@string/revanced_hide_expandable_shelf_summary_on" android:summaryOff="@string/revanced_hide_expandable_shelf_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_feed_captions_button_title" android:key="revanced_hide_feed_captions_button" 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: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: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_feed_survey_title" android:key="revanced_hide_feed_survey" android:summaryOn="@string/revanced_hide_feed_survey_summary_on" android:summaryOff="@string/revanced_hide_feed_survey_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_floating_button_title" android:key="revanced_hide_floating_button" android:summaryOn="@string/revanced_hide_floating_button_summary_on" android:summaryOff="@string/revanced_hide_floating_button_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_image_shelf_title" android:key="revanced_hide_image_shelf" android:summaryOn="@string/revanced_hide_image_shelf_summary_on" android:summaryOff="@string/revanced_hide_image_shelf_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_latest_posts_title" android:key="revanced_hide_latest_posts" android:summaryOn="@string/revanced_hide_latest_posts_summary_on" android:summaryOff="@string/revanced_hide_latest_posts_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_latest_videos_button_title" android:key="revanced_hide_latest_videos_button" android:summaryOn="@string/revanced_hide_latest_videos_button_summary_on" android:summaryOff="@string/revanced_hide_latest_videos_button_summary_off" />
Expand Down

0 comments on commit e644186

Please sign in to comment.