From 6aa5b02110b8e4431142e969039be2ecede22c12 Mon Sep 17 00:00:00 2001 From: franzap <_@franzap.com> Date: Fri, 22 Nov 2024 19:27:41 -0300 Subject: [PATCH] Revert to previous install_plugin, closes #170 --- .../zapstore/app}/MainActivity.kt | 2 +- lib/models/app.dart | 68 ++++++++++++------- pubspec.lock | 49 +++++++------ pubspec.yaml | 15 ++-- 4 files changed, 75 insertions(+), 59 deletions(-) rename android/app/src/main/kotlin/{com/example/zapstore => dev/zapstore/app}/MainActivity.kt (67%) diff --git a/android/app/src/main/kotlin/com/example/zapstore/MainActivity.kt b/android/app/src/main/kotlin/dev/zapstore/app/MainActivity.kt similarity index 67% rename from android/app/src/main/kotlin/com/example/zapstore/MainActivity.kt rename to android/app/src/main/kotlin/dev/zapstore/app/MainActivity.kt index 54fc934..1b4c74a 100644 --- a/android/app/src/main/kotlin/com/example/zapstore/MainActivity.kt +++ b/android/app/src/main/kotlin/dev/zapstore/app/MainActivity.kt @@ -2,4 +2,4 @@ package dev.zapstore.app import io.flutter.embedding.android.FlutterActivity -class MainActivity: FlutterActivity() +class MainActivity: FlutterActivity() \ No newline at end of file diff --git a/lib/models/app.dart b/lib/models/app.dart index 1817653..9508f2e 100644 --- a/lib/models/app.dart +++ b/lib/models/app.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:io'; import 'dart:isolate'; -import 'package:android_package_installer/android_package_installer.dart'; import 'package:android_package_manager/android_package_manager.dart'; import 'package:async/async.dart'; import 'package:collection/collection.dart'; @@ -10,6 +9,7 @@ import 'package:convert/convert.dart'; import 'package:crypto/crypto.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_data/flutter_data.dart'; +import 'package:install_plugin/install_plugin.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:purplebase/purplebase.dart'; @@ -129,30 +129,52 @@ If you want to update anyway, you need to manually uninstall the app and install } notifier.state = RequestInstallProgress(); - final result = - await AndroidPackageInstaller.installApk(apkFilePath: file.path); - final installationStatus = - result != null ? PackageInstallerStatus.byCode(result) : null; - switch (installationStatus) { - case PackageInstallerStatus.success: - notifier.state = IdleInstallProgress(success: true); - await file.delete(); - await adapter.ref.localApps.localAppAdapter - .refreshUpdateStatus(appId: identifier); - Future.microtask(() { - notifier.state = IdleInstallProgress(); - }); - break; - case PackageInstallerStatus.failureAborted: - // Simply reset state + + // NOTE: Using https://github.com/hui-z/flutter_install_plugin + // Tried https://github.com/zapstore/android_package_installer + // but it is giving users problems (and for me it's slower) + // Probably need to fork hui-z's with support for user-canceled action + final result = await InstallPlugin.install(file.path); + + if (result['isSuccess']) { + notifier.state = IdleInstallProgress(success: true); + await file.delete(); + await adapter.ref.localApps.localAppAdapter + .refreshUpdateStatus(appId: identifier); + Future.microtask(() { notifier.state = IdleInstallProgress(); - break; - default: - notifier.state = ErrorInstallProgress( - Exception('Error installing app'), - info: installationStatus?.name, - ); + }); + } else { + const msg = 'App not installed'; + notifier.state = ErrorInstallProgress( + Exception(msg), + info: 'User canceled or error occured: ${result['errorMessage']}', + ); } + // final result = + // await AndroidPackageInstaller.installApk(apkFilePath: file.path); + // final installationStatus = + // result != null ? PackageInstallerStatus.byCode(result) : null; + // switch (installationStatus) { + // case PackageInstallerStatus.success: + // notifier.state = IdleInstallProgress(success: true); + // await file.delete(); + // await adapter.ref.localApps.localAppAdapter + // .refreshUpdateStatus(appId: identifier); + // Future.microtask(() { + // notifier.state = IdleInstallProgress(); + // }); + // break; + // case PackageInstallerStatus.failureAborted: + // // Simply reset state + // notifier.state = IdleInstallProgress(); + // break; + // default: + // notifier.state = ErrorInstallProgress( + // Exception('Error installing app'), + // info: installationStatus?.name, + // ); + // } } final fileExists = await file.exists(); diff --git a/pubspec.lock b/pubspec.lock index 3889ed6..64443b9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,15 +17,6 @@ packages: url: "https://pub.dev" source: hosted version: "6.4.1" - android_package_installer: - dependency: "direct main" - description: - path: "." - ref: ba2aa7a - resolved-ref: ba2aa7a11edc2649d1d80c25ed9291521262f714 - url: "https://github.com/zapstore/android_package_installer" - source: git - version: "0.0.1" android_package_manager: dependency: "direct main" description: @@ -586,6 +577,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.3+2" + install_plugin: + dependency: "direct main" + description: + name: install_plugin + sha256: "6fb67ba0781e75de4f2f2266ed25e835bfd277c5bfc2ed034af52774355857c6" + url: "https://pub.dev" + source: hosted + version: "2.1.0" intl: dependency: "direct main" description: @@ -630,18 +629,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: @@ -686,18 +685,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.12.0" mime: dependency: transitive description: @@ -901,11 +900,9 @@ packages: purplebase: dependency: "direct main" description: - path: "." - ref: cbe8342031adf908c8243125e176f52739d400d8 - resolved-ref: cbe8342031adf908c8243125e176f52739d400d8 - url: "https://github.com/purplebase/purplebase" - source: git + path: "../purplebase" + relative: true + source: path version: "0.2.0" quiver: dependency: transitive @@ -1164,10 +1161,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.0" timing: dependency: transitive description: @@ -1284,10 +1281,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "14.2.5" + version: "14.2.1" watcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8844683..da1d2ce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -46,18 +46,15 @@ dependencies: app_links: ^6.3.2 dart_emoji: ^0.2.0+2 remove_markdown: ^0.0.2 - android_package_installer: - git: - url: https://github.com/zapstore/android_package_installer - ref: ba2aa7a + install_plugin: ^2.1.0 shared_preferences: ^2.3.2 dependency_overrides: purplebase: - # path: ../purplebase - git: - url: https://github.com/purplebase/purplebase - ref: cbe8342031adf908c8243125e176f52739d400d8 + path: ../purplebase + # git: + # url: https://github.com/purplebase/purplebase + # ref: 0.2.0 flutter_data: git: url: https://github.com/zapstore/flutter_data @@ -98,7 +95,7 @@ icons_launcher: notification_image: "assets/images/logo.png" adaptive_background_image: "assets/images/logo-bg.png" adaptive_foreground_image: "assets/images/logo-fg.png" - adaptive_monochrome_image: "assets/images/logo-fg.png" + adaptive_monochrome_image: "assets/images/logo-bw.png" macos: enable: true image_path: "assets/images/logo.png"