feat: settings patch framework (#266)

This commit is contained in:
oSumAtrIX
2022-08-22 01:59:43 +02:00
committed by GitHub
parent 8c3866f5e3
commit 9ef93f6618
62 changed files with 1219 additions and 728 deletions
@@ -17,10 +17,13 @@ import app.revanced.patches.youtube.layout.fullscreenpanels.annotations.Fullscre
import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint
import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.FullscreenViewAdderParentFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
@Patch
@Name("disable-fullscreen-panels")
@DependsOn([IntegrationsPatch::class])
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@Description("Disables video description and comments panel in fullscreen view.")
@FullscreenPanelsCompatibility
@Version("0.0.1")
@@ -30,6 +33,16 @@ class FullscreenPanelsRemoverPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_fullscreen_panels_enabled",
StringResource("revanced_fullscreen_panels_enabled_title", "Show fullscreen panels"),
false,
StringResource("revanced_fullscreen_panels_summary_on", "Fullscreen panels are shown"),
StringResource("revanced_fullscreen_panels_summary_off", "Fullscreen panels are hidden")
)
)
val parentResult = FullscreenViewAdderParentFingerprint.result!!
FullscreenViewAdderFingerprint.resolve(data, parentResult.method, parentResult.classDef)
val result = FullscreenViewAdderParentFingerprint.result