From 83e79207c13802baede2f81fba3bf929e6045946 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Fri, 27 May 2022 16:33:55 +0300 Subject: [PATCH] Implement stop sharing button visibility. --- .../map/LiveLocationBottomSheetController.kt | 2 +- .../location/live/map/LiveLocationUserItem.kt | 17 ++++++++++++++--- .../live/map/LocationLiveMapViewState.kt | 3 ++- .../live/map/UserLiveLocationViewStateMapper.kt | 6 ++++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationBottomSheetController.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationBottomSheetController.kt index 44caba19ca..0136dbfff8 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationBottomSheetController.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationBottomSheetController.kt @@ -64,7 +64,7 @@ class LiveLocationBottomSheetController @Inject constructor( avatarRenderer(host.avatarRenderer) remainingTime(remainingTime) locationUpdateTimeMillis(liveLocationViewState.locationTimestampMillis) - showStopSharingButton(false) + showStopSharingButton(liveLocationViewState.showStopSharingButton) } } } diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationUserItem.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationUserItem.kt index e32157ff10..448663d07e 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationUserItem.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationUserItem.kt @@ -65,8 +65,6 @@ abstract class LiveLocationUserItem : VectorEpoxyModel(R.id.itemUserAvatarImageView) val itemUserDisplayNameTextView by bind(R.id.itemUserDisplayNameTextView) val itemRemainingTimeTextView by bind(R.id.itemRemainingTimeTextView) diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewState.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewState.kt index a17ddca00c..e96fdb2645 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewState.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewState.kt @@ -39,5 +39,6 @@ data class UserLiveLocationViewState( val pinDrawable: Drawable, val locationData: LocationData, val endOfLiveTimestampMillis: Long?, - val locationTimestampMillis: Long? + val locationTimestampMillis: Long?, + val showStopSharingButton: Boolean ) diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/UserLiveLocationViewStateMapper.kt b/vector/src/main/java/im/vector/app/features/location/live/map/UserLiveLocationViewStateMapper.kt index 845b62f32c..09922b77d4 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/UserLiveLocationViewStateMapper.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/UserLiveLocationViewStateMapper.kt @@ -44,14 +44,16 @@ class UserLiveLocationViewStateMapper @Inject constructor( } else -> { locationPinProvider.create(userId) { pinDrawable -> - activeSessionHolder.getActiveSession().getUser(userId)?.toMatrixItem()?.let { matrixItem -> + val session = activeSessionHolder.getActiveSession() + session.getUser(userId)?.toMatrixItem()?.let { matrixItem -> val locationTimestampMillis = liveLocationShareAggregatedSummary.lastLocationDataContent?.getBestTimestampMillis() val viewState = UserLiveLocationViewState( matrixItem = matrixItem, pinDrawable = pinDrawable, locationData = locationData, endOfLiveTimestampMillis = liveLocationShareAggregatedSummary.endOfLiveTimestampMillis, - locationTimestampMillis = locationTimestampMillis + locationTimestampMillis = locationTimestampMillis, + showStopSharingButton = userId == session.myUserId ) continuation.resume(viewState) { // do nothing on cancellation