mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed numpad dial button while transfering a call
This commit is contained in:
parent
afa041baf6
commit
c64bd5bc1c
6 changed files with 78 additions and 10 deletions
|
|
@ -35,6 +35,7 @@ import kotlin.getValue
|
|||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
import org.linphone.core.Address
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.CallTransferFragmentBinding
|
||||
import org.linphone.ui.call.adapter.CallsListAdapter
|
||||
|
|
@ -44,9 +45,9 @@ import org.linphone.ui.call.viewmodel.CurrentCallViewModel
|
|||
import org.linphone.ui.main.adapter.ConversationsContactsAndSuggestionsListAdapter
|
||||
import org.linphone.ui.main.history.viewmodel.StartCallViewModel
|
||||
import org.linphone.utils.ConfirmationDialogModel
|
||||
import org.linphone.ui.main.model.ConversationContactOrSuggestionModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
import org.linphone.utils.RecyclerViewHeaderDecoration
|
||||
import org.linphone.utils.hideKeyboard
|
||||
import org.linphone.utils.setKeyboardInsetListener
|
||||
|
|
@ -144,7 +145,7 @@ class TransferCallFragment : GenericCallFragment() {
|
|||
|
||||
contactsAdapter.onClickedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { model ->
|
||||
showConfirmBlindTransferDialog(model)
|
||||
showConfirmBlindTransferDialog(model.address, model.name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,6 +232,12 @@ class TransferCallFragment : GenericCallFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.initiateBlindTransferEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { address ->
|
||||
showConfirmBlindTransferDialog(address, LinphoneUtils.getDisplayName(address))
|
||||
}
|
||||
}
|
||||
|
||||
binding.root.setKeyboardInsetListener { keyboardVisible ->
|
||||
if (keyboardVisible) {
|
||||
viewModel.isNumpadVisible.value = false
|
||||
|
|
@ -300,14 +307,13 @@ class TransferCallFragment : GenericCallFragment() {
|
|||
dialog.show()
|
||||
}
|
||||
|
||||
private fun showConfirmBlindTransferDialog(contactModel: ConversationContactOrSuggestionModel) {
|
||||
private fun showConfirmBlindTransferDialog(toAddress: Address, toDisplayName: String) {
|
||||
val from = callViewModel.displayedName.value.orEmpty()
|
||||
val to = contactModel.name
|
||||
Log.i("$TAG Asking user confirmation before doing blind transfer of call with [$from] to [$to](${contactModel.address.asStringUriOnly()})")
|
||||
Log.i("$TAG Asking user confirmation before doing blind transfer of call with [$from] to [$toDisplayName](${toAddress.asStringUriOnly()})")
|
||||
val label = AppUtils.getFormattedString(
|
||||
R.string.call_transfer_confirm_dialog_message,
|
||||
from,
|
||||
to
|
||||
toDisplayName
|
||||
)
|
||||
val model = ConfirmationDialogModel(label)
|
||||
val dialog = DialogUtils.getConfirmCallTransferCallDialog(
|
||||
|
|
@ -325,7 +331,7 @@ class TransferCallFragment : GenericCallFragment() {
|
|||
model.confirmEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
coreContext.postOnCoreThread {
|
||||
val address = contactModel.address
|
||||
val address = toAddress
|
||||
Log.i("$TAG Transferring (blind) call to [${address.asStringUriOnly()}]")
|
||||
callViewModel.blindTransferCallTo(address)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -580,6 +580,8 @@ class CurrentCallViewModel
|
|||
},
|
||||
{ // OnCallClicked
|
||||
},
|
||||
{ // OnBlindTransferClicked
|
||||
},
|
||||
{ // OnClearInput
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ open class NumpadModel
|
|||
private val onVoicemailClicked: () -> (Unit),
|
||||
private val onBackspaceClicked: () -> (Unit),
|
||||
private val onCallClicked: () -> (Unit),
|
||||
private val onTransferCallClicked: () -> (Unit),
|
||||
private val onClearClicked: () -> (Unit)
|
||||
) {
|
||||
companion object {
|
||||
|
|
@ -106,4 +107,10 @@ open class NumpadModel
|
|||
Log.i("$TAG Starting call")
|
||||
onCallClicked.invoke()
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun onBlindTransferClicked() {
|
||||
Log.i("$TAG Transferring call")
|
||||
onTransferCallClicked.invoke()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,10 @@ class StartCallViewModel
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val initiateBlindTransferEvent: MutableLiveData<Event<Address>> by lazy {
|
||||
MutableLiveData<Event<Address>>()
|
||||
}
|
||||
|
||||
private val conferenceListener = object : ConferenceListenerStub() {
|
||||
@WorkerThread
|
||||
override fun onStateChanged(conference: Conference, newState: Conference.State?) {
|
||||
|
|
@ -139,6 +143,24 @@ class StartCallViewModel
|
|||
}
|
||||
}
|
||||
},
|
||||
{ // OnBlindTransferClicked
|
||||
val suggestion = searchFilter.value.orEmpty()
|
||||
if (suggestion.isNotEmpty()) {
|
||||
Log.i("$TAG Using numpad transfer button to blind forward call to [$suggestion]")
|
||||
coreContext.postOnCoreThread { core ->
|
||||
val address = core.interpretUrl(
|
||||
suggestion,
|
||||
LinphoneUtils.applyInternationalPrefix()
|
||||
)
|
||||
if (address != null) {
|
||||
initiateBlindTransferEvent.postValue(Event(address))
|
||||
leaveFragmentEvent.postValue(Event(true))
|
||||
} else {
|
||||
Log.e("$TAG Failed to parse [$suggestion] as SIP address")
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{ // OnClearInput
|
||||
clearSearchBarEvent.value = Event(true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@
|
|||
android:id="@+id/numpad_layout"
|
||||
bind:handleClickedListener="@{hideNumpadClickListener}"
|
||||
bind:model="@{viewModel.numpadModel}"
|
||||
bind:showCallTransferIcon="@{true}"
|
||||
layout="@layout/start_call_numpad_bottom_sheet" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
<variable
|
||||
name="model"
|
||||
type="org.linphone.ui.main.history.model.NumpadModel" />
|
||||
<variable
|
||||
name="showCallTransferIcon"
|
||||
type="Boolean" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
@ -23,6 +26,13 @@
|
|||
app:behavior_peekHeight="0dp"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/call_barrier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="top"
|
||||
app:constraint_referenced_ids="call, transfer" />
|
||||
|
||||
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
|
||||
android:id="@+id/handle"
|
||||
android:onClick="@{handleClickedListener}"
|
||||
|
|
@ -41,7 +51,7 @@
|
|||
android:layout_height="0dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/handle"
|
||||
app:layout_constraintBottom_toTopOf="@id/call"
|
||||
app:layout_constraintBottom_toTopOf="@id/call_barrier"
|
||||
android:layout_marginBottom="20dp"
|
||||
app:flow_horizontalStyle="spread"
|
||||
app:flow_wrapMode="aligned"
|
||||
|
|
@ -190,6 +200,27 @@
|
|||
android:contentDescription="@string/content_description_call_start"
|
||||
android:elevation="3dp"
|
||||
android:background="@drawable/squircle_green_button_background"
|
||||
android:visibility="@{showCallTransferIcon ? View.GONE : View.VISIBLE}"
|
||||
app:tint="@color/bc_white"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/digit_0"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/transfer"
|
||||
android:onClick="@{() -> model.onBlindTransferClicked()}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/call_button_size"
|
||||
android:paddingStart="30dp"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingEnd="30dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:src="@drawable/phone_transfer"
|
||||
android:contentDescription="@string/content_description_call_start"
|
||||
android:elevation="3dp"
|
||||
android:background="@drawable/squircle_green_button_background"
|
||||
android:visibility="@{showCallTransferIcon ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:tint="@color/bc_white"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
@ -207,8 +238,7 @@
|
|||
android:padding="15dp"
|
||||
app:layout_constraintStart_toStartOf="@id/digit_sharp"
|
||||
app:layout_constraintEnd_toEndOf="@id/digit_sharp"
|
||||
app:layout_constraintTop_toTopOf="@id/call"
|
||||
app:layout_constraintBottom_toBottomOf="@id/call"
|
||||
app:layout_constraintTop_toTopOf="@id/call_barrier"
|
||||
app:tint="?attr/color_main2_600" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue