mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-01 05:10:15 +02:00
Synced
This commit is contained in:
@@ -76,16 +76,7 @@ class FDroid extends AppSource {
|
||||
'https://$host/repo/$appId',
|
||||
standardUrl,
|
||||
name,
|
||||
autoSelectHighestVersionCode:
|
||||
additionalSettings['autoSelectHighestVersionCode'] == true,
|
||||
trySelectingSuggestedVersionCode:
|
||||
additionalSettings['trySelectingSuggestedVersionCode'] == true,
|
||||
filterVersionsByRegEx:
|
||||
(additionalSettings['filterVersionsByRegEx'] as String?)
|
||||
?.isNotEmpty ==
|
||||
true
|
||||
? additionalSettings['filterVersionsByRegEx']
|
||||
: null);
|
||||
additionalSettings: additionalSettings);
|
||||
if (!hostChanged) {
|
||||
try {
|
||||
var res = await sourceRequest(
|
||||
@@ -166,12 +157,30 @@ class FDroid extends AppSource {
|
||||
|
||||
APKDetails getAPKUrlsFromFDroidPackagesAPIResponse(
|
||||
Response res, String apkUrlPrefix, String standardUrl, String sourceName,
|
||||
{bool autoSelectHighestVersionCode = false,
|
||||
bool trySelectingSuggestedVersionCode = false,
|
||||
String? filterVersionsByRegEx}) {
|
||||
{Map<String, dynamic> additionalSettings = const {}}) {
|
||||
var autoSelectHighestVersionCode =
|
||||
additionalSettings['autoSelectHighestVersionCode'] == true;
|
||||
var trySelectingSuggestedVersionCode =
|
||||
additionalSettings['trySelectingSuggestedVersionCode'] == true;
|
||||
var filterVersionsByRegEx =
|
||||
(additionalSettings['filterVersionsByRegEx'] as String?)?.isNotEmpty ==
|
||||
true
|
||||
? additionalSettings['filterVersionsByRegEx']
|
||||
: null;
|
||||
var apkFilterRegEx =
|
||||
(additionalSettings['apkFilterRegEx'] as String?)?.isNotEmpty == true
|
||||
? additionalSettings['apkFilterRegEx']
|
||||
: null;
|
||||
if (res.statusCode == 200) {
|
||||
var response = jsonDecode(res.body);
|
||||
List<dynamic> releases = response['packages'] ?? [];
|
||||
if (apkFilterRegEx != null) {
|
||||
releases = releases.where((rel) {
|
||||
String apk = '${apkUrlPrefix}_${rel['versionCode']}.apk';
|
||||
return filterApks([MapEntry(apk, apk)], apkFilterRegEx, false)
|
||||
.isNotEmpty;
|
||||
}).toList();
|
||||
}
|
||||
if (releases.isEmpty) {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:html/parser.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:obtainium/components/generated_form.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/providers/source_provider.dart';
|
||||
@@ -45,7 +46,7 @@ class FDroidRepo extends AppSource {
|
||||
String sourceSpecificStandardizeURL(String url) {
|
||||
var standardUri = Uri.parse(url);
|
||||
var pathSegments = standardUri.pathSegments;
|
||||
if (pathSegments.last == 'index.xml') {
|
||||
if (pathSegments.isNotEmpty && pathSegments.last == 'index.xml') {
|
||||
pathSegments.removeLast();
|
||||
standardUri = standardUri.replace(path: pathSegments.join('/'));
|
||||
}
|
||||
@@ -60,7 +61,7 @@ class FDroidRepo extends AppSource {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
url = removeQueryParamsFromUrl(standardizeUrl(url));
|
||||
var res = await sourceRequest('$url/index.xml', {});
|
||||
var res = await sourceRequestWithURLVariants(url, {});
|
||||
if (res.statusCode == 200) {
|
||||
var body = parse(res.body);
|
||||
Map<String, List<String>> results = {};
|
||||
@@ -72,7 +73,11 @@ class FDroidRepo extends AppSource {
|
||||
appId.contains(query) ||
|
||||
appName.contains(query) ||
|
||||
appDesc.contains(query)) {
|
||||
results['$url?appId=$appId'] = [appName, appDesc];
|
||||
results[
|
||||
'${res.request!.url.toString().split('/').reversed.toList().sublist(1).reversed.join('/')}?appId=$appId'] = [
|
||||
appName,
|
||||
appDesc
|
||||
];
|
||||
}
|
||||
});
|
||||
return results;
|
||||
@@ -102,6 +107,26 @@ class FDroidRepo extends AppSource {
|
||||
return app;
|
||||
}
|
||||
|
||||
Future<Response> sourceRequestWithURLVariants(
|
||||
String url,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var res = await sourceRequest(
|
||||
'$url${url.endsWith('/index.xml') ? '' : '/index.xml'}',
|
||||
additionalSettings);
|
||||
if (res.statusCode != 200) {
|
||||
var base = url.endsWith('/index.xml')
|
||||
? url.split('/').reversed.toList().sublist(1).reversed.join('/')
|
||||
: url;
|
||||
res = await sourceRequest('$base/repo/index.xml', additionalSettings);
|
||||
if (res.statusCode != 200) {
|
||||
res = await sourceRequest(
|
||||
'$base/fdroid/repo/index.xml', additionalSettings);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<APKDetails> getLatestAPKDetails(
|
||||
String standardUrl,
|
||||
@@ -117,9 +142,8 @@ class FDroidRepo extends AppSource {
|
||||
if (appIdOrName == null) {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
var res = await sourceRequest(
|
||||
'$standardUrl${standardUrl.endsWith('/index.xml') ? '' : '/index.xml'}',
|
||||
additionalSettings);
|
||||
var res =
|
||||
await sourceRequestWithURLVariants(standardUrl, additionalSettings);
|
||||
if (res.statusCode == 200) {
|
||||
var body = parse(res.body);
|
||||
var foundApps = body.querySelectorAll('application').where((element) {
|
||||
@@ -168,7 +192,8 @@ class FDroidRepo extends AppSource {
|
||||
latestVersionReleases = [latestVersionReleases[0]];
|
||||
}
|
||||
List<String> apkUrls = latestVersionReleases
|
||||
.map((e) => '$standardUrl/${e.querySelector('apkname')!.innerHtml}')
|
||||
.map((e) =>
|
||||
'${res.request!.url.toString().split('/').reversed.toList().sublist(1).reversed.join('/')}/${e.querySelector('apkname')!.innerHtml}')
|
||||
.toList();
|
||||
return APKDetails(latestVersion, getApkUrlsFromUrls(apkUrls),
|
||||
AppNames(authorName, appName),
|
||||
|
@@ -344,12 +344,14 @@ class GitHub extends AppSource {
|
||||
});
|
||||
}
|
||||
if (latestRelease != null &&
|
||||
(latestRelease['tag_name'] ?? latestRelease['name']) != null &&
|
||||
releases.isNotEmpty &&
|
||||
latestRelease !=
|
||||
(releases[releases.length - 1]['tag_name'] ??
|
||||
releases[0]['name'])) {
|
||||
var ind = releases.indexWhere((element) =>
|
||||
latestRelease == (element['tag_name'] ?? element['name']));
|
||||
(latestRelease['tag_name'] ?? latestRelease['name']) ==
|
||||
(element['tag_name'] ?? element['name']));
|
||||
if (ind >= 0) {
|
||||
releases.add(releases.removeAt(ind));
|
||||
}
|
||||
@@ -400,7 +402,7 @@ class GitHub extends AppSource {
|
||||
if (version == null) {
|
||||
throw NoVersionError();
|
||||
}
|
||||
var changeLog = targetRelease['body'].toString();
|
||||
var changeLog = (targetRelease['body'] ?? '').toString();
|
||||
return APKDetails(
|
||||
version,
|
||||
targetRelease['apkUrls'] as List<MapEntry<String, String>>,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:html/parser.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:obtainium/app_sources/github.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
@@ -72,14 +72,6 @@ class GitLab extends AppSource {
|
||||
return creds != null && creds.isNotEmpty ? creds : null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> getSourceNote() async {
|
||||
if ((await getPATIfAny({})) == null) {
|
||||
return '${tr('gitlabSourceNote')} ${hostChanged ? tr('addInfoBelow') : tr('addInfoInSettings')}';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, List<String>>> search(String query,
|
||||
{Map<String, dynamic> querySettings = const {}}) async {
|
||||
@@ -104,105 +96,90 @@ class GitLab extends AppSource {
|
||||
String? changeLogPageFromStandardUrl(String standardUrl) =>
|
||||
'$standardUrl/-/releases';
|
||||
|
||||
@override
|
||||
Future<Map<String, String>?> getRequestHeaders(
|
||||
Map<String, dynamic> additionalSettings,
|
||||
{bool forAPKDownload = false}) async {
|
||||
// Change headers to pacify, e.g. cloudflare protection
|
||||
// Related to: (#1397, #1389, #1384, #1382, #1381, #1380, #1359, #854, #785, #697)
|
||||
var headers = <String, String>{};
|
||||
headers[HttpHeaders.refererHeader] = 'https://${hosts[0]}';
|
||||
if (headers.isNotEmpty) {
|
||||
return headers;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<APKDetails> getLatestAPKDetails(
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
// Prepare request params
|
||||
var names = GitHub().getAppNames(standardUrl);
|
||||
String? PAT = await getPATIfAny(hostChanged ? additionalSettings : {});
|
||||
String optionalAuth = (PAT != null) ? 'private_token=$PAT' : '';
|
||||
|
||||
bool trackOnly = additionalSettings['trackOnly'] == true;
|
||||
|
||||
// Request data from REST API
|
||||
Response res = await sourceRequest(
|
||||
'https://${hosts[0]}/api/v4/projects/${names.author}%2F${names.name}/${trackOnly ? 'repository/tags' : 'releases'}?$optionalAuth',
|
||||
additionalSettings);
|
||||
if (res.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
|
||||
// Extract .apk details from received data
|
||||
Iterable<APKDetails> apkDetailsList = [];
|
||||
var json = jsonDecode(res.body) as List<dynamic>;
|
||||
apkDetailsList = json.map((e) {
|
||||
var apkUrlsFromAssets = (e['assets']?['links'] as List<dynamic>? ?? [])
|
||||
.map((e) {
|
||||
return (e['direct_asset_url'] ?? e['url'] ?? '') as String;
|
||||
})
|
||||
.where((s) => s.isNotEmpty)
|
||||
.toList();
|
||||
List<String> uploadedAPKsFromDescription =
|
||||
((e['description'] ?? '') as String)
|
||||
.split('](')
|
||||
.join('\n')
|
||||
.split('.apk)')
|
||||
.join('.apk\n')
|
||||
.split('\n')
|
||||
.where((s) => s.startsWith('/uploads/') && s.endsWith('apk'))
|
||||
.map((s) => '$standardUrl$s')
|
||||
.toList();
|
||||
var apkUrlsSet = apkUrlsFromAssets.toSet();
|
||||
apkUrlsSet.addAll(uploadedAPKsFromDescription);
|
||||
var releaseDateString = e['released_at'] ?? e['created_at'];
|
||||
DateTime? releaseDate =
|
||||
releaseDateString != null ? DateTime.parse(releaseDateString) : null;
|
||||
return APKDetails(
|
||||
e['tag_name'] ?? e['name'],
|
||||
getApkUrlsFromUrls(apkUrlsSet.toList()),
|
||||
GitHub().getAppNames(standardUrl),
|
||||
releaseDate: releaseDate);
|
||||
});
|
||||
if (apkDetailsList.isEmpty) {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
var finalResult = apkDetailsList.first;
|
||||
|
||||
// Fallback procedure
|
||||
bool fallbackToOlderReleases =
|
||||
additionalSettings['fallbackToOlderReleases'] == true;
|
||||
String? PAT = await getPATIfAny(hostChanged ? additionalSettings : {});
|
||||
Iterable<APKDetails> apkDetailsList = [];
|
||||
if (PAT != null) {
|
||||
var names = GitHub().getAppNames(standardUrl);
|
||||
Response res = await sourceRequest(
|
||||
'https://${hosts[0]}/api/v4/projects/${names.author}%2F${names.name}/releases?private_token=$PAT',
|
||||
additionalSettings);
|
||||
if (res.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
var json = jsonDecode(res.body) as List<dynamic>;
|
||||
apkDetailsList = json.map((e) {
|
||||
var apkUrlsFromAssets = (e['assets']?['links'] as List<dynamic>? ?? [])
|
||||
.map((e) {
|
||||
return (e['direct_asset_url'] ?? e['url'] ?? '') as String;
|
||||
})
|
||||
.where((s) => s.isNotEmpty)
|
||||
.toList();
|
||||
List<String> uploadedAPKsFromDescription =
|
||||
((e['description'] ?? '') as String)
|
||||
.split('](')
|
||||
.join('\n')
|
||||
.split('.apk)')
|
||||
.join('.apk\n')
|
||||
.split('\n')
|
||||
.where((s) => s.startsWith('/uploads/') && s.endsWith('apk'))
|
||||
.map((s) => '$standardUrl$s')
|
||||
.toList();
|
||||
var apkUrlsSet = apkUrlsFromAssets.toSet();
|
||||
apkUrlsSet.addAll(uploadedAPKsFromDescription);
|
||||
var releaseDateString = e['released_at'] ?? e['created_at'];
|
||||
DateTime? releaseDate = releaseDateString != null
|
||||
? DateTime.parse(releaseDateString)
|
||||
: null;
|
||||
return APKDetails(
|
||||
e['tag_name'] ?? e['name'],
|
||||
getApkUrlsFromUrls(apkUrlsSet.toList()),
|
||||
GitHub().getAppNames(standardUrl),
|
||||
releaseDate: releaseDate);
|
||||
});
|
||||
} else {
|
||||
Response res = await sourceRequest(
|
||||
'$standardUrl/-/tags?format=atom', additionalSettings);
|
||||
if (res.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
var standardUri = Uri.parse(standardUrl);
|
||||
var parsedHtml = parse(res.body);
|
||||
apkDetailsList = parsedHtml.querySelectorAll('entry').map((entry) {
|
||||
var entryContent = parse(
|
||||
parseFragment(entry.querySelector('content')!.innerHtml).text);
|
||||
var apkUrls = [
|
||||
...getLinksFromParsedHTML(
|
||||
entryContent,
|
||||
RegExp(
|
||||
'^${standardUri.path.replaceAllMapped(RegExp(r'[.*+?^${}()|[\]\\]'), (x) {
|
||||
return '\\${x[0]}';
|
||||
})}/uploads/[^/]+/[^/]+\\.apk\$',
|
||||
caseSensitive: false),
|
||||
standardUri.origin),
|
||||
// GitLab releases may contain links to externally hosted APKs
|
||||
...getLinksFromParsedHTML(entryContent,
|
||||
RegExp('/[^/]+\\.apk\$', caseSensitive: false), '')
|
||||
.where((element) => Uri.parse(element).host != '')
|
||||
];
|
||||
var entryId = entry.querySelector('id')?.innerHtml;
|
||||
var version =
|
||||
entryId == null ? null : Uri.parse(entryId).pathSegments.last;
|
||||
var releaseDateString = entry.querySelector('updated')?.innerHtml;
|
||||
DateTime? releaseDate = releaseDateString != null
|
||||
? DateTime.parse(releaseDateString)
|
||||
: null;
|
||||
if (version == null) {
|
||||
throw NoVersionError();
|
||||
}
|
||||
return APKDetails(version, getApkUrlsFromUrls(apkUrls),
|
||||
GitHub().getAppNames(standardUrl),
|
||||
releaseDate: releaseDate);
|
||||
});
|
||||
if (finalResult.apkUrls.isEmpty && fallbackToOlderReleases && !trackOnly) {
|
||||
apkDetailsList =
|
||||
apkDetailsList.where((e) => e.apkUrls.isNotEmpty).toList();
|
||||
finalResult = apkDetailsList.first;
|
||||
}
|
||||
if (apkDetailsList.isEmpty) {
|
||||
throw NoReleasesError(note: tr('gitlabSourceNote'));
|
||||
}
|
||||
if (fallbackToOlderReleases) {
|
||||
if (additionalSettings['trackOnly'] != true) {
|
||||
apkDetailsList =
|
||||
apkDetailsList.where((e) => e.apkUrls.isNotEmpty).toList();
|
||||
}
|
||||
if (apkDetailsList.isEmpty) {
|
||||
throw NoReleasesError(note: tr('gitlabSourceNote'));
|
||||
}
|
||||
|
||||
if (finalResult.apkUrls.isEmpty && !trackOnly) {
|
||||
throw NoAPKError();
|
||||
}
|
||||
|
||||
return apkDetailsList.first;
|
||||
}
|
||||
}
|
||||
|
@@ -50,10 +50,6 @@ class IzzyOnDroid extends AppSource {
|
||||
'https://android.izzysoft.de/frepo/$appId',
|
||||
standardUrl,
|
||||
name,
|
||||
autoSelectHighestVersionCode:
|
||||
additionalSettings['autoSelectHighestVersionCode'] == true,
|
||||
trySelectingSuggestedVersionCode:
|
||||
additionalSettings['trySelectingSuggestedVersionCode'] == true,
|
||||
filterVersionsByRegEx: additionalSettings['filterVersionsByRegEx']);
|
||||
additionalSettings: additionalSettings);
|
||||
}
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ List<MapEntry<Locale, String>> supportedLocales = const [
|
||||
MapEntry(Locale('nl'), 'Nederlands'),
|
||||
MapEntry(Locale('vi'), 'Tiếng Việt'),
|
||||
MapEntry(Locale('tr'), 'Türkçe'),
|
||||
MapEntry(Locale('uk'), 'Українська'),
|
||||
];
|
||||
const fallbackLocale = Locale('en');
|
||||
const localeDir = 'assets/translations';
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:obtainium/app_sources/html.dart';
|
||||
import 'package:obtainium/components/custom_app_bar.dart';
|
||||
import 'package:obtainium/components/generated_form.dart';
|
||||
import 'package:obtainium/components/generated_form_modal.dart';
|
||||
@@ -62,18 +61,6 @@ class AddAppPageState extends State<AddAppPage> {
|
||||
var prevHost = pickedSource?.hosts.isNotEmpty == true
|
||||
? pickedSource?.hosts[0]
|
||||
: null;
|
||||
try {
|
||||
var naturalSource =
|
||||
valid ? sourceProvider.getSource(userInput) : null;
|
||||
if (naturalSource != null &&
|
||||
naturalSource.runtimeType.toString() !=
|
||||
HTML().runtimeType.toString()) {
|
||||
// If input has changed to match a regular source, reset the override
|
||||
pickedSourceOverride = null;
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
var source = valid
|
||||
? sourceProvider.getSource(userInput,
|
||||
overrideSource: pickedSourceOverride)
|
||||
@@ -163,7 +150,7 @@ class AddAppPageState extends State<AddAppPage> {
|
||||
app = await sourceProvider.getApp(
|
||||
pickedSource!, userInput.trim(), additionalSettings,
|
||||
trackOnlyOverride: trackOnly,
|
||||
overrideSource: pickedSourceOverride,
|
||||
sourceIsOverriden: pickedSourceOverride != null,
|
||||
inferAppIdIfOptional: inferAppIdIfOptional);
|
||||
// Only download the APK here if you need to for the package ID
|
||||
if (isTempId(app) && app.additionalSettings['trackOnly'] != true) {
|
||||
@@ -361,8 +348,9 @@ class AddAppPageState extends State<AddAppPage> {
|
||||
[
|
||||
GeneratedFormDropdown(
|
||||
'overrideSource',
|
||||
defaultValue: HTML().runtimeType.toString(),
|
||||
defaultValue: '',
|
||||
[
|
||||
MapEntry('', tr('none')),
|
||||
...sourceProvider.sources.map(
|
||||
(s) => MapEntry(s.runtimeType.toString(), s.name))
|
||||
],
|
||||
@@ -577,11 +565,7 @@ class AddAppPageState extends State<AddAppPage> {
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
if (pickedSourceOverride != null ||
|
||||
(pickedSource != null &&
|
||||
pickedSource.runtimeType.toString() ==
|
||||
HTML().runtimeType.toString()))
|
||||
getHTMLSourceOverrideDropdown(),
|
||||
if (pickedSource != null) getHTMLSourceOverrideDropdown(),
|
||||
if (shouldShowSearchBar()) getSearchBarRow(),
|
||||
if (pickedSource != null)
|
||||
FutureBuilder(
|
||||
|
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:obtainium/components/generated_form_modal.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/main.dart';
|
||||
import 'package:obtainium/pages/apps.dart';
|
||||
import 'package:obtainium/pages/settings.dart';
|
||||
import 'package:obtainium/providers/apps_provider.dart';
|
||||
import 'package:obtainium/providers/settings_provider.dart';
|
||||
@@ -104,6 +105,11 @@ class _AppPageState extends State<AppPage> {
|
||||
if (installedVersionIsEstimate) {
|
||||
infoLines = '${tr('pseudoVersionInUse')}\n$infoLines';
|
||||
}
|
||||
if ((app?.app.apkUrls.length ?? 0) > 0) {
|
||||
infoLines =
|
||||
'$infoLines\n${app?.app.apkUrls.length == 1 ? app?.app.apkUrls[0].key : plural('apk', app?.app.apkUrls.length ?? 0)}';
|
||||
}
|
||||
var changeLogFn = app != null ? getChangeLogFn(context, app.app) : null;
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -121,13 +127,26 @@ class _AppPageState extends State<AppPage> {
|
||||
.textTheme
|
||||
.bodyLarge!
|
||||
.copyWith(fontWeight: FontWeight.bold)),
|
||||
app?.app.releaseDate == null
|
||||
? const SizedBox.shrink()
|
||||
: Text(
|
||||
app!.app.releaseDate.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
changeLogFn != null || app?.app.releaseDate != null
|
||||
? GestureDetector(
|
||||
onTap: changeLogFn,
|
||||
child: Text(
|
||||
app?.app.releaseDate == null
|
||||
? tr('changes')
|
||||
: app!.app.releaseDate.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
style:
|
||||
Theme.of(context).textTheme.labelSmall!.copyWith(
|
||||
decoration: changeLogFn != null
|
||||
? TextDecoration.underline
|
||||
: null,
|
||||
fontStyle: changeLogFn != null
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
@@ -357,6 +376,9 @@ class _AppPageState extends State<AppPage> {
|
||||
!areDownloadsRunning
|
||||
? () async {
|
||||
try {
|
||||
var successMessage = app?.app.installedVersion == null
|
||||
? tr('installed')
|
||||
: tr('appsUpdated');
|
||||
HapticFeedback.heavyImpact();
|
||||
var res = await appsProvider.downloadAndInstallLatestApps(
|
||||
app?.app.id != null ? [app!.app.id] : [],
|
||||
@@ -364,7 +386,7 @@ class _AppPageState extends State<AppPage> {
|
||||
);
|
||||
if (res.isNotEmpty && !trackOnly) {
|
||||
// ignore: use_build_context_synchronously
|
||||
showMessage(tr('appsUpdated'), context);
|
||||
showMessage(successMessage, context);
|
||||
}
|
||||
if (res.isNotEmpty && mounted) {
|
||||
Navigator.of(context).pop();
|
||||
|
@@ -26,6 +26,92 @@ class AppsPage extends StatefulWidget {
|
||||
State<AppsPage> createState() => AppsPageState();
|
||||
}
|
||||
|
||||
showChangeLogDialog(BuildContext context, App app, String? changesUrl,
|
||||
AppSource appSource, String changeLog) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return GeneratedFormModal(
|
||||
title: tr('changes'),
|
||||
items: const [],
|
||||
message: app.latestVersion,
|
||||
additionalWidgets: [
|
||||
changesUrl != null
|
||||
? GestureDetector(
|
||||
child: Text(
|
||||
changesUrl,
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontStyle: FontStyle.italic),
|
||||
),
|
||||
onTap: () {
|
||||
launchUrlString(changesUrl,
|
||||
mode: LaunchMode.externalApplication);
|
||||
},
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
changesUrl != null
|
||||
? const SizedBox(
|
||||
height: 16,
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
appSource.changeLogIfAnyIsMarkDown
|
||||
? SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height - 350,
|
||||
child: Markdown(
|
||||
data: changeLog,
|
||||
onTapLink: (text, href, title) {
|
||||
if (href != null) {
|
||||
launchUrlString(
|
||||
href.startsWith('http://') ||
|
||||
href.startsWith('https://')
|
||||
? href
|
||||
: '${Uri.parse(app.url).origin}/$href',
|
||||
mode: LaunchMode.externalApplication);
|
||||
}
|
||||
},
|
||||
extensionSet: md.ExtensionSet(
|
||||
md.ExtensionSet.gitHubFlavored.blockSyntaxes,
|
||||
[
|
||||
md.EmojiSyntax(),
|
||||
...md.ExtensionSet.gitHubFlavored.inlineSyntaxes
|
||||
],
|
||||
),
|
||||
))
|
||||
: Text(changeLog),
|
||||
],
|
||||
singleNullReturnButton: tr('ok'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
getChangeLogFn(BuildContext context, App app) {
|
||||
AppSource appSource =
|
||||
SourceProvider().getSource(app.url, overrideSource: app.overrideSource);
|
||||
String? changesUrl = appSource.changeLogPageFromStandardUrl(app.url);
|
||||
String? changeLog = app.changeLog;
|
||||
if (changeLog?.split('\n').length == 1) {
|
||||
if (RegExp(
|
||||
'(http|ftp|https)://([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])?')
|
||||
.hasMatch(changeLog!)) {
|
||||
if (changesUrl == null) {
|
||||
changesUrl = changeLog;
|
||||
changeLog = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (changeLog == null && changesUrl == null)
|
||||
? null
|
||||
: () {
|
||||
if (changeLog != null) {
|
||||
showChangeLogDialog(context, app, changesUrl, appSource, changeLog);
|
||||
} else {
|
||||
launchUrlString(changesUrl!, mode: LaunchMode.externalApplication);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class AppsPageState extends State<AppsPage> {
|
||||
AppsFilter filter = AppsFilter();
|
||||
final AppsFilter neutralFilter = AppsFilter();
|
||||
@@ -262,66 +348,6 @@ class AppsPageState extends State<AppsPage> {
|
||||
.where((a) => selectedAppIds.contains(a.id))
|
||||
.toSet();
|
||||
|
||||
showChangeLogDialog(
|
||||
String? changesUrl, AppSource appSource, String changeLog, int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return GeneratedFormModal(
|
||||
title: tr('changes'),
|
||||
items: const [],
|
||||
message: listedApps[index].app.latestVersion,
|
||||
additionalWidgets: [
|
||||
changesUrl != null
|
||||
? GestureDetector(
|
||||
child: Text(
|
||||
changesUrl,
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontStyle: FontStyle.italic),
|
||||
),
|
||||
onTap: () {
|
||||
launchUrlString(changesUrl,
|
||||
mode: LaunchMode.externalApplication);
|
||||
},
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
changesUrl != null
|
||||
? const SizedBox(
|
||||
height: 16,
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
appSource.changeLogIfAnyIsMarkDown
|
||||
? SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height - 350,
|
||||
child: Markdown(
|
||||
data: changeLog,
|
||||
onTapLink: (text, href, title) {
|
||||
if (href != null) {
|
||||
launchUrlString(
|
||||
href.startsWith('http://') ||
|
||||
href.startsWith('https://')
|
||||
? href
|
||||
: '${Uri.parse(listedApps[index].app.url).origin}/$href',
|
||||
mode: LaunchMode.externalApplication);
|
||||
}
|
||||
},
|
||||
extensionSet: md.ExtensionSet(
|
||||
md.ExtensionSet.gitHubFlavored.blockSyntaxes,
|
||||
[
|
||||
md.EmojiSyntax(),
|
||||
...md.ExtensionSet.gitHubFlavored.inlineSyntaxes
|
||||
],
|
||||
),
|
||||
))
|
||||
: Text(changeLog),
|
||||
],
|
||||
singleNullReturnButton: tr('ok'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
getLoadingWidgets() {
|
||||
return [
|
||||
if (listedApps.isEmpty)
|
||||
@@ -351,35 +377,6 @@ class AppsPageState extends State<AppsPage> {
|
||||
];
|
||||
}
|
||||
|
||||
getChangeLogFn(int appIndex) {
|
||||
AppSource appSource = SourceProvider().getSource(
|
||||
listedApps[appIndex].app.url,
|
||||
overrideSource: listedApps[appIndex].app.overrideSource);
|
||||
String? changesUrl =
|
||||
appSource.changeLogPageFromStandardUrl(listedApps[appIndex].app.url);
|
||||
String? changeLog = listedApps[appIndex].app.changeLog;
|
||||
if (changeLog?.split('\n').length == 1) {
|
||||
if (RegExp(
|
||||
'(http|ftp|https)://([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])?')
|
||||
.hasMatch(changeLog!)) {
|
||||
if (changesUrl == null) {
|
||||
changesUrl = changeLog;
|
||||
changeLog = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (changeLog == null && changesUrl == null)
|
||||
? null
|
||||
: () {
|
||||
if (changeLog != null) {
|
||||
showChangeLogDialog(changesUrl, appSource, changeLog, appIndex);
|
||||
} else {
|
||||
launchUrlString(changesUrl!,
|
||||
mode: LaunchMode.externalApplication);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
getUpdateButton(int appIndex) {
|
||||
return IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
@@ -444,7 +441,7 @@ class AppsPageState extends State<AppsPage> {
|
||||
}
|
||||
|
||||
getSingleAppHorizTile(int index) {
|
||||
var showChangesFn = getChangeLogFn(index);
|
||||
var showChangesFn = getChangeLogFn(context, listedApps[index].app);
|
||||
var hasUpdate = listedApps[index].app.installedVersion != null &&
|
||||
listedApps[index].app.installedVersion !=
|
||||
listedApps[index].app.latestVersion;
|
||||
|
@@ -213,7 +213,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
setState(() {
|
||||
importInProgress = true;
|
||||
});
|
||||
if (values['url'] != source.hosts[0]) {
|
||||
if (source.hosts.isEmpty || values['url'] != source.hosts[0]) {
|
||||
source = sourceProvider.getSource(values['url'],
|
||||
overrideSource: source.runtimeType.toString());
|
||||
}
|
||||
|
@@ -328,6 +328,22 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
],
|
||||
),
|
||||
height16,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child:
|
||||
Text(tr('removeOnExternalUninstall'))),
|
||||
Switch(
|
||||
value: settingsProvider
|
||||
.removeOnExternalUninstall,
|
||||
onChanged: (value) {
|
||||
settingsProvider
|
||||
.removeOnExternalUninstall = value;
|
||||
})
|
||||
],
|
||||
),
|
||||
height16,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -341,6 +357,43 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
],
|
||||
),
|
||||
height16,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(tr(
|
||||
'beforeNewInstallsShareToAppVerifier')),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
launchUrlString(
|
||||
'https://github.com/soupslurpr/AppVerifier',
|
||||
mode: LaunchMode
|
||||
.externalApplication);
|
||||
},
|
||||
child: Text(
|
||||
tr('about'),
|
||||
style: const TextStyle(
|
||||
decoration:
|
||||
TextDecoration.underline,
|
||||
fontSize: 12),
|
||||
)),
|
||||
],
|
||||
)),
|
||||
Switch(
|
||||
value: settingsProvider
|
||||
.beforeNewInstallsShareToAppVerifier,
|
||||
onChanged: (value) {
|
||||
settingsProvider
|
||||
.beforeNewInstallsShareToAppVerifier =
|
||||
value;
|
||||
})
|
||||
],
|
||||
),
|
||||
height16,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -473,22 +526,6 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
],
|
||||
),
|
||||
height16,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child:
|
||||
Text(tr('removeOnExternalUninstall'))),
|
||||
Switch(
|
||||
value: settingsProvider
|
||||
.removeOnExternalUninstall,
|
||||
onChanged: (value) {
|
||||
settingsProvider
|
||||
.removeOnExternalUninstall = value;
|
||||
})
|
||||
],
|
||||
),
|
||||
height16,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
|
@@ -5,6 +5,7 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:crypto/crypto.dart';
|
||||
|
||||
@@ -31,6 +32,7 @@ import 'package:obtainium/providers/source_provider.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:android_intent_plus/android_intent.dart';
|
||||
import 'package:flutter_archive/flutter_archive.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:shared_storage/shared_storage.dart' as saf;
|
||||
import 'native_provider.dart';
|
||||
|
||||
@@ -202,14 +204,18 @@ Future<String> checkPartialDownloadHash(String url, int bytesToGrab,
|
||||
Future<File> downloadFile(
|
||||
String url, String fileNameNoExt, Function? onProgress, String destDir,
|
||||
{bool useExisting = true, Map<String, String>? headers}) async {
|
||||
// Send the initial request but cancel it as soon as you have the headers
|
||||
var reqHeaders = headers ?? {};
|
||||
var req = Request('GET', Uri.parse(url));
|
||||
if (headers != null) {
|
||||
req.headers.addAll(headers);
|
||||
}
|
||||
req.headers.addAll(reqHeaders);
|
||||
var client = http.Client();
|
||||
StreamedResponse response = await client.send(req);
|
||||
String ext =
|
||||
response.headers['content-disposition']?.split('.').last ?? 'apk';
|
||||
var resHeaders = response.headers;
|
||||
|
||||
// Use the headers to decide what the file extension is, and
|
||||
// whether it supports partial downloads (range request), and
|
||||
// what the total size of the file is (if provided)
|
||||
String ext = resHeaders['content-disposition']?.split('.').last ?? 'apk';
|
||||
if (ext.endsWith('"') || ext.endsWith("other")) {
|
||||
ext = ext.substring(0, ext.length - 1);
|
||||
}
|
||||
@@ -217,41 +223,108 @@ Future<File> downloadFile(
|
||||
ext = 'apk';
|
||||
}
|
||||
File downloadedFile = File('$destDir/$fileNameNoExt.$ext');
|
||||
if (!(downloadedFile.existsSync() && useExisting)) {
|
||||
File tempDownloadedFile = File('${downloadedFile.path}.part');
|
||||
if (tempDownloadedFile.existsSync()) {
|
||||
tempDownloadedFile.deleteSync(recursive: true);
|
||||
}
|
||||
var length = response.contentLength;
|
||||
var received = 0;
|
||||
double? progress;
|
||||
var sink = tempDownloadedFile.openWrite();
|
||||
await response.stream.map((s) {
|
||||
received += s.length;
|
||||
progress = (length != null ? received / length * 100 : 30);
|
||||
if (onProgress != null) {
|
||||
onProgress(progress);
|
||||
|
||||
bool rangeFeatureEnabled = false;
|
||||
if (resHeaders['accept-ranges']?.isNotEmpty == true) {
|
||||
rangeFeatureEnabled =
|
||||
resHeaders['accept-ranges']?.trim().toLowerCase() == 'bytes';
|
||||
}
|
||||
|
||||
// If you have an existing file that is usable,
|
||||
// decide whether you can use it (either return full or resume partial)
|
||||
var fullContentLength = response.contentLength;
|
||||
if (useExisting && downloadedFile.existsSync()) {
|
||||
var length = downloadedFile.lengthSync();
|
||||
if (fullContentLength == null) {
|
||||
// Assume full
|
||||
client.close();
|
||||
return downloadedFile;
|
||||
} else {
|
||||
// Check if resume needed/possible
|
||||
if (length == fullContentLength) {
|
||||
client.close();
|
||||
return downloadedFile;
|
||||
}
|
||||
return s;
|
||||
}).pipe(sink);
|
||||
await sink.close();
|
||||
progress = null;
|
||||
if (length > fullContentLength) {
|
||||
useExisting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Download to a '.temp' file (to distinguish btn. complete/incomplete files)
|
||||
File tempDownloadedFile = File('${downloadedFile.path}.part');
|
||||
|
||||
// If the range feature is not available (or you need to start a ranged req from 0),
|
||||
// complete the already-started request, else cancel it and start a ranged request,
|
||||
// and open the file for writing in the appropriate mode
|
||||
var targetFileLength = useExisting && tempDownloadedFile.existsSync()
|
||||
? tempDownloadedFile.lengthSync()
|
||||
: null;
|
||||
int rangeStart = targetFileLength ?? 0;
|
||||
IOSink? sink;
|
||||
if (rangeFeatureEnabled && fullContentLength != null && rangeStart > 0) {
|
||||
client.close();
|
||||
client = http.Client();
|
||||
req = Request('GET', Uri.parse(url));
|
||||
req.headers.addAll(reqHeaders);
|
||||
req.headers.addAll({'range': 'bytes=$rangeStart-${fullContentLength - 1}'});
|
||||
response = await client.send(req);
|
||||
sink = tempDownloadedFile.openWrite(mode: FileMode.writeOnlyAppend);
|
||||
} else if (tempDownloadedFile.existsSync()) {
|
||||
tempDownloadedFile.deleteSync(recursive: true);
|
||||
}
|
||||
sink ??= tempDownloadedFile.openWrite(mode: FileMode.writeOnly);
|
||||
|
||||
// Perform the download
|
||||
var received = 0;
|
||||
double? progress;
|
||||
if (rangeStart > 0 && fullContentLength != null) {
|
||||
received = rangeStart;
|
||||
}
|
||||
await response.stream.map((s) {
|
||||
received += s.length;
|
||||
progress =
|
||||
(fullContentLength != null ? (received / fullContentLength) * 100 : 30);
|
||||
if (onProgress != null) {
|
||||
onProgress(progress);
|
||||
}
|
||||
if (response.statusCode != 200) {
|
||||
tempDownloadedFile.deleteSync(recursive: true);
|
||||
throw response.reasonPhrase ?? tr('unexpectedError');
|
||||
}
|
||||
if (tempDownloadedFile.existsSync()) {
|
||||
tempDownloadedFile.renameSync(downloadedFile.path);
|
||||
}
|
||||
} else {
|
||||
client.close();
|
||||
return s;
|
||||
}).pipe(sink);
|
||||
await sink.close();
|
||||
bool likelyCorruptFile = (progress ?? 0) > 101;
|
||||
progress = null;
|
||||
if (onProgress != null) {
|
||||
onProgress(progress);
|
||||
}
|
||||
if (response.statusCode < 200 ||
|
||||
response.statusCode > 299 ||
|
||||
likelyCorruptFile) {
|
||||
tempDownloadedFile.deleteSync(recursive: true);
|
||||
throw response.reasonPhrase ?? tr('unexpectedError');
|
||||
}
|
||||
if (tempDownloadedFile.existsSync()) {
|
||||
tempDownloadedFile.renameSync(downloadedFile.path);
|
||||
}
|
||||
client.close();
|
||||
return downloadedFile;
|
||||
}
|
||||
|
||||
Future<Map<String, String>> getHeaders(String url,
|
||||
{Map<String, String>? headers}) async {
|
||||
var req = http.Request('GET', Uri.parse(url));
|
||||
if (headers != null) {
|
||||
req.headers.addAll(headers);
|
||||
}
|
||||
var client = http.Client();
|
||||
var response = await client.send(req);
|
||||
if (response.statusCode < 200 || response.statusCode > 299) {
|
||||
throw ObtainiumError(response.reasonPhrase ?? tr('unexpectedError'));
|
||||
}
|
||||
var returnHeaders = response.headers;
|
||||
client.close();
|
||||
return returnHeaders;
|
||||
}
|
||||
|
||||
Future<PackageInfo?> getInstalledInfo(String? packageName,
|
||||
{bool printErr = true}) async {
|
||||
if (packageName != null) {
|
||||
@@ -493,13 +566,14 @@ class AppsProvider with ChangeNotifier {
|
||||
zipFile: File(filePath), destinationDir: Directory(destinationPath));
|
||||
}
|
||||
|
||||
Future<void> installXApkDir(DownloadedXApkDir dir,
|
||||
Future<bool> installXApkDir(
|
||||
DownloadedXApkDir dir, BuildContext? firstTimeWithContext,
|
||||
{bool needsBGWorkaround = false}) async {
|
||||
// We don't know which APKs in an XAPK are supported by the user's device
|
||||
// So we try installing all of them and assume success if at least one installed
|
||||
// If 0 APKs installed, throw the first install error encountered
|
||||
var somethingInstalled = false;
|
||||
try {
|
||||
var somethingInstalled = false;
|
||||
MultiAppMultiError errors = MultiAppMultiError();
|
||||
for (var file in dir.extracted
|
||||
.listSync(recursive: true, followLinks: false)
|
||||
@@ -507,7 +581,8 @@ class AppsProvider with ChangeNotifier {
|
||||
if (file.path.toLowerCase().endsWith('.apk')) {
|
||||
try {
|
||||
somethingInstalled = somethingInstalled ||
|
||||
await installApk(DownloadedApk(dir.appId, file),
|
||||
await installApk(
|
||||
DownloadedApk(dir.appId, file), firstTimeWithContext,
|
||||
needsBGWorkaround: needsBGWorkaround);
|
||||
} catch (e) {
|
||||
logs.add(
|
||||
@@ -526,10 +601,22 @@ class AppsProvider with ChangeNotifier {
|
||||
} finally {
|
||||
dir.extracted.delete(recursive: true);
|
||||
}
|
||||
return somethingInstalled;
|
||||
}
|
||||
|
||||
Future<bool> installApk(DownloadedApk file,
|
||||
Future<bool> installApk(
|
||||
DownloadedApk file, BuildContext? firstTimeWithContext,
|
||||
{bool needsBGWorkaround = false}) async {
|
||||
if (firstTimeWithContext != null &&
|
||||
settingsProvider.beforeNewInstallsShareToAppVerifier &&
|
||||
(await getInstalledInfo('dev.soupslurpr.appverifier')) != null) {
|
||||
XFile f = XFile.fromData(file.file.readAsBytesSync(),
|
||||
mimeType: 'application/vnd.android.package-archive');
|
||||
Fluttertoast.showToast(
|
||||
msg: tr('appVerifierInstructionToast'),
|
||||
toastLength: Toast.LENGTH_LONG);
|
||||
await Share.shareXFiles([f]);
|
||||
}
|
||||
var newInfo =
|
||||
await pm.getPackageArchiveInfo(archiveFilePath: file.file.path);
|
||||
if (newInfo == null) {
|
||||
@@ -570,7 +657,13 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
bool installed = false;
|
||||
if (code != null && code != 0 && code != 3) {
|
||||
throw InstallError(code);
|
||||
try {
|
||||
file.file.deleteSync(recursive: true);
|
||||
} catch (e) {
|
||||
//
|
||||
} finally {
|
||||
throw InstallError(code);
|
||||
}
|
||||
} else if (code == 0) {
|
||||
installed = true;
|
||||
apps[file.appId]!.app.installedVersion =
|
||||
@@ -710,7 +803,7 @@ class AppsProvider with ChangeNotifier {
|
||||
appsToInstall =
|
||||
moveStrToEnd(appsToInstall, obtainiumId, strB: obtainiumTempId);
|
||||
|
||||
Future<void> updateFn(String id, {bool skipInstalls = false}) async {
|
||||
Future<String> updateFn(String id, {bool skipInstalls = false}) async {
|
||||
try {
|
||||
var downloadedArtifact =
|
||||
// ignore: use_build_context_synchronously
|
||||
@@ -723,8 +816,8 @@ class AppsProvider with ChangeNotifier {
|
||||
} else {
|
||||
downloadedDir = downloadedArtifact as DownloadedXApkDir;
|
||||
}
|
||||
var appId = downloadedFile?.appId ?? downloadedDir!.appId;
|
||||
bool willBeSilent = await canInstallSilently(apps[appId]!.app);
|
||||
var id = downloadedFile?.appId ?? downloadedDir!.appId;
|
||||
bool willBeSilent = await canInstallSilently(apps[id]!.app);
|
||||
if (!settingsProvider.useShizuku) {
|
||||
if (!(await settingsProvider.getInstallPermission(enforce: false))) {
|
||||
throw ObtainiumError(tr('cancelled'));
|
||||
@@ -745,33 +838,43 @@ class AppsProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
try {
|
||||
if (!skipInstalls) {
|
||||
bool sayInstalled = true;
|
||||
var contextIfNewInstall =
|
||||
apps[id]?.installedInfo == null ? context : null;
|
||||
if (downloadedFile != null) {
|
||||
if (willBeSilent && context == null) {
|
||||
installApk(downloadedFile, needsBGWorkaround: true);
|
||||
installApk(downloadedFile, contextIfNewInstall,
|
||||
needsBGWorkaround: true);
|
||||
} else {
|
||||
await installApk(downloadedFile);
|
||||
sayInstalled =
|
||||
await installApk(downloadedFile, contextIfNewInstall);
|
||||
}
|
||||
} else {
|
||||
if (willBeSilent && context == null) {
|
||||
installXApkDir(downloadedDir!, needsBGWorkaround: true);
|
||||
installXApkDir(downloadedDir!, contextIfNewInstall,
|
||||
needsBGWorkaround: true);
|
||||
} else {
|
||||
await installXApkDir(downloadedDir!);
|
||||
sayInstalled =
|
||||
await installXApkDir(downloadedDir!, contextIfNewInstall);
|
||||
}
|
||||
}
|
||||
if (willBeSilent && context == null) {
|
||||
notificationsProvider?.notify(SilentUpdateAttemptNotification(
|
||||
[apps[appId]!.app],
|
||||
id: appId.hashCode));
|
||||
[apps[id]!.app],
|
||||
id: id.hashCode));
|
||||
}
|
||||
if (sayInstalled) {
|
||||
installedIds.add(id);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
apps[id]?.downloadProgress = null;
|
||||
notifyListeners();
|
||||
}
|
||||
installedIds.add(id);
|
||||
} catch (e) {
|
||||
errors.add(id, e, appName: apps[id]?.name);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
if (forceParallelDownloads || !settingsProvider.parallelDownloads) {
|
||||
@@ -779,9 +882,9 @@ class AppsProvider with ChangeNotifier {
|
||||
await updateFn(id);
|
||||
}
|
||||
} else {
|
||||
await Future.wait(
|
||||
List<String> ids = await Future.wait(
|
||||
appsToInstall.map((id) => updateFn(id, skipInstalls: true)));
|
||||
for (var id in appsToInstall) {
|
||||
for (var id in ids) {
|
||||
if (!errors.appIdNames.containsKey(id)) {
|
||||
await updateFn(id);
|
||||
}
|
||||
|
@@ -28,8 +28,22 @@ enum SortOrderSettings { ascending, descending }
|
||||
|
||||
const maxAPIRateLimitMinutes = 30;
|
||||
const minUpdateIntervalMinutes = maxAPIRateLimitMinutes + 30;
|
||||
const maxUpdateIntervalMinutes = 4320;
|
||||
List<int> updateIntervals = [15, 30, 60, 120, 180, 360, 720, 1440, 4320, 0]
|
||||
const maxUpdateIntervalMinutes = 43200;
|
||||
List<int> updateIntervals = [
|
||||
15,
|
||||
30,
|
||||
60,
|
||||
120,
|
||||
180,
|
||||
360,
|
||||
720,
|
||||
1440,
|
||||
4320,
|
||||
10080,
|
||||
20160,
|
||||
43200,
|
||||
0
|
||||
]
|
||||
.where((element) =>
|
||||
(element >= minUpdateIntervalMinutes &&
|
||||
element <= maxUpdateIntervalMinutes) ||
|
||||
@@ -462,4 +476,13 @@ class SettingsProvider with ChangeNotifier {
|
||||
prefs?.setStringList('searchDeselected', list);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool get beforeNewInstallsShareToAppVerifier {
|
||||
return prefs?.getBool('beforeNewInstallsShareToAppVerifier') ?? true;
|
||||
}
|
||||
|
||||
set beforeNewInstallsShareToAppVerifier(bool val) {
|
||||
prefs?.setBool('beforeNewInstallsShareToAppVerifier', val);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
@@ -736,7 +736,6 @@ class SourceProvider {
|
||||
FDroid(),
|
||||
FDroidRepo(),
|
||||
IzzyOnDroid(),
|
||||
SourceForge(),
|
||||
SourceHut(),
|
||||
APKPure(),
|
||||
Aptoide(),
|
||||
@@ -819,7 +818,7 @@ class SourceProvider {
|
||||
AppSource source, String url, Map<String, dynamic> additionalSettings,
|
||||
{App? currentApp,
|
||||
bool trackOnlyOverride = false,
|
||||
String? overrideSource,
|
||||
bool sourceIsOverriden = false,
|
||||
bool inferAppIdIfOptional = false}) async {
|
||||
if (trackOnlyOverride || source.enforceTrackOnly) {
|
||||
additionalSettings['trackOnly'] = true;
|
||||
@@ -887,7 +886,9 @@ class SourceProvider {
|
||||
categories: currentApp?.categories ?? const [],
|
||||
releaseDate: apk.releaseDate,
|
||||
changeLog: apk.changeLog,
|
||||
overrideSource: overrideSource ?? currentApp?.overrideSource,
|
||||
overrideSource: sourceIsOverriden
|
||||
? source.runtimeType.toString()
|
||||
: currentApp?.overrideSource,
|
||||
allowIdChange: currentApp?.allowIdChange ??
|
||||
trackOnly ||
|
||||
(source.appIdInferIsOptional &&
|
||||
@@ -911,6 +912,7 @@ class SourceProvider {
|
||||
apps.add(await getApp(
|
||||
source,
|
||||
url,
|
||||
sourceIsOverriden: sourceOverride != null,
|
||||
getDefaultValuesFromFormItems(
|
||||
source.combinedAppSpecificSettingFormItems)));
|
||||
} catch (e) {
|
||||
|
Reference in New Issue
Block a user