diff --git a/packages/neon/neon/lib/l10n/en.arb b/packages/neon/neon/lib/l10n/en.arb index f3893eb9..545d54fd 100644 --- a/packages/neon/neon/lib/l10n/en.arb +++ b/packages/neon/neon/lib/l10n/en.arb @@ -34,6 +34,7 @@ } } }, + "errorUnableToOpenFile": "Unable to open the file", "errorUnsupportedVersion": "Sorry, this Nextcloud {name} version is not supported.", "@errorUnsupportedVersion" : { "placeholders": { diff --git a/packages/neon/neon/lib/l10n/localizations.dart b/packages/neon/neon/lib/l10n/localizations.dart index ee67d1dd..5c4ee6b5 100644 --- a/packages/neon/neon/lib/l10n/localizations.dart +++ b/packages/neon/neon/lib/l10n/localizations.dart @@ -179,6 +179,12 @@ abstract class AppLocalizations { /// **'Permission for {name} is missing'** String errorMissingPermission(String name); + /// No description provided for @errorUnableToOpenFile. + /// + /// In en, this message translates to: + /// **'Unable to open the file'** + String get errorUnableToOpenFile; + /// No description provided for @errorUnsupportedVersion. /// /// In en, this message translates to: diff --git a/packages/neon/neon/lib/l10n/localizations_en.dart b/packages/neon/neon/lib/l10n/localizations_en.dart index 141c7a38..2992257d 100644 --- a/packages/neon/neon/lib/l10n/localizations_en.dart +++ b/packages/neon/neon/lib/l10n/localizations_en.dart @@ -72,6 +72,9 @@ class AppLocalizationsEn extends AppLocalizations { return 'Permission for $name is missing'; } + @override + String get errorUnableToOpenFile => 'Unable to open the file'; + @override String errorUnsupportedVersion(String name) { return 'Sorry, this Nextcloud $name version is not supported.'; diff --git a/packages/neon/neon/lib/neon.dart b/packages/neon/neon/lib/neon.dart index 2c42de04..ca55f91e 100644 --- a/packages/neon/neon/lib/neon.dart +++ b/packages/neon/neon/lib/neon.dart @@ -72,12 +72,12 @@ part 'src/utils/app_implementation.dart'; part 'src/utils/bloc.dart'; part 'src/utils/branding.dart'; part 'src/utils/confirmation_dialog.dart'; +part 'src/utils/exceptions.dart'; part 'src/utils/global.dart'; part 'src/utils/global_options.dart'; part 'src/utils/global_popups.dart'; part 'src/utils/hex_color.dart'; part 'src/utils/localizations.dart'; -part 'src/utils/missing_permission_exception.dart'; part 'src/utils/nextcloud_app_specific_options.dart'; part 'src/utils/push_utils.dart'; part 'src/utils/rename_dialog.dart'; diff --git a/packages/neon/neon/lib/src/utils/missing_permission_exception.dart b/packages/neon/neon/lib/src/utils/exceptions.dart similarity index 74% rename from packages/neon/neon/lib/src/utils/missing_permission_exception.dart rename to packages/neon/neon/lib/src/utils/exceptions.dart index c91fcd6f..0131906e 100644 --- a/packages/neon/neon/lib/src/utils/missing_permission_exception.dart +++ b/packages/neon/neon/lib/src/utils/exceptions.dart @@ -5,3 +5,5 @@ class MissingPermissionException implements Exception { final Permission permission; } + +class UnableToOpenFileException implements Exception {} diff --git a/packages/neon/neon/lib/src/widgets/exception.dart b/packages/neon/neon/lib/src/widgets/exception.dart index 84455b2c..064078af 100644 --- a/packages/neon/neon/lib/src/widgets/exception.dart +++ b/packages/neon/neon/lib/src/widgets/exception.dart @@ -108,6 +108,12 @@ class NeonException extends StatelessWidget { ); } + if (exception is UnableToOpenFileException) { + return _ExceptionDetails( + text: AppLocalizations.of(context).errorUnableToOpenFile, + ); + } + if (exception is NextcloudApiException) { if (exception.statusCode == 401) { return _ExceptionDetails( diff --git a/packages/neon/neon_files/lib/blocs/files.dart b/packages/neon/neon_files/lib/blocs/files.dart index 3668eb6e..addadd7f 100644 --- a/packages/neon/neon_files/lib/blocs/files.dart +++ b/packages/neon/neon_files/lib/blocs/files.dart @@ -101,7 +101,10 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta } await _downloadFile(path, file); } - await OpenFile.open(file.path, type: mimeType); + final result = await OpenFile.open(file.path, type: mimeType); + if (result.type != ResultType.done) { + throw UnableToOpenFileException(); + } }, disableTimeout: true, );