diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt index 4030a773..0ea6834d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt @@ -8,18 +8,14 @@ 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.patches.shared.settings.preference.impl.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference -import app.revanced.patches.shared.settings.preference.impl.TextPreference -import app.revanced.patches.shared.settings.preference.impl.InputType -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen +import app.revanced.patches.shared.settings.preference.impl.* import app.revanced.patches.youtube.interaction.downloads.annotation.DownloadsCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.playercontrols.resource.patch.BottomControlsResourcePatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.util.resources.ResourceUtils -import app.revanced.util.resources.ResourceUtils.Settings.mergeStrings import app.revanced.util.resources.ResourceUtils.copyResources +import app.revanced.util.resources.ResourceUtils.mergeStrings @Name("downloads-resource-patch") @DependsOn([BottomControlsResourcePatch::class, FixLocaleConfigErrorPatch::class, SettingsPatch::class]) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/resource/patch/ReturnYouTubeDislikeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/resource/patch/ReturnYouTubeDislikeResourcePatch.kt index 5f0c9075..35dd0af7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/resource/patch/ReturnYouTubeDislikeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/resource/patch/ReturnYouTubeDislikeResourcePatch.kt @@ -8,12 +8,12 @@ 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.patches.shared.settings.preference.impl.Preference +import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch -import app.revanced.patches.shared.settings.preference.impl.Preference -import app.revanced.patches.shared.settings.preference.impl.StringResource -import app.revanced.util.resources.ResourceUtils.Settings.mergeStrings +import app.revanced.util.resources.ResourceUtils.mergeStrings @DependsOn([FixLocaleConfigErrorPatch::class, SettingsPatch::class]) @Name("return-youtube-dislike-resource-patch") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt index 51b1e08c..7b0d58f6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt @@ -7,16 +7,16 @@ 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.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility -import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch -import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.shared.settings.preference.impl.Preference import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility +import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch +import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.util.resources.ResourceUtils -import app.revanced.util.resources.ResourceUtils.Settings.mergeStrings import app.revanced.util.resources.ResourceUtils.copyResources import app.revanced.util.resources.ResourceUtils.copyXmlNode +import app.revanced.util.resources.ResourceUtils.mergeStrings @Name("sponsorblock-resource-patch") @SponsorBlockCompatibility diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt index 6c8af526..348e1458 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt @@ -1,7 +1,7 @@ package app.revanced.util.microg import app.revanced.patcher.data.ResourceContext -import app.revanced.util.resources.ResourceUtils.Settings.mergeStrings +import app.revanced.util.resources.ResourceUtils.mergeStrings /** * Helper class for applying resource patches needed for the microg-support patches. diff --git a/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt b/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt index 7acb9fcb..be6a7748 100644 --- a/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt @@ -2,8 +2,8 @@ package app.revanced.util.resources import app.revanced.patcher.data.DomFileEditor import app.revanced.patcher.data.ResourceContext -import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import org.w3c.dom.Node import java.nio.file.Files import java.nio.file.StandardCopyOption @@ -11,26 +11,21 @@ import java.nio.file.StandardCopyOption internal object ResourceUtils { /** - * Settings related utilities + * Merge strings. This manages [StringResource]s automatically. + * @param host The hosting xml resource. Needs to be a valid strings.xml resource. */ - internal object Settings { - /** - * Merge strings. This handles [StringResource]s automatically. - * @param host The hosting xml resource. Needs to be a valid strings.xml resource. - */ - internal fun ResourceContext.mergeStrings(host: String) { - this.iterateXmlNodeChildren(host, "resources") { - // TODO: figure out why this is needed - if (!it.hasAttributes()) return@iterateXmlNodeChildren + internal fun ResourceContext.mergeStrings(host: String) { + this.iterateXmlNodeChildren(host, "resources") { + // TODO: figure out why this is needed + if (!it.hasAttributes()) return@iterateXmlNodeChildren - val attributes = it.attributes - val key = attributes.getNamedItem("name")!!.nodeValue!! - val value = it.textContent!! + val attributes = it.attributes + val key = attributes.getNamedItem("name")!!.nodeValue!! + val value = it.textContent!! - val formatted = attributes.getNamedItem("formatted") == null + val formatted = attributes.getNamedItem("formatted") == null - SettingsPatch.addString(key, value, formatted) - } + SettingsPatch.addString(key, value, formatted) } }