From d0a255819a2b5bca3ffa1638a08cba00f50a6fae Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Wed, 30 Mar 2022 14:34:56 +0200 Subject: [PATCH] Creating BottomSheet to choose the live duration --- .../location/LocationSharingFragment.kt | 7 ++- .../duration/ChooseLiveDurationBottomSheet.kt | 48 +++++++++++++++++++ ...et_choose_live_location_share_duration.xml | 18 +++++++ 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/location/live/duration/ChooseLiveDurationBottomSheet.kt create mode 100644 vector/src/main/res/layout/bottom_sheet_choose_live_location_share_duration.xml diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt index ab3bf9b933..62104aa8eb 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt @@ -39,6 +39,7 @@ import im.vector.app.databinding.FragmentLocationSharingBinding import im.vector.app.features.VectorFeatures import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider +import im.vector.app.features.location.live.duration.ChooseLiveDurationBottomSheet import im.vector.app.features.location.option.LocationSharingOption import org.matrix.android.sdk.api.util.MatrixItem import java.lang.ref.WeakReference @@ -236,8 +237,10 @@ class LocationSharingFragment @Inject constructor( private fun startLiveLocationSharing() { // TODO. Get duration from user - val duration = 30 * 1000L - viewModel.handle(LocationSharingAction.StartLiveLocationSharing(duration)) + ChooseLiveDurationBottomSheet.newInstance() + .show(requireActivity().supportFragmentManager, "DISPLAY_CHOOSE_DURATION_OPTIONS") + //val duration = 30 * 1000L + //viewModel.handle(LocationSharingAction.StartLiveLocationSharing(duration)) } private fun updateMap(state: LocationSharingViewState) { diff --git a/vector/src/main/java/im/vector/app/features/location/live/duration/ChooseLiveDurationBottomSheet.kt b/vector/src/main/java/im/vector/app/features/location/live/duration/ChooseLiveDurationBottomSheet.kt new file mode 100644 index 0000000000..2801d5f0a6 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/live/duration/ChooseLiveDurationBottomSheet.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2019 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.location.live.duration + +import android.view.LayoutInflater +import android.view.ViewGroup +import dagger.hilt.android.AndroidEntryPoint +import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment +import im.vector.app.databinding.BottomSheetChooseLiveLocationShareDurationBinding +import im.vector.app.features.home.room.detail.timeline.action.MessageSharedActionViewModel + +/** + * Bottom sheet displaying list of options to choose the duration of the live sharing. + */ +@AndroidEntryPoint +class ChooseLiveDurationBottomSheet : + VectorBaseBottomSheetDialogFragment() { + + // TODO create interface callback to set the chosen duration + // TODO show same UI as in Figma + // TODO handle choice of user + + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetChooseLiveLocationShareDurationBinding { + return BottomSheetChooseLiveLocationShareDurationBinding.inflate(inflater, container, false) + } + + // we are not using state for this one as it's static, so no need to override invalidate() + + companion object { + fun newInstance(): ChooseLiveDurationBottomSheet { + return ChooseLiveDurationBottomSheet() + } + } +} diff --git a/vector/src/main/res/layout/bottom_sheet_choose_live_location_share_duration.xml b/vector/src/main/res/layout/bottom_sheet_choose_live_location_share_duration.xml new file mode 100644 index 0000000000..675a63144f --- /dev/null +++ b/vector/src/main/res/layout/bottom_sheet_choose_live_location_share_duration.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file