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) { if (version == null) {
throw NoVersionError(); throw NoVersionError();
} }
var changeLog = targetRelease['body'].toString();
return APKDetails(version, targetRelease['apkUrls'] as List<String>, return APKDetails(version, targetRelease['apkUrls'] as List<String>,
getAppNames(standardUrl), getAppNames(standardUrl),
releaseDate: releaseDate); releaseDate: releaseDate,
changeLog: changeLog.isEmpty ? null : changeLog);
} else { } else {
throw getObtainiumHttpError(res); throw getObtainiumHttpError(res);
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -97,10 +97,13 @@ class NeutronCode extends AppSource {
var dateString = dateStringOriginal != null var dateString = dateStringOriginal != null
? (customDateParse(dateStringOriginal)) ? (customDateParse(dateStringOriginal))
: null; : null;
var changeLogElements = http.querySelectorAll('.pd-fdesc p');
return APKDetails(version, [apkUrl], return APKDetails(version, [apkUrl],
AppNames(runtimeType.toString(), name ?? standardUrl.split('/').last), 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 { } else {
throw getObtainiumHttpError(res); throw getObtainiumHttpError(res);
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart';
// ignore: implementation_imports // ignore: implementation_imports
import 'package:easy_localization/src/localization.dart'; import 'package:easy_localization/src/localization.dart';
const String currentVersion = '0.11.10'; const String currentVersion = '0.11.11';
const String currentReleaseTag = const String currentReleaseTag =
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES

View File

@@ -232,6 +232,49 @@ class AppsPageState extends State<AppsPage> {
String? changesUrl = SourceProvider() String? changesUrl = SourceProvider()
.getSource(listedApps[index].app.url) .getSource(listedApps[index].app.url)
.changeLogPageFromStandardUrl(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 transparent = const Color.fromARGB(0, 0, 0, 0).value;
var hasUpdate = listedApps[index].app.installedVersion != null && var hasUpdate = listedApps[index].app.installedVersion != null &&
listedApps[index].app.installedVersion != listedApps[index].app.installedVersion !=
@@ -366,13 +409,7 @@ class AppsPageState extends State<AppsPage> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
GestureDetector( GestureDetector(
onTap: changesUrl == null onTap: showChanges,
? null
: () {
launchUrlString(changesUrl,
mode: LaunchMode
.externalApplication);
},
child: Text( child: Text(
listedApps[index].app.releaseDate == listedApps[index].app.releaseDate ==
null null
@@ -381,10 +418,11 @@ class AppsPageState extends State<AppsPage> {
.format(listedApps[index] .format(listedApps[index]
.app .app
.releaseDate!), .releaseDate!),
style: const TextStyle( style: TextStyle(
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
decoration: decoration: showChanges != null
TextDecoration.underline), ? TextDecoration.underline
: TextDecoration.none),
)) ))
], ],
), ),

View File

@@ -36,8 +36,10 @@ class APKDetails {
late List<String> apkUrls; late List<String> apkUrls;
late AppNames names; late AppNames names;
late DateTime? releaseDate; 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 { class App {
@@ -54,6 +56,7 @@ class App {
bool pinned = false; bool pinned = false;
List<String> categories; List<String> categories;
late DateTime? releaseDate; late DateTime? releaseDate;
late String? changeLog;
App( App(
this.id, this.id,
this.url, this.url,
@@ -67,7 +70,8 @@ class App {
this.lastUpdateCheck, this.lastUpdateCheck,
this.pinned, this.pinned,
{this.categories = const [], {this.categories = const [],
this.releaseDate}); this.releaseDate,
this.changeLog});
@override @override
String toString() { String toString() {
@@ -130,34 +134,35 @@ class App {
preferredApkIndex = 0; preferredApkIndex = 0;
} }
return App( return App(
json['id'] as String, json['id'] as String,
json['url'] as String, json['url'] as String,
json['author'] as String, json['author'] as String,
json['name'] as String, json['name'] as String,
json['installedVersion'] == null json['installedVersion'] == null
? null ? null
: json['installedVersion'] as String, : json['installedVersion'] as String,
json['latestVersion'] as String, json['latestVersion'] as String,
json['apkUrls'] == null json['apkUrls'] == null
? [] ? []
: List<String>.from(jsonDecode(json['apkUrls'])), : List<String>.from(jsonDecode(json['apkUrls'])),
preferredApkIndex, preferredApkIndex,
additionalSettings, additionalSettings,
json['lastUpdateCheck'] == null json['lastUpdateCheck'] == null
? null ? null
: DateTime.fromMicrosecondsSinceEpoch(json['lastUpdateCheck']), : DateTime.fromMicrosecondsSinceEpoch(json['lastUpdateCheck']),
json['pinned'] ?? false, json['pinned'] ?? false,
categories: json['categories'] != null categories: json['categories'] != null
? (json['categories'] as List<dynamic>) ? (json['categories'] as List<dynamic>)
.map((e) => e.toString()) .map((e) => e.toString())
.toList() .toList()
: json['category'] != null : json['category'] != null
? [json['category'] as String] ? [json['category'] as String]
: [], : [],
releaseDate: json['releaseDate'] == null releaseDate: json['releaseDate'] == null
? null ? null
: DateTime.fromMicrosecondsSinceEpoch(json['releaseDate']), : DateTime.fromMicrosecondsSinceEpoch(json['releaseDate']),
); changeLog:
json['changeLog'] == null ? null : json['changeLog'] as String);
} }
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
@@ -173,7 +178,8 @@ class App {
'lastUpdateCheck': lastUpdateCheck?.microsecondsSinceEpoch, 'lastUpdateCheck': lastUpdateCheck?.microsecondsSinceEpoch,
'pinned': pinned, 'pinned': pinned,
'categories': categories, 'categories': categories,
'releaseDate': releaseDate?.microsecondsSinceEpoch 'releaseDate': releaseDate?.microsecondsSinceEpoch,
'changeLog': changeLog
}; };
} }
@@ -437,7 +443,8 @@ class SourceProvider {
DateTime.now(), DateTime.now(),
currentApp?.pinned ?? false, currentApp?.pinned ?? false,
categories: currentApp?.categories ?? const [], categories: currentApp?.categories ?? const [],
releaseDate: apk.releaseDate); releaseDate: apk.releaseDate,
changeLog: apk.changeLog);
} }
// Returns errors in [results, errors] instead of throwing them // 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 # 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 # 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. # 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: environment:
sdk: '>=2.18.2 <3.0.0' sdk: '>=2.18.2 <3.0.0'