Skip to content

Commit 235e8cd

Browse files
authored
Fix edit button shown when image has no location (commons-app#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
1 parent c1acdbe commit 235e8cd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

app/src/main/java/fr/free/nrw/commons/filepicker/UploadableFile.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.os.Parcelable
1010
import androidx.exifinterface.media.ExifInterface
1111

1212
import fr.free.nrw.commons.upload.FileUtils
13+
import fr.free.nrw.commons.upload.ImageCoordinates
1314
import java.io.File
1415
import java.io.IOException
1516
import java.util.Date
@@ -87,9 +88,7 @@ class UploadableFile : Parcelable {
8788
fun hasLocation(): Boolean {
8889
return try {
8990
val exif = ExifInterface(file.absolutePath)
90-
val latitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE)
91-
val longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE)
92-
latitude != null && longitude != null
91+
ImageCoordinates(exif, null).imageCoordsExists
9392
} catch (e: IOException) {
9493
Timber.tag("UploadableFile").d(e)
9594
false

0 commit comments

Comments
 (0)