App name overrides more consistent (#450)

This commit is contained in:
Imran Remtulla
2023-04-12 15:36:17 -04:00
parent 0704dfe2ee
commit 7ea75325bb
5 changed files with 26 additions and 22 deletions

View File

@@ -153,7 +153,7 @@ class _AppPageState extends State<AppPage> {
height: 25, height: 25,
), ),
Text( Text(
app?.app.name ?? tr('app'), app?.name ?? tr('app'),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.displayLarge, style: Theme.of(context).textTheme.displayLarge,
), ),
@@ -386,7 +386,7 @@ class _AppPageState extends State<AppPage> {
scrollable: true, scrollable: true,
content: getInfoColumn(), content: getInfoColumn(),
title: Text( title: Text(
'${app.app.name} ${tr('byX', args: [ '${app.name} ${tr('byX', args: [
app.app.author app.app.author
])}'), ])}'),
actions: [ actions: [

View File

@@ -94,8 +94,7 @@ class AppsPageState extends State<AppsPage> {
.toList(); .toList();
for (var t in nameTokens) { for (var t in nameTokens) {
var name = app.installedInfo?.name ?? app.app.name; if (!app.name.toLowerCase().contains(t.toLowerCase())) {
if (!name.toLowerCase().contains(t.toLowerCase())) {
return false; return false;
} }
} }
@@ -120,13 +119,11 @@ class AppsPageState extends State<AppsPage> {
}).toList(); }).toList();
listedApps.sort((a, b) { listedApps.sort((a, b) {
var nameA = a.installedInfo?.name ?? a.app.name;
var nameB = b.installedInfo?.name ?? b.app.name;
int result = 0; int result = 0;
if (settingsProvider.sortColumn == SortColumnSettings.authorName) { if (settingsProvider.sortColumn == SortColumnSettings.authorName) {
result = (a.app.author + nameA).compareTo(b.app.author + nameB); result = (a.app.author + a.name).compareTo(b.app.author + b.name);
} else if (settingsProvider.sortColumn == SortColumnSettings.nameAuthor) { } else if (settingsProvider.sortColumn == SortColumnSettings.nameAuthor) {
result = (nameA + a.app.author).compareTo(nameB + b.app.author); result = (a.name + a.app.author).compareTo(b.name + b.app.author);
} else if (settingsProvider.sortColumn == } else if (settingsProvider.sortColumn ==
SortColumnSettings.releaseDate) { SortColumnSettings.releaseDate) {
result = (a.app.releaseDate)?.compareTo( result = (a.app.releaseDate)?.compareTo(
@@ -481,8 +478,7 @@ class AppsPageState extends State<AppsPage> {
leading: getAppIcon(index), leading: getAppIcon(index),
title: Text( title: Text(
maxLines: 1, maxLines: 1,
listedApps[index].installedInfo?.name ?? listedApps[index].name,
listedApps[index].app.name,
style: TextStyle( style: TextStyle(
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
fontWeight: listedApps[index].app.pinned fontWeight: listedApps[index].app.pinned

View File

@@ -36,6 +36,8 @@ class AppInMemory {
AppInMemory(this.app, this.downloadProgress, this.installedInfo); AppInMemory(this.app, this.downloadProgress, this.installedInfo);
AppInMemory deepCopy() => AppInMemory deepCopy() =>
AppInMemory(app.deepCopy(), downloadProgress, installedInfo); AppInMemory(app.deepCopy(), downloadProgress, installedInfo);
String get name => app.overrideName ?? installedInfo?.name ?? app.finalName;
} }
class DownloadedApk { class DownloadedApk {
@@ -163,7 +165,7 @@ class AppsProvider with ChangeNotifier {
Future<DownloadedApk> downloadApp(App app, BuildContext? context) async { Future<DownloadedApk> downloadApp(App app, BuildContext? context) async {
NotificationsProvider? notificationsProvider = NotificationsProvider? notificationsProvider =
context?.read<NotificationsProvider>(); context?.read<NotificationsProvider>();
var notifId = DownloadNotification(app.name, 0).id; var notifId = DownloadNotification(app.finalName, 0).id;
if (apps[app.id] != null) { if (apps[app.id] != null) {
apps[app.id]!.downloadProgress = 0; apps[app.id]!.downloadProgress = 0;
notifyListeners(); notifyListeners();
@@ -173,7 +175,7 @@ class AppsProvider with ChangeNotifier {
.getSource(app.url) .getSource(app.url)
.apkUrlPrefetchModifier(app.apkUrls[app.preferredApkIndex].value); .apkUrlPrefetchModifier(app.apkUrls[app.preferredApkIndex].value);
var fileName = '${app.id}-${downloadUrl.hashCode}.apk'; var fileName = '${app.id}-${downloadUrl.hashCode}.apk';
var notif = DownloadNotification(app.name, 100); var notif = DownloadNotification(app.finalName, 100);
notificationsProvider?.cancel(notif.id); notificationsProvider?.cancel(notif.id);
int? prevProg; int? prevProg;
File downloadedFile = File downloadedFile =
@@ -183,7 +185,7 @@ class AppsProvider with ChangeNotifier {
apps[app.id]!.downloadProgress = progress; apps[app.id]!.downloadProgress = progress;
notifyListeners(); notifyListeners();
} }
notif = DownloadNotification(app.name, prog ?? 100); notif = DownloadNotification(app.finalName, prog ?? 100);
if (prog != null && prevProg != prog) { if (prog != null && prevProg != prog) {
notificationsProvider?.notify(notif); notificationsProvider?.notify(notif);
} }
@@ -641,7 +643,7 @@ class AppsProvider with ChangeNotifier {
sp.getSource(newApps[i].url); sp.getSource(newApps[i].url);
apps[newApps[i].id] = AppInMemory(newApps[i], null, info); apps[newApps[i].id] = AppInMemory(newApps[i], null, info);
} catch (e) { } catch (e) {
errors.add([newApps[i].id, newApps[i].name, e.toString()]); errors.add([newApps[i].id, newApps[i].finalName, e.toString()]);
} }
} }
if (errors.isNotEmpty) { if (errors.isNotEmpty) {
@@ -675,9 +677,6 @@ class AppsProvider with ChangeNotifier {
var app = a.deepCopy(); var app = a.deepCopy();
AppInfo? info = await getInstalledInfo(app.id); AppInfo? info = await getInstalledInfo(app.id);
app.name = info?.name ?? app.name; app.name = info?.name ?? app.name;
if (app.additionalSettings['appName']?.toString().isNotEmpty == true) {
app.name = app.additionalSettings['appName'].toString().trim();
}
if (attemptToCorrectInstallStatus) { if (attemptToCorrectInstallStatus) {
app = getCorrectedInstallStatusAppIfPossible(app, info) ?? app; app = getCorrectedInstallStatusAppIfPossible(app, info) ?? app;
} }
@@ -945,7 +944,7 @@ class _APKPickerState extends State<APKPicker> {
scrollable: true, scrollable: true,
title: Text(tr('pickAnAPK')), title: Text(tr('pickAnAPK')),
content: Column(children: [ content: Column(children: [
Text(tr('appHasMoreThanOnePackage', args: [widget.app.name])), Text(tr('appHasMoreThanOnePackage', args: [widget.app.finalName])),
const SizedBox(height: 16), const SizedBox(height: 16),
...widget.app.apkUrls.map( ...widget.app.apkUrls.map(
(u) => RadioListTile<String>( (u) => RadioListTile<String>(

View File

@@ -34,9 +34,9 @@ class UpdateNotification extends ObtainiumNotification {
message = updates.isEmpty message = updates.isEmpty
? tr('noNewUpdates') ? tr('noNewUpdates')
: updates.length == 1 : updates.length == 1
? tr('xHasAnUpdate', args: [updates[0].name]) ? tr('xHasAnUpdate', args: [updates[0].finalName])
: plural('xAndNMoreUpdatesAvailable', updates.length - 1, : plural('xAndNMoreUpdatesAvailable', updates.length - 1,
args: [updates[0].name, (updates.length - 1).toString()]); args: [updates[0].finalName, (updates.length - 1).toString()]);
} }
} }
@@ -46,9 +46,9 @@ class SilentUpdateNotification extends ObtainiumNotification {
tr('appsUpdatedNotifDescription'), Importance.defaultImportance) { tr('appsUpdatedNotifDescription'), Importance.defaultImportance) {
message = updates.length == 1 message = updates.length == 1
? tr('xWasUpdatedToY', ? tr('xWasUpdatedToY',
args: [updates[0].name, updates[0].latestVersion]) args: [updates[0].finalName, updates[0].latestVersion])
: plural('xAndNMoreUpdatesInstalled', updates.length - 1, : plural('xAndNMoreUpdatesInstalled', updates.length - 1,
args: [updates[0].name, (updates.length - 1).toString()]); args: [updates[0].finalName, (updates.length - 1).toString()]);
} }
} }

View File

@@ -80,6 +80,15 @@ class App {
return 'ID: $id URL: $url INSTALLED: $installedVersion LATEST: $latestVersion APK: $apkUrls PREFERREDAPK: $preferredApkIndex ADDITIONALSETTINGS: ${additionalSettings.toString()} LASTCHECK: ${lastUpdateCheck.toString()} PINNED $pinned'; return 'ID: $id URL: $url INSTALLED: $installedVersion LATEST: $latestVersion APK: $apkUrls PREFERREDAPK: $preferredApkIndex ADDITIONALSETTINGS: ${additionalSettings.toString()} LASTCHECK: ${lastUpdateCheck.toString()} PINNED $pinned';
} }
String? get overrideName =>
additionalSettings['appName']?.toString().trim().isNotEmpty == true
? additionalSettings['appName']
: null;
String get finalName {
return overrideName ?? name;
}
App deepCopy() => App( App deepCopy() => App(
id, id,
url, url,