mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-18 04:38:10 +02:00
Reduced dependece on fgbg thanks to new install plugin
This commit is contained in:
@@ -105,16 +105,19 @@ class AppsProvider with ChangeNotifier {
|
|||||||
osInfo.version.release!.compareTo('12') >= 0;
|
osInfo.version.release!.compareTo('12') >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> askUserToReturnToForeground(BuildContext context) async {
|
Future<void> askUserToReturnToForeground(BuildContext context,
|
||||||
|
{bool waitForFG = false}) async {
|
||||||
NotificationsProvider notificationsProvider =
|
NotificationsProvider notificationsProvider =
|
||||||
context.read<NotificationsProvider>();
|
context.read<NotificationsProvider>();
|
||||||
if (!isForeground) {
|
if (!isForeground) {
|
||||||
await notificationsProvider.notify(completeInstallationNotification,
|
await notificationsProvider.notify(completeInstallationNotification,
|
||||||
cancelExisting: true);
|
cancelExisting: true);
|
||||||
|
if (waitForFG) {
|
||||||
await FGBGEvents.stream.first == FGBGType.foreground;
|
await FGBGEvents.stream.first == FGBGType.foreground;
|
||||||
await notificationsProvider.cancel(completeInstallationNotification.id);
|
await notificationsProvider.cancel(completeInstallationNotification.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Unfortunately this 'await' does not actually wait for the APK to finish installing
|
// Unfortunately this 'await' does not actually wait for the APK to finish installing
|
||||||
// So we only know that the install prompt was shown, but the user could still cancel w/o us knowing
|
// So we only know that the install prompt was shown, but the user could still cancel w/o us knowing
|
||||||
@@ -143,8 +146,6 @@ class AppsProvider with ChangeNotifier {
|
|||||||
// If the App has more than one APK, the user should pick one (if context provided)
|
// If the App has more than one APK, the user should pick one (if context provided)
|
||||||
String? apkUrl = apps[id]!.app.apkUrls[apps[id]!.app.preferredApkIndex];
|
String? apkUrl = apps[id]!.app.apkUrls[apps[id]!.app.preferredApkIndex];
|
||||||
if (apps[id]!.app.apkUrls.length > 1 && context != null) {
|
if (apps[id]!.app.apkUrls.length > 1 && context != null) {
|
||||||
// ignore: use_build_context_synchronously
|
|
||||||
await askUserToReturnToForeground(context);
|
|
||||||
apkUrl = await showDialog(
|
apkUrl = await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext ctx) {
|
builder: (BuildContext ctx) {
|
||||||
@@ -155,8 +156,6 @@ class AppsProvider with ChangeNotifier {
|
|||||||
if (apkUrl != null &&
|
if (apkUrl != null &&
|
||||||
Uri.parse(apkUrl).origin != Uri.parse(apps[id]!.app.url).origin &&
|
Uri.parse(apkUrl).origin != Uri.parse(apps[id]!.app.url).origin &&
|
||||||
context != null) {
|
context != null) {
|
||||||
// ignore: use_build_context_synchronously
|
|
||||||
await askUserToReturnToForeground(context);
|
|
||||||
if (await showDialog(
|
if (await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext ctx) {
|
builder: (BuildContext ctx) {
|
||||||
|
Reference in New Issue
Block a user