From 0804e680b2f3bd36c552936db55a48cca03d5460 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Thu, 6 Apr 2023 22:37:24 -0400 Subject: [PATCH] Added simple APK try auto-select by CPU arch #436 Plus minor form switch UI fixes (overflow, spacing) --- assets/translations/de.json | 1 + assets/translations/en.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/zh.json | 1 + lib/components/generated_form.dart | 5 ++++- lib/main.dart | 2 +- lib/providers/source_provider.dart | 23 +++++++++++++++++++++++ pubspec.yaml | 2 +- 12 files changed, 37 insertions(+), 3 deletions(-) diff --git a/assets/translations/de.json b/assets/translations/de.json index 95d0bab..e0caa02 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -222,6 +222,7 @@ "versionDetection": "Versionserkennung", "standardVersionDetection": "Standardversionserkennung", "groupByCategory": "Group by Category", + "autoApkFilterByArch": "Attempt to filter APKs by CPU architecture if possible", "removeAppQuestion": { "one": "App entfernen?", "other": "App entfernen?" diff --git a/assets/translations/en.json b/assets/translations/en.json index 379b45c..bdafd9b 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -222,6 +222,7 @@ "versionDetection": "Version Detection", "standardVersionDetection": "Standard version detection", "groupByCategory": "Group by Category", + "autoApkFilterByArch": "Attempt to filter APKs by CPU architecture if possible", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/fa.json b/assets/translations/fa.json index 2aebffb..f0b9401 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -222,6 +222,7 @@ "versionDetection": "تشخیص نسخه", "standardVersionDetection": "تشخیص نسخه استاندارد", "groupByCategory": "Group by Category", + "autoApkFilterByArch": "Attempt to filter APKs by CPU architecture if possible", "removeAppQuestion": { "one": "برنامه حذف شود؟", "other": "برنامه ها حذف شوند؟" diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 2912ab1..b363c4f 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -222,6 +222,7 @@ "versionDetection": "Détection des versions", "standardVersionDetection": "Détection de version standard", "groupByCategory": "Group by Category", + "autoApkFilterByArch": "Attempt to filter APKs by CPU architecture if possible", "removeAppQuestion": { "one": "Supprimer l'application ?", "other": "Supprimer les applications ?" diff --git a/assets/translations/hu.json b/assets/translations/hu.json index 40f7f59..5fd5ec5 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -221,6 +221,7 @@ "versionDetection": "Verzió érzékelés", "standardVersionDetection": "Alapért. verzió érzékelés", "groupByCategory": "Csoportosítás Kategória alapján", + "autoApkFilterByArch": "Attempt to filter APKs by CPU architecture if possible", "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 85ea697..4a619f6 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -222,6 +222,7 @@ "versionDetection": "Rilevamento di versione", "standardVersionDetection": "Rilevamento di versione standard", "groupByCategory": "Group by Category", + "autoApkFilterByArch": "Attempt to filter APKs by CPU architecture if possible", "removeAppQuestion": { "one": "Rimuovere l'App?", "other": "Rimuovere le App?" diff --git a/assets/translations/ja.json b/assets/translations/ja.json index 04806a4..eee03d3 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -222,6 +222,7 @@ "versionDetection": "バージョン検出", "standardVersionDetection": "標準のバージョン検出", "groupByCategory": "Group by Category", + "autoApkFilterByArch": "Attempt to filter APKs by CPU architecture if possible", "removeAppQuestion": { "one": "アプリを削除しますか?", "other": "アプリを削除しますか?" diff --git a/assets/translations/zh.json b/assets/translations/zh.json index 0aba1e6..b1a18bc 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -222,6 +222,7 @@ "versionDetection": "Version Detection", "standardVersionDetection": "Standard version detection", "groupByCategory": "Group by Category", + "autoApkFilterByArch": "Attempt to filter APKs by CPU architecture if possible", "removeAppQuestion": { "one": "删除应用?", "other": "删除应用?" diff --git a/lib/components/generated_form.dart b/lib/components/generated_form.dart index 3f892c8..8ab4149 100644 --- a/lib/components/generated_form.dart +++ b/lib/components/generated_form.dart @@ -267,7 +267,10 @@ class _GeneratedFormState extends State { formInputs[r][e] = Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(widget.items[r][e].label), + Flexible(child: Text(widget.items[r][e].label)), + const SizedBox( + width: 8, + ), Switch( value: values[widget.items[r][e].key], onChanged: (value) { diff --git a/lib/main.dart b/lib/main.dart index db412df..016eb3a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart'; // ignore: implementation_imports import 'package:easy_localization/src/localization.dart'; -const String currentVersion = '0.11.25'; +const String currentVersion = '0.11.26'; const String currentReleaseTag = 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 6e3430c..181d423 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -3,6 +3,7 @@ import 'dart:convert'; +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'; @@ -146,6 +147,11 @@ class App { .toList(); } } + // Arch based APK filter option should be disabled if it previously did not exist + if (json['additionalSettings'] != null && + jsonDecode(json['additionalSettings'])['autoApkFilterByArch'] == null) { + additionalSettings['autoApkFilterByArch'] = false; + } return App( json['id'] as String, json['url'] as String, @@ -294,6 +300,10 @@ class AppSource { } ]) ], + [ + GeneratedFormSwitch('autoApkFilterByArch', + label: tr('autoApkFilterByArch'), defaultValue: true) + ], [GeneratedFormTextField('appName', label: tr('appName'), required: false)] ]; @@ -442,6 +452,19 @@ class SourceProvider { if (apk.apkUrls.isEmpty && !trackOnly) { throw NoAPKError(); } + if (apk.apkUrls.length > 1 && + additionalSettings['autoApkFilterByArch'] == true) { + var abis = (await DeviceInfoPlugin().androidInfo).supportedAbis; + for (var abi in abis) { + var urls2 = apk.apkUrls + .where((element) => RegExp('.*$abi.*').hasMatch(element.key)) + .toList(); + if (urls2.isNotEmpty && urls2.length < apk.apkUrls.length) { + apk.apkUrls = urls2; + break; + } + } + } String apkVersion = apk.version.replaceAll('/', '-'); var name = currentApp != null ? currentApp.name.trim() : ''; name = name.isNotEmpty diff --git a/pubspec.yaml b/pubspec.yaml index f080bd2..cd39266 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: 0.11.25+147 # When changing this, update the tag in main() accordingly +version: 0.11.26+148 # When changing this, update the tag in main() accordingly environment: sdk: '>=2.18.2 <3.0.0'