mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2026-01-29 22:01:06 +00:00
feat: root installation (wip)
This commit is contained in:
@@ -6,19 +6,24 @@ import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:package_archive_info/package_archive_info.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/models/application_info.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
import 'package:revanced_manager/services/patcher_api.dart';
|
||||
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class AppSelectorViewModel extends BaseViewModel {
|
||||
final PatcherAPI patcherAPI = locator<PatcherAPI>();
|
||||
bool isRooted = false;
|
||||
bool isFromStorage = false;
|
||||
List<ApplicationWithIcon> apps = [];
|
||||
ApplicationInfo? selectedApp;
|
||||
PatchedApplication? selectedApp;
|
||||
|
||||
Future<void> initialize() async {
|
||||
await getApps();
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
isRooted = prefs.getBool('isRooted') ?? false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -27,12 +32,15 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
apps = await patcherAPI.getFilteredInstalledApps();
|
||||
}
|
||||
|
||||
void selectApp(ApplicationWithIcon application) {
|
||||
ApplicationInfo app = ApplicationInfo(
|
||||
void selectApp(ApplicationWithIcon application) async {
|
||||
isFromStorage = false;
|
||||
PatchedApplication app = PatchedApplication(
|
||||
name: application.appName,
|
||||
packageName: application.packageName,
|
||||
version: application.versionName!,
|
||||
apkFilePath: application.apkFilePath,
|
||||
isRooted: isRooted,
|
||||
isFromStorage: isFromStorage,
|
||||
);
|
||||
locator<AppSelectorViewModel>().selectedApp = app;
|
||||
locator<PatchesSelectorViewModel>().selectedPatches.clear();
|
||||
@@ -41,6 +49,7 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
}
|
||||
|
||||
Future<void> selectAppFromStorage(BuildContext context) async {
|
||||
isFromStorage = true;
|
||||
try {
|
||||
FilePickerResult? result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
@@ -50,11 +59,13 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
File apkFile = File(result.files.single.path!);
|
||||
PackageArchiveInfo? packageArchiveInfo =
|
||||
await PackageArchiveInfo.fromPath(apkFile.path);
|
||||
ApplicationInfo app = ApplicationInfo(
|
||||
PatchedApplication app = PatchedApplication(
|
||||
name: packageArchiveInfo.appName,
|
||||
packageName: packageArchiveInfo.packageName,
|
||||
version: packageArchiveInfo.version,
|
||||
apkFilePath: result.files.single.path!,
|
||||
isRooted: isRooted,
|
||||
isFromStorage: isFromStorage,
|
||||
);
|
||||
locator<AppSelectorViewModel>().selectedApp = app;
|
||||
locator<PatchesSelectorViewModel>().selectedPatches.clear();
|
||||
|
||||
Reference in New Issue
Block a user