Browse Source

neon,neon_files: Display error message when file can't be opened

pull/271/head
jld3103 2 years ago
parent
commit
7af3b1f7a9
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 1
      packages/neon/neon/lib/l10n/en.arb
  2. 6
      packages/neon/neon/lib/l10n/localizations.dart
  3. 3
      packages/neon/neon/lib/l10n/localizations_en.dart
  4. 2
      packages/neon/neon/lib/neon.dart
  5. 2
      packages/neon/neon/lib/src/utils/exceptions.dart
  6. 6
      packages/neon/neon/lib/src/widgets/exception.dart
  7. 5
      packages/neon/neon_files/lib/blocs/files.dart

1
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": "Sorry, this Nextcloud {name} version is not supported.",
"@errorUnsupportedVersion" : { "@errorUnsupportedVersion" : {
"placeholders": { "placeholders": {

6
packages/neon/neon/lib/l10n/localizations.dart

@ -179,6 +179,12 @@ abstract class AppLocalizations {
/// **'Permission for {name} is missing'** /// **'Permission for {name} is missing'**
String errorMissingPermission(String name); 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. /// No description provided for @errorUnsupportedVersion.
/// ///
/// In en, this message translates to: /// In en, this message translates to:

3
packages/neon/neon/lib/l10n/localizations_en.dart

@ -72,6 +72,9 @@ class AppLocalizationsEn extends AppLocalizations {
return 'Permission for $name is missing'; return 'Permission for $name is missing';
} }
@override
String get errorUnableToOpenFile => 'Unable to open the file';
@override @override
String errorUnsupportedVersion(String name) { String errorUnsupportedVersion(String name) {
return 'Sorry, this Nextcloud $name version is not supported.'; return 'Sorry, this Nextcloud $name version is not supported.';

2
packages/neon/neon/lib/neon.dart

@ -72,12 +72,12 @@ part 'src/utils/app_implementation.dart';
part 'src/utils/bloc.dart'; part 'src/utils/bloc.dart';
part 'src/utils/branding.dart'; part 'src/utils/branding.dart';
part 'src/utils/confirmation_dialog.dart'; part 'src/utils/confirmation_dialog.dart';
part 'src/utils/exceptions.dart';
part 'src/utils/global.dart'; part 'src/utils/global.dart';
part 'src/utils/global_options.dart'; part 'src/utils/global_options.dart';
part 'src/utils/global_popups.dart'; part 'src/utils/global_popups.dart';
part 'src/utils/hex_color.dart'; part 'src/utils/hex_color.dart';
part 'src/utils/localizations.dart'; part 'src/utils/localizations.dart';
part 'src/utils/missing_permission_exception.dart';
part 'src/utils/nextcloud_app_specific_options.dart'; part 'src/utils/nextcloud_app_specific_options.dart';
part 'src/utils/push_utils.dart'; part 'src/utils/push_utils.dart';
part 'src/utils/rename_dialog.dart'; part 'src/utils/rename_dialog.dart';

2
packages/neon/neon/lib/src/utils/missing_permission_exception.dart → packages/neon/neon/lib/src/utils/exceptions.dart

@ -5,3 +5,5 @@ class MissingPermissionException implements Exception {
final Permission permission; final Permission permission;
} }
class UnableToOpenFileException implements Exception {}

6
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 is NextcloudApiException) {
if (exception.statusCode == 401) { if (exception.statusCode == 401) {
return _ExceptionDetails( return _ExceptionDetails(

5
packages/neon/neon_files/lib/blocs/files.dart

@ -101,7 +101,10 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta
} }
await _downloadFile(path, file); 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, disableTimeout: true,
); );

Loading…
Cancel
Save