mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat(microg): temporary suspension of support for all patches https://github.com/inotia00/ReVanced_Extended/issues/1207
This commit is contained in:
@ -1,27 +0,0 @@
|
||||
package app.revanced.patches.microg.layout.branding.icon.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.microg.utils.annotations.MicroGCompatibility
|
||||
import app.revanced.util.resources.MicroGResourceUtils.copyFiles
|
||||
|
||||
@Patch(false)
|
||||
@Name("Custom branding icon MMT")
|
||||
@Description("Changes the MicroG launcher icon to MMT.")
|
||||
@MicroGCompatibility
|
||||
@Version("0.0.1")
|
||||
class CustomBrandingIconMMTPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
context.copyFiles("microg/branding/mmt")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package app.revanced.patches.microg.layout.branding.icon.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.microg.utils.annotations.MicroGCompatibility
|
||||
import app.revanced.util.resources.MicroGResourceUtils.copyFiles
|
||||
|
||||
@Patch(false)
|
||||
@Name("Custom branding icon Revancify blue")
|
||||
@Description("Changes the MicroG launcher icon to Revancify Blue.")
|
||||
@MicroGCompatibility
|
||||
@Version("0.0.1")
|
||||
class CustomBrandingIconRevancifyBluePatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
context.copyFiles("microg/branding/revancify-blue")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package app.revanced.patches.microg.layout.branding.icon.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.microg.utils.annotations.MicroGCompatibility
|
||||
import app.revanced.util.resources.MicroGResourceUtils.copyFiles
|
||||
|
||||
@Patch
|
||||
@Name("Custom branding icon Revancify red")
|
||||
@Description("Changes the MicroG launcher icon to Revancify Red.")
|
||||
@MicroGCompatibility
|
||||
@Version("0.0.1")
|
||||
class CustomBrandingIconRevancifyRedPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
context.copyFiles("microg/branding/revancify-red")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package app.revanced.patches.microg.layout.branding.name.patch
|
||||
|
||||
import app.revanced.extensions.startsWithAny
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.OptionsContainer
|
||||
import app.revanced.patcher.patch.PatchOption
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.microg.utils.annotations.MicroGCompatibility
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@Patch
|
||||
@Name("Custom branding Microg name")
|
||||
@Description("Rename the MicroG app to the name specified in options.json.")
|
||||
@MicroGCompatibility
|
||||
@Version("0.0.1")
|
||||
class CustomBrandingNamePatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
MicroGAppName?.let { appName ->
|
||||
val resourceFileNames = arrayOf("strings.xml")
|
||||
|
||||
context.forEach {
|
||||
if (!it.name.startsWithAny(*resourceFileNames)) return@forEach
|
||||
|
||||
context.xmlEditor[it.absolutePath].use { editor ->
|
||||
val resourcesNode =
|
||||
editor.file.getElementsByTagName("resources").item(0) as Element
|
||||
var label = ""
|
||||
|
||||
for (i in 0 until resourcesNode.childNodes.length) {
|
||||
val node = resourcesNode.childNodes.item(i)
|
||||
if (node !is Element) continue
|
||||
|
||||
val element = resourcesNode.childNodes.item(i) as Element
|
||||
|
||||
when (element.getAttribute("name")) {
|
||||
"app_name", "gms_app_name" -> {
|
||||
if (label == "")
|
||||
label = element.textContent
|
||||
|
||||
element.textContent = appName
|
||||
}
|
||||
|
||||
"gms_settings_name" -> element.textContent = appName
|
||||
|
||||
else -> continue
|
||||
}
|
||||
}
|
||||
|
||||
for (i in 0 until resourcesNode.childNodes.length) {
|
||||
val node = resourcesNode.childNodes.item(i)
|
||||
if (node !is Element) continue
|
||||
|
||||
val element = resourcesNode.childNodes.item(i) as Element
|
||||
|
||||
if (element.textContent.contains(label)) {
|
||||
element.textContent = element.textContent.replace(label, appName)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} ?: return PatchResultError("Invalid app name.")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object : OptionsContainer() {
|
||||
var MicroGAppName: String? by option(
|
||||
PatchOption.StringOption(
|
||||
key = "MicroGAppName",
|
||||
default = "MicroG",
|
||||
title = "Application Name of MicroG",
|
||||
description = "The name of the MicroG it will show on your home screen."
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package app.revanced.patches.microg.layout.hideicon.patch
|
||||
|
||||
import app.revanced.extensions.doRecursively
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.microg.utils.annotations.MicroGCompatibility
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@Patch(false)
|
||||
@Name("Hide icon from launcher")
|
||||
@Description("Hide MicroG icon from launcher.")
|
||||
@MicroGCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideIconPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
context.xmlEditor["AndroidManifest.xml"].use { editor ->
|
||||
editor.file.doRecursively loop@{
|
||||
if (it !is Element) return@loop
|
||||
|
||||
it.getAttributeNode("android:name")?.let { attribute ->
|
||||
if (attribute.textContent == "android.intent.category.LAUNCHER") {
|
||||
attribute.textContent = "android.intent.category.DEFAULT"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package app.revanced.patches.microg.layout.materialyou.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.microg.utils.annotations.MicroGCompatibility
|
||||
import app.revanced.util.resources.ResourceUtils
|
||||
import app.revanced.util.resources.ResourceUtils.copyResources
|
||||
|
||||
@Patch(false)
|
||||
@Name("MaterialYou")
|
||||
@Description("Enables MaterialYou theme for Android 12+")
|
||||
@MicroGCompatibility
|
||||
@Version("0.0.1")
|
||||
class MaterialYouPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
arrayOf(
|
||||
ResourceUtils.ResourceGroup(
|
||||
"values-v31",
|
||||
"styles.xml"
|
||||
),
|
||||
).forEach {
|
||||
context["res/${it.resourceDirectoryName}"].mkdirs()
|
||||
context.copyResources("microg/materialyou", it)
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package app.revanced.patches.microg.utils.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility([Package("com.mgoogle.android.gms")])
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
internal annotation class MicroGCompatibility
|
@ -1,63 +0,0 @@
|
||||
package app.revanced.util.resources
|
||||
|
||||
import app.revanced.extensions.doRecursively
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.util.resources.ResourceUtils.copyResources
|
||||
import app.revanced.util.resources.ResourceUtils.copyXmlNode
|
||||
import org.w3c.dom.Element
|
||||
|
||||
internal object MicroGResourceUtils {
|
||||
|
||||
internal fun ResourceContext.copyFiles(path: String) {
|
||||
fun copyResources(resourceGroups: List<ResourceUtils.ResourceGroup>) {
|
||||
resourceGroups.forEach { this.copyResources(path, it) }
|
||||
}
|
||||
|
||||
val iconResourceFileNames = arrayOf(
|
||||
"ic_microg_launcher"
|
||||
).map { "$it.png" }.toTypedArray()
|
||||
|
||||
fun createGroup(directory: String) = ResourceUtils.ResourceGroup(
|
||||
directory, *iconResourceFileNames
|
||||
)
|
||||
|
||||
// change the app icon
|
||||
arrayOf("xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi")
|
||||
.map { "mipmap-$it" }
|
||||
.map(::createGroup)
|
||||
.let(::copyResources)
|
||||
|
||||
arrayOf(
|
||||
ResourceUtils.ResourceGroup(
|
||||
"drawable",
|
||||
"ic_app_icons_themed_microg.xml",
|
||||
"ic_microg_launcher_foreground.xml"
|
||||
),
|
||||
ResourceUtils.ResourceGroup(
|
||||
"mipmap-anydpi-v26",
|
||||
"ic_microg_launcher.xml"
|
||||
)
|
||||
).forEach { this.copyResources(path, it) }
|
||||
|
||||
this.copyXmlNode(path, "values/colors.xml", "resources")
|
||||
this.setManifestIcon()
|
||||
}
|
||||
|
||||
private fun ResourceContext.setManifestIcon() {
|
||||
this.xmlEditor["AndroidManifest.xml"].use {
|
||||
val attributes = arrayOf("icon", "roundIcon")
|
||||
|
||||
it.file.doRecursively {
|
||||
attributes.forEach replacement@{ replacement ->
|
||||
if (it !is Element) return@replacement
|
||||
|
||||
it.getAttributeNode("android:$replacement")?.let { attribute ->
|
||||
if (attribute.textContent.startsWith("@mipmap/"))
|
||||
attribute.textContent = "@mipmap/ic_microg_launcher"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user