feat: use default include property from patches

This commit is contained in:
Alberto Ponces 2022-08-21 02:58:40 +01:00
parent 8434211b61
commit e142a5aa19
5 changed files with 13 additions and 5 deletions

View File

@ -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<Map<String, String?>>()
val filteredPatches = mutableListOf<Map<String, Any?>>()
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<String, String?>()
var p = mutableMapOf<String, Any?>()
p.put("name", patch.patchName)
p.put("version", patch.version)
p.put("description", patch.description)
p.put("include", patch.include)
filteredPatches.add(p)
}
}

View File

@ -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,
});
}

View File

@ -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,
),
);
}

View File

@ -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<NavigationService>();
final ManagerAPI _managerAPI = ManagerAPI();
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =

View File

@ -14,6 +14,11 @@ class PatchesSelectorViewModel extends BaseViewModel {
patches.addAll(await _patcherAPI.getFilteredPatches(
locator<PatcherViewModel>().selectedApp,
));
for (Patch p in patches) {
if (p.include) {
selectedPatches.add(p);
}
}
notifyListeners();
}