Lint all files

This commit is contained in:
Imran Remtulla
2025-06-13 16:53:36 -04:00
parent 5f971dcddb
commit e0c69b9cf4
42 changed files with 6864 additions and 5334 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -22,7 +22,7 @@ class Log {
idColumn: id,
levelColumn: level.index,
messageColumn: message,
timestampColumn: timestamp.millisecondsSinceEpoch
timestampColumn: timestamp.millisecondsSinceEpoch,
};
return map;
}
@@ -33,8 +33,9 @@ class Log {
id = map[idColumn] as int;
level = LogLevels.values.elementAt(map[levelColumn] as int);
message = map[messageColumn] as String;
timestamp =
DateTime.fromMillisecondsSinceEpoch(map[timestampColumn] as int);
timestamp = DateTime.fromMillisecondsSinceEpoch(
map[timestampColumn] as int,
);
}
@override
@@ -51,16 +52,19 @@ class LogsProvider {
Database? db;
Future<Database> getDB() async {
db ??= await openDatabase(dbPath, version: 1,
onCreate: (Database db, int version) async {
await db.execute('''
db ??= await openDatabase(
dbPath,
version: 1,
onCreate: (Database db, int version) async {
await db.execute('''
create table if not exists $logTable (
$idColumn integer primary key autoincrement,
$levelColumn integer not null,
$messageColumn text not null,
$timestampColumn integer not null)
''');
});
},
);
return db!;
}
@@ -75,27 +79,38 @@ create table if not exists $logTable (
Future<List<Log>> get({DateTime? before, DateTime? after}) async {
var where = getWhereDates(before: before, after: after);
return (await (await getDB())
.query(logTable, where: where.key, whereArgs: where.value))
.map((e) => Log.fromMap(e))
.toList();
return (await (await getDB()).query(
logTable,
where: where.key,
whereArgs: where.value,
)).map((e) => Log.fromMap(e)).toList();
}
Future<int> clear({DateTime? before, DateTime? after}) async {
var where = getWhereDates(before: before, after: after);
var res = await (await getDB())
.delete(logTable, where: where.key, whereArgs: where.value);
var res = await (await getDB()).delete(
logTable,
where: where.key,
whereArgs: where.value,
);
if (res > 0) {
add(plural('clearedNLogsBeforeXAfterY', res,
add(
plural(
'clearedNLogsBeforeXAfterY',
res,
namedArgs: {'before': before.toString(), 'after': after.toString()},
name: 'n'));
name: 'n',
),
);
}
return res;
}
}
MapEntry<String?, List<int>?> getWhereDates(
{DateTime? before, DateTime? after}) {
MapEntry<String?, List<int>?> getWhereDates({
DateTime? before,
DateTime? after,
}) {
List<String> where = [];
List<int> whereArgs = [];
if (before != null) {

View File

@@ -20,91 +20,116 @@ class ObtainiumNotification {
bool onlyAlertOnce;
String? payload;
ObtainiumNotification(this.id, this.title, this.message, this.channelCode,
this.channelName, this.channelDescription, this.importance,
{this.onlyAlertOnce = false, this.progPercent, this.payload});
ObtainiumNotification(
this.id,
this.title,
this.message,
this.channelCode,
this.channelName,
this.channelDescription,
this.importance, {
this.onlyAlertOnce = false,
this.progPercent,
this.payload,
});
}
class UpdateNotification extends ObtainiumNotification {
UpdateNotification(List<App> updates, {int? id})
: super(
id ?? 2,
tr('updatesAvailable'),
'',
'UPDATES_AVAILABLE',
tr('updatesAvailableNotifChannel'),
tr('updatesAvailableNotifDescription'),
Importance.max) {
: super(
id ?? 2,
tr('updatesAvailable'),
'',
'UPDATES_AVAILABLE',
tr('updatesAvailableNotifChannel'),
tr('updatesAvailableNotifDescription'),
Importance.max,
) {
message = updates.isEmpty
? tr('noNewUpdates')
: updates.length == 1
? tr('xHasAnUpdate', args: [updates[0].finalName])
: plural('xAndNMoreUpdatesAvailable', updates.length - 1,
args: [updates[0].finalName, (updates.length - 1).toString()]);
? tr('xHasAnUpdate', args: [updates[0].finalName])
: plural(
'xAndNMoreUpdatesAvailable',
updates.length - 1,
args: [updates[0].finalName, (updates.length - 1).toString()],
);
}
}
class SilentUpdateNotification extends ObtainiumNotification {
SilentUpdateNotification(List<App> updates, bool succeeded, {int? id})
: super(
id ?? 3,
succeeded ? tr('appsUpdated') : tr('appsNotUpdated'),
'',
'APPS_UPDATED',
tr('appsUpdatedNotifChannel'),
tr('appsUpdatedNotifDescription'),
Importance.defaultImportance) {
: super(
id ?? 3,
succeeded ? tr('appsUpdated') : tr('appsNotUpdated'),
'',
'APPS_UPDATED',
tr('appsUpdatedNotifChannel'),
tr('appsUpdatedNotifDescription'),
Importance.defaultImportance,
) {
message = updates.length == 1
? tr(succeeded ? 'xWasUpdatedToY' : 'xWasNotUpdatedToY',
args: [updates[0].finalName, updates[0].latestVersion])
? tr(
succeeded ? 'xWasUpdatedToY' : 'xWasNotUpdatedToY',
args: [updates[0].finalName, updates[0].latestVersion],
)
: plural(
succeeded ? 'xAndNMoreUpdatesInstalled' : "xAndNMoreUpdatesFailed",
updates.length - 1,
args: [updates[0].finalName, (updates.length - 1).toString()]);
args: [updates[0].finalName, (updates.length - 1).toString()],
);
}
}
class SilentUpdateAttemptNotification extends ObtainiumNotification {
SilentUpdateAttemptNotification(List<App> updates, {int? id})
: super(
id ?? 3,
tr('appsPossiblyUpdated'),
'',
'APPS_POSSIBLY_UPDATED',
tr('appsPossiblyUpdatedNotifChannel'),
tr('appsPossiblyUpdatedNotifDescription'),
Importance.defaultImportance) {
: super(
id ?? 3,
tr('appsPossiblyUpdated'),
'',
'APPS_POSSIBLY_UPDATED',
tr('appsPossiblyUpdatedNotifChannel'),
tr('appsPossiblyUpdatedNotifDescription'),
Importance.defaultImportance,
) {
message = updates.length == 1
? tr('xWasPossiblyUpdatedToY',
args: [updates[0].finalName, updates[0].latestVersion])
: plural('xAndNMoreUpdatesPossiblyInstalled', updates.length - 1,
args: [updates[0].finalName, (updates.length - 1).toString()]);
? tr(
'xWasPossiblyUpdatedToY',
args: [updates[0].finalName, updates[0].latestVersion],
)
: plural(
'xAndNMoreUpdatesPossiblyInstalled',
updates.length - 1,
args: [updates[0].finalName, (updates.length - 1).toString()],
);
}
}
class ErrorCheckingUpdatesNotification extends ObtainiumNotification {
ErrorCheckingUpdatesNotification(String error, {int? id})
: super(
id ?? 5,
tr('errorCheckingUpdates'),
error,
'BG_UPDATE_CHECK_ERROR',
tr('errorCheckingUpdatesNotifChannel'),
tr('errorCheckingUpdatesNotifDescription'),
Importance.high,
payload: "${tr('errorCheckingUpdates')}\n$error");
: super(
id ?? 5,
tr('errorCheckingUpdates'),
error,
'BG_UPDATE_CHECK_ERROR',
tr('errorCheckingUpdatesNotifChannel'),
tr('errorCheckingUpdatesNotifDescription'),
Importance.high,
payload: "${tr('errorCheckingUpdates')}\n$error",
);
}
class AppsRemovedNotification extends ObtainiumNotification {
AppsRemovedNotification(List<List<String>> namedReasons)
: super(
6,
tr('appsRemoved'),
'',
'APPS_REMOVED',
tr('appsRemovedNotifChannel'),
tr('appsRemovedNotifDescription'),
Importance.max) {
: super(
6,
tr('appsRemoved'),
'',
'APPS_REMOVED',
tr('appsRemovedNotifChannel'),
tr('appsRemovedNotifDescription'),
Importance.max,
) {
message = '';
for (var r in namedReasons) {
message += '${tr('xWasRemovedDueToErrorY', args: [r[0], r[1]])} \n';
@@ -115,49 +140,53 @@ class AppsRemovedNotification extends ObtainiumNotification {
class DownloadNotification extends ObtainiumNotification {
DownloadNotification(String appName, int progPercent)
: super(
appName.hashCode,
tr('downloadingX', args: [appName]),
'',
'APP_DOWNLOADING',
tr('downloadingXNotifChannel', args: [tr('app')]),
tr('downloadNotifDescription'),
Importance.low,
onlyAlertOnce: true,
progPercent: progPercent);
: super(
appName.hashCode,
tr('downloadingX', args: [appName]),
'',
'APP_DOWNLOADING',
tr('downloadingXNotifChannel', args: [tr('app')]),
tr('downloadNotifDescription'),
Importance.low,
onlyAlertOnce: true,
progPercent: progPercent,
);
}
class DownloadedNotification extends ObtainiumNotification {
DownloadedNotification(String fileName, String downloadUrl)
: super(
downloadUrl.hashCode,
tr('downloadedX', args: [fileName]),
'',
'FILE_DOWNLOADED',
tr('downloadedXNotifChannel', args: [tr('app')]),
tr('downloadedX', args: [tr('app')]),
Importance.defaultImportance);
: super(
downloadUrl.hashCode,
tr('downloadedX', args: [fileName]),
'',
'FILE_DOWNLOADED',
tr('downloadedXNotifChannel', args: [tr('app')]),
tr('downloadedX', args: [tr('app')]),
Importance.defaultImportance,
);
}
final completeInstallationNotification = ObtainiumNotification(
1,
tr('completeAppInstallation'),
tr('obtainiumMustBeOpenToInstallApps'),
'COMPLETE_INSTALL',
tr('completeAppInstallationNotifChannel'),
tr('completeAppInstallationNotifDescription'),
Importance.max);
1,
tr('completeAppInstallation'),
tr('obtainiumMustBeOpenToInstallApps'),
'COMPLETE_INSTALL',
tr('completeAppInstallationNotifChannel'),
tr('completeAppInstallationNotifDescription'),
Importance.max,
);
class CheckingUpdatesNotification extends ObtainiumNotification {
CheckingUpdatesNotification(String appName)
: super(
4,
tr('checkingForUpdates'),
appName,
'BG_UPDATE_CHECK',
tr('checkingForUpdatesNotifChannel'),
tr('checkingForUpdatesNotifDescription'),
Importance.min);
: super(
4,
tr('checkingForUpdates'),
appName,
'BG_UPDATE_CHECK',
tr('checkingForUpdatesNotifChannel'),
tr('checkingForUpdatesNotifDescription'),
Importance.min,
);
}
class NotificationsProvider {
@@ -173,13 +202,15 @@ class NotificationsProvider {
Importance.max: Priority.max,
Importance.min: Priority.min,
Importance.none: Priority.min,
Importance.unspecified: Priority.defaultPriority
Importance.unspecified: Priority.defaultPriority,
};
Future<void> initialize() async {
isInitialized = await notifications.initialize(
isInitialized =
await notifications.initialize(
const InitializationSettings(
android: AndroidInitializationSettings('ic_notification')),
android: AndroidInitializationSettings('ic_notification'),
),
onDidReceiveNotificationResponse: (NotificationResponse response) {
_showNotificationPayload(response.payload);
},
@@ -188,11 +219,13 @@ class NotificationsProvider {
}
checkLaunchByNotif() async {
final NotificationAppLaunchDetails? launchDetails =
await notifications.getNotificationAppLaunchDetails();
final NotificationAppLaunchDetails? launchDetails = await notifications
.getNotificationAppLaunchDetails();
if (launchDetails?.didNotificationLaunchApp ?? false) {
_showNotificationPayload(launchDetails!.notificationResponse?.payload,
doublePop: true);
_showNotificationPayload(
launchDetails!.notificationResponse?.payload,
doublePop: true,
);
}
}
@@ -207,13 +240,14 @@ class NotificationsProvider {
content: Text(content),
actions: [
TextButton(
onPressed: () {
onPressed: () {
Navigator.of(context).pop(null);
if (doublePop) {
Navigator.of(context).pop(null);
if (doublePop) {
Navigator.of(context).pop(null);
}
},
child: Text(tr('ok'))),
}
},
child: Text(tr('ok')),
),
],
),
),
@@ -229,17 +263,18 @@ class NotificationsProvider {
}
Future<void> notifyRaw(
int id,
String title,
String message,
String channelCode,
String channelName,
String channelDescription,
Importance importance,
{bool cancelExisting = false,
int? progPercent,
bool onlyAlertOnce = false,
String? payload}) async {
int id,
String title,
String message,
String channelCode,
String channelName,
String channelDescription,
Importance importance, {
bool cancelExisting = false,
int? progPercent,
bool onlyAlertOnce = false,
String? payload,
}) async {
if (cancelExisting) {
await cancel(id);
}
@@ -247,29 +282,42 @@ class NotificationsProvider {
await initialize();
}
await notifications.show(
id,
title,
message,
NotificationDetails(
android: AndroidNotificationDetails(channelCode, channelName,
channelDescription: channelDescription,
importance: importance,
priority: importanceToPriority[importance]!,
groupKey: '$obtainiumId.$channelCode',
progress: progPercent ?? 0,
maxProgress: 100,
showProgress: progPercent != null,
onlyAlertOnce: onlyAlertOnce,
indeterminate: progPercent != null && progPercent < 0)),
payload: payload);
id,
title,
message,
NotificationDetails(
android: AndroidNotificationDetails(
channelCode,
channelName,
channelDescription: channelDescription,
importance: importance,
priority: importanceToPriority[importance]!,
groupKey: '$obtainiumId.$channelCode',
progress: progPercent ?? 0,
maxProgress: 100,
showProgress: progPercent != null,
onlyAlertOnce: onlyAlertOnce,
indeterminate: progPercent != null && progPercent < 0,
),
),
payload: payload,
);
}
Future<void> notify(ObtainiumNotification notif,
{bool cancelExisting = false}) =>
notifyRaw(notif.id, notif.title, notif.message, notif.channelCode,
notif.channelName, notif.channelDescription, notif.importance,
cancelExisting: cancelExisting,
onlyAlertOnce: notif.onlyAlertOnce,
progPercent: notif.progPercent,
payload: notif.payload);
Future<void> notify(
ObtainiumNotification notif, {
bool cancelExisting = false,
}) => notifyRaw(
notif.id,
notif.title,
notif.message,
notif.channelCode,
notif.channelName,
notif.channelDescription,
notif.importance,
cancelExisting: cancelExisting,
onlyAlertOnce: notif.onlyAlertOnce,
progPercent: notif.progPercent,
payload: notif.payload,
);
}

View File

@@ -58,8 +58,8 @@ class SettingsProvider with ChangeNotifier {
}
ThemeSettings get theme {
return ThemeSettings
.values[prefs?.getInt('theme') ?? ThemeSettings.system.index];
return ThemeSettings.values[prefs?.getInt('theme') ??
ThemeSettings.system.index];
}
set theme(ThemeSettings t) {
@@ -123,8 +123,8 @@ class SettingsProvider with ChangeNotifier {
}
SortColumnSettings get sortColumn {
return SortColumnSettings.values[
prefs?.getInt('sortColumn') ?? SortColumnSettings.nameAuthor.index];
return SortColumnSettings.values[prefs?.getInt('sortColumn') ??
SortColumnSettings.nameAuthor.index];
}
set sortColumn(SortColumnSettings s) {
@@ -133,8 +133,8 @@ class SettingsProvider with ChangeNotifier {
}
SortOrderSettings get sortOrder {
return SortOrderSettings.values[
prefs?.getInt('sortOrder') ?? SortOrderSettings.ascending.index];
return SortOrderSettings.values[prefs?.getInt('sortOrder') ??
SortOrderSettings.ascending.index];
}
set sortOrder(SortOrderSettings s) {
@@ -171,7 +171,9 @@ class SettingsProvider with ChangeNotifier {
while (!(await Permission.requestInstallPackages.isGranted)) {
// Explicit request as InstallPlugin request sometimes bugged
Fluttertoast.showToast(
msg: tr('pleaseAllowInstallPerm'), toastLength: Toast.LENGTH_LONG);
msg: tr('pleaseAllowInstallPerm'),
toastLength: Toast.LENGTH_LONG,
);
if ((await Permission.requestInstallPackages.request()) ==
PermissionStatus.granted) {
return true;
@@ -470,7 +472,8 @@ class SettingsProvider with ChangeNotifier {
}
List<String> get searchDeselected {
return prefs?.getStringList('searchDeselected') ?? SourceProvider().sources.map((s) => s.name).toList();
return prefs?.getStringList('searchDeselected') ??
SourceProvider().sources.map((s) => s.name).toList();
}
set searchDeselected(List<String> list) {

File diff suppressed because it is too large Load Diff