diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/MetadataFetchHandler.kt b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/MetadataFetchHandler.kt index bfb96d900..c1e4c2ae4 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/MetadataFetchHandler.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/MetadataFetchHandler.kt @@ -636,16 +636,16 @@ class MetadataFetchHandler(private val context: Context) : MethodCallHandler { return } - val saveExposureTime: (value: Rational) -> Unit = { + val saveExposureTime = fun(value: Rational) { // `TAG_EXPOSURE_TIME` as a string is sometimes a ratio, sometimes a decimal // so we explicitly request it as a rational (e.g. 1/100, 1/14, 71428571/1000000000, 4000/1000, 2000000000/500000000) // and process it to make sure the numerator is `1` when the ratio value is less than 1 - val num = it.numerator - val denom = it.denominator + val num = value.numerator + val denom = value.denominator metadataMap[KEY_EXPOSURE_TIME] = when { - num >= denom -> "${it.toSimpleString(true)}″" + num >= denom -> "${value.toSimpleString(true)}″" num != 1L && num != 0L -> Rational(1, (denom / num.toDouble()).roundToLong()).toString() - else -> it.toString() + else -> value.toString() } } diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/ExifInterfaceHelper.kt b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/ExifInterfaceHelper.kt index 3817c7b38..102387552 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/ExifInterfaceHelper.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/ExifInterfaceHelper.kt @@ -223,7 +223,9 @@ object ExifInterfaceHelper { val dirs = DirType.values().map { Pair(it, it.createDirectory()) }.toMap() // exclude Exif directory when it only includes image size - val isUselessExif: (Map) -> Boolean = { it.size == 2 && it.containsKey("Image Height") && it.containsKey("Image Width") } + val isUselessExif = fun(it: Map): Boolean { + return it.size == 2 && it.containsKey("Image Height") && it.containsKey("Image Width") + } return HashMap>().apply { put("Exif", describeDir(exif, dirs, baseTags).takeUnless(isUselessExif) ?: hashMapOf()) diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/model/provider/MediaStoreImageProvider.kt b/android/app/src/main/kotlin/deckers/thibault/aves/model/provider/MediaStoreImageProvider.kt index 5f8c9dbfc..be6731028 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/model/provider/MediaStoreImageProvider.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/model/provider/MediaStoreImageProvider.kt @@ -45,15 +45,15 @@ class MediaStoreImageProvider : ImageProvider() { fetchFrom(context, isModified, handleNewEntry, VIDEO_CONTENT_URI, VIDEO_PROJECTION) } + // the provided URI can point to the wrong media collection, + // e.g. a GIF image with the URI `content://media/external/video/media/[ID]` + // so the effective entry URI may not match the provided URI override fun fetchSingle(context: Context, uri: Uri, sourceMimeType: String?, callback: ImageOpCallback) { var found = false val fetched = arrayListOf() val id = uri.tryParseId() - val onSuccess = fun(entry: FieldMap) { - entry["uri"] = uri.toString() - fetched.add(entry) - } - val alwaysValid = { _: Int, _: Int -> true } + val alwaysValid: NewEntryChecker = fun(_: Int, _: Int): Boolean = true + val onSuccess: NewEntryHandler = fun(entry: FieldMap) { fetched.add(entry) } if (id != null) { if (!found && (sourceMimeType == null || isImage(sourceMimeType))) { val contentUri = ContentUris.withAppendedId(IMAGE_CONTENT_URI, id)