Fixed version extraction + re-added background wait

This commit is contained in:
Imran Remtulla
2022-08-23 16:12:37 -04:00
parent a2ef86c8b3
commit 6d5126162b
2 changed files with 21 additions and 5 deletions

View File

@@ -97,6 +97,19 @@ class AppsProvider with ChangeNotifier {
throw response.reasonPhrase ?? 'Unknown Error';
}
if (!isForeground) {
await notify(
1,
'Complete App Installation',
'Obtainium must be open to install Apps',
'COMPLETE_INSTALL',
'Complete App Installation',
'Asks the user to return to Obtanium to finish installing an App');
while (await FGBGEvents.stream.first != FGBGType.foreground) {
// We need to wait for the App to come to the foreground since the APK installer doesn't work otherwise
}
}
// 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
// This also does not use the 'session-based' installer API, so background/silent updates are impossible

View File

@@ -1,7 +1,6 @@
// Exposes functions related to interacting with App sources and retrieving App info
// Stateless - not a provider
import 'dart:convert';
import 'package:http/http.dart';
import 'package:html/parser.dart';
@@ -25,7 +24,7 @@ class APKDetails {
abstract class AppSource {
String standardizeURL(String url);
Future<APKDetails> getLatestAPKUrl(String standardUrl);
Future<APKDetails> getLatestAPKDetails(String standardUrl);
AppNames getAppNames(String standardUrl);
}
@@ -95,7 +94,7 @@ class GitHub implements AppSource {
}
@override
Future<APKDetails> getLatestAPKUrl(String standardUrl) async {
Future<APKDetails> getLatestAPKDetails(String standardUrl) async {
Response res = await get(Uri.parse('$standardUrl/releases/latest'));
if (res.statusCode == 200) {
var standardUri = Uri.parse(standardUrl);
@@ -106,7 +105,11 @@ class GitHub implements AppSource {
caseSensitive: false)
.hasMatch(element.attributes['href']!);
}).toList();
String? version = parsedHtml.querySelector('h1')?.innerHtml;
String? version = parsedHtml
.querySelector('.octicon-tag')
?.nextElementSibling
?.innerHtml
.trim();
if (apkUrlList.isEmpty || version == null) {
throw 'No APK found';
}
@@ -143,7 +146,7 @@ class SourceService {
AppSource source = getSource(url);
String standardUrl = source.standardizeURL(url);
AppNames names = source.getAppNames(standardUrl);
APKDetails apk = await source.getLatestAPKUrl(standardUrl);
APKDetails apk = await source.getLatestAPKDetails(standardUrl);
return App(
'${names.author}_${names.name}',
standardUrl,