Added button to turn microphone on/off during call
This commit is contained in:
@ -1406,6 +1406,22 @@ Java_com_tutpro_baresip_Call_call_1unhold(JNIEnv *env, jobject thiz, jstring jav
|
||||
return ret;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_tutpro_baresip_Call_call_1ismuted(JNIEnv *env, jobject thiz, jstring jCall) {
|
||||
const char *native_call = (*env)->GetStringUTFChars(env, jCall, 0);
|
||||
struct call *call = (struct call *) strtoul(native_call, NULL, 10);
|
||||
(*env)->ReleaseStringUTFChars(env, jCall, native_call);
|
||||
return audio_ismuted(call_audio(call));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_tutpro_baresip_Call_call_1mute(JNIEnv *env, jobject thiz, jstring jCall, jboolean mute) {
|
||||
const char *native_call = (*env)->GetStringUTFChars(env, jCall, 0);
|
||||
struct call *call = (struct call *) strtoul(native_call, NULL, 10);
|
||||
(*env)->ReleaseStringUTFChars(env, jCall, native_call);
|
||||
audio_mute(call_audio(call), mute);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_tutpro_baresip_Call_call_1transfer(JNIEnv *env, jobject thiz, jstring jCall,
|
||||
jstring jPeer) {
|
||||
|
||||
@ -32,6 +32,14 @@ class Call(val callp: String, val ua: UserAgent, val peerUri: String, val dir: S
|
||||
return call_hold(callp)
|
||||
}
|
||||
|
||||
fun isMuted(): Boolean {
|
||||
return call_ismuted(callp)
|
||||
}
|
||||
|
||||
fun mute(mute: Boolean) {
|
||||
call_mute(callp, mute)
|
||||
}
|
||||
|
||||
fun unhold(): Int {
|
||||
return call_unhold(callp)
|
||||
}
|
||||
@ -64,6 +72,8 @@ class Call(val callp: String, val ua: UserAgent, val peerUri: String, val dir: S
|
||||
private external fun call_connect(callp: String, peer_uri: String): Int
|
||||
private external fun call_hold(callp: String): Int
|
||||
private external fun call_unhold(callp: String): Int
|
||||
private external fun call_ismuted(callp: String): Boolean
|
||||
private external fun call_mute(callp: String, mute: Boolean)
|
||||
private external fun call_transfer(callp: String, peer_uri: String): Int
|
||||
private external fun call_send_digit(callp: String, digit: Char): Int
|
||||
private external fun call_notify_sipfrag(callp: String, code: Int, reason: String)
|
||||
|
||||
@ -48,6 +48,7 @@ class MainActivity : AppCompatActivity() {
|
||||
private lateinit var answerButton: ImageButton
|
||||
private lateinit var rejectButton: ImageButton
|
||||
private lateinit var holdButton: ImageButton
|
||||
private lateinit var micButton: ImageButton
|
||||
private lateinit var transferButton: ImageButton
|
||||
private lateinit var voicemailButton: ImageButton
|
||||
private lateinit var contactsButton: ImageButton
|
||||
@ -124,6 +125,7 @@ class MainActivity : AppCompatActivity() {
|
||||
answerButton = binding.answerButton
|
||||
rejectButton = binding.rejectButton
|
||||
holdButton = binding.holdButton
|
||||
micButton = binding.micButton
|
||||
transferButton = binding.transferButton
|
||||
dtmf = binding.dtmf
|
||||
infoButton = binding.info
|
||||
@ -380,6 +382,21 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
micButton.setOnClickListener {
|
||||
val ua = UserAgent.uas()[aorSpinner.selectedItemPosition]
|
||||
val aor = ua.account.aor
|
||||
val call = Call.uaCalls(ua, "")[0]
|
||||
if (call.isMuted()) {
|
||||
Log.d(TAG, "AoR $aor un-muting call ${call.callp} with ${callUri.text}")
|
||||
call.mute(false)
|
||||
micButton.setImageResource(R.drawable.mic)
|
||||
} else {
|
||||
Log.d(TAG, "AoR $aor muting call ${call.callp} with ${callUri.text}")
|
||||
call.mute(true)
|
||||
micButton.setImageResource(R.drawable.mic_off)
|
||||
}
|
||||
}
|
||||
|
||||
transferButton.setOnClickListener {
|
||||
callTransfer(UserAgent.uas()[aorSpinner.selectedItemPosition])
|
||||
}
|
||||
@ -1605,6 +1622,7 @@ class MainActivity : AppCompatActivity() {
|
||||
answerButton.visibility = View.INVISIBLE
|
||||
rejectButton.visibility = View.INVISIBLE
|
||||
holdButton.visibility = View.INVISIBLE
|
||||
micButton.visibility = View.INVISIBLE
|
||||
transferButton.visibility = View.INVISIBLE
|
||||
dtmf.visibility = View.INVISIBLE
|
||||
dialpadButton.isEnabled = true
|
||||
@ -1626,6 +1644,7 @@ class MainActivity : AppCompatActivity() {
|
||||
answerButton.visibility = View.INVISIBLE
|
||||
rejectButton.visibility = View.INVISIBLE
|
||||
holdButton.visibility = View.INVISIBLE
|
||||
micButton.visibility = View.INVISIBLE
|
||||
transferButton.visibility = View.INVISIBLE
|
||||
dtmf.visibility = View.INVISIBLE
|
||||
dialpadButton.isEnabled = false
|
||||
@ -1645,6 +1664,7 @@ class MainActivity : AppCompatActivity() {
|
||||
rejectButton.visibility = View.VISIBLE
|
||||
rejectButton.isEnabled = true
|
||||
holdButton.visibility = View.INVISIBLE
|
||||
micButton.visibility = View.INVISIBLE
|
||||
transferButton.visibility = View.INVISIBLE
|
||||
dtmf.visibility = View.INVISIBLE
|
||||
dialpadButton.isEnabled = false
|
||||
@ -1684,6 +1704,7 @@ class MainActivity : AppCompatActivity() {
|
||||
holdButton.setImageResource(R.drawable.pause)
|
||||
}
|
||||
holdButton.visibility = View.VISIBLE
|
||||
micButton.visibility = View.VISIBLE
|
||||
transferButton.visibility = View.VISIBLE
|
||||
dtmf.visibility = View.VISIBLE
|
||||
dtmf.isEnabled = true
|
||||
|
||||
9
app/src/main/res/drawable/mic.xml
Normal file
9
app/src/main/res/drawable/mic.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/colorSecondaryDark"
|
||||
android:pathData="M12,14c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6c0,1.66 1.34,3 3,3zM17.3,11c0,3 -2.54,5.1 -5.3,5.1S6.7,14 6.7,11L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c3.28,-0.48 6,-3.3 6,-6.72h-1.7z"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/mic_off.xml
Normal file
9
app/src/main/res/drawable/mic_off.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/colorSecondaryDark"
|
||||
android:pathData="M19,11h-1.7c0,0.74 -0.16,1.43 -0.43,2.05l1.23,1.23c0.56,-0.98 0.9,-2.09 0.9,-3.28zM14.98,11.17c0,-0.06 0.02,-0.11 0.02,-0.17L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v0.18l5.98,5.99zM4.27,3L3,4.27l6.01,6.01L9.01,11c0,1.66 1.33,3 2.99,3 0.22,0 0.44,-0.03 0.65,-0.08l1.66,1.66c-0.71,0.33 -1.5,0.52 -2.31,0.52 -2.76,0 -5.3,-2.1 -5.3,-5.1L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c0.91,-0.13 1.77,-0.45 2.54,-0.9L19.73,21 21,19.73 4.27,3z"/>
|
||||
</vector>
|
||||
@ -159,6 +159,19 @@
|
||||
android:contentDescription="@string/hold" >
|
||||
</ImageButton>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/micButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:src="@drawable/mic"
|
||||
android:background="@null"
|
||||
android:layout_marginStart="130dp"
|
||||
android:clickable="false"
|
||||
android:visibility="invisible"
|
||||
android:contentDescription="@string/mic" >
|
||||
</ImageButton>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/transferButton"
|
||||
android:layout_width="wrap_content"
|
||||
@ -166,27 +179,12 @@
|
||||
android:padding="0dp"
|
||||
android:src="@drawable/call_transfer"
|
||||
android:background="@null"
|
||||
android:layout_marginStart="135dp"
|
||||
android:layout_marginStart="195dp"
|
||||
android:clickable="false"
|
||||
android:visibility="invisible"
|
||||
android:contentDescription="@string/call_transfer" >
|
||||
</ImageButton>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dtmf"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@+id/transferButton"
|
||||
android:layout_toStartOf="@+id/info"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:hint="@string/dtmf"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="phone"
|
||||
android:textSize="20sp"
|
||||
android:visibility="invisible">
|
||||
</EditText>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/info"
|
||||
android:layout_width="wrap_content"
|
||||
@ -203,6 +201,27 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/dtmfRow"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/callRow" >
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dtmf"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:hint="@string/dtmf"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="phone"
|
||||
android:textSize="20sp"
|
||||
android:visibility="invisible" >
|
||||
</EditText>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
@ -428,6 +428,7 @@
|
||||
<string name="allow_video_send">Salli video videon lähetys puhelussa \'%1$s\'?</string>
|
||||
<string name="allow_video_recv">Salli video videon vastaanotto puhelussa \'%1$s\'?</string>
|
||||
<string name="hold">Aseta puhelu pitoon</string>
|
||||
<string name="mic">Mikrofoni päälle/pois</string>
|
||||
<string name="call_transfer">Puhelun siirto</string>
|
||||
<string name="transfer_destination">Siirron kohde</string>
|
||||
<string name="transfer">Siirto</string>
|
||||
|
||||
@ -388,7 +388,8 @@
|
||||
<string name="allow_video">Accept sending and receiving video with \'%1$s\'?</string>
|
||||
<string name="allow_video_send">Accept sending of video to \'%1$s\'?</string>
|
||||
<string name="allow_video_recv">Accept receiving video from \'%1$s\'?</string>
|
||||
<string name="hold">Hold</string>
|
||||
<string name="hold">Call Hold/Unhold</string>
|
||||
<string name="mic">Microphone On/Off</string>
|
||||
<string name="call_transfer">Call Transfer</string>
|
||||
<string name="transfer_destination">Transfer destination</string>
|
||||
<string name="transfer">Transfer</string>
|
||||
|
||||
Reference in New Issue
Block a user