Skip to content

Commit

Permalink
compose: Add translations for attaching media to messages and related…
Browse files Browse the repository at this point in the history
… permission issues
  • Loading branch information
sirpengi committed Oct 4, 2023
1 parent 49df1b4 commit c1622bc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
28 changes: 20 additions & 8 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,22 @@
"@profileButtonSendDirectMessage": {
"description": "Label for button in profile screen to navigate to DMs with the shown user."
},
"cameraAccessDeniedTitle": "Permissions needed",
"@cameraAccessDeniedTitle": {
"description": "Title for dialog when the user needs to grant permissions for camera access."
"permissionsNeededTitle": "Permissions needed",
"@permissionsNeededTitle": {
"description": "Title for dialog when the user needs to grant additional permissions."
},
"cameraAccessDeniedMessage": "To upload an image, please grant Zulip additional permissions in Settings.",
"@cameraAccessDeniedMessage": {
"description": "Message for dialog when the user needs to grant permissions for camera access."
"permissionsNeededOpenSettings": "Open settings",
"@permissionsNeededOpenSettings": {
"description": "Button label for permissions dialog button that opens the system settings screen."
},
"cameraAccessDeniedButtonText": "Open settings",
"@cameraAccessDeniedButtonText": {
"permissionsDeniedCameraAccess": "To upload an image, please grant Zulip additional permissions in Settings.",
"@permissionsDeniedCameraAccess": {
"description": "Message for dialog when the user needs to grant permissions for camera access."
},
"permissionsDeniedReadExternalStorage": "To upload files, please grant Zulip additional permissions in Settings.",
"@permissionsDeniedReadExternalStorage": {
"description": "Message for dialog when the user needs to grant permissions for external storage read access."
},
"actionSheetOptionCopy": "Copy message text",
"@actionSheetOptionCopy": {
"description": "Label for copy message text button on action sheet."
Expand Down Expand Up @@ -90,6 +94,10 @@
"@errorLoginFailedTitle": {
"description": "Error title for login when signing into a Zulip server fails."
},
"errorMessageNotSent": "Message not sent",
"@errorMessageNotSent": {
"description": "Error message for compose box when a message could not be sent."
},
"errorLoginCouldNotConnect": "Failed to connect to server:\n{url}",
"@errorLoginCouldNotConnect": {
"description": "Error message when the app could not connect to the server.",
Expand Down Expand Up @@ -159,6 +167,10 @@
"@errorDialogContinue": {
"description": "Button label in error dialogs to acknowledge error."
},
"errorDialogTitle": "Error",
"@errorDialogTitle": {
"description": "Generic title for error dialog."
},
"lightboxCopyLinkTooltip": "Copy link",
"@lightboxCopyLinkTooltip": {
"description": "Tooltip in lightbox for the copy link action."
Expand Down
27 changes: 15 additions & 12 deletions lib/widgets/compose_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -539,23 +539,25 @@ Future<Iterable<_File>> _getFilePickerFiles(BuildContext context, FileType type)
.pickFiles(allowMultiple: true, withReadStream: true, type: type);
} catch (e) {
if (!context.mounted) return [];
final zulipLocalizations = ZulipLocalizations.of(context);
if (e is PlatformException && e.code == 'read_external_storage_denied') {
// Observed on Android. If Android's error message tells us whether the
// user has checked "Don't ask again", it seems the library doesn't pass
// that on to us. So just always prompt to check permissions in settings.
// If the user hasn't checked "Don't ask again", they can always dismiss
// our prompt and retry, and the permissions request will reappear,
// letting them grant permissions and complete the upload.
showSuggestedActionDialog(context: context, // TODO(i18n)
title: 'Permissions needed',
message: 'To upload files, please grant Zulip additional permissions in Settings.',
actionButtonText: 'Open settings',
showSuggestedActionDialog(context: context,
title: zulipLocalizations.permissionsNeededTitle,
message: zulipLocalizations.permissionsDeniedReadExternalStorage,
actionButtonText: zulipLocalizations.permissionsNeededOpenSettings,
onActionButtonPress: () {
AppSettings.openAppSettings();
});
} else {
// TODO(i18n)
showErrorDialog(context: context, title: 'Error', message: e.toString());
showErrorDialog(context: context,
title: zulipLocalizations.errorDialogTitle,
message: e.toString());
}
return [];
}
Expand Down Expand Up @@ -626,15 +628,16 @@ class _AttachFromCameraButton extends _AttachUploadsButton {
// use a protected resource. After that, the only way the user can
// grant it is in Settings.
showSuggestedActionDialog(context: context,
title: zulipLocalizations.cameraAccessDeniedTitle,
message: zulipLocalizations.cameraAccessDeniedMessage,
actionButtonText: zulipLocalizations.cameraAccessDeniedButtonText,
title: zulipLocalizations.permissionsNeededTitle,
message: zulipLocalizations.permissionsDeniedCameraAccess,
actionButtonText: zulipLocalizations.permissionsNeededOpenSettings,
onActionButtonPress: () {
AppSettings.openAppSettings();
});
} else {
// TODO(i18n)
showErrorDialog(context: context, title: 'Error', message: e.toString());
showErrorDialog(context: context,
title: zulipLocalizations.errorDialogTitle,
message: e.toString());
}
return [];
}
Expand Down Expand Up @@ -712,7 +715,7 @@ class _SendButtonState extends State<_SendButton> {
];
showErrorDialog(
context: context,
title: 'Message not sent',
title: zulipLocalizations.errorMessageNotSent,
message: validationErrorMessages.join('\n\n'));
return;
}
Expand Down

0 comments on commit c1622bc

Please sign in to comment.