diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt index bbb838a41a..3aacd70f0e 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt @@ -111,13 +111,6 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment<Fra private fun setupMap() { val mapFragment = getOrCreateSupportMapFragment() 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 { mapboxMap.setStyle(urlMapProvider.getMapUrl()) { style -> mapStyle = style @@ -175,11 +168,43 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment<Fra private fun updateUserListBottomSheet(userLocations: List<UserLiveLocationViewState>) { if (userLocations.isEmpty()) { - views.bottomSheet.isGone = true - // TODO show Live location ended view + showEndedLiveBanner() } else { - views.bottomSheet.isVisible = true - bottomSheetController.setData(userLocations) + showUserList(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 { 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 } } diff --git a/vector/src/main/res/layout/fragment_location_live_map_view.xml b/vector/src/main/res/layout/fragment_location_live_map_view.xml index 95598db0de..ac8f18479b 100644 --- a/vector/src/main/res/layout/fragment_location_live_map_view.xml +++ b/vector/src/main/res/layout/fragment_location_live_map_view.xml @@ -10,7 +10,7 @@ android:id="@+id/liveLocationPopupAnchor" android:layout_width="0dp" android:layout_height="0dp" - android:layout_gravity="center"/> + android:layout_gravity="center" /> <FrameLayout android:id="@+id/liveLocationMapFragmentContainer" @@ -49,4 +49,13 @@ </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> diff --git a/vector/src/main/res/layout/item_timeline_event_live_location_start_stub.xml b/vector/src/main/res/layout/item_timeline_event_live_location_start_stub.xml index d8b04413fe..2cf1eb1787 100644 --- a/vector/src/main/res/layout/item_timeline_event_live_location_start_stub.xml +++ b/vector/src/main/res/layout/item_timeline_event_live_location_start_stub.xml @@ -28,8 +28,8 @@ <ImageView android:id="@+id/locationLiveStartIcon" - android:layout_width="26dp" - android:layout_height="26dp" + android:layout_width="32dp" + android:layout_height="32dp" android:layout_marginVertical="8dp" android:layout_marginStart="8dp" android:background="@drawable/circle" diff --git a/vector/src/main/res/layout/view_location_live_ended_banner.xml b/vector/src/main/res/layout/view_location_live_ended_banner.xml index 2a6036139a..983f268757 100644 --- a/vector/src/main/res/layout/view_location_live_ended_banner.xml +++ b/vector/src/main/res/layout/view_location_live_ended_banner.xml @@ -3,22 +3,24 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="48dp" tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> <ImageView android:id="@+id/locationLiveEndedBannerBackground" android:layout_width="0dp" - android:layout_height="48dp" + android:layout_height="0dp" android:src="?android:colorBackground" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" tools:ignore="ContentDescription" /> <ImageView android:id="@+id/locationLiveEndedBannerIcon" - android:layout_width="26dp" - android:layout_height="26dp" + android:layout_width="32dp" + android:layout_height="32dp" android:layout_marginVertical="8dp" android:layout_marginStart="8dp" android:background="@drawable/circle"