diff --git a/lib/models/file.dart b/lib/models/file.dart index 2477c2750..0a821f038 100644 --- a/lib/models/file.dart +++ b/lib/models/file.dart @@ -193,8 +193,7 @@ class File extends EnteFile { if ((fileType == FileType.image || fileType == FileType.video) && Platform.isAndroid) { //Fix for missing location data in lower android versions. - final exifLocation = - (await gpsDataFromExif(exifData)).toLocationObj(); + final exifLocation = locationFromExif(exifData); if (exifLocation?.latitude != null && exifLocation?.longitude != null) { location = exifLocation; diff --git a/lib/ui/viewer/file/file_details_widget.dart b/lib/ui/viewer/file/file_details_widget.dart index b75be34df..d0b41b098 100644 --- a/lib/ui/viewer/file/file_details_widget.dart +++ b/lib/ui/viewer/file/file_details_widget.dart @@ -60,11 +60,9 @@ class _FileDetailsWidgetState extends State { _currentUserID = Configuration.instance.getUserID()!; _isImage = widget.file.fileType == FileType.image || widget.file.fileType == FileType.livePhoto; - _exifNotifier.addListener(() async { + _exifNotifier.addListener(() { if (_exifNotifier.value != null) { - _hasLocationData().then( - (value) => hasLocationDataNotifer.value = value, - ); + hasLocationDataNotifer.value = _hasLocationData(); } }); if (_isImage) { @@ -234,7 +232,7 @@ class _FileDetailsWidgetState extends State { ); } - Future _hasLocationData() async { + bool _hasLocationData() { final fileLocation = widget.file.location; bool hasLocation = (fileLocation != null && fileLocation.latitude != null && @@ -245,14 +243,13 @@ class _FileDetailsWidgetState extends State { //missing and the EXIF has location data. This is only happens for a //certain specific minority of devices. if (!hasLocation) { - hasLocation = await _setLocationDataFromExif(); + hasLocation = _setLocationDataFromExif(); } return hasLocation; } - Future _setLocationDataFromExif() async { - final locationDataFromExif = - (await gpsDataFromExif(_exifNotifier.value!)).toLocationObj(); + bool _setLocationDataFromExif() { + final locationDataFromExif = locationFromExif(_exifNotifier.value!); if (locationDataFromExif?.latitude != null && locationDataFromExif?.longitude != null) { widget.file.location = locationDataFromExif; diff --git a/lib/utils/exif_util.dart b/lib/utils/exif_util.dart index 0fc0a888e..e1e58b9ea 100644 --- a/lib/utils/exif_util.dart +++ b/lib/utils/exif_util.dart @@ -4,6 +4,7 @@ import 'package:exif/exif.dart'; import 'package:intl/intl.dart'; import 'package:logging/logging.dart'; import 'package:photos/models/file.dart'; +import "package:photos/models/location/location.dart"; import "package:photos/services/location_service.dart"; import 'package:photos/utils/file_util.dart'; @@ -62,7 +63,11 @@ Future getCreationTimeFromEXIF( return null; } -Future gpsDataFromExif(Map exif) async { +Location? locationFromExif(Map exif) { + return _gpsDataFromExif(exif).toLocationObj(); +} + +GPSData _gpsDataFromExif(Map exif) { final Map exifLocationData = { "lat": null, "long": null,