Skip to content

Commit 5d0e20b

Browse files
committed
fix(ui): move the my location fab in a bit
fixes: #2182
1 parent 2c57917 commit 5d0e20b

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
- Fix slow start caused by replacing the map SDK on every resume.
1212
- Fixed map to show a sensible view when the activity is being resumed
13+
- My location fab now has a little more space from the edge of the display
1314

1415
## Version 2.5.6
1516

project/app/src/main/java/org/owntracks/android/ui/map/MapActivity.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)