mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-31 05:23:28 +01:00 
			
		
		
		
	Compare commits
	
		
			6 Commits
		
	
	
		
			v0.5.5-bet
			...
			v0.5.10-be
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | a954a627fd | ||
|  | 52ce5b19c4 | ||
|  | 03f0b6cf05 | ||
|  | 5d8d0de8de | ||
|  | 07f6d4ad2c | ||
|  | dfbb4e19a5 | 
| @@ -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.5-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES | ||||
|     'v0.5.10-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES | ||||
|  | ||||
| const String bgUpdateCheckTaskName = 'bg-update-check'; | ||||
|  | ||||
| @@ -31,8 +31,10 @@ bgUpdateCheck(int? ignoreAfterMicroseconds) async { | ||||
|     List<String> existingUpdateIds = | ||||
|         appsProvider.getExistingUpdates(installedOnly: true); | ||||
|     DateTime nextIgnoreAfter = DateTime.now(); | ||||
|     String? err; | ||||
|     try { | ||||
|       await appsProvider.checkUpdates(ignoreAfter: ignoreAfter); | ||||
|       await appsProvider.checkUpdates( | ||||
|           ignoreAfter: ignoreAfter, immediatelyThrowRateLimitError: true); | ||||
|     } catch (e) { | ||||
|       if (e is RateLimitError) { | ||||
|         String nextTaskName = | ||||
| @@ -42,7 +44,7 @@ bgUpdateCheck(int? ignoreAfterMicroseconds) async { | ||||
|             initialDelay: Duration(minutes: e.remainingMinutes), | ||||
|             inputData: {'ignoreAfter': nextIgnoreAfter.microsecondsSinceEpoch}); | ||||
|       } else { | ||||
|         rethrow; | ||||
|         err = e.toString(); | ||||
|       } | ||||
|     } | ||||
|     List<App> newUpdates = appsProvider | ||||
| @@ -69,6 +71,9 @@ bgUpdateCheck(int? ignoreAfterMicroseconds) async { | ||||
|       notificationsProvider.notify(UpdateNotification(newUpdates), | ||||
|           cancelExisting: true); | ||||
|     } | ||||
|     if (err != null) { | ||||
|       throw err; | ||||
|     } | ||||
|     return Future.value(true); | ||||
|   } catch (e) { | ||||
|     notificationsProvider.notify(ErrorCheckingUpdatesNotification(e.toString()), | ||||
|   | ||||
| @@ -114,7 +114,7 @@ class AppsPageState extends State<AppsPage> { | ||||
|       return result; | ||||
|     }); | ||||
|  | ||||
|     if (settingsProvider.sortOrder == SortOrderSettings.ascending) { | ||||
|     if (settingsProvider.sortOrder == SortOrderSettings.descending) { | ||||
|       sortedApps = sortedApps.reversed.toList(); | ||||
|     } | ||||
|  | ||||
| @@ -340,16 +340,139 @@ class AppsPageState extends State<AppsPage> { | ||||
|                     : IconButton( | ||||
|                         visualDensity: VisualDensity.compact, | ||||
|                         onPressed: () { | ||||
|                           String urls = ''; | ||||
|                           for (var id in selectedIds) { | ||||
|                             urls += '${appsProvider.apps[id]!.app.url}\n'; | ||||
|                           } | ||||
|                           urls = urls.substring(0, urls.length - 1); | ||||
|                           Share.share(urls, | ||||
|                               subject: 'Selected App URLs from Obtainium'); | ||||
|                           showDialog( | ||||
|                               context: context, | ||||
|                               builder: (BuildContext ctx) { | ||||
|                                 return AlertDialog( | ||||
|                                   scrollable: true, | ||||
|                                   content: Padding( | ||||
|                                     padding: const EdgeInsets.only(top: 6), | ||||
|                                     child: Row( | ||||
|                                         mainAxisAlignment: | ||||
|                                             MainAxisAlignment.spaceBetween, | ||||
|                                         children: [ | ||||
|                                           IconButton( | ||||
|                                               onPressed: | ||||
|                                                   appsProvider | ||||
|                                                           .areDownloadsRunning() | ||||
|                                                       ? null | ||||
|                                                       : () { | ||||
|                                                           showDialog( | ||||
|                                                               context: context, | ||||
|                                                               builder: | ||||
|                                                                   (BuildContext | ||||
|                                                                       ctx) { | ||||
|                                                                 return AlertDialog( | ||||
|                                                                   title: Text( | ||||
|                                                                       'Mark ${selectedIds.length} Selected Apps as Not Installed?'), | ||||
|                                                                   actions: [ | ||||
|                                                                     TextButton( | ||||
|                                                                         onPressed: | ||||
|                                                                             () { | ||||
|                                                                           Navigator.of(context) | ||||
|                                                                               .pop(); | ||||
|                                                                         }, | ||||
|                                                                         child: const Text( | ||||
|                                                                             'No')), | ||||
|                                                                     TextButton( | ||||
|                                                                         onPressed: | ||||
|                                                                             () { | ||||
|                                                                           HapticFeedback | ||||
|                                                                               .selectionClick(); | ||||
|                                                                           appsProvider | ||||
|                                                                               .saveApps(selectedIds.map((e) { | ||||
|                                                                             var a = | ||||
|                                                                                 appsProvider.apps[e]!.app; | ||||
|                                                                             a.installedVersion = | ||||
|                                                                                 null; | ||||
|                                                                             return a; | ||||
|                                                                           }).toList()); | ||||
|  | ||||
|                                                                           Navigator.of(context) | ||||
|                                                                               .pop(); | ||||
|                                                                         }, | ||||
|                                                                         child: const Text( | ||||
|                                                                             'Yes')) | ||||
|                                                                   ], | ||||
|                                                                 ); | ||||
|                                                               }); | ||||
|                                                         }, | ||||
|                                               tooltip: | ||||
|                                                   'Mark Selected Apps as Not Installed', | ||||
|                                               icon: const Icon( | ||||
|                                                   Icons.no_cell_outlined)), | ||||
|                                           IconButton( | ||||
|                                               onPressed: | ||||
|                                                   appsProvider | ||||
|                                                           .areDownloadsRunning() | ||||
|                                                       ? null | ||||
|                                                       : () { | ||||
|                                                           showDialog( | ||||
|                                                               context: context, | ||||
|                                                               builder: | ||||
|                                                                   (BuildContext | ||||
|                                                                       ctx) { | ||||
|                                                                 return AlertDialog( | ||||
|                                                                   title: Text( | ||||
|                                                                       'Mark ${selectedIds.length} Selected Apps as Installed/Updated?'), | ||||
|                                                                   actions: [ | ||||
|                                                                     TextButton( | ||||
|                                                                         onPressed: | ||||
|                                                                             () { | ||||
|                                                                           Navigator.of(context) | ||||
|                                                                               .pop(); | ||||
|                                                                         }, | ||||
|                                                                         child: const Text( | ||||
|                                                                             'No')), | ||||
|                                                                     TextButton( | ||||
|                                                                         onPressed: | ||||
|                                                                             () { | ||||
|                                                                           HapticFeedback | ||||
|                                                                               .selectionClick(); | ||||
|                                                                           appsProvider | ||||
|                                                                               .saveApps(selectedIds.map((e) { | ||||
|                                                                             var a = | ||||
|                                                                                 appsProvider.apps[e]!.app; | ||||
|                                                                             a.installedVersion = | ||||
|                                                                                 a.latestVersion; | ||||
|                                                                             return a; | ||||
|                                                                           }).toList()); | ||||
|  | ||||
|                                                                           Navigator.of(context) | ||||
|                                                                               .pop(); | ||||
|                                                                         }, | ||||
|                                                                         child: const Text( | ||||
|                                                                             'Yes')) | ||||
|                                                                   ], | ||||
|                                                                 ); | ||||
|                                                               }); | ||||
|                                                         }, | ||||
|                                               tooltip: | ||||
|                                                   'Mark Selected Apps as Installed/Updated', | ||||
|                                               icon: const Icon(Icons.done)), | ||||
|                                           IconButton( | ||||
|                                             onPressed: () { | ||||
|                                               String urls = ''; | ||||
|                                               for (var id in selectedIds) { | ||||
|                                                 urls += | ||||
|                                                     '${appsProvider.apps[id]!.app.url}\n'; | ||||
|                                               } | ||||
|                                               urls = urls.substring( | ||||
|                                                   0, urls.length - 1); | ||||
|                                               Share.share(urls, | ||||
|                                                   subject: | ||||
|                                                       '${selectedIds.length} Selected App URLs from Obtainium'); | ||||
|                                             }, | ||||
|                                             tooltip: 'Share Selected App URLs', | ||||
|                                             icon: const Icon(Icons.share), | ||||
|                                           ), | ||||
|                                         ]), | ||||
|                                   ), | ||||
|                                 ); | ||||
|                               }); | ||||
|                         }, | ||||
|                         tooltip: 'Share Selected App URLs', | ||||
|                         icon: const Icon(Icons.share), | ||||
|                         tooltip: 'More', | ||||
|                         icon: const Icon(Icons.more_horiz), | ||||
|                       ), | ||||
|               ], | ||||
|             )), | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import 'package:flutter/material.dart'; | ||||
| import 'package:flutter/services.dart'; | ||||
| import 'package:install_plugin_v2/install_plugin_v2.dart'; | ||||
| import 'package:obtainium/app_sources/github.dart'; | ||||
| import 'package:obtainium/custom_errors.dart'; | ||||
| import 'package:obtainium/providers/notifications_provider.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import 'package:path_provider/path_provider.dart'; | ||||
| @@ -313,7 +314,8 @@ class AppsProvider with ChangeNotifier { | ||||
|     App newApp = await sourceProvider.getApp( | ||||
|         sourceProvider.getSource(currentApp.url), | ||||
|         currentApp.url, | ||||
|         currentApp.additionalData); | ||||
|         currentApp.additionalData, | ||||
|         customName: currentApp.name); | ||||
|     newApp.installedVersion = currentApp.installedVersion; | ||||
|     if (currentApp.preferredApkIndex < newApp.apkUrls.length) { | ||||
|       newApp.preferredApkIndex = currentApp.preferredApkIndex; | ||||
| @@ -322,8 +324,11 @@ class AppsProvider with ChangeNotifier { | ||||
|     return newApp.latestVersion != currentApp.latestVersion ? newApp : null; | ||||
|   } | ||||
|  | ||||
|   Future<List<App>> checkUpdates({DateTime? ignoreAfter}) async { | ||||
|   Future<List<App>> checkUpdates( | ||||
|       {DateTime? ignoreAfter, | ||||
|       bool immediatelyThrowRateLimitError = false}) async { | ||||
|     List<App> updates = []; | ||||
|     Map<String, List<String>> errors = {}; | ||||
|     if (!gettingUpdates) { | ||||
|       gettingUpdates = true; | ||||
|  | ||||
| @@ -339,14 +344,34 @@ class AppsProvider with ChangeNotifier { | ||||
|               DateTime.fromMicrosecondsSinceEpoch(0)) | ||||
|           .compareTo(apps[b]!.app.lastUpdateCheck ?? | ||||
|               DateTime.fromMicrosecondsSinceEpoch(0))); | ||||
|  | ||||
|       for (int i = 0; i < appIds.length; i++) { | ||||
|         App? newApp = await getUpdate(appIds[i]); | ||||
|         App? newApp; | ||||
|         try { | ||||
|           newApp = await getUpdate(appIds[i]); | ||||
|         } catch (e) { | ||||
|           if (e is RateLimitError && immediatelyThrowRateLimitError) { | ||||
|             rethrow; | ||||
|           } | ||||
|           var tempIds = errors.remove(e.toString()); | ||||
|           tempIds ??= []; | ||||
|           tempIds.add(appIds[i]); | ||||
|           errors.putIfAbsent(e.toString(), () => tempIds!); | ||||
|         } | ||||
|         if (newApp != null) { | ||||
|           updates.add(newApp); | ||||
|         } | ||||
|       } | ||||
|       gettingUpdates = false; | ||||
|     } | ||||
|     if (errors.isNotEmpty) { | ||||
|       String finalError = ''; | ||||
|       for (var e in errors.keys) { | ||||
|         finalError += | ||||
|             '$e ${errors[e]!.map((e) => apps[e]!.app.name).toString()}. '; | ||||
|       } | ||||
|       throw finalError; | ||||
|     } | ||||
|     return updates; | ||||
|   } | ||||
|  | ||||
| @@ -391,8 +416,8 @@ class AppsProvider with ChangeNotifier { | ||||
|     for (App a in importedApps) { | ||||
|       a.installedVersion = | ||||
|           apps.containsKey(a.id) ? apps[a]?.app.installedVersion : null; | ||||
|       await saveApps([a]); | ||||
|     } | ||||
|     await saveApps(importedApps); | ||||
|     notifyListeners(); | ||||
|     return importedApps.length; | ||||
|   } | ||||
|   | ||||
| @@ -74,8 +74,8 @@ class SettingsProvider with ChangeNotifier { | ||||
|   } | ||||
|  | ||||
|   SortColumnSettings get sortColumn { | ||||
|     return SortColumnSettings | ||||
|         .values[prefs?.getInt('sortColumn') ?? SortColumnSettings.added.index]; | ||||
|     return SortColumnSettings.values[ | ||||
|         prefs?.getInt('sortColumn') ?? SortColumnSettings.nameAuthor.index]; | ||||
|   } | ||||
|  | ||||
|   set sortColumn(SortColumnSettings s) { | ||||
| @@ -85,7 +85,7 @@ class SettingsProvider with ChangeNotifier { | ||||
|  | ||||
|   SortOrderSettings get sortOrder { | ||||
|     return SortOrderSettings.values[ | ||||
|         prefs?.getInt('sortOrder') ?? SortOrderSettings.descending.index]; | ||||
|         prefs?.getInt('sortOrder') ?? SortOrderSettings.ascending.index]; | ||||
|   } | ||||
|  | ||||
|   set sortOrder(SortOrderSettings s) { | ||||
|   | ||||
| @@ -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.5+26 # When changing this, update the tag in main() accordingly | ||||
| version: 0.5.10+31 # When changing this, update the tag in main() accordingly | ||||
|  | ||||
| environment: | ||||
|   sdk: '>=2.19.0-79.0.dev <3.0.0' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user