mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Adding ended live banner view in the map screen
This commit is contained in:
parent
5e59eb474a
commit
e51488bc57
4 changed files with 56 additions and 18 deletions
|
@ -111,13 +111,6 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment<Fra
|
||||||
private fun setupMap() {
|
private fun setupMap() {
|
||||||
val mapFragment = getOrCreateSupportMapFragment()
|
val mapFragment = getOrCreateSupportMapFragment()
|
||||||
mapFragment.getMapAsync { mapboxMap ->
|
mapFragment.getMapAsync { mapboxMap ->
|
||||||
val bottomSheetHeight = BottomSheetBehavior.from(views.bottomSheet).peekHeight
|
|
||||||
mapboxMap.uiSettings.apply {
|
|
||||||
// Place copyright above the user list bottom sheet
|
|
||||||
setLogoMargins(dimensionConverter.dpToPx(8), 0, 0, bottomSheetHeight + dimensionConverter.dpToPx(8))
|
|
||||||
setAttributionMargins(dimensionConverter.dpToPx(96), 0, 0, bottomSheetHeight + dimensionConverter.dpToPx(8))
|
|
||||||
}
|
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
mapboxMap.setStyle(urlMapProvider.getMapUrl()) { style ->
|
mapboxMap.setStyle(urlMapProvider.getMapUrl()) { style ->
|
||||||
mapStyle = style
|
mapStyle = style
|
||||||
|
@ -175,11 +168,43 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment<Fra
|
||||||
|
|
||||||
private fun updateUserListBottomSheet(userLocations: List<UserLiveLocationViewState>) {
|
private fun updateUserListBottomSheet(userLocations: List<UserLiveLocationViewState>) {
|
||||||
if (userLocations.isEmpty()) {
|
if (userLocations.isEmpty()) {
|
||||||
views.bottomSheet.isGone = true
|
showEndedLiveBanner()
|
||||||
// TODO show Live location ended view
|
|
||||||
} else {
|
} else {
|
||||||
views.bottomSheet.isVisible = true
|
showUserList(userLocations)
|
||||||
bottomSheetController.setData(userLocations)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showEndedLiveBanner() {
|
||||||
|
views.bottomSheet.isGone = true
|
||||||
|
views.liveLocationMapFragmentEndedBanner.isVisible = true
|
||||||
|
updateCopyrightMargin(bottomOffset = views.liveLocationMapFragmentEndedBanner.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showUserList(userLocations: List<UserLiveLocationViewState>) {
|
||||||
|
val bottomSheetHeight = BottomSheetBehavior.from(views.bottomSheet).peekHeight
|
||||||
|
updateCopyrightMargin(bottomOffset = bottomSheetHeight)
|
||||||
|
views.bottomSheet.isVisible = true
|
||||||
|
views.liveLocationMapFragmentEndedBanner.isGone = true
|
||||||
|
bottomSheetController.setData(userLocations)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateCopyrightMargin(bottomOffset: Int) {
|
||||||
|
getOrCreateSupportMapFragment().getMapAsync { mapboxMap ->
|
||||||
|
mapboxMap.uiSettings.apply {
|
||||||
|
// Place copyright above the user list bottom sheet
|
||||||
|
setLogoMargins(
|
||||||
|
dimensionConverter.dpToPx(COPYRIGHT_MARGIN_DP),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
bottomOffset + dimensionConverter.dpToPx(COPYRIGHT_MARGIN_DP)
|
||||||
|
)
|
||||||
|
setAttributionMargins(
|
||||||
|
dimensionConverter.dpToPx(COPYRIGHT_ATTRIBUTION_MARGIN_DP),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
bottomOffset + dimensionConverter.dpToPx(COPYRIGHT_MARGIN_DP)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,5 +310,7 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment<Fra
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val MAP_FRAGMENT_TAG = "im.vector.app.features.location.live.map"
|
private const val MAP_FRAGMENT_TAG = "im.vector.app.features.location.live.map"
|
||||||
|
private const val COPYRIGHT_MARGIN_DP = 8
|
||||||
|
private const val COPYRIGHT_ATTRIBUTION_MARGIN_DP = 96
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
android:id="@+id/liveLocationPopupAnchor"
|
android:id="@+id/liveLocationPopupAnchor"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/liveLocationMapFragmentContainer"
|
android:id="@+id/liveLocationMapFragmentContainer"
|
||||||
|
@ -49,4 +49,13 @@
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<im.vector.app.features.location.live.LocationLiveEndedBannerView
|
||||||
|
android:id="@+id/liveLocationMapFragmentEndedBanner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:locLiveEndedBkgWithAlpha="false"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/locationLiveStartIcon"
|
android:id="@+id/locationLiveStartIcon"
|
||||||
android:layout_width="26dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="26dp"
|
android:layout_height="32dp"
|
||||||
android:layout_marginVertical="8dp"
|
android:layout_marginVertical="8dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:background="@drawable/circle"
|
android:background="@drawable/circle"
|
||||||
|
|
|
@ -3,22 +3,24 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="48dp"
|
||||||
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
|
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/locationLiveEndedBannerBackground"
|
android:id="@+id/locationLiveEndedBannerBackground"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="0dp"
|
||||||
android:src="?android:colorBackground"
|
android:src="?android:colorBackground"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/locationLiveEndedBannerIcon"
|
android:id="@+id/locationLiveEndedBannerIcon"
|
||||||
android:layout_width="26dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="26dp"
|
android:layout_height="32dp"
|
||||||
android:layout_marginVertical="8dp"
|
android:layout_marginVertical="8dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:background="@drawable/circle"
|
android:background="@drawable/circle"
|
||||||
|
|
Loading…
Reference in a new issue