mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Fix edit button shown when image has no location (#6029)
Changed the commons.filepicker.UploadableFile's hasLocation method to use the existing ImageCoordinates class for detecting the presence of geolocation in an image's exif
This commit is contained in:
parent
c1acdbe31a
commit
235e8cdba2
1 changed files with 2 additions and 3 deletions
|
|
@ -10,6 +10,7 @@ import android.os.Parcelable
|
||||||
import androidx.exifinterface.media.ExifInterface
|
import androidx.exifinterface.media.ExifInterface
|
||||||
|
|
||||||
import fr.free.nrw.commons.upload.FileUtils
|
import fr.free.nrw.commons.upload.FileUtils
|
||||||
|
import fr.free.nrw.commons.upload.ImageCoordinates
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
@ -87,9 +88,7 @@ class UploadableFile : Parcelable {
|
||||||
fun hasLocation(): Boolean {
|
fun hasLocation(): Boolean {
|
||||||
return try {
|
return try {
|
||||||
val exif = ExifInterface(file.absolutePath)
|
val exif = ExifInterface(file.absolutePath)
|
||||||
val latitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE)
|
ImageCoordinates(exif, null).imageCoordsExists
|
||||||
val longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE)
|
|
||||||
latitude != null && longitude != null
|
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Timber.tag("UploadableFile").d(e)
|
Timber.tag("UploadableFile").d(e)
|
||||||
false
|
false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue