@@ -107,6 +107,7 @@ class MapActivity :
107107 )
108108 private var service: BackgroundService ? = null
109109 private var bottomSheetBehavior: BottomSheetBehavior <LinearLayoutCompat >? = null
110+ private var navBarInset: Int = 0
110111 private var menu: Menu ? = null
111112 private var sensorManager: SensorManager ? = null
112113 private var orientationSensor: Sensor ? = null
@@ -299,11 +300,20 @@ class MapActivity :
299300 // Apply bottom insets to FABs to avoid navigation bar
300301 ViewCompat .setOnApplyWindowInsetsListener(mapCoordinatorLayout) { _, windowInsets ->
301302 val insets = windowInsets.getInsets(WindowInsetsCompat .Type .systemBars())
303+ val fabMargin = resources.getDimensionPixelSize(R .dimen.fab_margin)
304+
305+ navBarInset = insets.bottom
302306
303307 fabMapLayers.updateLayoutParams<ViewGroup .MarginLayoutParams > {
304- bottomMargin = insets.bottom + resources.getDimensionPixelSize(R .dimen.fab_margin)
308+ bottomMargin = insets.bottom + fabMargin
309+ }
310+
311+ fabMyLocation.updateLayoutParams<ViewGroup .MarginLayoutParams > {
312+ marginEnd = insets.right + fabMargin
305313 }
306314
315+ bottomSheetBehavior?.state?.let { updateFabMyLocationPosition(it) }
316+
307317 windowInsets
308318 }
309319 }
@@ -819,9 +829,9 @@ class MapActivity :
819829 bottomMargin =
820830 when (bottomSheetState) {
821831 BottomSheetBehavior .STATE_COLLAPSED -> {
822- bottomSheetBehavior?.peekHeight ? : bottom
832+ ( bottomSheetBehavior?.peekHeight ? : 0 ) + navBarInset
823833 }
824- else -> bottom
834+ else -> navBarInset
825835 }
826836 }
827837 }
0 commit comments