Open changelog inside App for supported Sources (#82)

This commit is contained in:
Imran Remtulla
2023-03-18 23:53:42 -04:00
parent bd0e322465
commit ef06ae289e
14 changed files with 100 additions and 69 deletions

View File

@ -118,9 +118,11 @@ class Codeberg extends AppSource {
if (version == null) {
throw NoVersionError();
}
var changeLog = targetRelease['body'].toString();
return APKDetails(version, targetRelease['apkUrls'] as List<String>,
getAppNames(standardUrl),
releaseDate: releaseDate);
releaseDate: releaseDate,
changeLog: changeLog.isEmpty ? null : changeLog);
} else {
throw getObtainiumHttpError(res);
}

View File

@ -27,9 +27,6 @@ class FDroid extends AppSource {
return url.substring(0, match.end);
}
@override
String? changeLogPageFromStandardUrl(String standardUrl) => null;
@override
String? tryInferringAppId(String standardUrl,
{Map<String, dynamic> additionalSettings = const {}}) {

View File

@ -160,9 +160,11 @@ class GitHub extends AppSource {
if (version == null) {
throw NoVersionError();
}
var changeLog = targetRelease['body'].toString();
return APKDetails(version, targetRelease['apkUrls'] as List<String>,
getAppNames(standardUrl),
releaseDate: releaseDate);
releaseDate: releaseDate,
changeLog: changeLog.isEmpty ? null : changeLog);
} else {
rateLimitErrorCheck(res);
throw getObtainiumHttpError(res);

View File

@ -10,9 +10,6 @@ class HTML extends AppSource {
return url;
}
@override
String? changeLogPageFromStandardUrl(String standardUrl) => null;
@override
Future<APKDetails> getLatestAPKDetails(
String standardUrl,

View File

@ -18,9 +18,6 @@ class IzzyOnDroid extends AppSource {
return url.substring(0, match.end);
}
@override
String? changeLogPageFromStandardUrl(String standardUrl) => null;
@override
String? tryInferringAppId(String standardUrl,
{Map<String, dynamic> additionalSettings = const {}}) {

View File

@ -97,10 +97,13 @@ class NeutronCode extends AppSource {
var dateString = dateStringOriginal != null
? (customDateParse(dateStringOriginal))
: null;
var changeLogElements = http.querySelectorAll('.pd-fdesc p');
return APKDetails(version, [apkUrl],
AppNames(runtimeType.toString(), name ?? standardUrl.split('/').last),
releaseDate: dateString != null ? DateTime.parse(dateString) : null);
releaseDate: dateString != null ? DateTime.parse(dateString) : null,
changeLog: changeLogElements.isNotEmpty
? changeLogElements.last.innerHtml
: null);
} else {
throw getObtainiumHttpError(res);
}

View File

@ -13,9 +13,6 @@ class Signal extends AppSource {
return 'https://$host';
}
@override
String? changeLogPageFromStandardUrl(String standardUrl) => null;
@override
Future<APKDetails> getLatestAPKDetails(
String standardUrl,

View File

@ -18,9 +18,6 @@ class SourceForge extends AppSource {
return url.substring(0, match.end);
}
@override
String? changeLogPageFromStandardUrl(String standardUrl) => null;
@override
Future<APKDetails> getLatestAPKDetails(
String standardUrl,

View File

@ -24,9 +24,6 @@ class SteamMobile extends AppSource {
return 'https://$host';
}
@override
String? changeLogPageFromStandardUrl(String standardUrl) => null;
@override
Future<APKDetails> getLatestAPKDetails(
String standardUrl,

View File

@ -15,9 +15,6 @@ class TelegramApp extends AppSource {
return 'https://$host';
}
@override
String? changeLogPageFromStandardUrl(String standardUrl) => null;
@override
Future<APKDetails> getLatestAPKDetails(
String standardUrl,

View File

@ -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.10';
const String currentVersion = '0.11.11';
const String currentReleaseTag =
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES

View File

@ -232,6 +232,49 @@ class AppsPageState extends State<AppsPage> {
String? changesUrl = SourceProvider()
.getSource(listedApps[index].app.url)
.changeLogPageFromStandardUrl(listedApps[index].app.url);
String? changeLog = listedApps[index].app.changeLog;
var showChanges = (changeLog == null && changesUrl == null)
? null
: () {
if (changeLog != null) {
showDialog(
context: context,
builder: (BuildContext context) {
return GeneratedFormModal(
title: tr('changes'),
items: [],
additionalWidgets: [
Text(changeLog),
changesUrl != null
? const SizedBox(
height: 16,
)
: const SizedBox.shrink(),
changesUrl != null
? GestureDetector(
child: Text(
changesUrl,
style: const TextStyle(
decoration:
TextDecoration.underline,
fontStyle: FontStyle.italic),
),
onTap: () {
launchUrlString(changesUrl,
mode: LaunchMode
.externalApplication);
},
)
: const SizedBox.shrink()
],
singleNullReturnButton: tr('ok'),
);
});
} else {
launchUrlString(changesUrl!,
mode: LaunchMode.externalApplication);
}
};
var transparent = const Color.fromARGB(0, 0, 0, 0).value;
var hasUpdate = listedApps[index].app.installedVersion != null &&
listedApps[index].app.installedVersion !=
@ -366,13 +409,7 @@ class AppsPageState extends State<AppsPage> {
mainAxisSize: MainAxisSize.min,
children: [
GestureDetector(
onTap: changesUrl == null
? null
: () {
launchUrlString(changesUrl,
mode: LaunchMode
.externalApplication);
},
onTap: showChanges,
child: Text(
listedApps[index].app.releaseDate ==
null
@ -381,10 +418,11 @@ class AppsPageState extends State<AppsPage> {
.format(listedApps[index]
.app
.releaseDate!),
style: const TextStyle(
style: TextStyle(
fontStyle: FontStyle.italic,
decoration:
TextDecoration.underline),
decoration: showChanges != null
? TextDecoration.underline
: TextDecoration.none),
))
],
),

View File

@ -36,8 +36,10 @@ class APKDetails {
late List<String> apkUrls;
late AppNames names;
late DateTime? releaseDate;
late String? changeLog;
APKDetails(this.version, this.apkUrls, this.names, {this.releaseDate});
APKDetails(this.version, this.apkUrls, this.names,
{this.releaseDate, this.changeLog});
}
class App {
@ -54,6 +56,7 @@ class App {
bool pinned = false;
List<String> categories;
late DateTime? releaseDate;
late String? changeLog;
App(
this.id,
this.url,
@ -67,7 +70,8 @@ class App {
this.lastUpdateCheck,
this.pinned,
{this.categories = const [],
this.releaseDate});
this.releaseDate,
this.changeLog});
@override
String toString() {
@ -157,7 +161,8 @@ class App {
releaseDate: json['releaseDate'] == null
? null
: DateTime.fromMicrosecondsSinceEpoch(json['releaseDate']),
);
changeLog:
json['changeLog'] == null ? null : json['changeLog'] as String);
}
Map<String, dynamic> toJson() => {
@ -173,7 +178,8 @@ class App {
'lastUpdateCheck': lastUpdateCheck?.microsecondsSinceEpoch,
'pinned': pinned,
'categories': categories,
'releaseDate': releaseDate?.microsecondsSinceEpoch
'releaseDate': releaseDate?.microsecondsSinceEpoch,
'changeLog': changeLog
};
}
@ -437,7 +443,8 @@ class SourceProvider {
DateTime.now(),
currentApp?.pinned ?? false,
categories: currentApp?.categories ?? const [],
releaseDate: apk.releaseDate);
releaseDate: apk.releaseDate,
changeLog: apk.changeLog);
}
// Returns errors in [results, errors] instead of throwing them

View File

@ -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.10+131 # When changing this, update the tag in main() accordingly
version: 0.11.11+132 # When changing this, update the tag in main() accordingly
environment:
sdk: '>=2.18.2 <3.0.0'