Skip to content

Commit

Permalink
build: Bump dependencies (#1311)
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX authored Oct 1, 2023
2 parents 37986c5 + 697ae92 commit 76b89ba
Show file tree
Hide file tree
Showing 23 changed files with 197 additions and 552 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

// ReVanced
implementation "app.revanced:revanced-patcher:14.2.2"
implementation "app.revanced:revanced-patcher:15.0.3"

// Signing & aligning
implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@ import app.revanced.manager.flutter.utils.zip.structures.ZipEntry
import app.revanced.patcher.PatchBundleLoader
import app.revanced.patcher.Patcher
import app.revanced.patcher.PatcherOptions
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
import app.revanced.patcher.extensions.PatchExtensions.dependencies
import app.revanced.patcher.extensions.PatchExtensions.description
import app.revanced.patcher.extensions.PatchExtensions.include
import app.revanced.patcher.extensions.PatchExtensions.patchName
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.cancel
import kotlinx.coroutines.runBlocking
import org.json.JSONArray
import org.json.JSONObject
import java.io.File
import java.io.PrintWriter
import java.io.StringWriter
import java.lang.Error
import java.util.logging.LogRecord
import java.util.logging.Logger

Expand Down Expand Up @@ -93,29 +91,42 @@ class MainActivity : FlutterActivity() {
}

"getPatches" -> {
val patchBundleFilePath = call.argument<String>("patchBundleFilePath")
val cacheDirPath = call.argument<String>("cacheDirPath")

if (patchBundleFilePath != null) {
val patches = PatchBundleLoader.Dex(
File(patchBundleFilePath),
optimizedDexDirectory = File(cacheDirPath)
).map { patch ->
val map = HashMap<String, Any>()
map["\"name\""] = "\"${patch.patchName.replace("\"","\\\"")}\""
map["\"description\""] = "\"${patch.description?.replace("\"","\\\"")}\""
map["\"excluded\""] = !patch.include
map["\"dependencies\""] = patch.dependencies?.map { "\"${it.java.patchName}\"" } ?: emptyList<Any>()
map["\"compatiblePackages\""] = patch.compatiblePackages?.map {
val map2 = HashMap<String, Any>()
map2["\"name\""] = "\"${it.name}\""
map2["\"versions\""] = it.versions.map { version -> "\"${version}\"" }
map2
} ?: emptyList<Any>()
map
val patchBundleFilePath = call.argument<String>("patchBundleFilePath")!!
val cacheDirPath = call.argument<String>("cacheDirPath")!!

JSONArray().apply {
try {
PatchBundleLoader.Dex(
File(patchBundleFilePath),
optimizedDexDirectory = File(cacheDirPath)
)
} catch (ex: Exception) {
return@setMethodCallHandler result.notImplemented()
} catch (err: Error) {
return@setMethodCallHandler result.notImplemented()
}.forEach {
JSONObject().apply {
put("name", it.name)
put("description", it.description)
put("excluded", !it.use)
put("compatiblePackages", JSONArray().apply {
it.compatiblePackages?.forEach { compatiblePackage ->
val compatiblePackageJson = JSONObject().apply {
put("name", compatiblePackage.name)
put(
"versions",
JSONArray().apply {
compatiblePackage.versions?.forEach { version ->
put(version)
}
})
}
put(compatiblePackageJson)
}
})
}.let(::put)
}
result.success(patches)
} else result.notImplemented()
}.toString().let(result::success)
}

else -> result.notImplemented()
Expand Down Expand Up @@ -168,8 +179,11 @@ class MainActivity : FlutterActivity() {
}

