fix(youtube/general-ads): move settings to correct preference screens

This commit is contained in:
oSumAtrIX 2023-01-07 04:03:14 +01:00
parent 03f28404ab
commit cde45fca76
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4

View file

@ -7,22 +7,21 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.shared.settings.preference.impl.InputType import app.revanced.patches.shared.settings.preference.impl.*
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.TextPreference
import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility
import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.PreferenceScreen import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.PreferenceScreen
@DependsOn(dependencies = [ @DependsOn(
FixLocaleConfigErrorPatch::class, dependencies = [
LithoFilterPatch::class, FixLocaleConfigErrorPatch::class,
SettingsPatch::class, LithoFilterPatch::class,
ResourceMappingPatch::class SettingsPatch::class,
]) ResourceMappingPatch::class
]
)
@GeneralAdsCompatibility @GeneralAdsCompatibility
@Version("0.0.1") @Version("0.0.1")
class GeneralAdsResourcePatch : ResourcePatch { class GeneralAdsResourcePatch : ResourcePatch {
@ -32,20 +31,42 @@ class GeneralAdsResourcePatch : ResourcePatch {
} }
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext): PatchResult {
PreferenceScreen.ADS.addPreferences( PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference( SwitchPreference(
"revanced_adremover_ad_removal", "revanced_adremover_separator",
StringResource("revanced_adremover_ad_removal_enabled_title", "Hide general ads"), StringResource("revanced_adremover_separator_title", "Hide gray separator"),
true, true,
StringResource("revanced_adremover_ad_removal_enabled_summary_on", "General ads are hidden"), StringResource("revanced_adremover_separator_summary_on", "Gray separators are hidden"),
StringResource("revanced_adremover_ad_removal_enabled_summary_off", "General ads are shown") StringResource("revanced_adremover_separator_summary_off", "Gray separators are shown")
), ),
SwitchPreference( SwitchPreference(
"revanced_adremover_buttoned", "revanced_adremover_hide_channel_guidelines",
StringResource("revanced_adremover_buttoned_enabled_title", "Hide buttoned ad"), StringResource("revanced_adremover_hide_channel_guidelines_enabled_title", "Hide channel guidelines"),
true, true,
StringResource("revanced_adremover_buttoned_enabled_summary_on", "Buttoned ads are hidden"), StringResource(
StringResource("revanced_adremover_buttoned_enabled_summary_off", "Buttoned ads are shown") "revanced_adremover_hide_channel_guidelines_enabled_summary_on",
"Channel guidelines are hidden"
),
StringResource(
"revanced_adremover_hide_channel_guidelines_enabled_summary_off",
"Channel guidelines are shown"
)
),
SwitchPreference(
"revanced_adremover_chapter_teaser",
StringResource(
"revanced_adremover_chapter_teaser_enabled_title",
"Hide chapter teaser under videos"
),
true,
StringResource(
"revanced_adremover_chapter_teaser_enabled_summary_on",
"Chapter teasers are hidden"
),
StringResource(
"revanced_adremover_chapter_teaser_enabled_summary_off",
"Chapter teasers are shown"
)
), ),
SwitchPreference( SwitchPreference(
"revanced_adremover_merchandise", "revanced_adremover_merchandise",
@ -104,17 +125,32 @@ class GeneralAdsResourcePatch : ResourcePatch {
), ),
SwitchPreference( SwitchPreference(
"revanced_adremover_subscribers_community_guidelines_removal", "revanced_adremover_subscribers_community_guidelines_removal",
StringResource("revanced_adremover_subscribers_community_guidelines_enabled_title", "Hide subscribers community guidelines"), StringResource(
"revanced_adremover_subscribers_community_guidelines_enabled_title",
"Hide subscribers community guidelines"
),
true, true,
StringResource("revanced_adremover_subscribers_community_guidelines_enabled_summary_on", "Subscribers community guidelines are hidden"), StringResource(
StringResource("revanced_adremover_subscribers_community_guidelines_enabled_summary_off", "Subscribers community guidelines are shown") "revanced_adremover_subscribers_community_guidelines_enabled_summary_on",
"Subscribers community guidelines are hidden"
),
StringResource(
"revanced_adremover_subscribers_community_guidelines_enabled_summary_off",
"Subscribers community guidelines are shown"
)
), ),
SwitchPreference( SwitchPreference(
"revanced_adremover_channel_member_shelf_removal", "revanced_adremover_channel_member_shelf_removal",
StringResource("revanced_adremover_channel_member_shelf_enabled_title", "Hide channel member shelf"), StringResource("revanced_adremover_channel_member_shelf_enabled_title", "Hide channel member shelf"),
true, true,
StringResource("revanced_adremover_channel_member_shelf_enabled_summary_on", "Channel member shelf is hidden"), StringResource(
StringResource("revanced_adremover_channel_member_shelf_enabled_summary_off", "Channel member shelf is shown") "revanced_adremover_channel_member_shelf_enabled_summary_on",
"Channel member shelf is hidden"
),
StringResource(
"revanced_adremover_channel_member_shelf_enabled_summary_off",
"Channel member shelf is shown"
)
), ),
SwitchPreference( SwitchPreference(
"revanced_adremover_emergency_box_removal", "revanced_adremover_emergency_box_removal",
@ -137,6 +173,23 @@ class GeneralAdsResourcePatch : ResourcePatch {
StringResource("revanced_adremover_medical_panel_enabled_summary_on", "Medical panels are hidden"), StringResource("revanced_adremover_medical_panel_enabled_summary_on", "Medical panels are hidden"),
StringResource("revanced_adremover_medical_panel_enabled_summary_off", "Medical panels are shown") StringResource("revanced_adremover_medical_panel_enabled_summary_off", "Medical panels are shown")
), ),
)
PreferenceScreen.ADS.addPreferences(
SwitchPreference(
"revanced_adremover_ad_removal",
StringResource("revanced_adremover_ad_removal_enabled_title", "Hide general ads"),
true,
StringResource("revanced_adremover_ad_removal_enabled_summary_on", "General ads are hidden"),
StringResource("revanced_adremover_ad_removal_enabled_summary_off", "General ads are shown")
),
SwitchPreference(
"revanced_adremover_buttoned",
StringResource("revanced_adremover_buttoned_enabled_title", "Hide buttoned ad"),
true,
StringResource("revanced_adremover_buttoned_enabled_summary_on", "Buttoned ads are hidden"),
StringResource("revanced_adremover_buttoned_enabled_summary_off", "Buttoned ads are shown")
),
SwitchPreference( SwitchPreference(
"revanced_adremover_paid_content", "revanced_adremover_paid_content",
StringResource("revanced_adremover_paid_content_enabled_title", "Hide paid content"), StringResource("revanced_adremover_paid_content_enabled_title", "Hide paid content"),
@ -158,19 +211,6 @@ class GeneralAdsResourcePatch : ResourcePatch {
StringResource("revanced_adremover_hide_latest_posts_enabled_summary_on", "Latest posts are hidden"), StringResource("revanced_adremover_hide_latest_posts_enabled_summary_on", "Latest posts are hidden"),
StringResource("revanced_adremover_hide_latest_posts_enabled_summary_off", "Latest posts are shown") StringResource("revanced_adremover_hide_latest_posts_enabled_summary_off", "Latest posts are shown")
), ),
SwitchPreference(
"revanced_adremover_hide_channel_guidelines",
StringResource("revanced_adremover_hide_channel_guidelines_enabled_title", "Hide channel guidelines"),
true,
StringResource(
"revanced_adremover_hide_channel_guidelines_enabled_summary_on",
"Channel guidelines are hidden"
),
StringResource(
"revanced_adremover_hide_channel_guidelines_enabled_summary_off",
"Channel guidelines are shown"
)
),
SwitchPreference( SwitchPreference(
"revanced_adremover_self_sponsor", "revanced_adremover_self_sponsor",
StringResource("revanced_adremover_self_sponsor_enabled_title", "Hide self sponsored cards"), StringResource("revanced_adremover_self_sponsor_enabled_title", "Hide self sponsored cards"),
@ -178,30 +218,7 @@ class GeneralAdsResourcePatch : ResourcePatch {
StringResource("revanced_adremover_self_sponsor_enabled_summary_on", "Self sponsored cards are hidden"), StringResource("revanced_adremover_self_sponsor_enabled_summary_on", "Self sponsored cards are hidden"),
StringResource("revanced_adremover_self_sponsor_enabled_summary_off", "Self sponsored cards are shown") StringResource("revanced_adremover_self_sponsor_enabled_summary_off", "Self sponsored cards are shown")
), ),
SwitchPreference( PreferenceScreen(
"revanced_adremover_separator",
StringResource("revanced_adremover_separator_title", "Hide gray separator"),
true,
StringResource("revanced_adremover_separator_summary_on", "Gray separators are hidden"),
StringResource("revanced_adremover_separator_summary_off", "Gray separators are shown")
),
SwitchPreference(
"revanced_adremover_chapter_teaser",
StringResource(
"revanced_adremover_chapter_teaser_enabled_title",
"Hide chapter teaser under videos"
),
true,
StringResource(
"revanced_adremover_chapter_teaser_enabled_summary_on",
"Chapter teasers are hidden"
),
StringResource(
"revanced_adremover_chapter_teaser_enabled_summary_off",
"Chapter teasers are shown"
)
),
app.revanced.patches.shared.settings.preference.impl.PreferenceScreen(
"revanced_adremover_custom", "revanced_adremover_custom",
StringResource("revanced_adremover_custom_title", "Custom filter"), StringResource("revanced_adremover_custom_title", "Custom filter"),
listOf( listOf(
@ -221,7 +238,7 @@ class GeneralAdsResourcePatch : ResourcePatch {
"Custom filter is disabled" "Custom filter is disabled"
) )
), ),
// TODO: This should be a ListPreference, which does not exist yet // TODO: This should be a dynamic ListPreference, which does not exist yet
TextPreference( TextPreference(
"revanced_adremover_custom_strings", "revanced_adremover_custom_strings",
StringResource("revanced_adremover_custom_strings_title", "Custom filter"), StringResource("revanced_adremover_custom_strings_title", "Custom filter"),