mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-11-04 07:13:28 +01:00 
			
		
		
		
	Merge pull request #309 from ImranR98/dev
Release Filter Support for APKMirror (#307) + UI Bugfix (#303)
This commit is contained in:
		@@ -1,7 +1,9 @@
 | 
			
		||||
import 'dart:io';
 | 
			
		||||
 | 
			
		||||
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';
 | 
			
		||||
 | 
			
		||||
@@ -9,6 +11,23 @@ class APKMirror extends AppSource {
 | 
			
		||||
  APKMirror() {
 | 
			
		||||
    host = 'apkmirror.com';
 | 
			
		||||
    enforceTrackOnly = true;
 | 
			
		||||
 | 
			
		||||
    additionalSourceAppSpecificSettingFormItems = [
 | 
			
		||||
      [
 | 
			
		||||
        GeneratedFormSwitch('fallbackToOlderReleases',
 | 
			
		||||
            label: tr('fallbackToOlderReleases'), defaultValue: true)
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        GeneratedFormTextField('filterReleaseTitlesByRegEx',
 | 
			
		||||
            label: tr('filterReleaseTitlesByRegEx'),
 | 
			
		||||
            required: false,
 | 
			
		||||
            additionalValidators: [
 | 
			
		||||
              (value) {
 | 
			
		||||
                return regExValidator(value);
 | 
			
		||||
              }
 | 
			
		||||
            ])
 | 
			
		||||
      ]
 | 
			
		||||
    ];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
@@ -30,11 +49,31 @@ class APKMirror extends AppSource {
 | 
			
		||||
    String standardUrl,
 | 
			
		||||
    Map<String, dynamic> additionalSettings,
 | 
			
		||||
  ) async {
 | 
			
		||||
    bool fallbackToOlderReleases =
 | 
			
		||||
        additionalSettings['fallbackToOlderReleases'] == true;
 | 
			
		||||
    String? regexFilter =
 | 
			
		||||
        (additionalSettings['filterReleaseTitlesByRegEx'] as String?)
 | 
			
		||||
                    ?.isNotEmpty ==
 | 
			
		||||
                true
 | 
			
		||||
            ? additionalSettings['filterReleaseTitlesByRegEx']
 | 
			
		||||
            : null;
 | 
			
		||||
    Response res = await get(Uri.parse('$standardUrl/feed'));
 | 
			
		||||
    if (res.statusCode == 200) {
 | 
			
		||||
      var item = parse(res.body).querySelector('item');
 | 
			
		||||
      String? titleString = item?.querySelector('title')?.innerHtml;
 | 
			
		||||
      String? dateString = item
 | 
			
		||||
      var items = parse(res.body).querySelectorAll('item');
 | 
			
		||||
      dynamic targetRelease;
 | 
			
		||||
      for (int i = 0; i < items.length; i++) {
 | 
			
		||||
        if (!fallbackToOlderReleases && i > 0) break;
 | 
			
		||||
        String? nameToFilter = items[i].querySelector('title')?.innerHtml;
 | 
			
		||||
        if (regexFilter != null &&
 | 
			
		||||
            nameToFilter != null &&
 | 
			
		||||
            !RegExp(regexFilter).hasMatch(nameToFilter.trim())) {
 | 
			
		||||
          continue;
 | 
			
		||||
        }
 | 
			
		||||
        targetRelease = items[i];
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      String? titleString = targetRelease?.querySelector('title')?.innerHtml;
 | 
			
		||||
      String? dateString = targetRelease
 | 
			
		||||
          ?.querySelector('pubDate')
 | 
			
		||||
          ?.innerHtml
 | 
			
		||||
          .split(' ')
 | 
			
		||||
 
 | 
			
		||||
@@ -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.0';
 | 
			
		||||
const String currentVersion = '0.11.1';
 | 
			
		||||
const String currentReleaseTag =
 | 
			
		||||
    'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -266,6 +266,7 @@ class AppsPageState extends State<AppsPage> {
 | 
			
		||||
                          )
 | 
			
		||||
                        : null,
 | 
			
		||||
                    title: Text(
 | 
			
		||||
                      maxLines: 1,
 | 
			
		||||
                      listedApps[index].installedInfo?.name ??
 | 
			
		||||
                          listedApps[index].app.name,
 | 
			
		||||
                      style: TextStyle(
 | 
			
		||||
@@ -298,11 +299,14 @@ class AppsPageState extends State<AppsPage> {
 | 
			
		||||
                                  Row(
 | 
			
		||||
                                      mainAxisSize: MainAxisSize.min,
 | 
			
		||||
                                      children: [
 | 
			
		||||
                                        Text(
 | 
			
		||||
                                          '${listedApps[index].app.installedVersion ?? tr('notInstalled')}${listedApps[index].app.additionalSettings['trackOnly'] == true ? ' ${tr('estimateInBrackets')}' : ''}',
 | 
			
		||||
                                          overflow: TextOverflow.ellipsis,
 | 
			
		||||
                                          textAlign: TextAlign.end,
 | 
			
		||||
                                        )
 | 
			
		||||
                                        Container(
 | 
			
		||||
                                            constraints: const BoxConstraints(
 | 
			
		||||
                                                maxWidth: 150),
 | 
			
		||||
                                            child: Text(
 | 
			
		||||
                                              '${listedApps[index].app.installedVersion ?? tr('notInstalled')}${listedApps[index].app.additionalSettings['trackOnly'] == true ? ' ${tr('estimateInBrackets')}' : ''}',
 | 
			
		||||
                                              overflow: TextOverflow.ellipsis,
 | 
			
		||||
                                              textAlign: TextAlign.end,
 | 
			
		||||
                                            ))
 | 
			
		||||
                                      ]),
 | 
			
		||||
                                  GestureDetector(
 | 
			
		||||
                                      onTap: changesUrl == null
 | 
			
		||||
 
 | 
			
		||||
@@ -830,10 +830,10 @@ packages:
 | 
			
		||||
    dependency: "direct main"
 | 
			
		||||
    description:
 | 
			
		||||
      name: webview_flutter
 | 
			
		||||
      sha256: f7ec234830f86d0ef2bd664e8460b0038b8c1a83ff076035cad74ac70273753c
 | 
			
		||||
      sha256: dad1f2caa3272071275436984eb123276a6810dbe7cd6f4c60697640b56a4699
 | 
			
		||||
      url: "https://pub.dev"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "4.0.2"
 | 
			
		||||
    version: "4.0.4"
 | 
			
		||||
  webview_flutter_android:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
 
 | 
			
		||||
@@ -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.0+119 # When changing this, update the tag in main() accordingly
 | 
			
		||||
version: 0.11.1+120 # When changing this, update the tag in main() accordingly
 | 
			
		||||
 | 
			
		||||
environment:
 | 
			
		||||
  sdk: '>=2.18.2 <3.0.0'
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user