object : java.util.logging.Handler() {
override fun publish(record: LogRecord) =
override fun publish(record: LogRecord) {
if (record.loggerName?.startsWith("app.revanced") != true) return

updateProgress(-1.0, "", record.message)
}

override fun flush() = Unit
override fun close() = flush()
Expand Down Expand Up @@ -220,7 +234,7 @@ class MainActivity : FlutterActivity() {
val compatibleOrUniversal =
isCompatible || patch.compatiblePackages.isNullOrEmpty()

compatibleOrUniversal && selectedPatches.any { it == patch.patchName }
compatibleOrUniversal && selectedPatches.any { it == patch.name }
}

if (cancel) {
Expand Down Expand Up @@ -251,9 +265,9 @@ class MainActivity : FlutterActivity() {
val msg = patchResult.exception?.let {
val writer = StringWriter()
it.printStackTrace(PrintWriter(writer))
"${patchResult.patchName} failed: $writer"
"${patchResult.patch.name} failed: $writer"
} ?: run {
"${patchResult.patchName} succeeded"
"${patchResult.patch.name} succeeded"
}

updateProgress(progress, "", msg)
Expand Down
21 changes: 6 additions & 15 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"widgetTitle": "Dashboard",

"updatesSubtitle": "Updates",
"patchedSubtitle": "Patched applications",
"patchedSubtitle": "Patched apps",

"noUpdates": "No updates available",

"WIP": "Work in progress...",

"noInstallations": "No patched applications installed",
"noInstallations": "No patched apps installed",
"installUpdate": "Continue to install the update?",

"updateDialogTitle": "Update Manager",
Expand All @@ -56,9 +56,7 @@
"updatesDisabled": "Updating a patched app is currently disabled. Repatch the app again."
},
"applicationItem": {
"patchButton": "Patch",
"infoButton": "Info",
"changelogLabel": "Changelog"
"infoButton": "Info"
},
"latestCommitCard": {
"loadingLabel": "Loading...",
Expand All @@ -71,9 +69,8 @@
"widgetTitle": "Patcher",
"patchButton": "Patch",

"patchDialogText": "You have selected a resource patch and a split APK installation has been detected, so patching errors may occur.\nAre you sure you want to proceed?",
"armv7WarningDialogText": "Patching on ARMv7 devices is not yet supported and might fail. Proceed anyways?",
"splitApkWarningDialogText": "Patching a split APK is not yet supported and might fail. Proceed anyways?",

"removedPatchesWarningDialogText": "The following patches have been removed since the last time you used them.\n\n{patches}\n\nProceed anyways?"
},
"appSelectorCard": {
Expand Down Expand Up @@ -148,9 +145,8 @@
"installTypeDescription": "Select the installation type to proceed with.",

"installButton": "Install",
"installRootType": "Root",
"installNonRootType": "Non-root",
"installRecommendedType": "Recommended",
"installRootType": "Mount",
"installNonRootType": "Normal",

"pressBackAgain": "Press back again to cancel",
"openButton": "Open",
Expand All @@ -162,10 +158,6 @@
"exportApkButtonTooltip": "Export patched APK",
"exportLogButtonTooltip": "Export log",

"installErrorDialogTitle": "Error",
"installErrorDialogText1": "Root install is not possible with the current patches selection.\nRepatch your app or choose non-root install.",
"installErrorDialogText2": "Non-root install is not possible with the current patches selection.\nRepatch your app or choose root install if you have your device rooted.",
"installErrorDialogText3": "Root install is not possible as the original APK was selected from storage.\nSelect an installed app or choose non-root install.",
"noExit": "Installer is still running, cannot exit..."
},
"settingsView": {
Expand Down Expand Up @@ -285,7 +277,6 @@
"rootDialogText": "App was installed with superuser permissions, but currently ReVanced Manager has no permissions.\nPlease grant superuser permissions first.",

"packageNameLabel": "Package name",
"originalPackageNameLabel": "Original package name",
"installTypeLabel": "Installation type",
"rootTypeLabel": "Root",
"nonRootTypeLabel": "Non-root",
Expand Down
12 changes: 2 additions & 10 deletions lib/models/patch.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:revanced_manager/utils/string.dart';

part 'patch.g.dart';

Expand All @@ -9,26 +8,19 @@ class Patch {
required this.name,
required this.description,
required this.excluded,
required this.dependencies,
required this.compatiblePackages,
});

factory Patch.fromJson(Map<String, dynamic> json) => _$PatchFromJson(json);
final String name;
final String description;
final String? description;
final bool excluded;
final List<String> dependencies;
final List<Package> compatiblePackages;

Map<String, dynamic> toJson() => _$PatchToJson(this);

String getSimpleName() {
return name
.replaceAll('-', ' ')
.split('-')
.join(' ')
.toTitleCase()
.replaceFirst('Microg', 'MicroG');
return name;
}
}

Expand Down
6 changes: 0 additions & 6 deletions lib/models/patched_application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,19 @@ class PatchedApplication {
PatchedApplication({
required this.name,
required this.packageName,
required this.originalPackageName,
required this.version,
required this.apkFilePath,
required this.icon,
required this.patchDate,
this.isRooted = false,
this.isFromStorage = false,
this.hasUpdates = false,
this.appliedPatches = const [],
this.changelog = const [],
});

factory PatchedApplication.fromJson(Map<String, dynamic> json) =>
_$PatchedApplicationFromJson(json);
String name;
String packageName;
String originalPackageName;
String version;
final String apkFilePath;
@JsonKey(
Expand All @@ -36,9 +32,7 @@ class PatchedApplication {
DateTime patchDate;
bool isRooted;
bool isFromStorage;
bool hasUpdates;
List<String> appliedPatches;
List<String> changelog;

Map<String, dynamic> toJson() => _$PatchedApplicationToJson(this);

Expand Down
71 changes: 0 additions & 71 deletions lib/services/github_api.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:io';
import 'package:collection/collection.dart';
import 'package:dio/dio.dart';
Expand All @@ -7,7 +6,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:injectable/injectable.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/services/manager_api.dart';

@lazySingleton
Expand All @@ -21,17 +19,6 @@ class GithubAPI {
priority: CachePriority.high,
);

final Map<String, String> repoAppPath = {
'com.google.android.youtube': 'youtube',
'com.google.android.apps.youtube.music': 'music',
'com.twitter.android': 'twitter',
'com.reddit.frontpage': 'reddit',
'com.zhiliaoapp.musically': 'tiktok',
'de.dwd.warnapp': 'warnwetter',
'com.garzotto.pflotsh.ecmwf_a': 'ecmwf',
'com.spotify.music': 'spotify',
};

Future<void> initialize(String repoUrl) async {
try {
_dio = Dio(
Expand Down Expand Up @@ -142,38 +129,6 @@ class GithubAPI {
}
}

Future<List<String>> getCommits(
String packageName,
String repoName,
DateTime since,
) async {
final String path =
'src/main/kotlin/app/revanced/patches/${repoAppPath[packageName]}';
try {
final response = await _dio.get(
'/repos/$repoName/commits',
queryParameters: {
'path': path,
'since': since.toIso8601String(),
},
);
final List<dynamic> commits = response.data;
return commits
.map(
(commit) => commit['commit']['message'].split('\n')[0] +
' - ' +
commit['commit']['author']['name'] +
'\n' as String,
)
.toList();
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
return [];
}

Future<File?> getLatestReleaseFile(
String extension,
String repoName,
Expand Down Expand Up @@ -237,30 +192,4 @@ class GithubAPI {
}
return null;
}

Future<List<Patch>> getPatches(
String repoName,
String version,
String url,
) async {
List<Patch> patches = [];
try {
final File? f = await getPatchesReleaseFile(
'.json',
repoName,
version,
url,
);
if (f != null) {
final List<dynamic> list = jsonDecode(f.readAsStringSync());
patches = list.map((patch) => Patch.fromJson(patch)).toList();
}
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}

return patches;
}
}
Loading

0 comments on commit 76b89ba

Please sign in to comment.