@@ -21,6 +21,8 @@ import androidx.core.content.ContextCompat
2121import androidx.core.os.bundleOf
2222import androidx.exifinterface.media.ExifInterface
2323import androidx.recyclerview.widget.LinearLayoutManager
24+ import androidx.viewpager.widget.ViewPager
25+ import androidx.viewpager2.widget.ViewPager2
2426import fr.free.nrw.commons.CameraPosition
2527import fr.free.nrw.commons.R
2628import fr.free.nrw.commons.contributions.MainActivity
@@ -215,21 +217,7 @@ class UploadMediaDetailFragment : UploadBaseFragment(), UploadMediaDetailsContra
215217 btnPrevious.alpha = 1.0f
216218 }
217219
218- // If the image EXIF data contains the location, show the map icon with a green tick
219- if (inAppPictureLocation != null || (uploadableFile != null && uploadableFile!! .hasLocation())) {
220- val mapTick =
221- ContextCompat .getDrawable(requireContext(), R .drawable.ic_map_available_20dp)
222- locationImageView.setImageDrawable(mapTick)
223- locationTextView.setText(R .string.edit_location)
224- } else {
225- // Otherwise, show the map icon with a red question mark
226- val mapQuestionMark = ContextCompat .getDrawable(
227- requireContext(),
228- R .drawable.ic_map_not_available_20dp
229- )
230- locationImageView.setImageDrawable(mapQuestionMark)
231- locationTextView.setText(R .string.add_location)
232- }
220+ updateMapTickIcon(0 )
233221
234222 // If this is the last media, we have nothing to copy, lets not show the button
235223 btnCopySubsequentMedia.visibility =
@@ -323,6 +311,7 @@ class UploadMediaDetailFragment : UploadBaseFragment(), UploadMediaDetailsContra
323311 )
324312 binding.locationImageView.setImageDrawable(mapTick)
325313 binding.locationTextView.setText(R .string.edit_location)
314+ updateMapTickIcon(0 )
326315 }
327316
328317 override fun onNegativeResponse () {
@@ -437,6 +426,7 @@ class UploadMediaDetailFragment : UploadBaseFragment(), UploadMediaDetailsContra
437426 if (fragmentCallback == null ) {
438427 return
439428 }
429+ updateMapTickIcon(this .indexOfFragment)
440430 presenter.fetchTitleAndDescription(indexOfFragment)
441431 if (showNearbyFound) {
442432 if (UploadActivity .nearbyPopupAnswers!! .containsKey(nearbyPlace!! )) {
@@ -718,6 +708,8 @@ class UploadMediaDetailFragment : UploadBaseFragment(), UploadMediaDetailsContra
718708 binding.locationTextView.setText(R .string.add_location)
719709 }
720710
711+ updateMapTickIcon(this .indexOfFragment) // Refresh UI immediately
712+
721713 editableUploadItem!! .gpsCoords!! .decLatitude = 0.0
722714 editableUploadItem!! .gpsCoords!! .decLongitude = 0.0
723715 editableUploadItem!! .gpsCoords!! .imageCoordsExists = false
@@ -871,6 +863,32 @@ class UploadMediaDetailFragment : UploadBaseFragment(), UploadMediaDetailsContra
871863 Toast .makeText(context, R .string.copied_successfully, Toast .LENGTH_SHORT ).show()
872864 }
873865
866+ private fun updateMapTickIcon (index : Int ) {
867+ if (_binding == null ) return
868+
869+ editableUploadItem = presenter.getUploadItem(index)
870+
871+ val hasLocation = (! hasUserRemovedLocation) && (
872+ inAppPictureLocation != null ||
873+ (uploadableFile != null && uploadableFile!! .hasLocation()) ||
874+ (editableUploadItem?.gpsCoords?.imageCoordsExists == true &&
875+ editableUploadItem?.gpsCoords?.decimalCoords != null )
876+ )
877+
878+ binding.locationImageView.setImageDrawable(
879+ ContextCompat .getDrawable(
880+ requireContext(),
881+ if (hasLocation) R .drawable.ic_map_available_20dp
882+ else R .drawable.ic_map_not_available_20dp
883+ )
884+ )
885+
886+ binding.locationTextView.setText(
887+ if (hasLocation) R .string.edit_location
888+ else R .string.add_location
889+ )
890+ }
891+
874892 override fun onSaveInstanceState (outState : Bundle ) {
875893 super .onSaveInstanceState(outState)
876894
0 commit comments