Display call error reason as Snack + small audio call overlay improvement
This commit is contained in:
parent
e204e8d990
commit
fd3f3a076e
5 changed files with 51 additions and 10 deletions
|
@ -142,9 +142,9 @@ repositories {
|
||||||
url file(LinphoneSdkBuildDir + '/maven_repository/')
|
url file(LinphoneSdkBuildDir + '/maven_repository/')
|
||||||
}
|
}
|
||||||
|
|
||||||
/*maven {
|
maven {
|
||||||
url "https://linphone.org/maven_repository"
|
url "https://linphone.org/maven_repository"
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -87,6 +87,12 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
coreContext.callErrorMessageResourceId.observe(this, Observer {
|
||||||
|
it.consume { messageResourceId ->
|
||||||
|
showSnackBar(messageResourceId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
binding.setGoBackToCallClickListener {
|
binding.setGoBackToCallClickListener {
|
||||||
val intent = Intent(this, CallActivity::class.java)
|
val intent = Intent(this, CallActivity::class.java)
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||||
|
|
|
@ -52,11 +52,11 @@ class SharedMainViewModel : ViewModel() {
|
||||||
|
|
||||||
val selectedContact = MutableLiveData<Contact>()
|
val selectedContact = MutableLiveData<Contact>()
|
||||||
|
|
||||||
/* Call */
|
|
||||||
|
|
||||||
var pendingCallTransfer: Boolean = false
|
|
||||||
|
|
||||||
/* Accounts */
|
/* Accounts */
|
||||||
|
|
||||||
val proxyConfigRemoved = MutableLiveData<Boolean>()
|
val proxyConfigRemoved = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
/* Call */
|
||||||
|
|
||||||
|
var pendingCallTransfer: Boolean = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,11 @@ import android.os.Vibrator
|
||||||
import android.telephony.PhoneStateListener
|
import android.telephony.PhoneStateListener
|
||||||
import android.telephony.TelephonyManager
|
import android.telephony.TelephonyManager
|
||||||
import android.view.*
|
import android.view.*
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
|
import org.linphone.R
|
||||||
import org.linphone.activities.call.CallActivity
|
import org.linphone.activities.call.CallActivity
|
||||||
import org.linphone.activities.call.IncomingCallActivity
|
import org.linphone.activities.call.IncomingCallActivity
|
||||||
import org.linphone.activities.call.OutgoingCallActivity
|
import org.linphone.activities.call.OutgoingCallActivity
|
||||||
|
@ -42,6 +44,7 @@ import org.linphone.core.tools.Log
|
||||||
import org.linphone.mediastream.Version
|
import org.linphone.mediastream.Version
|
||||||
import org.linphone.notifications.NotificationsManager
|
import org.linphone.notifications.NotificationsManager
|
||||||
import org.linphone.utils.AppUtils
|
import org.linphone.utils.AppUtils
|
||||||
|
import org.linphone.utils.Event
|
||||||
import org.linphone.utils.LinphoneUtils
|
import org.linphone.utils.LinphoneUtils
|
||||||
|
|
||||||
class CoreContext(val context: Context, coreConfig: Config) {
|
class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
|
@ -66,6 +69,10 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
NotificationsManager(context)
|
NotificationsManager(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val callErrorMessageResourceId: MutableLiveData<Event<Int>> by lazy {
|
||||||
|
MutableLiveData<Event<Int>>()
|
||||||
|
}
|
||||||
|
|
||||||
private var gsmCallActive = false
|
private var gsmCallActive = false
|
||||||
private val phoneStateListener = object : PhoneStateListener() {
|
private val phoneStateListener = object : PhoneStateListener() {
|
||||||
override fun onCallStateChanged(state: Int, phoneNumber: String?) {
|
override fun onCallStateChanged(state: Int, phoneNumber: String?) {
|
||||||
|
@ -171,6 +178,22 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
|
|
||||||
removeCallOverlay()
|
removeCallOverlay()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state == Call.State.Error) {
|
||||||
|
Log.w("[Context] Call error reason is ${call.errorInfo.reason}")
|
||||||
|
val id = when (call.errorInfo.reason) {
|
||||||
|
Reason.Busy -> R.string.call_error_user_busy
|
||||||
|
Reason.IOError -> R.string.call_error_io_error
|
||||||
|
Reason.NotAcceptable -> R.string.call_error_incompatible_media_params
|
||||||
|
Reason.NotFound -> R.string.call_error_user_not_found
|
||||||
|
else -> R.string.call_error_unknown
|
||||||
|
}
|
||||||
|
callErrorMessageResourceId.value = Event(id)
|
||||||
|
} else if (state == Call.State.End && call.errorInfo.reason == Reason.Declined) {
|
||||||
|
Log.i("[Context] Call has been declined")
|
||||||
|
val id = R.string.call_error_declined
|
||||||
|
callErrorMessageResourceId.value = Event(id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,6 +340,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
val address: Address? = core.interpretUrl(stringAddress)
|
val address: Address? = core.interpretUrl(stringAddress)
|
||||||
if (address == null) {
|
if (address == null) {
|
||||||
Log.e("[Context] Failed to parse $stringAddress, abort outgoing call")
|
Log.e("[Context] Failed to parse $stringAddress, abort outgoing call")
|
||||||
|
callErrorMessageResourceId.value = Event(R.string.call_error_network_unreachable)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,6 +350,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
fun startCall(address: Address, forceZRTP: Boolean = false) {
|
fun startCall(address: Address, forceZRTP: Boolean = false) {
|
||||||
if (!core.isNetworkReachable) {
|
if (!core.isNetworkReachable) {
|
||||||
Log.e("[Context] Network unreachable, abort outgoing call")
|
Log.e("[Context] Network unreachable, abort outgoing call")
|
||||||
|
callErrorMessageResourceId.value = Event(R.string.call_error_network_unreachable)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,11 +413,11 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
params.x = overlayX.toInt()
|
params.x = overlayX.toInt()
|
||||||
params.y = overlayY.toInt()
|
params.y = overlayY.toInt()
|
||||||
params.gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
|
params.gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
|
||||||
val overlay = LayoutInflater.from(context).inflate(org.linphone.R.layout.call_overlay, null)
|
val overlay = LayoutInflater.from(context).inflate(R.layout.call_overlay, null)
|
||||||
|
|
||||||
var initX = overlayX
|
var initX = overlayX
|
||||||
var initY = overlayY
|
var initY = overlayY
|
||||||
overlay.setOnTouchListener { _, event ->
|
overlay.setOnTouchListener { view, event ->
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
initX = params.x - event.rawX
|
initX = params.x - event.rawX
|
||||||
|
@ -408,8 +433,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_UP -> {
|
MotionEvent.ACTION_UP -> {
|
||||||
if (abs(overlayX - params.x) < 5 && abs(overlayY - params.y) < 5) {
|
if (abs(overlayX - params.x) < 5 && abs(overlayY - params.y) < 5) {
|
||||||
Log.i("[Core Context] Overlay clicked, go back to call view")
|
view.performClick()
|
||||||
onCallStarted()
|
|
||||||
}
|
}
|
||||||
overlayX = params.x.toFloat()
|
overlayX = params.x.toFloat()
|
||||||
overlayY = params.y.toFloat()
|
overlayY = params.y.toFloat()
|
||||||
|
@ -418,6 +442,10 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
overlay.setOnClickListener {
|
||||||
|
Log.i("[Context] Overlay clicked, go back to call view")
|
||||||
|
onCallStarted()
|
||||||
|
}
|
||||||
|
|
||||||
callOverlay = overlay
|
callOverlay = overlay
|
||||||
windowManager.addView(overlay, params)
|
windowManager.addView(overlay, params)
|
||||||
|
|
|
@ -189,6 +189,13 @@
|
||||||
<string name="call_notification_outgoing">Outgoing call</string>
|
<string name="call_notification_outgoing">Outgoing call</string>
|
||||||
<string name="call_notification_active">Call running</string>
|
<string name="call_notification_active">Call running</string>
|
||||||
<string name="call_conference_title">Conference</string>
|
<string name="call_conference_title">Conference</string>
|
||||||
|
<string name="call_error_declined">Call has been declined</string>
|
||||||
|
<string name="call_error_user_busy">User is busy</string>
|
||||||
|
<string name="call_error_user_not_found">User hasn\'t been found</string>
|
||||||
|
<string name="call_error_incompatible_media_params">Incompatible media parameters</string>
|
||||||
|
<string name="call_error_network_unreachable">Network is unreachable</string>
|
||||||
|
<string name="call_error_io_error">Network error</string>
|
||||||
|
<string name="call_error_unknown">Unknown error</string>
|
||||||
|
|
||||||
<!-- Call stats -->
|
<!-- Call stats -->
|
||||||
<string name="call_stats_audio">Audio</string>
|
<string name="call_stats_audio">Audio</string>
|
||||||
|
|
Loading…
Reference in a new issue