mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-13 05:16:43 +02:00
bugs
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
|
@ -77,11 +77,9 @@ class _HomePageState extends State<HomePage> {
|
||||
} else if (action == 'app') {
|
||||
await context
|
||||
.read<AppsProvider>()
|
||||
.importApps('[${Uri.decodeComponent(data)}]');
|
||||
.import('[${Uri.decodeComponent(data)}]');
|
||||
} else if (action == 'apps') {
|
||||
await context
|
||||
.read<AppsProvider>()
|
||||
.importApps(Uri.decodeComponent(data));
|
||||
await context.read<AppsProvider>().import(Uri.decodeComponent(data));
|
||||
} else {
|
||||
throw ObtainiumError(tr('unknown'));
|
||||
}
|
||||
@ -145,13 +143,13 @@ class _HomePageState extends State<HomePage> {
|
||||
AppsProvider appsProvider = context.watch<AppsProvider>();
|
||||
SettingsProvider settingsProvider = context.watch<SettingsProvider>();
|
||||
|
||||
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;
|
||||
|
||||
|
@ -106,7 +106,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
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<ImportExportPage> {
|
||||
} 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<ImportExportPage> {
|
||||
});
|
||||
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
|
||||
|
@ -974,7 +974,7 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
exportApps(isAuto: true);
|
||||
export(isAuto: true);
|
||||
}
|
||||
|
||||
Future<void> removeApps(List<String> 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<String?> exportApps(
|
||||
{bool pickOnly = false,
|
||||
isAuto = false,
|
||||
SettingsProvider? sp,
|
||||
bool includeSettings = false}) async {
|
||||
Future<String?> 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<int> importApps(String appsJSON) async {
|
||||
Future<MapEntry<int, bool>> import(String appsJSON) async {
|
||||
var decodedJSON = jsonDecode(appsJSON);
|
||||
var newFormat = !(decodedJSON is List);
|
||||
List<App> importedApps =
|
||||
((decodedJSON['apps'] ?? decodedJSON) as List<dynamic>)
|
||||
((newFormat ? decodedJSON['apps'] : decodedJSON) as List<dynamic>)
|
||||
.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<String, Object?>;
|
||||
settingsMap.forEach((key, value) {
|
||||
if (value is int) {
|
||||
@ -1259,7 +1257,8 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
});
|
||||
}
|
||||
return importedApps.length;
|
||||
return MapEntry<int, bool>(
|
||||
importedApps.length, newFormat && decodedJSON['settings'] != null);
|
||||
}
|
||||
|
||||
@override
|
||||
|
Reference in New Issue
Block a user