minor fixes
This commit is contained in:
parent
65ec62c117
commit
05aa7641f7
4 changed files with 24 additions and 6 deletions
|
@ -77,7 +77,7 @@ class RegionFetcher internal constructor(
|
|||
}
|
||||
}
|
||||
if (newDecoder == null) {
|
||||
result.error("getRegion-read-null", "failed to open file for uri=$uri regionRect=$regionRect", null)
|
||||
result.error("getRegion-read-null", "failed to open file for mimeType=$mimeType uri=$uri regionRect=$regionRect", null)
|
||||
return
|
||||
}
|
||||
currentDecoderRef = LastDecoderRef(uri, newDecoder)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class MimeTypes {
|
||||
static const anyImage = 'image/*';
|
||||
|
||||
static const avif = 'image/avif';
|
||||
static const bmp = 'image/bmp';
|
||||
static const bmpX = 'image/x-ms-bmp';
|
||||
static const gif = 'image/gif';
|
||||
|
@ -66,18 +67,26 @@ class MimeTypes {
|
|||
// groups
|
||||
|
||||
// formats that support transparency
|
||||
static const Set<String> alphaImages = {bmp, bmpX, gif, ico, png, svg, tiff, webp};
|
||||
static const Set<String> alphaImages = {avif, bmp, bmpX, gif, heic, heif, ico, png, svg, tiff, webp};
|
||||
|
||||
static const Set<String> rawImages = {arw, cr2, crw, dcr, dng, erf, k25, kdc, mrw, nef, nrw, orf, pef, raf, raw, rw2, sr2, srf, srw, x3f};
|
||||
|
||||
// TODO TLAD [codec] make it dynamic if it depends on OS/lib versions
|
||||
static const Set<String> undecodableImages = {art, cdr, crw, djvu, jxl, psdVnd, psdX, octetStream, zip};
|
||||
|
||||
static const Set<String> _knownOpaqueImages = {heic, heif, jpeg};
|
||||
static const Set<String> _knownOpaqueImages = {jpeg};
|
||||
|
||||
static const Set<String> _knownVideos = {avi, aviVnd, flv, flvX, mkv, mov, mp2t, mp2ts, mp4, mpeg, ogv, webm};
|
||||
|
||||
static final Set<String> knownMediaTypes = {..._knownOpaqueImages, ...alphaImages, ...rawImages, ...undecodableImages, ..._knownVideos};
|
||||
static final Set<String> knownMediaTypes = {
|
||||
anyImage,
|
||||
..._knownOpaqueImages,
|
||||
...alphaImages,
|
||||
...rawImages,
|
||||
...undecodableImages,
|
||||
anyVideo,
|
||||
..._knownVideos,
|
||||
};
|
||||
|
||||
static bool isImage(String mimeType) => mimeType.startsWith('image');
|
||||
|
||||
|
|
|
@ -248,7 +248,9 @@ class PlatformMediaFileService implements MediaFileService {
|
|||
});
|
||||
if (result != null) return result as Uint8List;
|
||||
} on PlatformException catch (e, stack) {
|
||||
await reportService.recordError(e, stack);
|
||||
if (!MimeTypes.knownMediaTypes.contains(mimeType) && MimeTypes.isVisual(mimeType)) {
|
||||
await reportService.recordError(e, stack);
|
||||
}
|
||||
}
|
||||
return Uint8List(0);
|
||||
},
|
||||
|
|
|
@ -200,7 +200,14 @@ class PlatformStorageService implements StorageService {
|
|||
// `await` here, so that `completeError` will be caught below
|
||||
return await completer.future;
|
||||
} on PlatformException catch (e, stack) {
|
||||
await reportService.recordError(e, stack);
|
||||
final message = e.message;
|
||||
// mute issue in the specific case when an item:
|
||||
// 1) is a Media Store `file` content,
|
||||
// 2) has no `images` or `video` entry,
|
||||
// 3) is in a restricted directory
|
||||
if (message == null || !message.contains('/external/file/')) {
|
||||
await reportService.recordError(e, stack);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue