From 6487284dd2d99a1f050db51cfdc673dcead7ce31 Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Thu, 1 Sep 2022 13:52:51 +0100 Subject: [PATCH] fix: update name, version and icon when saving on prefs --- lib/models/patched_application.dart | 6 +++--- lib/services/manager_api.dart | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/models/patched_application.dart b/lib/models/patched_application.dart index 2a3747fe..438d025e 100644 --- a/lib/models/patched_application.dart +++ b/lib/models/patched_application.dart @@ -6,15 +6,15 @@ part 'patched_application.g.dart'; @JsonSerializable() class PatchedApplication { - final String name; + String name; final String packageName; - final String version; + String version; final String apkFilePath; @JsonKey( fromJson: decodeBase64, toJson: encodeBase64, ) - final Uint8List icon; + Uint8List icon; DateTime patchDate; final bool isRooted; final bool isFromStorage; diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 759a575a..e0af730e 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -68,6 +68,13 @@ class ManagerAPI { Future savePatchedApp(PatchedApplication app) async { List patchedApps = getPatchedApps(); patchedApps.removeWhere((a) => a.packageName == app.packageName); + ApplicationWithIcon? installed = + await DeviceApps.getApp(app.packageName, true) as ApplicationWithIcon?; + if (installed != null) { + app.name = installed.appName; + app.version = installed.versionName!; + app.icon = installed.icon; + } patchedApps.add(app); await setPatchedApps(patchedApps); }