mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 13:47:42 +02:00
feat(Reddit/Settings for Reddit): add patch option RVX settings menu name
This commit is contained in:
@ -2,6 +2,7 @@ package app.revanced.patches.reddit.utils.settings
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
|
||||
import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.reddit.utils.integrations.IntegrationsPatch
|
||||
import app.revanced.util.patch.BaseResourcePatch
|
||||
@ -18,10 +19,25 @@ object SettingsPatch : BaseResourcePatch(
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
requiresIntegrations = true
|
||||
) {
|
||||
private const val DEFAULT_NAME = "ReVanced Extended"
|
||||
|
||||
private val RVXSettingsMenuName by stringPatchOption(
|
||||
key = "RVXSettingsMenuName",
|
||||
default = DEFAULT_NAME,
|
||||
title = "RVX settings menu name",
|
||||
description = "The name of the RVX settings menu.",
|
||||
required = true
|
||||
)
|
||||
override fun execute(context: ResourceContext) {
|
||||
/**
|
||||
* Replace settings icon and label
|
||||
*/
|
||||
|
||||
var settingsLabel = DEFAULT_NAME
|
||||
|
||||
if (!RVXSettingsMenuName.isNullOrEmpty())
|
||||
settingsLabel = RVXSettingsMenuName!!
|
||||
|
||||
arrayOf("preferences", "preferences_logged_in").forEach { targetXML ->
|
||||
val resDirectory = context["res"]
|
||||
val targetXml = resDirectory.resolve("xml").resolve("$targetXML.xml").toPath()
|
||||
@ -35,7 +51,7 @@ object SettingsPatch : BaseResourcePatch(
|
||||
preference.readText()
|
||||
.replace(
|
||||
"\"@drawable/icon_text_post\" android:title=\"@string/label_acknowledgements\"",
|
||||
"\"@drawable/icon_beta_planet\" android:title=\"ReVanced Extended\""
|
||||
"\"@drawable/icon_beta_planet\" android:title=\"$settingsLabel\""
|
||||
)
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user