mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-31 05:23:28 +01:00 
			
		
		
		
	Added option to disable background update checking
This commit is contained in:
		| @@ -81,11 +81,15 @@ class MyApp extends StatelessWidget { | |||||||
|       settingsProvider.initializeSettings(); |       settingsProvider.initializeSettings(); | ||||||
|     } else { |     } else { | ||||||
|       // Register the background update task according to the user's setting |       // Register the background update task according to the user's setting | ||||||
|       Workmanager().registerPeriodicTask('bg-update-check', 'bg-update-check', |       if (settingsProvider.updateInterval > 0) { | ||||||
|           frequency: Duration(minutes: settingsProvider.updateInterval), |         Workmanager().registerPeriodicTask('bg-update-check', 'bg-update-check', | ||||||
|           initialDelay: Duration(minutes: settingsProvider.updateInterval), |             frequency: Duration(minutes: settingsProvider.updateInterval), | ||||||
|           constraints: Constraints(networkType: NetworkType.connected), |             initialDelay: Duration(minutes: settingsProvider.updateInterval), | ||||||
|           existingWorkPolicy: ExistingWorkPolicy.replace); |             constraints: Constraints(networkType: NetworkType.connected), | ||||||
|  |             existingWorkPolicy: ExistingWorkPolicy.replace); | ||||||
|  |       } else { | ||||||
|  |         Workmanager().cancelByUniqueName('bg-update-check'); | ||||||
|  |       } | ||||||
|       bool isFirstRun = settingsProvider.checkAndFlipFirstRun(); |       bool isFirstRun = settingsProvider.checkAndFlipFirstRun(); | ||||||
|       if (isFirstRun) { |       if (isFirstRun) { | ||||||
|         // If this is the first run, ask for notification permissions and add Obtainium to the Apps list |         // If this is the first run, ask for notification permissions and add Obtainium to the Apps list | ||||||
|   | |||||||
| @@ -103,6 +103,10 @@ class _SettingsPageState extends State<SettingsPage> { | |||||||
|                           value: 1440, |                           value: 1440, | ||||||
|                           child: Text('1 Day'), |                           child: Text('1 Day'), | ||||||
|                         ), |                         ), | ||||||
|  |                         DropdownMenuItem( | ||||||
|  |                           value: 0, | ||||||
|  |                           child: Text('Never - Manual Only'), | ||||||
|  |                         ), | ||||||
|                       ], |                       ], | ||||||
|                       onChanged: (value) { |                       onChanged: (value) { | ||||||
|                         if (value != null) { |                         if (value != null) { | ||||||
|   | |||||||
| @@ -45,7 +45,7 @@ class SettingsProvider with ChangeNotifier { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   set updateInterval(int min) { |   set updateInterval(int min) { | ||||||
|     prefs?.setInt('updateInterval', min < 15 ? 15 : min); |     prefs?.setInt('updateInterval', (min < 15 && min != 0) ? 15 : min); | ||||||
|     notifyListeners(); |     notifyListeners(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user