Initial release date support

This commit is contained in:
Imran Remtulla
2023-02-18 20:37:30 -05:00
parent ea81b0e66e
commit 191776d0d5
12 changed files with 209 additions and 66 deletions

View File

@@ -213,6 +213,9 @@
"removeFromObtainium": "Remove from Obtainium",
"uninstallFromDevice": "Uninstall from Device",
"onlyWorksWithNonVersionDetectApps": "Only works for Apps with version detection disabled.",
"useReleaseDateAsVersion": "Use Release Date as Version",
"releaseDateAsVersionExplanation": "This option should only be used for Apps where version detection does not work correctly, but a release date is available.",
"changes": "Changes",
"removeAppQuestion": {
"one": "App entfernen?",
"other": "App entfernen?"

View File

@@ -213,6 +213,9 @@
"removeFromObtainium": "Remove from Obtainium",
"uninstallFromDevice": "Uninstall from Device",
"onlyWorksWithNonVersionDetectApps": "Only works for Apps with version detection disabled.",
"useReleaseDateAsVersion": "Use Release Date as Version",
"releaseDateAsVersionExplanation": "This option should only be used for Apps where version detection does not work correctly, but a release date is available.",
"changes": "Changes",
"removeAppQuestion": {
"one": "Remove App?",
"other": "Remove Apps?"

View File

@@ -213,6 +213,9 @@
"removeFromObtainium": "از Obtainium حذف کنید",
"uninstallFromDevice": "حذف نصب از دستگاه",
"onlyWorksWithNonVersionDetectApps": "فقط برای برنامه‌هایی کار می‌کند که تشخیص نسخه غیرفعال است.",
"useReleaseDateAsVersion": "Use Release Date as Version",
"releaseDateAsVersionExplanation": "This option should only be used for Apps where version detection does not work correctly, but a release date is available.",
"changes": "Changes",
"removeAppQuestion": {
"one": "برنامه حذف شود؟",
"other": "برنامه ها حذف شوند؟"

View File

@@ -212,6 +212,9 @@
"removeFromObtainium": "Eltávolítás az Obtainiumból",
"uninstallFromDevice": "Eltávolítás a készülékről",
"onlyWorksWithNonVersionDetectApps": "Csak azoknál az alkalmazásoknál működik, amelyeknél a verzióérzékelés le van tiltva.",
"useReleaseDateAsVersion": "Use Release Date as Version",
"releaseDateAsVersionExplanation": "This option should only be used for Apps where version detection does not work correctly, but a release date is available.",
"changes": "Changes",
"removeAppQuestion": {
"one": "Eltávolítja az alkalmazást?",
"other": "Eltávolítja az alkalmazást?"

View File

@@ -213,6 +213,9 @@
"removeFromObtainium": "Rimuovi da Obtainium",
"uninstallFromDevice": "Disinstalla dal dispositivo",
"onlyWorksWithNonVersionDetectApps": "Funziona solo per le App con il rilevamento della versione disattivato.",
"useReleaseDateAsVersion": "Use Release Date as Version",
"releaseDateAsVersionExplanation": "This option should only be used for Apps where version detection does not work correctly, but a release date is available.",
"changes": "Changes",
"removeAppQuestion": {
"one": "Rimuovere l'App?",
"other": "Rimuovere le App?"

View File

@@ -213,6 +213,9 @@
"removeFromObtainium": "Obtainiumから削除する",
"uninstallFromDevice": "デバイスからアンインストールする",
"onlyWorksWithNonVersionDetectApps": "バージョン検出を無効にしているアプリにのみ動作します。",
"useReleaseDateAsVersion": "Use Release Date as Version",
"releaseDateAsVersionExplanation": "This option should only be used for Apps where version detection does not work correctly, but a release date is available.",
"changes": "Changes",
"removeAppQuestion": {
"one": "アプリを削除しますか?",
"other": "アプリを削除しますか?"

View File

@@ -213,6 +213,9 @@
"filterAPKsByRegEx": "Filter APKs by Regular Expression",
"removeFromObtainium": "Remove from Obtainium",
"uninstallFromDevice": "Uninstall from Device",
"useReleaseDateAsVersion": "Use Release Date as Version",
"releaseDateAsVersionExplanation": "This option should only be used for Apps where version detection does not work correctly, but a release date is available.",
"changes": "Changes",
"removeAppQuestion": {
"one": "删除应用?",
"other": "删除应用?"

View File

@@ -154,11 +154,15 @@ class GitHub extends AppSource {
throw NoReleasesError();
}
String? version = targetRelease['tag_name'];
DateTime? releaseDate = targetRelease['published_at'] != null
? DateTime.parse(targetRelease['published_at'])
: null;
if (version == null) {
throw NoVersionError();
}
return APKDetails(version, targetRelease['apkUrls'] as List<String>,
getAppNames(standardUrl));
getAppNames(standardUrl),
releaseDate: releaseDate);
} else {
rateLimitErrorCheck(res);
throw getObtainiumHttpError(res);

View File

@@ -73,6 +73,8 @@ class _AddAppPageState extends State<AddAppPage> {
var userPickedTrackOnly = additionalSettings['trackOnly'] == true;
var userPickedNoVersionDetection =
additionalSettings['noVersionDetection'] == true;
var userPickedReleaseDateAsVersion =
additionalSettings['releaseDateAsVersion'] == true;
var cont = true;
if ((userPickedTrackOnly || pickedSource!.enforceTrackOnly) &&
// ignore: use_build_context_synchronously
@@ -93,7 +95,22 @@ class _AddAppPageState extends State<AddAppPage> {
null) {
cont = false;
}
if (userPickedNoVersionDetection &&
if (userPickedReleaseDateAsVersion && // ignore: use_build_context_synchronously
// ignore: use_build_context_synchronously
await showDialog(
context: context,
builder: (BuildContext ctx) {
return GeneratedFormModal(
title: tr('useReleaseDateAsVersion'),
items: const [],
message: tr('releaseDateAsVersionExplanation'),
);
}) ==
null) {
cont = false;
}
if (!userPickedReleaseDateAsVersion &&
userPickedNoVersionDetection &&
// ignore: use_build_context_synchronously
await showDialog(
context: context,
@@ -113,7 +130,8 @@ class _AddAppPageState extends State<AddAppPage> {
App app = await sourceProvider.getApp(
pickedSource!, userInput, additionalSettings,
trackOnlyOverride: trackOnly,
noVersionDetectionOverride: userPickedNoVersionDetection);
noVersionDetectionOverride: userPickedNoVersionDetection,
releaseDateAsVersionOverride: userPickedReleaseDateAsVersion);
if (!trackOnly) {
await settingsProvider.getInstallPermission();
}

View File

@@ -144,6 +144,13 @@ class _AppPageState extends State<AppPage> {
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.labelSmall,
),
app?.app.releaseDate == null
? const SizedBox.shrink()
: Text(
app!.app.releaseDate.toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.labelSmall,
),
const SizedBox(
height: 32,
),
@@ -286,6 +293,37 @@ class _AppPageState extends State<AppPage> {
tr('appsFromSourceAreTrackOnly'),
context);
}
if (changedApp.additionalSettings[
'releaseDateAsVersion'] ==
true) {
changedApp.additionalSettings[
'noVersionDetection'] = true;
if (app.app.additionalSettings[
'releaseDateAsVersion'] !=
true) {
if (app.app.releaseDate != null) {
changedApp.latestVersion = app
.app
.releaseDate!
.microsecondsSinceEpoch
.toString();
if (app.app.installedVersion ==
app.app.latestVersion) {
changedApp.installedVersion =
changedApp.latestVersion;
}
}
}
} else if (app.app.additionalSettings[
'releaseDateAsVersion'] ==
true) {
changedApp.additionalSettings[
'noVersionDetection'] = false;
changedApp.installedVersion = app
.installedInfo
?.versionName ??
changedApp.installedVersion;
}
appsProvider.saveApps(
[changedApp]).then((value) {
getUpdate(changedApp.id);

View File

@@ -264,6 +264,7 @@ class AppsPageState extends State<AppsPage> {
sortedApps[index].installedInfo?.name ??
sortedApps[index].app.name,
style: TextStyle(
overflow: TextOverflow.ellipsis,
fontWeight: sortedApps[index].app.pinned
? FontWeight.bold
: FontWeight.normal,
@@ -289,12 +290,35 @@ class AppsPageState extends State<AppsPage> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
SizedBox(
width: 100,
child: Text(
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'${sortedApps[index].app.installedVersion ?? tr('notInstalled')}${sortedApps[index].app.additionalSettings['trackOnly'] == true ? ' ${tr('estimateInBrackets')}' : ''}',
overflow: TextOverflow.fade,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.end,
)
]),
GestureDetector(
onTap: changesUrl == null
? null
: () {
launchUrlString(changesUrl,
mode: LaunchMode
.externalApplication);
},
child: Text(
sortedApps[index].app.releaseDate ==
null
? tr('changes')
: DateFormat('yyyy-MM-dd').format(
sortedApps[index]
.app
.releaseDate!),
style: const TextStyle(
fontStyle: FontStyle.italic,
decoration:
TextDecoration.underline),
)),
sortedApps[index].app.installedVersion !=
null &&
@@ -304,29 +328,47 @@ class AppsPageState extends State<AppsPage> {
sortedApps[index]
.app
.latestVersion
? GestureDetector(
onTap: changesUrl == null
? null
: () {
launchUrlString(changesUrl,
mode: LaunchMode
.externalApplication);
},
child: appsProvider
.areDownloadsRunning()
? appsProvider.areDownloadsRunning()
? Text(tr('pleaseWait'))
: Text(
'${tr('updateAvailable')}${sortedApps[index].app.additionalSettings['trackOnly'] == true ? ' ${tr('estimateInBracketsShort')}' : ''}',
: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.end,
children: [
GestureDetector(
onTap: () {
appsProvider
.downloadAndInstallLatestApps(
[
sortedApps[index]
.app
.id
],
globalNavigatorKey
.currentContext).catchError(
(e) {
showError(e, context);
});
},
child: Text(
sortedApps[index]
.app
.additionalSettings[
'trackOnly'] ==
true
? tr('markUpdated')
: tr('update'),
style: TextStyle(
fontStyle:
FontStyle.italic,
decoration: changesUrl ==
null
? TextDecoration.none
: TextDecoration
.underline),
))
: const SizedBox(),
color:
Theme.of(context)
.colorScheme
.primary,
fontWeight:
FontWeight.bold),
)),
],
)
: const SizedBox.shrink(),
],
))),
onTap: () {

View File

@@ -33,8 +33,9 @@ class APKDetails {
late String version;
late List<String> apkUrls;
late AppNames names;
late DateTime? releaseDate;
APKDetails(this.version, this.apkUrls, this.names);
APKDetails(this.version, this.apkUrls, this.names, {this.releaseDate});
}
class App {
@@ -50,6 +51,7 @@ class App {
late DateTime? lastUpdateCheck;
bool pinned = false;
List<String> categories;
late DateTime? releaseDate;
App(
this.id,
this.url,
@@ -62,7 +64,8 @@ class App {
this.additionalSettings,
this.lastUpdateCheck,
this.pinned,
{this.categories = const []});
{this.categories = const [],
this.releaseDate});
@override
String toString() {
@@ -134,7 +137,11 @@ class App {
.toList()
: json['category'] != null
? [json['category'] as String]
: []);
: [],
releaseDate: json['releaseDate'] == null
? null
: DateTime.fromMicrosecondsSinceEpoch(json['releaseDate']),
);
}
Map<String, dynamic> toJson() => {
@@ -149,7 +156,8 @@ class App {
'additionalSettings': jsonEncode(additionalSettings),
'lastUpdateCheck': lastUpdateCheck?.microsecondsSinceEpoch,
'pinned': pinned,
'categories': categories
'categories': categories,
'releaseDate': releaseDate?.microsecondsSinceEpoch
};
}
@@ -225,6 +233,10 @@ class AppSource {
label: tr('trackOnly'),
)
],
[
GeneratedFormSwitch('releaseDateAsVersion',
label: tr('useReleaseDateAsVersion'))
],
[
GeneratedFormSwitch('noVersionDetection', label: tr('noVersionDetection'))
],
@@ -359,16 +371,19 @@ class SourceProvider {
}
Future<App> getApp(
AppSource source,
String url,
Map<String, dynamic> additionalSettings, {
App? currentApp,
AppSource source, String url, Map<String, dynamic> additionalSettings,
{App? currentApp,
bool trackOnlyOverride = false,
noVersionDetectionOverride = false,
}) async {
bool noVersionDetectionOverride = false,
bool releaseDateAsVersionOverride = false}) async {
if (trackOnlyOverride || source.enforceTrackOnly) {
additionalSettings['trackOnly'] = true;
}
if (releaseDateAsVersionOverride) {
additionalSettings['releaseDateAsVersion'] = true;
noVersionDetectionOverride =
true; // Rel. date as version means no ver. det.
}
if (noVersionDetectionOverride) {
additionalSettings['noVersionDetection'] = true;
}
@@ -376,6 +391,10 @@ class SourceProvider {
String standardUrl = source.standardizeURL(preStandardizeUrl(url));
APKDetails apk =
await source.getLatestAPKDetails(standardUrl, additionalSettings);
if (additionalSettings['releaseDateAsVersion'] == true &&
apk.releaseDate != null) {
apk.version = apk.releaseDate!.microsecondsSinceEpoch.toString();
}
if (additionalSettings['apkFilterRegEx'] != null) {
var reg = RegExp(additionalSettings['apkFilterRegEx']);
apk.apkUrls =
@@ -404,7 +423,8 @@ class SourceProvider {
additionalSettings,
DateTime.now(),
currentApp?.pinned ?? false,
categories: currentApp?.categories ?? const []);
categories: currentApp?.categories ?? const [],
releaseDate: apk.releaseDate);
}
// Returns errors in [results, errors] instead of throwing them