From dcd3ad3d39e69431bc7df3267a7e30b7717c6955 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:13:14 +0400 Subject: [PATCH] Rearrange settings --- .../impl/NonInteractivePreference.kt | 6 +- .../thumbnails/AlternativeThumbnailsPatch.kt | 86 +++++++++---------- 2 files changed, 45 insertions(+), 47 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt index 1f33084dc40..ef08bc3e2f7 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt @@ -14,13 +14,15 @@ import org.w3c.dom.Element * * @param title The title of the preference. * @param summary The summary of the text preference. - * @param selectable If this preference is selectable or not. - * Changes the appearance of the horizontal dividers on top/bottom. + * @param selectable If this preference responds to tapping. + * Setting to 'true' restores the horizontal dividers on the top and bottom, + * but tapping will still do nothing since this Preference has no key. */ class NonInteractivePreference( title: StringResource, summary: StringResource?, tag: String = "Preference", + // If androidx.preference is later used, this can be changed to the show top/bottom dividers feature. val selectable: Boolean = false ) : BasePreference(null, title, summary, tag) { override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit): Element { 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 543635bcb62..a7628a54cc8 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 @@ -107,6 +107,46 @@ object AlternativeThumbnailsPatch : BytecodePatch( null, // Summary is dynamically updated based on the current settings. tag = "app.revanced.integrations.settingsmenu.AlternativeThumbnailsStatusPreference" ), + SwitchPreference( + "revanced_alt_thumbnails_dearrow", + StringResource("revanced_alt_thumbnails_dearrow_title", "Enable DeArrow"), + StringResource("revanced_alt_thumbnails_dearrow_summary_on", "Using DeArrow"), + StringResource("revanced_alt_thumbnails_dearrow_summary_off", "Not using DeArrow") + ), + SwitchPreference( + "revanced_alt_thumbnails_dearrow_connection_toast", + StringResource("revanced_alt_thumbnails_dearrow_connection_toast_title", "Show toast if API is not available"), + StringResource("revanced_alt_thumbnails_dearrow_connection_toast_summary_on", "Toast shown if DeArrow is not available"), + StringResource("revanced_alt_thumbnails_dearrow_connection_toast_summary_off", "Toast not shown if DeArrow is not available") + ), + TextPreference( + "revanced_alt_thumbnails_dearrow_api_url", + StringResource( + "revanced_alt_thumbnails_dearrow_api_url_title", + "DeArrow Thumbnail Cache Endpoint" + ), + StringResource( + "revanced_alt_thumbnails_dearrow_api_url_summary", + "The URL of the DeArrow thumbnail cache endpoint. " + + "Do not change this unless you know what you\\\'re doing" + ), + ), + NonInteractivePreference( + StringResource( + "revanced_alt_thumbnails_dearrow_about_title", + "About DeArrow" + ), + StringResource( + "revanced_alt_thumbnails_dearrow_about_summary", + "DeArrow provides crowd sourced thumbnails for YouTube videos. " + + "These thumbnails are often more relevant than those provided by YouTube. " + + "If enabled, video URLs will be sent to the API server and no other data is sent" + + "\\n\\nTap here to learn more about DeArrow" + ), + // Custom about preference with link to the DeArrow website. + tag = "app.revanced.integrations.settingsmenu.AlternativeThumbnailsAboutDeArrowPreference", + selectable = true + ), SwitchPreference( "revanced_alt_thumbnails_stills", StringResource("revanced_alt_thumbnails_stills_title", "Enable still video captures"), @@ -160,52 +200,8 @@ object AlternativeThumbnailsPatch : BytecodePatch( "Still captures are taken from the beginning/middle/end of each video. " + "These images are built into YouTube, and no external API is used" ), - // When a Preference is set to non selectable it loses its horizontal dividers on the top and bottom. - // This looks ok when the preference is at the bottom, but looks weird when it's in the middle of a list. - // - // Restoring the divider is simple when using androidx.Preference, - // but there is no simple way to do this for the old legacy Preference used here. - // Instead make this selectable so the UI looks more normal. + // Restore the preference dividers to keep it from looking weird. selectable = true - ), - SwitchPreference( - "revanced_alt_thumbnails_dearrow", - StringResource("revanced_alt_thumbnails_dearrow_title", "Enable DeArrow"), - StringResource("revanced_alt_thumbnails_dearrow_summary_on", "Using DeArrow"), - StringResource("revanced_alt_thumbnails_dearrow_summary_off", "Not using DeArrow") - ), - SwitchPreference( - "revanced_alt_thumbnails_dearrow_connection_toast", - StringResource("revanced_alt_thumbnails_dearrow_connection_toast_title", "Show toast if API is not available"), - StringResource("revanced_alt_thumbnails_dearrow_connection_toast_summary_on", "Toast shown if DeArrow is not available"), - StringResource("revanced_alt_thumbnails_dearrow_connection_toast_summary_off", "Toast not shown if DeArrow is not available") - ), - TextPreference( - "revanced_alt_thumbnails_dearrow_api_url", - StringResource( - "revanced_alt_thumbnails_dearrow_api_url_title", - "DeArrow Thumbnail Cache Endpoint" - ), - StringResource( - "revanced_alt_thumbnails_dearrow_api_url_summary", - "The URL of the DeArrow thumbnail cache endpoint. " + - "Do not change this unless you know what you\\\'re doing" - ), - ), - NonInteractivePreference( - StringResource( - "revanced_alt_thumbnails_dearrow_about_title", - "About DeArrow" - ), - StringResource( - "revanced_alt_thumbnails_dearrow_about_summary", - "DeArrow provides crowd sourced thumbnails for YouTube videos. " + - "These thumbnails are often more relevant than those provided by YouTube. " + - "If enabled, video URLs will be sent to the API server and no other data is sent" - + "\\n\\nTap here to learn more about DeArrow" - ), - // Custom preference to open the DeArrow website. - tag = "app.revanced.integrations.settingsmenu.AlternativeThumbnailsAboutDeArrowPreference" ) ), StringResource("revanced_alt_thumbnails_preference_screen_summary", "Video thumbnail settings")