diff --git a/android/app/src/main/kotlin/app/revanced/manager/flutter/MainActivity.kt b/android/app/src/main/kotlin/app/revanced/manager/flutter/MainActivity.kt index ee84f070..8ff71d9d 100644 --- a/android/app/src/main/kotlin/app/revanced/manager/flutter/MainActivity.kt +++ b/android/app/src/main/kotlin/app/revanced/manager/flutter/MainActivity.kt @@ -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 { diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index bca0e902..c0f7d70e 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -54,6 +54,25 @@ class PatcherAPI { Future> getFilteredInstalledApps() async { List 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 { @@ -76,11 +95,19 @@ class PatcherAPI { } Future> getFilteredPatches(String packageName) async { - return _patches - .where((patch) => - !patch.name.contains('settings') && - patch.compatiblePackages.any((pack) => pack.name == packageName)) - .toList(); + List 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> getAppliedPatches(List appliedPatches) async { @@ -229,7 +256,6 @@ class PatcherAPI { return false; } - void exportPatchedFile(String appName, String version) { try { if (_outFile != null) { @@ -238,13 +264,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 +292,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 sharePatcherLog(String logs) async { diff --git a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart index 3af479b0..16c04012 100644 --- a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart +++ b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart @@ -147,7 +147,7 @@ class PatchesSelectorViewModel extends BaseViewModel { bool isPatchSupported(Patch patch) { PatchedApplication app = locator().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))); }