Skip to content

Commit

Permalink
Merge pull request #2030 from ImranR98/dev
Browse files Browse the repository at this point in the history
- Avoid OS version reconciliation for pseudo-versioned apps (#2023)
- When importing configs via link, don't show dialog twice
- GitHub - do not use filtered asset release dates (#2012)
  • Loading branch information
ImranR98 authored Dec 12, 2024
2 parents 79c4d3b + d93798a commit 8651f58
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 44 deletions.
42 changes: 33 additions & 9 deletions lib/app_sources/github.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,15 @@ class GitHub extends AppSource {
}
}

List<MapEntry<String, String>> getReleaseAssetUrls(dynamic release) =>
findReleaseAssetUrls(dynamic release) =>
(release['assets'] as List<dynamic>?)?.map((e) {
var url = !e['name'].toString().toLowerCase().endsWith('.apk')
? (e['browser_download_url'] ?? e['url'])
: (e['url'] ?? e['browser_download_url']);
return (e['name'] != null) && (url != null)
e['final_url'] = (e['name'] != null) && (url != null)
? MapEntry(e['name'] as String, url as String)
: const MapEntry('', '');
return e;
}).toList() ??
[];

Expand All @@ -293,7 +294,9 @@ class GitHub extends AppSource {
? DateTime.parse(rel['commit']['created'])
: null;
DateTime? getNewestAssetDateFromRelease(dynamic rel) {
var t = (rel['assets'] as List<dynamic>?)
var allAssets = rel['assets'] as List<dynamic>?;
var filteredAssets = rel['filteredAssets'] as List<dynamic>?;
var t = (filteredAssets ?? allAssets)
?.map((e) {
return e?['updated_at'] != null
? DateTime.parse(e['updated_at'])
Expand Down Expand Up @@ -387,18 +390,38 @@ class GitHub extends AppSource {
.hasMatch(((releases[i]['body'] as String?) ?? '').trim())) {
continue;
}
var allAssetUrls = getReleaseAssetUrls(releases[i]);
List<MapEntry<String, String>> apkUrls = allAssetUrls
.where((element) => element.key.toLowerCase().endsWith('.apk'))
var allAssetsWithUrls = findReleaseAssetUrls(releases[i]);
List<MapEntry<String, String>> allAssetUrls = allAssetsWithUrls
.map((e) => e['final_url'] as MapEntry<String, String>)
.toList();
var apkAssetsWithUrls = allAssetsWithUrls
.where((element) =>
(element['final_url'] as MapEntry<String, String>)
.key
.toLowerCase()
.endsWith('.apk'))
.toList();

apkUrls = filterApks(apkUrls, additionalSettings['apkFilterRegEx'],
var filteredApkUrls = filterApks(
apkAssetsWithUrls
.map((e) => e['final_url'] as MapEntry<String, String>)
.toList(),
additionalSettings['apkFilterRegEx'],
additionalSettings['invertAPKFilter']);
if (apkUrls.isEmpty && additionalSettings['trackOnly'] != true) {
var filteredApks = apkAssetsWithUrls
.where((e) => filteredApkUrls
.where((e2) =>
e2.key == (e['final_url'] as MapEntry<String, String>).key)
.isNotEmpty)
.toList();

if (apkAssetsWithUrls.isEmpty &&
additionalSettings['trackOnly'] != true) {
continue;
}
targetRelease = releases[i];
targetRelease['apkUrls'] = apkUrls;
targetRelease['apkUrls'] = filteredApkUrls;
targetRelease['filteredAssets'] = filteredApks;
targetRelease['version'] =
additionalSettings['releaseTitleAsVersion'] == true
? nameToFilter
Expand All @@ -420,6 +443,7 @@ class GitHub extends AppSource {
throw NoReleasesError();
}
String? version = targetRelease['version'];

DateTime? releaseDate = getReleaseDateFromRelease(
targetRelease, useLatestAssetDateAsReleaseDate);
if (version == null) {
Expand Down
24 changes: 0 additions & 24 deletions lib/pages/apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -838,30 +838,6 @@ class AppsPageState extends State<AppsPage> {
Navigator.of(context).pop();
}

resetSelectedAppsInstallStatuses() async {
try {
var values = await showDialog(
context: context,
builder: (BuildContext ctx) {
return GeneratedFormModal(
title: tr('resetInstallStatusForSelectedAppsQuestion'),
items: const [],
initValid: true,
message: tr('installStatusOfXWillBeResetExplanation',
args: [plural('apps', selectedAppIds.length)]),
);
});
if (values != null) {
appsProvider.saveApps(selectedApps.map((e) {
e.installedVersion = null;
return e;
}).toList());
}
} finally {
Navigator.of(context).pop();
}
}

showMoreOptionsDialog() {
return showDialog(
context: context,
Expand Down
9 changes: 7 additions & 2 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,18 @@ class _HomePageState extends State<HomePage> {

// Check initial link if app was in cold state (terminated)
final appLink = await _appLinks.getInitialLink();
var initLinked = false;
if (appLink != null) {
await interpretLink(appLink);
initLinked = true;
}

// Handle link when app is in warm state (front or background)
_linkSubscription = _appLinks.uriLinkStream.listen((uri) async {
await interpretLink(uri);
if (!initLinked) {
await interpretLink(uri);
} else {
initLinked = false;
}
});
}

Expand Down
19 changes: 15 additions & 4 deletions lib/providers/apps_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ 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/app_sources/directAPKLink.dart';
import 'package:obtainium/app_sources/html.dart';
import 'package:obtainium/components/generated_form.dart';
import 'package:obtainium/components/generated_form_modal.dart';
import 'package:obtainium/custom_errors.dart';
Expand Down Expand Up @@ -1159,17 +1161,25 @@ class AppsProvider with ChangeNotifier {
if (app?.app == null) {
return false;
}
var source = SourceProvider()
.getSource(app!.app.url, overrideSource: app.app.overrideSource);
var naiveStandardVersionDetection =
app!.app.additionalSettings['naiveStandardVersionDetection'] == true ||
SourceProvider()
.getSource(app.app.url, overrideSource: app.app.overrideSource)
.naiveStandardVersionDetection;
app.app.additionalSettings['naiveStandardVersionDetection'] == true ||
source.naiveStandardVersionDetection;
String? realInstalledVersion =
app.app.additionalSettings['useVersionCodeAsOSVersion'] == true
? app.installedInfo?.versionCode.toString()
: app.installedInfo?.versionName;
bool isHTMLWithNoVersionDetection =
(source.runtimeType == HTML().runtimeType &&
(app.app.additionalSettings['versionExtractionRegEx'] as String?)
?.isNotEmpty !=
true);
bool isDirectAPKLink = source.runtimeType == DirectAPKLink().runtimeType;
return app.app.additionalSettings['trackOnly'] != true &&
app.app.additionalSettings['releaseDateAsVersion'] != true &&
!isHTMLWithNoVersionDetection &&
!isDirectAPKLink &&
realInstalledVersion != null &&
app.app.installedVersion != null &&
(reconcileVersionDifferences(
Expand Down Expand Up @@ -1240,6 +1250,7 @@ class AppsProvider with ChangeNotifier {
!isVersionDetectionPossible(
AppInMemory(app, null, installedInfo, null))) {
app.additionalSettings['versionDetection'] = false;
app.installedVersion = app.latestVersion;
logs.add('Could not reconcile version formats for: ${app.id}');
modded = true;
}
Expand Down
4 changes: 0 additions & 4 deletions lib/providers/source_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ appJSONCompatibilityModifiers(Map<String, dynamic> json) {
additionalSettings['autoApkFilterByArch'] = false;
}
if (source.runtimeType == HTML().runtimeType) {
// HTML 'fixed URL' support should be disabled if it previously did not exist
if (originalAdditionalSettings['supportFixedAPKURL'] == null) {
additionalSettings['supportFixedAPKURL'] = false;
}
// HTML key rename
if (originalAdditionalSettings['sortByFileNamesNotLinks'] != null) {
additionalSettings['sortByLastLinkSegment'] =
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.34+2291
version: 1.1.35+2292

environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down

0 comments on commit 8651f58

Please sign in to comment.