@@ -277,57 +277,12 @@ class MapFragment : Fragment() {
277277
278278 binding.searchBar.setOnMenuItemClickListener {
279279 when (it.itemId) {
280- // R.id.action_donate -> {
281- // parentFragmentManager.commit {
282- // setReorderingAllowed(true)
283- // replace<DonationFragment>(R.id.nav_host_fragment)
284- // addToBackStack(null)
285- // }
286- // }
287-
288280 R .id.action_add_element -> {
289281 val intent = Intent (Intent .ACTION_VIEW )
290282 intent.data = Uri .parse(" https://btcmap.org/add-location" )
291283 startActivity(intent)
292284 }
293285
294- // R.id.action_areas -> {
295- // parentFragmentManager.commit {
296- // setReorderingAllowed(true)
297- // replace<AreasFragment>(
298- // R.id.nav_host_fragment, null, bundleOf(
299- // "lat" to model.mapViewport.value.boundingBox.center.latitude.toFloat(),
300- // "lon" to model.mapViewport.value.boundingBox.center.longitude.toFloat(),
301- // )
302- // )
303- // addToBackStack(null)
304- // }
305- // }
306-
307- // R.id.action_trends -> {
308- // parentFragmentManager.commit {
309- // setReorderingAllowed(true)
310- // replace<ReportsFragment>(R.id.nav_host_fragment)
311- // addToBackStack(null)
312- // }
313- // }
314-
315- // R.id.action_users -> {
316- // parentFragmentManager.commit {
317- // setReorderingAllowed(true)
318- // replace<UsersFragment>(R.id.nav_host_fragment)
319- // addToBackStack(null)
320- // }
321- // }
322-
323- // R.id.action_events -> {
324- // parentFragmentManager.commit {
325- // setReorderingAllowed(true)
326- // replace<EventsFragment>(R.id.nav_host_fragment)
327- // addToBackStack(null)
328- // }
329- // }
330-
331286 R .id.action_settings -> {
332287 parentFragmentManager.commit {
333288 setReorderingAllowed(true )
@@ -368,17 +323,6 @@ class MapFragment : Fragment() {
368323 bottomSheetBehavior.state = BottomSheetBehavior .STATE_HIDDEN
369324 bottomSheetBehavior.addSlideCallback()
370325
371- when (prefs.mapStyle) {
372- MapStyle .Auto -> {
373- val nightMode =
374- requireContext().resources.configuration.uiMode and Configuration .UI_MODE_NIGHT_MASK == Configuration .UI_MODE_NIGHT_YES
375- insetsController?.isAppearanceLightStatusBars = ! nightMode
376- }
377-
378- MapStyle .Dark -> insetsController?.isAppearanceLightStatusBars = false
379- else -> insetsController?.isAppearanceLightStatusBars = true
380- }
381-
382326 viewLifecycleOwner.lifecycleScope.launch {
383327 val elementDetailsToolbar = getElementDetailsToolbar() ? : return @launch
384328 bottomSheetBehavior.peekHeight = elementDetailsToolbar.height * 3
@@ -788,4 +732,33 @@ class MapFragment : Fragment() {
788732
789733 return clusterIcon
790734 }
735+
736+ override fun onResume () {
737+ super .onResume()
738+ styleStatusBar()
739+ }
740+
741+ override fun onPause () {
742+ super .onPause()
743+ restoreDefaultStatusBar()
744+ }
745+
746+ fun styleStatusBar () {
747+ when (prefs.mapStyle) {
748+ MapStyle .Auto -> {
749+ val nightMode =
750+ requireContext().resources.configuration.uiMode and Configuration .UI_MODE_NIGHT_MASK == Configuration .UI_MODE_NIGHT_YES
751+ insetsController?.isAppearanceLightStatusBars = ! nightMode
752+ }
753+
754+ MapStyle .Dark -> insetsController?.isAppearanceLightStatusBars = false
755+ else -> insetsController?.isAppearanceLightStatusBars = true
756+ }
757+ }
758+
759+ fun restoreDefaultStatusBar () {
760+ val nightMode =
761+ requireContext().resources.configuration.uiMode and Configuration .UI_MODE_NIGHT_MASK == Configuration .UI_MODE_NIGHT_YES
762+ insetsController?.isAppearanceLightStatusBars = ! nightMode
763+ }
791764}
0 commit comments