Typo: 'Installed' not 'Updated' (#1469) + Bugfix: Don't incorrectly show message when user cancels

This commit is contained in:
Imran Remtulla
2024-03-17 04:01:09 -04:00
parent 3943caeedb
commit e95f575530
2 changed files with 13 additions and 6 deletions

View File

@@ -361,6 +361,9 @@ class _AppPageState extends State<AppPage> {
!areDownloadsRunning !areDownloadsRunning
? () async { ? () async {
try { try {
var successMessage = app?.app.installedVersion == null
? tr('installed')
: tr('appsUpdated');
HapticFeedback.heavyImpact(); HapticFeedback.heavyImpact();
var res = await appsProvider.downloadAndInstallLatestApps( var res = await appsProvider.downloadAndInstallLatestApps(
app?.app.id != null ? [app!.app.id] : [], app?.app.id != null ? [app!.app.id] : [],
@@ -368,7 +371,7 @@ class _AppPageState extends State<AppPage> {
); );
if (res.isNotEmpty && !trackOnly) { if (res.isNotEmpty && !trackOnly) {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
showMessage(tr('appsUpdated'), context); showMessage(successMessage, context);
} }
if (res.isNotEmpty && mounted) { if (res.isNotEmpty && mounted) {
Navigator.of(context).pop(); Navigator.of(context).pop();

View File

@@ -563,13 +563,13 @@ class AppsProvider with ChangeNotifier {
zipFile: File(filePath), destinationDir: Directory(destinationPath)); zipFile: File(filePath), destinationDir: Directory(destinationPath));
} }
Future<void> installXApkDir(DownloadedXApkDir dir, Future<bool> installXApkDir(DownloadedXApkDir dir,
{bool needsBGWorkaround = false}) async { {bool needsBGWorkaround = false}) async {
// We don't know which APKs in an XAPK are supported by the user's device // We don't know which APKs in an XAPK are supported by the user's device
// So we try installing all of them and assume success if at least one installed // So we try installing all of them and assume success if at least one installed
// If 0 APKs installed, throw the first install error encountered // If 0 APKs installed, throw the first install error encountered
try {
var somethingInstalled = false; var somethingInstalled = false;
try {
MultiAppMultiError errors = MultiAppMultiError(); MultiAppMultiError errors = MultiAppMultiError();
for (var file in dir.extracted for (var file in dir.extracted
.listSync(recursive: true, followLinks: false) .listSync(recursive: true, followLinks: false)
@@ -596,6 +596,7 @@ class AppsProvider with ChangeNotifier {
} finally { } finally {
dir.extracted.delete(recursive: true); dir.extracted.delete(recursive: true);
} }
return somethingInstalled;
} }
Future<bool> installApk(DownloadedApk file, Future<bool> installApk(DownloadedApk file,
@@ -828,17 +829,18 @@ class AppsProvider with ChangeNotifier {
notifyListeners(); notifyListeners();
try { try {
if (!skipInstalls) { if (!skipInstalls) {
bool sayInstalled = true;
if (downloadedFile != null) { if (downloadedFile != null) {
if (willBeSilent && context == null) { if (willBeSilent && context == null) {
installApk(downloadedFile, needsBGWorkaround: true); installApk(downloadedFile, needsBGWorkaround: true);
} else { } else {
await installApk(downloadedFile); sayInstalled = await installApk(downloadedFile);
} }
} else { } else {
if (willBeSilent && context == null) { if (willBeSilent && context == null) {
installXApkDir(downloadedDir!, needsBGWorkaround: true); installXApkDir(downloadedDir!, needsBGWorkaround: true);
} else { } else {
await installXApkDir(downloadedDir!); sayInstalled = await installXApkDir(downloadedDir!);
} }
} }
if (willBeSilent && context == null) { if (willBeSilent && context == null) {
@@ -846,8 +848,10 @@ class AppsProvider with ChangeNotifier {
[apps[id]!.app], [apps[id]!.app],
id: id.hashCode)); id: id.hashCode));
} }
if (sayInstalled) {
installedIds.add(id); installedIds.add(id);
} }
}
} finally { } finally {
apps[id]?.downloadProgress = null; apps[id]?.downloadProgress = null;
notifyListeners(); notifyListeners();