safer xmp parsing
This commit is contained in:
parent
c4c95280ef
commit
44b6d30a49
5 changed files with 33 additions and 22 deletions
|
@ -211,12 +211,23 @@ public class MetadataHandler implements MethodChannel.MethodCallHandler {
|
||||||
}
|
}
|
||||||
metadataMap.put("xmpSubjects", sb.toString());
|
metadataMap.put("xmpSubjects", sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// double check retrieved items as the property sometimes is reported to exist but it is actually null
|
||||||
|
String titleDescription = null;
|
||||||
if (xmpMeta.doesPropertyExist(XMP_DC_SCHEMA_NS, XMP_TITLE_PROP_NAME)) {
|
if (xmpMeta.doesPropertyExist(XMP_DC_SCHEMA_NS, XMP_TITLE_PROP_NAME)) {
|
||||||
XMPProperty item = xmpMeta.getLocalizedText(XMP_DC_SCHEMA_NS, XMP_TITLE_PROP_NAME, XMP_GENERIC_LANG, XMP_SPECIFIC_LANG);
|
XMPProperty item = xmpMeta.getLocalizedText(XMP_DC_SCHEMA_NS, XMP_TITLE_PROP_NAME, XMP_GENERIC_LANG, XMP_SPECIFIC_LANG);
|
||||||
metadataMap.put("xmpTitleDescription", item.getValue());
|
if (item != null) {
|
||||||
} else if (xmpMeta.doesPropertyExist(XMP_DC_SCHEMA_NS, XMP_DESCRIPTION_PROP_NAME)) {
|
titleDescription = item.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (titleDescription == null && xmpMeta.doesPropertyExist(XMP_DC_SCHEMA_NS, XMP_DESCRIPTION_PROP_NAME)) {
|
||||||
XMPProperty item = xmpMeta.getLocalizedText(XMP_DC_SCHEMA_NS, XMP_DESCRIPTION_PROP_NAME, XMP_GENERIC_LANG, XMP_SPECIFIC_LANG);
|
XMPProperty item = xmpMeta.getLocalizedText(XMP_DC_SCHEMA_NS, XMP_DESCRIPTION_PROP_NAME, XMP_GENERIC_LANG, XMP_SPECIFIC_LANG);
|
||||||
metadataMap.put("xmpTitleDescription", item.getValue());
|
if (item != null) {
|
||||||
|
titleDescription = item.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (titleDescription != null) {
|
||||||
|
metadataMap.put("xmpTitleDescription", titleDescription);
|
||||||
}
|
}
|
||||||
} catch (XMPException e) {
|
} catch (XMPException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -11,7 +11,7 @@ class ImageFileService {
|
||||||
try {
|
try {
|
||||||
await platform.invokeMethod('getImageEntries');
|
await platform.invokeMethod('getImageEntries');
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('getImageEntries failed with exception=${e.message}');
|
debugPrint('getImageEntries failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class ImageFileService {
|
||||||
}) as Map;
|
}) as Map;
|
||||||
return ImageEntry.fromMap(result);
|
return ImageEntry.fromMap(result);
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('getImageEntry failed with exception=${e.message}');
|
debugPrint('getImageEntry failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ class ImageFileService {
|
||||||
});
|
});
|
||||||
return result as Uint8List;
|
return result as Uint8List;
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('getImage failed with exception=${e.message}');
|
debugPrint('getImage failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
return Uint8List(0);
|
return Uint8List(0);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ class ImageFileService {
|
||||||
});
|
});
|
||||||
return result as Uint8List;
|
return result as Uint8List;
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('getThumbnail failed with exception=${e.message}');
|
debugPrint('getThumbnail failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Uint8List(0);
|
return Uint8List(0);
|
||||||
|
@ -65,7 +65,7 @@ class ImageFileService {
|
||||||
'uri': uri,
|
'uri': uri,
|
||||||
});
|
});
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('cancelGetThumbnail failed with exception=${e.message}');
|
debugPrint('cancelGetThumbnail failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class ImageFileService {
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('delete failed with exception=${e.message}');
|
debugPrint('delete failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ class ImageFileService {
|
||||||
}) as Map;
|
}) as Map;
|
||||||
return result;
|
return result;
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('rename failed with exception=${e.message}');
|
debugPrint('rename failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class ImageFileService {
|
||||||
}) as Map;
|
}) as Map;
|
||||||
return result;
|
return result;
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('rotate failed with exception=${e.message}');
|
debugPrint('rotate failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ class MetadataService {
|
||||||
});
|
});
|
||||||
return result as Map;
|
return result as Map;
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('getAllMetadata failed with exception=${e.message}');
|
debugPrint('getAllMetadata failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class MetadataService {
|
||||||
result['contentId'] = entry.contentId;
|
result['contentId'] = entry.contentId;
|
||||||
return CatalogMetadata.fromMap(result);
|
return CatalogMetadata.fromMap(result);
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('getCatalogMetadata failed with exception=${e.message}');
|
debugPrint('getCatalogMetadata failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ class MetadataService {
|
||||||
}) as Map;
|
}) as Map;
|
||||||
return OverlayMetadata.fromMap(result);
|
return OverlayMetadata.fromMap(result);
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('getOverlayMetadata failed with exception=${e.message}');
|
debugPrint('getOverlayMetadata failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ class AndroidAppService {
|
||||||
final result = await platform.invokeMethod('getAppNames');
|
final result = await platform.invokeMethod('getAppNames');
|
||||||
return result as Map;
|
return result as Map;
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('getAppNames failed with exception=${e.message}');
|
debugPrint('getAppNames failed with code=${e.code}, exception=${e.message}, details=${e.details}}');
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class AndroidAppService {
|
||||||
});
|
});
|
||||||
return result as Uint8List;
|
return result as Uint8List;
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('getAppIcon failed with exception=${e.message}');
|
debugPrint('getAppIcon failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
return Uint8List(0);
|
return Uint8List(0);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ class AndroidAppService {
|
||||||
'mimeType': mimeType,
|
'mimeType': mimeType,
|
||||||
});
|
});
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('edit failed with exception=${e.message}');
|
debugPrint('edit failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class AndroidAppService {
|
||||||
'mimeType': mimeType,
|
'mimeType': mimeType,
|
||||||
});
|
});
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('open failed with exception=${e.message}');
|
debugPrint('open failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class AndroidAppService {
|
||||||
'geoUri': geoUri,
|
'geoUri': geoUri,
|
||||||
});
|
});
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('openMap failed with exception=${e.message}');
|
debugPrint('openMap failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class AndroidAppService {
|
||||||
'mimeType': mimeType,
|
'mimeType': mimeType,
|
||||||
});
|
});
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('setAs failed with exception=${e.message}');
|
debugPrint('setAs failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class AndroidAppService {
|
||||||
'mimeType': mimeType,
|
'mimeType': mimeType,
|
||||||
});
|
});
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('share failed with exception=${e.message}');
|
debugPrint('share failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ class ViewerService {
|
||||||
// return nullable map with: 'uri' 'mimeType'
|
// return nullable map with: 'uri' 'mimeType'
|
||||||
return await platform.invokeMethod('getSharedEntry') as Map;
|
return await platform.invokeMethod('getSharedEntry') as Map;
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
debugPrint('getSharedEntry failed with exception=${e.message}');
|
debugPrint('getSharedEntry failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue