UI to select the duration
This commit is contained in:
parent
5abc196536
commit
c18a9230e5
@ -16,12 +16,29 @@
|
|||||||
|
|
||||||
package im.vector.app.features.location.live.duration
|
package im.vector.app.features.location.live.duration
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import im.vector.app.R
|
||||||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
||||||
import im.vector.app.databinding.BottomSheetChooseLiveLocationShareDurationBinding
|
import im.vector.app.databinding.BottomSheetChooseLiveLocationShareDurationBinding
|
||||||
import im.vector.app.features.home.room.detail.timeline.action.MessageSharedActionViewModel
|
|
||||||
|
/**
|
||||||
|
* 15 minutes.
|
||||||
|
*/
|
||||||
|
private const val DURATION_IN_MS_OPTION_1 = 15 * 60_000L
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1 hour.
|
||||||
|
*/
|
||||||
|
private const val DURATION_IN_MS_OPTION_2 = 60 * 60_000L
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 8 hours.
|
||||||
|
*/
|
||||||
|
private const val DURATION_IN_MS_OPTION_3 = 8 * 60 * 60_000L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bottom sheet displaying list of options to choose the duration of the live sharing.
|
* Bottom sheet displaying list of options to choose the duration of the live sharing.
|
||||||
@ -30,8 +47,7 @@ import im.vector.app.features.home.room.detail.timeline.action.MessageSharedActi
|
|||||||
class ChooseLiveDurationBottomSheet :
|
class ChooseLiveDurationBottomSheet :
|
||||||
VectorBaseBottomSheetDialogFragment<BottomSheetChooseLiveLocationShareDurationBinding>() {
|
VectorBaseBottomSheetDialogFragment<BottomSheetChooseLiveLocationShareDurationBinding>() {
|
||||||
|
|
||||||
// TODO show same UI as in Figma
|
// TODO fix text color problem of button in dqrk mode
|
||||||
// TODO handle choice of user
|
|
||||||
|
|
||||||
var durationChoiceListener: DurationChoiceListener? = null
|
var durationChoiceListener: DurationChoiceListener? = null
|
||||||
|
|
||||||
@ -39,6 +55,11 @@ class ChooseLiveDurationBottomSheet :
|
|||||||
return BottomSheetChooseLiveLocationShareDurationBinding.inflate(inflater, container, false)
|
return BottomSheetChooseLiveLocationShareDurationBinding.inflate(inflater, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
initConfirmButton()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
durationChoiceListener = null
|
durationChoiceListener = null
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
@ -46,6 +67,23 @@ class ChooseLiveDurationBottomSheet :
|
|||||||
|
|
||||||
// we are not using state for this one as it's static, so no need to override invalidate()
|
// we are not using state for this one as it's static, so no need to override invalidate()
|
||||||
|
|
||||||
|
private fun initConfirmButton() {
|
||||||
|
views.liveLocShareChooseDurationConfirm.setOnClickListener {
|
||||||
|
val currentChoice = getCurrentChoice()
|
||||||
|
durationChoiceListener?.onDurationChoice(currentChoice)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getCurrentChoice(): Long {
|
||||||
|
return when (views.liveLocShareChooseDurationOptions.checkedRadioButtonId) {
|
||||||
|
R.id.liveLocShareChooseDurationOption1 -> DURATION_IN_MS_OPTION_1
|
||||||
|
R.id.liveLocShareChooseDurationOption2 -> DURATION_IN_MS_OPTION_2
|
||||||
|
R.id.liveLocShareChooseDurationOption3 -> DURATION_IN_MS_OPTION_3
|
||||||
|
else -> DURATION_IN_MS_OPTION_1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(durationChoiceListener: DurationChoiceListener): ChooseLiveDurationBottomSheet {
|
fun newInstance(durationChoiceListener: DurationChoiceListener): ChooseLiveDurationBottomSheet {
|
||||||
val bottomSheet = ChooseLiveDurationBottomSheet()
|
val bottomSheet = ChooseLiveDurationBottomSheet()
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<size android:height="1dp" />
|
||||||
|
<solid android:color="?vctr_list_separator_system" />
|
||||||
|
</shape>
|
@ -2,17 +2,61 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?colorSurface"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bottomSheetLiveLocShareChooseDurationTitle"
|
android:id="@+id/liveLocShareChooseDurationTitle"
|
||||||
style="@style/Widget.Vector.TextView.Subtitle"
|
style="@style/Widget.Vector.TextView.Subtitle.Medium"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:padding="8dp"
|
android:paddingHorizontal="15dp"
|
||||||
android:textColor="?vctr_content_primary"
|
android:paddingVertical="24dp"
|
||||||
android:text="@string/location_share_live_select_duration_title" />
|
android:text="@string/location_share_live_select_duration_title"
|
||||||
|
android:textColor="?vctr_content_primary" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/liveLocShareChooseDurationOptions"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:divider="@drawable/divider_horizontal_system"
|
||||||
|
android:showDividers="beginning|middle|end">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/liveLocShareChooseDurationOption1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="12dp"
|
||||||
|
android:paddingHorizontal="12dp"
|
||||||
|
android:paddingVertical="22dp"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/location_share_live_select_duration_option_1" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/liveLocShareChooseDurationOption2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="12dp"
|
||||||
|
android:paddingHorizontal="12dp"
|
||||||
|
android:paddingVertical="22dp"
|
||||||
|
android:text="@string/location_share_live_select_duration_option_2" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/liveLocShareChooseDurationOption3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="12dp"
|
||||||
|
android:paddingHorizontal="12dp"
|
||||||
|
android:paddingVertical="22dp"
|
||||||
|
android:text="@string/location_share_live_select_duration_option_3" />
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/liveLocShareChooseDurationConfirm"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginVertical="12dp"
|
||||||
|
android:text="@string/action_share" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user