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
@@ -7,13 +7,18 @@ import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.impl.BytecodeData
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.impl.BytecodePatch
import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility
import app.revanced.patches.youtube.layout.reels.fingerprints.HideReelsFingerprint
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 TODO: this is currently in the general-bytecode-ads patch due to the integrations having a preference for including reels or not. Move it here.
@Name("hide-reels")
@Description("Hides reels on the home page.")
@DependsOn([SettingsPatch::class])
@HideReelsCompatibility
@Version("0.0.1")
class HideReelsPatch : BytecodePatch(
@@ -22,6 +27,16 @@ class HideReelsPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_reel_button_enabled",
StringResource("revanced_reel_button_enabled_title", "Show reels button"),
false,
StringResource("revanced_reel_button_summary_on", "Reels button is shown"),
StringResource("revanced_reel_button_summary_off", "Reels button is hidden")
)
)
val result = HideReelsFingerprint.result!!
// HideReel will hide the reel view before it is being used,