fix: update name, version and icon when saving on prefs

This commit is contained in:
Alberto Ponces 2022-09-01 13:52:51 +01:00
parent 0ccf1fb3b8
commit 6487284dd2
2 changed files with 10 additions and 3 deletions

View File

@ -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;

View File

@ -68,6 +68,13 @@ class ManagerAPI {
Future<void> savePatchedApp(PatchedApplication app) async {
List<PatchedApplication> 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);
}