mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-18 20:49:30 +02:00
@@ -19,7 +19,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:easy_localization/src/localization.dart';
|
||||
|
||||
const String currentVersion = '0.14.12';
|
||||
const String currentVersion = '0.14.13';
|
||||
const String currentReleaseTag =
|
||||
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
||||
|
||||
|
@@ -74,11 +74,6 @@ class AppsPageState extends State<AppsPage> {
|
||||
setState(() {
|
||||
refreshingSince = null;
|
||||
});
|
||||
if (settingsProvider.autoExportOnUpdateCheckKeepNum > 0) {
|
||||
appsProvider.exportApps(isAuto: true).then((value) {
|
||||
appsProvider.trimAutoExports();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -337,36 +337,19 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
GeneratedForm(
|
||||
items: [
|
||||
[
|
||||
GeneratedFormTextField(
|
||||
'autoExportOnUpdateCheckKeepNum',
|
||||
label: tr(
|
||||
'autoExportOnUpdateCheckKeepNum'),
|
||||
required: false,
|
||||
defaultValue: settingsProvider
|
||||
.autoExportOnUpdateCheckKeepNum
|
||||
.toString(),
|
||||
textInputType: const TextInputType
|
||||
.numberWithOptions(),
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
value ??= settingsProvider
|
||||
.autoExportOnUpdateCheckKeepNum
|
||||
.toString();
|
||||
return intValidator(value,
|
||||
positive: true);
|
||||
}
|
||||
])
|
||||
GeneratedFormSwitch(
|
||||
'autoExportOnChanges',
|
||||
label: tr('autoExportOnChanges'),
|
||||
defaultValue:
|
||||
settingsProvider.autoExportOnChanges,
|
||||
)
|
||||
]
|
||||
],
|
||||
onValueChanges: (value, valid, isBuilding) {
|
||||
if (valid && !isBuilding) {
|
||||
if (value[
|
||||
'autoExportOnUpdateCheckKeepNum'] !=
|
||||
null) {
|
||||
settingsProvider
|
||||
.autoExportOnUpdateCheckKeepNum =
|
||||
int.parse(value[
|
||||
'autoExportOnUpdateCheckKeepNum']);
|
||||
if (value['autoExportOnChanges'] != null) {
|
||||
settingsProvider.autoExportOnChanges =
|
||||
value['autoExportOnChanges'] == true;
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
@@ -16,7 +16,6 @@ import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:obtainium/app_sources/html.dart';
|
||||
import 'package:obtainium/components/generated_form.dart';
|
||||
import 'package:obtainium/components/generated_form_modal.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
@@ -917,6 +916,7 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
await exportApps(isAuto: true);
|
||||
}
|
||||
|
||||
Future<void> removeApps(List<String> appIds) async {
|
||||
@@ -938,6 +938,7 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
if (appIds.isNotEmpty) {
|
||||
notifyListeners();
|
||||
await exportApps(isAuto: true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1097,6 +1098,17 @@ class AppsProvider with ChangeNotifier {
|
||||
Future<String?> exportApps({bool pickOnly = false, isAuto = false}) async {
|
||||
if (isAuto) {
|
||||
logs.add('Started auto-export.');
|
||||
var exportDir = settingsProvider.exportDir;
|
||||
if (exportDir != null) {
|
||||
var files = await saf.listFiles(exportDir,
|
||||
columns: [saf.DocumentFileColumn.id]).toList();
|
||||
if (files.isNotEmpty) {
|
||||
for (var f in files) {
|
||||
saf.delete(f.uri);
|
||||
}
|
||||
logs.add('Previous auto-export deleted.');
|
||||
}
|
||||
}
|
||||
}
|
||||
var exportDir = settingsProvider.exportDir;
|
||||
if (exportDir == null || pickOnly) {
|
||||
@@ -1122,32 +1134,6 @@ class AppsProvider with ChangeNotifier {
|
||||
return returnPath;
|
||||
}
|
||||
|
||||
Future<void> trimAutoExports() async {
|
||||
var exportDir = settingsProvider.exportDir;
|
||||
if (exportDir != null) {
|
||||
var files = await saf
|
||||
.listFiles(exportDir, columns: [saf.DocumentFileColumn.id]).toList();
|
||||
var maxCount = settingsProvider.autoExportOnUpdateCheckKeepNum;
|
||||
if (files.length > maxCount) {
|
||||
files.sort((a, b) {
|
||||
if (a.name == null) {
|
||||
return -1;
|
||||
} else if (b.name == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return compareAlphaNumeric(a.name!, b.name!);
|
||||
}
|
||||
});
|
||||
files = files.reversed.toList();
|
||||
logs.add(
|
||||
'Deleting auto-exports older than ${files[maxCount - 1].uri.pathSegments.last}.');
|
||||
files.sublist(maxCount).forEach((f) {
|
||||
saf.delete(f.uri);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> importApps(String appsJSON) async {
|
||||
List<App> importedApps = (jsonDecode(appsJSON) as List<dynamic>)
|
||||
.map((e) => App.fromJson(e))
|
||||
@@ -1431,10 +1417,6 @@ Future<void> bgUpdateCheck(int taskId, Map<String, dynamic>? params) async {
|
||||
if (toNotify.isNotEmpty) {
|
||||
notificationsProvider.notify(UpdateNotification(toNotify));
|
||||
}
|
||||
if (appsProvider.settingsProvider.autoExportOnUpdateCheckKeepNum > 0) {
|
||||
await appsProvider.exportApps(isAuto: true);
|
||||
await appsProvider.trimAutoExports();
|
||||
}
|
||||
}
|
||||
// If you're done checking and found some silently installable updates, schedule another task which will run in install mode
|
||||
if (didCompleteChecking && toInstall.isNotEmpty) {
|
||||
|
@@ -391,12 +391,12 @@ class SettingsProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
int get autoExportOnUpdateCheckKeepNum {
|
||||
return prefs?.getInt('autoExportOnUpdateCheckKeepNum') ?? 0;
|
||||
bool get autoExportOnChanges {
|
||||
return prefs?.getBool('autoExportOnChanges') ?? false;
|
||||
}
|
||||
|
||||
set autoExportOnUpdateCheckKeepNum(int val) {
|
||||
prefs?.setInt('autoExportOnUpdateCheckKeepNum', val);
|
||||
set autoExportOnChanges(bool val) {
|
||||
prefs?.setBool('autoExportOnChanges', val);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user