From efa3aa5cf8e24726c18ce4a3493feff618db2e13 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 24 Aug 2020 15:08:52 +0200 Subject: [PATCH] Stop using internal context of VectorLocal in CallHeadsUpActionReceiver... --- .../call/service/CallHeadsUpActionReceiver.kt | 22 ++++++------------- .../app/features/settings/VectorLocale.kt | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/call/service/CallHeadsUpActionReceiver.kt b/vector/src/main/java/im/vector/app/features/call/service/CallHeadsUpActionReceiver.kt index 179ba288eb..04e7401e6c 100644 --- a/vector/src/main/java/im/vector/app/features/call/service/CallHeadsUpActionReceiver.kt +++ b/vector/src/main/java/im/vector/app/features/call/service/CallHeadsUpActionReceiver.kt @@ -21,8 +21,6 @@ import android.content.Context import android.content.Intent import im.vector.app.core.di.HasVectorInjector import im.vector.app.features.call.WebRtcPeerConnectionManager -import im.vector.app.features.notifications.NotificationUtils -import im.vector.app.features.settings.VectorLocale.context import timber.log.Timber class CallHeadsUpActionReceiver : BroadcastReceiver() { @@ -32,20 +30,14 @@ class CallHeadsUpActionReceiver : BroadcastReceiver() { const val CALL_ACTION_REJECT = 0 } - private lateinit var peerConnectionManager: WebRtcPeerConnectionManager - private lateinit var notificationUtils: NotificationUtils - - init { - val appContext = context.applicationContext - if (appContext is HasVectorInjector) { - peerConnectionManager = appContext.injector().webRtcPeerConnectionManager() - notificationUtils = appContext.injector().notificationUtils() - } - } - override fun onReceive(context: Context, intent: Intent?) { + val peerConnectionManager = (context.applicationContext as? HasVectorInjector) + ?.injector() + ?.webRtcPeerConnectionManager() + ?: return + when (intent?.getIntExtra(EXTRA_CALL_ACTION_KEY, 0)) { - CALL_ACTION_REJECT -> onCallRejectClicked() + CALL_ACTION_REJECT -> onCallRejectClicked(peerConnectionManager) } // Not sure why this should be needed @@ -56,7 +48,7 @@ class CallHeadsUpActionReceiver : BroadcastReceiver() { // context.stopService(Intent(context, CallHeadsUpService::class.java)) } - private fun onCallRejectClicked() { + private fun onCallRejectClicked(peerConnectionManager: WebRtcPeerConnectionManager) { Timber.d("onCallRejectClicked") peerConnectionManager.endCall() } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt b/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt index d2f92e300e..b9d81ab005 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt @@ -52,7 +52,7 @@ object VectorLocale { var applicationLocale = defaultLocale private set - lateinit var context: Context + private lateinit var context: Context /** * Init this object