From e019c8027b95d8150e54d1de8f67261fe66918f6 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Thu, 5 Sep 2024 13:10:02 -0400 Subject: [PATCH 1/8] Improved APKPure compatibility by prioritizing APK when available (over XAPK) --- lib/app_sources/apkpure.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/app_sources/apkpure.dart b/lib/app_sources/apkpure.dart index 3fe3237..fe5e549 100644 --- a/lib/app_sources/apkpure.dart +++ b/lib/app_sources/apkpure.dart @@ -109,11 +109,16 @@ class APKPure extends AppSource { '') ?.group(0) ?.trim(); - String? type = apkInfo - ?.querySelector('div.info-top span.tag') - ?.text - .trim() ?? - 'APK'; + var types = apkInfo + ?.querySelectorAll('div.info-top span.tag') + .map((e) => e.text.trim()) + .map((t) => t == 'APKs' ? 'APK' : t) ?? + []; + String type = types.length == 0 + ? 'APK' + : types.length == 1 + ? types.first + : types.last; String? dateString = apkInfo ?.querySelector('div.info-bottom span.time') ?.text From 0e46a83843d1009dffba3e46b7cc54610588ddec Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 8 Sep 2024 02:51:11 -0400 Subject: [PATCH 2/8] Auto-select direct APK source for URLs ending in '.apk' (#1820) --- lib/app_sources/apkcombo.dart | 2 +- lib/app_sources/apkmirror.dart | 2 +- lib/app_sources/apkpure.dart | 2 +- lib/app_sources/aptoide.dart | 2 +- lib/app_sources/codeberg.dart | 2 +- lib/app_sources/directAPKLink.dart | 16 +++++++++++++++- lib/app_sources/fdroid.dart | 2 +- lib/app_sources/fdroidrepo.dart | 2 +- lib/app_sources/github.dart | 2 +- lib/app_sources/gitlab.dart | 2 +- lib/app_sources/html.dart | 2 +- lib/app_sources/huaweiappgallery.dart | 2 +- lib/app_sources/izzyondroid.dart | 2 +- lib/app_sources/mullvad.dart | 2 +- lib/app_sources/neutroncode.dart | 2 +- lib/app_sources/signal.dart | 2 +- lib/app_sources/sourceforge.dart | 2 +- lib/app_sources/sourcehut.dart | 2 +- lib/app_sources/steammobile.dart | 2 +- lib/app_sources/telegramapp.dart | 2 +- lib/app_sources/uptodown.dart | 2 +- lib/app_sources/vlc.dart | 2 +- lib/app_sources/whatsapp.dart | 2 +- lib/providers/source_provider.dart | 4 ++-- 24 files changed, 39 insertions(+), 25 deletions(-) diff --git a/lib/app_sources/apkcombo.dart b/lib/app_sources/apkcombo.dart index 3a1ae49..b63afa6 100644 --- a/lib/app_sources/apkcombo.dart +++ b/lib/app_sources/apkcombo.dart @@ -10,7 +10,7 @@ class APKCombo extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+[^/]+', caseSensitive: false); diff --git a/lib/app_sources/apkmirror.dart b/lib/app_sources/apkmirror.dart index 236a300..1b3a67b 100644 --- a/lib/app_sources/apkmirror.dart +++ b/lib/app_sources/apkmirror.dart @@ -32,7 +32,7 @@ class APKMirror extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/apk/[^/]+/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/apkpure.dart b/lib/app_sources/apkpure.dart index fe5e549..82fdf23 100644 --- a/lib/app_sources/apkpure.dart +++ b/lib/app_sources/apkpure.dart @@ -29,7 +29,7 @@ class APKPure extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegExB = RegExp( '^https?://m.${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+', caseSensitive: false); diff --git a/lib/app_sources/aptoide.dart b/lib/app_sources/aptoide.dart index 9daf57b..b545d8a 100644 --- a/lib/app_sources/aptoide.dart +++ b/lib/app_sources/aptoide.dart @@ -14,7 +14,7 @@ class Aptoide extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}', caseSensitive: false); diff --git a/lib/app_sources/codeberg.dart b/lib/app_sources/codeberg.dart index 6354ea4..e2899c3 100644 --- a/lib/app_sources/codeberg.dart +++ b/lib/app_sources/codeberg.dart @@ -16,7 +16,7 @@ class Codeberg extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/directAPKLink.dart b/lib/app_sources/directAPKLink.dart index f80a711..1addc13 100644 --- a/lib/app_sources/directAPKLink.dart +++ b/lib/app_sources/directAPKLink.dart @@ -1,12 +1,12 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:obtainium/app_sources/html.dart'; +import 'package:obtainium/custom_errors.dart'; import 'package:obtainium/providers/source_provider.dart'; class DirectAPKLink extends AppSource { HTML html = HTML(); DirectAPKLink() { - neverAutoSelect = true; name = tr('directAPKLink'); additionalSourceAppSpecificSettingFormItems = html .additionalSourceAppSpecificSettingFormItems @@ -24,6 +24,20 @@ class DirectAPKLink extends AppSource { ]; } + @override + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { + print('AAA'); + if (!forSelection) { + return url; + } + RegExp standardUrlRegExA = RegExp('.+\\.apk\$', caseSensitive: false); + var match = standardUrlRegExA.firstMatch(url); + if (match == null) { + throw InvalidURLError(name); + } + return match.group(0)!; + } + @override Future?> getRequestHeaders( Map additionalSettings, diff --git a/lib/app_sources/fdroid.dart b/lib/app_sources/fdroid.dart index ac08801..22d3791 100644 --- a/lib/app_sources/fdroid.dart +++ b/lib/app_sources/fdroid.dart @@ -38,7 +38,7 @@ class FDroid extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegExB = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+packages/+[^/]+', caseSensitive: false); diff --git a/lib/app_sources/fdroidrepo.dart b/lib/app_sources/fdroidrepo.dart index f4afe08..c8cc536 100644 --- a/lib/app_sources/fdroidrepo.dart +++ b/lib/app_sources/fdroidrepo.dart @@ -43,7 +43,7 @@ class FDroidRepo extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { var standardUri = Uri.parse(url); var pathSegments = standardUri.pathSegments; if (pathSegments.isNotEmpty && pathSegments.last == 'index.xml') { diff --git a/lib/app_sources/github.dart b/lib/app_sources/github.dart index 2f0fb42..a0af39e 100644 --- a/lib/app_sources/github.dart +++ b/lib/app_sources/github.dart @@ -154,7 +154,7 @@ class GitHub extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/gitlab.dart b/lib/app_sources/gitlab.dart index 395c596..e8404a4 100644 --- a/lib/app_sources/gitlab.dart +++ b/lib/app_sources/gitlab.dart @@ -52,7 +52,7 @@ class GitLab extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/html.dart b/lib/app_sources/html.dart index 46f5a65..d3244d8 100644 --- a/lib/app_sources/html.dart +++ b/lib/app_sources/html.dart @@ -288,7 +288,7 @@ class HTML extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return url; } diff --git a/lib/app_sources/huaweiappgallery.dart b/lib/app_sources/huaweiappgallery.dart index 0f2be00..0716597 100644 --- a/lib/app_sources/huaweiappgallery.dart +++ b/lib/app_sources/huaweiappgallery.dart @@ -12,7 +12,7 @@ class HuaweiAppGallery extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}(/#)?/(app|appdl)/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/izzyondroid.dart b/lib/app_sources/izzyondroid.dart index d49071e..2960c6e 100644 --- a/lib/app_sources/izzyondroid.dart +++ b/lib/app_sources/izzyondroid.dart @@ -14,7 +14,7 @@ class IzzyOnDroid extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegExA = RegExp( '^https?://android.${getSourceRegex(hosts)}/repo/apk/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/mullvad.dart b/lib/app_sources/mullvad.dart index 3b0439d..3980930 100644 --- a/lib/app_sources/mullvad.dart +++ b/lib/app_sources/mullvad.dart @@ -10,7 +10,7 @@ class Mullvad extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}', caseSensitive: false); diff --git a/lib/app_sources/neutroncode.dart b/lib/app_sources/neutroncode.dart index 0429718..cc3d501 100644 --- a/lib/app_sources/neutroncode.dart +++ b/lib/app_sources/neutroncode.dart @@ -10,7 +10,7 @@ class NeutronCode extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/downloads/file/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/signal.dart b/lib/app_sources/signal.dart index 8e91939..6bbaddb 100644 --- a/lib/app_sources/signal.dart +++ b/lib/app_sources/signal.dart @@ -9,7 +9,7 @@ class Signal extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return 'https://${hosts[0]}'; } diff --git a/lib/app_sources/sourceforge.dart b/lib/app_sources/sourceforge.dart index caaeea8..50fc76a 100644 --- a/lib/app_sources/sourceforge.dart +++ b/lib/app_sources/sourceforge.dart @@ -9,7 +9,7 @@ class SourceForge extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { var sourceRegex = getSourceRegex(hosts); RegExp standardUrlRegExC = RegExp('^https?://(www\\.)?$sourceRegex/p/.+', caseSensitive: false); diff --git a/lib/app_sources/sourcehut.dart b/lib/app_sources/sourcehut.dart index e28294c..51e98b5 100644 --- a/lib/app_sources/sourcehut.dart +++ b/lib/app_sources/sourcehut.dart @@ -20,7 +20,7 @@ class SourceHut extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/steammobile.dart b/lib/app_sources/steammobile.dart index cbb28ef..8e6c11e 100644 --- a/lib/app_sources/steammobile.dart +++ b/lib/app_sources/steammobile.dart @@ -20,7 +20,7 @@ class SteamMobile extends AppSource { final apks = {'steam': tr('steamMobile'), 'steam-chat-app': tr('steamChat')}; @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return 'https://${hosts[0]}'; } diff --git a/lib/app_sources/telegramapp.dart b/lib/app_sources/telegramapp.dart index 651d00f..7c6372b 100644 --- a/lib/app_sources/telegramapp.dart +++ b/lib/app_sources/telegramapp.dart @@ -11,7 +11,7 @@ class TelegramApp extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return 'https://${hosts[0]}'; } diff --git a/lib/app_sources/uptodown.dart b/lib/app_sources/uptodown.dart index 30c86ce..e59998c 100644 --- a/lib/app_sources/uptodown.dart +++ b/lib/app_sources/uptodown.dart @@ -14,7 +14,7 @@ class Uptodown extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}', caseSensitive: false); diff --git a/lib/app_sources/vlc.dart b/lib/app_sources/vlc.dart index 7d16870..4ee0f50 100644 --- a/lib/app_sources/vlc.dart +++ b/lib/app_sources/vlc.dart @@ -21,7 +21,7 @@ class VLC extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return 'https://${hosts[0]}'; } diff --git a/lib/app_sources/whatsapp.dart b/lib/app_sources/whatsapp.dart index 94b26d1..b6e88d2 100644 --- a/lib/app_sources/whatsapp.dart +++ b/lib/app_sources/whatsapp.dart @@ -10,7 +10,7 @@ class WhatsApp extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return 'https://${hosts[0]}'; } diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 8b1c41e..d60e19f 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -472,7 +472,7 @@ abstract class AppSource { // } - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { throw NotImplementedError(); } @@ -809,7 +809,7 @@ class SourceProvider { for (var s in sources.where( (element) => element.hosts.isEmpty && !element.neverAutoSelect)) { try { - s.sourceSpecificStandardizeURL(url); + s.sourceSpecificStandardizeURL(url, forSelection: true); source = s; break; } catch (e) { From 61c88596f07c09a599dfbfaa2775762477d90f60 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 8 Sep 2024 02:54:43 -0400 Subject: [PATCH 3/8] Bugfix --- assets/translations/eo.json | 2 +- lib/main.dart | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/assets/translations/eo.json b/assets/translations/eo.json index b835d45..43b071f 100644 --- a/assets/translations/eo.json +++ b/assets/translations/eo.json @@ -102,7 +102,7 @@ "searchX": "Serĉi {}", "noResults": "Neniu rezulto", "importX": "Importi {}", - "importedAppsIdDisclaimer": "La importitaj apoj povas montriĝi malĝuste kiel \"Neinstalitaj\".\nPor solvi tion, reinstalu ilin per Obtainium.\Tiu ne afekcios la apodatumoj.\n\nAkefcias nur la URL-ajn lak triajn importmetodojn.", + "importedAppsIdDisclaimer": "La importitaj apoj povas montriĝi malĝuste kiel \"Neinstalitaj\".\nPor solvi tion, reinstalu ilin per Obtainium.\nTiu ne afekcios la apodatumoj.\n\nAkefcias nur la URL-ajn lak triajn importmetodojn.", "importErrors": "Eraroj de importado", "importedXOfYApps": "{} apoj el {} importitaj.", "followingURLsHadErrors": "La sekvantaj URLj havis erarojn:", diff --git a/lib/main.dart b/lib/main.dart index b80e5ef..663a52c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -245,15 +245,17 @@ class _ObtainiumState extends State { colorScheme: settingsProvider.theme == ThemeSettings.dark ? darkColorScheme : lightColorScheme, - fontFamily: - settingsProvider.useSystemFont ? 'SystemFont' : 'Wix-Madefor-Display'), + fontFamily: settingsProvider.useSystemFont + ? 'SystemFont' + : 'Wix-Madefor-Display'), darkTheme: ThemeData( useMaterial3: true, colorScheme: settingsProvider.theme == ThemeSettings.light ? lightColorScheme : darkColorScheme, - fontFamily: - settingsProvider.useSystemFont ? 'SystemFont' : 'Wix-Madefor-Display'), + fontFamily: settingsProvider.useSystemFont + ? 'SystemFont' + : 'Wix-Madefor-Display'), home: Shortcuts(shortcuts: { LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(), }, child: const HomePage())); From e1bed6f0cf0cbb544461192fcacf223d6d319c28 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 8 Sep 2024 03:11:49 -0400 Subject: [PATCH 4/8] Handle install failures more gracefully on apps page (#1782) --- lib/providers/apps_provider.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 57cd005..93201d5 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -967,11 +967,16 @@ class AppsProvider with ChangeNotifier { } for (var res in downloadResults) { if (!errors.appIdNames.containsKey(res['id'])) { - await installFn( - res['id'] as String, - res['willBeSilent'] as bool, - res['downloadedFile'] as DownloadedApk?, - res['downloadedDir'] as DownloadedXApkDir?); + try { + await installFn( + res['id'] as String, + res['willBeSilent'] as bool, + res['downloadedFile'] as DownloadedApk?, + res['downloadedDir'] as DownloadedXApkDir?); + } catch (e) { + var id = res['id'] as String; + errors.add(id, e, appName: apps[id]?.name); + } } } From 86416df7dd8e224a96b704384045d4e1bce14164 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 8 Sep 2024 03:23:29 -0400 Subject: [PATCH 5/8] Enabled ZH-TW and EO languages --- assets/translations/{eo.json => en-EO.json} | 0 assets/translations/{zh-TW.json => zh-Hant-TW.json} | 0 lib/main.dart | 3 +++ 3 files changed, 3 insertions(+) rename assets/translations/{eo.json => en-EO.json} (100%) rename assets/translations/{zh-TW.json => zh-Hant-TW.json} (100%) diff --git a/assets/translations/eo.json b/assets/translations/en-EO.json similarity index 100% rename from assets/translations/eo.json rename to assets/translations/en-EO.json diff --git a/assets/translations/zh-TW.json b/assets/translations/zh-Hant-TW.json similarity index 100% rename from assets/translations/zh-TW.json rename to assets/translations/zh-Hant-TW.json diff --git a/lib/main.dart b/lib/main.dart index 663a52c..479f90c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -23,6 +23,7 @@ import 'package:easy_localization/src/localization.dart'; List> supportedLocales = const [ MapEntry(Locale('en'), 'English'), MapEntry(Locale('zh'), '简体中文'), + MapEntry(Locale('zh_Hant_TW'), '臺灣話'), MapEntry(Locale('it'), 'Italiano'), MapEntry(Locale('ja'), '日本語'), MapEntry(Locale('hu'), 'Magyar'), @@ -41,6 +42,8 @@ List> supportedLocales = const [ MapEntry(Locale('tr'), 'Türkçe'), MapEntry(Locale('uk'), 'Українська'), MapEntry(Locale('da'), 'Dansk'), + MapEntry(Locale('en', 'EO'), + 'Esperanto'), // https://github.com/aissat/easy_localization/issues/220#issuecomment-846035493 ]; const fallbackLocale = Locale('en'); const localeDir = 'assets/translations'; From b8dc6f9a5311bcadd527b8681bc08bf893aa4f89 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 8 Sep 2024 03:25:52 -0400 Subject: [PATCH 6/8] Dart fix --- lib/app_sources/apkpure.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app_sources/apkpure.dart b/lib/app_sources/apkpure.dart index 82fdf23..89c2523 100644 --- a/lib/app_sources/apkpure.dart +++ b/lib/app_sources/apkpure.dart @@ -114,7 +114,7 @@ class APKPure extends AppSource { .map((e) => e.text.trim()) .map((t) => t == 'APKs' ? 'APK' : t) ?? []; - String type = types.length == 0 + String type = types.isEmpty ? 'APK' : types.length == 1 ? types.first From 19bb9a0331e8f0077125fb168ea77ebb4c1d7475 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 8 Sep 2024 03:27:20 -0400 Subject: [PATCH 7/8] Update packages + Flutter, increment version --- .flutter | 2 +- pubspec.lock | 48 ++++++++++++++++++++++++------------------------ pubspec.yaml | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.flutter b/.flutter index 80c2e84..4cf269e 160000 --- a/.flutter +++ b/.flutter @@ -1 +1 @@ -Subproject commit 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819 +Subproject commit 4cf269e36de2573851eaef3c763994f8f9be494d diff --git a/pubspec.lock b/pubspec.lock index 93c9b3a..b600543 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -47,10 +47,10 @@ packages: dependency: "direct main" description: name: app_links - sha256: "4acba851087b25136e8f6e32a53bd4536eb3bec69947ddb66e7b9a5792ceb0c7" + sha256: ad1a6d598e7e39b46a34f746f9a8b011ee147e4c275d407fa457e7a62f84dd99 url: "https://pub.dev" source: hosted - version: "6.2.0" + version: "6.3.2" app_links_linux: dependency: transitive description: @@ -103,10 +103,10 @@ packages: dependency: "direct main" description: name: background_fetch - sha256: b5c298c911bc2ce41152668bc72eb0488f0665d75bc6d1e69e7d8367763eddcd + sha256: f910c1c7c67a55f242daf78e9e9835d26eb01d39fc7f5d77f57dd84d009a6bab url: "https://pub.dev" source: hosted - version: "1.3.5" + version: "1.3.6" boolean_selector: dependency: transitive description: @@ -311,10 +311,10 @@ packages: dependency: transitive description: name: flex_seed_scheme - sha256: cc08c81879ecfd2ab840664ce4770980da0b8a319e35f51bcf763849b7f7596b + sha256: "7d97ba5c20f0e5cb1e3e2c17c865e1f797d129de31fc1f75d2dcce9470d6373c" url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.3.0" flutter: dependency: "direct main" description: flutter @@ -441,10 +441,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: "9d98bd47ef9d34e803d438f17fd32b116d31009f534a6fa5ce3a1167f189a6de" + sha256: "9ee02950848f61c4129af3d6ec84a1cfc0e47931abc746b03e7a3bc3e8ff6eda" url: "https://pub.dev" source: hosted - version: "2.0.21" + version: "2.0.22" flutter_test: dependency: "direct dev" description: flutter @@ -611,10 +611,10 @@ packages: dependency: transitive description: name: mime - sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + sha256: "801fd0b26f14a4a58ccb09d5892c3fbdeff209594300a542492cf13fba9d247a" url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.0.6" nested: dependency: transitive description: @@ -715,10 +715,10 @@ packages: dependency: transitive description: name: permission_handler_html - sha256: d220eb8476b466d58b161e10b3001d93999010a26228a3fb89c4280db1249546 + sha256: af26edbbb1f2674af65a8f4b56e1a6f526156bc273d0e65dd8075fab51c78851 url: "https://pub.dev" source: hosted - version: "0.1.3+1" + version: "0.1.3+2" permission_handler_platform_interface: dependency: transitive description: @@ -827,10 +827,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: a7e8467e9181cef109f601e3f65765685786c1a738a83d7fbbde377589c0d974 + sha256: "480ba4345773f56acda9abf5f50bd966f581dac5d514e5fc4a18c62976bbba7e" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.3.2" shared_preferences_foundation: dependency: transitive description: @@ -1001,10 +1001,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: f0c73347dfcfa5b3db8bc06e1502668265d39c08f310c29bff4e28eea9699f79 + sha256: e35a698ac302dd68e41f73250bd9517fe3ab5fa4f18fe4647a0872db61bacbab url: "https://pub.dev" source: hosted - version: "6.3.9" + version: "6.3.10" url_launcher_ios: dependency: transitive description: @@ -1057,10 +1057,10 @@ packages: dependency: transitive description: name: uuid - sha256: "83d37c7ad7aaf9aa8e275490669535c8080377cfa7a7004c24dfac53afffaa90" + sha256: f33d6bb662f0e4f79dcd7ada2e6170f3b3a2530c28fc41f49a411ddedd576a77 url: "https://pub.dev" source: hosted - version: "4.4.2" + version: "4.5.0" vector_math: dependency: transitive description: @@ -1073,10 +1073,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.2.4" + version: "14.2.5" web: dependency: transitive description: @@ -1089,18 +1089,18 @@ packages: dependency: "direct main" description: name: webview_flutter - sha256: "6869c8786d179f929144b4a1f86e09ac0eddfe475984951ea6c634774c16b522" + sha256: ec81f57aa1611f8ebecf1d2259da4ef052281cb5ad624131c93546c79ccc7736 url: "https://pub.dev" source: hosted - version: "4.8.0" + version: "4.9.0" webview_flutter_android: dependency: transitive description: name: webview_flutter_android - sha256: c66651fba15f9d7ddd31daec42da8d6bce46c85610a7127e3ebcb39a4395c3c9 + sha256: "6e64fcb1c19d92024da8f33503aaeeda35825d77142c01d0ea2aa32edc79fdc8" url: "https://pub.dev" source: hosted - version: "3.16.6" + version: "3.16.7" webview_flutter_platform_interface: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 890ec30..3a66aed 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.1.20+2277 +version: 1.1.21+2278 environment: sdk: '>=3.0.0 <4.0.0' From d801994fed674404683c259313a30a29d83625dd Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 8 Sep 2024 03:58:51 -0400 Subject: [PATCH 8/8] Added "allow insecure request" option (#1825) --- assets/translations/bs.json | 1 + assets/translations/cs.json | 1 + assets/translations/da.json | 1 + assets/translations/de.json | 1 + assets/translations/en-EO.json | 1 + assets/translations/en.json | 1 + assets/translations/es.json | 1 + assets/translations/fa.json | 1 + assets/translations/fr.json | 1 + assets/translations/hu.json | 1 + assets/translations/it.json | 1 + assets/translations/ja.json | 1 + assets/translations/nl.json | 1 + assets/translations/pl.json | 1 + assets/translations/pt.json | 1 + assets/translations/ru.json | 1 + assets/translations/sv.json | 1 + assets/translations/tr.json | 1 + assets/translations/uk.json | 1 + assets/translations/vi.json | 1 + assets/translations/zh-Hant-TW.json | 1 + assets/translations/zh.json | 1 + lib/app_sources/directAPKLink.dart | 1 - lib/app_sources/html.dart | 3 +- lib/providers/apps_provider.dart | 45 +++++++++++++++++++---------- lib/providers/source_provider.dart | 19 +++++++++++- 26 files changed, 72 insertions(+), 18 deletions(-) diff --git a/assets/translations/bs.json b/assets/translations/bs.json index 7868a31..b08151c 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Dijeli sa AppVerifier-om, zatim se vratite kada ste spremni.", "wiki": "Pomoć/Wiki", "crowdsourcedConfigsLabel": "Konfiguracije aplikacije obezbeđene pomoću velikog broja ljudi (crowdsourcing) (koristite na svoju odgovornost)", + "allowInsecure": "Allow insecure HTTP requests", "removeAppQuestion": { "one": "Želite li ukloniti aplikaciju?", "other": "Želite li ukloniti aplikacije?" diff --git a/assets/translations/cs.json b/assets/translations/cs.json index 537960c..11552ce 100644 --- a/assets/translations/cs.json +++ b/assets/translations/cs.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Sdílejte do aplikace AppVerifier a po dokončení se sem vraťte.", "wiki": "Nápověda/Wiki", "crowdsourcedConfigsLabel": "Konfigurace aplikací s využitím crowdsourcingu (použití na vlastní nebezpečí)", + "allowInsecure": "Povolení nezabezpečených požadavků HTTP", "removeAppQuestion": { "one": "Odstranit Apku?", "other": "Odstranit Apky?" diff --git a/assets/translations/da.json b/assets/translations/da.json index db918d0..7bc0450 100644 --- a/assets/translations/da.json +++ b/assets/translations/da.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Del til AppVerifier, og vend tilbage hertil, når du er klar.", "wiki": "Hjælp/Wiki", "crowdsourcedConfigsLabel": "Crowdsourcede app-konfigurationer (brug på egen risiko)", + "allowInsecure": "Tillad usikre HTTP-anmodninger", "removeAppQuestion": { "one": "Fjern app?", "other": "Fjern apps?" diff --git a/assets/translations/de.json b/assets/translations/de.json index e199f6a..425b22d 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Geben Sie die Daten an AppVerifier weiter und kehren Sie dann hierher zurück, wenn Sie fertig sind.", "wiki": "Hilfe/Wiki", "crowdsourcedConfigsLabel": "Crowdsourced App-Konfigurationen (Verwendung auf eigene Gefahr)", + "allowInsecure": "Unsichere HTTP-Anfragen zulassen", "removeAppQuestion": { "one": "App entfernen?", "other": "Apps entfernen?" diff --git a/assets/translations/en-EO.json b/assets/translations/en-EO.json index 43b071f..4d14b33 100644 --- a/assets/translations/en-EO.json +++ b/assets/translations/en-EO.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Diskonigu kun AppVerifier, poste revenu ĉi tie kiam preta.", "wiki": "Helpo/Vikio", "crowdsourcedConfigsLabel": "Komunumaj apo-agordoj (uzu kun singardo)", + "allowInsecure": "Allow insecure HTTP requests", "removeAppQuestion": { "one": "Forigi la aplikaĵon?", "other": "Forigi la aplikaĵojn?" diff --git a/assets/translations/en.json b/assets/translations/en.json index a0eba80..cea5156 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Share to AppVerifier, then return here when ready.", "wiki": "Help/Wiki", "crowdsourcedConfigsLabel": "Crowdsourced App Configurations (use at your own risk)", + "allowInsecure": "Allow insecure HTTP requests", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/es.json b/assets/translations/es.json index d80c5e9..1899fc2 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Comparta con AppVerifier y vuelva aquí cuando esté listo.", "wiki": "Ayuda/Wiki", "crowdsourcedConfigsLabel": "Crowdsourced App Configurations (uso bajo su propia responsabilidad)", + "allowInsecure": "Permitir peticiones HTTP inseguras", "removeAppQuestion": { "one": "¿Eliminar aplicación?", "other": "¿Eliminar aplicaciones?" diff --git a/assets/translations/fa.json b/assets/translations/fa.json index 4c88c0f..1c1c7cc 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "در AppVerifier به اشتراک بگذارید، سپس پس از آماده شدن به اینجا برگردید.", "wiki": "راهنما/ویکی", "crowdsourcedConfigsLabel": "تنظیمات برنامه Crowdsourced (با مسئولیت خود استفاده کنید)", + "allowInsecure": "Allow insecure HTTP requests", "removeAppQuestion": { "one": "برنامه حذف شود؟", "other": "برنامه ها حذف شوند؟" diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 965d79d..8b4dab6 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Partagez avec AppVerifier, puis revenez ici lorsque tout est prêt.", "wiki": "Aide/Wiki", "crowdsourcedConfigsLabel": "Configurations d'applications par la communauté (à utiliser à vos risques et périls)", + "allowInsecure": "Autoriser les requêtes HTTP non sécurisées", "removeAppQuestion": { "one": "Supprimer l'application ?", "other": "Supprimer les applications ?" diff --git a/assets/translations/hu.json b/assets/translations/hu.json index ad09e14..469e91e 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Ossza meg az AppVerifierrel, majd térjen vissza ide, ha kész.", "wiki": "Súgó/Wiki", "crowdsourcedConfigsLabel": "Crowdsourced App Configurations (használat saját felelősségre)", + "allowInsecure": "Bizonytalan HTTP-kérések engedélyezése", "removeAppQuestion": { "one": "Eltávolítja az alkalmazást?", "other": "Eltávolítja az alkalmazásokat?" diff --git a/assets/translations/it.json b/assets/translations/it.json index 6c79886..3d930d3 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Condividete con AppVerifier, quindi tornate qui quando siete pronti.", "wiki": "Aiuto/Wiki", "crowdsourcedConfigsLabel": "Configurazioni di app in crowdsourcing (uso a proprio rischio)", + "allowInsecure": "Consentire le richieste HTTP non sicure", "removeAppQuestion": { "one": "Rimuovere l'app?", "other": "Rimuovere le app?" diff --git a/assets/translations/ja.json b/assets/translations/ja.json index 797b38b..1c58b3a 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "AppVerifierに共有し、準備ができたらここに戻ってください。", "wiki": "ヘルプ/ウィキ", "crowdsourcedConfigsLabel": "クラウドソーシングによるアプリの設定(利用は自己責任で)", + "allowInsecure": "安全でないHTTPリクエストを許可する", "removeAppQuestion": { "one": "アプリを削除しますか?", "other": "アプリを削除しますか?" diff --git a/assets/translations/nl.json b/assets/translations/nl.json index 039f7cc..543f953 100644 --- a/assets/translations/nl.json +++ b/assets/translations/nl.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Deel het met AppVerifier en keer daarna hier terug.", "wiki": "Help/Wiki", "crowdsourcedConfigsLabel": "Crowdsourced App-configuraties (gebruik op eigen risico)", + "allowInsecure": "Onveilige HTTP-verzoeken toestaan", "removeAppQuestion": { "one": "App verwijderen?", "other": "Apps verwijderen?" diff --git a/assets/translations/pl.json b/assets/translations/pl.json index 7297882..3e64f8d 100644 --- a/assets/translations/pl.json +++ b/assets/translations/pl.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Udostępnij w AppVerifier, a następnie wróć tutaj, gdy będziesz gotowy.", "wiki": "Pomoc/Wiki", "crowdsourcedConfigsLabel": "Konfiguracje aplikacji pochodzące z crowdsourcingu (korzystanie na własne ryzyko)", + "allowInsecure": "Zezwalaj na niezabezpieczone żądania HTTP", "removeAppQuestion": { "one": "Usunąć aplikację?", "few": "Usunąć aplikacje?", diff --git a/assets/translations/pt.json b/assets/translations/pt.json index d0ff541..0012515 100644 --- a/assets/translations/pt.json +++ b/assets/translations/pt.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Partilhe com o AppVerifier e, em seguida, regresse aqui quando estiver pronto.", "wiki": "Ajuda/Wiki", "crowdsourcedConfigsLabel": "Configurações de aplicações de crowdsourcing (utilização por sua conta e risco)", + "allowInsecure": "Permitir pedidos HTTP inseguros", "removeAppQuestion": { "one": "Remover aplicativo?", "other": "Remover aplicativos?" diff --git a/assets/translations/ru.json b/assets/translations/ru.json index ec8f603..5bd4b93 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Поделитесь с AppVerifier, а затем вернитесь сюда, когда будете готовы.", "wiki": "Помощь/Вики", "crowdsourcedConfigsLabel": "Конфигурации приложений на основе краудсорсинга (используйте на свой страх и риск)", + "allowInsecure": "Разрешить небезопасные HTTP-запросы", "removeAppQuestion": { "one": "Удалить приложение?", "other": "Удалить приложения?" diff --git a/assets/translations/sv.json b/assets/translations/sv.json index 56dfd9d..490cbc3 100644 --- a/assets/translations/sv.json +++ b/assets/translations/sv.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Dela till AppVerifier och återvänd sedan hit när du är klar.", "wiki": "Hjälp/Wiki", "crowdsourcedConfigsLabel": "Crowdsourcade appkonfigurationer (använd på egen risk)", + "allowInsecure": "Tillåt osäkra HTTP-förfrågningar", "removeAppQuestion": { "one": "Ta Bort App?", "other": "Ta Bort Appar?" diff --git a/assets/translations/tr.json b/assets/translations/tr.json index 7243da0..745d59f 100644 --- a/assets/translations/tr.json +++ b/assets/translations/tr.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "AppVerifier ile paylaşın, hazır olduğunuzda buraya dönün.", "wiki": "Yardım/Wiki", "crowdsourcedConfigsLabel": "Kitle Kaynaklı Uygulama Yapılandırmaları (riski size ait olmak üzere kullanın)", + "allowInsecure": "Güvensiz HTTP isteklerine izin ver", "removeAppQuestion": { "one": "Uygulamayı Kaldır?", "other": "Uygulamaları Kaldır?" diff --git a/assets/translations/uk.json b/assets/translations/uk.json index bd38802..9754ebe 100644 --- a/assets/translations/uk.json +++ b/assets/translations/uk.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Надішліть на AppVerifier, а потім поверніться сюди, коли будете готові.", "wiki": "Довідка/Вікі", "crowdsourcedConfigsLabel": "Краудсорсингові конфігурації додатків (використовуйте на свій страх і ризик)", + "allowInsecure": "Дозволити незахищені HTTP-запити", "removeAppQuestion": { "one": "Видалити застосунок?", "other": "Видалити застосунки?" diff --git a/assets/translations/vi.json b/assets/translations/vi.json index e545fc1..1f09f12 100644 --- a/assets/translations/vi.json +++ b/assets/translations/vi.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "Chia sẻ lên AppVerifier, sau đó quay lại đây khi sẵn sàng.", "wiki": "Trợ giúp/Wiki", "crowdsourcedConfigsLabel": "Crowdsourced App Configurations (use at your own risk)", + "allowInsecure": "Allow insecure HTTP requests", "removeAppQuestion": { "one": "Gỡ ứng dụng?", "other": "Gỡ ứng dụng?" diff --git a/assets/translations/zh-Hant-TW.json b/assets/translations/zh-Hant-TW.json index 5aec1b9..7f38e49 100644 --- a/assets/translations/zh-Hant-TW.json +++ b/assets/translations/zh-Hant-TW.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "分享至 AppVerifier,然後準備好時回到此處。", "wiki": "幫助/維基", "crowdsourcedConfigsLabel": "群眾外包的應用程式設定(使用風險自負)", + "allowInsecure": "Allow insecure HTTP requests", "removeAppQuestion": { "one": "移除應用程式?", "other": "移除應用程式?" diff --git a/assets/translations/zh.json b/assets/translations/zh.json index 220dafd..ea41bf7 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -314,6 +314,7 @@ "appVerifierInstructionToast": "分享至 AppVerifier,完成后返回此处。", "wiki": "帮助/Wiki", "crowdsourcedConfigsLabel": "众包应用程序配置(使用风险自负)", + "allowInsecure": "允许不安全的 HTTP 请求", "removeAppQuestion": { "one": "是否删除应用?", "other": "是否删除应用?" diff --git a/lib/app_sources/directAPKLink.dart b/lib/app_sources/directAPKLink.dart index 1addc13..d17b3d7 100644 --- a/lib/app_sources/directAPKLink.dart +++ b/lib/app_sources/directAPKLink.dart @@ -26,7 +26,6 @@ class DirectAPKLink extends AppSource { @override String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { - print('AAA'); if (!forSelection) { return url; } diff --git a/lib/app_sources/html.dart b/lib/app_sources/html.dart index d3244d8..553f4ec 100644 --- a/lib/app_sources/html.dart +++ b/lib/app_sources/html.dart @@ -350,7 +350,8 @@ class HTML extends AppSource { ? rel.hashCode.toString() : (await checkPartialDownloadHashDynamic(rel, headers: await getRequestHeaders(additionalSettings, - forAPKDownload: true))) + forAPKDownload: true), + allowInsecure: additionalSettings['allowInsecure'] == true)) .toString(); return APKDetails(version, [rel].map((e) => MapEntry(e, e)).toList(), AppNames(uri.host, tr('app'))); diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 93201d5..d1b968d 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -17,6 +17,7 @@ import 'package:device_info_plus/device_info_plus.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:http/io_client.dart'; import 'package:obtainium/components/generated_form.dart'; import 'package:obtainium/components/generated_form_modal.dart'; import 'package:obtainium/custom_errors.dart'; @@ -146,17 +147,23 @@ Future downloadFileWithRetry(String url, String fileName, bool fileNameHasExt, Function? onProgress, String destDir, {bool useExisting = true, Map? headers, - int retries = 3}) async { + int retries = 3, + bool allowInsecure = false}) async { try { return await downloadFile( url, fileName, fileNameHasExt, onProgress, destDir, - useExisting: useExisting, headers: headers); + useExisting: useExisting, + headers: headers, + allowInsecure: allowInsecure); } catch (e) { if (retries > 0 && e is ClientException) { await Future.delayed(const Duration(seconds: 5)); return await downloadFileWithRetry( url, fileName, fileNameHasExt, onProgress, destDir, - useExisting: useExisting, headers: headers, retries: (retries - 1)); + useExisting: useExisting, + headers: headers, + retries: (retries - 1), + allowInsecure: allowInsecure); } else { rethrow; } @@ -173,11 +180,14 @@ String hashListOfLists(List> data) { Future checkPartialDownloadHashDynamic(String url, {int startingSize = 1024, int lowerLimit = 128, - Map? headers}) async { + Map? headers, + bool allowInsecure = false}) async { for (int i = startingSize; i >= lowerLimit; i -= 256) { List ab = await Future.wait([ - checkPartialDownloadHash(url, i, headers: headers), - checkPartialDownloadHash(url, i, headers: headers) + checkPartialDownloadHash(url, i, + headers: headers, allowInsecure: allowInsecure), + checkPartialDownloadHash(url, i, + headers: headers, allowInsecure: allowInsecure) ]); if (ab[0] == ab[1]) { return ab[0]; @@ -187,13 +197,13 @@ Future checkPartialDownloadHashDynamic(String url, } Future checkPartialDownloadHash(String url, int bytesToGrab, - {Map? headers}) async { + {Map? headers, bool allowInsecure = false}) async { var req = Request('GET', Uri.parse(url)); if (headers != null) { req.headers.addAll(headers); } req.headers[HttpHeaders.rangeHeader] = 'bytes=0-$bytesToGrab'; - var client = http.Client(); + var client = IOClient(createHttpClient(allowInsecure)); var response = await client.send(req); if (response.statusCode < 200 || response.statusCode > 299) { throw ObtainiumError(response.reasonPhrase ?? tr('unexpectedError')); @@ -204,12 +214,14 @@ Future checkPartialDownloadHash(String url, int bytesToGrab, Future downloadFile(String url, String fileName, bool fileNameHasExt, Function? onProgress, String destDir, - {bool useExisting = true, Map? headers}) async { + {bool useExisting = true, + Map? headers, + bool allowInsecure = false}) 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)); req.headers.addAll(reqHeaders); - var client = http.Client(); + var client = IOClient(createHttpClient(allowInsecure)); StreamedResponse response = await client.send(req); var resHeaders = response.headers; @@ -275,7 +287,7 @@ Future downloadFile(String url, String fileName, bool fileNameHasExt, IOSink? sink; if (rangeFeatureEnabled && fullContentLength != null && rangeStart > 0) { client.close(); - client = http.Client(); + client = IOClient(createHttpClient(allowInsecure)); req = Request('GET', Uri.parse(url)); req.headers.addAll(reqHeaders); req.headers.addAll({'range': 'bytes=$rangeStart-${fullContentLength - 1}'}); @@ -318,12 +330,12 @@ Future downloadFile(String url, String fileName, bool fileNameHasExt, } Future> getHeaders(String url, - {Map? headers}) async { + {Map? headers, bool allowInsecure = false}) async { var req = http.Request('GET', Uri.parse(url)); if (headers != null) { req.headers.addAll(headers); } - var client = http.Client(); + var client = IOClient(createHttpClient(allowInsecure)); var response = await client.send(req); if (response.statusCode < 200 || response.statusCode > 299) { throw ObtainiumError(response.reasonPhrase ?? tr('unexpectedError')); @@ -468,7 +480,9 @@ class AppsProvider with ChangeNotifier { notificationsProvider?.notify(notif); } prevProg = prog; - }, APKDir.path, useExisting: useExisting); + }, APKDir.path, + useExisting: useExisting, + allowInsecure: app.additionalSettings['allowInsecure'] == true); // Set to 90 for remaining steps, will make null in 'finally' if (apps[app.id] != null) { apps[app.id]!.downloadProgress = -1; @@ -1036,7 +1050,8 @@ class AppsProvider with ChangeNotifier { .getRequestHeaders(app.additionalSettings, forAPKDownload: fileUrl.key.endsWith('.apk') ? true : false), - useExisting: false); + useExisting: false, + allowInsecure: app.additionalSettings['allowInsecure'] == true); notificationsProvider .notify(DownloadedNotification(fileUrl.key, fileUrl.value)); } catch (e) { diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index d60e19f..43b90ba 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -2,11 +2,13 @@ // AppSource is an abstract class with a concrete implementation for each source import 'dart:convert'; +import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:html/dom.dart'; import 'package:http/http.dart'; +import 'package:http/io_client.dart'; import 'package:obtainium/app_sources/apkmirror.dart'; import 'package:obtainium/app_sources/apkpure.dart'; import 'package:obtainium/app_sources/aptoide.dart'; @@ -399,6 +401,15 @@ getSourceRegex(List hosts) { return '(${hosts.join('|').replaceAll('.', '\\.')})'; } +HttpClient createHttpClient(bool insecure) { + final client = HttpClient(); + if (insecure) { + client.badCertificateCallback = + (X509Certificate cert, String host, int port) => true; + } + return client; +} + abstract class AppSource { List hosts = []; bool hostChanged = false; @@ -462,7 +473,9 @@ abstract class AppSource { if (requestHeaders != null) { req.headers.addAll(requestHeaders); } - return Response.fromStream(await Client().send(req)); + return Response.fromStream(await IOClient( + createHttpClient(additionalSettings['allowInsecure'] == true)) + .send(req)); } else { return get(Uri.parse(url)); } @@ -538,6 +551,10 @@ abstract class AppSource { GeneratedFormSwitch('shizukuPretendToBeGooglePlay', label: tr('shizukuPretendToBeGooglePlay'), defaultValue: false) ], + [ + GeneratedFormSwitch('allowInsecure', + label: tr('allowInsecure'), defaultValue: false) + ], [ GeneratedFormSwitch('exemptFromBackgroundUpdates', label: tr('exemptFromBackgroundUpdates'))