converted/Migrated

This commit is contained in:
Sujal-Gupta-SG 2025-02-03 18:30:07 +05:30
parent 6c8e1da420
commit c199e5278b

View file

@ -1,7 +1,6 @@
package fr.free.nrw.commons.nearby.fragments package fr.free.nrw.commons.nearby.fragments
import android.Manifest.permission import android.Manifest.permission
import android.fr.free.nrw.commons.R
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.ProgressDialog import android.app.ProgressDialog
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
@ -51,7 +50,6 @@ import com.jakewharton.rxbinding2.view.RxView
import com.jakewharton.rxbinding3.appcompat.queryTextChanges import com.jakewharton.rxbinding3.appcompat.queryTextChanges
import fr.free.nrw.commons.CommonsApplication import fr.free.nrw.commons.CommonsApplication
import fr.free.nrw.commons.MapController.NearbyPlacesInfo import fr.free.nrw.commons.MapController.NearbyPlacesInfo
import fr.free.nrw.commons.R
import fr.free.nrw.commons.Utils import fr.free.nrw.commons.Utils
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao
import fr.free.nrw.commons.contributions.ContributionController import fr.free.nrw.commons.contributions.ContributionController
@ -127,7 +125,7 @@ import javax.inject.Named
import kotlin.concurrent.Volatile import kotlin.concurrent.Volatile
class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentFragmentContract.View, class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentFragmentContract.View,
WikidataP18EditListener, LocationUpdateListener, LocationPermissionCallback, ItemClickListener { WikidataP18EditListener, LocationUpdateListener, LocationPermissionCallback, ItemClickListener {
var binding: FragmentNearbyParentBinding? = null var binding: FragmentNearbyParentBinding? = null
@ -240,36 +238,50 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
private val galleryPickLauncherForResult = private val galleryPickLauncherForResult =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
controller?.handleActivityResultWithCallback(requireActivity(), object : FilePicker.HandleActivityResult { controller?.handleActivityResultWithCallback(
override fun onHandleActivityResult(callbacks: FilePicker.Callbacks) { requireActivity(),
// Handle the result from the gallery object : FilePicker.HandleActivityResult {
controller?.onPictureReturnedFromGallery(result, requireActivity(), callbacks) override fun onHandleActivityResult(callbacks: FilePicker.Callbacks) {
} // Handle the result from the gallery
}) controller?.onPictureReturnedFromGallery(
result,
requireActivity(),
callbacks
)
}
})
} }
private val customSelectorLauncherForResult = private val customSelectorLauncherForResult =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult? -> registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult? ->
controller?.handleActivityResultWithCallback(requireActivity(), object : FilePicker.HandleActivityResult { controller?.handleActivityResultWithCallback(
override fun onHandleActivityResult(callbacks: FilePicker.Callbacks) { requireActivity(),
controller?.onPictureReturnedFromCustomSelector( object : FilePicker.HandleActivityResult {
result, override fun onHandleActivityResult(callbacks: FilePicker.Callbacks) {
requireActivity(), controller?.onPictureReturnedFromCustomSelector(
callbacks result,
) requireActivity(),
} callbacks
}) )
}
})
} }
private val cameraPickLauncherForResult = private val cameraPickLauncherForResult =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult? -> registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult? ->
controller?.handleActivityResultWithCallback(requireActivity(), object : FilePicker.HandleActivityResult { controller?.handleActivityResultWithCallback(
override fun onHandleActivityResult(callbacks: FilePicker.Callbacks) { requireActivity(),
controller?.onPictureReturnedFromCamera(result, requireActivity(), callbacks) object : FilePicker.HandleActivityResult {
} override fun onHandleActivityResult(callbacks: FilePicker.Callbacks) {
}) controller?.onPictureReturnedFromCamera(
result,
requireActivity(),
callbacks
)
}
})
} }
@ -309,8 +321,8 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
/** /**
* WLM URL * WLM URL
*/ */
val WLM_URL = "https://commons.wikimedia.org/wiki/Commons:Mobile_app/Contributing_to_WLM_using_the_app" val WLM_URL =
"https://commons.wikimedia.org/wiki/Commons:Mobile_app/Contributing_to_WLM_using_the_app"
override fun onCreateView( override fun onCreateView(
@ -360,16 +372,15 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
false false
} }
showInExploreButton.setOnMenuItemClickListener(object : OnMenuItemClickListener() { showInExploreButton.setOnMenuItemClickListener { item ->
fun onMenuItemClick(@NonNull item: MenuItem?): Boolean { (context as MainActivity).loadExploreMapFromNearby(
(context as MainActivity).loadExploreMapFromNearby( binding?.map?.zoomLevelDouble ?: 0.0, // Using safe calls to avoid NPE
binding!!.map.zoomLevelDouble, binding?.map?.mapCenter?.latitude ?: 0.0,
binding!!.map.mapCenter.latitude, binding?.map?.mapCenter?.longitude ?: 0.0
binding!!.map.mapCenter.longitude )
) return@setOnMenuItemClickListener true
return false }
}
})
saveAsGPXButton.setOnMenuItemClickListener { saveAsGPXButton.setOnMenuItemClickListener {
try { try {
@ -396,25 +407,26 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
// Initialize the launcher in the appropriate lifecycle method (e.g., onViewCreated) // Initialize the launcher in the appropriate lifecycle method (e.g., onViewCreated)
inAppCameraLocationPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { result -> inAppCameraLocationPermissionLauncher =
val areAllGranted = result.values.all { it } registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { result ->
val areAllGranted = result.values.all { it }
if (areAllGranted) { if (areAllGranted) {
controller?.locationPermissionCallback?.onLocationPermissionGranted() controller?.locationPermissionCallback?.onLocationPermissionGranted()
} else {
if (shouldShowRequestPermissionRationale(permission.ACCESS_FINE_LOCATION)) {
controller?.handleShowRationaleFlowCameraLocation(
requireActivity(),
inAppCameraLocationPermissionLauncher, // Reference it directly
cameraPickLauncherForResult
)
} else { } else {
controller?.locationPermissionCallback?.onLocationPermissionDenied( if (shouldShowRequestPermissionRationale(permission.ACCESS_FINE_LOCATION)) {
getString(fr.free.nrw.commons.R.string.in_app_camera_location_permission_denied) controller?.handleShowRationaleFlowCameraLocation(
) requireActivity(),
inAppCameraLocationPermissionLauncher, // Reference it directly
cameraPickLauncherForResult
)
} else {
controller?.locationPermissionCallback?.onLocationPermissionDenied(
getString(fr.free.nrw.commons.R.string.in_app_camera_location_permission_denied)
)
}
} }
} }
}
isDarkTheme = systemThemeUtils?.isDeviceInNightMode() == true isDarkTheme = systemThemeUtils?.isDeviceInNightMode() == true
if (Utils.isMonumentsEnabled(Date())) { if (Utils.isMonumentsEnabled(Date())) {
binding?.rlContainerWlmMonthMessage?.visibility = View.VISIBLE binding?.rlContainerWlmMonthMessage?.visibility = View.VISIBLE
@ -439,14 +451,16 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
initThemePreferences() initThemePreferences()
initViews() initViews()
presenter?.setActionListeners(applicationKvStore) presenter?.setActionListeners(applicationKvStore)
org.osmdroid.config.Configuration.getInstance().load(requireContext(), PreferenceManager.getDefaultSharedPreferences(requireContext())) org.osmdroid.config.Configuration.getInstance()
.load(requireContext(), PreferenceManager.getDefaultSharedPreferences(requireContext()))
// Use the Wikimedia tile server, rather than OpenStreetMap (Mapnik) // Use the Wikimedia tile server, rather than OpenStreetMap (Mapnik)
binding?.map?.setTileSource(TileSourceFactory.WIKIMEDIA) binding?.map?.setTileSource(TileSourceFactory.WIKIMEDIA)
binding?.map?.setTilesScaledToDpi(true) binding?.map?.setTilesScaledToDpi(true)
// Add referer HTTP header because the Wikimedia tile server requires it. // Add referer HTTP header because the Wikimedia tile server requires it.
org.osmdroid.config.Configuration.getInstance().getAdditionalHttpRequestProperties().put("Referer", "http://maps.wikimedia.org/") org.osmdroid.config.Configuration.getInstance().getAdditionalHttpRequestProperties()
.put("Referer", "http://maps.wikimedia.org/")
if (applicationKvStore?.getString("LastLocation") != null) { // Checking for last searched location if (applicationKvStore?.getString("LastLocation") != null) { // Checking for last searched location
val locationLatLng = applicationKvStore!!.getString("LastLocation")!!.split(",") val locationLatLng = applicationKvStore!!.getString("LastLocation")!!.split(",")
@ -463,7 +477,8 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
scaleBarOverlay.setBackgroundPaint(barPaint) scaleBarOverlay.setBackgroundPaint(barPaint)
scaleBarOverlay.enableScaleBar() scaleBarOverlay.enableScaleBar()
binding?.map?.overlays?.add(scaleBarOverlay) binding?.map?.overlays?.add(scaleBarOverlay)
binding?.map?.getZoomController()?.setVisibility(CustomZoomButtonsController.Visibility.NEVER) binding?.map?.getZoomController()
?.setVisibility(CustomZoomButtonsController.Visibility.NEVER)
binding?.map?.controller?.setZoom(ZOOM_LEVEL.toInt()) binding?.map?.controller?.setZoom(ZOOM_LEVEL.toInt())
// if we came from Explore map using 'Show in Nearby', load Explore map camera position // if we came from Explore map using 'Show in Nearby', load Explore map camera position
@ -499,10 +514,14 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
onResume() onResume()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
binding?.tvAttribution?.text = Html.fromHtml(getString(fr.free.nrw.commons.R.string.map_attribution), Html.FROM_HTML_MODE_LEGACY) binding?.tvAttribution?.text = Html.fromHtml(
getString(fr.free.nrw.commons.R.string.map_attribution),
Html.FROM_HTML_MODE_LEGACY
)
} else { } else {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
binding?.tvAttribution?.text = Html.fromHtml(getString(fr.free.nrw.commons.R.string.map_attribution)) binding?.tvAttribution?.text =
Html.fromHtml(getString(fr.free.nrw.commons.R.string.map_attribution))
} }
binding?.tvAttribution?.movementMethod = LinkMovementMethod.getInstance() binding?.tvAttribution?.movementMethod = LinkMovementMethod.getInstance()
@ -512,7 +531,10 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
val fragment = AdvanceQueryFragment() val fragment = AdvanceQueryFragment()
val bundle = Bundle() val bundle = Bundle()
try { try {
bundle.putString("query", FileUtils.readFromResource("/queries/radius_query_for_upload_wizard.rq")) bundle.putString(
"query",
FileUtils.readFromResource("/queries/radius_query_for_upload_wizard.rq")
)
} catch (e: IOException) { } catch (e: IOException) {
Timber.e(e) Timber.e(e)
} }
@ -554,9 +576,9 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
fun loadExploreMapData() { fun loadExploreMapData() {
// get fragment arguments // get fragment arguments
if (arguments != null) { if (arguments != null) {
prevZoom = arguments!!.getDouble("prev_zoom") prevZoom = requireArguments().getDouble("prev_zoom")
prevLatitude = arguments!!.getDouble("prev_latitude") prevLatitude = requireArguments().getDouble("prev_latitude")
prevLongitude = arguments!!.getDouble("prev_longitude") prevLongitude = requireArguments().getDouble("prev_longitude")
} }
} }
@ -580,7 +602,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
requireContext().resources.getColor(fr.free.nrw.commons.R.color.contributionListDarkBackground) requireContext().resources.getColor(fr.free.nrw.commons.R.color.contributionListDarkBackground)
) )
binding!!.nearbyFilterList.checkboxTriStates.setTextColor( binding!!.nearbyFilterList.checkboxTriStates.setTextColor(
requireContext().resources.getColor(android.fr.free.nrw.commons.R.color.white) requireContext().resources.getColor(fr.free.nrw.commons.R.color.white)
) )
binding!!.nearbyFilterList.checkboxTriStates.setTextColor( binding!!.nearbyFilterList.checkboxTriStates.setTextColor(
requireContext().resources.getColor(fr.free.nrw.commons.R.color.white) requireContext().resources.getColor(fr.free.nrw.commons.R.color.white)
@ -715,7 +737,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
} else { } else {
lastKnownLocation = defaultLatLng lastKnownLocation = defaultLatLng
} }
if (binding?.map ?: != null && !isCameFromExploreMap()) { if (binding!!.map != null && !isCameFromExploreMap()) {
moveCameraToPosition( moveCameraToPosition(
GeoPoint(lastKnownLocation!!.latitude, lastKnownLocation!!.longitude) GeoPoint(lastKnownLocation!!.latitude, lastKnownLocation!!.longitude)
) )
@ -940,8 +962,10 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
private fun loadAnimations() { private fun loadAnimations() {
fab_open = AnimationUtils.loadAnimation(activity, fr.free.nrw.commons.R.anim.fab_open) fab_open = AnimationUtils.loadAnimation(activity, fr.free.nrw.commons.R.anim.fab_open)
fab_close = AnimationUtils.loadAnimation(activity, fr.free.nrw.commons.R.anim.fab_close) fab_close = AnimationUtils.loadAnimation(activity, fr.free.nrw.commons.R.anim.fab_close)
rotate_forward = AnimationUtils.loadAnimation(activity, fr.free.nrw.commons.R.anim.rotate_forward) rotate_forward =
rotate_backward = AnimationUtils.loadAnimation(activity, fr.free.nrw.commons.R.anim.rotate_backward) AnimationUtils.loadAnimation(activity, fr.free.nrw.commons.R.anim.rotate_forward)
rotate_backward =
AnimationUtils.loadAnimation(activity, fr.free.nrw.commons.R.anim.rotate_backward)
} }
/** /**
@ -953,7 +977,8 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
"place", binding!!.bottomSheetDetails.title.text.toString(), "place", binding!!.bottomSheetDetails.title.text.toString(),
context context
) )
Toast.makeText(context, fr.free.nrw.commons.R.string.text_copy, Toast.LENGTH_SHORT).show() Toast.makeText(context, fr.free.nrw.commons.R.string.text_copy, Toast.LENGTH_SHORT)
.show()
true true
} }
@ -1327,7 +1352,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
Timber.d(throwable) Timber.d(throwable)
showErrorMessage( showErrorMessage(
getString(fr.free.nrw.commons.R.string.error_fetching_nearby_places) getString(fr.free.nrw.commons.R.string.error_fetching_nearby_places)
+ throwable.localizedMessage + throwable.localizedMessage
) )
setProgressBarVisibility(false) setProgressBarVisibility(false)
presenter!!.lockUnlockNearby(false) presenter!!.lockUnlockNearby(false)
@ -1371,7 +1396,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
Timber.d(throwable) Timber.d(throwable)
showErrorMessage( showErrorMessage(
getString(fr.free.nrw.commons.R.string.error_fetching_nearby_places) getString(fr.free.nrw.commons.R.string.error_fetching_nearby_places)
+ throwable.localizedMessage + throwable.localizedMessage
) )
setProgressBarVisibility(false) setProgressBarVisibility(false)
presenter!!.lockUnlockNearby(false) presenter!!.lockUnlockNearby(false)
@ -1379,6 +1404,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
}) })
) )
} }
fun saveFile(string: String, fileName: String?): Boolean { fun saveFile(string: String, fileName: String?): Boolean {
if (!isExternalStorageWritable) { if (!isExternalStorageWritable) {
return false return false
@ -1488,7 +1514,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
Timber.d(throwable) Timber.d(throwable)
showErrorMessage( showErrorMessage(
getString(fr.free.nrw.commons.R.string.could_not_load_place_data) getString(fr.free.nrw.commons.R.string.could_not_load_place_data)
+ throwable.localizedMessage + throwable.localizedMessage
) )
}) })
) )
@ -1538,7 +1564,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
Timber.d(throwable) Timber.d(throwable)
showErrorMessage( showErrorMessage(
getString(fr.free.nrw.commons.R.string.error_fetching_nearby_places) getString(fr.free.nrw.commons.R.string.error_fetching_nearby_places)
+ throwable.localizedMessage + throwable.localizedMessage
) )
setProgressBarVisibility(false) setProgressBarVisibility(false)
presenter!!.lockUnlockNearby(false) presenter!!.lockUnlockNearby(false)
@ -1599,7 +1625,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
Timber.e(throwable) Timber.e(throwable)
showErrorMessage( showErrorMessage(
getString(fr.free.nrw.commons.R.string.error_fetching_nearby_places) getString(fr.free.nrw.commons.R.string.error_fetching_nearby_places)
+ throwable.localizedMessage + throwable.localizedMessage
) )
setProgressBarVisibility(false) setProgressBarVisibility(false)
presenter!!.lockUnlockNearby(false) presenter!!.lockUnlockNearby(false)
@ -1905,8 +1931,8 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
// then compare it against place's label // then compare it against place's label
if (selectedLabels != null && (selectedLabels.size != 0 || !filterForPlaceState) if (selectedLabels != null && (selectedLabels.size != 0 || !filterForPlaceState)
&& (!selectedLabels.contains(place.label) && (!selectedLabels.contains(place.label)
&& !(selectedLabels.contains(Label.BOOKMARKS) && !(selectedLabels.contains(Label.BOOKMARKS)
&& markerPlaceGroup.isBookmarked)) && markerPlaceGroup.isBookmarked))
) { ) {
continue continue
} }
@ -1977,7 +2003,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
// Highlight nearest place only when user clicks on the home nearby banner // Highlight nearest place only when user clicks on the home nearby banner
// highlightNearestPlace(place); // highlightNearestPlace(place);
return (if (isBookmarked) fr.free.nrw.commons.R.drawable.ic_custom_map_marker_purple_bookmarked else fr.free.nrw.commons.R.drawable.ic_custom_map_marker_purple return (if (isBookmarked) fr.free.nrw.commons.R.drawable.ic_custom_map_marker_purple_bookmarked else fr.free.nrw.commons.R.drawable.ic_custom_map_marker_purple
) )
} }
if (place.isMonument) { if (place.isMonument) {
@ -1985,17 +2011,17 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
} }
if (!place.pic.trim { it <= ' ' }.isEmpty()) { if (!place.pic.trim { it <= ' ' }.isEmpty()) {
return (if (isBookmarked) fr.free.nrw.commons.R.drawable.ic_custom_map_marker_green_bookmarked else fr.free.nrw.commons.R.drawable.ic_custom_map_marker_green return (if (isBookmarked) fr.free.nrw.commons.R.drawable.ic_custom_map_marker_green_bookmarked else fr.free.nrw.commons.R.drawable.ic_custom_map_marker_green
) )
} }
if (!place.exists) { // Means that the topic of the Wikidata item does not exist in the real world anymore, for instance it is a past event, or a place that was destroyed if (!place.exists) { // Means that the topic of the Wikidata item does not exist in the real world anymore, for instance it is a past event, or a place that was destroyed
return (fr.free.nrw.commons.R.drawable.ic_clear_black_24dp) return (fr.free.nrw.commons.R.drawable.ic_clear_black_24dp)
} }
if (place.name.isEmpty()) { if (place.name.isEmpty()) {
return (if (isBookmarked) fr.free.nrw.commons.R.drawable.ic_custom_map_marker_grey_bookmarked else fr.free.nrw.commons.R.drawable.ic_custom_map_marker_grey return (if (isBookmarked) fr.free.nrw.commons.R.drawable.ic_custom_map_marker_grey_bookmarked else fr.free.nrw.commons.R.drawable.ic_custom_map_marker_grey
) )
} }
return (if (isBookmarked) fr.free.nrw.commons.R.drawable.ic_custom_map_marker_red_bookmarked else fr.free.nrw.commons.R.drawable.ic_custom_map_marker_red return (if (isBookmarked) fr.free.nrw.commons.R.drawable.ic_custom_map_marker_red_bookmarked else fr.free.nrw.commons.R.drawable.ic_custom_map_marker_red
) )
} }
fun convertToMarker(place: Place, isBookMarked: Boolean): Marker { fun convertToMarker(place: Place, isBookMarked: Boolean): Marker {
@ -2129,10 +2155,18 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
if (intent.resolveActivity(packageManager) != null) { if (intent.resolveActivity(packageManager) != null) {
startActivity(intent) startActivity(intent)
Toast.makeText(context, fr.free.nrw.commons.R.string.recommend_high_accuracy_mode, Toast.LENGTH_LONG) Toast.makeText(
context,
fr.free.nrw.commons.R.string.recommend_high_accuracy_mode,
Toast.LENGTH_LONG
)
.show() .show()
} else { } else {
Toast.makeText(context, fr.free.nrw.commons.R.string.cannot_open_location_settings, Toast.LENGTH_LONG) Toast.makeText(
context,
fr.free.nrw.commons.R.string.cannot_open_location_settings,
Toast.LENGTH_LONG
)
.show() .show()
} }
} }
@ -2180,7 +2214,12 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
selectedPlace = place selectedPlace = place
dataList = ArrayList() dataList = ArrayList()
// TODO: Decide button text for fitting in the screen // TODO: Decide button text for fitting in the screen
(dataList as ArrayList<BottomSheetItem>).add(BottomSheetItem(fr.free.nrw.commons.R.drawable.ic_round_star_border_24px, "")) (dataList as ArrayList<BottomSheetItem>).add(
BottomSheetItem(
fr.free.nrw.commons.R.drawable.ic_round_star_border_24px,
""
)
)
(dataList as ArrayList<BottomSheetItem>).add( (dataList as ArrayList<BottomSheetItem>).add(
BottomSheetItem( BottomSheetItem(
fr.free.nrw.commons.R.drawable.ic_directions_black_24dp, fr.free.nrw.commons.R.drawable.ic_directions_black_24dp,
@ -2220,7 +2259,8 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
val spanCount = spanCount val spanCount = spanCount
gridLayoutManager = GridLayoutManager(this.context, spanCount) gridLayoutManager = GridLayoutManager(this.context, spanCount)
binding!!.bottomSheetDetails.bottomSheetRecyclerView.layoutManager = gridLayoutManager binding!!.bottomSheetDetails.bottomSheetRecyclerView.layoutManager = gridLayoutManager
bottomSheetAdapter = BottomSheetAdapter(this.context, bottomSheetAdapter = BottomSheetAdapter(
this.context,
dataList as ArrayList<BottomSheetItem> dataList as ArrayList<BottomSheetItem>
) )
bottomSheetAdapter!!.setClickListener(this) bottomSheetAdapter!!.setClickListener(this)
@ -2277,7 +2317,8 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
private fun storeSharedPrefs(selectedPlace: Place) { private fun storeSharedPrefs(selectedPlace: Place) {
applicationKvStore!!.putJson<Place>(WikidataConstants.PLACE_OBJECT, selectedPlace) applicationKvStore!!.putJson<Place>(WikidataConstants.PLACE_OBJECT, selectedPlace)
val place = applicationKvStore!!.getJson<Place>(WikidataConstants.PLACE_OBJECT, Place::class.java) val place =
applicationKvStore!!.getJson<Place>(WikidataConstants.PLACE_OBJECT, Place::class.java)
Timber.d("Stored place object %s", place.toString()) Timber.d("Stored place object %s", place.toString())
} }
@ -2380,7 +2421,10 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
Marker.ANCHOR_BOTTOM Marker.ANCHOR_BOTTOM
) )
startMarker.icon = startMarker.icon =
ContextCompat.getDrawable(this.requireContext(), fr.free.nrw.commons.R.drawable.current_location_marker) ContextCompat.getDrawable(
this.requireContext(),
fr.free.nrw.commons.R.drawable.current_location_marker
)
startMarker.title = "Your Location" startMarker.title = "Your Location"
startMarker.textLabelFontSize = 24 startMarker.textLabelFontSize = 24
binding!!.map.overlays.add(startMarker) binding!!.map.overlays.add(startMarker)
@ -2438,7 +2482,10 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
Marker.ANCHOR_BOTTOM Marker.ANCHOR_BOTTOM
) )
startMarker.icon = startMarker.icon =
ContextCompat.getDrawable(this.requireContext(), fr.free.nrw.commons.R.drawable.current_location_marker) ContextCompat.getDrawable(
this.requireContext(),
fr.free.nrw.commons.R.drawable.current_location_marker
)
startMarker.title = "Your Location" startMarker.title = "Your Location"
startMarker.textLabelFontSize = 24 startMarker.textLabelFontSize = 24
binding!!.map.overlays.add(startMarker) binding!!.map.overlays.add(startMarker)
@ -2573,7 +2620,6 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), NearbyParentF
} }
private val isExternalStorageWritable: Boolean private val isExternalStorageWritable: Boolean
get() { get() {
val state = Environment.getExternalStorageState() val state = Environment.getExternalStorageState()