Fixed caret direction when in-call bottom sheet is opened by dragging the handle

This commit is contained in:
Sylvain Berfini 2023-09-08 09:46:24 +02:00
parent 8e1d22bbb9
commit b0a1ac3ee4
2 changed files with 30 additions and 7 deletions

View file

@ -143,14 +143,33 @@ class ActiveCallFragment : GenericCallFragment() {
binding.chronometer.start()
}
callViewModel.isActionsMenuExpanded.observe(viewLifecycleOwner) { expanded ->
val standardBottomSheetBehavior = BottomSheetBehavior.from(binding.bottomBar.root)
if (expanded) {
standardBottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
} else {
standardBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
val standardBottomSheetBehavior = BottomSheetBehavior.from(binding.bottomBar.root)
callViewModel.toggleExtraActionsBottomSheetEvent.observe(viewLifecycleOwner) {
it.consume {
val state = standardBottomSheetBehavior.state
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
standardBottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
} else if (state == BottomSheetBehavior.STATE_EXPANDED) {
standardBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
}
}
}
standardBottomSheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {
when (newState) {
BottomSheetBehavior.STATE_COLLAPSED -> {
callViewModel.isActionsMenuExpanded.value = false
}
BottomSheetBehavior.STATE_EXPANDED -> {
callViewModel.isActionsMenuExpanded.value = true
}
else -> {}
}
}
override fun onSlide(bottomSheet: View, slideOffset: Float) {}
})
}
override fun onResume() {

View file

@ -86,6 +86,10 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
val isActionsMenuExpanded = MutableLiveData<Boolean>()
val toggleExtraActionsBottomSheetEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
private lateinit var call: Call
private val callListener = object : CallListenerStub() {
@ -302,7 +306,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
@UiThread
fun toggleExpandActionsMenu() {
isActionsMenuExpanded.value = isActionsMenuExpanded.value == false
toggleExtraActionsBottomSheetEvent.value = Event(true)
}
@WorkerThread