From 20aff26784296517257ea19d66ffd3bdfe6b06fa Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 25 Aug 2023 00:04:07 +0200 Subject: [PATCH] feat: Publicize resource utility functions This commit adds the functions to the public API --- .../app/revanced/util/resources/ResourceUtils.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt b/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt index 03ec8e91a..0cb67a06f 100644 --- a/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt @@ -8,14 +8,15 @@ import org.w3c.dom.Node import java.nio.file.Files import java.nio.file.StandardCopyOption -internal object ResourceUtils { +@Suppress("MemberVisibilityCanBePrivate") +object ResourceUtils { /** * Merge strings. This manages [StringResource]s automatically. * * @param host The hosting xml resource. Needs to be a valid strings.xml resource. */ - internal fun ResourceContext.mergeStrings(host: String) { + fun ResourceContext.mergeStrings(host: String) { this.iterateXmlNodeChildren(host, "resources") { // TODO: figure out why this is needed if (!it.hasAttributes()) return@iterateXmlNodeChildren @@ -32,10 +33,11 @@ internal object ResourceUtils { /** * Copy resources from the current class loader to the resource directory. + * * @param sourceResourceDirectory The source resource directory name. * @param resources The resources to copy. */ - internal fun ResourceContext.copyResources(sourceResourceDirectory: String, vararg resources: ResourceGroup) { + fun ResourceContext.copyResources(sourceResourceDirectory: String, vararg resources: ResourceGroup) { val classLoader = ResourceUtils.javaClass.classLoader val targetResourceDirectory = this["res"] @@ -55,7 +57,7 @@ internal object ResourceUtils { * @param resourceDirectoryName The name of the directory of the resource. * @param resources A list of resource names. */ - internal class ResourceGroup(val resourceDirectoryName: String, vararg val resources: String) + class ResourceGroup(val resourceDirectoryName: String, vararg val resources: String) /** * Iterate through the children of a node by its tag. @@ -63,7 +65,7 @@ internal object ResourceUtils { * @param targetTag The target xml node. * @param callback The callback to call when iterating over the nodes. */ - internal fun ResourceContext.iterateXmlNodeChildren( + fun ResourceContext.iterateXmlNodeChildren( resource: String, targetTag: String, callback: (node: Node) -> Unit