Skip to content

Commit

Permalink
chore: Merge branch dev to main (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX authored Nov 4, 2023
2 parents dde402a + 89075c5 commit e1c6f65
Show file tree
Hide file tree
Showing 30 changed files with 588 additions and 474 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'zulu'
- name: Setup Flutter
uses: subosito/flutter-action@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
- uses: actions/checkout@v4
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up JDK 11
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: "11"
java-version: "17"
distribution: "zulu"
- uses: subosito/flutter-action@v2
with:
Expand Down
33 changes: 20 additions & 13 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,26 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion
compileSdk 34
ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '11'
jvmTarget = '17'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
applicationId "app.revanced.manager.flutter"
minSdkVersion 26
targetSdkVersion 33
minSdk 26
targetSdk 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

buildTypes {
release {
shrinkResources false
Expand All @@ -71,10 +67,21 @@ android {
}
}
}

packagingOptions {
exclude '/prebuilt/**'
jniLibs {
useLegacyPackaging true
excludes += ['/prebuilt/**']
}
resources {
excludes += ['/prebuilt/**']
}
}

namespace 'app.revanced.manager.flutter'
}

kotlin {
jvmToolchain(17)
}

flutter {
Expand All @@ -85,7 +92,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

// ReVanced
implementation "app.revanced:revanced-patcher:17.0.0"
implementation "app.revanced:revanced-patcher:19.0.0"

// Signing & aligning
implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
Expand Down
3 changes: 1 addition & 2 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.revanced.manager.flutter">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
7 changes: 2 additions & 5 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.revanced.manager.flutter">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
Expand All @@ -24,8 +22,7 @@
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:largeHeap="true"
android:requestLegacyExternalStorage="true"
android:extractNativeLibs="true">
android:requestLegacyExternalStorage="true">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import app.revanced.patcher.patch.PatchResult
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import kotlinx.coroutines.InternalCoroutinesApi
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.runBlocking
import org.json.JSONArray
import org.json.JSONObject
Expand All @@ -25,6 +27,7 @@ import java.io.StringWriter
import java.util.logging.LogRecord
import java.util.logging.Logger


class MainActivity : FlutterActivity() {
private val handler = Handler(Looper.getMainLooper())
private lateinit var installerChannel: MethodChannel
Expand Down Expand Up @@ -98,8 +101,10 @@ class MainActivity : FlutterActivity() {
val cacheDirPath = call.argument<String>("cacheDirPath")!!

try {
val patchBundleFile = File(patchBundleFilePath)
patchBundleFile.setWritable(false)
patches = PatchBundleLoader.Dex(
File(patchBundleFilePath),
patchBundleFile,
optimizedDexDirectory = File(cacheDirPath)
)
} catch (ex: Exception) {
Expand Down Expand Up @@ -131,24 +136,34 @@ class MainActivity : FlutterActivity() {
})
put("options", JSONArray().apply {
it.options.values.forEach { option ->
val optionJson = JSONObject().apply option@{
JSONObject().apply {
put("key", option.key)
put("title", option.title)
put("description", option.description)
put("required", option.required)

when (val value = option.value) {
null -> put("value", null)
is Array<*> -> put("value", JSONArray().apply {

fun JSONObject.putValue(
value: Any?,
key: String = "value"
) = if (value is Array<*>) put(
key,
JSONArray().apply {
value.forEach { put(it) }
})
else -> put("value", option.value)
}

put("optionClassType", option::class.simpleName)
}
put(optionJson)
else put(key, value)

putValue(option.default)

option.values?.let { values ->
put("values",
JSONObject().apply {
values.forEach { (key, value) ->
putValue(value, key)
}
})
} ?: put("values", null)
put("valueType", option.valueType)
}.let(::put)
}
})
}.let(::put)
Expand All @@ -161,6 +176,7 @@ class MainActivity : FlutterActivity() {
}
}

@OptIn(InternalCoroutinesApi::class)
private fun runPatcher(
result: MethodChannel.Result,
originalFilePath: String,
Expand Down Expand Up @@ -283,12 +299,12 @@ class MainActivity : FlutterActivity() {
acceptPatches(patches)

runBlocking {
apply(false).collect { patchResult: PatchResult ->
apply(false).collect(FlowCollector { patchResult: PatchResult ->
if (cancel) {
handler.post { stopResult!!.success(null) }
this.cancel()
this@apply.close()
return@collect
return@FlowCollector
}

val msg = patchResult.exception?.let {
Expand All @@ -301,7 +317,7 @@ class MainActivity : FlutterActivity() {

updateProgress(progress, "", msg)
progress += progressStep
}
})
}
}

Expand Down
3 changes: 1 addition & 2 deletions android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.revanced.manager.flutter">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
11 changes: 6 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.9.0'
ext.kotlin_version = '1.9.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.android.tools.build:gradle:8.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -22,12 +22,13 @@ allprojects {
}
}

rootProject.buildDir = '../build'
layout.buildDirectory.set(file("../build"))
var root = layout.buildDirectory.get().asFile.absolutePath
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.layout.buildDirectory.set(file("$root/${project.name}"))
project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
delete rootProject.buildDir
delete layout.buildDirectory
}
3 changes: 3 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ org.gradle.daemon=true
org.gradle.caching=true
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
1 change: 1 addition & 0 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"setRequiredOption": "Some patches require options to be set:\n\n{patches}\n\nPlease set them before continuing."
},
"patchOptionsView": {
"customValue": "Custom value",
"resetOptionsTooltip": "Reset patch options",
"viewTitle": "Patch options",
"saveOptions": "Save",
Expand Down
16 changes: 3 additions & 13 deletions docs/4_building.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,13 @@ This page will guide you through building ReVanced Manager from source.
```sh
git clone https://github.com/revanced/revanced-manager.git && cd revanced-manager
```

3. Create a GitHub personal access token with the `read:packages` scope [here](https://github.com/settings/tokens/new?scopes=read:packages&description=ReVanced)

4. Add your GitHub username and the token to `~/android/gradle.properties`

```properties
gpr.user = YourUsername
gpr.key = ghp_longrandomkey
```

5. Get dependencies
3. Get dependencies

```sh
flutter pub get
```

6. Delete conflicting outputs
4. Delete conflicting outputs

```sh
flutter packages pub run build_runner build --delete-conflicting-outputs
Expand All @@ -34,7 +24,7 @@ This page will guide you through building ReVanced Manager from source.
> [!Note]
> Must be run every time you sync your local repository with the remote repository.
7. Build the APK
5. Build the APK

```sh
flutter build apk
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit e1c6f65

Please sign in to comment.