mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-19 13:09:30 +02:00
Bugfixes
This commit is contained in:
@@ -28,8 +28,8 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
SourceProvider sourceProvider = SourceProvider();
|
SourceProvider sourceProvider = SourceProvider();
|
||||||
var appsProvider = context.read<AppsProvider>();
|
var appsProvider = context.watch<AppsProvider>();
|
||||||
var settingsProvider = context.read<SettingsProvider>();
|
var settingsProvider = context.watch<SettingsProvider>();
|
||||||
|
|
||||||
var outlineButtonStyle = ButtonStyle(
|
var outlineButtonStyle = ButtonStyle(
|
||||||
shape: MaterialStateProperty.all(
|
shape: MaterialStateProperty.all(
|
||||||
@@ -102,10 +102,12 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
runObtainiumExport() {
|
runObtainiumExport() async {
|
||||||
HapticFeedback.selectionClick();
|
HapticFeedback.selectionClick();
|
||||||
appsProvider
|
appsProvider
|
||||||
.exportApps(pickOnly: settingsProvider.exportDir == null)
|
.exportApps(
|
||||||
|
pickOnly: (await settingsProvider.getExportDir()) == null,
|
||||||
|
sp: settingsProvider)
|
||||||
.then((String? result) {
|
.then((String? result) {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
showError(tr('exportedTo', args: [result]), context);
|
showError(tr('exportedTo', args: [result]), context);
|
||||||
@@ -305,56 +307,69 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
FutureBuilder(
|
||||||
children: [
|
future: settingsProvider.getExportDir(),
|
||||||
Expanded(
|
builder: (context, snapshot) {
|
||||||
child: TextButton(
|
return Column(
|
||||||
style: outlineButtonStyle,
|
children: [
|
||||||
onPressed: appsProvider.apps.isEmpty ||
|
Row(
|
||||||
importInProgress
|
children: [
|
||||||
? null
|
Expanded(
|
||||||
: runObtainiumExport,
|
child: TextButton(
|
||||||
child: Text(tr(
|
style: outlineButtonStyle,
|
||||||
settingsProvider.exportDir != null
|
onPressed: appsProvider.apps.isEmpty ||
|
||||||
? 'obtainiumExport'
|
importInProgress
|
||||||
: 'pickExportDirKeepLastN')))),
|
? null
|
||||||
const SizedBox(
|
: runObtainiumExport,
|
||||||
width: 16,
|
child: Text(tr(snapshot.data != null
|
||||||
),
|
? 'obtainiumExport'
|
||||||
Expanded(
|
: 'pickExportDir')),
|
||||||
child: TextButton(
|
)),
|
||||||
style: outlineButtonStyle,
|
const SizedBox(
|
||||||
onPressed: importInProgress
|
width: 16,
|
||||||
? null
|
),
|
||||||
: runObtainiumImport,
|
Expanded(
|
||||||
child: Text(tr('obtainiumImport'))))
|
child: TextButton(
|
||||||
],
|
style: outlineButtonStyle,
|
||||||
),
|
onPressed: importInProgress
|
||||||
if (settingsProvider.exportDir != null)
|
? null
|
||||||
Column(
|
: runObtainiumImport,
|
||||||
children: [
|
child: Text(tr('obtainiumImport'))))
|
||||||
const SizedBox(height: 16),
|
|
||||||
GeneratedForm(
|
|
||||||
items: [
|
|
||||||
[
|
|
||||||
GeneratedFormSwitch(
|
|
||||||
'autoExportOnChanges',
|
|
||||||
label: tr('autoExportOnChanges'),
|
|
||||||
defaultValue:
|
|
||||||
settingsProvider.autoExportOnChanges,
|
|
||||||
)
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
onValueChanges: (value, valid, isBuilding) {
|
),
|
||||||
if (valid && !isBuilding) {
|
if (snapshot.data != null)
|
||||||
if (value['autoExportOnChanges'] != null) {
|
Column(
|
||||||
settingsProvider.autoExportOnChanges =
|
children: [
|
||||||
value['autoExportOnChanges'] == true;
|
const SizedBox(height: 16),
|
||||||
}
|
GeneratedForm(
|
||||||
}
|
items: [
|
||||||
}),
|
[
|
||||||
],
|
GeneratedFormSwitch(
|
||||||
),
|
'autoExportOnChanges',
|
||||||
|
label: tr('autoExportOnChanges'),
|
||||||
|
defaultValue: settingsProvider
|
||||||
|
.autoExportOnChanges,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
],
|
||||||
|
onValueChanges:
|
||||||
|
(value, valid, isBuilding) {
|
||||||
|
if (valid && !isBuilding) {
|
||||||
|
if (value['autoExportOnChanges'] !=
|
||||||
|
null) {
|
||||||
|
settingsProvider
|
||||||
|
.autoExportOnChanges = value[
|
||||||
|
'autoExportOnChanges'] ==
|
||||||
|
true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
if (importInProgress)
|
if (importInProgress)
|
||||||
const Column(
|
const Column(
|
||||||
children: [
|
children: [
|
||||||
|
@@ -1095,8 +1095,10 @@ class AppsProvider with ChangeNotifier {
|
|||||||
return updateAppIds;
|
return updateAppIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> exportApps({bool pickOnly = false, isAuto = false}) async {
|
Future<String?> exportApps(
|
||||||
var exportDir = settingsProvider.exportDir;
|
{bool pickOnly = false, isAuto = false, SettingsProvider? sp}) async {
|
||||||
|
SettingsProvider settingsProvider = sp ?? this.settingsProvider;
|
||||||
|
var exportDir = await settingsProvider.getExportDir();
|
||||||
if (isAuto) {
|
if (isAuto) {
|
||||||
if (exportDir == null) {
|
if (exportDir == null) {
|
||||||
logs.add('Skipping auto-export as dir is not set.');
|
logs.add('Skipping auto-export as dir is not set.');
|
||||||
@@ -1112,13 +1114,12 @@ class AppsProvider with ChangeNotifier {
|
|||||||
logs.add('Previous auto-export deleted.');
|
logs.add('Previous auto-export deleted.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exportDir = settingsProvider.exportDir;
|
|
||||||
if (exportDir == null || pickOnly) {
|
if (exportDir == null || pickOnly) {
|
||||||
await settingsProvider.pickExportDirKeepLastN();
|
await settingsProvider.pickExportDir();
|
||||||
exportDir = settingsProvider.exportDir;
|
exportDir = await settingsProvider.getExportDir();
|
||||||
}
|
}
|
||||||
if (exportDir == null) {
|
if (exportDir == null) {
|
||||||
throw ObtainiumError(tr('unexpectedError'));
|
return null;
|
||||||
}
|
}
|
||||||
String? returnPath;
|
String? returnPath;
|
||||||
if (!pickOnly) {
|
if (!pickOnly) {
|
||||||
|
@@ -362,18 +362,25 @@ class SettingsProvider with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Uri? get exportDir {
|
Future<Uri?> getExportDir() async {
|
||||||
var uriString = prefs?.getString('exportDir');
|
var uriString = prefs?.getString('exportDir');
|
||||||
if (uriString != null) {
|
if (uriString != null) {
|
||||||
return Uri.parse(uriString);
|
Uri? uri = Uri.parse(uriString);
|
||||||
|
if (!(await saf.canRead(uri) ?? false) ||
|
||||||
|
!(await saf.canWrite(uri) ?? false)) {
|
||||||
|
uri = null;
|
||||||
|
prefs?.remove('exportDir');
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return uri;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> pickExportDirKeepLastN({bool remove = false}) async {
|
Future<void> pickExportDir({bool remove = false}) async {
|
||||||
var existingSAFPerms = (await saf.persistedUriPermissions()) ?? [];
|
var existingSAFPerms = (await saf.persistedUriPermissions()) ?? [];
|
||||||
var currentOneWayDataSyncDir = exportDir;
|
var currentOneWayDataSyncDir = await getExportDir();
|
||||||
Uri? newOneWayDataSyncDir;
|
Uri? newOneWayDataSyncDir;
|
||||||
if (!remove) {
|
if (!remove) {
|
||||||
newOneWayDataSyncDir = (await saf.openDocumentTree());
|
newOneWayDataSyncDir = (await saf.openDocumentTree());
|
||||||
|
Reference in New Issue
Block a user