- improved sending of dtmf digits
- renamed call uri autocompletetextview
This commit is contained in:
@@ -986,6 +986,7 @@ Java_com_tutpro_baresip_MainActivity_call_1send_1digit(JNIEnv *env, jobject thiz
|
|||||||
struct call *call = (struct call *)strtoul(native_call, NULL, 10);
|
struct call *call = (struct call *)strtoul(native_call, NULL, 10);
|
||||||
LOGD("sending DTMF digit '%c' to call %s\n", (char)native_digit, native_call);
|
LOGD("sending DTMF digit '%c' to call %s\n", (char)native_digit, native_call);
|
||||||
int res = call_send_digit(call, (char)native_digit);
|
int res = call_send_digit(call, (char)native_digit);
|
||||||
|
if (!res) res = call_send_digit(call, KEYCODE_REL);
|
||||||
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
appContext = applicationContext
|
appContext = applicationContext
|
||||||
layout = findViewById(R.id.mainActivityLayout) as RelativeLayout
|
layout = findViewById(R.id.mainActivityLayout) as RelativeLayout
|
||||||
callTitle = findViewById(R.id.callTitle) as TextView
|
callTitle = findViewById(R.id.callTitle) as TextView
|
||||||
callUri = findViewById(R.id.uri) as AutoCompleteTextView
|
callUri = findViewById(R.id.callUri) as AutoCompleteTextView
|
||||||
securityButton = findViewById(R.id.securityButton) as ImageButton
|
securityButton = findViewById(R.id.securityButton) as ImageButton
|
||||||
callButton = findViewById(R.id.callButton) as ImageButton
|
callButton = findViewById(R.id.callButton) as ImageButton
|
||||||
hangupButton = findViewById(R.id.hangupButton) as ImageButton
|
hangupButton = findViewById(R.id.hangupButton) as ImageButton
|
||||||
@@ -276,7 +276,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val ua = uas[aorSpinner.selectedItemPosition]
|
val ua = uas[aorSpinner.selectedItemPosition]
|
||||||
val aor = ua.account.aor
|
val aor = ua.account.aor
|
||||||
if (!ONE_CALL_ONLY || calls.isEmpty()) {
|
if (!ONE_CALL_ONLY || calls.isEmpty()) {
|
||||||
val uriText = (findViewById(R.id.uri) as EditText).text.toString().trim()
|
val uriText = callUri.text.toString().trim()
|
||||||
if (uriText.length > 0) {
|
if (uriText.length > 0) {
|
||||||
var uri = ContactsActivity.findContactURI(uriText)
|
var uri = ContactsActivity.findContactURI(uriText)
|
||||||
if (!uri.startsWith("sip:")) {
|
if (!uri.startsWith("sip:")) {
|
||||||
@@ -305,8 +305,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val ua = uas[aorSpinner.selectedItemPosition]
|
val ua = uas[aorSpinner.selectedItemPosition]
|
||||||
val aor = ua.account.aor
|
val aor = ua.account.aor
|
||||||
val callp = Call.uaCalls(calls, ua,"")[0].callp
|
val callp = Call.uaCalls(calls, ua,"")[0].callp
|
||||||
Log.d("Baresip", "AoR $aor hanging up call $callp with " +
|
Log.d("Baresip", "AoR $aor hanging up call $callp with ${callUri.text}")
|
||||||
(findViewById(R.id.uri) as EditText).text)
|
|
||||||
hangupButton.isEnabled = false
|
hangupButton.isEnabled = false
|
||||||
ua_hangup(ua.uap, callp, 0, "")
|
ua_hangup(ua.uap, callp, 0, "")
|
||||||
}
|
}
|
||||||
@@ -315,8 +314,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val ua = uas[aorSpinner.selectedItemPosition]
|
val ua = uas[aorSpinner.selectedItemPosition]
|
||||||
val aor = ua.account.aor
|
val aor = ua.account.aor
|
||||||
val callp = Call.uaCalls(calls, ua,"in")[0].callp
|
val callp = Call.uaCalls(calls, ua,"in")[0].callp
|
||||||
Log.d("Baresip", "AoR $aor answering call $callp from " +
|
Log.d("Baresip", "AoR $aor answering call $callp from ${callUri.text}")
|
||||||
(findViewById(R.id.uri) as EditText).text)
|
|
||||||
answerButton.isEnabled = false
|
answerButton.isEnabled = false
|
||||||
ua_answer(ua.uap, callp)
|
ua_answer(ua.uap, callp)
|
||||||
}
|
}
|
||||||
@@ -325,8 +323,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val ua = uas[aorSpinner.selectedItemPosition]
|
val ua = uas[aorSpinner.selectedItemPosition]
|
||||||
val aor = ua.account.aor
|
val aor = ua.account.aor
|
||||||
val callp = Call.uaCalls(calls, ua,"in")[0].callp
|
val callp = Call.uaCalls(calls, ua,"in")[0].callp
|
||||||
Log.d("Baresip", "AoR $aor rejecting call $callp from " +
|
Log.d("Baresip", "AoR $aor rejecting call $callp from ${callUri.text}")
|
||||||
(findViewById(R.id.uri) as EditText).text)
|
|
||||||
rejectButton.isEnabled = false
|
rejectButton.isEnabled = false
|
||||||
ua_hangup(ua.uap, callp, 486, "Rejected")
|
ua_hangup(ua.uap, callp, 486, "Rejected")
|
||||||
}
|
}
|
||||||
@@ -336,14 +333,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val aor = ua.account.aor
|
val aor = ua.account.aor
|
||||||
val call = Call.uaCalls(calls, ua,"")[0]
|
val call = Call.uaCalls(calls, ua,"")[0]
|
||||||
if (call.onhold) {
|
if (call.onhold) {
|
||||||
Log.d("Baresip", "AoR $aor resuming call ${call.callp} with " +
|
Log.d("Baresip", "AoR $aor resuming call ${call.callp} with ${callUri.text}")
|
||||||
(findViewById(R.id.uri) as EditText).text)
|
|
||||||
call_unhold(call.callp)
|
call_unhold(call.callp)
|
||||||
call.onhold = false
|
call.onhold = false
|
||||||
holdButton.setImageResource(R.drawable.pause)
|
holdButton.setImageResource(R.drawable.pause)
|
||||||
} else {
|
} else {
|
||||||
Log.d("Baresip", "AoR $aor holding call ${call.callp} with " +
|
Log.d("Baresip", "AoR $aor holding call ${call.callp} with ${callUri.text}")
|
||||||
(findViewById(R.id.uri) as EditText).text)
|
|
||||||
call_hold(call.callp)
|
call_hold(call.callp)
|
||||||
call.onhold = true
|
call.onhold = true
|
||||||
holdButton.setImageResource(R.drawable.play)
|
holdButton.setImageResource(R.drawable.play)
|
||||||
@@ -921,9 +916,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
CALLS_CODE -> {
|
CALLS_CODE -> {
|
||||||
val acc = uas[aorSpinner.selectedItemPosition].account
|
val acc = uas[aorSpinner.selectedItemPosition].account
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
if (data != null) {
|
if (data != null)
|
||||||
(findViewById(R.id.uri) as EditText).setText(data.getStringExtra("peer_uri"))
|
callUri.setText(data.getStringExtra("peer_uri"))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (resultCode == RESULT_CANCELED) {
|
if (resultCode == RESULT_CANCELED) {
|
||||||
Log.d("Baresip", "History canceled")
|
Log.d("Baresip", "History canceled")
|
||||||
@@ -946,7 +940,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
"You have not granted microphone permission.", Toast.LENGTH_SHORT).show()
|
"You have not granted microphone permission.", Toast.LENGTH_SHORT).show()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
(findViewById(R.id.uri) as EditText).setText(uri)
|
callUri.setText(uri)
|
||||||
callButton.visibility = View.INVISIBLE
|
callButton.visibility = View.INVISIBLE
|
||||||
val callp = ua_connect(ua.uap, uri)
|
val callp = ua_connect(ua.uap, uri)
|
||||||
if (callp != "") {
|
if (callp != "") {
|
||||||
@@ -971,13 +965,17 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return object : TextWatcher {
|
return object : TextWatcher {
|
||||||
override fun beforeTextChanged(sequence: CharSequence, start: Int, count: Int, after: Int) {}
|
override fun beforeTextChanged(sequence: CharSequence, start: Int, count: Int, after: Int) {}
|
||||||
override fun onTextChanged(sequence: CharSequence, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(sequence: CharSequence, start: Int, before: Int, count: Int) {
|
||||||
val digit = sequence.subSequence(start, start + count).toString()
|
val text = sequence.subSequence(start, start + count).toString()
|
||||||
Log.d("Baresip", "Got DTMF digit '" + digit + "'")
|
if (text.length > 0) {
|
||||||
if (digit.isNotEmpty()) call_send_digit(callp, digit[0])
|
val digit = text[0]
|
||||||
|
Log.d("Baresip", "Got DTMF digit '$digit'")
|
||||||
|
if (((digit >= '0') && (digit <= '9')) || (digit == '*') || (digit == '#'))
|
||||||
|
call_send_digit(callp, digit)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(sequence: Editable) {
|
override fun afterTextChanged(sequence: Editable) {
|
||||||
call_send_digit(callp, 4.toChar())
|
// KEYCODE_REL
|
||||||
|
// call_send_digit(callp, 4.toChar())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
android:layout_below="@id/callTitle" >
|
android:layout_below="@id/callTitle" >
|
||||||
|
|
||||||
<AutoCompleteTextView
|
<AutoCompleteTextView
|
||||||
android:id="@+id/uri"
|
android:id="@+id/callUri"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight = "1"
|
android:layout_weight = "1"
|
||||||
|
|||||||
Reference in New Issue
Block a user