@@ -80,9 +80,9 @@ import fr.free.nrw.commons.MediaDataExtractor
80
80
import fr.free.nrw.commons.R
81
81
import fr.free.nrw.commons.Utils
82
82
import fr.free.nrw.commons.actions.ThanksClient
83
- import fr.free.nrw.commons.auth.AccountUtil
84
83
import fr.free.nrw.commons.auth.SessionManager
85
84
import fr.free.nrw.commons.auth.csrf.InvalidLoginTokenException
85
+ import fr.free.nrw.commons.auth.getUserName
86
86
import fr.free.nrw.commons.category.CATEGORY_NEEDING_CATEGORIES
87
87
import fr.free.nrw.commons.category.CATEGORY_UNCATEGORISED
88
88
import fr.free.nrw.commons.category.CategoryClient
@@ -495,8 +495,8 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
495
495
enableProgressBar()
496
496
}
497
497
498
- if (AccountUtil . getUserName(context) != null && media != null && AccountUtil . getUserName(
499
- context
498
+ if (getUserName(requireContext()) != null && media != null && getUserName(
499
+ requireContext()
500
500
) == media!! .author
501
501
) {
502
502
binding.sendThanks.visibility = View .GONE
@@ -610,7 +610,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
610
610
}
611
611
612
612
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) {
614
614
binding.nominateDeletion.visibility = View .GONE
615
615
binding.nominatedDeletionBanner.visibility = View .GONE
616
616
} else if (deletionPageExists) {
@@ -1050,16 +1050,19 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
1050
1050
defaultLatitude = media!! .coordinates!! .latitude
1051
1051
defaultLongitude = media!! .coordinates!! .longitude
1052
1052
} 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
1056
1056
} else {
1057
- val lastLocation: Array <String > = applicationKvStore.getString(
1057
+ val lastLocation: Array <String >? = applicationKvStore.getString(
1058
1058
UploadMediaDetailFragment .LAST_LOCATION ,
1059
1059
(" $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
+ }
1063
1066
}
1064
1067
}
1065
1068
@@ -1068,8 +1071,8 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
1068
1071
LocationPicker .IntentBuilder ()
1069
1072
.defaultLocation(CameraPosition (defaultLatitude, defaultLongitude, 16.0 ))
1070
1073
.activityKey(" MediaActivity" )
1071
- .media(media)
1072
- .build(activity )
1074
+ .media(media!! )
1075
+ .build(requireActivity() )
1073
1076
)
1074
1077
}
1075
1078
@@ -1572,7 +1575,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
1572
1575
1573
1576
@SuppressLint(" StringFormatInvalid" )
1574
1577
fun onDeleteButtonClicked () {
1575
- if (AccountUtil . getUserName(context) != null && AccountUtil . getUserName(context ) == media!! .author) {
1578
+ if (getUserName(requireContext()) != null && getUserName(requireContext() ) == media!! .author) {
1576
1579
val languageAdapter: ArrayAdapter <String > = ArrayAdapter (
1577
1580
requireActivity(),
1578
1581
R .layout.simple_spinner_dropdown_list, reasonList
@@ -1599,7 +1602,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
1599
1602
if (isDeleted) {
1600
1603
dialog!! .getButton(AlertDialog .BUTTON_POSITIVE ).isEnabled = false
1601
1604
}
1602
- } else if (AccountUtil . getUserName(context ) != null ) {
1605
+ } else if (getUserName(requireContext() ) != null ) {
1603
1606
val input = EditText (activity)
1604
1607
input.requestFocus()
1605
1608
val d: AlertDialog ? = showAlertDialog(
@@ -1886,7 +1889,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
1886
1889
if (media.coordinates == null ) {
1887
1890
return getString(R .string.media_detail_coordinates_empty)
1888
1891
}
1889
- return media.coordinates!! .prettyCoordinateString
1892
+ return media.coordinates!! .getPrettyCoordinateString()
1890
1893
}
1891
1894
1892
1895
override fun updateCategoryDisplay (categories : List <String >? ): Boolean {
0 commit comments