revanced-patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt

70 lines
2.8 KiB
Kotlin
Raw Normal View History

package app.revanced.patches.youtube.layout.hide.comments
2022-10-25 23:33:49 +02:00
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
@Patch(
name = "Comments",
description = "Adds options to hide components related to comments.",
dependencies = [
SettingsPatch::class,
LithoFilterPatch::class
],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"18.32.39",
"18.37.36",
"18.38.44",
"18.43.45",
"18.44.41",
"18.45.43",
"18.48.39",
"18.49.37",
"19.01.34",
"19.02.39",
"19.03.35"
]
)
]
)
@Suppress("unused")
object CommentsPatch : ResourcePatch() {
private const val FILTER_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/youtube/patches/components/CommentsFilter;"
2022-10-25 23:33:49 +02:00
override fun execute(context: ResourceContext) {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
2022-10-25 23:33:49 +02:00
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
PreferenceScreen(
"revanced_comments_preference_screen",
StringResource("revanced_comments_preference_screen_title", "Comments"),
2022-10-25 23:33:49 +02:00
listOf(
SwitchPreference(
"revanced_hide_comments_section",
StringResource("revanced_hide_comments_section_title", "Hide comments section"),
2022-10-25 23:33:49 +02:00
StringResource("revanced_hide_comments_section_summary_on", "Comment section is hidden"),
StringResource("revanced_hide_comments_section_summary_off", "Comment section is shown")
),
SwitchPreference(
"revanced_hide_preview_comment",
StringResource("revanced_hide_preview_comment_title", "Hide preview comment"),
StringResource("revanced_hide_preview_comment_on", "Preview comment is hidden"),
StringResource("revanced_hide_preview_comment_off", "Preview comment is shown")
)
2022-10-25 23:33:49 +02:00
),
StringResource("revanced_comments_preference_screen_summary", "Manage the visibility of comments section components")
2022-10-25 23:33:49 +02:00
)
)
}
}