Improved call hold/pause user experience
This commit is contained in:
@ -198,6 +198,12 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
||||
case UA_EVENT_CALL_ESTABLISHED:
|
||||
len = re_snprintf(event_buf, sizeof event_buf, "call established");
|
||||
break;
|
||||
case UA_EVENT_CALL_REMOTE_SDP:
|
||||
if (strcmp(prm, "offer") != 0)
|
||||
return;
|
||||
ardir = sdp_media_rdir(stream_sdpmedia(audio_strm(call_audio(call))));
|
||||
len = re_snprintf(event_buf, sizeof event_buf, "call update,%d", ardir);
|
||||
break;
|
||||
case UA_EVENT_CALL_MENC:
|
||||
if (prm[0] == '0')
|
||||
len = re_snprintf(event_buf, sizeof event_buf, "call secure");
|
||||
|
||||
@ -695,6 +695,17 @@ class BaresipService: Service() {
|
||||
if (!Utils.isVisible())
|
||||
return
|
||||
}
|
||||
"call update" -> {
|
||||
val call = Call.ofCallp(callp)
|
||||
if (call == null) {
|
||||
Log.w("Baresip", "Call $callp that is updated is not found")
|
||||
return
|
||||
}
|
||||
when (ev[1]) {
|
||||
"0", "1" -> call.held = true
|
||||
"2", "3" -> call.held = false
|
||||
}
|
||||
}
|
||||
"call verified", "call secure" -> {
|
||||
val call = Call.ofCallp(callp)
|
||||
if (call == null) {
|
||||
|
||||
@ -7,6 +7,7 @@ class Call(val callp: String, val ua: UserAgent, val peerUri: String, val dir: S
|
||||
var status: String, val dtmfWatcher: TextWatcher?) {
|
||||
|
||||
var onhold = false
|
||||
var held = false
|
||||
var security = 0
|
||||
var zid = ""
|
||||
var hasHistory = false
|
||||
|
||||
@ -64,6 +64,7 @@ class MainActivity : AppCompatActivity() {
|
||||
private lateinit var dtmf: EditText
|
||||
private var dtmfWatcher: TextWatcher? = null
|
||||
private lateinit var infoButton: ImageButton
|
||||
private lateinit var onHoldNotice: TextView
|
||||
private lateinit var uaAdapter: UaSpinnerAdapter
|
||||
private lateinit var aorSpinner: Spinner
|
||||
private lateinit var imm: InputMethodManager
|
||||
@ -140,6 +141,7 @@ class MainActivity : AppCompatActivity() {
|
||||
transferButton = binding.transferButton
|
||||
dtmf = binding.dtmf
|
||||
infoButton = binding.info
|
||||
onHoldNotice = binding.onHoldNotice
|
||||
voicemailButton = binding.voicemailButton
|
||||
contactsButton = binding.contactsButton
|
||||
messagesButton = binding.messagesButton
|
||||
@ -361,12 +363,12 @@ class MainActivity : AppCompatActivity() {
|
||||
Log.d(TAG, "AoR $aor resuming call ${call.callp} with ${callUri.text}")
|
||||
call.resume()
|
||||
call.onhold = false
|
||||
holdButton.setImageResource(R.drawable.pause)
|
||||
holdButton.setImageResource(R.drawable.resume)
|
||||
} else {
|
||||
Log.d(TAG, "AoR $aor holding call ${call.callp} with ${callUri.text}")
|
||||
call.hold()
|
||||
call.onhold = true
|
||||
holdButton.setImageResource(R.drawable.play)
|
||||
holdButton.setImageResource(R.drawable.hold)
|
||||
}
|
||||
}
|
||||
|
||||
@ -943,6 +945,9 @@ class MainActivity : AppCompatActivity() {
|
||||
showCall(ua)
|
||||
}
|
||||
}
|
||||
"call update" -> {
|
||||
showCall(ua)
|
||||
}
|
||||
"call verify" -> {
|
||||
val callp = params[1]
|
||||
val call = Call.ofCallp(callp)
|
||||
@ -1682,6 +1687,7 @@ class MainActivity : AppCompatActivity() {
|
||||
BaresipService.isMicMuted = false
|
||||
micIcon!!.setIcon(R.drawable.mic_on)
|
||||
}
|
||||
onHoldNotice.visibility = View.GONE
|
||||
} else {
|
||||
swipeRefresh.isEnabled = false
|
||||
val call = showCall ?: Call.uaCalls(ua, "")[0]
|
||||
@ -1699,6 +1705,7 @@ class MainActivity : AppCompatActivity() {
|
||||
answerButton.visibility = View.INVISIBLE
|
||||
rejectButton.visibility = View.INVISIBLE
|
||||
callControl.visibility = View.INVISIBLE
|
||||
onHoldNotice.visibility = View.GONE
|
||||
dialpadButton.isEnabled = false
|
||||
}
|
||||
"incoming" -> {
|
||||
@ -1714,6 +1721,7 @@ class MainActivity : AppCompatActivity() {
|
||||
rejectButton.visibility = View.VISIBLE
|
||||
rejectButton.isEnabled = true
|
||||
callControl.visibility = View.INVISIBLE
|
||||
onHoldNotice.visibility = View.GONE
|
||||
dialpadButton.isEnabled = false
|
||||
}
|
||||
"connected" -> {
|
||||
@ -1747,9 +1755,9 @@ class MainActivity : AppCompatActivity() {
|
||||
answerButton.visibility = View.INVISIBLE
|
||||
rejectButton.visibility = View.INVISIBLE
|
||||
if (call.onhold) {
|
||||
holdButton.setImageResource(R.drawable.play)
|
||||
holdButton.setImageResource(R.drawable.resume)
|
||||
} else {
|
||||
holdButton.setImageResource(R.drawable.pause)
|
||||
holdButton.setImageResource(R.drawable.hold)
|
||||
}
|
||||
dtmf.isEnabled = true
|
||||
dtmf.requestFocus()
|
||||
@ -1764,6 +1772,13 @@ class MainActivity : AppCompatActivity() {
|
||||
dialpadButton.isEnabled = false
|
||||
infoButton.isEnabled = true
|
||||
callControl.visibility = View.VISIBLE
|
||||
if (call.held) {
|
||||
imm.hideSoftInputFromWindow(dtmf.windowToken, 0)
|
||||
onHoldNotice.text = getString(R.string.call_on_hold_by_peer)
|
||||
onHoldNotice.visibility = View.VISIBLE
|
||||
} else {
|
||||
onHoldNotice.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
<vector android:height="48dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@color/colorSecondaryDark" android:pathData="M10,16.5l6,-4.5 -6,-4.5v9zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
|
||||
</vector>
|
||||
4
app/src/main/res/drawable/resume.xml
Normal file
4
app/src/main/res/drawable/resume.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<vector android:height="48dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@color/colorAccent" android:pathData="M9,16h2L11,8L9,8v8zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM13,16h2L15,8h-2v8z"/>
|
||||
</vector>
|
||||
@ -214,17 +214,34 @@
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/onHoldNotice"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/buttons"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@color/colorAccent"
|
||||
android:text="@string/call_on_hold_by_peer" >
|
||||
</TextView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="end"
|
||||
android:layout_alignParentBottom="true" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/voicemailButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:src="@drawable/voicemail"
|
||||
android:layout_toStartOf="@id/contactsButton"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:visibility="invisible"
|
||||
android:contentDescription="@string/voicemail" >
|
||||
</ImageButton>
|
||||
|
||||
@ -234,9 +251,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:src="@drawable/contacts"
|
||||
android:layout_toStartOf="@id/messagesButton"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:contentDescription="@string/contacts" >
|
||||
</ImageButton>
|
||||
@ -247,9 +262,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:src="@drawable/messages"
|
||||
android:layout_toStartOf="@id/callsButton"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:contentDescription="@string/messages" >
|
||||
</ImageButton>
|
||||
@ -258,9 +271,7 @@
|
||||
android:id="@+id/callsButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toStartOf="@id/dialpadButton"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:padding="0dp"
|
||||
android:background="@null"
|
||||
@ -273,12 +284,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:background="@null"
|
||||
android:src="@drawable/dialpad_off"
|
||||
android:contentDescription="@string/dialpad" >
|
||||
</ImageButton>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@ -429,6 +429,7 @@
|
||||
<string name="call_is_secure">This call is SECURE and peer is VERIFIED!
|
||||
Do you want to unverify the peer?
|
||||
</string>
|
||||
<string name="call_on_hold_by_peer">Call is on hold by peer</string>
|
||||
<string name="unverify">Unverify</string>
|
||||
<string name="backed_up">Application data has been backed up to file \'%1$s\'. In Android
|
||||
versions 9 and below, the file is in Download folder.</string>
|
||||
|
||||
Reference in New Issue
Block a user