From ed6ac395b06ae6f3bf7fb4cfa5146f5be5f5317e Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 17 Feb 2024 13:20:58 +0400 Subject: [PATCH] feat(YouTube): Reorganize settings menu --- api/revanced-patches.api | 10 +-- .../settings/BaseSettingsResourcePatch.kt | 13 ++-- .../preference/BasePreferenceScreen.kt | 9 --- .../settings/preference/IntentPreference.kt | 7 +-- .../youtube/ad/general/HideAdsPatch.kt | 2 +- .../copyvideourl/CopyVideoUrlBytecodePatch.kt | 2 +- .../copyvideourl/CopyVideoUrlResourcePatch.kt | 2 +- .../RemoveViewerDiscretionDialogPatch.kt | 4 +- .../ExternalDownloadsBytecodePatch.kt | 2 +- .../ExternalDownloadsResourcePatch.kt | 2 +- .../DisablePreciseSeekingGesturePatch.kt | 2 +- .../seekbar/EnableSeekbarTappingPatch.kt | 2 +- .../seekbar/EnableSlideToSeekPatch.kt | 2 +- .../SwipeControlsResourcePatch.kt | 2 +- .../layout/autocaptions/AutoCaptionsPatch.kt | 2 +- .../branding/header/ChangeHeaderPatch.kt | 2 +- .../layout/buttons/action/HideButtonsPatch.kt | 2 +- .../autoplay/HideAutoplayButtonPatch.kt | 2 +- .../captions/HideCaptionsButtonPatch.kt | 2 +- .../buttons/cast/HideCastButtonPatch.kt | 4 +- .../navigation/NavigationButtonsPatch.kt | 2 +- .../player/hide/HidePlayerButtonsPatch.kt | 2 +- .../albumcards/AlbumCardsResourcePatch.kt | 2 +- .../breakingnews/BreakingNewsResourcePatch.kt | 2 +- .../layout/hide/comments/CommentsPatch.kt | 2 +- .../CrowdfundingBoxResourcePatch.kt | 2 +- .../HideEndscreenCardsResourcePatch.kt | 2 +- .../filterbar/HideFilterBarResourcePatch.kt | 2 +- ...deFloatingMicrophoneButtonResourcePatch.kt | 2 +- .../DisableFullscreenAmbientModePatch.kt | 2 +- .../hide/general/HideLayoutComponentsPatch.kt | 62 ++++++++++--------- .../infocards/HideInfocardsResourcePatch.kt | 2 +- .../HideLoadMoreButtonResourcePatch.kt | 2 +- .../HidePlayerFlyoutMenuPatch.kt | 2 +- .../DisableRollingNumberAnimationPatch.kt | 2 +- .../layout/hide/seekbar/HideSeekbarPatch.kt | 4 +- .../HideShortsComponentsResourcePatch.kt | 32 ++++------ ...bleSuggestedVideoEndScreenResourcePatch.kt | 2 +- .../layout/hide/time/HideTimestampPatch.kt | 2 +- .../panels/popup/PlayerPopupPanelsPatch.kt | 2 +- ...CustomPlayerOverlayOpacityResourcePatch.kt | 2 +- .../ReturnYouTubeDislikeResourcePatch.kt | 11 ++-- .../layout/searchbar/WideSearchbarPatch.kt | 2 +- .../RestoreOldSeekbarThumbnailsPatch.kt | 5 +- .../layout/seekbar/SeekbarPreferencesPatch.kt | 34 ---------- .../sponsorblock/SponsorBlockResourcePatch.kt | 12 ++-- .../spoofappversion/SpoofAppVersionPatch.kt | 2 +- .../layout/startpage/ChangeStartPagePatch.kt | 2 +- .../DisableResumingShortsOnStartupPatch.kt | 2 +- .../layout/tablet/EnableTabletLayoutPatch.kt | 2 +- .../tabletminiplayer/TabletMiniPlayerPatch.kt | 4 +- .../layout/theme/ThemeBytecodePatch.kt | 2 +- .../layout/theme/ThemeResourcePatch.kt | 4 +- .../thumbnails/AlternativeThumbnailsPatch.kt | 2 +- .../spoof/SpoofDeviceDimensionsPatch.kt | 4 +- .../youtube/misc/settings/SettingsPatch.kt | 18 ++++-- .../misc/settings/SettingsResourcePatch.kt | 27 +++++++- .../youtube/video/speed/PlaybackSpeedPatch.kt | 2 +- .../resources/addresources/values/strings.xml | 23 ++----- 59 files changed, 176 insertions(+), 191 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 25de72baa6..c296ccdce2 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -715,8 +715,6 @@ public abstract class app/revanced/patches/shared/misc/settings/preference/BaseP public class app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen : app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$BasePreferenceCollection { public fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;)V public synthetic fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;)V - public synthetic fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun addPreferences ([Lapp/revanced/patches/shared/misc/settings/preference/BasePreference;)V public final fun getCategories ()Ljava/util/Set; public synthetic fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreference; @@ -1452,7 +1450,6 @@ public final class app/revanced/patches/youtube/layout/tabletminiplayer/TabletMi public static final field INSTANCE Lapp/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V - public final fun unwrap (Lapp/revanced/patcher/fingerprint/MethodFingerprint;)Lkotlin/Triple; } public final class app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch : app/revanced/patcher/patch/BytecodePatch { @@ -1601,9 +1598,12 @@ public final class app/revanced/patches/youtube/misc/settings/SettingsPatch$Pref public static final field INSTANCE Lapp/revanced/patches/youtube/misc/settings/SettingsPatch$PreferenceScreen; public fun commit (Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreen;)V public final fun getADS ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; - public final fun getINTERACTIONS ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; - public final fun getLAYOUT ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; + public final fun getLAYOUT_FEED ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; + public final fun getLAYOUT_OTHER ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; + public final fun getLAYOUT_PLAYER ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; public final fun getMISC ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; + public final fun getSEEKBAR ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; + public final fun getSHORTS ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; public final fun getVIDEO ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; } diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch.kt index d54601dae1..dd9f99a091 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch.kt @@ -39,18 +39,23 @@ abstract class BaseSettingsResourcePatch( } override fun close() { - fun Node.addPreference(preference: BasePreference) { - preference.serialize(ownerDocument) { resource -> + fun Node.addPreference(preference: BasePreference, addFirst: Boolean = false) { + val node = preference.serialize(ownerDocument) { resource -> // TODO: Currently, resources can only be added to "values", which may not be the correct place. // It may be necessary to ask for the desired resourceValue in the future. AddResourcesPatch("values", resource) - }.let(this::appendChild) + } + if (addFirst && firstChild != null) { + insertBefore(node, firstChild) + } else { + appendChild(node) + } } // Add the root preference to an existing fragment if needed. rootPreference?.let { (intentPreference, fragment) -> context.xmlEditor["res/xml/$fragment.xml"].use { - it.getNode("PreferenceScreen").addPreference(intentPreference) + it.getNode("PreferenceScreen").addPreference(intentPreference, true) } } diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt index 29bf976a8b..46007378da 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt @@ -27,15 +27,6 @@ abstract class BasePreferenceScreen( val categories: MutableSet = mutableSetOf() ) : BasePreferenceCollection(key, titleKey, preferences) { - /** - * Initialize using title and summary keys with suffix "_title" and "_summary". - */ - constructor( - key: String? = null, - preferences: MutableSet = mutableSetOf(), - categories: MutableSet = mutableSetOf() - ) : this(key, key + "_title", key + "_summary", preferences, categories) - override fun transform(): PreferenceScreen { return PreferenceScreen( key, diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt index 3c933a7299..dbc109ae86 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt @@ -1,19 +1,16 @@ package app.revanced.patches.shared.misc.settings.preference -import app.revanced.patches.shared.misc.settings.preference.IntentPreference.Intent import app.revanced.util.resource.BaseResource import org.w3c.dom.Document /** * A preference that opens an intent. * - * @param key The preference key. If null, other parameters must be specified. + * @param key Optional preference key. * @param titleKey The preference title key. * @param summaryKey The preference summary key. * @param tag The preference tag. * @param intent The intent to open. - * - * @see Intent */ class IntentPreference( key: String? = null, @@ -21,7 +18,7 @@ class IntentPreference( summaryKey: String? = "${key}_summary", tag: String = "Preference", val intent: Intent, -) : BasePreference(null, titleKey, summaryKey, tag) { +) : BasePreference(key, titleKey, summaryKey, tag) { override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = super.serialize(ownerDocument, resourceCallback).apply { diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt index d487bfeac3..109ac0fe96 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt @@ -43,7 +43,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c ] ) @Suppress("unused") -object HideAdsPatch : BytecodePatch() { +object HideAdsPatch : BytecodePatch(emptySet()) { override fun execute(context: BytecodeContext) { context.classes.forEach { classDef -> classDef.methods.forEach { method -> diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlBytecodePatch.kt index 9d23802f7b..f2dec9907b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlBytecodePatch.kt @@ -30,7 +30,7 @@ import app.revanced.patches.youtube.video.information.VideoInformationPatch ] ) @Suppress("unused") -object CopyVideoUrlBytecodePatch : BytecodePatch() { +object CopyVideoUrlBytecodePatch : BytecodePatch(emptySet()) { private const val INTEGRATIONS_PLAYER_PACKAGE = "Lapp/revanced/integrations/youtube/videoplayer" private val BUTTONS_DESCRIPTORS = listOf( "$INTEGRATIONS_PLAYER_PACKAGE/CopyVideoUrlButton;", diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt index 83a4456828..2c0afb1a8d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt @@ -22,7 +22,7 @@ internal object CopyVideoUrlResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( PreferenceScreen( "revanced_copy_video_url_preference_screen", preferences = setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt index e67cdb9f34..00702d7591 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt @@ -50,7 +50,9 @@ object RemoveViewerDiscretionDialogPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(SwitchPreference("revanced_remove_viewer_discretion_dialog")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( + SwitchPreference("revanced_remove_viewer_discretion_dialog") + ) CreateDialogFingerprint.result?.mutableMethod?.apply { val showDialogIndex = implementation!!.instructions.lastIndex - 2 diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsBytecodePatch.kt index 9a2bd645a6..1397aab3d5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsBytecodePatch.kt @@ -30,7 +30,7 @@ import app.revanced.patches.youtube.video.information.VideoInformationPatch ] ) @Suppress("unused") -object ExternalDownloadsBytecodePatch : BytecodePatch() { +object ExternalDownloadsBytecodePatch : BytecodePatch(emptySet()) { private const val BUTTON_DESCRIPTOR = "Lapp/revanced/integrations/youtube/videoplayer/ExternalDownloadButton;" override fun execute(context: BytecodeContext) { diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt index 656eb13de6..286ee49040 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt @@ -24,7 +24,7 @@ internal object ExternalDownloadsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( PreferenceScreen( "revanced_external_downloader_preference_screen", preferences = setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt index 6aebf707cf..a7cbd0a777 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt @@ -50,7 +50,7 @@ object DisablePreciseSeekingGesturePatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( + SettingsPatch.PreferenceScreen.SEEKBAR.addPreferences( SwitchPreference("revanced_disable_precise_seeking_gesture") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt index ed67a5eb20..2c831b5c52 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt @@ -51,7 +51,7 @@ object EnableSeekbarTappingPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(SwitchPreference("revanced_seekbar_tapping")) + SettingsPatch.PreferenceScreen.SEEKBAR.addPreferences(SwitchPreference("revanced_seekbar_tapping")) // Find the required methods to tap the seekbar. val seekbarTappingMethods = OnTouchEventHandlerFingerprint.result?.let { diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt index fc52fb5c3d..613cc99a0e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt @@ -50,7 +50,7 @@ object EnableSlideToSeekPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(SwitchPreference("revanced_slide_to_seek")) + SettingsPatch.PreferenceScreen.SEEKBAR.addPreferences(SwitchPreference("revanced_slide_to_seek")) arrayOf( // Restore the behaviour to slide to seek. diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt index de61545681..d0b396c02e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt @@ -19,7 +19,7 @@ internal object SwipeControlsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( PreferenceScreen( key = "revanced_swipe_controls_preference_screen", preferences = setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt index 80d33fd6fb..4c1fbd1c38 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt @@ -48,7 +48,7 @@ object AutoCaptionsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_auto_captions")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences(SwitchPreference("revanced_auto_captions")) mapOf( StartVideoInformerFingerprint to 0, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/ChangeHeaderPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/ChangeHeaderPatch.kt index 6f1e76a07c..ce225c61dd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/ChangeHeaderPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/ChangeHeaderPatch.kt @@ -75,7 +75,7 @@ object ChangeHeaderPatch : ResourcePatch() { } /** - * A function that overwrites both header variants from [from] to [to] in the target resource directories. + * A function that overwrites both header variants in the target resource directories. */ val overwriteFromTo: (String, String) -> Unit = { from: String, to: String -> targetResourceDirectories.forEach { directory -> diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt index ca9c19def7..68ab2b4b75 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt @@ -48,7 +48,7 @@ object HideButtonsPatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( PreferenceScreen( "revanced_hide_buttons_preference_screen", preferences = setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt index 79ee7e6a15..d8d8ac9350 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt @@ -57,7 +57,7 @@ object HideAutoplayButtonPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_autoplay_button")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences(SwitchPreference("revanced_hide_autoplay_button")) LayoutConstructorFingerprint.result?.mutableMethod?.apply { val layoutGenMethodInstructions = implementation!!.instructions diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt index 45fe579f88..c87cc826f2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt @@ -48,7 +48,7 @@ object HideCaptionsButtonPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_captions_button")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences(SwitchPreference("revanced_hide_captions_button")) val subtitleButtonControllerMethod = SubtitleButtonControllerFingerprint.result!!.mutableMethod diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt index ee1f6943a6..d2ffc1600b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt @@ -23,11 +23,11 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch CompatiblePackage("com.google.android.youtube") ] ) -object HideCastButtonPatch : BytecodePatch() { +object HideCastButtonPatch : BytecodePatch(emptySet()) { override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_cast_button")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences(SwitchPreference("revanced_hide_cast_button")) val buttonClass = context.findClass("MediaRouteButton") ?: throw PatchException("MediaRouteButton class not found.") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt index 71e7374d83..18c0be2226 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt @@ -57,7 +57,7 @@ object NavigationButtonsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_OTHER.addPreferences( PreferenceScreen( key = "revanced_navigation_buttons_preference_screen", preferences = setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt index bf52cb063c..77e8049144 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt @@ -52,7 +52,7 @@ object HidePlayerButtonsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_player_buttons")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences(SwitchPreference("revanced_hide_player_buttons")) PlayerControlsVisibilityModelFingerprint.result?.apply { val callIndex = scanResult.patternScanResult!!.endIndex diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt index e05b3e8b61..61861dcaad 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt @@ -21,7 +21,7 @@ internal object AlbumCardsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_album_cards")) + SettingsPatch.PreferenceScreen.LAYOUT_FEED.addPreferences(SwitchPreference("revanced_hide_album_cards")) albumCardId = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "album_card" 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 index 31fb0b4a56..73c6c65d25 100644 --- 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 @@ -21,7 +21,7 @@ internal object BreakingNewsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_breaking_news")) + SettingsPatch.PreferenceScreen.LAYOUT_FEED.addPreferences(SwitchPreference("revanced_hide_breaking_news")) horizontalCardListId = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "horizontal_card_list" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt index ee2a941154..4145995481 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt @@ -47,7 +47,7 @@ object CommentsPatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( PreferenceScreen( "revanced_comments_preference_screen", preferences = setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt index 0ce74f7f02..22f8e71b93 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt @@ -21,7 +21,7 @@ internal object CrowdfundingBoxResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_crowdfunding_box")) + SettingsPatch.PreferenceScreen.LAYOUT_FEED.addPreferences(SwitchPreference("revanced_hide_crowdfunding_box")) crowdfundingBoxId = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "donation_companion" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt index 6f601391ef..650d716587 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt @@ -23,7 +23,7 @@ internal object HideEndscreenCardsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_endscreen_cards")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences(SwitchPreference("revanced_hide_endscreen_cards")) fun findEndscreenResourceId(name: String) = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "endscreen_element_layout_$name" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt index 70ef188f5a..87f97aa6f2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt @@ -18,7 +18,7 @@ internal object HideFilterBarResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_FEED.addPreferences( PreferenceScreen( key = "revanced_hide_filter_bar_preference", preferences = setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt index 92f8f42347..88d4087e9c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt @@ -22,7 +22,7 @@ internal object HideFloatingMicrophoneButtonResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_floating_microphone_button")) + SettingsPatch.PreferenceScreen.LAYOUT_OTHER.addPreferences(SwitchPreference("revanced_hide_floating_microphone_button")) fabButtonId = ResourceMappingPatch.resourceMappings.find { it.type == "id" && it.name == "fab" }?.id ?: throw PatchException("Can not find required fab button resource id") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt index 0825d7864a..5bd117576b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt @@ -45,7 +45,7 @@ object DisableFullscreenAmbientModePatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( SwitchPreference("revanced_disable_fullscreen_ambient_mode") ) 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 de05d88594..91174c79be 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 @@ -68,37 +68,14 @@ object HideLayoutComponentsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference("revanced_hide_gray_separator"), - SwitchPreference("revanced_hide_join_membership_button"), - SwitchPreference("revanced_hide_channel_watermark"), - SwitchPreference("revanced_hide_for_you_shelf"), - SwitchPreference("revanced_hide_notify_me_button"), - SwitchPreference("revanced_hide_timed_reactions"), - SwitchPreference("revanced_hide_search_result_recommendations"), - SwitchPreference("revanced_hide_search_result_shelf_header"), + PreferenceScreen.LAYOUT_PLAYER.addPreferences( + SwitchPreference("revanced_hide_channel_bar"), SwitchPreference("revanced_hide_channel_guidelines"), - SwitchPreference("revanced_hide_expandable_chip"), - SwitchPreference("revanced_hide_video_quality_menu_footer"), - SwitchPreference("revanced_hide_chapters"), - SwitchPreference("revanced_hide_community_posts"), - SwitchPreference("revanced_hide_compact_banner"), - SwitchPreference("revanced_hide_movies_section"), - SwitchPreference("revanced_hide_feed_survey"), - SwitchPreference("revanced_hide_community_guidelines"), - SwitchPreference("revanced_hide_subscribers_community_guidelines"), SwitchPreference("revanced_hide_channel_member_shelf"), - SwitchPreference("revanced_hide_emergency_box"), - SwitchPreference("revanced_hide_info_panels"), - SwitchPreference("revanced_hide_medical_panels"), - SwitchPreference("revanced_hide_channel_bar"), - SwitchPreference("revanced_hide_quick_actions"), - SwitchPreference("revanced_hide_related_videos"), - SwitchPreference("revanced_hide_image_shelf"), - SwitchPreference("revanced_hide_latest_posts_ads"), - SwitchPreference("revanced_hide_mix_playlists"), - SwitchPreference("revanced_hide_artist_cards"), + SwitchPreference("revanced_hide_channel_watermark"), + SwitchPreference("revanced_hide_chapters"), SwitchPreference("revanced_hide_chips_shelf"), + SwitchPreference("revanced_hide_community_guidelines"), app.revanced.patches.shared.misc.settings.preference.PreferenceScreen( "revanced_hide_description_components_preference_screen", preferences = setOf( @@ -109,6 +86,35 @@ object HideLayoutComponentsPatch : BytecodePatch( SwitchPreference("revanced_hide_transcript_section"), ) ), + SwitchPreference("revanced_hide_emergency_box"), + SwitchPreference("revanced_hide_expandable_chip"), + SwitchPreference("revanced_hide_gray_separator"), + SwitchPreference("revanced_hide_info_panels"), + SwitchPreference("revanced_hide_medical_panels"), + SwitchPreference("revanced_hide_quick_actions"), + SwitchPreference("revanced_hide_related_videos"), + SwitchPreference("revanced_hide_subscribers_community_guidelines"), + SwitchPreference("revanced_hide_timed_reactions"), + SwitchPreference("revanced_hide_video_quality_menu_footer"), + ) + + PreferenceScreen.LAYOUT_FEED.addPreferences( + SwitchPreference("revanced_hide_artist_cards"), + SwitchPreference("revanced_hide_community_posts"), + SwitchPreference("revanced_hide_compact_banner"), + SwitchPreference("revanced_hide_feed_survey"), + SwitchPreference("revanced_hide_for_you_shelf"), + SwitchPreference("revanced_hide_image_shelf"), + SwitchPreference("revanced_hide_join_membership_button"), + SwitchPreference("revanced_hide_latest_posts_ads"), + SwitchPreference("revanced_hide_mix_playlists"), + SwitchPreference("revanced_hide_movies_section"), + SwitchPreference("revanced_hide_notify_me_button"), + SwitchPreference("revanced_hide_search_result_recommendations"), + SwitchPreference("revanced_hide_search_result_shelf_header"), + ) + + PreferenceScreen.LAYOUT_OTHER.addPreferences( app.revanced.patches.shared.misc.settings.preference.PreferenceScreen( "revanced_custom_filter_preference_screen", preferences = setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt index cde96076d7..9275ef20f1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt @@ -21,7 +21,7 @@ object HideInfocardsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_info_cards")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences(SwitchPreference("revanced_hide_info_cards")) drawerResourceId = ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == "info_cards_drawer_header" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt index 4ab73f3a3b..a054b835b9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt @@ -21,7 +21,7 @@ internal object HideLoadMoreButtonResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_load_more_button")) + SettingsPatch.PreferenceScreen.LAYOUT_FEED.addPreferences(SwitchPreference("revanced_hide_load_more_button")) expandButtonDownId = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "expand_button_down" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt index 1185ba7fd6..2f4c130222 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt @@ -50,7 +50,7 @@ object HidePlayerFlyoutMenuPatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( PreferenceScreen( key = KEY, preferences = setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt index 70fde81be6..352114bdcd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt @@ -49,7 +49,7 @@ object DisableRollingNumberAnimationPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( SwitchPreference("revanced_disable_rolling_number_animations") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt index 263b7bad69..588367fd34 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt @@ -8,7 +8,6 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.seekbar.SeekbarColorBytecodePatch -import app.revanced.patches.youtube.layout.seekbar.SeekbarPreferencesPatch import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.shared.fingerprints.SeekbarFingerprint @@ -21,7 +20,6 @@ import app.revanced.patches.youtube.shared.fingerprints.SeekbarOnDrawFingerprint IntegrationsPatch::class, SettingsPatch::class, SeekbarColorBytecodePatch::class, - SeekbarPreferencesPatch::class, AddResourcesPatch::class ], compatiblePackages = [ @@ -51,7 +49,7 @@ object HideSeekbarPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SeekbarPreferencesPatch.addPreferences( + SettingsPatch.PreferenceScreen.SEEKBAR.addPreferences( SwitchPreference("revanced_hide_seekbar"), SwitchPreference("revanced_hide_seekbar_thumbnail") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt index b9f411fea1..83528f34bf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt @@ -5,7 +5,6 @@ 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.PreferenceScreen import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @@ -17,24 +16,19 @@ object HideShortsComponentsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - PreferenceScreen( - "revanced_shorts_preference_screen", - preferences = setOf( - SwitchPreference("revanced_hide_shorts"), - SwitchPreference("revanced_hide_shorts_join_button"), - SwitchPreference("revanced_hide_shorts_subscribe_button"), - SwitchPreference("revanced_hide_shorts_subscribe_button_paused"), - SwitchPreference("revanced_hide_shorts_thanks_button"), - SwitchPreference("revanced_hide_shorts_comments_button"), - SwitchPreference("revanced_hide_shorts_remix_button"), - SwitchPreference("revanced_hide_shorts_share_button"), - SwitchPreference("revanced_hide_shorts_info_panel"), - SwitchPreference("revanced_hide_shorts_channel_bar"), - SwitchPreference("revanced_hide_shorts_sound_button"), - SwitchPreference("revanced_hide_shorts_navigation_bar") - ) - ) + SettingsPatch.PreferenceScreen.SHORTS.addPreferences( + SwitchPreference("revanced_hide_shorts"), + SwitchPreference("revanced_hide_shorts_join_button"), + SwitchPreference("revanced_hide_shorts_subscribe_button"), + SwitchPreference("revanced_hide_shorts_subscribe_button_paused"), + SwitchPreference("revanced_hide_shorts_thanks_button"), + SwitchPreference("revanced_hide_shorts_comments_button"), + SwitchPreference("revanced_hide_shorts_remix_button"), + SwitchPreference("revanced_hide_shorts_share_button"), + SwitchPreference("revanced_hide_shorts_info_panel"), + SwitchPreference("revanced_hide_shorts_channel_bar"), + SwitchPreference("revanced_hide_shorts_sound_button"), + SwitchPreference("revanced_hide_shorts_navigation_bar") ) ResourceMappingPatch.resourceMappings.find { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt index b190b321d3..dfc367c208 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt @@ -21,7 +21,7 @@ internal object DisableSuggestedVideoEndScreenResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( SwitchPreference("revanced_disable_suggested_video_end_screen") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt index 673816e39a..8f461d9015 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt @@ -42,7 +42,7 @@ object HideTimestampPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_timestamp")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences(SwitchPreference("revanced_hide_timestamp")) TimeCounterFingerprint.result?.apply { mutableMethod.addInstructionsWithLabels( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt index eaf67270e4..a3f403308d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt @@ -43,7 +43,7 @@ object PlayerPopupPanelsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_player_popup_panels")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences(SwitchPreference("revanced_hide_player_popup_panels")) val engagementPanelControllerMethod = EngagementPanelControllerFingerprint .result?.mutableMethod ?: throw EngagementPanelControllerFingerprint.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt index a409030c4b..c062be3dd5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt @@ -18,7 +18,7 @@ internal object CustomPlayerOverlayOpacityResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences( TextPreference("revanced_player_overlay_opacity", inputType = InputType.NUMBER) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt index 848b86af6e..28c6e495df 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt @@ -7,6 +7,7 @@ import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.shared.misc.settings.preference.IntentPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.patches.youtube.misc.settings.SettingsResourcePatch @Patch( dependencies = [ @@ -20,11 +21,11 @@ internal object ReturnYouTubeDislikeResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - IntentPreference( - "revanced_ryd_settings", - intent = SettingsPatch.newIntent("revanced_ryd_settings_intent") - ) + SettingsResourcePatch += IntentPreference( + key = "revanced_setting_screen_07", + titleKey = "revanced_ryd_settings_title", + summaryKey = null, + intent = SettingsPatch.newIntent("revanced_ryd_settings_intent") ) AddResourcesPatch(this::class) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt index 5fe87e4fa2..b9981d9e36 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt @@ -54,7 +54,7 @@ object WideSearchbarPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_wide_searchbar")) + SettingsPatch.PreferenceScreen.LAYOUT_FEED.addPreferences(SwitchPreference("revanced_wide_searchbar")) val result = CreateSearchSuggestionsFingerprint.result ?: throw CreateSearchSuggestionsFingerprint.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt index 665190fd4f..39ebc153e9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt @@ -10,12 +10,13 @@ import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.seekbar.fingerprints.FullscreenSeekbarThumbnailsFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch +import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.exception @Patch( name = "Restore old seekbar thumbnails", description = "Adds an option to restore the old seekbar thumbnails that appear above the seekbar while seeking instead of fullscreen thumbnails.", - dependencies = [IntegrationsPatch::class, SeekbarPreferencesPatch::class, AddResourcesPatch::class], + dependencies = [IntegrationsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -45,7 +46,7 @@ object RestoreOldSeekbarThumbnailsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SeekbarPreferencesPatch.addPreferences(SwitchPreference("revanced_restore_old_seekbar_thumbnails")) + SettingsPatch.PreferenceScreen.SEEKBAR.addPreferences(SwitchPreference("revanced_restore_old_seekbar_thumbnails")) FullscreenSeekbarThumbnailsFingerprint.result?.mutableMethod?.apply { val moveResultIndex = getInstructions().lastIndex - 1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt deleted file mode 100644 index 0a9f7e27db..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt +++ /dev/null @@ -1,34 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar - -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.BasePreference -import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen -import app.revanced.patches.youtube.misc.settings.SettingsPatch -import java.io.Closeable - -@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class]) -internal object SeekbarPreferencesPatch : ResourcePatch(), Closeable { - private val seekbarPreferences = mutableSetOf() - - override fun execute(context: ResourceContext) { - // Nothing to do here. All work is done in close method. - } - - override fun close() { - AddResourcesPatch(this::class) - - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - PreferenceScreen( - "revanced_seekbar_preference_screen", - preferences = seekbarPreferences, - ) - ) - } - - internal fun addPreferences(vararg preferencesToAdd: BasePreference) = - seekbarPreferences.addAll(preferencesToAdd) -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt index a8c347b2c7..14dd3a6487 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt @@ -8,6 +8,7 @@ import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.shared.misc.settings.preference.IntentPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.patches.youtube.misc.settings.SettingsResourcePatch import app.revanced.util.ResourceGroup import app.revanced.util.copyResources import app.revanced.util.copyXmlNode @@ -25,12 +26,13 @@ internal object SponsorBlockResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - IntentPreference( - "revanced_sb_settings", - intent = SettingsPatch.newIntent("revanced_sb_settings_intent") - ) + SettingsResourcePatch += IntentPreference( + key = "revanced_setting_screen_08", + titleKey = "revanced_sb_settings_title", + summaryKey = null, + intent = SettingsPatch.newIntent("revanced_sb_settings_intent") ) + arrayOf( ResourceGroup( "layout", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt index 8ac797111a..3cd390c06a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt @@ -49,7 +49,7 @@ object SpoofAppVersionPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_OTHER.addPreferences( SwitchPreference("revanced_spoof_app_version"), ListPreference( key = "revanced_spoof_app_version_target", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt index 9016385ad6..53e1ca1392 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt @@ -33,7 +33,7 @@ object ChangeStartPagePatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_OTHER.addPreferences( ListPreference( key = "revanced_start_page", summaryKey = null, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt index 1cf63fc002..425adf111b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt @@ -56,7 +56,7 @@ object DisableResumingShortsOnStartupPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.SHORTS.addPreferences( SwitchPreference("revanced_disable_resuming_shorts_player") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt index 10dadae37a..edd4140910 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt @@ -28,7 +28,7 @@ object EnableTabletLayoutPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_tablet_layout")) + SettingsPatch.PreferenceScreen.LAYOUT_OTHER.addPreferences(SwitchPreference("revanced_tablet_layout")) GetFormFactorFingerprint.result?.let { it.mutableMethod.apply { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt index e50e1a24b8..6f6fc4e0c8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt @@ -55,7 +55,7 @@ object TabletMiniPlayerPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_tablet_miniplayer")) + SettingsPatch.PreferenceScreen.LAYOUT_OTHER.addPreferences(SwitchPreference("revanced_tablet_miniplayer")) // First resolve the fingerprints via the parent fingerprint. MiniPlayerDimensionsCalculatorParentFingerprint.result @@ -127,7 +127,7 @@ object TabletMiniPlayerPatch : BytecodePatch( ) } - fun MethodFingerprint.unwrap(): Triple { + private fun MethodFingerprint.unwrap(): Triple { val result = this.result!! val scanIndex = result.scanResult.patternScanResult!!.endIndex val method = result.mutableMethod diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt index be9aaaea50..b9f13ddae7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt @@ -100,7 +100,7 @@ object ThemeBytecodePatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_gradient_loading_screen")) + SettingsPatch.PreferenceScreen.LAYOUT_PLAYER.addPreferences(SwitchPreference("revanced_gradient_loading_screen")) UseGradientLoadingScreenFingerprint.result?.mutableMethod?.apply { val isEnabledIndex = indexOfFirstWideLiteralInstructionValue(GRADIENT_LOADING_SCREEN_AB_CONSTANT) + 3 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt index d379514e2e..f66f6da1aa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt @@ -9,7 +9,6 @@ import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.shared.misc.settings.preference.InputType import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.shared.misc.settings.preference.TextPreference -import app.revanced.patches.youtube.layout.seekbar.SeekbarPreferencesPatch import app.revanced.patches.youtube.layout.theme.ThemeBytecodePatch.darkThemeBackgroundColor import app.revanced.patches.youtube.layout.theme.ThemeBytecodePatch.lightThemeBackgroundColor import app.revanced.patches.youtube.misc.settings.SettingsPatch @@ -19,7 +18,6 @@ import org.w3c.dom.Element dependencies = [ SettingsPatch::class, ResourceMappingPatch::class, - SeekbarPreferencesPatch::class, AddResourcesPatch::class ] ) @@ -29,7 +27,7 @@ internal object ThemeResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) - SeekbarPreferencesPatch.addPreferences( + SettingsPatch.PreferenceScreen.SEEKBAR.addPreferences( SwitchPreference("revanced_seekbar_custom_color"), TextPreference("revanced_seekbar_custom_color_value", inputType = InputType.TEXT_CAP_CHARACTERS) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt index 2bda4802ae..9049800054 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt @@ -121,7 +121,7 @@ object AlternativeThumbnailsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SettingsPatch.PreferenceScreen.LAYOUT_FEED.addPreferences( PreferenceScreen( "revanced_alt_thumbnail_preference_screen", preferences = setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt index 2181994778..5e871159e1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt @@ -45,7 +45,9 @@ object SpoofDeviceDimensionsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) - SettingsPatch.PreferenceScreen.MISC.addPreferences(SwitchPreference("revanced_spoof_device_dimensions",)) + SettingsPatch.PreferenceScreen.MISC.addPreferences( + SwitchPreference("revanced_spoof_device_dimensions") + ) DeviceDimensionsModelToStringFingerprint.result ?.mutableClass?.methods?.find { method -> method.name == "" } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt index dd33c86373..7b53d62ad3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt @@ -104,11 +104,19 @@ object SettingsPatch : BytecodePatch( } object PreferenceScreen : BasePreferenceScreen() { - val ADS = Screen("revanced_ads_screen") - val INTERACTIONS = Screen("revanced_interactions_screen") - val LAYOUT = Screen("revanced_layout_screen") - val VIDEO = Screen("revanced_video_screen") - val MISC = Screen("revanced_misc_screen") + // Screens are sorted in the UI by the screen key. + // This is done because alphabetical ordering scatters related items apart, + // and there is no way to specify an ordering here without refactoring other code. + // Screens are bundled only if one or more preference is added during patching. + val ADS = Screen("revanced_setting_screen_01", "revanced_ads_screen_title", null) + val LAYOUT_FEED = Screen("revanced_setting_screen_02", "revanced_layout_feed_screen_title", null) + val LAYOUT_PLAYER = Screen("revanced_setting_screen_03", "revanced_layout_player_screen_title", null) + val LAYOUT_OTHER = Screen("revanced_setting_screen_04", "revanced_layout_other_screen_title", null) + val SHORTS = Screen("revanced_setting_screen_05", "revanced_shorts_screen_title", null) + val SEEKBAR = Screen("revanced_setting_screen_06", "revanced_seekbar_screen_title", null) + // RYD and SB are items 7 and 8,and use an Intent preference as they have their own custom Integrations fragments. + val MISC = Screen("revanced_setting_screen_09", "revanced_misc_screen_title", null) + val VIDEO = Screen("revanced_setting_screen_10", "revanced_video_screen_title", null) override fun commit(screen: app.revanced.patches.shared.misc.settings.preference.PreferenceScreen) { SettingsResourcePatch += screen diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt index b4b50461aa..4a6ae9348d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt @@ -1,6 +1,7 @@ package app.revanced.patches.youtube.misc.settings import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.PatchException import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.shared.misc.settings.BaseSettingsResourcePatch @@ -11,7 +12,9 @@ import org.w3c.dom.Element object SettingsResourcePatch : BaseSettingsResourcePatch( IntentPreference( - "revanced_settings", + null, + "revanced_settings_title", + null, intent = SettingsPatch.newIntent("revanced_settings_intent") ) to "settings_fragment", dependencies = setOf( @@ -38,9 +41,28 @@ object SettingsResourcePatch : BaseSettingsResourcePatch( context.copyResources("settings", resourceGroup) } + // Remove horizontal divider from the settings Preferences + // To better match the appearance of the stock YouTube settings. + context.xmlEditor["res/values/styles.xml"].use { editor -> + val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element + + val listDividerNode = editor.file.createElement("item") + listDividerNode.setAttribute("name", "android:listDivider") + listDividerNode.appendChild(editor.file.createTextNode("@null")) + + for (i in 0 until resourcesNode.childNodes.length) { + val node = resourcesNode.childNodes.item(i) as? Element ?: continue + val name = node.getAttribute("name") + if (name == "Theme.YouTube.Settings" || name == "Theme.YouTube.Settings.Dark") { + node.appendChild(listDividerNode) + } + } + } + // Modify the manifest and add a data intent filter to the LicenseActivity. // Some devices freak out if undeclared data is passed to an intent, // and this change appears to fix the issue. + var modifiedIntent = false context.xmlEditor["AndroidManifest.xml"].use { editor -> // A xml regular-expression would probably work better than this manual searching. val manifestNodes = editor.file.getElementsByTagName("manifest").item(0).childNodes @@ -58,11 +80,14 @@ object SettingsResourcePatch : BaseSettingsResourcePatch( mimeType.setAttribute("android:mimeType", "text/plain") intentFilter.appendChild(mimeType) applicationChild.appendChild(intentFilter) + modifiedIntent = true break } } } } } + + if (!modifiedIntent) throw PatchException("Could not modify activity intent") } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt index 07be6f2eb9..bceb7d6be3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt @@ -26,7 +26,7 @@ import app.revanced.patches.youtube.video.speed.remember.RememberPlaybackSpeedPa ] ) @Suppress("unused") -object PlaybackSpeedPatch : BytecodePatch() { +object PlaybackSpeedPatch : BytecodePatch(emptySet()) { override fun execute(context: BytecodeContext) { // All patches this patch depends on succeed. } diff --git a/src/main/resources/addresources/values/strings.xml b/src/main/resources/addresources/values/strings.xml index fbda6995cb..2a5750b96c 100644 --- a/src/main/resources/addresources/values/strings.xml +++ b/src/main/resources/addresources/values/strings.xml @@ -28,21 +28,18 @@ ReVanced - ReVanced specific settings Import / Export Import / Export ReVanced settings Ads - Ad related settings - Interactions - Settings related to interactions - Layout - Settings related to the layout - Video - Settings related to the video player + Feed layout + Player layout + Other layout + Shorts + Seekbar Misc - Miscellaneous patches + Video Debug logging @@ -478,7 +475,6 @@ Thumbnail seekbar is shown - Shorts components Hide Shorts in feed Shorts are hidden Shorts are shown @@ -515,7 +511,6 @@ Hide navigation bar Navigation bar is hidden Navigation bar is shown - Manage the visibility of Shorts components Disable suggested video end screen @@ -538,7 +533,6 @@ Return YouTube Dislike - Settings for Return YouTube Dislike Hidden Dislikes temporarily not available (API timed out) Dislikes not available (status %d) @@ -594,13 +588,8 @@ Seekbar thumbnails will appear above the seekbar Seekbar thumbnails will appear in fullscreen - - Seekbar - Settings for the seekbar - SponsorBlock - SponsorBlock related settings Enable SponsorBlock SponsorBlock is a crowd-sourced system for skipping annoying parts of YouTube videos Appearance