diff --git a/lib/main.dart b/lib/main.dart index 9b16b6a..beda1ce 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,7 +14,7 @@ import 'package:dynamic_color/dynamic_color.dart'; import 'package:device_info_plus/device_info_plus.dart'; const String currentReleaseTag = - 'v0.5.3-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES + 'v0.5.4-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES const String bgUpdateCheckTaskName = 'bg-update-check'; @@ -28,8 +28,6 @@ bgUpdateCheck(int? ignoreAfterMicroseconds) async { var appsProvider = AppsProvider(); await notificationsProvider.cancel(ErrorCheckingUpdatesNotification('').id); await appsProvider.loadApps(); - // List existingUpdateIds = // TODO: Uncomment this and below when it works - // appsProvider.getExistingUpdates(installedOnly: true); List existingUpdateIds = appsProvider.getExistingUpdates(installedOnly: true); DateTime nextIgnoreAfter = DateTime.now(); @@ -52,11 +50,13 @@ bgUpdateCheck(int? ignoreAfterMicroseconds) async { .where((id) => !existingUpdateIds.contains(id)) .map((e) => appsProvider.apps[e]!.app) .toList(); + + // TODO: This silent update code doesn't work yet // List silentlyUpdated = await appsProvider // .downloadAndInstallLatestApp( // [...newUpdates.map((e) => e.id), ...existingUpdateIds], null); // if (silentlyUpdated.isNotEmpty) { - // newUpdates + // newUpdates = newUpdates // .where((element) => !silentlyUpdated.contains(element.id)) // .toList(); // notificationsProvider.notify( @@ -64,6 +64,7 @@ bgUpdateCheck(int? ignoreAfterMicroseconds) async { // silentlyUpdated.map((e) => appsProvider.apps[e]!.app).toList()), // cancelExisting: true); // } + if (newUpdates.isNotEmpty) { notificationsProvider.notify(UpdateNotification(newUpdates), cancelExisting: true); diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 4e03915..5dfbb9b 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -8,6 +8,7 @@ import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:obtainium/app_sources/github.dart'; import 'package:obtainium/providers/notifications_provider.dart'; import 'package:provider/provider.dart'; import 'package:path_provider/path_provider.dart'; @@ -194,6 +195,26 @@ class AppsProvider with ChangeNotifier { } } + // If Obtainium is being installed, it should be the last one + List moveObtainiumToEnd(List items) { + String obtainiumId = 'imranr98_obtainium_${GitHub().host}'; + ApkFile? temp; + items.removeWhere((element) { + bool res = element.appId == obtainiumId; + if (res) { + temp = element; + } + return res; + }); + if (temp != null) { + items.add(temp!); + } + return items; + } + + silentUpdates = moveObtainiumToEnd(silentUpdates); + regularInstalls = moveObtainiumToEnd(regularInstalls); + for (var u in silentUpdates) { await installApk(u); } diff --git a/pubspec.yaml b/pubspec.yaml index 13b6655..cbf995f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.5.3+24 # When changing this, update the tag in main() accordingly +version: 0.5.4+25 # When changing this, update the tag in main() accordingly environment: sdk: '>=2.19.0-79.0.dev <3.0.0'