fix: showing Installed when it's actually not (#1021)

This commit is contained in:
Aabed Khan 2023-07-15 06:55:36 +05:45 committed by GitHub
parent a879ac30fb
commit eb58475259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 11 deletions

View File

@ -1,12 +1,12 @@
import 'dart:io'; import 'dart:io';
import 'package:app_installer/app_installer.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:cr_file_saver/file_saver.dart'; import 'package:cr_file_saver/file_saver.dart';
import 'package:device_apps/device_apps.dart'; import 'package:device_apps/device_apps.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import 'package:install_plugin/install_plugin.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patch.dart';
@ -232,10 +232,8 @@ class PatcherAPI {
); );
} }
} else { } else {
await AppInstaller.installApk(_outFile!.path); final install = await InstallPlugin.installApk(_outFile!.path);
return await DeviceApps.isAppInstalled( return install['isSuccess'];
patchedApp.packageName,
);
} }
} on Exception catch (e) { } on Exception catch (e) {
if (kDebugMode) { if (kDebugMode) {

View File

@ -1,13 +1,13 @@
// ignore_for_file: use_build_context_synchronously // ignore_for_file: use_build_context_synchronously
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:app_installer/app_installer.dart';
import 'package:cross_connectivity/cross_connectivity.dart'; import 'package:cross_connectivity/cross_connectivity.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import 'package:install_plugin/install_plugin.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/app/app.router.dart'; import 'package:revanced_manager/app/app.router.dart';
@ -51,7 +51,7 @@ class HomeViewModel extends BaseViewModel {
_toast.showBottom('homeView.installingMessage'); _toast.showBottom('homeView.installingMessage');
final File? managerApk = await _managerAPI.downloadManager(); final File? managerApk = await _managerAPI.downloadManager();
if (managerApk != null) { if (managerApk != null) {
await AppInstaller.installApk(managerApk.path); await InstallPlugin.installApk(managerApk.path);
} else { } else {
_toast.showBottom('homeView.errorDownloadMessage'); _toast.showBottom('homeView.errorDownloadMessage');
} }
@ -72,7 +72,7 @@ class HomeViewModel extends BaseViewModel {
_toast.showBottom('homeView.installingMessage'); _toast.showBottom('homeView.installingMessage');
final File? managerApk = await _managerAPI.downloadManager(); final File? managerApk = await _managerAPI.downloadManager();
if (managerApk != null) { if (managerApk != null) {
await AppInstaller.installApk(managerApk.path); await InstallPlugin.installApk(managerApk.path);
} else { } else {
_toast.showBottom('homeView.errorDownloadMessage'); _toast.showBottom('homeView.errorDownloadMessage');
} }
@ -272,7 +272,7 @@ class HomeViewModel extends BaseViewModel {
child: CustomMaterialButton( child: CustomMaterialButton(
label: I18nText('updateButton'), label: I18nText('updateButton'),
onPressed: () async { onPressed: () async {
await AppInstaller.installApk( await InstallPlugin.installApk(
downloadedApk!.path, downloadedApk!.path,
); );
}, },
@ -318,7 +318,7 @@ class HomeViewModel extends BaseViewModel {
// UILocalNotificationDateInterpretation.absoluteTime, // UILocalNotificationDateInterpretation.absoluteTime,
// ); // );
_toast.showBottom('homeView.installingMessage'); _toast.showBottom('homeView.installingMessage');
await AppInstaller.installApk(managerApk.path); await InstallPlugin.installApk(managerApk.path);
} else { } else {
_toast.showBottom('homeView.errorDownloadMessage'); _toast.showBottom('homeView.errorDownloadMessage');
} }

View File

@ -11,7 +11,6 @@ environment:
dependencies: dependencies:
animations: ^2.0.7 animations: ^2.0.7
app_installer: ^1.1.0
collection: ^1.17.0 collection: ^1.17.0
cross_connectivity: ^3.0.5 cross_connectivity: ^3.0.5
cr_file_saver: cr_file_saver:
@ -75,6 +74,7 @@ dependencies:
flutter_dotenv: ^5.0.2 flutter_dotenv: ^5.0.2
flutter_markdown: ^0.6.14 flutter_markdown: ^0.6.14
dio_cache_interceptor: ^3.4.0 dio_cache_interceptor: ^3.4.0
install_plugin: ^2.1.0
dev_dependencies: dev_dependencies:
json_serializable: ^6.6.1 json_serializable: ^6.6.1