Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/github_actions/gradle/wrapper-…
Browse files Browse the repository at this point in the history
…validation-action-3.3.2
  • Loading branch information
vitorhugods authored May 2, 2024
2 parents 8f15978 + 6142d0a commit 2b2fa7d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 31 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
android:launchMode="singleTop"
android:hardwareAccelerated="true"
android:screenOrientation="portrait"
android:taskAffinity="wire.call"
android:theme="@style/AppTheme" />

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ fun getOngoingCallIntent(
activity: Activity,
conversationId: String
) = Intent(activity, CallActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(CallActivity.EXTRA_CONVERSATION_ID, conversationId)
putExtra(CallActivity.EXTRA_SCREEN_TYPE, CallScreenType.Ongoing.name)
}
Expand All @@ -189,12 +190,14 @@ fun getOutgoingCallIntent(
activity: Activity,
conversationId: String
) = Intent(activity, CallActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(CallActivity.EXTRA_CONVERSATION_ID, conversationId)
putExtra(CallActivity.EXTRA_SCREEN_TYPE, CallScreenType.Outgoing.name)
}

fun getIncomingCallIntent(context: Context, conversationId: String) =
Intent(context.applicationContext, CallActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(CallActivity.EXTRA_CONVERSATION_ID, conversationId)
putExtra(CallActivity.EXTRA_SCREEN_TYPE, CallScreenType.Incoming.name)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import com.wire.android.mapper.UICallParticipantMapper
import com.wire.android.mapper.UserTypeMapper
import com.wire.android.media.CallRinger
import com.wire.android.model.ImageAsset
import com.wire.android.util.CurrentScreen
import com.wire.android.util.CurrentScreenManager
import com.wire.android.util.dispatchers.DispatcherProvider
import com.wire.android.util.ui.WireSessionImageLoader
import com.wire.kalium.logic.data.call.Call
Expand Down Expand Up @@ -88,7 +86,6 @@ class SharedCallingViewModel @AssistedInject constructor(
private val uiCallParticipantMapper: UICallParticipantMapper,
private val wireSessionImageLoader: WireSessionImageLoader,
private val userTypeMapper: UserTypeMapper,
private val currentScreenManager: CurrentScreenManager,
private val dispatchers: DispatcherProvider
) : ViewModel() {

Expand Down Expand Up @@ -116,18 +113,6 @@ class SharedCallingViewModel @AssistedInject constructor(
launch {
observeOnSpeaker(this)
}
launch {
observeScreenState()
}
}
}

private suspend fun observeScreenState() {
currentScreenManager.observeCurrentScreen(viewModelScope).collect {
// clear video preview when the screen is in background to avoid memory leaks
if (it == CurrentScreen.InBackground && callState.isCameraOn) {
clearVideoPreview()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fun OngoingCallScreen(
sharedCallingViewModel.clearVideoPreview()
ongoingCallViewModel.stopSendingVideoFeed()
},
navigateBack = { activity.finish() },
onCollapse = { activity.moveTaskToBack(true) },
requestVideoStreams = ongoingCallViewModel::requestVideoStreams,
hideDoubleTapToast = ongoingCallViewModel::hideDoubleTapToast,
onPermissionPermanentlyDenied = {
Expand All @@ -160,7 +160,7 @@ fun OngoingCallScreen(
}
)
BackHandler {
activity.finish()
activity.moveTaskToBack(true)
}
}

Expand All @@ -173,7 +173,8 @@ fun OngoingCallScreen(
isCameraOn = sharedCallingViewModel.callState.isCameraOn,
callStatus = sharedCallingViewModel.callState.callStatus,
startSendingVideoFeed = ongoingCallViewModel::startSendingVideoFeed,
pauseSendingVideoFeed = ongoingCallViewModel::pauseSendingVideoFeed
pauseSendingVideoFeed = ongoingCallViewModel::pauseSendingVideoFeed,
onClearVideoPreview = sharedCallingViewModel::clearVideoPreview
)
}

Expand All @@ -186,7 +187,8 @@ private fun handleVideoPreviewOnLifecycleChange(
isCameraOn: Boolean,
callStatus: CallStatus,
startSendingVideoFeed: () -> Unit,
pauseSendingVideoFeed: () -> Unit
pauseSendingVideoFeed: () -> Unit,
onClearVideoPreview: () -> Unit
) {
val lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current
DisposableEffect(lifecycleOwner, isCameraOn, callStatus) {
Expand All @@ -198,6 +200,9 @@ private fun handleVideoPreviewOnLifecycleChange(
if (event == Lifecycle.Event.ON_RESUME && callStatus == CallStatus.ESTABLISHED && isCameraOn) {
startSendingVideoFeed()
}
if (event == Lifecycle.Event.ON_DESTROY) {
onClearVideoPreview()
}
}

lifecycleOwner.lifecycle.addObserver(observer)
Expand Down Expand Up @@ -230,7 +235,7 @@ private fun OngoingCallContent(
flipCamera: () -> Unit,
setVideoPreview: (view: View) -> Unit,
clearVideoPreview: () -> Unit,
navigateBack: () -> Unit,
onCollapse: () -> Unit,
hideDoubleTapToast: () -> Unit,
onPermissionPermanentlyDenied: (type: PermissionDenialType) -> Unit,
requestVideoStreams: (participants: List<UICallParticipant>) -> Unit
Expand Down Expand Up @@ -258,7 +263,7 @@ private fun OngoingCallContent(
else -> ""
},
isCbrEnabled = isCbrEnabled,
onCollapse = navigateBack,
onCollapse = onCollapse,
protocolInfo = protocolInfo,
mlsVerificationStatus = mlsVerificationStatus,
proteusVerificationStatus = proteusVerificationStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import com.wire.android.config.TestDispatcherProvider
import com.wire.android.mapper.UICallParticipantMapper
import com.wire.android.mapper.UserTypeMapper
import com.wire.android.media.CallRinger
import com.wire.android.util.CurrentScreen
import com.wire.android.util.CurrentScreenManager
import com.wire.android.util.ui.WireSessionImageLoader
import com.wire.kalium.logic.data.call.VideoState
import com.wire.kalium.logic.data.id.ConversationId
Expand All @@ -48,7 +46,6 @@ import io.mockk.coVerify
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.verify
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
Expand Down Expand Up @@ -109,9 +106,6 @@ class SharedCallingViewModelTest {
@MockK
private lateinit var userTypeMapper: UserTypeMapper

@MockK
private lateinit var currentScreenManager: CurrentScreenManager

@MockK(relaxed = true)
private lateinit var onCompleted: () -> Unit

Expand All @@ -130,9 +124,6 @@ class SharedCallingViewModelTest {
coEvery { allCalls.invoke() } returns emptyFlow()
coEvery { observeConversationDetails.invoke(any()) } returns emptyFlow()
coEvery { observeSpeaker.invoke() } returns emptyFlow()
coEvery { currentScreenManager.observeCurrentScreen(any()) } returns MutableStateFlow(
CurrentScreen.SomeOther
)

sharedCallingViewModel = SharedCallingViewModel(
conversationId = conversationId,
Expand All @@ -152,7 +143,6 @@ class SharedCallingViewModelTest {
uiCallParticipantMapper = uiCallParticipantMapper,
wireSessionImageLoader = wireSessionImageLoader,
userTypeMapper = userTypeMapper,
currentScreenManager = currentScreenManager,
dispatchers = TestDispatcherProvider()
)
}
Expand Down

0 comments on commit 2b2fa7d

Please sign in to comment.