mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-16 11:48:09 +02:00
More version filtering options for F-Droid (#885)
This commit is contained in:
@@ -256,6 +256,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Remover App?",
|
"one": "Remover App?",
|
||||||
"other": "Remover Apps?"
|
"other": "Remover Apps?"
|
||||||
|
@@ -253,6 +253,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Želite li ukloniti aplikaciju?",
|
"one": "Želite li ukloniti aplikaciju?",
|
||||||
"other": "Želite li ukloniti aplikacije?"
|
"other": "Želite li ukloniti aplikacije?"
|
||||||
|
@@ -253,6 +253,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "App entfernen?",
|
"one": "App entfernen?",
|
||||||
"other": "Apps entfernen?"
|
"other": "Apps entfernen?"
|
||||||
|
@@ -256,6 +256,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Remove App?",
|
"one": "Remove App?",
|
||||||
"other": "Remove Apps?"
|
"other": "Remove Apps?"
|
||||||
|
@@ -253,6 +253,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "¿Eliminar Aplicación?",
|
"one": "¿Eliminar Aplicación?",
|
||||||
"other": "¿Eliminar Aplicaciones?"
|
"other": "¿Eliminar Aplicaciones?"
|
||||||
|
@@ -253,6 +253,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "برنامه حذف شود؟",
|
"one": "برنامه حذف شود؟",
|
||||||
"other": "برنامه ها حذف شوند؟"
|
"other": "برنامه ها حذف شوند؟"
|
||||||
|
@@ -253,6 +253,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Supprimer l'application ?",
|
"one": "Supprimer l'application ?",
|
||||||
"other": "Supprimer les applications ?"
|
"other": "Supprimer les applications ?"
|
||||||
|
@@ -252,6 +252,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Eltávolítja az alkalmazást?",
|
"one": "Eltávolítja az alkalmazást?",
|
||||||
"other": "Eltávolítja az alkalmazást?"
|
"other": "Eltávolítja az alkalmazást?"
|
||||||
|
@@ -253,6 +253,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Rimuovere l'app?",
|
"one": "Rimuovere l'app?",
|
||||||
"other": "Rimuovere le app?"
|
"other": "Rimuovere le app?"
|
||||||
|
@@ -254,6 +254,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "アプリを削除しますか?",
|
"one": "アプリを削除しますか?",
|
||||||
"other": "アプリを削除しますか?"
|
"other": "アプリを削除しますか?"
|
||||||
|
@@ -259,6 +259,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Usunąć aplikację?",
|
"one": "Usunąć aplikację?",
|
||||||
"few": "Usunąć aplikacje?",
|
"few": "Usunąć aplikacje?",
|
||||||
|
@@ -253,6 +253,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Удалить приложение?",
|
"one": "Удалить приложение?",
|
||||||
"other": "Удалить приложения?"
|
"other": "Удалить приложения?"
|
||||||
|
@@ -254,6 +254,8 @@
|
|||||||
"highlightTouchTargets": "Highlight less obvious touch targets",
|
"highlightTouchTargets": "Highlight less obvious touch targets",
|
||||||
"pickExportDir": "Pick Export Directory",
|
"pickExportDir": "Pick Export Directory",
|
||||||
"autoExportOnChanges": "Auto-export on changes",
|
"autoExportOnChanges": "Auto-export on changes",
|
||||||
|
"filterVersionsByRegEx": "Filter Versions by Regular Expression",
|
||||||
|
"trySelectingSuggestedVersionCode": "Try selecting suggested versionCode APK",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "是否删除应用?",
|
"one": "是否删除应用?",
|
||||||
"other": "是否删除应用?"
|
"other": "是否删除应用?"
|
||||||
|
@@ -13,10 +13,24 @@ class FDroid extends AppSource {
|
|||||||
name = tr('fdroid');
|
name = tr('fdroid');
|
||||||
canSearch = true;
|
canSearch = true;
|
||||||
additionalSourceAppSpecificSettingFormItems = [
|
additionalSourceAppSpecificSettingFormItems = [
|
||||||
|
[
|
||||||
|
GeneratedFormTextField('filterVersionsByRegEx',
|
||||||
|
label: tr('filterVersionsByRegEx'),
|
||||||
|
required: false,
|
||||||
|
additionalValidators: [
|
||||||
|
(value) {
|
||||||
|
return regExValidator(value);
|
||||||
|
}
|
||||||
|
])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
GeneratedFormSwitch('trySelectingSuggestedVersionCode',
|
||||||
|
label: tr('trySelectingSuggestedVersionCode'), defaultValue: true)
|
||||||
|
],
|
||||||
[
|
[
|
||||||
GeneratedFormSwitch('autoSelectHighestVersionCode',
|
GeneratedFormSwitch('autoSelectHighestVersionCode',
|
||||||
label: tr('autoSelectHighestVersionCode'))
|
label: tr('autoSelectHighestVersionCode'))
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,25 +59,73 @@ class FDroid extends AppSource {
|
|||||||
|
|
||||||
APKDetails getAPKUrlsFromFDroidPackagesAPIResponse(
|
APKDetails getAPKUrlsFromFDroidPackagesAPIResponse(
|
||||||
Response res, String apkUrlPrefix, String standardUrl,
|
Response res, String apkUrlPrefix, String standardUrl,
|
||||||
{bool autoSelectHighestVersionCode = false}) {
|
{bool autoSelectHighestVersionCode = false,
|
||||||
|
bool trySelectingSuggestedVersionCode = false,
|
||||||
|
String? filterVersionsByRegEx}) {
|
||||||
if (res.statusCode == 200) {
|
if (res.statusCode == 200) {
|
||||||
List<dynamic> releases = jsonDecode(res.body)['packages'] ?? [];
|
var response = jsonDecode(res.body);
|
||||||
|
List<dynamic> releases = response['packages'] ?? [];
|
||||||
if (releases.isEmpty) {
|
if (releases.isEmpty) {
|
||||||
throw NoReleasesError();
|
throw NoReleasesError();
|
||||||
}
|
}
|
||||||
String? latestVersion = releases[0]['versionName'];
|
String? version;
|
||||||
if (latestVersion == null) {
|
Iterable<dynamic> releaseChoices = [];
|
||||||
|
// Grab the versionCode suggested if the user chose to do that
|
||||||
|
// Only do so at this stage if the user has no release filter
|
||||||
|
if (trySelectingSuggestedVersionCode &&
|
||||||
|
response['suggestedVersionCode'] != null &&
|
||||||
|
filterVersionsByRegEx == null) {
|
||||||
|
var suggestedReleases = releases.where((element) =>
|
||||||
|
element['versionCode'] == response['suggestedVersionCode']);
|
||||||
|
if (suggestedReleases.isNotEmpty) {
|
||||||
|
releaseChoices = suggestedReleases;
|
||||||
|
version = suggestedReleases.first['versionName'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Apply the release filter if any
|
||||||
|
if (filterVersionsByRegEx != null) {
|
||||||
|
version = null;
|
||||||
|
releaseChoices = [];
|
||||||
|
for (var i = 0; i < releases.length; i++) {
|
||||||
|
if (RegExp(filterVersionsByRegEx)
|
||||||
|
.hasMatch(releases[i]['versionName'])) {
|
||||||
|
version = releases[i]['versionName'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (version == null) {
|
||||||
|
throw NoVersionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Default to the highest version
|
||||||
|
version ??= releases[0]['versionName'];
|
||||||
|
if (version == null) {
|
||||||
throw NoVersionError();
|
throw NoVersionError();
|
||||||
}
|
}
|
||||||
Iterable<dynamic> latestReleases =
|
// If a suggested release was not already picked, pick all those with the selected version
|
||||||
releases.where((element) => element['versionName'] == latestVersion);
|
if (releaseChoices.isEmpty) {
|
||||||
if (latestReleases.length > 1 && autoSelectHighestVersionCode) {
|
releaseChoices =
|
||||||
latestReleases = [latestReleases.first];
|
releases.where((element) => element['versionName'] == version);
|
||||||
}
|
}
|
||||||
List<String> apkUrls = latestReleases
|
// For the remaining releases, use the toggles to auto-select one if possible
|
||||||
|
if (releaseChoices.length > 1) {
|
||||||
|
if (autoSelectHighestVersionCode) {
|
||||||
|
releaseChoices = [releaseChoices.first];
|
||||||
|
} else if (trySelectingSuggestedVersionCode &&
|
||||||
|
response['suggestedVersionCode'] != null) {
|
||||||
|
var suggestedReleases = releaseChoices.where((element) =>
|
||||||
|
element['versionCode'] == response['suggestedVersionCode']);
|
||||||
|
if (suggestedReleases.isNotEmpty) {
|
||||||
|
releaseChoices = suggestedReleases;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (releaseChoices.isEmpty) {
|
||||||
|
throw NoReleasesError();
|
||||||
|
}
|
||||||
|
List<String> apkUrls = releaseChoices
|
||||||
.map((e) => '${apkUrlPrefix}_${e['versionCode']}.apk')
|
.map((e) => '${apkUrlPrefix}_${e['versionCode']}.apk')
|
||||||
.toList();
|
.toList();
|
||||||
return APKDetails(latestVersion, getApkUrlsFromUrls(apkUrls),
|
return APKDetails(version, getApkUrlsFromUrls(apkUrls),
|
||||||
AppNames(name, Uri.parse(standardUrl).pathSegments.last));
|
AppNames(name, Uri.parse(standardUrl).pathSegments.last));
|
||||||
} else {
|
} else {
|
||||||
throw getObtainiumHttpError(res);
|
throw getObtainiumHttpError(res);
|
||||||
@@ -82,7 +144,15 @@ class FDroid extends AppSource {
|
|||||||
'https://$host/repo/$appId',
|
'https://$host/repo/$appId',
|
||||||
standardUrl,
|
standardUrl,
|
||||||
autoSelectHighestVersionCode:
|
autoSelectHighestVersionCode:
|
||||||
additionalSettings['autoSelectHighestVersionCode'] == true);
|
additionalSettings['autoSelectHighestVersionCode'] == true,
|
||||||
|
trySelectingSuggestedVersionCode:
|
||||||
|
additionalSettings['trySelectingSuggestedVersionCode'] == true,
|
||||||
|
filterVersionsByRegEx:
|
||||||
|
(additionalSettings['filterVersionsByRegEx'] as String?)
|
||||||
|
?.isNotEmpty ==
|
||||||
|
true
|
||||||
|
? additionalSettings['filterVersionsByRegEx']
|
||||||
|
: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@@ -40,6 +40,9 @@ class IzzyOnDroid extends AppSource {
|
|||||||
'https://android.izzysoft.de/frepo/$appId',
|
'https://android.izzysoft.de/frepo/$appId',
|
||||||
standardUrl,
|
standardUrl,
|
||||||
autoSelectHighestVersionCode:
|
autoSelectHighestVersionCode:
|
||||||
additionalSettings['autoSelectHighestVersionCode'] == true);
|
additionalSettings['autoSelectHighestVersionCode'] == true,
|
||||||
|
trySelectingSuggestedVersionCode:
|
||||||
|
additionalSettings['trySelectingSuggestedVersionCode'] == true,
|
||||||
|
filterVersionsByRegEx: additionalSettings['filterVersionsByRegEx']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user