Moved call mute button from call control to action bar
This commit is contained in:
@ -881,19 +881,6 @@ Java_com_tutpro_baresip_Api_account_1set_1medianat(JNIEnv *env, jobject thiz,
|
||||
return res;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_tutpro_baresip_Api_account_1sipnat(JNIEnv *env, jobject thiz, jstring javaAcc)
|
||||
{
|
||||
const char *native_acc = (*env)->GetStringUTFChars(env, javaAcc, 0);
|
||||
struct account *acc = (struct account *) strtoul(native_acc, NULL, 10);
|
||||
(*env)->ReleaseStringUTFChars(env, javaAcc, native_acc);
|
||||
if (acc) {
|
||||
const char *sipnat = account_sipnat(acc);
|
||||
if (sipnat) return (*env)->NewStringUTF(env, sipnat);
|
||||
}
|
||||
return (*env)->NewStringUTF(env, "");
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_tutpro_baresip_Api_account_1set_1sipnat(JNIEnv *env, jobject thiz,
|
||||
jstring javaAcc, jstring javaSipNat) {
|
||||
@ -1271,6 +1258,22 @@ Java_com_tutpro_baresip_Api_ua_1answer(JNIEnv *env, jobject thiz, jstring javaUA
|
||||
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_tutpro_baresip_Api_calls_1mute(JNIEnv *env, jobject thiz, jboolean mute) {
|
||||
struct le *ua_le;
|
||||
struct le *call_le;
|
||||
LOGD("muting calls %d\n", mute);
|
||||
re_thread_enter();
|
||||
for (ua_le = list_head(uag_list()); ua_le != NULL; ua_le = ua_le->next) {
|
||||
const struct ua *ua = ua_le->data;
|
||||
for (call_le = list_head(ua_calls(ua)); call_le != NULL; call_le = call_le->next) {
|
||||
const struct call *call = call_le->data;
|
||||
audio_mute(call_audio(call), mute);
|
||||
}
|
||||
}
|
||||
re_thread_leave();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_tutpro_baresip_Api_ua_1debug(JNIEnv *env, jobject thiz, jstring javaUA) {
|
||||
const char *native_ua = (*env)->GetStringUTFChars(env, javaUA, 0);
|
||||
|
||||
@ -2,9 +2,6 @@ package com.tutpro.baresip
|
||||
|
||||
object Api {
|
||||
|
||||
const val AF_UNSPEC = 0
|
||||
// const val AF_INET = 2
|
||||
const val AF_INET6 = 10
|
||||
const val VIDMODE_OFF = 0
|
||||
// const val VIDMODE_ON = 1
|
||||
const val ANSWERMODE_MANUAL = 0
|
||||
@ -63,6 +60,7 @@ object Api {
|
||||
external fun ua_answer(uap: String, callp: String, video: Int)
|
||||
external fun ua_debug(uap: String)
|
||||
|
||||
external fun calls_mute(mute: Boolean)
|
||||
external fun call_peeruri(callp: String): String
|
||||
|
||||
external fun message_send(uap: String, peer_uri: String, message: String, time: String): Int
|
||||
|
||||
@ -1404,6 +1404,7 @@ class BaresipService: Service() {
|
||||
var sipTrace = false
|
||||
var callActionUri = ""
|
||||
var isMainVisible = false
|
||||
var isMicMuted = false
|
||||
|
||||
val uas = ArrayList<UserAgent>()
|
||||
val status = ArrayList<Int>()
|
||||
|
||||
@ -32,14 +32,6 @@ 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)
|
||||
}
|
||||
|
||||
@ -53,9 +53,8 @@ class MainActivity : AppCompatActivity() {
|
||||
private lateinit var hangupButton: ImageButton
|
||||
private lateinit var answerButton: ImageButton
|
||||
private lateinit var rejectButton: ImageButton
|
||||
private lateinit var callControl: HorizontalScrollView
|
||||
private lateinit var callControl: RelativeLayout
|
||||
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
|
||||
@ -74,6 +73,7 @@ class MainActivity : AppCompatActivity() {
|
||||
private lateinit var serviceEventReceiver: BroadcastReceiver
|
||||
private lateinit var quitTimer: CountDownTimer
|
||||
private lateinit var stopState: String
|
||||
private var micIcon: MenuItem? = null
|
||||
private var speakerIcon: MenuItem? = null
|
||||
private lateinit var swipeRefresh: SwipeRefreshLayout
|
||||
private lateinit var requestPermissionLauncher: ActivityResultLauncher<String>
|
||||
@ -107,6 +107,8 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
||||
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
|
||||
val intentAction = intent.getStringExtra("action")
|
||||
@ -135,7 +137,6 @@ class MainActivity : AppCompatActivity() {
|
||||
rejectButton = binding.rejectButton
|
||||
callControl = binding.callControl
|
||||
holdButton = binding.holdButton
|
||||
micButton = binding.micButton
|
||||
transferButton = binding.transferButton
|
||||
dtmf = binding.dtmf
|
||||
infoButton = binding.info
|
||||
@ -371,21 +372,6 @@ 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])
|
||||
}
|
||||
@ -1137,13 +1123,23 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
||||
menuInflater.inflate(R.menu.main_menu, menu)
|
||||
|
||||
menuInflater.inflate(R.menu.mic_icon, menu)
|
||||
micIcon = menu.findItem(R.id.micIcon)
|
||||
if (BaresipService.isMicMuted)
|
||||
micIcon!!.setIcon(R.drawable.mic_off)
|
||||
else
|
||||
micIcon!!.setIcon(R.drawable.mic_on)
|
||||
|
||||
menuInflater.inflate(R.menu.speaker_icon, menu)
|
||||
speakerIcon = menu.findItem(R.id.speakerIcon)
|
||||
if (am.isSpeakerphoneOn)
|
||||
speakerIcon!!.setIcon(R.drawable.speaker_on)
|
||||
else
|
||||
speakerIcon!!.setIcon(R.drawable.speaker_off)
|
||||
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
@ -1151,6 +1147,17 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
when (item.itemId) {
|
||||
|
||||
R.id.micIcon -> {
|
||||
BaresipService.isMicMuted = !BaresipService.isMicMuted
|
||||
if (BaresipService.isMicMuted) {
|
||||
item.setIcon(R.drawable.mic_off)
|
||||
Api.calls_mute(true)
|
||||
} else {
|
||||
item.setIcon(R.drawable.mic_on)
|
||||
Api.calls_mute(false)
|
||||
}
|
||||
}
|
||||
|
||||
R.id.speakerIcon -> {
|
||||
am.isSpeakerphoneOn = !am.isSpeakerphoneOn
|
||||
if (am.isSpeakerphoneOn)
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
<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>
|
||||
@ -1,9 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:tint="@color/colorAccent"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/colorSecondaryDark"
|
||||
android:fillColor="#FF000000"
|
||||
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>
|
||||
|
||||
10
app/src/main/res/drawable/mic_on.xml
Normal file
10
app/src/main/res/drawable/mic_on.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:tint="@color/colorGrayLight"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
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>
|
||||
@ -146,80 +146,65 @@
|
||||
android:contentDescription="@string/reject" >
|
||||
</ImageButton>
|
||||
|
||||
<HorizontalScrollView
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="70dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="invisible"
|
||||
android:id="@+id/callControl" >
|
||||
|
||||
<RelativeLayout
|
||||
<ImageButton
|
||||
android:id="@+id/holdButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
android:padding="0dp"
|
||||
android:src="@drawable/pause"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:contentDescription="@string/hold" >
|
||||
</ImageButton>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/holdButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:src="@drawable/pause"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:contentDescription="@string/hold" >
|
||||
</ImageButton>
|
||||
<ImageButton
|
||||
android:id="@+id/transferButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:src="@drawable/call_transfer"
|
||||
android:background="@null"
|
||||
android:layout_marginStart="60dp"
|
||||
android:clickable="false"
|
||||
android:contentDescription="@string/call_transfer" >
|
||||
</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="60dp"
|
||||
android:clickable="false"
|
||||
android:contentDescription="@string/mic" >
|
||||
</ImageButton>
|
||||
<EditText
|
||||
android:id="@+id/dtmf"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="120dp"
|
||||
android:singleLine="true"
|
||||
android:scrollHorizontally="true"
|
||||
android:hint="@string/dtmf"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="phone"
|
||||
android:textSize="20sp" >
|
||||
</EditText>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/transferButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:src="@drawable/call_transfer"
|
||||
android:background="@null"
|
||||
android:layout_marginStart="120dp"
|
||||
android:clickable="false"
|
||||
android:contentDescription="@string/call_transfer" >
|
||||
</ImageButton>
|
||||
<ImageButton
|
||||
android:id="@+id/info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:src="@drawable/info"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:contentDescription="@string/call_info" >
|
||||
</ImageButton>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dtmf"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="180dp"
|
||||
android:hint="@string/dtmf"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="phone"
|
||||
android:textSize="20sp" >
|
||||
</EditText>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:layout_marginStart="250dp"
|
||||
android:src="@drawable/info"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:contentDescription="@string/call_info" >
|
||||
</ImageButton>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user