diff --git a/widgetssdk/src/main/java/com/glia/widgets/chat/AttachmentPopup.kt b/widgetssdk/src/main/java/com/glia/widgets/chat/AttachmentPopup.kt index 25929f43f..941f3762c 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/chat/AttachmentPopup.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/chat/AttachmentPopup.kt @@ -12,18 +12,19 @@ import com.glia.widgets.databinding.ChatAttachmentPopupBinding import com.glia.widgets.helper.getColorCompat import com.glia.widgets.helper.setLocaleText import com.glia.widgets.helper.setTintCompat +import com.glia.widgets.helper.wrapWithMaterialThemeOverlay import com.glia.widgets.view.unifiedui.applyImageColorTheme import com.glia.widgets.view.unifiedui.applyTextTheme import com.glia.widgets.view.unifiedui.theme.chat.AttachmentsPopupTheme internal class AttachmentPopup( - anchor: View, + context: Context, private val theme: AttachmentsPopupTheme?, private val popupWindowFunc: (LinearLayout) -> PopupWindow = ::popupWindow ) { - private val margin by lazy { anchor.context.resources.getDimensionPixelSize(R.dimen.glia_chat_attachment_menu_margin) } - private val binding: ChatAttachmentPopupBinding by lazy { bindLayout(anchor.context) } + private val margin by lazy { context.resources.getDimensionPixelSize(R.dimen.glia_chat_attachment_menu_margin) } + private val binding: ChatAttachmentPopupBinding by lazy { bindLayout(context.wrapWithMaterialThemeOverlay()) } private val popupWindow: PopupWindow by lazy { createPopupMenu() } private fun createPopupMenu(): PopupWindow { diff --git a/widgetssdk/src/main/java/com/glia/widgets/chat/ChatView.kt b/widgetssdk/src/main/java/com/glia/widgets/chat/ChatView.kt index e301099de..6dd413f12 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/chat/ChatView.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/chat/ChatView.kt @@ -168,7 +168,7 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In private var binding by Delegates.notNull() private val attachmentPopup by lazy { AttachmentPopup( - binding.chatMessageLayout, Dependencies.gliaThemeManager.theme?.chatTheme?.attachmentsPopup + context, Dependencies.gliaThemeManager.theme?.chatTheme?.attachmentsPopup ) } @@ -718,7 +718,7 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In private fun setupAddAttachmentButton() { binding.addAttachmentButton.setOnClickListener { - attachmentPopup.show(binding.chatMessageLayout, { + attachmentPopup.show(binding.addAttachmentButton, { getContentLauncher?.launch(arrayOf(Constants.MIME_TYPE_IMAGES)) }, { controller?.onTakePhotoClicked() @@ -851,7 +851,7 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In binding.sendButton.applyButtonTheme(inputTheme.sendButton) binding.addAttachmentButton.applyButtonTheme(inputTheme.mediaButton) binding.dividerView.applyColorTheme(inputTheme.divider) - binding.chatMessageLayout.applyLayerTheme(inputTheme.background) + binding.messageInputBackground.applyLayerTheme(inputTheme.background) binding.chatEditText.applyTextTheme(textTheme = inputTheme.text, withAlignment = false) inputTheme.placeholder?.textColor?.primaryColor?.also(binding.chatEditText::setHintTextColor) } @@ -872,7 +872,10 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In binding.apply { chatRecyclerView.updatePadding(bottom = dialogHeight) chatRecyclerView.scrollBy(0, dialogHeight) - chatMessageLayout.isGone = true + messageInputBackground.isGone = true + chatEditText.isGone = true + addAttachmentButton.isGone = true + sendButton.isGone = true operatorTypingAnimationView.isGone = true } } 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 d4462e38d..3b324a947 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageView.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageView.kt @@ -77,7 +77,7 @@ internal class MessageView( private var theme: UiTheme by Delegates.notNull() private val attachmentPopup by lazy { - AttachmentPopup(addAttachmentButton, unifiedTheme?.pickMediaTheme) + AttachmentPopup(context, unifiedTheme?.pickMediaTheme) } val messageTitleTop: Int get() = messageTitle.top diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/snackbar/SnackBarDelegate.kt b/widgetssdk/src/main/java/com/glia/widgets/view/snackbar/SnackBarDelegate.kt index ee41eeed3..1985ff13f 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/view/snackbar/SnackBarDelegate.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/view/snackbar/SnackBarDelegate.kt @@ -88,7 +88,7 @@ internal class CommonSnackBarDelegate(activity: Activity, titleStringKey: Int, l @VisibleForTesting internal class ChatActivitySnackBarDelegate(activity: ChatActivity, titleStringKey: Int, localeProvider: LocaleProvider, unifiedTheme: UnifiedTheme?) : SnackBarDelegate(activity.findViewById(R.id.chat_view), titleStringKey, localeProvider, unifiedTheme?.snackBarTheme) { - override val anchorViewId: Int = R.id.chat_message_layout + override val anchorViewId: Int = R.id.message_input_background } @VisibleForTesting diff --git a/widgetssdk/src/main/res/layout/chat_view.xml b/widgetssdk/src/main/res/layout/chat_view.xml index f604e439b..78a13cb51 100644 --- a/widgetssdk/src/main/res/layout/chat_view.xml +++ b/widgetssdk/src/main/res/layout/chat_view.xml @@ -103,26 +103,29 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="vertical" - app:layout_constraintBottom_toTopOf="@+id/chat_message_layout" + app:layout_constraintBottom_toTopOf="@+id/chat_edit_text" app:layout_constraintHeight_max="216dp" app:layout_constraintTop_toBottomOf="@+id/divider_view" tools:itemCount="6" tools:listitem="@layout/chat_attachment_uploaded_item" /> - + + tools:text="@string/chat_input_placeholder"/> - + - - + diff --git a/widgetssdk/src/test/java/com/glia/widgets/view/snackbar/SnackBarDelegateTest.kt b/widgetssdk/src/test/java/com/glia/widgets/view/snackbar/SnackBarDelegateTest.kt index ec2b58cff..97093b88f 100644 --- a/widgetssdk/src/test/java/com/glia/widgets/view/snackbar/SnackBarDelegateTest.kt +++ b/widgetssdk/src/test/java/com/glia/widgets/view/snackbar/SnackBarDelegateTest.kt @@ -80,7 +80,7 @@ class SnackBarDelegateTest { fun `anchorViewId returns corresponding ids when chat or call activity is passed`() { CommonSnackBarDelegate(commonActivity, titleStringKey, mock(), mock()).apply { assertNull(anchorViewId) } CallActivitySnackBarDelegate(callActivity, titleStringKey, mock(), mock()).apply { assertEquals(R.id.buttons_layout_bg, anchorViewId) } - ChatActivitySnackBarDelegate(chatActivity, titleStringKey, mock(), mock()).apply { assertEquals(R.id.chat_message_layout, anchorViewId) } + ChatActivitySnackBarDelegate(chatActivity, titleStringKey, mock(), mock()).apply { assertEquals(R.id.message_input_background, anchorViewId) } } @Test diff --git a/widgetssdk/src/testSnapshot/java/com/glia/widgets/chat/AttachmentPopupSnapshotTest.kt b/widgetssdk/src/testSnapshot/java/com/glia/widgets/chat/AttachmentPopupSnapshotTest.kt index 3c6be35e2..19ff93ab7 100644 --- a/widgetssdk/src/testSnapshot/java/com/glia/widgets/chat/AttachmentPopupSnapshotTest.kt +++ b/widgetssdk/src/testSnapshot/java/com/glia/widgets/chat/AttachmentPopupSnapshotTest.kt @@ -55,16 +55,15 @@ class AttachmentPopupSnapshotTest : SnapshotTest(), SnapshotTheme, SnapshotProvi ) : AttachmentPopup { localeProviderMock() - val anchor = LinearLayout(context) return AttachmentPopup( - anchor, + context, unifiedTheme ) { it.layoutParams = LinearLayout.LayoutParams(650, LinearLayout.LayoutParams.WRAP_CONTENT) viewCallback(it) mock() }.apply { - show(anchor, mock(), mock(), mock()) + show(View(context), mock(), mock(), mock()) } } }