Skip to content

Commit

Permalink
Devs want to implement GVA(Live engagement) to SC transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
DavDo committed Nov 26, 2024
1 parent 51de7e5 commit 420a67a
Show file tree
Hide file tree
Showing 37 changed files with 376 additions and 238 deletions.
10 changes: 5 additions & 5 deletions widgetssdk/src/main/java/com/glia/widgets/call/CallController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import com.glia.widgets.engagement.domain.EnqueueForEngagementUseCase
import com.glia.widgets.engagement.domain.FlipCameraButtonStateUseCase
import com.glia.widgets.engagement.domain.FlipVisitorCameraUseCase
import com.glia.widgets.engagement.domain.IsCurrentEngagementCallVisualizerUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrEngagementUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrLiveEngagementUseCase
import com.glia.widgets.engagement.domain.OperatorMediaUseCase
import com.glia.widgets.engagement.domain.ScreenSharingUseCase
import com.glia.widgets.engagement.domain.ToggleVisitorAudioMediaStateUseCase
Expand Down Expand Up @@ -88,7 +88,7 @@ internal class CallController(
private val toggleVisitorVideoMediaStateUseCase: ToggleVisitorVideoMediaStateUseCase,
private val flipVisitorCameraUseCase: FlipVisitorCameraUseCase,
private val flipCameraButtonStateUseCase: FlipCameraButtonStateUseCase,
private val isQueueingOrEngagementUseCase: IsQueueingOrEngagementUseCase,
private val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase,
private val enqueueForEngagementUseCase: EnqueueForEngagementUseCase,
private val decideOnQueueingUseCase: DecideOnQueueingUseCase,
private val screenSharingUseCase: ScreenSharingUseCase,
Expand Down Expand Up @@ -219,7 +219,7 @@ internal class CallController(
}

private fun tryToQueueForEngagement() {
if (!isQueueingOrEngagementUseCase()) {
if (!isQueueingOrLiveEngagementUseCase()) {
confirmationDialogUseCase { shouldShow: Boolean ->
if (shouldShow) {
dialogController.showEngagementConfirmationDialog()
Expand All @@ -231,7 +231,7 @@ internal class CallController(
}

override fun onLiveObservationDialogRequested() {
if (isQueueingOrEngagementUseCase()) return
if (isQueueingOrLiveEngagementUseCase()) return
view?.showEngagementConfirmationDialog()
}

Expand Down Expand Up @@ -403,7 +403,7 @@ internal class CallController(
}

private fun onNewOperatorMediaState(operatorMediaState: MediaState) {
if (!isQueueingOrEngagementUseCase.hasOngoingEngagement) return
if (!isQueueingOrLiveEngagementUseCase.hasOngoingLiveEngagement) return
d(TAG, "newOperatorMediaState: $operatorMediaState, timer task running: ${callTimer.isRunning}")
if (operatorMediaState.video != null) {
onOperatorMediaStateVideo(operatorMediaState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.glia.widgets.callvisualizer.VisitorCodeContract
import com.glia.widgets.core.callvisualizer.domain.VisitorCodeRepository
import com.glia.widgets.engagement.State
import com.glia.widgets.engagement.domain.EngagementStateUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrEngagementUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrLiveEngagementUseCase
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.schedulers.Schedulers
Expand All @@ -14,7 +14,7 @@ internal class VisitorCodeController(
private val callVisualizerController: CallVisualizerContract.Controller,
private val visitorCodeRepository: VisitorCodeRepository,
private val engagementStateUseCase: EngagementStateUseCase,
private val isQueueingOrEngagementUseCase: IsQueueingOrEngagementUseCase
private val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase
) : VisitorCodeContract.Controller {

private var disposable: Disposable? = null
Expand Down Expand Up @@ -63,7 +63,7 @@ internal class VisitorCodeController(
}

private fun autoCloseOnEngagement() {
if (isQueueingOrEngagementUseCase.hasOngoingEngagement) {
if (isQueueingOrLiveEngagementUseCase.hasOngoingLiveEngagement) {
// Normally, there is no need for visitor code if there is already ongoing engagement.
// But it also doesn't seem right to just close it if right away when it was open
return
Expand Down
6 changes: 3 additions & 3 deletions widgetssdk/src/main/java/com/glia/widgets/chat/ChatManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import com.glia.widgets.chat.model.VisitorChatItem
import com.glia.widgets.core.engagement.domain.model.ChatHistoryResponse
import com.glia.widgets.core.engagement.domain.model.ChatMessageInternal
import com.glia.widgets.core.secureconversations.domain.MarkMessagesReadWithDelayUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrEngagementUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrLiveEngagementUseCase
import com.glia.widgets.helper.Logger
import com.glia.widgets.helper.TAG
import com.glia.widgets.helper.isValid
Expand All @@ -53,7 +53,7 @@ internal class ChatManager(
private val sendUnsentMessagesUseCase: SendUnsentMessagesUseCase,
private val handleCustomCardClickUseCase: HandleCustomCardClickUseCase,
private val isAuthenticatedUseCase: IsAuthenticatedUseCase,
private val isQueueingOrEngagementUseCase: IsQueueingOrEngagementUseCase,
private val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase,
private val compositeDisposable: CompositeDisposable = CompositeDisposable(),
private val state: BehaviorProcessor<State> = BehaviorProcessor.createDefault(State()),
private val quickReplies: BehaviorProcessor<List<GvaButton>> = BehaviorProcessor.create(),
Expand Down Expand Up @@ -108,7 +108,7 @@ internal class ChatManager(

@VisibleForTesting
fun loadHistory(onHistoryLoaded: (hasHistory: Boolean) -> Unit): Flowable<State> {
val historyEvent = if (isAuthenticatedUseCase() || isQueueingOrEngagementUseCase.hasOngoingEngagement) {
val historyEvent = if (isAuthenticatedUseCase() || isQueueingOrLiveEngagementUseCase.hasOngoingLiveEngagement) {
loadHistoryUseCase()
.doOnSuccess { historyLoaded.onNext(true) }
.zipWith(state.firstOrError(), ::mapChatHistory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import com.glia.widgets.engagement.domain.EndEngagementUseCase
import com.glia.widgets.engagement.domain.EngagementStateUseCase
import com.glia.widgets.engagement.domain.EnqueueForEngagementUseCase
import com.glia.widgets.engagement.domain.IsCurrentEngagementCallVisualizerUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrEngagementUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrLiveEngagementUseCase
import com.glia.widgets.engagement.domain.OperatorMediaUseCase
import com.glia.widgets.engagement.domain.OperatorTypingUseCase
import com.glia.widgets.engagement.domain.ReleaseResourcesUseCase
Expand Down Expand Up @@ -125,7 +125,7 @@ internal class ChatController(
private val engagementStateUseCase: EngagementStateUseCase,
private val operatorMediaUseCase: OperatorMediaUseCase,
private val acceptMediaUpgradeOfferUseCase: AcceptMediaUpgradeOfferUseCase,
private val isQueueingOrEngagementUseCase: IsQueueingOrEngagementUseCase,
private val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase,
private val enqueueForEngagementUseCase: EnqueueForEngagementUseCase,
private val decideOnQueueingUseCase: DecideOnQueueingUseCase,
private val screenSharingUseCase: ScreenSharingUseCase,
Expand Down Expand Up @@ -195,7 +195,7 @@ internal class ChatController(
@Volatile
private var chatState: ChatState

private val isQueueingOrOngoingEngagement get() = isQueueingOrEngagementUseCase()
private val isQueueingOrOngoingEngagement get() = isQueueingOrLiveEngagementUseCase()

override val isChatVisible: Boolean
get() = chatState.isVisible
Expand Down Expand Up @@ -322,7 +322,7 @@ internal class ChatController(
}

override fun onEngagementConfirmationDialogRequested() {
if (isQueueingOrEngagementUseCase()) return
if (isQueueingOrLiveEngagementUseCase()) return
view?.showEngagementConfirmationDialog()
}

Expand Down Expand Up @@ -584,13 +584,18 @@ internal class ChatController(
is State.Update -> handleEngagementStateUpdate(state.updateState)
is State.PreQueuing, is State.Queuing -> queueForEngagementStarted()
is State.QueueUnstaffed, is State.UnexpectedErrorHappened, is State.QueueingCanceled -> emitViewState { chatState.chatUnavailableState() }
State.TransferredToSecureConversation -> onTransferredToSecureConversation()

else -> {
// no op
}
}
}

private fun onTransferredToSecureConversation() {
emitViewState { chatState.setSecureMessagingState().setSecureMessagingAvailable() }
}

private fun handleEngagementStateUpdate(state: EngagementUpdateState) {
when (state) {
is EngagementUpdateState.Ongoing -> onEngagementOngoing(state.operator)
Expand Down Expand Up @@ -681,7 +686,7 @@ internal class ChatController(
chatManager.onChatAction(
ChatManager.Action.OperatorJoined(formattedOperatorName, profileImgUrl)
)
emitViewState { chatState.operatorConnected(formattedOperatorName, profileImgUrl) }
emitViewState { chatState.operatorConnected(formattedOperatorName, profileImgUrl).setLiveChatState() }
}

private fun endChat() {
Expand Down Expand Up @@ -784,7 +789,7 @@ internal class ChatController(
private fun onHistoryLoaded(hasHistory: Boolean) {
Logger.d(TAG, "historyLoaded")

val isSecureEngagement = manageSecureMessagingStatusUseCase.shouldBehaveAsSecureMessaging()
val isSecureEngagement = manageSecureMessagingStatusUseCase.shouldBehaveAsSecureMessaging

if (!hasHistory) {
if (!isSecureEngagement && !isQueueingOrOngoingEngagement) {
Expand All @@ -796,7 +801,7 @@ internal class ChatController(

when {
isSecureEngagement -> { /* to prevent calling chatState.liveChatHistoryLoaded() */ }
isQueueingOrEngagementUseCase.hasOngoingEngagement -> emitViewState { chatState.engagementStarted() }
isQueueingOrLiveEngagementUseCase.hasOngoingLiveEngagement -> emitViewState { chatState.engagementStarted() }
else -> emitViewState { chatState.liveChatHistoryLoaded() }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class GliaLoadHistoryUseCase(
private val getUnreadMessagesCountUseCase: GetUnreadMessagesCountWithTimeoutUseCase
) {

private val isSecureEngagement get() = shouldUseSecureMessagingApis.shouldUseSecureMessagingEndpoints()
private val isSecureEngagement get() = shouldUseSecureMessagingApis.shouldUseSecureMessagingEndpoints

operator fun invoke(): Single<ChatHistoryResponse> = if (isSecureEngagement) {
loadHistoryWithNewMessagesCount()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal class GliaSendMessageUseCase(
}

private val isSecureEngagement: Boolean
get() = shouldUseSecureMessagingApis.shouldUseSecureMessagingEndpoints()
get() = shouldUseSecureMessagingApis.shouldUseSecureMessagingEndpoints

private fun sendMessage(payload: SendMessagePayload, listener: Listener) {
if (isSecureEngagement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package com.glia.widgets.chat.domain

import com.glia.widgets.core.fileupload.FileAttachmentRepository
import com.glia.widgets.core.secureconversations.domain.ManageSecureMessagingStatusUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrEngagementUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrLiveEngagementUseCase

internal class IsShowSendButtonUseCase(
private val isQueueingOrEngagementUseCase: IsQueueingOrEngagementUseCase,
private val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase,
private val fileAttachmentRepository: FileAttachmentRepository,
private val manageSecureMessagingStatusUseCase: ManageSecureMessagingStatusUseCase
) {
operator fun invoke(message: String?): Boolean {
return when {
manageSecureMessagingStatusUseCase.shouldBehaveAsSecureMessaging() -> hasText(message) || hadReadyToSendUnsentAttachments()
manageSecureMessagingStatusUseCase.shouldBehaveAsSecureMessaging -> hasText(message) || hadReadyToSendUnsentAttachments()
else -> hasText(message) || hasEngagementOngoingAndReadyToSendUnsentAttachments()
}
}
Expand All @@ -25,6 +25,6 @@ internal class IsShowSendButtonUseCase(
}

private fun hasEngagementOngoingAndReadyToSendUnsentAttachments(): Boolean {
return isQueueingOrEngagementUseCase.hasOngoingEngagement && hadReadyToSendUnsentAttachments()
return isQueueingOrLiveEngagementUseCase.hasOngoingLiveEngagement && hadReadyToSendUnsentAttachments()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal class SendUnsentMessagesUseCase(
}

private fun sendMessage(payload: SendMessagePayload, callback: RequestCallback<VisitorMessage?>) {
if (shouldUseSecureMessagingApis.shouldUseSecureMessagingEndpoints()) {
if (shouldUseSecureMessagingApis.shouldUseSecureMessagingEndpoints) {
secureConversationsRepository.send(payload, callback)
} else {
chatRepository.sendMessage(payload, callback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package com.glia.widgets.core.chathead.domain
import com.glia.widgets.core.permissions.PermissionManager
import com.glia.widgets.engagement.domain.EngagementTypeUseCase
import com.glia.widgets.engagement.domain.IsCurrentEngagementCallVisualizerUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrEngagementUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrLiveEngagementUseCase
import com.glia.widgets.engagement.domain.ScreenSharingUseCase
import com.glia.widgets.launcher.ConfigurationManager

internal class IsDisplayBubbleInsideAppUseCase(
isQueueingOrEngagementUseCase: IsQueueingOrEngagementUseCase,
isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase,
isCurrentEngagementCallVisualizerUseCase: IsCurrentEngagementCallVisualizerUseCase,
screenSharingUseCase: ScreenSharingUseCase,
permissionManager: PermissionManager,
configurationManager: ConfigurationManager,
engagementTypeUseCase: EngagementTypeUseCase
) : IsDisplayBubbleUseCase(
isQueueingOrEngagementUseCase,
isQueueingOrLiveEngagementUseCase,
isCurrentEngagementCallVisualizerUseCase,
screenSharingUseCase,
permissionManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.glia.widgets.core.chathead.ChatHeadManager
import com.glia.widgets.core.permissions.PermissionManager
import com.glia.widgets.engagement.domain.EngagementTypeUseCase
import com.glia.widgets.engagement.domain.IsCurrentEngagementCallVisualizerUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrEngagementUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrLiveEngagementUseCase
import com.glia.widgets.engagement.domain.ScreenSharingUseCase
import com.glia.widgets.helper.Logger
import com.glia.widgets.helper.TAG
Expand All @@ -16,15 +16,15 @@ import com.glia.widgets.launcher.ConfigurationManager
* 2) starts or stops the chat head service (bubble outside the app)
*/
internal class IsDisplayBubbleOutsideAppUseCase(
isQueueingOrEngagementUseCase: IsQueueingOrEngagementUseCase,
isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase,
isCurrentEngagementCallVisualizerUseCase: IsCurrentEngagementCallVisualizerUseCase,
screenSharingUseCase: ScreenSharingUseCase,
private val chatHeadManager: ChatHeadManager,
permissionManager: PermissionManager,
configurationManager: ConfigurationManager,
engagementTypeUseCase: EngagementTypeUseCase
) : IsDisplayBubbleUseCase(
isQueueingOrEngagementUseCase,
isQueueingOrLiveEngagementUseCase,
isCurrentEngagementCallVisualizerUseCase,
screenSharingUseCase,
permissionManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import com.glia.widgets.chat.ChatView
import com.glia.widgets.core.permissions.PermissionManager
import com.glia.widgets.engagement.domain.EngagementTypeUseCase
import com.glia.widgets.engagement.domain.IsCurrentEngagementCallVisualizerUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrEngagementUseCase
import com.glia.widgets.engagement.domain.IsQueueingOrLiveEngagementUseCase
import com.glia.widgets.engagement.domain.ScreenSharingUseCase
import com.glia.widgets.filepreview.ui.ImagePreviewView
import com.glia.widgets.helper.DialogHolderView
import com.glia.widgets.launcher.ConfigurationManager
import com.glia.widgets.messagecenter.MessageCenterView

internal abstract class IsDisplayBubbleUseCase(
private val isQueueingOrEngagementUseCase: IsQueueingOrEngagementUseCase,
private val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase,
private val isCurrentEngagementCallVisualizerUseCase: IsCurrentEngagementCallVisualizerUseCase,
private val screenSharingUseCase: ScreenSharingUseCase,
val permissionManager: PermissionManager,
Expand Down Expand Up @@ -60,8 +60,8 @@ internal abstract class IsDisplayBubbleUseCase(

private val isChatEngagementOrQueueingOngoing: Boolean get() = isChatEngagementOngoing || isChatQueueingOngoing
private val isMediaEngagementOrQueueingOngoing: Boolean get() = isMediaEngagementOngoing || isMediaQueueingOngoing
private val isMediaQueueingOngoing: Boolean get() = isQueueingOrEngagementUseCase.isQueueingForMedia
private val isMediaQueueingOngoing: Boolean get() = isQueueingOrLiveEngagementUseCase.isQueueingForMedia
private val isMediaEngagementOngoing: Boolean get() = engagementTypeUseCase.isMediaEngagement
private val isChatQueueingOngoing: Boolean get() = isQueueingOrEngagementUseCase.isQueueingForChat
private val isChatQueueingOngoing: Boolean get() = isQueueingOrLiveEngagementUseCase.isQueueingForLiveChat
private val isChatEngagementOngoing: Boolean get() = engagementTypeUseCase.isChatEngagement
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

import com.glia.widgets.core.callvisualizer.domain.IsCallVisualizerScreenSharingUseCase;
import com.glia.widgets.engagement.domain.EngagementTypeUseCase;
import com.glia.widgets.engagement.domain.IsQueueingOrEngagementUseCase;
import com.glia.widgets.engagement.domain.IsQueueingOrLiveEngagementUseCase;

/**
* @hide
*/
public class ResolveChatHeadNavigationUseCase {
private final IsQueueingOrEngagementUseCase isQueueingOrEngagementUseCase;
private final IsQueueingOrLiveEngagementUseCase isQueueingOrLiveEngagementUseCase;
private final EngagementTypeUseCase engagementTypeUseCase;
private final IsCallVisualizerScreenSharingUseCase isCallVisualizerScreenSharingUseCase;

public ResolveChatHeadNavigationUseCase(
IsQueueingOrEngagementUseCase isQueueingOrEngagementUseCase,
IsQueueingOrLiveEngagementUseCase isQueueingOrLiveEngagementUseCase,
EngagementTypeUseCase engagementTypeUseCase,
IsCallVisualizerScreenSharingUseCase isCallVisualizerScreenSharingUseCase
) {
this.isQueueingOrEngagementUseCase = isQueueingOrEngagementUseCase;
this.isQueueingOrLiveEngagementUseCase = isQueueingOrLiveEngagementUseCase;
this.engagementTypeUseCase = engagementTypeUseCase;
this.isCallVisualizerScreenSharingUseCase = isCallVisualizerScreenSharingUseCase;
}
Expand All @@ -42,11 +42,11 @@ public enum Destinations {
}

private boolean isMediaQueueingOngoing() {
return isQueueingOrEngagementUseCase.isQueueingForMedia();
return isQueueingOrLiveEngagementUseCase.isQueueingForMedia();
}

private boolean isMediaEngagementOngoing() {
return isQueueingOrEngagementUseCase.getHasOngoingEngagement() && engagementTypeUseCase.isMediaEngagement();
return isQueueingOrLiveEngagementUseCase.getHasOngoingLiveEngagement() && engagementTypeUseCase.isMediaEngagement();
}

private boolean isSharingScreen() {
Expand Down
Loading

0 comments on commit 420a67a

Please sign in to comment.