mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-28 22:16:22 +00:00
Improved dialer by using permanent bottom sheet
This commit is contained in:
parent
f0e39e92b7
commit
cbc46ed2e0
5 changed files with 246 additions and 242 deletions
|
|
@ -29,6 +29,7 @@ import androidx.core.view.doOnPreDraw
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.navigation.navGraphViewModels
|
import androidx.navigation.navGraphViewModels
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.contacts.getListOfSipAddressesAndPhoneNumbers
|
import org.linphone.contacts.getListOfSipAddressesAndPhoneNumbers
|
||||||
|
|
@ -171,6 +172,15 @@ class StartCallFragment : GenericFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.isNumpadVisible.observe(viewLifecycleOwner) { visible ->
|
||||||
|
val standardBottomSheetBehavior = BottomSheetBehavior.from(binding.numpadLayout.root)
|
||||||
|
if (visible) {
|
||||||
|
standardBottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
} else {
|
||||||
|
standardBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
binding.root.setKeyboardInsetListener { keyboardVisible ->
|
binding.root.setKeyboardInsetListener { keyboardVisible ->
|
||||||
if (keyboardVisible) {
|
if (keyboardVisible) {
|
||||||
viewModel.isNumpadVisible.value = false
|
viewModel.isNumpadVisible.value = false
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,10 @@ import androidx.annotation.UiThread
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.contacts.ContactsManager.ContactsListener
|
import org.linphone.contacts.ContactsManager.ContactsListener
|
||||||
|
|
@ -146,8 +149,12 @@ class StartCallViewModel @UiThread constructor() : ViewModel() {
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
fun switchBetweenKeyboardAndNumpad() {
|
fun switchBetweenKeyboardAndNumpad() {
|
||||||
requestKeyboardVisibilityChangedEvent.value = Event(isNumpadVisible.value == true)
|
val showKeyboard = isNumpadVisible.value == true
|
||||||
isNumpadVisible.value = isNumpadVisible.value == false
|
requestKeyboardVisibilityChangedEvent.value = Event(showKeyboard)
|
||||||
|
viewModelScope.launch {
|
||||||
|
delay(100)
|
||||||
|
isNumpadVisible.value = !showKeyboard
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ import androidx.core.view.doOnLayout
|
||||||
import androidx.databinding.BindingAdapter
|
import androidx.databinding.BindingAdapter
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.databinding.ViewDataBinding
|
import androidx.databinding.ViewDataBinding
|
||||||
import androidx.lifecycle.LifecycleOwner
|
|
||||||
import androidx.lifecycle.findViewTreeLifecycleOwner
|
import androidx.lifecycle.findViewTreeLifecycleOwner
|
||||||
import coil.load
|
import coil.load
|
||||||
import coil.transform.CircleCropTransformation
|
import coil.transform.CircleCropTransformation
|
||||||
|
|
@ -320,15 +319,6 @@ fun setConstraintLayoutBottomMargin(view: View, margins: Float) {
|
||||||
view.layoutParams = params
|
view.layoutParams = params
|
||||||
}
|
}
|
||||||
|
|
||||||
@BindingAdapter("inflatedLifecycleOwner")
|
|
||||||
fun setInflatedViewStubLifecycleOwner(view: View, enable: Boolean) {
|
|
||||||
val binding = DataBindingUtil.bind<ViewDataBinding>(view)
|
|
||||||
// This is a bit hacky...
|
|
||||||
if (view.context is LifecycleOwner) {
|
|
||||||
binding?.lifecycleOwner = view.context as? LifecycleOwner
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@BindingAdapter("focusNextOnInput")
|
@BindingAdapter("focusNextOnInput")
|
||||||
fun focusNextOnInput(editText: EditText, enabled: Boolean) {
|
fun focusNextOnInput(editText: EditText, enabled: Boolean) {
|
||||||
if (!enabled) return
|
if (!enabled) return
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@
|
||||||
type="org.linphone.ui.main.calls.viewmodel.StartCallViewModel" />
|
type="org.linphone.ui.main.calls.viewmodel.StartCallViewModel" />
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
@ -242,20 +246,14 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/suggestions_label"
|
app:layout_constraintTop_toBottomOf="@id/suggestions_label"
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
app:layout_constraintBottom_toBottomOf="parent" />
|
||||||
|
|
||||||
<ViewStub
|
|
||||||
android:id="@+id/numpad_layout"
|
|
||||||
android:inflatedId="@+id/numpad_inflated"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout="@layout/call_start_numpad"
|
|
||||||
android:visibility="@{viewModel.isNumpadVisible ? View.VISIBLE : View.GONE}"
|
|
||||||
inflatedVisibility="@{viewModel.isNumpadVisible ? View.VISIBLE : View.GONE}"
|
|
||||||
handleClickedListener="@{hideNumpadClickListener}"
|
|
||||||
model="@{viewModel.numpadModel}"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/numpad_layout"
|
||||||
|
bind:handleClickedListener="@{hideNumpadClickListener}"
|
||||||
|
bind:model="@{viewModel.numpadModel}"
|
||||||
|
layout="@layout/call_start_numpad" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
@ -10,27 +10,26 @@
|
||||||
<variable
|
<variable
|
||||||
name="model"
|
name="model"
|
||||||
type="org.linphone.ui.main.calls.model.NumpadModel" />
|
type="org.linphone.ui.main.calls.model.NumpadModel" />
|
||||||
<variable
|
|
||||||
name="inflatedVisibility"
|
|
||||||
type="Integer" />
|
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/shape_numpad_background"
|
android:background="@drawable/shape_numpad_background"
|
||||||
android:visibility="@{inflatedVisibility}"
|
|
||||||
inflatedLifecycleOwner="@{true}"
|
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true">
|
android:focusable="true"
|
||||||
|
app:behavior_hideable="true"
|
||||||
|
app:behavior_peekHeight="0dp"
|
||||||
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||||
|
|
||||||
<ImageView
|
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
|
||||||
android:id="@+id/handle"
|
android:id="@+id/handle"
|
||||||
android:onClick="@{handleClickedListener}"
|
android:onClick="@{handleClickedListener}"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="11dp"
|
android:padding="11dp"
|
||||||
android:src="@drawable/shape_drawer_handle"
|
android:src="@drawable/shape_drawer_handle"
|
||||||
|
app:tint="@color/drawer_handle"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue