diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 5e60b1c..fb0c563 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ { } else if (action == 'app') { await context .read() - .importApps('[${Uri.decodeComponent(data)}]'); + .import('[${Uri.decodeComponent(data)}]'); } else if (action == 'apps') { - await context - .read() - .importApps(Uri.decodeComponent(data)); + await context.read().import(Uri.decodeComponent(data)); } else { throw ObtainiumError(tr('unknown')); } @@ -145,13 +143,13 @@ class _HomePageState extends State { AppsProvider appsProvider = context.watch(); SettingsProvider settingsProvider = context.watch(); - if (!prevIsLoading && - prevAppCount >= 0 && - appsProvider.apps.length > prevAppCount && - selectedIndexHistory.isNotEmpty && - selectedIndexHistory.last == 1) { - switchToPage(0); - } + // if (!prevIsLoading && + // prevAppCount >= 0 && + // appsProvider.apps.length > prevAppCount && + // selectedIndexHistory.isNotEmpty && + // selectedIndexHistory.last == 1) { + // switchToPage(0); + // } prevAppCount = appsProvider.apps.length; prevIsLoading = appsProvider.loadingApps; diff --git a/lib/pages/import_export.dart b/lib/pages/import_export.dart index 0083512..0a624e9 100644 --- a/lib/pages/import_export.dart +++ b/lib/pages/import_export.dart @@ -106,7 +106,7 @@ class _ImportExportPageState extends State { runObtainiumExport({bool pickOnly = false}) async { HapticFeedback.selectionClick(); appsProvider - .exportApps( + .export( pickOnly: pickOnly || (await settingsProvider.getExportDir()) == null, sp: settingsProvider) @@ -132,7 +132,7 @@ class _ImportExportPageState extends State { } catch (e) { throw ObtainiumError(tr('invalidInput')); } - appsProvider.importApps(data).then((value) { + appsProvider.import(data).then((value) { var cats = settingsProvider.categories; appsProvider.apps.forEach((key, value) { for (var c in value.app.categories) { @@ -143,7 +143,10 @@ class _ImportExportPageState extends State { }); appsProvider.addMissingCategories(settingsProvider); showMessage( - tr('importedX', args: [plural('apps', value)]), context); + '${tr('importedX', args: [ + plural('apps', value.key) + ])}${value.value ? ' + ${tr('settings')}' : ''}', + context); }); } else { // User canceled the picker diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 9130684..e76c1fd 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -974,7 +974,7 @@ class AppsProvider with ChangeNotifier { } } notifyListeners(); - exportApps(isAuto: true); + export(isAuto: true); } Future removeApps(List appIds) async { @@ -996,7 +996,7 @@ class AppsProvider with ChangeNotifier { } if (appIds.isNotEmpty) { notifyListeners(); - exportApps(isAuto: true); + export(isAuto: true); } } @@ -1173,11 +1173,8 @@ class AppsProvider with ChangeNotifier { return updateAppIds; } - Future exportApps( - {bool pickOnly = false, - isAuto = false, - SettingsProvider? sp, - bool includeSettings = false}) async { + Future export( + {bool pickOnly = false, isAuto = false, SettingsProvider? sp}) async { SettingsProvider settingsProvider = sp ?? this.settingsProvider; var exportDir = await settingsProvider.getExportDir(); if (isAuto) { @@ -1231,10 +1228,11 @@ class AppsProvider with ChangeNotifier { return returnPath; } - Future importApps(String appsJSON) async { + Future> import(String appsJSON) async { var decodedJSON = jsonDecode(appsJSON); + var newFormat = !(decodedJSON is List); List importedApps = - ((decodedJSON['apps'] ?? decodedJSON) as List) + ((newFormat ? decodedJSON['apps'] : decodedJSON) as List) .map((e) => App.fromJson(e)) .toList(); while (loadingApps) { @@ -1247,7 +1245,7 @@ class AppsProvider with ChangeNotifier { } await saveApps(importedApps, onlyIfExists: false); notifyListeners(); - if (decodedJSON['settings'] != null) { + if (newFormat && decodedJSON['settings'] != null) { var settingsMap = decodedJSON['settings'] as Map; settingsMap.forEach((key, value) { if (value is int) { @@ -1259,7 +1257,8 @@ class AppsProvider with ChangeNotifier { } }); } - return importedApps.length; + return MapEntry( + importedApps.length, newFormat && decodedJSON['settings'] != null); } @override