forked from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: merged changes from revanced-patches main branch
- Loading branch information
1 parent
5f8bba7
commit cb719d4
Showing
807 changed files
with
30,046 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,3 +130,5 @@ node_modules/ | |
|
||
#ignoring all builds | ||
build/ | ||
gradle.properties | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import org.gradle.kotlin.dsl.support.listFilesOrdered | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
plugins { | ||
kotlin("jvm") version "1.9.10" | ||
alias(libs.plugins.kotlin) | ||
alias(libs.plugins.binary.compatibility.validator) | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
group = "patches.grindr" | ||
|
@@ -11,7 +14,14 @@ repositories { | |
mavenCentral() | ||
mavenLocal() | ||
google() | ||
maven { url = uri("https://jitpack.io") } | ||
maven { | ||
// A repository must be specified for some reason. "registry" is a dummy. | ||
url = uri("https://maven.pkg.github.com/revanced/registry") | ||
credentials { | ||
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR") | ||
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
@@ -21,61 +31,78 @@ dependencies { | |
implementation(libs.guava) | ||
// Used in JsonGenerator. | ||
implementation(libs.gson) | ||
|
||
// A dependency to the Android library unfortunately fails the build, which is why this is required. | ||
compileOnly(project("dummy")) | ||
// Android API stubs defined here. | ||
compileOnly(project(":stub")) | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(11) | ||
compilerOptions { | ||
jvmTarget.set(JvmTarget.JVM_11) | ||
} | ||
} | ||
|
||
tasks.withType(Jar::class) { | ||
manifest { | ||
attributes["Name"] = "Grindr patches" | ||
attributes["Description"] = "Patches for Grindr." | ||
attributes["Version"] = version | ||
attributes["Timestamp"] = System.currentTimeMillis().toString() | ||
attributes["Source"] = "[email protected]:Slenderman00/revanced-patches-grindr.git" | ||
attributes["Author"] = "You" | ||
attributes["Contact"] = "[email protected]" | ||
attributes["Origin"] = "https://joar.me" | ||
attributes["License"] = "GNU General Public License v3.0" | ||
} | ||
java { | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
tasks { | ||
register<DefaultTask>("generateBundle") { | ||
description = "Generate DEX files and add them in the JAR file" | ||
withType(Jar::class) { | ||
exclude("app/revanced/meta") | ||
|
||
manifest { | ||
attributes["Name"] = "Grindr patches" | ||
attributes["Description"] = "Patches for Grindr." | ||
attributes["Version"] = version | ||
attributes["Timestamp"] = System.currentTimeMillis().toString() | ||
attributes["Source"] = "[email protected]:Slenderman00/revanced-patches-grindr.git" | ||
attributes["Author"] = "You" | ||
attributes["Contact"] = "[email protected]" | ||
attributes["Origin"] = "https://joar.me" | ||
attributes["License"] = "GNU General Public License v3.0" | ||
} | ||
} | ||
|
||
register("buildDexJar") { | ||
description = "Build and add a DEX to the JAR file" | ||
group = "build" | ||
|
||
dependsOn(build) | ||
|
||
doLast { | ||
val d8 = File(System.getenv("ANDROID_HOME")).resolve("build-tools") | ||
.listFilesOrdered().last().resolve("d8").absolutePath | ||
|
||
val artifacts = configurations.archives.get().allArtifacts.files.files.first().absolutePath | ||
val patchesJar = configurations.archives.get().allArtifacts.files.files.first().absolutePath | ||
val workingDirectory = layout.buildDirectory.dir("libs").get().asFile | ||
|
||
exec { | ||
workingDir = workingDirectory | ||
commandLine = listOf(d8, artifacts) | ||
commandLine = listOf(d8, "--release", patchesJar) | ||
} | ||
|
||
exec { | ||
workingDir = workingDirectory | ||
commandLine = listOf("zip", "-u", artifacts, "classes.dex") | ||
commandLine = listOf("zip", "-u", patchesJar, "classes.dex") | ||
} | ||
} | ||
} | ||
|
||
// Required to run tasks because Gradle semantic-release plugin runs the publish task. | ||
register<JavaExec>("generatePatchesFiles") { | ||
description = "Generate patches files" | ||
|
||
dependsOn(build) | ||
|
||
classpath = sourceSets["main"].runtimeClasspath | ||
mainClass.set("app.revanced.generator.MainKt") | ||
} | ||
|
||
// Needed by gradle-semantic-release-plugin. | ||
// Tracking: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435 | ||
named("publish") { | ||
dependsOn("generateBundle") | ||
publish { | ||
dependsOn("buildDexJar") | ||
dependsOn("generatePatchesFiles") | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("revanced-patches-publication") { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
[versions] | ||
revanced-patcher = "19.0.0" | ||
smali = "3.0.3" | ||
guava = "32.1.2-jre" | ||
gson = "2.10.1" | ||
revanced-patcher = "19.3.1" | ||
#noinspection GradleDependency | ||
smali = "3.0.5" # 3.0.7 breaks binary compatibility. Tracking https://github.com/google/smali/issues/58. | ||
guava = "33.2.1-jre" | ||
gson = "2.11.0" | ||
binary-compatibility-validator = "0.15.1" | ||
kotlin = "2.0.0" | ||
|
||
[libraries] | ||
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" } | ||
smali = { module = "com.android.tools.smali:smali", version.ref = "smali" } | ||
guava = { module = "com.google.guava:guava", version.ref = "guava" } | ||
gson = { module = "com.google.code.gson:gson", version.ref = "gson" } | ||
|
||
[plugins] | ||
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" } | ||
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
include("dummy") | ||
|
||
rootProject.name = "revanced-patches" | ||
rootProject.name = "revanced-patches-grindr" | ||
|
||
buildCache { | ||
local { | ||
isEnabled = !System.getenv().containsKey("CI") | ||
} | ||
} | ||
|
||
include(":stub") |
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/app/revanced/generator/JsonPatchesFileGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package app.revanced.generator | ||
|
||
import app.revanced.patcher.PatchSet | ||
import app.revanced.patcher.patch.Patch | ||
import com.google.gson.GsonBuilder | ||
import java.io.File | ||
|
||
internal class JsonPatchesFileGenerator : PatchesFileGenerator { | ||
override fun generate(patches: PatchSet) = patches.map { | ||
JsonPatch( | ||
it.name!!, | ||
it.description, | ||
it.compatiblePackages, | ||
it.use, | ||
it.requiresIntegrations, | ||
it.options.values.map { option -> | ||
JsonPatch.Option( | ||
option.key, | ||
option.default, | ||
option.values, | ||
option.title, | ||
option.description, | ||
option.required, | ||
) | ||
}, | ||
) | ||
}.let { | ||
File("patches.json").writeText(GsonBuilder().serializeNulls().create().toJson(it)) | ||
} | ||
|
||
@Suppress("unused") | ||
private class JsonPatch( | ||
val name: String? = null, | ||
val description: String? = null, | ||
val compatiblePackages: Set<Patch.CompatiblePackage>? = null, | ||
val use: Boolean = true, | ||
val requiresIntegrations: Boolean = false, | ||
val options: List<Option>, | ||
) { | ||
class Option( | ||
val key: String, | ||
val default: Any?, | ||
val values: Map<String, Any?>?, | ||
val title: String?, | ||
val description: String?, | ||
val required: Boolean, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package app.revanced.generator | ||
|
||
import app.revanced.patcher.PatchBundleLoader | ||
import java.io.File | ||
|
||
internal fun main() = PatchBundleLoader.Jar( | ||
File("build/libs/").listFiles { it -> it.name.endsWith(".jar") }!!.first(), | ||
).also { loader -> | ||
if (loader.isEmpty()) throw IllegalStateException("No patches found") | ||
}.let { bundle -> | ||
arrayOf(JsonPatchesFileGenerator()).forEach { generator -> generator.generate(bundle) } | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/app/revanced/generator/PatchesFileGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package app.revanced.generator | ||
|
||
import app.revanced.patcher.PatchSet | ||
|
||
internal interface PatchesFileGenerator { | ||
fun generate(patches: PatchSet) | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/app/revanced/patches/all/activity/exportall/ExportAllActivitiesPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package app.revanced.patches.all.activity.exportall | ||
|
||
import app.revanced.patcher.data.ResourceContext | ||
import app.revanced.patcher.patch.ResourcePatch | ||
import app.revanced.patcher.patch.annotation.Patch | ||
|
||
@Patch( | ||
name = "Export all activities", | ||
description = "Makes all app activities exportable.", | ||
use = false, | ||
) | ||
@Suppress("unused") | ||
object ExportAllActivitiesPatch : ResourcePatch() { | ||
private const val EXPORTED_FLAG = "android:exported" | ||
|
||
override fun execute(context: ResourceContext) { | ||
context.xmlEditor["AndroidManifest.xml"].use { editor -> | ||
val document = editor.file | ||
|
||
val activities = document.getElementsByTagName("activity") | ||
|
||
for (i in 0..activities.length) { | ||
activities.item(i)?.apply { | ||
val exportedAttribute = attributes.getNamedItem(EXPORTED_FLAG) | ||
|
||
if (exportedAttribute != null) { | ||
if (exportedAttribute.nodeValue != "true") { | ||
exportedAttribute.nodeValue = "true" | ||
} | ||
} | ||
// Reason why the attribute is added in the case it does not exist: | ||
// https://github.com/revanced/revanced-patches/pull/1751/files#r1141481604 | ||
else { | ||
document.createAttribute(EXPORTED_FLAG) | ||
.apply { value = "true" } | ||
.let(attributes::setNamedItem) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.