From d473cb49c53ab6d599bc543f06953662c382cd9f Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 6 Aug 2023 13:14:48 -0400 Subject: [PATCH 1/2] Add custom link filter for HTML --- assets/translations/bs.json | 1 + assets/translations/de.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/pl.json | 1 + assets/translations/ru.json | 1 + assets/translations/zh.json | 1 + lib/app_sources/html.dart | 36 ++++++++++++++++++++++++++++++------ 13 files changed, 42 insertions(+), 6 deletions(-) diff --git a/assets/translations/bs.json b/assets/translations/bs.json index 54fa76b..2c3c5d3 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "Želite li ukloniti aplikaciju?", "other": "Želite li ukloniti aplikacije?" diff --git a/assets/translations/de.json b/assets/translations/de.json index fe26fab..0884158 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "GitLab APK-Extraktion funktioniert möglicherweise nicht ohne API-Schlüssel", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "App entfernen?", "other": "Apps entfernen?" diff --git a/assets/translations/en.json b/assets/translations/en.json index 2daf50e..397c7a2 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/es.json b/assets/translations/es.json index 76bddc6..b5d3d25 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "¿Eliminar Aplicación?", "other": "¿Eliminar Aplicaciones?" diff --git a/assets/translations/fa.json b/assets/translations/fa.json index 342d98d..beaf442 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "برنامه حذف شود؟", "other": "برنامه ها حذف شوند؟" diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 32d1e35..ec680f8 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "Supprimer l'application ?", "other": "Supprimer les applications ?" diff --git a/assets/translations/hu.json b/assets/translations/hu.json index ab5be1f..8b10f31 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -245,6 +245,7 @@ "gitlabSourceNote": "Előfordulhat, hogy a GitLab APK kibontása nem működik API-kulcs nélkül.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "Eltávolítja az alkalmazást?", "other": "Eltávolítja az alkalmazást?" diff --git a/assets/translations/it.json b/assets/translations/it.json index be3e441..4dd0383 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "Rimuovere l'app?", "other": "Rimuovere le app?" diff --git a/assets/translations/ja.json b/assets/translations/ja.json index a89fc20..6c1f7eb 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "GitLabのAPK抽出はAPIキーがないと動作しない場合があります。", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "アプリを削除しますか?", "other": "アプリを削除しますか?" diff --git a/assets/translations/pl.json b/assets/translations/pl.json index be2f699..d227ee2 100644 --- a/assets/translations/pl.json +++ b/assets/translations/pl.json @@ -250,6 +250,7 @@ "gitlabSourceNote": "Pozyskiwanie pliku APK z GitLab może nie działać bez klucza API.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "Usunąć aplikację?", "other": "Usunąć aplikacje?" diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 94a6ebf..1f27453 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "Извлечение APK из GitLab может не работать без ключа API.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "Удалить приложение?", "other": "Удалить приложения?" diff --git a/assets/translations/zh.json b/assets/translations/zh.json index e59296d..d5bc0eb 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "未使用访问令牌时可能无法从 GitLab 获取 APK 文件。", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", + "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", "removeAppQuestion": { "one": "是否删除应用?", "other": "是否删除应用?" diff --git a/lib/app_sources/html.dart b/lib/app_sources/html.dart index a60386e..2331d54 100644 --- a/lib/app_sources/html.dart +++ b/lib/app_sources/html.dart @@ -91,7 +91,18 @@ class HTML extends AppSource { [ GeneratedFormSwitch('sortByFileNamesNotLinks', label: tr('sortByFileNamesNotLinks')) - ] + ], + [ + GeneratedFormTextField('customLinkFilterRegex', + label: tr('customLinkFilterRegex'), + hint: 'download/(.*/)?(android|apk|mobile)', + required: false, + additionalValidators: [ + (value) { + return regExValidator(value); + } + ]) + ], ]; } @@ -115,16 +126,29 @@ class HTML extends AppSource { var uri = Uri.parse(standardUrl); Response res = await sourceRequest(standardUrl); if (res.statusCode == 200) { - List links = parse(res.body) + var html = parse(res.body); + List allLinks = html .querySelectorAll('a') .map((element) => element.attributes['href'] ?? '') - .where((element) => - Uri.parse(element).path.toLowerCase().endsWith('.apk')) .toList(); + List links = []; + if ((additionalSettings['customLinkFilterRegex'] as String?) + ?.isNotEmpty == + true) { + var reg = RegExp(additionalSettings['customLinkFilterRegex']); + links = allLinks.where((element) => reg.hasMatch(element)).toList(); + } else { + links = allLinks + .where((element) => + Uri.parse(element).path.toLowerCase().endsWith('.apk')) + .toList(); + } links.sort((a, b) => additionalSettings['sortByFileNamesNotLinks'] == true - ? compareAlphaNumeric(a.split('/').last, b.split('/').last) + ? compareAlphaNumeric(a.split('/').where((e) => e.isNotEmpty).last, + b.split('/').where((e) => e.isNotEmpty).last) : compareAlphaNumeric(a, b)); - if (additionalSettings['apkFilterRegEx'] != null) { + if ((additionalSettings['apkFilterRegEx'] as String?)?.isNotEmpty == + true) { var reg = RegExp(additionalSettings['apkFilterRegEx']); links = links.where((element) => reg.hasMatch(element)).toList(); } From dcf5bd37ca13b6fcd797c3afe96f3cf2d57d540e Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 13 Aug 2023 21:18:53 -0400 Subject: [PATCH 2/2] Foreground-only silent install support --- android/app/src/main/AndroidManifest.xml | 1 + pubspec.lock | 34 ++++++++++++------------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 35f7597..cfeac66 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -62,6 +62,7 @@ + diff --git a/pubspec.lock b/pubspec.lock index f1e82a6..41f8b1e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -22,7 +22,7 @@ packages: description: path: "." ref: main - resolved-ref: f09c79eee5be3c60b04760143eb954a13fdd07f1 + resolved-ref: "2edf5dbbfeeb33257d526861f2a992aee5d97bb4" url: "https://github.com/ImranR98/android_package_installer" source: git version: "0.0.1" @@ -206,10 +206,10 @@ packages: dependency: transitive description: name: ffi - sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.1.0" file: dependency: transitive description: @@ -296,10 +296,10 @@ packages: dependency: "direct main" description: name: flutter_markdown - sha256: "4b1bfbb802d76320a1a46d9ce984106135093efd9d969765d07c2125af107bdf" + sha256: "2b206d397dd7836ea60035b2d43825c8a303a76a5098e66f42d55a753e18d431" url: "https://pub.dev" source: hosted - version: "0.6.17" + version: "0.6.17+1" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -482,10 +482,10 @@ packages: dependency: "direct main" description: name: path_provider - sha256: "3087813781ab814e4157b172f1a11c46be20179fcc9bea043e0fba36bc0acaa2" + sha256: "909b84830485dbcd0308edf6f7368bc8fd76afa26a270420f34cabea2a6467a0" url: "https://pub.dev" source: hosted - version: "2.0.15" + version: "2.1.0" path_provider_android: dependency: transitive description: @@ -642,10 +642,10 @@ packages: dependency: transitive description: name: shared_preferences_foundation - sha256: f39696b83e844923b642ce9dd4bd31736c17e697f6731a5adf445b1274cf3cd4 + sha256: d29753996d8eb8f7619a1f13df6ce65e34bc107bef6330739ed76f18b22310ef url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.3.3" shared_preferences_linux: dependency: transitive description: @@ -783,10 +783,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: "78cb6dea3e93148615109e58e42c35d1ffbf5ef66c44add673d0ab75f12ff3af" + sha256: "3dd2388cc0c42912eee04434531a26a82512b9cb1827e0214430c9bcbddfe025" url: "https://pub.dev" source: hosted - version: "6.0.37" + version: "6.0.38" url_launcher_ios: dependency: transitive description: @@ -863,10 +863,10 @@ packages: dependency: transitive description: name: webview_flutter_android - sha256: d936a09fbfd08cb78f7329e0bbacf6158fbdfe24ffc908b22444c07d295eb193 + sha256: bca797abba472868655b5f1a6029c1132385685ee9db4713cb0e7f33076210c6 url: "https://pub.dev" source: hosted - version: "3.9.2" + version: "3.9.3" webview_flutter_platform_interface: dependency: transitive description: @@ -879,10 +879,10 @@ packages: dependency: transitive description: name: webview_flutter_wkwebview - sha256: "5fa098f28b606f699e8ca52d9e4e11edbbfef65189f5f77ae92703ba5408fd25" + sha256: ed749f94ac9e814d04a258a9255cf69cfa4cc6006ff59542aea7fb4590144972 url: "https://pub.dev" source: hosted - version: "3.7.2" + version: "3.7.3" win32: dependency: transitive description: @@ -903,10 +903,10 @@ packages: dependency: transitive description: name: xdg_directories - sha256: e0b1147eec179d3911f1f19b59206448f78195ca1d20514134e10641b7d7fbff + sha256: f0c26453a2d47aa4c2570c6a033246a3fc62da2fe23c7ffdd0a7495086dc0247 url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.0.2" xml: dependency: transitive description: