Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix: update localization & fix lint

Prateek Sunal42d31a73a372
diff --git a/mobile/apps/photos/lib/db/files_db.dart b/mobile/apps/photos/lib/db/files_db.dart
index 7da36c4da2..044fdcffb6 100644
--- a/mobile/apps/photos/lib/db/files_db.dart
+++ b/mobile/apps/photos/lib/db/files_db.dart
@@ -449,9 +449,8 @@ class FilesDB with SqlDbBase {
final withIdParams = <List<Object?>>[];
const withIdColumnNames = _columnNames;
final withoutIdParams = <List<Object?>>[];
- final withoutIdColumns = _columnNames
- .where((column) => column != columnGeneratedID)
- .toList();
+ final withoutIdColumns =
+ _columnNames.where((column) => column != columnGeneratedID).toList();
// Sort files into appropriate parameter sets
for (final file in files) {
@@ -829,8 +828,7 @@ class FilesDB with SqlDbBase {
'$columnCreationTime <= ? AND $columnOwnerID = ?';
final List<Object> whereArgs = [startTime, endTime, userID];
- String query =
- 'SELECT * FROM $filesTable WHERE $whereClause ORDER BY '
+ String query = 'SELECT * FROM $filesTable WHERE $whereClause ORDER BY '
'$columnCreationTime $order, $columnModificationTime $order';
if (limit != null) {
query += ' LIMIT ?';
@@ -1013,7 +1011,9 @@ class FilesDB with SqlDbBase {
DELETE FROM $filesTable
WHERE $columnLocalID IN ($uploadedPlaceholders)
AND ($columnUploadedFileID IS NULL OR $columnUploadedFileID = -1)
- ''', batch);
+ ''',
+ batch,
+ );
if (r.isNotEmpty) {
_logger.warning(
@@ -1113,14 +1113,12 @@ class FilesDB with SqlDbBase {
final db = await instance.sqliteAsyncDB;
// on iOS, match using localID and fileType. title can either match or
// might be null based on how the file was imported
- String query =
- '''SELECT * FROM $filesTable WHERE ($columnOwnerID = ?
+ String query = '''SELECT * FROM $filesTable WHERE ($columnOwnerID = ?
OR $columnOwnerID IS NULL) AND $columnLocalID = ?
AND $columnFileType = ? AND ($columnTitle=? OR $columnTitle IS NULL) ''';
List<Object> whereArgs = [ownerID, localID, getInt(fileType), title];
if (Platform.isAndroid) {
- query =
- '''SELECT * FROM $filesTable WHERE ($columnOwnerID = ? OR
+ query = '''SELECT * FROM $filesTable WHERE ($columnOwnerID = ? OR
$columnOwnerID IS NULL) AND $columnLocalID = ? AND $columnFileType = ?
AND $columnTitle=? AND $columnDeviceFolder= ? ''';
whereArgs = [ownerID, localID, getInt(fileType), title, deviceFolder];
@@ -1132,7 +1130,7 @@ class FilesDB with SqlDbBase {
}
Future<Map<String, EnteFile>>
- getUserOwnedFilesWithSameHashForGivenListOfFiles(
+ getUserOwnedFilesWithSameHashForGivenListOfFiles(
List<EnteFile> files,
int userID,
) async {
@@ -1278,15 +1276,13 @@ class FilesDB with SqlDbBase {
final inParam = localIDs.map((id) => "'$id'").join(',');
final db = await instance.sqliteAsyncDB;
if (dedupeByLocalID) {
- query =
- '''
+ query = '''
SELECT * FROM $filesTable
WHERE $columnLocalID IN ($inParam)
GROUP BY $columnLocalID;
''';
} else {
- query =
- '''
+ query = '''
SELECT * FROM $filesTable
WHERE $columnLocalID IN ($inParam);
''';
@@ -1625,11 +1621,14 @@ class FilesDB with SqlDbBase {
parameterSets.add([uploadedFileIDToSize[uploadedFileID], uploadedFileID]);
}
- await db.executeBatch('''
+ await db.executeBatch(
+ '''
UPDATE $filesTable
SET $columnFileSize = ?
WHERE $columnUploadedFileID = ?;
- ''', parameterSets);
+ ''',
+ parameterSets,
+ );
}
Future<List<EnteFile>> getAllFilesAfterDate({
@@ -1689,8 +1688,7 @@ class FilesDB with SqlDbBase {
}) async {
final db = await instance.sqliteAsyncDB;
final order = (asc ?? false ? 'ASC' : 'DESC');
- String query =
- '''
+ String query = '''
SELECT * FROM $filesTable
WHERE $columnLatitude IS NOT NULL AND $columnLongitude IS NOT NULL AND
($columnLatitude IS NOT 0 OR $columnLongitude IS NOT 0) AND
@@ -1898,22 +1896,23 @@ class FilesDB with SqlDbBase {
) async {
final valuesPlaceholders = List.filled(columnNames.length, "?").join(",");
final columnNamesJoined = columnNames.join(",");
- await db.executeBatch('''
+ await db.executeBatch(
+ '''
INSERT OR ${conflictAlgorithm.name.toUpperCase()} INTO $filesTable($columnNamesJoined) VALUES($valuesPlaceholders)
- ''', parameterSets);
+ ''',
+ parameterSets,
+ );
}
EnteFile _getFileFromRow(Map<String, dynamic> row) {
final file = EnteFile();
file.generatedID = row[columnGeneratedID];
file.localID = row[columnLocalID];
- file.uploadedFileID = row[columnUploadedFileID] == -1
- ? null
- : row[columnUploadedFileID];
+ file.uploadedFileID =
+ row[columnUploadedFileID] == -1 ? null : row[columnUploadedFileID];
file.ownerID = row[columnOwnerID];
- file.collectionID = row[columnCollectionID] == -1
- ? null
- : row[columnCollectionID];
+ file.collectionID =
+ row[columnCollectionID] == -1 ? null : row[columnCollectionID];
file.title = row[columnTitle];
file.deviceFolder = row[columnDeviceFolder];
if (row[columnLatitude] != null && row[columnLongitude] != null) {
diff --git a/mobile/apps/photos/lib/services/video_preview_service.dart b/mobile/apps/photos/lib/services/video_preview_service.dart
index 9acf1f5298..2e4af816bc 100644
--- a/mobile/apps/photos/lib/services/video_preview_service.dart
+++ b/mobile/apps/photos/lib/services/video_preview_service.dart
@@ -221,9 +221,8 @@ class VideoPreviewService {
_items[enteFile.uploadedFileID!] = PreviewItem(
status: PreviewItemStatus.compressing,
file: enteFile,
- retryCount: forceUpload
- ? 0
- : _items[enteFile.uploadedFileID!]?.retryCount ?? 0,
+ retryCount:
+ forceUpload ? 0 : _items[enteFile.uploadedFileID!]?.retryCount ?? 0,
collectionID: enteFile.collectionID ?? 0,
);
@@ -249,11 +248,9 @@ class VideoPreviewService {
? (fileSize * 8) / props!.duration!.inSeconds
: null;
- final colorTransfer = videoData["color_transfer"]
- ?.toString()
- .toLowerCase();
- final isHDR =
- colorTransfer != null &&
+ final colorTransfer =
+ videoData["color_transfer"]?.toString().toLowerCase();
+ final isHDR = colorTransfer != null &&
(colorTransfer == "smpte2084" || colorTransfer == "arib-std-b67");
// create temp file & directory for preview generation
@@ -323,18 +320,17 @@ class VideoPreviewService {
_logger.info(command);
- final playlistGenResult =
- await IsolatedFfmpegService.runFfmpeg(
- // input file path
- '-i "${file.path}" ' +
- // main params for streaming
- command +
- // output file path
- '$prefix/output.m3u8',
- ).onError((error, stackTrace) {
- _logger.warning("FFmpeg command failed", error, stackTrace);
- return {};
- });
+ final playlistGenResult = await IsolatedFfmpegService.runFfmpeg(
+ // input file path
+ '-i "${file.path}" ' +
+ // main params for streaming
+ command +
+ // output file path
+ '$prefix/output.m3u8',
+ ).onError((error, stackTrace) {
+ _logger.warning("FFmpeg command failed", error, stackTrace);
+ return {};
+ });
final playlistGenReturnCode = playlistGenResult["returnCode"] as int?;
@@ -360,17 +356,16 @@ class VideoPreviewService {
objectSize = result.$2;
// Fetch resolution of generated stream by decrypting a single frame
- final playlistFrameResult =
- await IsolatedFfmpegService.runFfmpeg(
- '-allowed_extensions ALL -i "$prefix/output.m3u8" -frames:v 1 -c copy "$prefix/frame.ts"',
- ).onError((error, stackTrace) {
- _logger.warning(
- "FFmpeg command failed for frame",
- error,
- stackTrace,
- );
- return {};
- });
+ final playlistFrameResult = await IsolatedFfmpegService.runFfmpeg(
+ '-allowed_extensions ALL -i "$prefix/output.m3u8" -frames:v 1 -c copy "$prefix/frame.ts"',
+ ).onError((error, stackTrace) {
+ _logger.warning(
+ "FFmpeg command failed for frame",
+ error,
+ stackTrace,
+ );
+ return {};
+ });
final playlistFrameReturnCode =
playlistFrameResult["returnCode"] as int?;
int? width, height;
@@ -520,13 +515,16 @@ class VideoPreviewService {
try {
final encryptionKey = getFileKey(file);
final playlistContent = playlist.readAsStringSync();
- final result = await gzipAndEncryptJson({
- "playlist": playlistContent,
- 'type': 'hls_video',
- 'width': width,
- 'height': height,
- 'size': objectSize,
- }, encryptionKey);
+ final result = await gzipAndEncryptJson(
+ {
+ "playlist": playlistContent,
+ 'type': 'hls_video',
+ 'width': width,
+ 'height': height,
+ 'size': objectSize,
+ },
+ encryptionKey,
+ );
final _ = await _enteDio.put(
"/files/video-data",
data: {
@@ -644,7 +642,8 @@ class VideoPreviewService {
}
final videoFile = (await videoCacheManager.getFileFromCache(
_getVideoPreviewKey(objectID),
- ))?.file;
+ ))
+ ?.file;
if (videoFile == null) {
previewURLResult = previewURLResult ?? await _getPreviewUrl(file);
if (size != null && size < _maxPreviewSizeLimitForCache) {
@@ -668,13 +667,12 @@ class VideoPreviewService {
final tempDir = await getTemporaryDirectory();
final playlistFile = File("${tempDir.path}/${file.uploadedFileID}.m3u8");
await playlistFile.writeAsString(finalPlaylist);
- final String log =
- (StringBuffer()
- ..write("[CACHE-STATUS] ")
- ..write("Video: ${videoFile != null ? 'βœ“' : 'βœ—'} | ")
- ..write("Details: ${detailsCache != null ? 'βœ“' : 'βœ—'} | ")
- ..write("Playlist: ${playlistCache != null ? 'βœ“' : 'βœ—'}"))
- .toString();
+ final String log = (StringBuffer()
+ ..write("[CACHE-STATUS] ")
+ ..write("Video: ${videoFile != null ? 'βœ“' : 'βœ—'} | ")
+ ..write("Details: ${detailsCache != null ? 'βœ“' : 'βœ—'} | ")
+ ..write("Playlist: ${playlistCache != null ? 'βœ“' : 'βœ—'}"))
+ .toString();
_logger.info("Mapped playlist to ${playlistFile.path}, $log");
final data = PlaylistData(
preview: playlistFile,
@@ -745,9 +743,8 @@ class VideoPreviewService {
"${Configuration.instance.getHttpEndpoint()}/public-collection/files/data/preview",
queryParameters: {
"fileID": file.uploadedFileID,
- "type": file.fileType == FileType.video
- ? "vid_preview"
- : "img_preview",
+ "type":
+ file.fileType == FileType.video ? "vid_preview" : "img_preview",
},
options: Options(
headers: collectionsService.publicCollectionHeaders(
@@ -761,9 +758,8 @@ class VideoPreviewService {
"/files/data/preview",
queryParameters: {
"fileID": file.uploadedFileID,
- "type": file.fileType == FileType.video
- ? "vid_preview"
- : "img_preview",
+ "type":
+ file.fileType == FileType.video ? "vid_preview" : "img_preview",
},
);
url = (response.data["url"] as String);
@@ -855,9 +851,8 @@ class VideoPreviewService {
);
final previewIds = fileDataService.previewIds;
- final allFiles = files
- .where((file) => previewIds[file.uploadedFileID] == null)
- .toList();
+ final allFiles =
+ files.where((file) => previewIds[file.uploadedFileID] == null).toList();
// set all video status to in queue
var n = allFiles.length, i = 0;
diff --git a/mobile/apps/photos/lib/ui/components/menu_item_widget/menu_item_widget.dart b/mobile/apps/photos/lib/ui/components/menu_item_widget/menu_item_widget.dart
index 3802280aae..ea9dbd0c48 100644
--- a/mobile/apps/photos/lib/ui/components/menu_item_widget/menu_item_widget.dart
+++ b/mobile/apps/photos/lib/ui/components/menu_item_widget/menu_item_widget.dart
@@ -112,8 +112,8 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
menuItemColor = widget.menuItemColor;
borderRadius =
(widget.isBottomBorderRadiusRemoved || widget.isTopBorderRadiusRemoved)
- ? widget.multipleBorderRadius
- : widget.singleBorderRadius;
+ ? widget.multipleBorderRadius
+ : widget.singleBorderRadius;
if (widget.expandableController != null) {
widget.expandableController!.addListener(() {
setState(() {});
@@ -163,8 +163,8 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
final isExpanded = widget.expandableController?.value;
final bottomBorderRadius =
(isExpanded != null && isExpanded) || widget.isBottomBorderRadiusRemoved
- ? const Radius.circular(0)
- : circularRadius;
+ ? const Radius.circular(0)
+ : circularRadius;
final topBorderRadius = widget.isTopBorderRadiusRemoved
? const Radius.circular(0)
: circularRadius;
@@ -224,11 +224,14 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
executionStateNotifier.value = ExecutionState.inProgress;
}),
);
- await widget.onTap?.call().then((value) {
- widget.alwaysShowSuccessState
- ? executionStateNotifier.value = ExecutionState.successful
- : null;
- }, onError: (error, stackTrace) => _debouncer.cancelDebounceTimer());
+ await widget.onTap?.call().then(
+ (value) {
+ widget.alwaysShowSuccessState
+ ? executionStateNotifier.value = ExecutionState.successful
+ : null;
+ },
+ onError: (error, stackTrace) => _debouncer.cancelDebounceTimer(),
+ );
_debouncer.cancelDebounceTimer();
if (widget.alwaysShowSuccessState) {
Future.delayed(const Duration(seconds: 2), () {
diff --git a/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart b/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart
index 1789f4887d..9e8aa8def3 100644
--- a/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart
@@ -48,7 +48,7 @@ class _VideoStreamingSettingsPageState
slivers: <Widget>[
TitleBarWidget(
flexibleSpaceTitle: TitleBarTitleWidget(
- title: S.of(context).videoStreaming,
+ title: AppLocalizations.of(context).videoStreaming,
),
actionIcons: [
IconButtonWidget(
@@ -70,11 +70,13 @@ class _VideoStreamingSettingsPageState
Text.rich(
TextSpan(
children: [
- TextSpan(text: S.of(context).videoStreamingDescription),
+ TextSpan(
+ text: AppLocalizations.of(context)
+ .videoStreamingDescription,
+ ),
const TextSpan(text: " "),
TextSpan(
- text: S
- .of(context)
+ text: AppLocalizations.of(context)
.videoStreamingDescriptionClickable,
style: const TextStyle(
decoration: TextDecoration.underline,
@@ -85,8 +87,8 @@ class _VideoStreamingSettingsPageState
),
textAlign: TextAlign.justify,
style: getEnteTextTheme(context).mini.copyWith(
- color: getEnteColorScheme(context).textMuted,
- ),
+ color: getEnteColorScheme(context).textMuted,
+ ),
),
],
),
@@ -131,15 +133,13 @@ class _VideoStreamingSettingsPageState
}
Future<void> openHelp() async {
- Navigator.of(context)
- .push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return WebPage(S.of(context).help, helpUrl);
- },
- ),
- )
- .ignore();
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return WebPage(AppLocalizations.of(context).help, helpUrl);
+ },
+ ),
+ ).ignore();
}
Future<void> toggleVideoStreaming() async {
@@ -157,7 +157,7 @@ class _VideoStreamingSettingsPageState
MenuItemWidget(
padding: const EdgeInsets.only(left: 8, right: 4),
captionedTextWidget: CaptionedTextWidget(
- title: S.of(context).enabled,
+ title: AppLocalizations.of(context).enabled,
),
trailingWidget: ToggleSwitchWidget(
value: () => hasEnabled,
@@ -211,14 +211,14 @@ class VideoStreamingStatusWidgetState
MenuItemWidget(
padding: const EdgeInsets.only(left: 8, right: 6),
captionedTextWidget: CaptionedTextWidget(
- title: S.of(context).processed,
+ title: AppLocalizations.of(context).processed,
),
trailingWidget: Text(
total < 1
? 'NA'
: netProcessed == 0
- ? '0%'
- : '${(netProcessed * 100.0).toStringAsFixed(2)}%',
+ ? '0%'
+ : '${(netProcessed * 100.0).toStringAsFixed(2)}%',
style: Theme.of(context).textTheme.bodySmall,
),
singleBorderRadius: 8,
@@ -230,10 +230,10 @@ class VideoStreamingStatusWidgetState
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text(
- S.of(context).videoStreamingNote,
+ AppLocalizations.of(context).videoStreamingNote,
style: getEnteTextTheme(context).mini.copyWith(
- color: getEnteColorScheme(context).textMuted,
- ),
+ color: getEnteColorScheme(context).textMuted,
+ ),
),
),
],