From c7627ced8eee19cd44945ea4388b2ffe5e38b138 Mon Sep 17 00:00:00 2001 From: validcube Date: Mon, 29 Jul 2024 23:47:48 +0700 Subject: [PATCH] fix: Unable to install application regardless of preference Signed-off-by: validcube --- lib/services/manager_api.dart | 78 ------------------- .../views/installer/installer_viewmodel.dart | 4 +- .../appInfoView/app_info_viewmodel.dart | 14 ++-- 3 files changed, 9 insertions(+), 87 deletions(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 4f2f8974..ce26bf96 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -832,82 +832,4 @@ class ManagerAPI { selectedPatchesFile.deleteSync(); } } - - Future installTypeDialog(BuildContext context) async { - final ValueNotifier installType = ValueNotifier(0); - if (isRooted) { - await showDialog( - context: context, - barrierDismissible: false, - builder: (context) => AlertDialog( - title: Text(t.installerView.installType), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, - icon: const Icon(Icons.file_download_outlined), - contentPadding: const EdgeInsets.symmetric(vertical: 16), - content: SingleChildScrollView( - child: ValueListenableBuilder( - valueListenable: installType, - builder: (context, value, child) { - return Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 10, - ), - child: Text( - t.installerView.installTypeDescription, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Theme.of(context).colorScheme.secondary, - ), - ), - ), - RadioListTile( - title: Text(t.installerView.installNonRootType), - contentPadding: - const EdgeInsets.symmetric(horizontal: 16), - value: 0, - groupValue: value, - onChanged: (selected) { - installType.value = selected!; - }, - ), - RadioListTile( - title: Text(t.installerView.installRootType), - contentPadding: - const EdgeInsets.symmetric(horizontal: 16), - value: 1, - groupValue: value, - onChanged: (selected) { - installType.value = selected!; - }, - ), - ], - ); - }, - ), - ), - actions: [ - OutlinedButton( - child: Text(t.cancelButton), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - FilledButton( - child: Text(t.installerView.installButton), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ], - ), - ); - } - return false; - } } diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 9ec2e52b..2b197ad5 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -495,7 +495,7 @@ class InstallerViewModel extends BaseViewModel { Future installResult(BuildContext context, bool installAsRoot) async { isInstalling = true; try { - _app.isRooted = await _managerAPI.installTypeDialog(context); + _app.isRooted = installAsRoot; if (headerLogs != 'Installing...') { update( .85, @@ -512,7 +512,7 @@ class InstallerViewModel extends BaseViewModel { // In case a patch changed the app name or package name, // update the app info. final app = - await DeviceApps.getAppFromStorage(_patcherAPI.outFile!.path); + await DeviceApps.getAppFromStorage(_patcherAPI.outFile!.path); if (app != null) { _app.name = app.appName; _app.packageName = app.packageName; diff --git a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart index b5ec82ca..9f558f79 100644 --- a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart +++ b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart @@ -1,5 +1,6 @@ // ignore_for_file: use_build_context_synchronously import 'dart:math'; + import 'package:device_apps/device_apps.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; @@ -11,6 +12,7 @@ import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/root_api.dart'; import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.dart'; +import 'package:revanced_manager/ui/views/installer/installer_viewmodel.dart'; import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:stacked/stacked.dart'; @@ -25,11 +27,7 @@ class AppInfoViewModel extends BaseViewModel { BuildContext context, PatchedApplication app, ) async { - app.isRooted = await _managerAPI.installTypeDialog(context); - final int statusCode = await _patcherAPI.installPatchedFile(context, app); - if (statusCode == 0) { - locator().initialize(context); - } + locator().installTypeDialog(context); } Future exportApp( @@ -152,7 +150,7 @@ class AppInfoViewModel extends BaseViewModel { backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: Text(t.appInfoView.removeAppDialogText), actions: [ - OutlinedButton( + TextButton( child: Text(t.cancelButton), onPressed: () => Navigator.of(context).pop(), ), @@ -160,7 +158,9 @@ class AppInfoViewModel extends BaseViewModel { child: Text(t.okButton), onPressed: () => { _managerAPI.deleteLastPatchedApp(), - Navigator.of(context)..pop()..pop(), + Navigator.of(context) + ..pop() + ..pop(), locator().initialize(context), }, ),