mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-09 16:50:14 +02:00
Bugfix for prev. commit
This commit is contained in:
@@ -615,7 +615,7 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
items: formItems.map((e) => [e]).toList(),
|
items: formItems.map((e) => [e]).toList(),
|
||||||
initValid: true,
|
initValid: true,
|
||||||
);
|
);
|
||||||
}).then((values) {
|
}).then((values) async {
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
if (values.isEmpty) {
|
if (values.isEmpty) {
|
||||||
values = getDefaultValuesFromFormItems([formItems]);
|
values = getDefaultValuesFromFormItems([formItems]);
|
||||||
@@ -623,29 +623,22 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
bool shouldInstallUpdates = values['updates'] == true;
|
bool shouldInstallUpdates = values['updates'] == true;
|
||||||
bool shouldInstallNew = values['installs'] == true;
|
bool shouldInstallNew = values['installs'] == true;
|
||||||
bool shouldMarkTrackOnlies = values['trackonlies'] == true;
|
bool shouldMarkTrackOnlies = values['trackonlies'] == true;
|
||||||
(() async {
|
List<String> toInstall = [];
|
||||||
List<String> toInstall = [];
|
if (shouldInstallUpdates) {
|
||||||
if (shouldInstallUpdates) {
|
toInstall.addAll(existingUpdateIdsAllOrSelected);
|
||||||
toInstall.addAll(existingUpdateIdsAllOrSelected);
|
}
|
||||||
}
|
if (shouldInstallNew) {
|
||||||
if (shouldInstallNew) {
|
toInstall.addAll(newInstallIdsAllOrSelected);
|
||||||
toInstall.addAll(newInstallIdsAllOrSelected);
|
}
|
||||||
}
|
if (shouldMarkTrackOnlies) {
|
||||||
if (shouldMarkTrackOnlies) {
|
toInstall.addAll(trackOnlyUpdateIdsAllOrSelected);
|
||||||
toInstall.addAll(trackOnlyUpdateIdsAllOrSelected);
|
}
|
||||||
}
|
appsProvider
|
||||||
if (toInstall.length > 1) {
|
.downloadAndInstallLatestApps(
|
||||||
// Permission is requested automatically, but if there are more than 1 installs,
|
toInstall, globalNavigatorKey.currentContext,
|
||||||
// We want to explicitly request it and wait for the result to avoid multiple requests
|
settingsProvider: settingsProvider)
|
||||||
await settingsProvider.getInstallPermission(
|
.catchError((e) {
|
||||||
enforce: false);
|
showError(e, context);
|
||||||
}
|
|
||||||
appsProvider
|
|
||||||
.downloadAndInstallLatestApps(
|
|
||||||
toInstall, globalNavigatorKey.currentContext)
|
|
||||||
.catchError((e) {
|
|
||||||
showError(e, context);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -351,7 +351,8 @@ class AppsProvider with ChangeNotifier {
|
|||||||
// If user input is needed and the App is in the background, a notification is sent to get the user's attention
|
// If user input is needed and the App is in the background, a notification is sent to get the user's attention
|
||||||
// Returns an array of Ids for Apps that were successfully downloaded, regardless of installation result
|
// Returns an array of Ids for Apps that were successfully downloaded, regardless of installation result
|
||||||
Future<List<String>> downloadAndInstallLatestApps(
|
Future<List<String>> downloadAndInstallLatestApps(
|
||||||
List<String> appIds, BuildContext? context) async {
|
List<String> appIds, BuildContext? context,
|
||||||
|
{SettingsProvider? settingsProvider}) async {
|
||||||
List<String> appsToInstall = [];
|
List<String> appsToInstall = [];
|
||||||
List<String> trackOnlyAppsToUpdate = [];
|
List<String> trackOnlyAppsToUpdate = [];
|
||||||
// For all specified Apps, filter out those for which:
|
// For all specified Apps, filter out those for which:
|
||||||
@@ -440,6 +441,11 @@ class AppsProvider with ChangeNotifier {
|
|||||||
silentUpdates = moveObtainiumToStart(silentUpdates);
|
silentUpdates = moveObtainiumToStart(silentUpdates);
|
||||||
regularInstalls = moveObtainiumToStart(regularInstalls);
|
regularInstalls = moveObtainiumToStart(regularInstalls);
|
||||||
|
|
||||||
|
if (!(await settingsProvider?.getInstallPermission(enforce: false) ??
|
||||||
|
true)) {
|
||||||
|
throw ObtainiumError(tr('cancelled'));
|
||||||
|
}
|
||||||
|
|
||||||
// // Install silent updates (uncomment when it works - TODO)
|
// // Install silent updates (uncomment when it works - TODO)
|
||||||
// for (var u in silentUpdates) {
|
// for (var u in silentUpdates) {
|
||||||
// await installApk(u, silent: true); // Would need to add silent option
|
// await installApk(u, silent: true); // Would need to add silent option
|
||||||
|
@@ -120,19 +120,20 @@ class SettingsProvider with ChangeNotifier {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getInstallPermission({bool enforce = false}) async {
|
Future<bool> getInstallPermission({bool enforce = false}) async {
|
||||||
while (!(await Permission.requestInstallPackages.isGranted)) {
|
while (!(await Permission.requestInstallPackages.isGranted)) {
|
||||||
// Explicit request as InstallPlugin request sometimes bugged
|
// Explicit request as InstallPlugin request sometimes bugged
|
||||||
Fluttertoast.showToast(
|
Fluttertoast.showToast(
|
||||||
msg: tr('pleaseAllowInstallPerm'), toastLength: Toast.LENGTH_LONG);
|
msg: tr('pleaseAllowInstallPerm'), toastLength: Toast.LENGTH_LONG);
|
||||||
if ((await Permission.requestInstallPackages.request()) ==
|
if ((await Permission.requestInstallPackages.request()) ==
|
||||||
PermissionStatus.granted) {
|
PermissionStatus.granted) {
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
if (!enforce) {
|
if (!enforce) {
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get showAppWebpage {
|
bool get showAppWebpage {
|
||||||
|
Reference in New Issue
Block a user