Skip to content

Commit a647e61

Browse files
fix merge conflict
Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
1 parent 3adb6a2 commit a647e61

File tree

3 files changed

+90
-793
lines changed

3 files changed

+90
-793
lines changed

app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt

+19-16
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ import fr.free.nrw.commons.MediaDataExtractor
8080
import fr.free.nrw.commons.R
8181
import fr.free.nrw.commons.Utils
8282
import fr.free.nrw.commons.actions.ThanksClient
83-
import fr.free.nrw.commons.auth.AccountUtil
8483
import fr.free.nrw.commons.auth.SessionManager
8584
import fr.free.nrw.commons.auth.csrf.InvalidLoginTokenException
85+
import fr.free.nrw.commons.auth.getUserName
8686
import fr.free.nrw.commons.category.CATEGORY_NEEDING_CATEGORIES
8787
import fr.free.nrw.commons.category.CATEGORY_UNCATEGORISED
8888
import fr.free.nrw.commons.category.CategoryClient
@@ -495,8 +495,8 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
495495
enableProgressBar()
496496
}
497497

498-
if (AccountUtil.getUserName(context) != null && media != null && AccountUtil.getUserName(
499-
context
498+
if (getUserName(requireContext()) != null && media != null && getUserName(
499+
requireContext()
500500
) == media!!.author
501501
) {
502502
binding.sendThanks.visibility = View.GONE
@@ -610,7 +610,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
610610
}
611611

612612
private fun onDeletionPageExists(deletionPageExists: Boolean) {
613-
if (AccountUtil.getUserName(context) == null && AccountUtil.getUserName(context) != media!!.author) {
613+
if (getUserName(requireContext()) == null && getUserName(requireContext()) != media!!.author) {
614614
binding.nominateDeletion.visibility = View.GONE
615615
binding.nominatedDeletionBanner.visibility = View.GONE
616616
} else if (deletionPageExists) {
@@ -1050,16 +1050,19 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
10501050
defaultLatitude = media!!.coordinates!!.latitude
10511051
defaultLongitude = media!!.coordinates!!.longitude
10521052
} else {
1053-
if (locationManager.lastLocation != null) {
1054-
defaultLatitude = locationManager.lastLocation.latitude
1055-
defaultLongitude = locationManager.lastLocation.longitude
1053+
if (locationManager.getLastLocation() != null) {
1054+
defaultLatitude = locationManager.getLastLocation()!!.latitude
1055+
defaultLongitude = locationManager.getLastLocation()!!.longitude
10561056
} else {
1057-
val lastLocation: Array<String> = applicationKvStore.getString(
1057+
val lastLocation: Array<String>? = applicationKvStore.getString(
10581058
UploadMediaDetailFragment.LAST_LOCATION,
10591059
("$defaultLatitude,$defaultLongitude")
1060-
).split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
1061-
defaultLatitude = lastLocation[0].toDouble()
1062-
defaultLongitude = lastLocation[1].toDouble()
1060+
)?.split(",".toRegex())?.dropLastWhile { it.isEmpty() }?.toTypedArray()
1061+
1062+
if (lastLocation != null) {
1063+
defaultLatitude = lastLocation[0].toDouble()
1064+
defaultLongitude = lastLocation[1].toDouble()
1065+
}
10631066
}
10641067
}
10651068

@@ -1068,8 +1071,8 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
10681071
LocationPicker.IntentBuilder()
10691072
.defaultLocation(CameraPosition(defaultLatitude, defaultLongitude, 16.0))
10701073
.activityKey("MediaActivity")
1071-
.media(media)
1072-
.build(activity)
1074+
.media(media!!)
1075+
.build(requireActivity())
10731076
)
10741077
}
10751078

@@ -1572,7 +1575,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
15721575

15731576
@SuppressLint("StringFormatInvalid")
15741577
fun onDeleteButtonClicked() {
1575-
if (AccountUtil.getUserName(context) != null && AccountUtil.getUserName(context) == media!!.author) {
1578+
if (getUserName(requireContext()) != null && getUserName(requireContext()) == media!!.author) {
15761579
val languageAdapter: ArrayAdapter<String> = ArrayAdapter(
15771580
requireActivity(),
15781581
R.layout.simple_spinner_dropdown_list, reasonList
@@ -1599,7 +1602,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
15991602
if (isDeleted) {
16001603
dialog!!.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
16011604
}
1602-
} else if (AccountUtil.getUserName(context) != null) {
1605+
} else if (getUserName(requireContext()) != null) {
16031606
val input = EditText(activity)
16041607
input.requestFocus()
16051608
val d: AlertDialog? = showAlertDialog(
@@ -1886,7 +1889,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
18861889
if (media.coordinates == null) {
18871890
return getString(R.string.media_detail_coordinates_empty)
18881891
}
1889-
return media.coordinates!!.prettyCoordinateString
1892+
return media.coordinates!!.getPrettyCoordinateString()
18901893
}
18911894

18921895
override fun updateCategoryDisplay(categories: List<String>?): Boolean {

0 commit comments

Comments
 (0)