mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-01 21:30:16 +02:00
WiFi only BG update toggle (#819) + typo fix
This commit is contained in:
@@ -252,7 +252,32 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall),
|
||||
height8
|
||||
height8,
|
||||
if (settingsProvider
|
||||
.enableBackgroundUpdates)
|
||||
Column(
|
||||
children: [
|
||||
height16,
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(tr(
|
||||
'bgUpdatesOnWiFiOnly'))),
|
||||
Switch(
|
||||
value: settingsProvider
|
||||
.bgUpdatesOnWiFiOnly,
|
||||
onChanged: (value) {
|
||||
settingsProvider
|
||||
.bgUpdatesOnWiFiOnly =
|
||||
value;
|
||||
})
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox.shrink();
|
||||
|
@@ -9,6 +9,7 @@ import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
|
||||
import 'package:android_intent_plus/flag.dart';
|
||||
import 'package:android_package_installer/android_package_installer.dart';
|
||||
import 'package:android_package_manager/android_package_manager.dart';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -366,7 +367,7 @@ class AppsProvider with ChangeNotifier {
|
||||
if (!settingsProvider.enableBackgroundUpdates) {
|
||||
return false;
|
||||
}
|
||||
if (app.additionalSettings['examptFromBackgroundUpdates'] == true) {
|
||||
if (app.additionalSettings['exemptFromBackgroundUpdates'] == true) {
|
||||
return false;
|
||||
}
|
||||
if (app.apkUrls.length > 1) {
|
||||
@@ -1323,6 +1324,12 @@ Future<void> bgUpdateCheck(int taskId, Map<String, dynamic>? params) async {
|
||||
// If in update mode...
|
||||
var didCompleteChecking = false;
|
||||
CheckingUpdatesNotification? notif;
|
||||
var networkRestricted = false;
|
||||
if (settingsProvider.bgUpdatesOnWiFiOnly) {
|
||||
var netResult = await (Connectivity().checkConnectivity());
|
||||
networkRestricted = (netResult != ConnectivityResult.wifi) &&
|
||||
(netResult != ConnectivityResult.ethernet);
|
||||
}
|
||||
// Loop through all updates and check each
|
||||
for (int i = 0; i < toCheck.length; i++) {
|
||||
var appId = toCheck[i].key;
|
||||
@@ -1335,8 +1342,9 @@ Future<void> bgUpdateCheck(int taskId, Map<String, dynamic>? params) async {
|
||||
cancelExisting: true);
|
||||
App? newApp = await appsProvider.checkUpdate(appId);
|
||||
if (newApp != null) {
|
||||
if (!(await appsProvider.canInstallSilently(
|
||||
app!.app, settingsProvider))) {
|
||||
if (networkRestricted ||
|
||||
!(await appsProvider.canInstallSilently(
|
||||
app!.app, settingsProvider))) {
|
||||
notificationsProvider.notify(
|
||||
UpdateNotification([newApp], id: newApp.id.hashCode - 1));
|
||||
} else {
|
||||
|
@@ -319,6 +319,15 @@ class SettingsProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool get bgUpdatesOnWiFiOnly {
|
||||
return prefs?.getBool('bgUpdatesOnWiFiOnly') ?? false;
|
||||
}
|
||||
|
||||
set bgUpdatesOnWiFiOnly(bool val) {
|
||||
prefs?.setBool('bgUpdatesOnWiFiOnly', val);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
DateTime get lastBGCheckTime {
|
||||
int? temp = prefs?.getInt('lastBGCheckTime');
|
||||
return temp != null
|
||||
|
@@ -427,8 +427,8 @@ abstract class AppSource {
|
||||
],
|
||||
[GeneratedFormTextField('appName', label: tr('appName'), required: false)],
|
||||
[
|
||||
GeneratedFormSwitch('examptFromBackgroundUpdates',
|
||||
label: tr('examptFromBackgroundUpdates'))
|
||||
GeneratedFormSwitch('exemptFromBackgroundUpdates',
|
||||
label: tr('exemptFromBackgroundUpdates'))
|
||||
]
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user