-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Entry Widget for ongoing engagement cases
MOB-3811
- Loading branch information
1 parent
c55758d
commit 1f4342f
Showing
16 changed files
with
330 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 29 additions & 2 deletions
31
widgetssdk/src/main/java/com/glia/widgets/engagement/domain/EngagementTypeUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,48 @@ | ||
package com.glia.widgets.engagement.domain | ||
|
||
import com.glia.androidsdk.Engagement.MediaType | ||
import com.glia.widgets.helper.hasAudio | ||
import com.glia.widgets.helper.hasVideo | ||
import io.reactivex.rxjava3.core.Flowable | ||
|
||
internal interface EngagementTypeUseCase { | ||
val isAudioEngagement: Boolean | ||
val isVideoEngagement: Boolean | ||
val isMediaEngagement: Boolean | ||
val isChatEngagement: Boolean | ||
val isCallVisualizer: Boolean | ||
val isCallVisualizerScreenSharing: Boolean | ||
|
||
operator fun invoke(): Flowable<MediaType> | ||
} | ||
|
||
internal class EngagementTypeUseCaseImpl( | ||
private val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase, | ||
private val isCurrentEngagementCallVisualizerUseCase: IsCurrentEngagementCallVisualizerUseCase, | ||
private val screenSharingUseCase: ScreenSharingUseCase, | ||
private val operatorMediaUseCase: OperatorMediaUseCase, | ||
private val visitorMediaUseCase: VisitorMediaUseCase, | ||
private val isOperatorPresentUseCase: IsOperatorPresentUseCase | ||
private val isOperatorPresentUseCase: IsOperatorPresentUseCase, | ||
) : EngagementTypeUseCase { | ||
private val hasOngoingEngagement get() = isQueueingOrLiveEngagementUseCase.hasOngoingLiveEngagement | ||
private val hasAudio: Boolean get() = visitorMediaUseCase.hasAudio || operatorMediaUseCase.hasAudio | ||
private val hasVideo: Boolean get() = visitorMediaUseCase.hasVideo || operatorMediaUseCase.hasVideo | ||
override val isAudioEngagement: Boolean get() = hasOngoingEngagement && isOperatorPresentUseCase() && hasAudio | ||
override val isVideoEngagement: Boolean get() = hasOngoingEngagement && isOperatorPresentUseCase() && hasVideo | ||
private val hasAnyMedia: Boolean get() = visitorMediaUseCase.hasMedia || operatorMediaUseCase.hasMedia | ||
override val isMediaEngagement: Boolean get() = hasOngoingEngagement && isOperatorPresentUseCase() && hasAnyMedia | ||
override val isChatEngagement: Boolean get() = hasOngoingEngagement && !isCurrentEngagementCallVisualizerUseCase() && isOperatorPresentUseCase() && !hasAnyMedia | ||
override val isCallVisualizerScreenSharing: Boolean get() = isCurrentEngagementCallVisualizerUseCase() && !hasAnyMedia | ||
override val isCallVisualizer: Boolean get() = isCurrentEngagementCallVisualizerUseCase() | ||
override val isCallVisualizerScreenSharing: Boolean get() = isCurrentEngagementCallVisualizerUseCase() && screenSharingUseCase.isSharing | ||
private val operatorMediaObservable by lazy { operatorMediaUseCase() } | ||
|
||
override fun invoke(): Flowable<MediaType> { | ||
return operatorMediaObservable.map { operatorMediaState -> | ||
when { | ||
operatorMediaState.hasVideo -> MediaType.VIDEO | ||
operatorMediaState.hasAudio -> MediaType.AUDIO | ||
else -> MediaType.UNKNOWN | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.