From 6390cb55a497ba7c0ed718ef9dca6a63d6c91aa1 Mon Sep 17 00:00:00 2001 From: erinn Date: Sat, 18 Dec 2021 18:09:18 -0800 Subject: [PATCH] l10n --- lib/settings.dart | 14 ++++++++++++++ lib/views/messageview.dart | 11 +++++------ lib/widgets/filebubble.dart | 8 +++----- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/settings.dart b/lib/settings.dart index 329871d2..7d9392c8 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -228,6 +228,20 @@ class Settings extends ChangeNotifier { } } + // checks experiment settings and file extension for image previews + // (ignores file size; if the user manually accepts the file, assume it's okay to preview) + bool shouldPreview(String path) { + var lpath = path.toLowerCase(); + return isExperimentEnabled(ImagePreviewsExperiment) && ( + lpath.endsWith(".jpg") || + lpath.endsWith(".jpeg") || + lpath.endsWith(".png") || + lpath.endsWith(".gif") || + lpath.endsWith(".webp") || + lpath.endsWith(".bmp") + ); + } + String get downloadPath => _downloadPath; set downloadPath(String newval) { _downloadPath = newval; diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index 270ca4a4..c4315647 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -389,7 +389,7 @@ class _MessageViewState extends State { _confirmFileSend(ctx, file.path); } else { final snackBar = SnackBar( - content: Text("File size cannot exceed 10 GB"), + content: Text(AppLocalizations.of(context)!.msgFileTooBig), duration: Duration(seconds: 4), ); ScaffoldMessenger.of(ctx).showSnackBar(snackBar); @@ -401,9 +401,8 @@ class _MessageViewState extends State { showModalBottomSheet( context: ctx, builder: (BuildContext bcontext) { - var lpath = path.toLowerCase(); var showPreview = false; - if (Provider.of(context, listen: false).isExperimentEnabled(ImagePreviewsExperiment) && (lpath.endsWith("jpg") || lpath.endsWith("jpeg") || lpath.endsWith("png") || lpath.endsWith("gif") || lpath.endsWith("webp") || lpath.endsWith("bmp"))) { + if (Provider.of(context, listen: false).shouldPreview(path)) { showPreview = true; if (imagePreview == null) { imagePreview = new File(path); @@ -418,7 +417,7 @@ class _MessageViewState extends State { mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Text("Are you sure you want to send $path?"), + Text(AppLocalizations.of(context)!.msgConfirmSend + " $path?"), SizedBox( height: 20, ), @@ -437,14 +436,14 @@ class _MessageViewState extends State { Visibility(visible: showPreview, child: SizedBox(height: 10,)), Row(mainAxisAlignment: MainAxisAlignment.center, children: [ ElevatedButton( - child: Text("Cancel", semanticsLabel: "Cancel"), + child: Text(AppLocalizations.of(context)!.cancel, semanticsLabel: AppLocalizations.of(context)!.cancel), onPressed: () { Navigator.pop(bcontext); }, ), SizedBox(width: 20,), ElevatedButton( - child: Text("Send File", semanticsLabel: "Send File"), + child: Text(AppLocalizations.of(context)!.btnSendFile, semanticsLabel: AppLocalizations.of(context)!.btnSendFile), onPressed: () { _sendFile(path); Navigator.pop(bcontext); diff --git a/lib/widgets/filebubble.dart b/lib/widgets/filebubble.dart index 460f8e3e..e40c6097 100644 --- a/lib/widgets/filebubble.dart +++ b/lib/widgets/filebubble.dart @@ -49,7 +49,6 @@ class FileBubbleState extends State { var flagStarted = Provider.of(context).attributes["file-downloaded"] == "true"; var borderRadiousEh = 15.0; var showFileSharing = Provider.of(context).isExperimentEnabled(FileSharingExperiment); - var showImagePreviews = Provider.of(context).isExperimentEnabled(ImagePreviewsExperiment); var prettyDate = DateFormat.yMd(Platform.localeName).add_jm().format(Provider.of(context).timestamp); var downloadComplete = Provider.of(context).downloadComplete(widget.fileKey()); var downloadInterrupted = Provider.of(context).downloadInterrupted(widget.fileKey()); @@ -61,7 +60,7 @@ class FileBubbleState extends State { var path = Provider.of(context).downloadFinalPath(widget.fileKey()); if (downloadComplete) { var lpath = path!.toLowerCase(); - if (lpath.endsWith("jpg") || lpath.endsWith("jpeg") || lpath.endsWith("png") || lpath.endsWith("gif") || lpath.endsWith("webp") || lpath.endsWith("bmp")) { + if (lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp")) { if (myFile == null) { setState(() { myFile = new File(path); @@ -107,8 +106,7 @@ class FileBubbleState extends State { child: MessageBubbleDecoration(ackd: Provider.of(context).ackd, errored: Provider.of(context).error, fromMe: fromMe, prettyDate: prettyDate)); } else if (downloadComplete) { // in this case, whatever marked download.complete would have also set the path - var lpath = path!.toLowerCase(); - if (showImagePreviews && (lpath.endsWith("jpg") || lpath.endsWith("jpeg") || lpath.endsWith("png") || lpath.endsWith("gif") || lpath.endsWith("webp") || lpath.endsWith("bmp"))) { + if (Provider.of(context).shouldPreview(path!)) { isPreview = true; wdgDecorations = Center( child: GestureDetector( @@ -161,7 +159,7 @@ class FileBubbleState extends State { ])); } } else if (!senderIsContact) { - wdgDecorations = Text("Add this account to your contacts in order to accept this file."); + wdgDecorations = Text(AppLocalizations.of(context)!.msgAddToAccept); } else if (!widget.isAuto) { wdgDecorations = Visibility( visible: widget.interactive,