From 1298a96b0e6e4e11a484215daf4c8146ad18ba46 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 23 Dec 2023 22:08:58 +0100 Subject: [PATCH] fix: Update the progress properly until installation finishes successfully --- .../revanced/manager/flutter/MainActivity.kt | 6 +++--- .../views/installer/installer_viewmodel.dart | 18 +++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) 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 6fe5438e..d015836e 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 @@ -366,7 +366,7 @@ class MainActivity : FlutterActivity() { return@Thread } - updateProgress(0.8, "Building...", "") + updateProgress(0.75, "Building...", "") val res = patcher.get() patcher.close() @@ -399,7 +399,7 @@ class MainActivity : FlutterActivity() { return@Thread } - updateProgress(0.9, "Signing...", "Signing APK") + updateProgress(0.8, "Signing...", "Signing APK") try { Signer("ReVanced", keystorePassword) @@ -409,7 +409,7 @@ class MainActivity : FlutterActivity() { e.printStackTrace() } - updateProgress(1.0, "Patched", "Patched") + updateProgress(.85, "Patched", "Patched") } catch (ex: Throwable) { if (!cancel) { val stack = ex.stackTraceToString() diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index f056baef..6c6f9a44 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -13,6 +13,7 @@ import 'package:revanced_manager/services/manager_api.dart'; 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/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/utils/about_info.dart'; import 'package:screenshot_callback/screenshot_callback.dart'; @@ -103,7 +104,7 @@ class InstallerViewModel extends BaseViewModel { isPatching = true; isInstalled = false; hasErrors = false; - } else if (value == 1.0) { + } else if (value == .85) { isPatching = false; hasErrors = false; await _managerAPI.savePatches( @@ -126,10 +127,10 @@ class InstallerViewModel extends BaseViewModel { if (logs[logs.length - 1] == '\n') { logs = logs.substring(0, logs.length - 1); } - Future.delayed(const Duration(milliseconds: 500)).then((value) { + Future.delayed(const Duration(milliseconds: 100)).then((value) { scrollController.animateTo( scrollController.position.maxScrollExtent, - duration: const Duration(milliseconds: 200), + duration: const Duration(milliseconds: 100), curve: Curves.fastOutSlowIn, ); }); @@ -455,7 +456,7 @@ class InstallerViewModel extends BaseViewModel { _app.isRooted = installAsRoot; if (headerLogs != 'Installing...') { update( - 1.0, + .85, 'Installing...', _app.isRooted ? 'Mounting patched app' : 'Installing patched app', ); @@ -482,20 +483,15 @@ class InstallerViewModel extends BaseViewModel { update(1.0, 'Installed', 'Installed'); } else if (response == 3) { update( - 1.0, + .85, 'Installation canceled', 'Installation canceled', ); } else if (response == 10) { installResult(context, installAsRoot); - update( - 1.0, - '', - 'Starting installer', - ); } else { update( - 1.0, + .85, 'Installation failed', 'Installation failed', );