feat(music): add enable-custom-filter patch

This commit is contained in:
inotia00 2023-06-29 18:11:40 +09:00
parent 604165116a
commit 13b8670391
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,52 @@
package app.revanced.patches.music.layout.customfilter.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility
import app.revanced.patches.music.utils.litho.patch.LithoFilterPatch
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
@Patch
@Name("enable-custom-filter")
@Description("Enables custom filter to hide layout components.")
@DependsOn(
[
LithoFilterPatch::class,
SettingsPatch::class
]
)
@MusicCompatibility
@Version("0.0.1")
class CustomFilterPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
SettingsPatch.addMusicPreference(
CategoryType.LAYOUT,
"revanced_custom_filter",
"false"
)
SettingsPatch.addMusicPreferenceWithIntent(
CategoryType.LAYOUT,
"revanced_custom_filter_strings",
"revanced_custom_filter"
)
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
return PatchResultSuccess()
}
private companion object {
private const val FILTER_CLASS_DESCRIPTOR =
"$MUSIC_ADS_PATH/CustomFilter;"
}
}

View File

@ -3,6 +3,10 @@
<string name="revanced_category_ads">Ads</string>
<string name="revanced_category_layout">Layout</string>
<string name="revanced_category_misc">Miscellaneous</string>
<string name="revanced_custom_filter_strings_summary">Filter components by their name separated by a comma</string>
<string name="revanced_custom_filter_strings_title">Edit custom filter</string>
<string name="revanced_custom_filter_summary">Enables custom filters</string>
<string name="revanced_custom_filter_title">Enable custom filter</string>
<string name="revanced_disable_auto_captions_summary">Disables forced auto captions.</string>
<string name="revanced_disable_auto_captions_title">Disable forced auto captions</string>
<string name="revanced_downloader_not_installed" formatted="false">%s is not installed. Please install it.</string>