?) {
- engagementConfigUseCase(ChatType.SECURE_MESSAGING, queueIds ?: emptyList())
+ init {
+ engagementConfigUseCase(ChatType.SECURE_MESSAGING)
}
override fun setView(view: MessageCenterContract.View) {
@@ -203,7 +192,6 @@ internal class MessageCenterController(
override fun ensureMessageCenterAvailability() {
getAvailableQueueIdsForSecureMessagingUseCase(
RequestCallback { queueIds, exception ->
- setQueueIds(queueIds)
val showSendMessageGroup = when {
exception != null -> {
diff --git a/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageCenterView.kt b/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageCenterView.kt
index 4799c242f..356c4ae98 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageCenterView.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageCenterView.kt
@@ -17,7 +17,6 @@ import androidx.core.view.isVisible
import com.glia.widgets.Constants
import com.glia.widgets.R
import com.glia.widgets.UiTheme
-import com.glia.widgets.core.configuration.EngagementConfiguration
import com.glia.widgets.core.dialog.DialogContract
import com.glia.widgets.core.dialog.model.DialogState
import com.glia.widgets.core.fileupload.model.FileAttachment
@@ -125,7 +124,7 @@ internal class MessageCenterView(
}
private fun setDefaultTheme(typedArray: TypedArray) {
- theme = Utils.getThemeFromTypedArray(typedArray, this.context)
+ theme = Utils.getFullHybridTheme(typedArray, this.context)
}
private fun initCallbacks() {
@@ -157,10 +156,6 @@ internal class MessageCenterView(
}
}
- fun setConfiguration(configuration: EngagementConfiguration?) {
- controller?.setConfiguration(theme, configuration)
- }
-
private fun showUnAuthenticatedDialog() {
showDialog {
Dialogs.showUnAuthenticatedDialog(context, theme) {
diff --git a/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageView.kt b/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageView.kt
index 96eefe063..3cf765c53 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageView.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageView.kt
@@ -74,8 +74,6 @@ internal class MessageView(
Dependencies.gliaThemeManager.theme?.secureMessagingWelcomeScreenTheme
}
- private var theme: UiTheme by Delegates.notNull()
-
private val attachmentPopup by lazy {
AttachmentPopup(addAttachmentButton, unifiedTheme?.pickMediaTheme)
}
@@ -116,12 +114,12 @@ internal class MessageView(
}
private fun setDefaultTheme(typedArray: TypedArray) {
- theme = Utils.getThemeFromTypedArray(typedArray, this.context)
- setupAttachmentIconTheme()
- setupMessageErrorTextTheme()
+ val theme = Utils.getFullHybridTheme(typedArray, this.context)
+ setupAttachmentIconTheme(theme)
+ setupMessageErrorTextTheme(theme)
}
- private fun setupMessageErrorTextTheme() {
+ private fun setupMessageErrorTextTheme(theme: UiTheme) {
val systemNegativeColorId = theme.systemNegativeColor ?: return
TextViewCompat.setCompoundDrawableTintList(
@@ -185,7 +183,7 @@ internal class MessageView(
attachmentRecyclerView.adapter = uploadAttachmentAdapter
}
- private fun setupAttachmentIconTheme() {
+ private fun setupAttachmentIconTheme(theme: UiTheme) {
val normalColor = unifiedTheme?.filePickerButtonTheme?.primaryColor
?: theme.baseNormalColor?.let { getColorCompat(it) }
val disabledColor = unifiedTheme?.filePickerButtonDisabledTheme?.primaryColor
diff --git a/widgetssdk/src/main/java/com/glia/widgets/operator/OperatorRequestActivityWatcher.kt b/widgetssdk/src/main/java/com/glia/widgets/operator/OperatorRequestActivityWatcher.kt
index 0c5f53eaa..767b779b7 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/operator/OperatorRequestActivityWatcher.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/operator/OperatorRequestActivityWatcher.kt
@@ -136,7 +136,7 @@ internal class OperatorRequestActivityWatcher(
activity.isGlia -> finishActivities()
}
- activityLauncher.launchCall(activity, mediaType)
+ activityLauncher.launchCall(activity, mediaType, true)
}
private fun showUpgradeDialog(state: ControllerState.RequestMediaUpgrade, activity: Activity, consumeCallback: () -> Unit) {
diff --git a/widgetssdk/src/main/java/com/glia/widgets/operator/OperatorRequestController.kt b/widgetssdk/src/main/java/com/glia/widgets/operator/OperatorRequestController.kt
index 801736a20..ca224b3eb 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/operator/OperatorRequestController.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/operator/OperatorRequestController.kt
@@ -7,7 +7,6 @@ import androidx.activity.ComponentActivity
import androidx.activity.result.ActivityResult
import com.glia.androidsdk.Engagement
import com.glia.androidsdk.comms.MediaUpgradeOffer
-import com.glia.widgets.core.configuration.GliaSdkConfigurationManager
import com.glia.widgets.core.dialog.DialogContract
import com.glia.widgets.core.dialog.domain.IsShowOverlayPermissionRequestDialogUseCase
import com.glia.widgets.core.dialog.domain.SetOverlayPermissionRequestDialogShownUseCase
@@ -48,7 +47,6 @@ internal class OperatorRequestController(
private val isCurrentEngagementCallVisualizerUseCase: IsCurrentEngagementCallVisualizerUseCase,
private val setOverlayPermissionRequestDialogShownUseCase: SetOverlayPermissionRequestDialogShownUseCase,
private val dialogController: DialogContract.Controller,
- private val gliaSdkConfigurationManager: GliaSdkConfigurationManager,
private val withNotificationPermissionUseCase: WithNotificationPermissionUseCase,
private val prepareToScreenSharingUseCase: PrepareToScreenSharingUseCase,
private val releaseScreenSharingResourcesUseCase: ReleaseScreenSharingResourcesUseCase
@@ -160,7 +158,7 @@ internal class OperatorRequestController(
withNotificationPermissionUseCase {
_state.onNext(State.AcquireMediaProjectionToken)
- screenSharingUseCase.acceptRequestWithAskedPermission(activity, gliaSdkConfigurationManager.screenSharingMode)
+ screenSharingUseCase.acceptRequestWithAskedPermission(activity)
}
}
diff --git a/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyActivity.java b/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyActivity.java
deleted file mode 100644
index 174220e78..000000000
--- a/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyActivity.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package com.glia.widgets.survey;
-
-import android.os.Bundle;
-
-import androidx.activity.EdgeToEdge;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.view.WindowCompat;
-import androidx.core.view.WindowInsetsControllerCompat;
-
-import com.glia.androidsdk.engagement.Survey;
-import com.glia.widgets.GliaWidgets;
-import com.glia.widgets.R;
-import com.glia.widgets.UiTheme;
-import com.glia.widgets.di.Dependencies;
-import com.glia.widgets.helper.Insets;
-import com.glia.widgets.helper.Logger;
-
-/**
- * Glia internal class.
- *
- * It will be automatically added to the integrator's manifest file by the manifest merger during compilation.
- *
- * This activity is used to display post-engagement surveys.
- */
-public class SurveyActivity extends AppCompatActivity implements SurveyView.OnFinishListener {
- private static final String TAG = SurveyActivity.class.getSimpleName();
-
- private SurveyView surveyView;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- EdgeToEdge.enable(this);
- Insets.insetsControllerCompat(getWindow()).setAppearanceLightStatusBars(false);
- super.onCreate(savedInstanceState);
- Logger.i(TAG, "Create Survey screen");
- setContentView(R.layout.survey_activity);
- prepareSurveyView();
- }
-
- @Override
- protected void onDestroy() {
- Logger.i(TAG, "Destroy Survey screen");
- hideSoftKeyboard();
- if (surveyView != null) {
- surveyView.onDestroyView();
- }
- super.onDestroy();
- }
-
- @Override
- public void onBackPressed() {
- super.onBackPressed();
-
- // Back press behaves the same way as Callback.onFinish(). See the comment below.
- finishAndRemoveTask();
- }
-
- @Override
- public void onFinish() {
-
- // In case the engagement ends, Activity is removed from the device's Recents menu
- // to avoid app users to accidentally start queueing for another call when they resume
- // the app from the Recents menu and the app's backstack was empty.
- finishAndRemoveTask();
- }
-
- @Override
- public void finishAndRemoveTask() {
- overridePendingTransition(0, R.anim.slide_down);
- super.finishAndRemoveTask();
- }
-
- private void hideSoftKeyboard() {
- WindowInsetsControllerCompat insetsController = WindowCompat.getInsetsController(getWindow(), findViewById(R.id.survey_view));
- Insets.hideKeyboard(insetsController);
- }
-
- private void prepareSurveyView() {
- surveyView = findViewById(R.id.survey_view);
- surveyView.setOnTitleUpdatedListener(this::setTitle);
- surveyView.setOnFinishListener(this);
- SurveyContract.Controller surveyController = Dependencies.getControllerFactory().getSurveyController();
- surveyView.setController(surveyController);
- Bundle extras = getIntent().getExtras();
- if (extras != null) {
- UiTheme uiTheme = extras.getParcelable(GliaWidgets.UI_THEME);
- surveyView.setTheme(uiTheme);
- Survey survey = extras.getParcelable(GliaWidgets.SURVEY);
- surveyController.init(survey);
- }
- }
-}
diff --git a/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyActivity.kt b/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyActivity.kt
new file mode 100644
index 000000000..79073062b
--- /dev/null
+++ b/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyActivity.kt
@@ -0,0 +1,116 @@
+package com.glia.widgets.survey
+
+import android.os.Build
+import android.os.Bundle
+import androidx.activity.OnBackPressedCallback
+import androidx.activity.enableEdgeToEdge
+import androidx.annotation.RequiresApi
+import androidx.appcompat.app.AppCompatActivity
+import com.glia.androidsdk.engagement.Survey
+import com.glia.widgets.R
+import com.glia.widgets.di.Dependencies.controllerFactory
+import com.glia.widgets.helper.ExtraKeys
+import com.glia.widgets.helper.Logger.i
+import com.glia.widgets.helper.TAG
+import com.glia.widgets.helper.getParcelableExtraCompat
+import com.glia.widgets.helper.hideKeyboard
+import com.glia.widgets.helper.insetsController
+import com.glia.widgets.helper.insetsControllerCompat
+
+/**
+ * Glia internal class.
+ *
+ *
+ * It will be automatically added to the integrator's manifest file by the manifest merger during compilation.
+ *
+ *
+ * This activity is used to display post-engagement surveys.
+ */
+internal class SurveyActivity : AppCompatActivity(), SurveyView.OnFinishListener {
+ private val surveyView: SurveyView by lazy { findViewById(R.id.survey_view) }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ this.enableEdgeToEdge()
+ window.insetsControllerCompat.isAppearanceLightStatusBars = false
+
+ overrideEnterAnimation()
+ super.onCreate(savedInstanceState)
+
+ i(TAG, "Create Survey screen")
+ setContentView(R.layout.survey_activity)
+
+ onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
+ override fun handleOnBackPressed() {
+ finishAndRemoveTask()
+ }
+ })
+
+ prepareSurveyView()
+ }
+
+ override fun onDestroy() {
+ i(TAG, "Destroy Survey screen")
+ hideSoftKeyboard()
+ surveyView.onDestroyView()
+ super.onDestroy()
+ }
+
+ override fun onFinish() {
+ // In case the engagement ends, Activity is removed from the device's Recents menu
+ // to avoid app users to accidentally start queueing for another call when they resume
+ // the app from the Recents menu and the app's backstack was empty.
+
+ finishAndRemoveTask()
+ }
+
+ override fun finishAndRemoveTask() {
+ overrideExitAnimation()
+ super.finishAndRemoveTask()
+ }
+
+ private fun hideSoftKeyboard() {
+ surveyView.insetsController?.hideKeyboard()
+ }
+
+ private fun prepareSurveyView() {
+ surveyView.setOnTitleUpdatedListener(object : SurveyView.OnTitleUpdatedListener {
+ override fun onTitleUpdated(title: String?) {
+ updateTitle(title)
+ }
+ })
+
+ surveyView.setOnFinishListener(this)
+ val surveyController = controllerFactory.surveyController
+ surveyView.setController(surveyController)
+
+ intent.getParcelableExtraCompat(ExtraKeys.SURVEY)?.let {
+ surveyController.init(it)
+ }
+ }
+
+ private fun updateTitle(title: String?) {
+ this.title = title
+ }
+
+ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
+ private fun overrideAnimations() {
+ overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, R.anim.slide_up, 0)
+ overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, 0, R.anim.slide_down)
+ }
+
+ private fun overrideEnterAnimation() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ overrideAnimations()
+ return
+ }
+
+ overridePendingTransition(R.anim.slide_up, 0)
+ }
+
+ @Suppress("DEPRECATION")
+ private fun overrideExitAnimation() {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ overridePendingTransition(0, R.anim.slide_down)
+ }
+ }
+}
diff --git a/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyAdapter.kt b/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyAdapter.kt
index 585d2db15..4f2004836 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyAdapter.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyAdapter.kt
@@ -16,20 +16,16 @@ import com.glia.widgets.survey.viewholder.SingleQuestionViewHolder
import com.glia.widgets.survey.viewholder.SurveyViewHolder
import com.glia.widgets.view.configuration.survey.SurveyStyle
-internal class SurveyAdapter(private val listener: SurveyAdapterListener) :
- RecyclerView.Adapter() {
+internal class SurveyAdapter(
+ private val listener: SurveyAdapterListener,
+ private val style: SurveyStyle
+) : RecyclerView.Adapter() {
interface SurveyAdapterListener {
fun onAnswer(answer: Survey.Answer)
}
- private var style: SurveyStyle
private val questionItems: MutableList = ArrayList()
- init {
- // initialize style with default empty SurveyStyle, to make sure that style usage is safe even if new style is not set.
- style = SurveyStyle.Builder().build()
- }
-
fun submitList(items: List?) {
questionItems.clear()
if (items == null) {
@@ -40,10 +36,6 @@ internal class SurveyAdapter(private val listener: SurveyAdapterListener) :
private fun getItem(position: Int): QuestionItem = questionItems[position]
- fun setStyle(style: SurveyStyle) {
- this.style = style
- }
-
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SurveyViewHolder {
val inflater = LayoutInflater.from(parent.context)
return when (viewType) {
diff --git a/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyView.kt b/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyView.kt
index f7b4bb03e..8712455c8 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyView.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyView.kt
@@ -14,12 +14,10 @@ import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView
import com.glia.androidsdk.engagement.Survey
import com.glia.widgets.R
-import com.glia.widgets.UiTheme
import com.glia.widgets.databinding.SurveyViewBinding
import com.glia.widgets.di.Dependencies
import com.glia.widgets.helper.SimpleWindowInsetsAndAnimationHandler
import com.glia.widgets.helper.Utils
-import com.glia.widgets.helper.getFullHybridTheme
import com.glia.widgets.helper.hideKeyboard
import com.glia.widgets.helper.insetsController
import com.glia.widgets.helper.layoutInflater
@@ -37,7 +35,6 @@ import com.google.android.material.button.MaterialButton
import com.google.android.material.shape.CornerFamily
import com.google.android.material.shape.MaterialShapeDrawable
import com.google.android.material.shape.ShapeAppearanceModel
-import kotlin.properties.Delegates
internal class SurveyView(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) :
FrameLayout(
@@ -52,8 +49,6 @@ internal class SurveyView(context: Context, attrs: AttributeSet?, defStyleAttr:
private var onFinishListener: OnFinishListener? = null
private var controller: SurveyContract.Controller? = null
- private var uiTheme: UiTheme by Delegates.notNull()
-
private val surveyTheme: SurveyTheme? by lazy {
Dependencies.gliaThemeManager.theme?.surveyTheme
}
@@ -80,16 +75,10 @@ internal class SurveyView(context: Context, attrs: AttributeSet?, defStyleAttr:
) : this(context, attrs, defStyleAttr, R.style.Application_Glia_Chat)
init {
+ SimpleWindowInsetsAndAnimationHandler(this)
readTypedArray(attrs, defStyleAttr, defStyleRes)
setupViewAppearance()
initCallbacks()
- initAdapter()
- SimpleWindowInsetsAndAnimationHandler(this)
- }
-
- override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
- super.onLayout(changed, left, top, right, bottom)
- applyStyle(uiTheme.surveyStyle)
}
private fun setupViewAppearance() {
@@ -206,24 +195,15 @@ internal class SurveyView(context: Context, attrs: AttributeSet?, defStyleAttr:
private fun setDefaultTheme(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) {
@SuppressLint("CustomViewStyleable")
- val typedArray = this.context.obtainStyledAttributes(
- attrs,
- R.styleable.GliaView,
- defStyleAttr,
- defStyleRes
- )
- uiTheme = Utils.getThemeFromTypedArray(typedArray, this.context)
+ val typedArray = context.obtainStyledAttributes(attrs, R.styleable.GliaView, defStyleAttr, defStyleRes)
+ val surveyStyle = Utils.getFullHybridTheme(typedArray, this.context).surveyStyle
+ initAdapter(surveyStyle)
+ applyStyle(surveyStyle)
typedArray.recycle()
}
- fun setTheme(uiTheme: UiTheme?) {
- if (uiTheme == null) return
- this.uiTheme = this.uiTheme.getFullHybridTheme(uiTheme)
- this.uiTheme.surveyStyle?.also { surveyAdapter?.setStyle(it) }
- }
-
- private fun initAdapter() {
- surveyAdapter = SurveyAdapter(this)
+ private fun initAdapter(surveyStyle: SurveyStyle?) {
+ surveyAdapter = SurveyAdapter(this, surveyStyle ?: SurveyStyle.Builder().build())
recyclerView.adapter = surveyAdapter
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/VisitorCodeView.kt b/widgetssdk/src/main/java/com/glia/widgets/view/VisitorCodeView.kt
index 9c7d2c68e..f7587efef 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/view/VisitorCodeView.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/view/VisitorCodeView.kt
@@ -28,7 +28,6 @@ import com.glia.widgets.helper.applyTextTheme
import com.glia.widgets.helper.combineStringWith
import com.glia.widgets.helper.getColorCompat
import com.glia.widgets.helper.getFontCompat
-import com.glia.widgets.helper.getFullHybridTheme
import com.glia.widgets.helper.layoutInflater
import com.glia.widgets.helper.separateStringWithSymbol
import com.glia.widgets.helper.setLocaleContentDescription
@@ -56,7 +55,6 @@ internal class VisitorCodeView internal constructor(
private val uiThreadExecutor: Executor? = null
) : FrameLayout(context.wrapWithMaterialThemeOverlay(), null, 0), VisitorCodeContract.View {
private lateinit var controller: VisitorCodeContract.Controller
- private var theme: UiTheme? = null
private var timer: CountDownTimer? = null
@@ -139,10 +137,7 @@ internal class VisitorCodeView internal constructor(
}
private fun setDefaultTheme(typedArray: TypedArray) {
- val typedArrayTheme = Utils.getThemeFromTypedArray(typedArray, this.context)
- val runtimeGlobalTheme = Dependencies.sdkConfigurationManager.uiTheme
- theme = typedArrayTheme.getFullHybridTheme(runtimeGlobalTheme)
- applyRuntimeThemeConfig(theme)
+ applyRuntimeThemeConfig(Utils.getFullHybridTheme(typedArray, this.context))
}
override fun startLoading() {
diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/head/ActivityWatcherForChatHead.kt b/widgetssdk/src/main/java/com/glia/widgets/view/head/ActivityWatcherForChatHead.kt
index cdead95b0..457a28d8c 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/view/head/ActivityWatcherForChatHead.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/view/head/ActivityWatcherForChatHead.kt
@@ -10,10 +10,8 @@ import androidx.core.util.Pair
import androidx.core.view.contains
import com.glia.widgets.R
import com.glia.widgets.base.BaseActivityStackWatcher
-import com.glia.widgets.call.CallConfiguration
import com.glia.widgets.callvisualizer.EndScreenSharingView
import com.glia.widgets.chat.ChatView
-import com.glia.widgets.di.Dependencies
import com.glia.widgets.filepreview.ui.ImagePreviewView
import com.glia.widgets.helper.DialogHolderView
import com.glia.widgets.helper.Logger
@@ -133,7 +131,7 @@ internal class ActivityWatcherForChatHead(
}
private fun saveBubblePosition() {
- chatHeadLayout?.getPosition()?.let {
+ chatHeadLayout?.position?.let {
if (it.first == null || it.second == null) return
chatHeadViewPosition = Pair(it.first, it.second)
}
@@ -171,10 +169,6 @@ internal class ActivityWatcherForChatHead(
}
}
- private fun getDefaultCallConfiguration(): CallConfiguration = Dependencies.sdkConfigurationManager
- .buildEngagementConfiguration()
- .let(::CallConfiguration)
-
private fun navigateToChat(activity: Activity?) {
activity?.also(activityLauncher::launchChat)
}
@@ -184,6 +178,6 @@ internal class ActivityWatcherForChatHead(
}
private fun navigateToCall(activity: Activity?) {
- activity?.also { activityLauncher.launchCall(it, getDefaultCallConfiguration().copy(isUpgradeToCall = true)) }
+ activity?.also { activityLauncher.launchCall(it, null, false) }
}
}
diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadContract.kt b/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadContract.kt
index de55d3cdb..3c2a0611f 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadContract.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadContract.kt
@@ -1,9 +1,7 @@
package com.glia.widgets.view.head
-import com.glia.widgets.UiTheme
import com.glia.widgets.base.BaseController
import com.glia.widgets.base.BaseView
-import com.glia.widgets.core.configuration.EngagementConfiguration
internal interface ChatHeadContract {
interface Controller : BaseController {
@@ -12,8 +10,6 @@ internal interface ChatHeadContract {
fun onResume(view: android.view.View?)
fun onApplicationStop()
fun onChatHeadPositionChanged(x: Int, y: Int)
- fun setBuildTimeTheme(uiTheme: UiTheme?)
- fun setEngagementConfiguration(configuration: EngagementConfiguration?)
fun onPause(gliaOrRootView: android.view.View?)
fun updateChatHeadView()
fun onSetChatHeadView(view: View)
@@ -30,6 +26,5 @@ internal interface ChatHeadContract {
fun navigateToChat()
fun navigateToCall()
fun navigateToEndScreenSharing()
- fun updateConfiguration(buildTimeTheme: UiTheme, engagementConfiguration: EngagementConfiguration?)
}
}
diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadLayout.kt b/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadLayout.kt
index 963f5e6de..2963997fe 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadLayout.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadLayout.kt
@@ -8,11 +8,8 @@ import androidx.core.util.Pair
import androidx.core.view.ViewCompat
import com.glia.widgets.Constants
import com.glia.widgets.R
-import com.glia.widgets.UiTheme
-import com.glia.widgets.core.configuration.EngagementConfiguration
import com.glia.widgets.databinding.ChatHeadLayoutBinding
import com.glia.widgets.di.Dependencies
-import com.glia.widgets.helper.Utils
import com.glia.widgets.helper.layoutInflater
import com.glia.widgets.helper.wrapWithMaterialThemeOverlay
import com.glia.widgets.view.ViewHelpers
@@ -33,12 +30,12 @@ internal class ChatHeadLayout @JvmOverloads constructor(
private var chatHeadController: ChatHeadLayoutContract.Controller by Delegates.notNull()
private var navigationCallback: NavigationCallback? = null
- private var chatHeadClickedListener: OnChatHeadClickedListener? = null
- private var uiTheme: UiTheme by Delegates.notNull()
- private val chatHeadViewPosition: Pair
+ private val _chatHeadViewPosition: Pair
get() = Pair(chatHeadView.x.roundToInt(), chatHeadView.y.roundToInt())
+ val position: Pair get() = _chatHeadViewPosition
+
private val chatHeadSize: Float by lazy { resources.getDimension(R.dimen.glia_chat_head_size) }
private val chatHeadMargin: Float by lazy { resources.getDimension(R.dimen.glia_chat_head_content_padding) }
@@ -49,7 +46,7 @@ internal class ChatHeadLayout @JvmOverloads constructor(
private val chatHeadView: ChatHeadView by lazy { binding.chatHeadView }
init {
- init(attrs, defStyleAttr, defStyleRes)
+ initialize()
}
override fun showOperatorImage(operatorImgUrl: String) {
@@ -133,16 +130,6 @@ internal class ChatHeadLayout @JvmOverloads constructor(
super.onDetachedFromWindow()
}
- /**
- * Method for the integrator to override if they want to do custom logic when the chat head is
- * clicked.
- *
- * @param listener
- */
- fun setOnChatHeadClickedListener(listener: OnChatHeadClickedListener) {
- chatHeadClickedListener = listener
- }
-
/**
* Method that allows integrator to override navigation on click with using own paths
*
@@ -155,11 +142,10 @@ internal class ChatHeadLayout @JvmOverloads constructor(
navigationCallback = callback
}
- private fun init(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) {
+ private fun initialize() {
visibility = GONE
initConfigurations()
setupViewActions()
- readTypedArray(attrs, defStyleAttr, defStyleRes)
setController(Dependencies.controllerFactory.chatHeadLayoutController)
chatHeadController.setView(this)
}
@@ -174,45 +160,19 @@ internal class ChatHeadLayout @JvmOverloads constructor(
private fun setupViewActions() {
chatHeadView.setOnTouchListener(
ViewHelpers.OnTouchListener(
- { chatHeadViewPosition },
+ { _chatHeadViewPosition },
::onChatHeadDragged
) { onChatHeadClicked() }
)
}
- private fun readTypedArray(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) {
- @SuppressLint("CustomViewStyleable")
- val typedArray =
- context.obtainStyledAttributes(attrs, R.styleable.GliaView, defStyleAttr, defStyleRes)
- setBuildTimeTheme(Utils.getThemeFromTypedArray(typedArray, context))
- typedArray.recycle()
- }
-
- private fun setBuildTimeTheme(theme: UiTheme) {
- uiTheme = theme
- updateChatHeadConfiguration(uiTheme)
- }
-
- private fun updateChatHeadConfiguration(
- buildTimeTheme: UiTheme,
- engagementConfiguration: EngagementConfiguration? = null
- ) {
- chatHeadView.updateConfiguration(buildTimeTheme, engagementConfiguration)
- }
-
private fun onChatHeadDragged(x: Float, y: Float) {
chatHeadView.x = x
chatHeadView.y = y
chatHeadView.invalidate()
}
- private fun onChatHeadClicked() {
- chatHeadClickedListener?.onClicked(null) ?: chatHeadController.onChatHeadClicked()
- }
-
- fun getPosition(): Pair {
- return chatHeadViewPosition
- }
+ private fun onChatHeadClicked() = chatHeadController.onChatHeadClicked()
fun setPosition(x: Float, y: Float) {
chatHeadView.x = x
@@ -220,10 +180,6 @@ internal class ChatHeadLayout @JvmOverloads constructor(
chatHeadView.invalidate()
}
- fun interface OnChatHeadClickedListener {
- fun onClicked(engagementConfiguration: EngagementConfiguration?)
- }
-
interface NavigationCallback {
fun onNavigateToChat()
fun onNavigateToCall()
diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadView.kt b/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadView.kt
index 04f3cc664..868bfb402 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadView.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/view/head/ChatHeadView.kt
@@ -15,9 +15,7 @@ import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import androidx.core.view.isVisible
import com.glia.widgets.R
import com.glia.widgets.UiTheme
-import com.glia.widgets.call.CallConfiguration
import com.glia.widgets.core.callvisualizer.domain.IsCallVisualizerScreenSharingUseCase
-import com.glia.widgets.core.configuration.EngagementConfiguration
import com.glia.widgets.databinding.ChatHeadViewBinding
import com.glia.widgets.di.Dependencies
import com.glia.widgets.engagement.domain.IsCurrentEngagementCallVisualizerUseCase
@@ -51,21 +49,17 @@ internal class ChatHeadView @JvmOverloads constructor(
), ChatHeadContract.View {
private val activityLauncher: ActivityLauncher by lazy { Dependencies.activityLauncher }
private val binding by lazy { ChatHeadViewBinding.inflate(layoutInflater, this) }
- private var engagementConfiguration: EngagementConfiguration? = null
private var configuration: ChatHeadConfiguration by Delegates.notNull()
private val isService by lazy { context is Service }
private val bubbleTheme: BubbleTheme?
- get() = Dependencies.gliaThemeManager.theme?.run {
- if (isService) bubbleTheme else chatTheme?.bubble
- }
+ get() = Dependencies.gliaThemeManager.theme?.run { if (isService) bubbleTheme else chatTheme?.bubble }
@Suppress("JoinDeclarationAndAssignment")
private var serviceChatHeadController: ChatHeadContract.Controller
private var isCallVisualizerScreenSharingUseCase: IsCallVisualizerScreenSharingUseCase
private var isCallVisualizerUseCase: IsCurrentEngagementCallVisualizerUseCase
- private var theme: UiTheme? = null
init {
serviceChatHeadController = Dependencies.controllerFactory.chatHeadController
@@ -76,17 +70,15 @@ internal class ChatHeadView @JvmOverloads constructor(
}
private fun readTypedArray() {
- context.withStyledAttributes(
- set = null,
- attrs = R.styleable.GliaView,
- defStyleAttr = 0
- ) {
+ context.withStyledAttributes(set = null, attrs = R.styleable.GliaView, defStyleAttr = 0) {
setDefaultTheme(this)
}
}
+
private fun setDefaultTheme(typedArray: TypedArray) {
- theme = Utils.getThemeFromTypedArray(typedArray, this.context)
- serviceChatHeadController.setBuildTimeTheme(theme)
+ configuration = createConfiguration(Utils.getFullHybridTheme(typedArray, this.context))
+ post { updateView() }
+ updateView()
}
override fun showUnreadMessageCount(count: Int) {
@@ -159,16 +151,6 @@ internal class ChatHeadView @JvmOverloads constructor(
post { binding.onHoldIcon.visibility = GONE }
}
- override fun updateConfiguration(
- buildTimeTheme: UiTheme,
- engagementConfiguration: EngagementConfiguration?
- ) {
- this.engagementConfiguration = engagementConfiguration
- serviceChatHeadController.setBuildTimeTheme(buildTimeTheme)
- createHybridConfiguration(buildTimeTheme, engagementConfiguration)
- post { updateView() }
- }
-
private fun applyBubbleTheme() {
bubbleTheme?.badge?.also(binding.chatBubbleBadge::applyBadgeTheme)
bubbleTheme?.onHoldOverlay?.also {
@@ -186,54 +168,31 @@ internal class ChatHeadView @JvmOverloads constructor(
}
override fun navigateToChat() {
- engagementConfiguration?.let {
- activityLauncher.launchChat(context, it)
- }
+ activityLauncher.launchChat(context)
}
override fun navigateToCall() {
- activityLauncher.launchCall(context, CallConfiguration(engagementConfiguration))
+ activityLauncher.launchCall(context, null, false)
}
override fun navigateToEndScreenSharing() {
activityLauncher.launchEndScreenSharing(context)
}
- private fun createBuildTimeConfiguration(buildTimeTheme: UiTheme): ChatHeadConfiguration {
- return ChatHeadConfiguration.builder()
- .operatorPlaceholderBackgroundColor(buildTimeTheme.brandPrimaryColor)
- .operatorPlaceholderIcon(buildTimeTheme.iconPlaceholder)
- .operatorPlaceholderIconTintList(buildTimeTheme.baseLightColor)
- .badgeTextColor(buildTimeTheme.baseLightColor)
- .badgeBackgroundTintList(buildTimeTheme.brandPrimaryColor)
- .backgroundColorRes(buildTimeTheme.brandPrimaryColor)
- .iconOnHold(buildTimeTheme.iconOnHold)
- .iconOnHoldTintList(buildTimeTheme.baseLightColor)
- .iconScreenSharingDialog(buildTimeTheme.iconScreenSharingDialog)
- .build()
- }
-
- private fun createHybridConfiguration(
- buildTimeTheme: UiTheme,
- engagementConfiguration: EngagementConfiguration?
- ) {
- configuration = createBuildTimeConfiguration(buildTimeTheme)
- val runTimeTheme = engagementConfiguration?.runTimeTheme ?: return
-
- val builder = ChatHeadConfiguration.builder(configuration)
-
- runTimeTheme.chatHeadConfiguration?.apply {
- operatorPlaceholderBackgroundColor?.also(builder::operatorPlaceholderBackgroundColor)
- operatorPlaceholderIcon?.also(builder::operatorPlaceholderIcon)
- operatorPlaceholderIconTintList?.also(builder::operatorPlaceholderIconTintList)
- badgeBackgroundTintList?.also(builder::badgeBackgroundTintList)
- badgeTextColor?.also(builder::badgeTextColor)
- backgroundColorRes?.also(builder::backgroundColorRes)
- iconOnHold?.also(builder::iconOnHold)
- iconOnHoldTintList?.also(builder::iconOnHoldTintList)
- iconScreenSharingDialog?.also(builder::iconScreenSharingDialog)
+ private fun createConfiguration(buildTimeTheme: UiTheme): ChatHeadConfiguration {
+ return buildTimeTheme.chatHeadConfiguration.let {
+ ChatHeadConfiguration.builder()
+ .operatorPlaceholderBackgroundColor(it?.operatorPlaceholderBackgroundColor ?: buildTimeTheme.brandPrimaryColor)
+ .operatorPlaceholderIcon(it?.operatorPlaceholderIcon ?: buildTimeTheme.iconPlaceholder)
+ .operatorPlaceholderIconTintList(it?.operatorPlaceholderIconTintList ?: buildTimeTheme.baseLightColor)
+ .badgeTextColor(it?.badgeTextColor ?: buildTimeTheme.baseLightColor)
+ .badgeBackgroundTintList(it?.badgeBackgroundTintList ?: buildTimeTheme.brandPrimaryColor)
+ .backgroundColorRes(it?.backgroundColorRes ?: buildTimeTheme.brandPrimaryColor)
+ .iconOnHold(it?.iconOnHold ?: buildTimeTheme.iconOnHold)
+ .iconOnHoldTintList(it?.iconOnHoldTintList ?: buildTimeTheme.baseLightColor)
+ .iconScreenSharingDialog(it?.iconScreenSharingDialog ?: buildTimeTheme.iconScreenSharingDialog)
+ .build()
}
- configuration = builder.build()
}
private fun setAccessibilityLabels() {
@@ -300,6 +259,7 @@ internal class ChatHeadView @JvmOverloads constructor(
updateQueueingAnimationView()
applyBubbleTheme()
+ invalidate()
}
private fun isDisplayUnreadMessageBadge(unreadMessageCount: Int): Boolean =
diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/head/controller/ServiceChatHeadController.kt b/widgetssdk/src/main/java/com/glia/widgets/view/head/controller/ServiceChatHeadController.kt
index 118ec23ae..3c8ffdbcc 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/view/head/controller/ServiceChatHeadController.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/view/head/controller/ServiceChatHeadController.kt
@@ -2,13 +2,10 @@ package com.glia.widgets.view.head.controller
import android.view.View
import com.glia.androidsdk.Operator
-import com.glia.widgets.UiTheme
import com.glia.widgets.core.callvisualizer.domain.IsCallVisualizerScreenSharingUseCase
+import com.glia.widgets.core.chathead.domain.IsDisplayBubbleOutsideAppUseCase
import com.glia.widgets.core.chathead.domain.ResolveChatHeadNavigationUseCase
import com.glia.widgets.core.chathead.domain.ResolveChatHeadNavigationUseCase.Destinations
-import com.glia.widgets.core.chathead.domain.IsDisplayBubbleOutsideAppUseCase
-import com.glia.widgets.core.configuration.EngagementConfiguration
-import com.glia.widgets.di.Dependencies
import com.glia.widgets.engagement.domain.CurrentOperatorUseCase
import com.glia.widgets.engagement.domain.EngagementStateUseCase
import com.glia.widgets.engagement.domain.ScreenSharingUseCase
@@ -38,8 +35,6 @@ internal class ServiceChatHeadController(
private var operatorProfileImgUrl: String? = null
private var unreadMessagesCount = 0
private var isOnHold = false
- private var engagementConfiguration: EngagementConfiguration? = null
- private var buildTimeTheme: UiTheme? = null
/*
* We need to keep track of the currently active (topmost) view. This can be either ChatView
@@ -101,9 +96,6 @@ internal class ServiceChatHeadController(
updateChatHeadView()
}
- override fun setEngagementConfiguration(engagementConfiguration: EngagementConfiguration?) {
- this.engagementConfiguration = engagementConfiguration
- }
private fun handleEngagementState(state: com.glia.widgets.engagement.State) {
when (state) {
@@ -138,18 +130,13 @@ internal class ServiceChatHeadController(
}
override fun updateChatHeadView() {
- if (chatHeadView != null && buildTimeTheme != null) {
+ if (chatHeadView != null) {
updateChatHeadViewState()
updateOnHold()
chatHeadView!!.showUnreadMessageCount(unreadMessagesCount)
- chatHeadView!!.updateConfiguration(buildTimeTheme!!, engagementConfiguration)
}
}
- override fun setBuildTimeTheme(uiTheme: UiTheme?) {
- buildTimeTheme = uiTheme
- }
-
private fun engagementEnded() {
isDisplayBubbleOutsideAppUseCase.onDestroy()
isOnHold = false
@@ -164,18 +151,12 @@ internal class ServiceChatHeadController(
isOnHold = false
state = State.ENGAGEMENT
isDisplayBubbleOutsideAppUseCase(resumedViewName)
- if (engagementConfiguration == null) setEngagementConfiguration(
- Dependencies.sdkConfigurationManager.buildEngagementConfiguration()
- )
updateChatHeadView()
}
private fun queueingStarted() {
state = State.QUEUEING
isDisplayBubbleOutsideAppUseCase(resumedViewName)
- if (engagementConfiguration == null) setEngagementConfiguration(
- Dependencies.sdkConfigurationManager.buildEngagementConfiguration()
- )
updateChatHeadView()
}
diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/textview/BaseConfigurableTextView.java b/widgetssdk/src/main/java/com/glia/widgets/view/textview/BaseConfigurableTextView.java
index efdd7eb7d..8680dda7c 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/view/textview/BaseConfigurableTextView.java
+++ b/widgetssdk/src/main/java/com/glia/widgets/view/textview/BaseConfigurableTextView.java
@@ -1,7 +1,6 @@
package com.glia.widgets.view.textview;
-import static com.glia.widgets.helper.ContextExtensionsKt.pxToSp;
import android.content.Context;
import android.util.AttributeSet;
@@ -13,6 +12,7 @@
import com.glia.widgets.R;
import com.glia.widgets.UiTheme;
+import com.glia.widgets.helper.ContextExtensions;
import com.glia.widgets.view.configuration.TextConfiguration;
import com.google.android.material.textview.MaterialTextView;
@@ -48,7 +48,7 @@ private void createBuildTimeConfiguration() {
.textColor(getTextColors())
.textColorHighlight(getHighlightColor())
.hintColor(getHintTextColors())
- .textSize(pxToSp(getContext(), getTextSize()))
+ .textSize(ContextExtensions.pxToSp(getContext(), getTextSize()))
.build();
}
diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/entrywidget/MediaTypeItemRemoteConfig.kt b/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/entrywidget/MediaTypeItemRemoteConfig.kt
index 78e967b62..314b7e8cc 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/entrywidget/MediaTypeItemRemoteConfig.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/entrywidget/MediaTypeItemRemoteConfig.kt
@@ -1,6 +1,6 @@
package com.glia.widgets.view.unifiedui.config.entrywidget
-import com.glia.widgets.view.unifiedui.config.base.ColorRemoteConfig
+import com.glia.widgets.view.unifiedui.config.base.ColorLayerRemoteConfig
import com.glia.widgets.view.unifiedui.config.base.LayerRemoteConfig
import com.glia.widgets.view.unifiedui.config.base.TextRemoteConfig
import com.glia.widgets.view.unifiedui.theme.entrywidget.MediaTypeItemTheme
@@ -10,7 +10,7 @@ internal data class MediaTypeItemRemoteConfig(
@SerializedName("background")
val background: LayerRemoteConfig?,
@SerializedName("iconColor")
- val iconColor: ColorRemoteConfig?,
+ val iconColor: ColorLayerRemoteConfig?,
@SerializedName("title")
val title: TextRemoteConfig?,
@SerializedName("message")
diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/entrywidget/MediaTypeItemsRemoteConfig.kt b/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/entrywidget/MediaTypeItemsRemoteConfig.kt
index f9a48c44d..cbb1d69df 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/entrywidget/MediaTypeItemsRemoteConfig.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/entrywidget/MediaTypeItemsRemoteConfig.kt
@@ -1,14 +1,14 @@
package com.glia.widgets.view.unifiedui.config.entrywidget
-import com.glia.widgets.view.unifiedui.config.base.ColorRemoteConfig
-import com.google.gson.annotations.SerializedName
+import com.glia.widgets.view.unifiedui.config.base.ColorLayerRemoteConfig
import com.glia.widgets.view.unifiedui.theme.entrywidget.MediaTypeItemsTheme
+import com.google.gson.annotations.SerializedName
internal data class MediaTypeItemsRemoteConfig(
@SerializedName("mediaTypeItem")
val mediaTypeItem: MediaTypeItemRemoteConfig?,
@SerializedName("dividerColor")
- val dividerColor: ColorRemoteConfig?
+ val dividerColor: ColorLayerRemoteConfig?
) {
fun toMediaTypeItemsTheme(): MediaTypeItemsTheme = MediaTypeItemsTheme(
mediaTypeItem = mediaTypeItem?.toMediaTypeItemTheme(),
diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/securemessaging/SecureMessagingRemoteConfig.kt b/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/securemessaging/SecureMessagingRemoteConfig.kt
index fc64b4bee..c610e6287 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/securemessaging/SecureMessagingRemoteConfig.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/config/securemessaging/SecureMessagingRemoteConfig.kt
@@ -1,6 +1,6 @@
package com.glia.widgets.view.unifiedui.config.securemessaging
-import com.glia.widgets.view.unifiedui.config.base.ColorRemoteConfig
+import com.glia.widgets.view.unifiedui.config.base.ColorLayerRemoteConfig
import com.glia.widgets.view.unifiedui.config.base.LayerRemoteConfig
import com.glia.widgets.view.unifiedui.config.base.TextRemoteConfig
import com.glia.widgets.view.unifiedui.config.entrywidget.MediaTypeItemsRemoteConfig
@@ -17,15 +17,15 @@ internal data class SecureMessagingRemoteConfig(
@SerializedName("bottomBannerText")
val bottomBannerText: TextRemoteConfig?,
@SerializedName("bottomBannerDividerColor")
- val bottomBannerDividerColor: ColorRemoteConfig?,
+ val bottomBannerDividerColor: ColorLayerRemoteConfig?,
@SerializedName("topBannerBackground")
val topBannerBackground: LayerRemoteConfig?,
@SerializedName("topBannerText")
val topBannerText: TextRemoteConfig?,
@SerializedName("topBannerDividerColor")
- val topBannerDividerColor: ColorRemoteConfig?,
+ val topBannerDividerColor: ColorLayerRemoteConfig?,
@SerializedName("topBannerDropDownIconColor")
- val topBannerDropDownIconColor: ColorRemoteConfig?,
+ val topBannerDropDownIconColor: ColorLayerRemoteConfig?,
@SerializedName("mediaTypeItems")
val mediaTypeItems: MediaTypeItemsRemoteConfig?
) {
diff --git a/widgetssdk/src/main/java/com/glia/widgets/webbrowser/WebBrowserView.kt b/widgetssdk/src/main/java/com/glia/widgets/webbrowser/WebBrowserView.kt
index 600f12b24..9e5ce517a 100644
--- a/widgetssdk/src/main/java/com/glia/widgets/webbrowser/WebBrowserView.kt
+++ b/widgetssdk/src/main/java/com/glia/widgets/webbrowser/WebBrowserView.kt
@@ -4,7 +4,6 @@ import android.content.Context
import android.content.res.TypedArray
import android.net.Uri
import android.util.AttributeSet
-import android.view.Window
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
@@ -13,19 +12,16 @@ import androidx.core.content.withStyledAttributes
import androidx.core.view.ViewCompat
import com.glia.widgets.Constants
import com.glia.widgets.R
-import com.glia.widgets.UiTheme
import com.glia.widgets.databinding.WebBrowserViewBinding
import com.glia.widgets.di.Dependencies
import com.glia.widgets.helper.SimpleWindowInsetsAndAnimationHandler
import com.glia.widgets.helper.Utils
-import com.glia.widgets.helper.asActivity
import com.glia.widgets.helper.layoutInflater
import com.glia.widgets.locale.LocaleString
import com.glia.widgets.view.header.AppBarView
import com.glia.widgets.view.unifiedui.theme.UnifiedTheme
import com.glia.widgets.view.unifiedui.theme.base.HeaderTheme
import com.google.android.material.theme.overlay.MaterialThemeOverlay
-import kotlin.properties.Delegates
internal class WebBrowserView(
context: Context,
@@ -39,7 +35,6 @@ internal class WebBrowserView(
defStyleRes
) {
- private var theme: UiTheme by Delegates.notNull()
private val unifiedTheme: UnifiedTheme? by lazy { Dependencies.gliaThemeManager.theme }
var onFinishListener: OnFinishListener? = null
@@ -50,8 +45,6 @@ internal class WebBrowserView(
private val appBar: AppBarView? get() = binding?.appBarView
private val webView: WebView? get() = binding?.webView
- private val window: Window? by lazy { context.asActivity()?.window }
-
init {
isSaveEnabled = true
orientation = VERTICAL
@@ -107,7 +100,7 @@ internal class WebBrowserView(
}
private fun setDefaultTheme(typedArray: TypedArray) {
- theme = Utils.getThemeFromTypedArray(typedArray, this.context)
+ binding?.appBarView?.setTheme(Utils.getFullHybridTheme(typedArray, this.context))
}
private fun initCallbacks() {
diff --git a/widgetssdk/src/test/java/android/TestExtensions.kt b/widgetssdk/src/test/java/android/TestExtensions.kt
index 2daadd2df..919538080 100644
--- a/widgetssdk/src/test/java/android/TestExtensions.kt
+++ b/widgetssdk/src/test/java/android/TestExtensions.kt
@@ -4,7 +4,7 @@ import android.content.Intent
import java.nio.charset.StandardCharsets
internal const val COMMON_EXTENSIONS_CLASS_PATH = "com.glia.widgets.helper.CommonExtensionsKt"
-internal const val CONTEXT_EXTENSIONS_CLASS_PATH = "com.glia.widgets.helper.ContextExtensionsKt"
+internal const val CONTEXT_EXTENSIONS_CLASS_PATH = "com.glia.widgets.helper.ContextExtensions"
internal const val LOGGER_PATH = "com.glia.widgets.helper.Logger"
fun Class.readRawResource(resName: String): String = classLoader?.getResourceAsStream(resName)?.run {
diff --git a/widgetssdk/src/test/java/com/glia/widgets/GliaWidgetsTest.kt b/widgetssdk/src/test/java/com/glia/widgets/GliaWidgetsTest.kt
index 5b3ad4cfd..26ccad6d7 100644
--- a/widgetssdk/src/test/java/com/glia/widgets/GliaWidgetsTest.kt
+++ b/widgetssdk/src/test/java/com/glia/widgets/GliaWidgetsTest.kt
@@ -70,6 +70,7 @@ class GliaWidgetsTest {
val callVisualizerController = mock()
whenever(controllerFactory.callVisualizerController).thenReturn(callVisualizerController)
whenever(repositoryFactory.engagementRepository) doReturn mock()
+ whenever(repositoryFactory.engagementConfigRepository) doReturn mock()
GliaWidgets.init(widgetsConfig)
val captor = argumentCaptor()
verify(gliaCore).init(captor.capture())
diff --git a/widgetssdk/src/test/java/com/glia/widgets/chat/ChatManagerTest.kt b/widgetssdk/src/test/java/com/glia/widgets/chat/ChatManagerTest.kt
index c0007015d..4a7cf2472 100644
--- a/widgetssdk/src/test/java/com/glia/widgets/chat/ChatManagerTest.kt
+++ b/widgetssdk/src/test/java/com/glia/widgets/chat/ChatManagerTest.kt
@@ -146,17 +146,14 @@ class ChatManagerTest {
@Test
fun `mapInQueue adds OperatorStatusItem_InQueue to chatItems and updates operatorStatusItem`() {
- val companyName = "company Name"
- val newState = subjectUnderTest.mapInQueue(companyName, state)
+ val newState = subjectUnderTest.mapInQueue(state)
val lastItem = newState.chatItems.last() as OperatorStatusItem.InQueue
- assertEquals(companyName, lastItem.companyName)
- assertEquals(companyName, newState.operatorStatusItem!!.companyName)
assertEquals(lastItem, newState.operatorStatusItem)
}
@Test
fun `mapTransferring removes old OperatorStatusItem when it exists and adds new one`() {
- subjectUnderTest.mapTransferring(subjectUnderTest.mapInQueue("name", state)).apply {
+ subjectUnderTest.mapTransferring(subjectUnderTest.mapInQueue(state)).apply {
assertTrue(chatItems.count() == 1)
assertTrue(chatItems.contains(OperatorStatusItem.Transferring))
}
@@ -164,7 +161,7 @@ class ChatManagerTest {
@Test
fun `mapOperatorConnected adds OperatorStatusItem_Connected when the old is null`() {
- val action = ChatManager.Action.OperatorConnected("c_name", "o_name", "o_image")
+ val action = ChatManager.Action.OperatorConnected("o_name", "o_image")
val stateSpy = spy(state)
val subjectUnderTestSpy = spy(subjectUnderTest)
subjectUnderTestSpy.mapOperatorConnected(action, stateSpy)
@@ -172,13 +169,12 @@ class ChatManagerTest {
verify(stateSpy).resetOperator()
val newItem = stateSpy.chatItems.last() as OperatorStatusItem.Connected
assertEquals(newItem.operatorName, action.operatorFormattedName)
- assertEquals(newItem.companyName, action.companyName)
assertEquals(newItem.profileImgUrl, action.operatorImageUrl)
}
@Test
fun `mapOperatorConnected replaces old OperatorStatusItem when the old is exists`() {
- val action = ChatManager.Action.OperatorConnected("c_name", "o_name", "o_image")
+ val action = ChatManager.Action.OperatorConnected("o_name", "o_image")
state.apply {
operatorStatusItem = OperatorStatusItem.Transferring
chatItems.add(mock())
@@ -190,7 +186,6 @@ class ChatManagerTest {
verify(subjectUnderTestSpy).checkUnsentMessages(any())
val newItem = newState.chatItems.last() as OperatorStatusItem.Connected
assertEquals(newItem.operatorName, action.operatorFormattedName)
- assertEquals(newItem.companyName, action.companyName)
assertEquals(newItem.profileImgUrl, action.operatorImageUrl)
assertFalse(newState.chatItems.contains(OperatorStatusItem.Transferring))
}
@@ -198,7 +193,7 @@ class ChatManagerTest {
@Test
fun `addUnsentMessage adds Unsent message before OperatorStatusItem when chatItems contain OperatorStatusItem_InQueue`() {
val message = Unsent(SendMessagePayload(content = "message"))
- val inQueue = OperatorStatusItem.InQueue("company_name")
+ val inQueue = OperatorStatusItem.InQueue
assertTrue(state.unsentItems.isEmpty())
assertTrue(state.chatItems.isEmpty())
val newState = subjectUnderTest.addUnsentMessage(message, state)
@@ -229,7 +224,7 @@ class ChatManagerTest {
@Test
fun `mapOperatorJoined adds OperatorStatusItem_Joined to chatItems when called`() {
- val action: ChatManager.Action.OperatorJoined = ChatManager.Action.OperatorJoined("", "", "")
+ val action: ChatManager.Action.OperatorJoined = ChatManager.Action.OperatorJoined("", "")
subjectUnderTest.mapTransferring(state).apply {
assertTrue(chatItems.contains(OperatorStatusItem.Transferring))
}
@@ -326,19 +321,14 @@ class ChatManagerTest {
@Test
fun `mapAction calls mapInQueue when Action_QueuingStarted passed`() {
- val action: ChatManager.Action.QueuingStarted = mock {
- on { companyName } doReturn ""
- }
-
val subjectUnderTestSpy = spy(subjectUnderTest)
- subjectUnderTestSpy.mapAction(action, state)
- verify(subjectUnderTestSpy).mapInQueue(any(), any())
+ subjectUnderTestSpy.mapAction(ChatManager.Action.QueuingStarted, state)
+ verify(subjectUnderTestSpy).mapInQueue(any())
}
@Test
fun `mapAction calls mapOperatorConnected when Action_OperatorConnected passed`() {
val action: ChatManager.Action.OperatorConnected = mock {
- on { companyName } doReturn ""
on { operatorFormattedName } doReturn ""
}
@@ -359,7 +349,6 @@ class ChatManagerTest {
@Test
fun `mapAction calls mapOperatorJoined when Action_OperatorJoined passed`() {
val action: ChatManager.Action.OperatorJoined = mock {
- on { companyName } doReturn ""
on { operatorFormattedName } doReturn ""
}
diff --git a/widgetssdk/src/test/java/com/glia/widgets/chat/controller/ChatControllerTest.kt b/widgetssdk/src/test/java/com/glia/widgets/chat/controller/ChatControllerTest.kt
index a04368db3..e90c96298 100644
--- a/widgetssdk/src/test/java/com/glia/widgets/chat/controller/ChatControllerTest.kt
+++ b/widgetssdk/src/test/java/com/glia/widgets/chat/controller/ChatControllerTest.kt
@@ -34,8 +34,8 @@ import com.glia.widgets.core.notification.domain.CallNotificationUseCase
import com.glia.widgets.core.permissions.domain.RequestNotificationPermissionIfPushNotificationsSetUpUseCase
import com.glia.widgets.core.permissions.domain.WithCameraPermissionUseCase
import com.glia.widgets.core.permissions.domain.WithReadWritePermissionsUseCase
-import com.glia.widgets.core.secureconversations.domain.IsSecureEngagementUseCase
import com.glia.widgets.core.secureconversations.domain.GetAvailableQueueIdsForSecureMessagingUseCase
+import com.glia.widgets.core.secureconversations.domain.IsSecureEngagementUseCase
import com.glia.widgets.engagement.domain.AcceptMediaUpgradeOfferUseCase
import com.glia.widgets.engagement.domain.DeclineMediaUpgradeOfferUseCase
import com.glia.widgets.engagement.domain.EndEngagementUseCase
@@ -238,35 +238,23 @@ class ChatControllerTest {
@Test
fun initChat_setsConfiguration_withInitialParams() {
- val queueIds = listOf("QueueId1", "QueueId2")
whenever(chatManager.initialize(any(), any(), any())) doReturn Flowable.never()
- chatController.initChat(
- "CompanyName",
- queueIds,
- "VisitorId",
- ChatType.SECURE_MESSAGING
- )
+ chatController.initChat(ChatType.SECURE_MESSAGING)
- verify(engagementConfigUseCase).invoke(ChatType.SECURE_MESSAGING, queueIds)
+ verify(engagementConfigUseCase).invoke(ChatType.SECURE_MESSAGING)
}
@Test
fun initChat_setsConfiguration_withAvailableQueues() {
val queueIds = listOf("QueueId1", "QueueId2")
whenever(isSecureEngagementUseCase.invoke()) doReturn true
- whenever(getAvailableQueueIdsForSecureMessagingUseCase.invoke()) doReturn Single.just(Data.Value(queueIds))
+ whenever(getAvailableQueueIdsForSecureMessagingUseCase()) doReturn Single.just(Data.Value(queueIds))
whenever(chatManager.initialize(any(), any(), any())) doReturn Flowable.never()
- chatController.initChat(
- "CompanyName",
- emptyList(),
- "VisitorId",
- ChatType.SECURE_MESSAGING
- )
+ chatController.initChat(ChatType.SECURE_MESSAGING)
- verify(engagementConfigUseCase).invoke(ChatType.SECURE_MESSAGING, emptyList())
- verify(engagementConfigUseCase).invoke(ChatType.SECURE_MESSAGING, queueIds)
+ verify(engagementConfigUseCase).invoke(ChatType.SECURE_MESSAGING)
}
@Test
@@ -275,12 +263,7 @@ class ChatControllerTest {
whenever(getAvailableQueueIdsForSecureMessagingUseCase.invoke()) doReturn Single.just(Data.Value(null))
whenever(chatManager.initialize(any(), any(), any())) doReturn Flowable.never()
- chatController.initChat(
- "CompanyName",
- emptyList(),
- "VisitorId",
- ChatType.SECURE_MESSAGING
- )
+ chatController.initChat(ChatType.SECURE_MESSAGING)
verify(dialogController).showMessageCenterUnavailableDialog()
}
@@ -291,12 +274,7 @@ class ChatControllerTest {
whenever(getAvailableQueueIdsForSecureMessagingUseCase.invoke()) doReturn Single.error(Exception())
whenever(chatManager.initialize(any(), any(), any())) doReturn Flowable.never()
- chatController.initChat(
- "CompanyName",
- emptyList(),
- "VisitorId",
- ChatType.SECURE_MESSAGING
- )
+ chatController.initChat(ChatType.SECURE_MESSAGING)
verify(dialogController).showUnexpectedErrorDialog()
}
diff --git a/widgetssdk/src/test/java/com/glia/widgets/core/configuration/EngagementCallConfigurationManagerTest.kt b/widgetssdk/src/test/java/com/glia/widgets/core/configuration/EngagementCallConfigurationManagerTest.kt
deleted file mode 100644
index 45cf455c0..000000000
--- a/widgetssdk/src/test/java/com/glia/widgets/core/configuration/EngagementCallConfigurationManagerTest.kt
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.glia.widgets.core.configuration
-
-import com.glia.androidsdk.Glia
-import com.glia.widgets.R
-import com.glia.widgets.di.Dependencies
-import com.glia.widgets.helper.ResourceProvider
-import com.glia.widgets.locale.LocaleProvider
-import io.mockk.every
-import io.mockk.justRun
-import io.mockk.mockk
-import io.mockk.mockkStatic
-import org.junit.Assert.assertEquals
-import org.junit.Before
-import org.junit.Test
-
-private const val DEFAULT_LOCAL_COMPANY_NAME = "Local Company Name"
-
-class EngagementCallConfigurationManagerTest {
-
- private val configurationManager: GliaSdkConfigurationManager = GliaSdkConfigurationManager()
- private val resourceProvider: ResourceProvider = mockk()
- private val localeProvider: LocaleProvider = mockk()
-
- @Before
- fun setup() {
- mockkStatic(Glia::class)
- Dependencies.resourceProvider = resourceProvider
- Dependencies.localeProvider = localeProvider
- every { resourceProvider.getResourceKey(R.string.general_company_name)} returns "key"
- every { resourceProvider.getString(any()) } returns DEFAULT_LOCAL_COMPANY_NAME
- justRun { localeProvider.reportImproperInitialisation(any())}
- }
-
- @Test
- fun `getCompanyName returns legacy value when non-legacy is null`() {
- configurationManager.setLegacyCompanyName("Legacy name")
- configurationManager.companyName = null
- assertEquals("Legacy name", configurationManager.companyName)
- }
-
- @Test
- fun `getCompanyName should not be replaced when remote value is empty but local custom value is set using GliaWidgetsConfig setCompanyName`() {
- configurationManager.setLegacyCompanyName("Legacy name")
- configurationManager.companyName = "Init company name"
- every { Glia.getRemoteString(any()) } returns ""
- every { resourceProvider.getString(R.string.general_company_name) } returns DEFAULT_LOCAL_COMPANY_NAME
- assertEquals("Init company name", configurationManager.companyName)
- }
-}
diff --git a/widgetssdk/src/test/java/com/glia/widgets/engagement/EngagementRepositoryTest.kt b/widgetssdk/src/test/java/com/glia/widgets/engagement/EngagementRepositoryTest.kt
index 6fc06bf3a..9cc3e50e1 100644
--- a/widgetssdk/src/test/java/com/glia/widgets/engagement/EngagementRepositoryTest.kt
+++ b/widgetssdk/src/test/java/com/glia/widgets/engagement/EngagementRepositoryTest.kt
@@ -789,7 +789,7 @@ class EngagementRepositoryTest {
fun `queueForEngagement with TEXT type produces PreQueueing when queueing success`() {
val queueId = "queue_id"
val queueForEngagementCallbackSlot = slot>()
- repository.queueForEngagement(listOf(queueId), MediaType.TEXT,null)
+ repository.queueForEngagement(listOf(queueId), MediaType.TEXT)
verify(exactly = 1) { core.queueForEngagement(arrayOf(queueId), MediaType.TEXT, null, any(), any(), capture(queueForEngagementCallbackSlot)) }
queueForEngagementCallbackSlot.captured.accept(null)
@@ -799,7 +799,7 @@ class EngagementRepositoryTest {
repository.engagementState.test().assertNotComplete().assertValue(State.PreQueuing(listOf(queueId), MediaType.TEXT))
- repository.queueForEngagement(listOf(queueId), MediaType.TEXT, "url")
+ repository.queueForEngagement(listOf(queueId), MediaType.TEXT)
verify(exactly = 0) { core.queueForEngagement(arrayOf(queueId), MediaType.TEXT, "url", any(), any(), capture(queueForEngagementCallbackSlot)) }
}
@@ -809,7 +809,7 @@ class EngagementRepositoryTest {
val queueId = "queue_id"
val mediaType = MediaType.AUDIO
val queueForEngagementCallbackSlot = slot>()
- repository.queueForEngagement(listOf(queueId), mediaType, null)
+ repository.queueForEngagement(listOf(queueId), mediaType)
verify { core.queueForEngagement(arrayOf(queueId), mediaType, null, any(), any(), capture(queueForEngagementCallbackSlot)) }
queueForEngagementCallbackSlot.captured.accept(null)
@@ -822,7 +822,7 @@ class EngagementRepositoryTest {
val queueId = "queue_id"
val mediaType = MediaType.AUDIO
val queueForEngagementCallbackSlot = slot>()
- repository.queueForEngagement(listOf(queueId), mediaType, null)
+ repository.queueForEngagement(listOf(queueId), mediaType)
verify(exactly = 1) { core.queueForEngagement(arrayOf(queueId), mediaType, null, any(), any(), capture(queueForEngagementCallbackSlot)) }
queueForEngagementCallbackSlot.captured.accept(GliaException("message", GliaException.Cause.ALREADY_QUEUED))
@@ -832,7 +832,7 @@ class EngagementRepositoryTest {
repository.engagementState.test().assertNotComplete().assertValue(State.PreQueuing(listOf(queueId), mediaType))
- repository.queueForEngagement(listOf(queueId), MediaType.VIDEO, null)
+ repository.queueForEngagement(listOf(queueId), MediaType.VIDEO)
verify(exactly = 0) { core.queueForEngagement(arrayOf(queueId), MediaType.VIDEO, null, any(), any(), capture(queueForEngagementCallbackSlot)) }
}
@@ -843,7 +843,7 @@ class EngagementRepositoryTest {
val mediaType = MediaType.AUDIO
val queueForEngagementCallbackSlot = slot>()
val testSubscriber = repository.engagementState.test()
- repository.queueForEngagement(listOf(queueId), mediaType, null)
+ repository.queueForEngagement(listOf(queueId), mediaType)
verify { core.queueForEngagement(arrayOf(queueId), mediaType, null, any(), any(), capture(queueForEngagementCallbackSlot)) }
queueForEngagementCallbackSlot.captured.accept(GliaException("message", GliaException.Cause.QUEUE_CLOSED))
@@ -861,7 +861,7 @@ class EngagementRepositoryTest {
val mediaType = MediaType.AUDIO
val queueForEngagementCallbackSlot = slot>()
val testSubscriber = repository.engagementState.test()
- repository.queueForEngagement(listOf(queueId), mediaType, null)
+ repository.queueForEngagement(listOf(queueId), mediaType)
verify { core.queueForEngagement(arrayOf(queueId), mediaType, null, any(), any(), capture(queueForEngagementCallbackSlot)) }
queueForEngagementCallbackSlot.captured.accept(GliaException("message", GliaException.Cause.NETWORK_TIMEOUT))
@@ -883,7 +883,7 @@ class EngagementRepositoryTest {
val queueTicket: QueueTicket = mockk(relaxed = true) {
every { id } returns ticketId
}
- repository.queueForEngagement(listOf(queueId), mediaType, null)
+ repository.queueForEngagement(listOf(queueId), mediaType)
verify(exactly = 1) { core.queueForEngagement(arrayOf(queueId), mediaType, null, any(), any(), capture(queueForEngagementCallbackSlot)) }
queueForEngagementCallbackSlot.captured.accept(null)
@@ -922,7 +922,7 @@ class EngagementRepositoryTest {
val queueTicket: QueueTicket = mockk(relaxed = true) {
every { id } returns ticketId
}
- repository.queueForEngagement(listOf(queueId), mediaType, null)
+ repository.queueForEngagement(listOf(queueId), mediaType)
verify(exactly = 1) { core.queueForEngagement(arrayOf(queueId), mediaType, null, any(), any(), capture(queueForEngagementCallbackSlot)) }
queueForEngagementCallbackSlot.captured.accept(null)
@@ -960,7 +960,7 @@ class EngagementRepositoryTest {
val queueTicket: QueueTicket = mockk(relaxed = true) {
every { id } returns ticketId
}
- repository.queueForEngagement(listOf(queueId), mediaType, null)
+ repository.queueForEngagement(listOf(queueId), mediaType)
verify(exactly = 1) { core.queueForEngagement(arrayOf(queueId), mediaType, null, any(), any(), capture(queueForEngagementCallbackSlot)) }
queueForEngagementCallbackSlot.captured.accept(null)
diff --git a/widgetssdk/src/test/java/com/glia/widgets/engagement/completion/EngagementCompletionActivityWatcherTest.kt b/widgetssdk/src/test/java/com/glia/widgets/engagement/completion/EngagementCompletionActivityWatcherTest.kt
index 648c96723..a804b5ffa 100644
--- a/widgetssdk/src/test/java/com/glia/widgets/engagement/completion/EngagementCompletionActivityWatcherTest.kt
+++ b/widgetssdk/src/test/java/com/glia/widgets/engagement/completion/EngagementCompletionActivityWatcherTest.kt
@@ -7,12 +7,14 @@ import android.content.Context
import android.os.Parcelable
import android.view.View
import androidx.appcompat.app.AlertDialog
+import com.glia.androidsdk.engagement.Survey
import com.glia.widgets.UiTheme
import com.glia.widgets.chat.ChatActivity
import com.glia.widgets.helper.GliaActivityManager
import com.glia.widgets.helper.Logger
import com.glia.widgets.helper.OneTimeEvent
import com.glia.widgets.helper.withRuntimeTheme
+import com.glia.widgets.launcher.ActivityLauncher
import com.glia.widgets.view.Dialogs
import io.mockk.Runs
import io.mockk.confirmVerified
@@ -40,6 +42,7 @@ class EngagementCompletionActivityWatcherTest {
private lateinit var controller: EngagementCompletionContract.Controller
private lateinit var watcher: EngagementCompletionActivityWatcher
+ private lateinit var activityLauncher: ActivityLauncher
@Before
fun setUp() {
@@ -59,7 +62,9 @@ class EngagementCompletionActivityWatcherTest {
every { state } returns stateProcessor
}
- watcher = EngagementCompletionActivityWatcher(controller, gliaActivityManager)
+ activityLauncher = mockk(relaxUnitFun = true)
+
+ watcher = EngagementCompletionActivityWatcher(controller, gliaActivityManager, activityLauncher)
verify { controller.state }
}
@@ -275,7 +280,8 @@ class EngagementCompletionActivityWatcherTest {
@Test
fun `handleState will start Survey when event is SurveyLoaded`() {
- val event = createMockEvent(EngagementCompletionState.SurveyLoaded(mockk(moreInterfaces = arrayOf(Parcelable::class))))
+ val survey = mockk(moreInterfaces = arrayOf(Parcelable::class))
+ val event = createMockEvent(EngagementCompletionState.SurveyLoaded(survey))
val activity = mockkActivity()
@@ -292,9 +298,7 @@ class EngagementCompletionActivityWatcherTest {
verify { event.consume(any()) }
- verify { activity.overridePendingTransition(any(), any()) }
- verify { activity.startActivity(any()) }
- verify { activity.packageName }
+ verify { activityLauncher.launchSurvey(eq(activity), eq(survey)) }
verify(exactly = 0) { dialog.dismiss() }
verify(exactly = 0) { gliaActivityManager.finishActivities() }
diff --git a/widgetssdk/src/test/java/com/glia/widgets/engagement/domain/EngagementDomainTest.kt b/widgetssdk/src/test/java/com/glia/widgets/engagement/domain/EngagementDomainTest.kt
index e75729c03..a1a9a9d89 100644
--- a/widgetssdk/src/test/java/com/glia/widgets/engagement/domain/EngagementDomainTest.kt
+++ b/widgetssdk/src/test/java/com/glia/widgets/engagement/domain/EngagementDomainTest.kt
@@ -24,6 +24,7 @@ import com.glia.widgets.engagement.EngagementRepository
import com.glia.widgets.engagement.ScreenSharingState
import com.glia.widgets.helper.Data
import com.glia.widgets.helper.formattedName
+import com.glia.widgets.launcher.ConfigurationManager
import com.glia.widgets.permissions.Permissions
import com.glia.widgets.permissions.PermissionsGrantedCallback
import io.mockk.Runs
@@ -308,30 +309,18 @@ class EngagementDomainTest {
assertTrue(useCase.isMediaEngagement)
}
- @Test
- fun `EnqueueForEngagementUseCase invoke enqueues for chat engagement when media type is absent`() {
- val repository: EngagementRepository = mockk(relaxUnitFun = true)
- val queueIds = listOf("queueId1", "queueId2")
- val mediaType: Engagement.MediaType? = null
- val visitorContextAssetId = null
-
- val useCase: EnqueueForEngagementUseCase = EnqueueForEngagementUseCaseImpl(engagementRepository = repository)
- useCase(queueIds, mediaType, visitorContextAssetId)
-
- verify { repository.queueForEngagement(queueIds, Engagement.MediaType.TEXT, visitorContextAssetId) }
- }
-
@Test
fun `EnqueueForEngagementUseCase invoke enqueues with selected type engagement when media type is present`() {
val repository: EngagementRepository = mockk(relaxUnitFun = true)
val queueIds = listOf("queueId1", "queueId2")
val mediaType: Engagement.MediaType = mockk(relaxUnitFun = true)
- val visitorContextAssetId = null
- val useCase: EnqueueForEngagementUseCase = EnqueueForEngagementUseCaseImpl(engagementRepository = repository)
- useCase(queueIds, mediaType, visitorContextAssetId)
+ val configurationManager = mockk()
+ every { configurationManager.queueIds } returns queueIds
+ val useCase: EnqueueForEngagementUseCase = EnqueueForEngagementUseCaseImpl(engagementRepository = repository, configurationManager)
+ useCase(mediaType)
- verify { repository.queueForEngagement(queueIds, mediaType, visitorContextAssetId) }
+ verify { repository.queueForEngagement(queueIds, mediaType) }
}
@Test
@@ -523,12 +512,17 @@ class EngagementDomainTest {
@Test
fun `ScreenSharingUseCase test`() {
+ val mode = ScreenSharing.Mode.UNBOUNDED
val engagementRepository: EngagementRepository = mockk(relaxUnitFun = true)
val releaseScreenSharingResourcesUseCase: ReleaseScreenSharingResourcesUseCase = mockk(relaxUnitFun = true)
+ val configurationManager = mockk {
+ every { screenSharingMode } returns mode
+ }
val useCase: ScreenSharingUseCase = ScreenSharingUseCaseImpl(
engagementRepository = engagementRepository,
- releaseScreenSharingResourcesUseCase = releaseScreenSharingResourcesUseCase
+ releaseScreenSharingResourcesUseCase = releaseScreenSharingResourcesUseCase,
+ configurationManager
)
every { engagementRepository.isSharingScreen } returns true
@@ -548,8 +542,7 @@ class EngagementDomainTest {
verify { engagementRepository.declineScreenSharingRequest() }
val activity: Activity = mockk(relaxUnitFun = true)
- val mode: ScreenSharing.Mode = mockk(relaxUnitFun = true)
- useCase.acceptRequestWithAskedPermission(activity, mode)
+ useCase.acceptRequestWithAskedPermission(activity)
verify { engagementRepository.acceptScreenSharingWithAskedPermission(activity, mode) }
val resultCode = 1
diff --git a/widgetssdk/src/test/java/com/glia/widgets/messagecenter/MessageCenterControllerTest.kt b/widgetssdk/src/test/java/com/glia/widgets/messagecenter/MessageCenterControllerTest.kt
index c67141707..dce704eea 100644
--- a/widgetssdk/src/test/java/com/glia/widgets/messagecenter/MessageCenterControllerTest.kt
+++ b/widgetssdk/src/test/java/com/glia/widgets/messagecenter/MessageCenterControllerTest.kt
@@ -2,28 +2,25 @@ package com.glia.widgets.messagecenter
import com.glia.androidsdk.GliaException
import com.glia.androidsdk.RequestCallback
-import com.glia.widgets.UiTheme
import com.glia.widgets.chat.ChatType
import com.glia.widgets.chat.domain.IsAuthenticatedUseCase
import com.glia.widgets.chat.domain.SiteInfoUseCase
import com.glia.widgets.chat.domain.TakePictureUseCase
import com.glia.widgets.chat.domain.UriToFileAttachmentUseCase
-import com.glia.widgets.core.configuration.EngagementConfiguration
import com.glia.widgets.core.dialog.DialogContract
import com.glia.widgets.core.engagement.domain.SetEngagementConfigUseCase
import com.glia.widgets.core.fileupload.model.FileAttachment
import com.glia.widgets.core.permissions.domain.RequestNotificationPermissionIfPushNotificationsSetUpUseCase
import com.glia.widgets.core.secureconversations.domain.AddSecureFileAttachmentsObserverUseCase
import com.glia.widgets.core.secureconversations.domain.AddSecureFileToAttachmentAndUploadUseCase
+import com.glia.widgets.core.secureconversations.domain.GetAvailableQueueIdsForSecureMessagingUseCase
import com.glia.widgets.core.secureconversations.domain.GetSecureFileAttachmentsUseCase
import com.glia.widgets.core.secureconversations.domain.OnNextMessageUseCase
import com.glia.widgets.core.secureconversations.domain.RemoveSecureFileAttachmentUseCase
import com.glia.widgets.core.secureconversations.domain.ResetMessageCenterUseCase
-import com.glia.widgets.core.secureconversations.domain.GetAvailableQueueIdsForSecureMessagingUseCase
import com.glia.widgets.core.secureconversations.domain.SendMessageButtonStateUseCase
import com.glia.widgets.core.secureconversations.domain.SendSecureMessageUseCase
import com.glia.widgets.core.secureconversations.domain.ShowMessageLimitErrorUseCase
-import com.glia.widgets.view.head.controller.ServiceChatHeadController
import io.reactivex.rxjava3.core.Observable
import org.junit.Before
import org.junit.Test
@@ -37,7 +34,6 @@ import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
internal class MessageCenterControllerTest {
- private lateinit var serviceChatHeadController: ServiceChatHeadController
private lateinit var messageCenterController: MessageCenterController
private lateinit var engagementConfigUseCase: SetEngagementConfigUseCase
private lateinit var sendSecureMessageUseCase: SendSecureMessageUseCase
@@ -60,7 +56,6 @@ internal class MessageCenterControllerTest {
@Before
fun setUp() {
- serviceChatHeadController = mock()
engagementConfigUseCase = mock()
sendSecureMessageUseCase = mock()
getAvailableQueueIdsForSecureMessagingUseCase = mock()
@@ -80,7 +75,6 @@ internal class MessageCenterControllerTest {
uriToFileAttachmentUseCase = mock()
requestNotificationPermissionIfPushNotificationsSetUpUseCase = mock()
messageCenterController = MessageCenterController(
- serviceChatHeadController = serviceChatHeadController,
engagementConfigUseCase = engagementConfigUseCase,
sendSecureMessageUseCase = sendSecureMessageUseCase,
getAvailableQueueIdsForSecureMessagingUseCase = getAvailableQueueIdsForSecureMessagingUseCase,
@@ -101,22 +95,6 @@ internal class MessageCenterControllerTest {
)
}
- @Test
- fun setConfiguration_setBuildTimeTheme_onTrigger() {
- val uiTheme = mock()
- messageCenterController.setConfiguration(uiTheme, mock())
-
- verify(serviceChatHeadController, times(1)).setBuildTimeTheme(uiTheme)
- }
-
- @Test
- fun setConfiguration_setEngagementConfiguration_onTrigger() {
- val configuration = mock()
- messageCenterController.setConfiguration(mock(), configuration)
-
- verify(serviceChatHeadController, times(1)).setEngagementConfiguration(configuration)
- }
-
@Test
fun initialize_ExecutesAddSecureFileAttachmentsObserverUseCase_onTrigger() {
whenever(isAuthenticatedUseCase()) doReturn true
@@ -275,7 +253,7 @@ internal class MessageCenterControllerTest {
argumentCaptor.firstValue.onResult(availableQueueIds, null)
- verify(engagementConfigUseCase, times(1)).invoke(ChatType.SECURE_MESSAGING, availableQueueIds)
+ verify(engagementConfigUseCase, times(1)).invoke(ChatType.SECURE_MESSAGING)
}
@Test
diff --git a/widgetssdk/src/test/java/com/glia/widgets/operator/OperatorRequestActivityWatcherTest.kt b/widgetssdk/src/test/java/com/glia/widgets/operator/OperatorRequestActivityWatcherTest.kt
index 350d995de..dacb425a6 100644
--- a/widgetssdk/src/test/java/com/glia/widgets/operator/OperatorRequestActivityWatcherTest.kt
+++ b/widgetssdk/src/test/java/com/glia/widgets/operator/OperatorRequestActivityWatcherTest.kt
@@ -133,7 +133,7 @@ class OperatorRequestActivityWatcherTest {
) { event, activity ->
verify { event.consume(any()) }
verify { gliaActivityManager.finishActivities() }
- verify { activityLauncher.launchCall(any(), any()) }
+ verify { activityLauncher.launchCall(any(), any(), eq(true)) }
confirmVerified(activity, event)
}
@@ -146,7 +146,7 @@ class OperatorRequestActivityWatcherTest {
) { event, activity ->
verify { event.consume(any()) }
verify(exactly = 0) { gliaActivityManager.finishActivities() }
- verify { activityLauncher.launchCall(any(), any()) }
+ verify { activityLauncher.launchCall(any(), any(), eq(true)) }
confirmVerified(activity, event)
}
@@ -159,7 +159,7 @@ class OperatorRequestActivityWatcherTest {
) { event, activity ->
verify { event.consume(any()) }
verify(exactly = 0) { gliaActivityManager.finishActivities() }
- verify(exactly = 0) { activityLauncher.launchCall(any(), any()) }
+ verify(exactly = 0) { activityLauncher.launchCall(any(), any(), eq(true)) }
confirmVerified(activity, event)
}
diff --git a/widgetssdk/src/test/java/com/glia/widgets/operator/OperatorRequestControllerTest.kt b/widgetssdk/src/test/java/com/glia/widgets/operator/OperatorRequestControllerTest.kt
index a57f039c4..2d5047904 100644
--- a/widgetssdk/src/test/java/com/glia/widgets/operator/OperatorRequestControllerTest.kt
+++ b/widgetssdk/src/test/java/com/glia/widgets/operator/OperatorRequestControllerTest.kt
@@ -8,7 +8,6 @@ import androidx.activity.result.ActivityResult
import com.glia.androidsdk.Engagement
import com.glia.androidsdk.comms.MediaUpgradeOffer
import com.glia.widgets.chat.ChatActivity
-import com.glia.widgets.core.configuration.GliaSdkConfigurationManager
import com.glia.widgets.core.dialog.DialogContract
import com.glia.widgets.core.dialog.domain.IsShowOverlayPermissionRequestDialogUseCase
import com.glia.widgets.core.dialog.domain.SetOverlayPermissionRequestDialogShownUseCase
@@ -62,7 +61,6 @@ class OperatorRequestControllerTest {
private lateinit var setOverlayPermissionRequestDialogShownUseCase: SetOverlayPermissionRequestDialogShownUseCase
private lateinit var dialogController: DialogContract.Controller
private lateinit var dialogCallbackSlot: CapturingSlot
- private lateinit var gliaSdkConfigurationManager: GliaSdkConfigurationManager
private lateinit var withNotificationPermissionUseCase: WithNotificationPermissionUseCase
private lateinit var prepareToScreenSharingUseCase: PrepareToScreenSharingUseCase
private lateinit var releaseScreenSharingResourcesUseCase: ReleaseScreenSharingResourcesUseCase
@@ -93,8 +91,6 @@ class OperatorRequestControllerTest {
dialogCallbackSlot = slot()
- gliaSdkConfigurationManager = mockk(relaxed = true)
-
controller = OperatorRequestController(
operatorMediaUpgradeOfferUseCase,
acceptMediaUpgradeOfferUseCase,
@@ -106,7 +102,6 @@ class OperatorRequestControllerTest {
isCurrentEngagementCallVisualizerUseCase,
setOverlayPermissionRequestDialogShownUseCase,
dialogController,
- gliaSdkConfigurationManager,
withNotificationPermissionUseCase,
prepareToScreenSharingUseCase,
releaseScreenSharingResourcesUseCase
@@ -308,20 +303,17 @@ class OperatorRequestControllerTest {
verify { withNotificationPermissionUseCase(capture(callbackSlot)) }
- verify(exactly = 0) { gliaSdkConfigurationManager.screenSharingMode }
- verify(exactly = 0) { screenSharingUseCase.acceptRequestWithAskedPermission(eq(activity), any()) }
+ verify(exactly = 0) { screenSharingUseCase.acceptRequestWithAskedPermission(eq(activity)) }
state.assertNotComplete().assertNoValues()
callbackSlot.captured.invoke()
- verify { gliaSdkConfigurationManager.screenSharingMode }
- verify { screenSharingUseCase.acceptRequestWithAskedPermission(eq(activity), any()) }
+ verify { screenSharingUseCase.acceptRequestWithAskedPermission(eq(activity)) }
state.assertNotComplete().assertValue { it.value == OperatorRequestContract.State.AcquireMediaProjectionToken }
confirmVerified(
releaseScreenSharingResourcesUseCase,
prepareToScreenSharingUseCase,
screenSharingUseCase,
- gliaSdkConfigurationManager,
withNotificationPermissionUseCase
)
}
diff --git a/widgetssdk/src/testSnapshot/java/com/glia/widgets/call/CallViewVideoSnapshotTest.kt b/widgetssdk/src/testSnapshot/java/com/glia/widgets/call/CallViewVideoSnapshotTest.kt
index b8ccd0a55..aa7190b9e 100644
--- a/widgetssdk/src/testSnapshot/java/com/glia/widgets/call/CallViewVideoSnapshotTest.kt
+++ b/widgetssdk/src/testSnapshot/java/com/glia/widgets/call/CallViewVideoSnapshotTest.kt
@@ -12,8 +12,7 @@ internal class CallViewVideoSnapshotTest : SnapshotTest(
// MARK: Init call
- private fun initCallState() = callState()
- .initCall(requestedMediaType = Engagement.MediaType.VIDEO)
+ private fun initCallState() = callState().initCall(requestedMediaType = Engagement.MediaType.VIDEO)
@Test
fun initCall() {
diff --git a/widgetssdk/src/testSnapshot/java/com/glia/widgets/call/SnapshotCallView.kt b/widgetssdk/src/testSnapshot/java/com/glia/widgets/call/SnapshotCallView.kt
index 6ba95af98..94702678c 100644
--- a/widgetssdk/src/testSnapshot/java/com/glia/widgets/call/SnapshotCallView.kt
+++ b/widgetssdk/src/testSnapshot/java/com/glia/widgets/call/SnapshotCallView.kt
@@ -22,6 +22,7 @@ import com.glia.widgets.snapshotutils.SnapshotLottie
import com.glia.widgets.snapshotutils.SnapshotProviders
import com.glia.widgets.snapshotutils.SnapshotSchedulers
import com.glia.widgets.snapshotutils.SnapshotTheme
+import com.glia.widgets.snapshotutils.SnapshotThemeConfiguration
import com.glia.widgets.view.floatingvisitorvideoview.FloatingVisitorVideoContract.FlipButtonState
import com.glia.widgets.view.unifiedui.theme.UnifiedTheme
import com.google.gson.JsonObject
@@ -36,7 +37,7 @@ import java.util.concurrent.Executor
// TODO: move to com.glia.widgets.snapshotutils after CallState refactored
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
internal interface SnapshotCallView : SnapshotContent, SnapshotTheme, SnapshotActivityWindow,
- SnapshotProviders, SnapshotSchedulers, SnapshotLottie {
+ SnapshotProviders, SnapshotSchedulers, SnapshotLottie, SnapshotThemeConfiguration {
data class Mock(
val activityMock: SnapshotActivityWindow.Mock,
@@ -58,10 +59,6 @@ internal interface SnapshotCallView : SnapshotContent, SnapshotTheme, SnapshotAc
whenever(controllerFactoryMock.callController).thenReturn(callControllerMock)
Dependencies.controllerFactory = controllerFactoryMock
-// setOnEndListener {
-// Dependencies.controllerFactory = null
-// }
-
return Mock(activityMock, schedulersMock, controllerFactoryMock, callControllerMock)
}
@@ -73,17 +70,14 @@ internal interface SnapshotCallView : SnapshotContent, SnapshotTheme, SnapshotAc
fun setupView(
callState: CallState? = null,
- companyName: String? = "SnapshotCall Tests",
executor: Executor? = Executor(Runnable::run),
unifiedTheme: UnifiedTheme? = null,
uiTheme: UiTheme? = null,
callViewCallback: ((CallContract.View, callState: CallState?) -> Unit)? = null
): ViewData {
+ setGlobalThemes(uiTheme, unifiedTheme)
val mock = callViewMock()
- unifiedTheme?.let { Dependencies.gliaThemeManager.theme = it }
- Dependencies.sdkConfigurationManager.companyName = companyName
-
val callViewCaptor: KArgumentCaptor = argumentCaptor()
val callActivityBinding = CallActivityBinding.inflate(layoutInflater)
@@ -91,19 +85,11 @@ internal interface SnapshotCallView : SnapshotContent, SnapshotTheme, SnapshotAc
val callView = callActivityBinding.callView
verify(mock.callControllerMock).setView(callViewCaptor.capture())
- callView.setUiTheme(uiTheme)
-
callView.executor = executor
val callViewContract = callViewCaptor.lastValue
callState?.let { callViewContract.emitState(it) }
callViewCallback?.invoke(callViewContract, callState)
-
- setOnEndListener {
- Dependencies.gliaThemeManager.theme = null
- Dependencies.sdkConfigurationManager.companyName = null
- }
-
return ViewData(root, callView, mock)
}
@@ -160,6 +146,7 @@ internal interface SnapshotCallView : SnapshotContent, SnapshotTheme, SnapshotAc
) = mock().also {
whenever(it.status).thenReturn(status)
}
+
fun video(
status: Media.Status = Media.Status.PLAYING,
title: String,
@@ -175,7 +162,7 @@ internal interface SnapshotCallView : SnapshotContent, SnapshotTheme, SnapshotAc
title: String,
backgroundColor: Int = Color.BLACK,
textColor: Int = Color.WHITE
- ) = object:VideoView(context) {
+ ) = object : VideoView(context) {
init {
addView(
TextView(context).apply {
@@ -203,14 +190,12 @@ internal interface SnapshotCallView : SnapshotContent, SnapshotTheme, SnapshotAc
fun CallState.initCall(
companyName: String = "Snapshot tests",
- queueIds: List = listOf("queueId"),
- visitorContextAssetId: String = "visitorContextAssetId",
requestedMediaType: Engagement.MediaType = Engagement.MediaType.AUDIO,
visitorMediaState: VisitorMediaState? = null,
showFlipVisitorCameraButton: Boolean = false,
isOnHold: Boolean = false
): CallState = this
- .initCall(companyName, queueIds, visitorContextAssetId, requestedMediaType)
+ .initCall(requestedMediaType)
.visitorMediaStateChanged(visitorMediaState)
.setOnHold(isOnHold)
.landscapeControlsVisibleChanged(false)
diff --git a/widgetssdk/src/testSnapshot/java/com/glia/widgets/chat/adapter/holder/OperatorStatusViewHolderSnapshotTest.kt b/widgetssdk/src/testSnapshot/java/com/glia/widgets/chat/adapter/holder/OperatorStatusViewHolderSnapshotTest.kt
index 5088cd390..b96f0c440 100644
--- a/widgetssdk/src/testSnapshot/java/com/glia/widgets/chat/adapter/holder/OperatorStatusViewHolderSnapshotTest.kt
+++ b/widgetssdk/src/testSnapshot/java/com/glia/widgets/chat/adapter/holder/OperatorStatusViewHolderSnapshotTest.kt
@@ -20,7 +20,6 @@ class OperatorStatusViewHolderSnapshotTest : SnapshotTest(
// MARK: Connected
private fun connectedItem() = OperatorStatusItem.Connected(
- "Snapshot Company",
"Screen Shot",
"https://test.url"
)
@@ -88,9 +87,7 @@ class OperatorStatusViewHolderSnapshotTest : SnapshotTest(
// MARK: In Queue
- private fun inQueueItem() = OperatorStatusItem.InQueue(
- "Snapshot Company"
- )
+ private fun inQueueItem() = OperatorStatusItem.InQueue
@Test
fun inQueue() {
@@ -144,7 +141,6 @@ class OperatorStatusViewHolderSnapshotTest : SnapshotTest(
// MARK: In Queue
private fun joinedItem() = OperatorStatusItem.Joined(
- "Snapshot Company",
"Screen Shot",
null
)
diff --git a/widgetssdk/src/testSnapshot/java/com/glia/widgets/dialog/VisitorCodeDialogTest.kt b/widgetssdk/src/testSnapshot/java/com/glia/widgets/dialog/VisitorCodeDialogTest.kt
index 79c9041e8..22233b97c 100644
--- a/widgetssdk/src/testSnapshot/java/com/glia/widgets/dialog/VisitorCodeDialogTest.kt
+++ b/widgetssdk/src/testSnapshot/java/com/glia/widgets/dialog/VisitorCodeDialogTest.kt
@@ -4,10 +4,10 @@ import com.glia.androidsdk.omnibrowse.VisitorCode
import com.glia.widgets.R
import com.glia.widgets.SnapshotTest
import com.glia.widgets.UiTheme
-import com.glia.widgets.core.configuration.GliaSdkConfigurationManager
import com.glia.widgets.di.ControllerFactory
import com.glia.widgets.di.Dependencies
import com.glia.widgets.snapshotutils.SnapshotProviders
+import com.glia.widgets.snapshotutils.SnapshotThemeConfiguration
import com.glia.widgets.view.VisitorCodeView
import com.glia.widgets.view.unifiedui.theme.UnifiedTheme
import com.google.gson.JsonObject
@@ -18,7 +18,7 @@ import java.util.concurrent.Executor
class VisitorCodeDialogTest : SnapshotTest(
renderingMode = fullWidthRenderMode
-), SnapshotProviders {
+), SnapshotProviders, SnapshotThemeConfiguration {
// MARK: Show visitor code
@@ -220,25 +220,15 @@ class VisitorCodeDialogTest : SnapshotTest(
unifiedTheme: UnifiedTheme? = null,
executor: Executor? = Executor(Runnable::run)
): VisitorCodeView {
+ setGlobalThemes(uiTheme, unifiedTheme)
localeProviderMock()
resourceProviderMock()
- unifiedTheme?.let { Dependencies.gliaThemeManager.theme = it }
- val configurationManager = GliaSdkConfigurationManager().also {
- it.uiTheme = uiTheme
- }
val controllerFactoryMock: ControllerFactory = mock().also {
whenever(it.visitorCodeController).thenReturn(mock())
}
- Dependencies.sdkConfigurationManager = configurationManager
Dependencies.controllerFactory = controllerFactoryMock
- setOnEndListener {
- Dependencies.gliaThemeManager.theme = null
- Dependencies.sdkConfigurationManager = GliaSdkConfigurationManager()
-// Dependencies.controllerFactory = null
- }
-
return VisitorCodeView(context, executor).apply {
notifySetupComplete()
}
diff --git a/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotActivityWindow.kt b/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotActivityWindow.kt
index d7db3eb02..24dc164fb 100644
--- a/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotActivityWindow.kt
+++ b/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotActivityWindow.kt
@@ -26,14 +26,14 @@ interface SnapshotActivityWindow: SnapshotTestLifecycle {
val windowMock = mock()
whenever(activityMock.window).thenReturn(windowMock)
whenever(windowMock.statusBarColor).thenReturn(statusBarColor)
- mockkStatic("com.glia.widgets.helper.ContextExtensionsKt")
+ mockkStatic("com.glia.widgets.helper.ContextExtensions")
every { any().requireActivity() } returns activityMock
every { any().asActivity() } returns activityMock
mockkStatic("com.glia.widgets.helper.Insets")
every { any().hideKeyboard() } returns Unit
setOnEndListener {
- unmockkStatic("com.glia.widgets.helper.ContextExtensionsKt")
+ unmockkStatic("com.glia.widgets.helper.ContextExtensions")
unmockkStatic("com.glia.widgets.helper.Insets")
}
diff --git a/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotChatView.kt b/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotChatView.kt
index 857e6e6a1..4b956d88c 100644
--- a/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotChatView.kt
+++ b/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotChatView.kt
@@ -3,7 +3,6 @@ package com.glia.widgets.snapshotutils
import android.view.View
import android.widget.EditText
import androidx.annotation.DrawableRes
-import androidx.core.view.isVisible
import com.glia.widgets.R
import com.glia.widgets.UiTheme
import com.glia.widgets.chat.ChatContract
@@ -24,7 +23,7 @@ import org.mockito.kotlin.whenever
import java.util.concurrent.Executor
internal interface SnapshotChatView : SnapshotContent, SnapshotTheme, SnapshotActivityWindow, SnapshotProviders,
- SnapshotGetImageFile, SnapshotSchedulers, SnapshotAttachment, SnapshotPicasso, SnapshotLottie {
+ SnapshotGetImageFile, SnapshotSchedulers, SnapshotAttachment, SnapshotPicasso, SnapshotLottie, SnapshotThemeConfiguration {
data class Mock(
val activityMock: SnapshotActivityWindow.Mock,
@@ -67,10 +66,11 @@ internal interface SnapshotChatView : SnapshotContent, SnapshotTheme, SnapshotAc
unifiedTheme: UnifiedTheme? = null,
uiTheme: UiTheme? = null
): ViewData {
+ setGlobalThemes(uiTheme, unifiedTheme)
+
val mock = chatViewMock()
imageResources?.let { picassoMock(imageResources) }
- unifiedTheme?.let { Dependencies.gliaThemeManager.theme = it }
val chatViewCaptor: KArgumentCaptor = argumentCaptor()
val chatActivityBinding = ChatActivityBinding.inflate(layoutInflater)
@@ -78,8 +78,6 @@ internal interface SnapshotChatView : SnapshotContent, SnapshotTheme, SnapshotAc
val chatView = chatActivityBinding.chatView
verify(mock.chatControllerMock).setView(chatViewCaptor.capture())
- chatView.setUiTheme(uiTheme)
-
chatView.executor = executor
val chatViewCallback = chatViewCaptor.lastValue
@@ -88,10 +86,6 @@ internal interface SnapshotChatView : SnapshotContent, SnapshotTheme, SnapshotAc
fileAttachments?.let { chatViewCallback.emitUploadAttachments(it) }
message?.let { chatView.findViewById(R.id.chat_edit_text).setText(it) }
- setOnEndListener {
- Dependencies.gliaThemeManager.theme = null
- }
-
return ViewData(root, chatView, mock)
}
diff --git a/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotTheme.kt b/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotTheme.kt
index c8cdafba5..463d9d0c3 100644
--- a/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotTheme.kt
+++ b/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotTheme.kt
@@ -90,7 +90,6 @@ internal interface SnapshotTheme : SnapshotContent {
gliaAlertDialogButtonUseVerticalAlignment: Boolean? = true
): UiTheme {
return UiTheme(
- appBarTitle = "Snapshot Test",
brandPrimaryColor = brandPrimaryColor,
baseLightColor = baseLightColor,
baseDarkColor = baseDarkColor,
diff --git a/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotThemeConfiguration.kt b/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotThemeConfiguration.kt
new file mode 100644
index 000000000..7bf5432e2
--- /dev/null
+++ b/widgetssdk/src/testSnapshot/java/com/glia/widgets/snapshotutils/SnapshotThemeConfiguration.kt
@@ -0,0 +1,24 @@
+package com.glia.widgets.snapshotutils
+
+import com.glia.widgets.GliaWidgetsConfig
+import com.glia.widgets.UiTheme
+import com.glia.widgets.di.Dependencies
+import com.glia.widgets.view.unifiedui.theme.UnifiedTheme
+import io.mockk.mockk
+
+internal interface SnapshotThemeConfiguration : SnapshotTestLifecycle {
+
+ fun setGlobalThemes(uiTheme: UiTheme?, unifiedTheme: UnifiedTheme?) {
+ Dependencies.repositoryFactory = mockk(relaxed = true)
+
+ Dependencies.configurationManager.applyConfiguration(GliaWidgetsConfig.Builder().setUiTheme(uiTheme).build())
+
+ Dependencies.gliaThemeManager.theme = unifiedTheme
+
+ setOnEndListener {
+ Dependencies.configurationManager.applyConfiguration(GliaWidgetsConfig.Builder().build())
+ Dependencies.gliaThemeManager.theme = null
+ }
+ }
+
+}
diff --git a/widgetssdk/src/testSnapshot/java/com/glia/widgets/view/head/ChatHeadViewSnapshotTest.kt b/widgetssdk/src/testSnapshot/java/com/glia/widgets/view/head/ChatHeadViewSnapshotTest.kt
index 5fc30c4bc..216bf6893 100644
--- a/widgetssdk/src/testSnapshot/java/com/glia/widgets/view/head/ChatHeadViewSnapshotTest.kt
+++ b/widgetssdk/src/testSnapshot/java/com/glia/widgets/view/head/ChatHeadViewSnapshotTest.kt
@@ -4,7 +4,6 @@ import com.glia.widgets.R
import com.glia.widgets.SnapshotTest
import com.glia.widgets.UiTheme
import com.glia.widgets.core.callvisualizer.domain.IsCallVisualizerScreenSharingUseCase
-import com.glia.widgets.core.configuration.EngagementConfiguration
import com.glia.widgets.di.ControllerFactory
import com.glia.widgets.di.Dependencies
import com.glia.widgets.di.UseCaseFactory
@@ -13,6 +12,7 @@ import com.glia.widgets.snapshotutils.SnapshotChatView
import com.glia.widgets.snapshotutils.SnapshotLottie
import com.glia.widgets.snapshotutils.SnapshotPicasso
import com.glia.widgets.snapshotutils.SnapshotProviders
+import com.glia.widgets.snapshotutils.SnapshotThemeConfiguration
import com.glia.widgets.view.configuration.ChatHeadConfiguration
import com.glia.widgets.view.unifiedui.theme.UnifiedTheme
import org.junit.Test
@@ -22,15 +22,13 @@ import java.util.concurrent.Executor
class ChatHeadViewSnapshotTest : SnapshotTest(
maxPercentDifference = 0.01
-), SnapshotChatView, SnapshotProviders, SnapshotLottie, SnapshotPicasso {
+), SnapshotChatView, SnapshotProviders, SnapshotLottie, SnapshotPicasso, SnapshotThemeConfiguration {
// MARK: Default state
@Test
fun defaultState() {
- snapshot(
- setupView()
- )
+ snapshot(setupView())
}
// MARK: Operator Image
@@ -305,7 +303,6 @@ class ChatHeadViewSnapshotTest : SnapshotTest(
unifiedTheme: UnifiedTheme? = null,
uiTheme: UiTheme = UiTheme(),
executor: Executor? = Executor(Runnable::run),
- sdkConfiguration: EngagementConfiguration? = sdkConfiguration(uiTheme),
isCallVisualizerScreenSharingUseCase: Boolean = false
): ChatHeadView {
lottieMock()
@@ -326,24 +323,13 @@ class ChatHeadViewSnapshotTest : SnapshotTest(
whenever(useCaseFactoryMock.isCurrentEngagementCallVisualizer).thenReturn(isCurrentEngagementCallVisualizerUseCaseMock)
Dependencies.useCaseFactory = useCaseFactoryMock
- unifiedTheme?.let { Dependencies.gliaThemeManager.theme = it }
-
- setOnEndListener {
- Dependencies.gliaThemeManager.theme = null
- }
+ setGlobalThemes(uiTheme.copy(chatHeadConfiguration = chatHeadConfiguration()), unifiedTheme)
return ChatHeadView(context).also {
it.executor = executor
- it.updateConfiguration(uiTheme, sdkConfiguration)
}
}
- private fun sdkConfiguration(
- uiTheme: UiTheme = UiTheme(),
- chatHeadConfiguration: ChatHeadConfiguration = chatHeadConfiguration()
- ) = mock().also {
- whenever(it.runTimeTheme).thenReturn(uiTheme.copy(chatHeadConfiguration = chatHeadConfiguration))
- }
private fun chatHeadConfiguration() = ChatHeadConfiguration.Builder()
.operatorPlaceholderBackgroundColor(R.color.glia_brand_primary_color)
.operatorPlaceholderIcon(R.drawable.ic_person)