mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Hide numpad (if visible) from start call fragment when going back using gesture/click
This commit is contained in:
parent
e770822675
commit
abbc63354d
1 changed files with 26 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.annotation.UiThread
|
import androidx.annotation.UiThread
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.core.view.doOnPreDraw
|
import androidx.core.view.doOnPreDraw
|
||||||
|
|
@ -68,6 +69,24 @@ class StartCallFragment : GenericAddressPickerFragment() {
|
||||||
override fun onSlide(bottomSheet: View, slideOffset: Float) { }
|
override fun onSlide(bottomSheet: View, slideOffset: Float) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val backPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
|
override fun handleOnBackPressed() {
|
||||||
|
val actionsBottomSheetBehavior = BottomSheetBehavior.from(binding.numpadLayout.root)
|
||||||
|
if (actionsBottomSheetBehavior.state != BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
|
actionsBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i("$TAG Back gesture/click detected, no bottom sheet is expanded, going back")
|
||||||
|
isEnabled = false
|
||||||
|
try {
|
||||||
|
requireActivity().onBackPressedDispatcher.onBackPressed()
|
||||||
|
} catch (ise: IllegalStateException) {
|
||||||
|
Log.w("$TAG Can't go back: $ise")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
|
|
@ -91,6 +110,8 @@ class StartCallFragment : GenericAddressPickerFragment() {
|
||||||
observeToastEvents(viewModel)
|
observeToastEvents(viewModel)
|
||||||
|
|
||||||
binding.setBackClickListener {
|
binding.setBackClickListener {
|
||||||
|
// If back button from UI was clicked, go back even if numpad is opened
|
||||||
|
backPressedCallback.isEnabled = false
|
||||||
goBack()
|
goBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,6 +202,11 @@ class StartCallFragment : GenericAddressPickerFragment() {
|
||||||
viewModel.isNumpadVisible.value = false
|
viewModel.isNumpadVisible.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requireActivity().onBackPressedDispatcher.addCallback(
|
||||||
|
viewLifecycleOwner,
|
||||||
|
backPressedCallback
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue