Compare commits

..

11 Commits

Author SHA1 Message Date
oSumAtrIX
4505f10e50 build: bump version number 2022-12-14 06:04:42 +01:00
oSumAtrIX
3ce3df5e19 build: bump patcher version 2022-12-14 06:04:10 +01:00
Ushie
8d4e4ba6c9 feat: display app's patch count in appcard 2022-12-14 02:12:57 +03:00
Ushie
d78868b462 feat: filter apps by patch count 2022-12-14 01:52:06 +03:00
Canny
01a681ad00 build: bump version to v0.0.48 2022-12-12 22:34:39 +03:00
Canny
adfeb61eab fix: print patch fail cause if message is null 2022-12-12 22:32:11 +03:00
Ushie
8c3faac343 build: bump version to v0.0.47 2022-12-12 17:09:32 +03:00
Ushie
c81acce31c feat: improve patch fail logging 2022-12-12 17:09:32 +03:00
Aunali321
fe629ce77c Merge branch 'flutter' of https://github.com/revanced/revanced-manager into flutter 2022-12-11 18:04:06 +05:30
Aunali321
5c27add2b2 bump:bump version to v0.0.46 2022-12-11 18:04:00 +05:30
aliernfrog
ff90dae695 feat: add support for shared patches (#577)
* fix: avoid npe if a patch has empty compatible package.

* feat: support for shared patches

* fix: incorrect bool check and cleanup

Co-authored-by: Aunali321 <aunvakil.aa@gmail.com>
2022-12-11 18:00:44 +05:30
8 changed files with 76 additions and 30 deletions

View File

@@ -71,7 +71,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// ReVanced
implementation "app.revanced:revanced-patcher:6.3.0"
implementation "app.revanced:revanced-patcher:6.3.1"
// Signing & aligning
implementation("org.bouncycastle:bcpkix-jdk15on:1.70")

View File

@@ -174,7 +174,7 @@ class MainActivity : FlutterActivity() {
javaClass.classLoader
)
).loadPatches().filter { patch ->
patch.compatiblePackages!!.any { it.name == patcher.context.packageMetadata.packageName } &&
(patch.compatiblePackages?.any { it.name == patcher.context.packageMetadata.packageName } == true || patch.compatiblePackages.isNullOrEmpty()) &&
selectedPatches.any { it == patch.patchName }
}
} else {
@@ -196,7 +196,7 @@ class MainActivity : FlutterActivity() {
}
return@forEach
}
val msg = "$patch failed.\nError:\n" + res.exceptionOrNull()!!.printStackTrace()
val msg = "Failed to apply $patch: " + "${res.exceptionOrNull()!!.message ?: res.exceptionOrNull()!!.cause!!::class.simpleName}"
handler.post {
installerChannel.invokeMethod(
"update",

View File

@@ -54,6 +54,25 @@ class PatcherAPI {
Future<List<ApplicationWithIcon>> getFilteredInstalledApps() async {
List<ApplicationWithIcon> filteredApps = [];
bool? allAppsIncluded =
_patches.any((patch) => patch.compatiblePackages.isEmpty);
if (allAppsIncluded) {
var allPackages = await DeviceApps.getInstalledApplications(
includeAppIcons: true,
onlyAppsWithLaunchIntent: true,
);
allPackages.forEach((pkg) async {
if (!filteredApps.any((app) => app.packageName == pkg.packageName)) {
var appInfo = await DeviceApps.getApp(
pkg.packageName,
true,
) as ApplicationWithIcon?;
if (appInfo != null) {
filteredApps.add(appInfo);
}
}
});
}
for (Patch patch in _patches) {
for (Package package in patch.compatiblePackages) {
try {
@@ -75,12 +94,19 @@ class PatcherAPI {
return filteredApps;
}
Future<List<Patch>> getFilteredPatches(String packageName) async {
return _patches
.where((patch) =>
!patch.name.contains('settings') &&
patch.compatiblePackages.any((pack) => pack.name == packageName))
.toList();
List<Patch> getFilteredPatches(String packageName) {
List<Patch> filteredPatches = [];
_patches.forEach((patch) {
if (patch.compatiblePackages.isEmpty) {
filteredPatches.add(patch);
} else {
if (!patch.name.contains('settings') &&
patch.compatiblePackages.any((pack) => pack.name == packageName)) {
filteredPatches.add(patch);
}
}
});
return filteredPatches;
}
Future<List<Patch>> getAppliedPatches(List<String> appliedPatches) async {
@@ -229,7 +255,6 @@ class PatcherAPI {
return false;
}
void exportPatchedFile(String appName, String version) {
try {
if (_outFile != null) {
@@ -238,13 +263,12 @@ class PatcherAPI {
// This is temporary workaround to populate initial file name
// ref: https://github.com/Cleveroad/cr_file_saver/issues/7
int lastSeparator = _outFile!.path.lastIndexOf('/');
String newSourcePath = _outFile!.path.substring(0, lastSeparator + 1) + newName;
String newSourcePath =
_outFile!.path.substring(0, lastSeparator + 1) + newName;
_outFile!.copySync(newSourcePath);
CRFileSaver.saveFileWithDialog(SaveFileDialogParams(
sourceFilePath: newSourcePath,
destinationFileName: newName
));
sourceFilePath: newSourcePath, destinationFileName: newName));
}
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s);
@@ -267,10 +291,9 @@ class PatcherAPI {
}
String _getFileName(String appName, String version) {
String prefix = appName.toLowerCase().replaceAll(' ', '-');
String newName = '$prefix-revanced_v$version.apk';
return newName;
String prefix = appName.toLowerCase().replaceAll(' ', '-');
String newName = '$prefix-revanced_v$version.apk';
return newName;
}
Future<void> sharePatcherLog(String logs) async {

View File

@@ -92,6 +92,7 @@ class _AppSelectorViewState extends State<AppSelectorView> {
name: app.appName,
pkgName: app.packageName,
icon: app.icon,
patchesCount: model.patchesCount(app.packageName),
onTap: () {
model.selectApp(app);
Navigator.of(context).pop();

View File

@@ -2,7 +2,6 @@ import 'dart:io';
import 'package:device_apps/device_apps.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/patcher_api.dart';
@@ -16,10 +15,16 @@ class AppSelectorViewModel extends BaseViewModel {
final Toast _toast = locator<Toast>();
final List<ApplicationWithIcon> apps = [];
bool noApps = false;
int patchesCount(String packageName) {
return _patcherAPI.getFilteredPatches(packageName).length;
}
Future<void> initialize() async {
apps.addAll(await _patcherAPI.getFilteredInstalledApps());
apps.sort((a, b) => a.appName.compareTo(b.appName));
apps.sort(((a, b) => _patcherAPI
.getFilteredPatches(b.packageName)
.length
.compareTo(_patcherAPI.getFilteredPatches(a.packageName).length)));
noApps = apps.isEmpty;
notifyListeners();
}

View File

@@ -147,7 +147,7 @@ class PatchesSelectorViewModel extends BaseViewModel {
bool isPatchSupported(Patch patch) {
PatchedApplication app = locator<PatcherViewModel>().selectedApp!;
return patch.compatiblePackages.any((pack) =>
return patch.compatiblePackages.isEmpty || patch.compatiblePackages.any((pack) =>
pack.name == app.packageName &&
(pack.versions.isEmpty || pack.versions.contains(app.version)));
}

View File

@@ -6,6 +6,7 @@ class InstalledAppItem extends StatefulWidget {
final String name;
final String pkgName;
final Uint8List icon;
final int patchesCount;
final Function()? onTap;
const InstalledAppItem({
@@ -13,6 +14,7 @@ class InstalledAppItem extends StatefulWidget {
required this.name,
required this.pkgName,
required this.icon,
required this.patchesCount,
this.onTap,
}) : super(key: key);
@@ -45,14 +47,29 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.name,
maxLines: 2,
overflow: TextOverflow.visible,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
widget.name,
maxLines: 2,
overflow: TextOverflow.visible,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
const SizedBox(width: 6),
Text(
widget.patchesCount == 1
? "${widget.patchesCount} patch"
: "${widget.patchesCount} patches",
style: TextStyle(
fontSize: 8,
color: Theme.of(context).colorScheme.secondary,
),
),
],
),
const SizedBox(height: 4),
Text(widget.pkgName),

View File

@@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager
publish_to: 'none'
version: 0.0.45+45
version: 0.0.49+49
environment:
sdk: ">=2.17.5 <3.0.0"