From e142a5aa19aa292381307206dc434000f40dce1a Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Sun, 21 Aug 2022 02:58:40 +0100 Subject: [PATCH] feat: use default include property from patches --- .../src/main/kotlin/app/revanced/manager/MainActivity.kt | 6 ++++-- lib/models/patch.dart | 2 ++ lib/services/patcher_api.dart | 2 ++ lib/ui/views/home/home_viewmodel.dart | 3 --- .../views/patches_selector/patches_selector_viewmodel.dart | 5 +++++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt b/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt index fb4b9b5b..d41e5c6e 100644 --- a/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt +++ b/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt @@ -13,6 +13,7 @@ import app.revanced.patcher.PatcherOptions import app.revanced.patcher.data.Data import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages 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.extensions.PatchExtensions.version import app.revanced.patcher.patch.Patch @@ -149,7 +150,7 @@ class MainActivity : FlutterActivity() { ) { Thread( Runnable { - val filteredPatches = mutableListOf>() + val filteredPatches = mutableListOf>() patches.forEach patch@{ patch -> patch.compatiblePackages?.forEach { pkg -> if (pkg.name == targetPackage && @@ -157,10 +158,11 @@ class MainActivity : FlutterActivity() { pkg.versions.isNotEmpty() || pkg.versions.contains(targetVersion)) ) { - var p = mutableMapOf() + var p = mutableMapOf() p.put("name", patch.patchName) p.put("version", patch.version) p.put("description", patch.description) + p.put("include", patch.include) filteredPatches.add(p) } } diff --git a/lib/models/patch.dart b/lib/models/patch.dart index b9231198..6fa3da9f 100644 --- a/lib/models/patch.dart +++ b/lib/models/patch.dart @@ -3,11 +3,13 @@ class Patch { final String simpleName; final String version; final String description; + final bool include; Patch({ required this.name, required this.simpleName, required this.version, required this.description, + required this.include, }); } diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index b77d26b3..b7681e94 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -110,6 +110,7 @@ class PatcherAPI { .toTitleCase(), version: patch['version'] ?? '?.?.?', description: patch['description'] ?? 'N/A', + include: patch['include'] ?? true, ), ); } @@ -150,6 +151,7 @@ class PatcherAPI { .toTitleCase(), version: patch['version'] ?? '?.?.?', description: patch['description'] ?? 'N/A', + include: patch['include'] ?? true, ), ); } diff --git a/lib/ui/views/home/home_viewmodel.dart b/lib/ui/views/home/home_viewmodel.dart index 4bdfbc75..460bae38 100644 --- a/lib/ui/views/home/home_viewmodel.dart +++ b/lib/ui/views/home/home_viewmodel.dart @@ -9,7 +9,6 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:injectable/injectable.dart'; import 'package:revanced_manager/app/app.locator.dart'; -import 'package:revanced_manager/app/app.router.dart'; import 'package:revanced_manager/main_viewmodel.dart'; import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/services/manager_api.dart'; @@ -17,11 +16,9 @@ import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:stacked/stacked.dart'; -import 'package:stacked_services/stacked_services.dart'; @lazySingleton class HomeViewModel extends BaseViewModel { - final NavigationService _navigationService = locator(); final ManagerAPI _managerAPI = ManagerAPI(); final PatcherAPI _patcherAPI = locator(); final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = diff --git a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart index e0c43892..a0ee4195 100644 --- a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart +++ b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart @@ -14,6 +14,11 @@ class PatchesSelectorViewModel extends BaseViewModel { patches.addAll(await _patcherAPI.getFilteredPatches( locator().selectedApp, )); + for (Patch p in patches) { + if (p.include) { + selectedPatches.add(p); + } + } notifyListeners(); }