feat(youtube/settings): disable preferences and add dialog messages to preferences (#1801)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
LisoUseInAIKyrios 2023-04-05 12:25:12 +04:00 committed by oSumAtrIX
parent 33f795350d
commit 05023bab1d
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
6 changed files with 29 additions and 10 deletions

View File

@ -1,10 +1,7 @@
package app.revanced.patches.shared.settings.preference.impl
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.IResource
import app.revanced.patches.shared.settings.preference.addDefault
import app.revanced.patches.shared.settings.preference.addSummary
import app.revanced.patches.shared.settings.preference.SummaryType
import app.revanced.patches.shared.settings.preference.*
import app.revanced.patches.shared.settings.resource.patch.AbstractSettingsResourcePatch.Companion.include
import org.w3c.dom.Document
import org.w3c.dom.Element
@ -16,16 +13,21 @@ import org.w3c.dom.Element
* @param default The default value of the switch.
* @param summaryOn The summary to show when the preference is enabled.
* @param summaryOff The summary to show when the preference is disabled.
* @param userDialogMessage The message to show in a dialog when the user toggles the preference.
*/
internal class SwitchPreference(
key: String, title: StringResource,
val default: Boolean = false,
val summaryOn: StringResource? = null,
val summaryOff: StringResource? = null
val summaryOff: StringResource? = null,
val userDialogMessage: StringResource? = null
) : BasePreference(key, title) {
override val tag: String = "SwitchPreference"
override fun serialize(ownerDocument: Document, resourceCallback: ((IResource) -> Unit)?): Element {
// dialog message is stored as a regular string and later referenced by SettingsEnum
userDialogMessage?.include()
return super.serialize(ownerDocument, resourceCallback).apply {
addDefault(default)
addSummary(summaryOn?.also { resourceCallback?.invoke(it) }, SummaryType.ON)

View File

@ -36,8 +36,11 @@ class SpoofAppVersionPatch : BytecodePatch(
"revanced_spoof_app_version",
StringResource("revanced_spoof_app_version_title", "Spoof app version"),
false,
StringResource("revanced_spoof_app_version_summary_on", "Version spoofed to 17.30.34. If switched off, the old UI layout may remain until logging out or clearing app data"),
StringResource("revanced_spoof_app_version_summary_off", "Version not spoofed")
StringResource("revanced_spoof_app_version_summary_on", "Version spoofed to 17.30.34"),
StringResource("revanced_spoof_app_version_summary_off", "Version not spoofed"),
StringResource("revanced_spoof_app_version_user_dialog_message",
"App version will be spoofed to 17.30.34. This will give the old UI layout, but unknown side effects may occur."
+ " If later turned off, the old UI layout may remain until you log out or clear the app data.")
)
)

View File

@ -52,7 +52,12 @@ class DebuggingPatch : ResourcePatch {
),
true,
StringResource("revanced_debug_toast_on_error_summary_on", "Toast shown if error occurs"),
StringResource("revanced_debug_toast_on_error_summary_off", "Toast not shown if error occurs")
StringResource("revanced_debug_toast_on_error_summary_off", "Toast not shown if error occurs"),
StringResource("revanced_debug_toast_on_error_user_dialog_message",
"Turning off error toasts hides all ReVanced error notifications." +
" This includes hiding normal network connection timeouts, " +
"but also hides notification of any unexpected and more serious errors."
)
),
),
StringResource("revanced_debug_summary", "Enable or disable debugging options")

View File

@ -45,7 +45,9 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
StringResource("revanced_spoof_signature_verification_title", "Spoof app signature"),
true,
StringResource("revanced_spoof_signature_verification_summary_on", "App signature spoofed"),
StringResource("revanced_spoof_signature_verification_summary_off", "App signature not spoofed")
StringResource("revanced_spoof_signature_verification_summary_off", "App signature not spoofed"),
StringResource("revanced_spoof_signature_verification_user_dialog_message",
"Signature spoofing can fix playback issues, but may causes side effects.")
)
)

View File

@ -18,6 +18,7 @@ import app.revanced.patches.shared.settings.resource.patch.AbstractSettingsResou
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.util.resources.ResourceUtils
import app.revanced.util.resources.ResourceUtils.copyResources
import app.revanced.util.resources.ResourceUtils.mergeStrings
import org.w3c.dom.Node
@Name("settings-resource-patch")
@ -77,6 +78,8 @@ class SettingsResourcePatch : AbstractSettingsResourcePatch(
)
)
context.mergeStrings("settings/host/values/strings.xml")
return PatchResultSuccess()
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_settings_confirm_user_dialog_title">Do you wish to proceed?</string>
</resources>