Fixed call overlay sending to call view even if call is in incoming/outgoing state

This commit is contained in:
Sylvain Berfini 2021-07-13 10:15:16 +02:00
parent 9d4ebdb960
commit 66f86c278e
3 changed files with 23 additions and 5 deletions

View file

@ -52,6 +52,7 @@ import org.linphone.activities.main.viewmodels.SharedMainViewModel
import org.linphone.activities.navigateToDialer import org.linphone.activities.navigateToDialer
import org.linphone.compatibility.Compatibility import org.linphone.compatibility.Compatibility
import org.linphone.contact.ContactsUpdatedListenerStub import org.linphone.contact.ContactsUpdatedListenerStub
import org.linphone.core.CorePreferences
import org.linphone.core.tools.Log import org.linphone.core.tools.Log
import org.linphone.databinding.MainActivityBinding import org.linphone.databinding.MainActivityBinding
import org.linphone.utils.AppUtils import org.linphone.utils.AppUtils
@ -447,7 +448,8 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
.start() .start()
} }
MotionEvent.ACTION_UP -> { MotionEvent.ACTION_UP -> {
if (abs(initPosX - view.x) < 5 && abs(initPosY - view.y) < 5) { if (abs(initPosX - view.x) < CorePreferences.OVERLAY_CLICK_SENSITIVITY &&
abs(initPosY - view.y) < CorePreferences.OVERLAY_CLICK_SENSITIVITY) {
view.performClick() view.performClick()
} }
} }
@ -457,7 +459,7 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
} }
callOverlay.setOnClickListener { callOverlay.setOnClickListener {
coreContext.onCallStarted() coreContext.onCallOverlayClick()
} }
} }
} }

View file

@ -584,7 +584,8 @@ class CoreContext(val context: Context, coreConfig: Config) {
windowManager.updateViewLayout(overlay, params) windowManager.updateViewLayout(overlay, params)
} }
MotionEvent.ACTION_UP -> { MotionEvent.ACTION_UP -> {
if (abs(overlayX - params.x) < 5 && abs(overlayY - params.y) < 5) { if (abs(overlayX - params.x) < CorePreferences.OVERLAY_CLICK_SENSITIVITY &&
abs(overlayY - params.y) < CorePreferences.OVERLAY_CLICK_SENSITIVITY) {
view.performClick() view.performClick()
} }
overlayX = params.x.toFloat() overlayX = params.x.toFloat()
@ -595,14 +596,27 @@ class CoreContext(val context: Context, coreConfig: Config) {
true true
} }
overlay.setOnClickListener { overlay.setOnClickListener {
Log.i("[Context] Overlay clicked, go back to call view") onCallOverlayClick()
onCallStarted()
} }
callOverlay = overlay callOverlay = overlay
windowManager.addView(overlay, params) windowManager.addView(overlay, params)
} }
fun onCallOverlayClick() {
val call = core.currentCall ?: core.calls.firstOrNull()
if (call != null) {
Log.i("[Context] Overlay clicked, go back to call view")
when (call.state) {
Call.State.IncomingReceived, Call.State.IncomingEarlyMedia -> onIncomingReceived()
Call.State.OutgoingInit, Call.State.OutgoingProgress, Call.State.OutgoingRinging, Call.State.OutgoingEarlyMedia -> onOutgoingStarted()
else -> onCallStarted()
}
} else {
Log.e("[Context] Couldn't find call, why is the overlay clicked?!")
}
}
fun removeCallOverlay() { fun removeCallOverlay() {
if (callOverlay != null) { if (callOverlay != null) {
val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager

View file

@ -41,6 +41,8 @@ class CorePreferences constructor(private val context: Context) {
/* VFS encryption */ /* VFS encryption */
companion object { companion object {
const val OVERLAY_CLICK_SENSITIVITY = 10
private const val encryptedSharedPreferencesFile = "encrypted.pref" private const val encryptedSharedPreferencesFile = "encrypted.pref"
} }