From 463324b84423f3565685b6443a35aeb866e83b01 Mon Sep 17 00:00:00 2001 From: Davit Dolmazyan Date: Tue, 10 Sep 2024 13:02:10 +0300 Subject: [PATCH] Edge to Edge support - All screens now edge to edge enforced - Remove the status bar color setting, since it replaced by padding - Minor UI fixes MOB 3554 --- .../java/com/glia/exampleapp/MainFragment.kt | 9 ++- app/src/main/res/layout/main_fragment.xml | 7 ++- .../main/res/raw/sample_unified_config.json | 45 ++++++++------ .../widgets/base/FadeTransitionActivity.kt | 45 ++++++++++---- .../com/glia/widgets/call/CallActivity.java | 6 +- .../java/com/glia/widgets/call/CallView.kt | 61 +++++++------------ .../EndScreenSharingActivity.kt | 1 - .../callvisualizer/EndScreenSharingView.kt | 26 ++------ .../com/glia/widgets/chat/ChatActivity.java | 2 + .../java/com/glia/widgets/chat/ChatView.kt | 36 +++-------- .../filepreview/ui/FilePreviewActivity.kt | 7 ++- .../java/com/glia/widgets/helper/Insets.kt | 12 +++- .../com/glia/widgets/helper/ViewExtensions.kt | 22 +------ .../messagecenter/MessageCenterView.kt | 35 +---------- .../glia/widgets/survey/SurveyActivity.java | 11 ++-- .../com/glia/widgets/survey/SurveyView.kt | 10 +++ .../glia/widgets/view/header/AppBarView.kt | 24 +++----- .../widgets/webbrowser/WebBrowserActivity.kt | 2 +- .../glia/widgets/webbrowser/WebBrowserView.kt | 24 +------- widgetssdk/src/main/res/layout/app_bar.xml | 19 +++--- .../main/res/layout/message_center_view.xml | 1 - .../src/main/res/values-land/dimens.xml | 2 +- widgetssdk/src/main/res/values/themes.xml | 22 ++----- ...apshotTest_audioCallStartedWithUiTheme.png | 4 +- ...iewAudioSnapshotTest_onHoldWithUiTheme.png | 4 +- ...pshotTest_operatorConnectedWithUiTheme.png | 4 +- ...iewVideoSnapshotTest_onHoldWithUiTheme.png | 4 +- ...pshotTest_operatorConnectedWithUiTheme.png | 4 +- ...otTest_video1WayCallStartedWithUiTheme.png | 4 +- ...otTest_video2WayCallStartedWithUiTheme.png | 4 +- ...est_video2WayWithFlipButtonWithUiTheme.png | 4 +- ...ViewQuickReplySnapshotTest_withUiTheme.png | 4 +- ...SnapshotTest_attachmentListWithUiTheme.png | 4 +- ...hotTest_attachmentListWithUnifiedTheme.png | 4 +- ...otTest_failedAttachmentListWithUiTheme.png | 4 +- ...ewSnapshotTest_transferringWithUiTheme.png | 4 +- ...SnapshotTest_deliveredLabelWithUiTheme.png | 4 +- ...temsSnapshotTest_errorLabelWithUiTheme.png | 4 +- ...sSnapshotTest_withoutLabelsWithUiTheme.png | 4 +- .../snapshotutils/SnapshotActivityWindow.kt | 4 +- 40 files changed, 207 insertions(+), 290 deletions(-) diff --git a/app/src/main/java/com/glia/exampleapp/MainFragment.kt b/app/src/main/java/com/glia/exampleapp/MainFragment.kt index 6e291d0dd..dd6d69d34 100644 --- a/app/src/main/java/com/glia/exampleapp/MainFragment.kt +++ b/app/src/main/java/com/glia/exampleapp/MainFragment.kt @@ -517,7 +517,7 @@ class MainFragment : Fragment() { GliaWidgets.init( createDefaultConfig( context = requireActivity().applicationContext, -// uiJsonRemoteConfig = UnifiedUiConfigurationLoader.fetchLocalGlobalColors(requireContext()), +// uiJsonRemoteConfig = UnifiedUiConfigurationLoader.fetchRemoteConfiguration(), // runtimeConfig = createSampleRuntimeConfig(), // region = "us" ) @@ -526,14 +526,13 @@ class MainFragment : Fragment() { setupAuthButtonsVisibility() listenForCallVisualizerEngagements() - view?.post { - initMenu() - } + view?.post { initMenu() } } private fun createSampleRuntimeConfig(): UiTheme = UiTheme( gvaQuickReplyTextColor = android.R.color.holo_green_dark, - gvaQuickReplyStrokeColor = android.R.color.holo_green_dark + gvaQuickReplyStrokeColor = android.R.color.holo_green_dark, + brandPrimaryColor = android.R.color.holo_green_dark ) private fun prepareAuthentication() { diff --git a/app/src/main/res/layout/main_fragment.xml b/app/src/main/res/layout/main_fragment.xml index 09f6b2328..31aaf060d 100644 --- a/app/src/main/res/layout/main_fragment.xml +++ b/app/src/main/res/layout/main_fragment.xml @@ -24,15 +24,20 @@ diff --git a/app/src/main/res/raw/sample_unified_config.json b/app/src/main/res/raw/sample_unified_config.json index f3e9297d4..841ec0b52 100644 --- a/app/src/main/res/raw/sample_unified_config.json +++ b/app/src/main/res/raw/sample_unified_config.json @@ -1134,9 +1134,10 @@ }, "borderWidth": 2, "color": { - "type": "fill", + "type": "gradient", "value": [ - "#000000" + "#fdd42b", + "#ff0000" ] }, "cornerRadius": 8 @@ -1187,9 +1188,10 @@ }, "borderWidth": 2, "color": { - "type": "fill", + "type": "gradient", "value": [ - "#f9d12b" + "#fdd42b", + "#ff0000" ] }, "cornerRadius": 8 @@ -1962,9 +1964,10 @@ }, "borderWidth": 2, "color": { - "type": "fill", + "type": "gradient", "value": [ - "#fdd42b" + "#fdd42b", + "#ff0000" ] }, "cornerRadius": 8 @@ -3990,9 +3993,10 @@ }, "borderWidth": 2, "color": { - "type": "fill", + "type": "gradient", "value": [ - "#fdd42b" + "#fdd42b", + "#ff0000" ] }, "cornerRadius": 8 @@ -4413,9 +4417,10 @@ }, "borderWidth": 2, "color": { - "type": "fill", + "type": "gradient", "value": [ - "#000000" + "#fdd42b", + "#ff0000" ] }, "cornerRadius": 8 @@ -4466,9 +4471,10 @@ }, "borderWidth": 2, "color": { - "type": "fill", + "type": "gradient", "value": [ - "#f9d12b" + "#fdd42b", + "#ff0000" ] }, "cornerRadius": 8 @@ -4790,9 +4796,10 @@ }, "borderWidth": 2, "color": { - "type": "fill", + "type": "gradient", "value": [ - "#000000" + "#fdd42b", + "#ff0000" ] }, "cornerRadius": 8 @@ -4843,9 +4850,10 @@ }, "borderWidth": 2, "color": { - "type": "fill", + "type": "gradient", "value": [ - "#f9d12b" + "#fdd42b", + "#ff0000" ] }, "cornerRadius": 8 @@ -5212,9 +5220,10 @@ }, "borderWidth": 2, "color": { - "type": "fill", + "type": "gradient", "value": [ - "#fdd42b" + "#fdd42b", + "#ff0000" ] }, "cornerRadius": 8 diff --git a/widgetssdk/src/main/java/com/glia/widgets/base/FadeTransitionActivity.kt b/widgetssdk/src/main/java/com/glia/widgets/base/FadeTransitionActivity.kt index 216d4aa62..43a601686 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/base/FadeTransitionActivity.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/base/FadeTransitionActivity.kt @@ -1,10 +1,13 @@ package com.glia.widgets.base import android.content.Intent +import android.os.Build import android.os.Bundle +import androidx.activity.enableEdgeToEdge +import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity -import com.glia.androidsdk.Glia import com.glia.widgets.di.Dependencies +import com.glia.widgets.helper.insetsControllerCompat import com.glia.widgets.locale.LocaleString import io.reactivex.rxjava3.disposables.Disposable @@ -16,30 +19,50 @@ open class FadeTransitionActivity : AppCompatActivity() { private var disposable: Disposable? = null private val localeProvider = Dependencies.localeProvider - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) + + @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) + private fun overrideAnimation() { + overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, android.R.anim.fade_in, android.R.anim.fade_out) + overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, android.R.anim.fade_in, android.R.anim.fade_out) } - override fun finish() { - super.finish() - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) + private fun overrideAnimationCompat() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + overrideAnimation() + return + } + + overrideAnimationApi33() + } + + @Suppress("DEPRECATION") + private fun overrideAnimationApi33() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + enableEdgeToEdge() + window.insetsControllerCompat.isAppearanceLightStatusBars = false + overrideAnimationCompat() + super.onCreate(savedInstanceState) } override fun finishAndRemoveTask() { super.finishAndRemoveTask() - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) + overrideAnimationApi33() disposable?.dispose() } override fun startActivity(intent: Intent?) { super.startActivity(intent) - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) + overrideAnimationApi33() } override fun startActivity(intent: Intent?, options: Bundle?) { super.startActivity(intent, options) - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) + overrideAnimationApi33() } fun setTitle(locale: LocaleString?) { @@ -56,7 +79,7 @@ open class FadeTransitionActivity : AppCompatActivity() { .subscribe( { super.setTitle(it) }, { /* no-op */ } - ) + ) } } diff --git a/widgetssdk/src/main/java/com/glia/widgets/call/CallActivity.java b/widgetssdk/src/main/java/com/glia/widgets/call/CallActivity.java index 6f63240b5..974beb585 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/call/CallActivity.java +++ b/widgetssdk/src/main/java/com/glia/widgets/call/CallActivity.java @@ -7,7 +7,6 @@ import androidx.annotation.Nullable; import com.glia.widgets.GliaWidgets; -import com.glia.widgets.locale.LocaleString; import com.glia.widgets.R; import com.glia.widgets.base.FadeTransitionActivity; import com.glia.widgets.chat.ChatActivity; @@ -15,6 +14,7 @@ import com.glia.widgets.di.Dependencies; import com.glia.widgets.helper.Logger; import com.glia.widgets.helper.Utils; +import com.glia.widgets.locale.LocaleString; import com.glia.widgets.webbrowser.WebBrowserActivity; import java.util.ArrayList; @@ -161,9 +161,9 @@ private void navigateToWebBrowser(LocaleString title, String url) { /** * Creates and fills out Intent for starting CallActivity - * @deprecated use {@link #getIntent(Context, EngagementConfiguration)} since 1.8.2 + * @deprecated use {@link #getIntent(Context, CallConfiguration)} since 1.8.2 * @param applicationContext - application context - * @param sdkConfiguration - widgets sdk configuration + * @param engagementConfiguration - widgets sdk configuration * @param mediaType - media type that should be started (in case media engagement not ongoing) * @return Intent for starting CallActivity */ diff --git a/widgetssdk/src/main/java/com/glia/widgets/call/CallView.kt b/widgetssdk/src/main/java/com/glia/widgets/call/CallView.kt index 8d50daf91..7653629a0 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/call/CallView.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/call/CallView.kt @@ -7,6 +7,7 @@ import android.util.AttributeSet import android.view.Gravity import android.view.LayoutInflater import android.view.View +import android.view.View.OnClickListener import android.widget.FrameLayout import android.widget.TextView import android.widget.Toast @@ -23,7 +24,6 @@ import com.glia.androidsdk.comms.MediaState import com.glia.androidsdk.comms.VideoView import com.glia.androidsdk.screensharing.ScreenSharing import com.glia.widgets.Constants -import com.glia.widgets.locale.LocaleString import com.glia.widgets.R import com.glia.widgets.UiTheme import com.glia.widgets.UiTheme.UiThemeBuilder @@ -35,9 +35,9 @@ import com.glia.widgets.databinding.CallButtonsLayoutBinding import com.glia.widgets.databinding.CallViewBinding import com.glia.widgets.di.Dependencies import com.glia.widgets.helper.Logger +import com.glia.widgets.helper.SimpleWindowInsetsAndAnimationHandler import com.glia.widgets.helper.TAG import com.glia.widgets.helper.Utils -import com.glia.widgets.helper.changeStatusBarColor import com.glia.widgets.helper.getColorCompat import com.glia.widgets.helper.getColorStateListCompat import com.glia.widgets.helper.getFontCompat @@ -45,11 +45,12 @@ import com.glia.widgets.helper.getFullHybridTheme import com.glia.widgets.helper.hideKeyboard import com.glia.widgets.helper.insetsController import com.glia.widgets.helper.requireActivity -import com.glia.widgets.helper.showToast import com.glia.widgets.helper.setContentDescription import com.glia.widgets.helper.setLocaleContentDescription import com.glia.widgets.helper.setLocaleHint import com.glia.widgets.helper.setLocaleText +import com.glia.widgets.helper.showToast +import com.glia.widgets.locale.LocaleString import com.glia.widgets.locale.StringKey import com.glia.widgets.locale.StringKeyPair import com.glia.widgets.view.Dialogs @@ -71,6 +72,9 @@ import com.google.android.material.transition.SlideDistanceProvider import java.util.concurrent.Executor import kotlin.properties.Delegates +private const val CONTROLS_ALPHA_SEMI_TRANSPARENT = 0.9f +private const val CONTROLS_ALPHA = 1f + internal class CallView( context: Context, attrs: AttributeSet?, @@ -133,7 +137,6 @@ internal class CallView( private var onNavigateToChatListener: OnNavigateToChatListener? = null private var onNavigateToWebBrowserListener: OnNavigateToWebBrowserListener? = null private var onTitleUpdatedListener: OnTitleUpdatedListener? = null - private var defaultStatusBarColor: Int? = null private var operatorVideoView: VideoView? = null @@ -150,6 +153,7 @@ internal class CallView( setupViewAppearance() setupViewActions() setupControllers() + SimpleWindowInsetsAndAnimationHandler(this, appBarOrToolBar = appBar) } private fun setupViewActions() { @@ -229,7 +233,8 @@ internal class CallView( DialogState.OverlayPermission -> post { showOverlayPermissionsDialog() } DialogState.EndEngagement -> post { showEndEngagementDialog() } DialogState.Confirmation -> post { callController?.onLiveObservationDialogRequested() } - else -> { /* noop */ } + else -> { /* noop */ + } } } } @@ -381,9 +386,7 @@ internal class CallView( animateControls(fadeIn = false) } appBar.isVisible = callState.landscapeLayoutControlsVisible - buttonsLayoutBackground.isVisible = - callState.landscapeLayoutControlsVisible && callState.isVideoCall - + buttonsLayoutBackground.isVisible = callState.landscapeLayoutControlsVisible && callState.isVideoCall buttonsLayout.isVisible = callState.landscapeLayoutControlsVisible } else { appBar.isVisible = true @@ -395,12 +398,10 @@ internal class CallView( private fun animateControls(fadeIn: Boolean) { val transitionSet = TransitionSet() val appBarFade = MaterialFade() - appBarFade.secondaryAnimatorProvider = - SlideDistanceProvider(if (fadeIn) Gravity.TOP else Gravity.BOTTOM) + appBarFade.secondaryAnimatorProvider = SlideDistanceProvider(if (fadeIn) Gravity.TOP else Gravity.BOTTOM) transitionSet.addTransition(appBarFade.addTarget(appBar)) val buttonsFade = MaterialFade() - buttonsFade.secondaryAnimatorProvider = - SlideDistanceProvider(if (fadeIn) Gravity.BOTTOM else Gravity.TOP) + buttonsFade.secondaryAnimatorProvider = SlideDistanceProvider(if (fadeIn) Gravity.BOTTOM else Gravity.TOP) transitionSet.addTransition(buttonsFade.addTarget(buttonsLayoutBackground)) transitionSet.addTransition(buttonsFade.addTarget(buttonsLayout)) TransitionManager.beginDelayedTransition(this, transitionSet) @@ -488,7 +489,7 @@ internal class CallView( builder.setTheme(theme) builder.setSystemNegativeColor(R.color.glia_system_negative_color) builder.setBaseLightColor(R.color.glia_base_light_color) - builder.setBrandPrimaryColor(android.R.color.transparent) + builder.setBrandPrimaryColor(R.color.glia_call_view_background_color) builder.setGliaChatHeaderTitleTintColor(android.R.color.white) builder.setGliaChatHeaderHomeButtonTintColor(android.R.color.white) builder.setGliaChatHeaderExitQueueButtonTintColor(android.R.color.white) @@ -518,9 +519,6 @@ internal class CallView( fun setUiTheme(uiTheme: UiTheme?) { theme = theme.getFullHybridTheme(uiTheme ?: return) setupViewAppearance() - if (isVisible) { - handleStatusBarColor() - } } fun setOnBackClickedListener(onBackClicked: OnBackClickedListener) { @@ -549,7 +547,6 @@ internal class CallView( private fun showUIOnCallOngoing() { visibility = VISIBLE - handleStatusBarColor() } private fun hideUIOnCallEnd() { @@ -559,23 +556,6 @@ internal class CallView( insetsController?.hideKeyboard() } - private fun handleStatusBarColor() { - val activity = context.requireActivity() - if (defaultStatusBarColor == null) { - defaultStatusBarColor = activity.window.statusBarColor - changeStatusBarColor(getColorCompat(R.color.glia_call_view_background_color)) - } - } - - override fun onDetachedFromWindow() { - super.onDetachedFromWindow() - - defaultStatusBarColor?.also { - changeStatusBarColor(it) - defaultStatusBarColor = null - } - } - private fun showEndEngagementDialog() = showDialog { Dialogs.showEndEngagementDialog( context = context, @@ -807,13 +787,14 @@ internal class CallView( companyNameView.setLocaleHint(R.string.general_company_name) msrView.setLocaleText(R.string.android_call_queue_message) chatButtonBadgeView.text = callState.messagesNotSeen.toString() - if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && - callState.isVideoCall - ) { - appBar.backgroundTintList = - getColorStateListCompat(R.color.glia_call_view_background_color) + + //according to design, in Landscape mode + video call, the controls should be semi-transparent + if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && callState.isVideoCall) { + buttonsLayoutBackground.alpha = CONTROLS_ALPHA_SEMI_TRANSPARENT + appBar.alpha = CONTROLS_ALPHA_SEMI_TRANSPARENT } else { - appBar.backgroundTintList = getColorStateListCompat(android.R.color.transparent) + buttonsLayoutBackground.alpha = CONTROLS_ALPHA + appBar.alpha = CONTROLS_ALPHA } callState.isVideoButtonEnabled.also { diff --git a/widgetssdk/src/main/java/com/glia/widgets/callvisualizer/EndScreenSharingActivity.kt b/widgetssdk/src/main/java/com/glia/widgets/callvisualizer/EndScreenSharingActivity.kt index 36bdfa1ed..46768c6a1 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/callvisualizer/EndScreenSharingActivity.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/callvisualizer/EndScreenSharingActivity.kt @@ -36,6 +36,5 @@ internal class EndScreenSharingActivity : FadeTransitionActivity(), EndScreenSha override fun onDestroy() { super.onDestroy() Logger.i(TAG, "Destroy End Screen Sharing screen") - binding.screenSharingScreenView.onDestroy() } } diff --git a/widgetssdk/src/main/java/com/glia/widgets/callvisualizer/EndScreenSharingView.kt b/widgetssdk/src/main/java/com/glia/widgets/callvisualizer/EndScreenSharingView.kt index 094796731..46b423730 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/callvisualizer/EndScreenSharingView.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/callvisualizer/EndScreenSharingView.kt @@ -5,29 +5,27 @@ import android.util.AttributeSet import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.res.ResourcesCompat import androidx.core.content.withStyledAttributes -import com.glia.widgets.locale.LocaleString import com.glia.widgets.R import com.glia.widgets.UiTheme import com.glia.widgets.databinding.EndScreenSharingViewBinding import com.glia.widgets.di.Dependencies import com.glia.widgets.helper.Logger +import com.glia.widgets.helper.SimpleWindowInsetsAndAnimationHandler import com.glia.widgets.helper.TAG import com.glia.widgets.helper.Utils import com.glia.widgets.helper.applyButtonTheme import com.glia.widgets.helper.applyTextTheme -import com.glia.widgets.helper.asActivity -import com.glia.widgets.helper.changeStatusBarColor 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.setLocaleText +import com.glia.widgets.locale.LocaleString import com.glia.widgets.view.unifiedui.applyButtonTheme import com.glia.widgets.view.unifiedui.applyLayerTheme import com.glia.widgets.view.unifiedui.applyTextTheme import com.glia.widgets.view.unifiedui.theme.UnifiedTheme import com.google.android.material.theme.overlay.MaterialThemeOverlay -import kotlin.properties.Delegates internal class EndScreenSharingView( context: Context, @@ -39,13 +37,10 @@ internal class EndScreenSharingView( attrs, defStyleAttr, defStyleRes -), - EndScreenSharingContract.View { +), EndScreenSharingContract.View { var onFinishListener: OnFinishListener? = null private var controller: EndScreenSharingContract.Controller? = null - private var statusBarColor: Int by Delegates.notNull() - private var defaultStatusBarColor: Int? = null private val binding: EndScreenSharingViewBinding by lazy { EndScreenSharingViewBinding.inflate(layoutInflater, this) @@ -64,6 +59,7 @@ internal class EndScreenSharingView( applyRemoteTheme(Dependencies.gliaThemeManager.theme) setupViewTextResources() prepareView() + SimpleWindowInsetsAndAnimationHandler(this, binding.appBarView) } private fun setupViewTextResources() { @@ -74,7 +70,6 @@ internal class EndScreenSharingView( private fun applyDefaultTheme(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) { context.withStyledAttributes(attrs, R.styleable.GliaView, defStyleAttr, defStyleRes) { - defaultStatusBarColor = context.asActivity()?.window?.statusBarColor var theme = Utils.getThemeFromTypedArray(this, context) theme.iconEndScreenShare?.let { binding.endSharingButton.icon = ResourcesCompat.getDrawable(context.resources, it, null) @@ -112,10 +107,6 @@ internal class EndScreenSharingView( binding.endSharingButton.applyButtonTheme(theme.endButton) binding.screenSharingLabel.applyTextTheme(theme.label) binding.root.applyLayerTheme(theme.background) - theme.header?.background?.fill?.primaryColor?.also { - statusBarColor = it - changeStatusBarColor(it) - } } private fun applyRuntimeTheme(theme: UiTheme?) { @@ -124,16 +115,11 @@ internal class EndScreenSharingView( return } - val primaryColor = theme.brandPrimaryColor?.let(::getColorCompat) val systemNegativeColor = theme.systemNegativeColor?.let(::getColorCompat) val baseLightColor = theme.baseLightColor?.let(::getColorCompat) val baseDarkColor = theme.baseDarkColor?.let(::getColorCompat) val fontFamily = theme.fontRes?.let(::getFontCompat) - primaryColor?.also { - statusBarColor = it - changeStatusBarColor(it) - } binding.appBarView.setTheme(theme) binding.endSharingButton.applyButtonTheme( backgroundColor = systemNegativeColor, @@ -147,10 +133,6 @@ internal class EndScreenSharingView( binding.root.setBackgroundColor(baseLightColor ?: return) } - fun onDestroy() { - changeStatusBarColor(defaultStatusBarColor) - } - interface OnFinishListener { fun finish() } diff --git a/widgetssdk/src/main/java/com/glia/widgets/chat/ChatActivity.java b/widgetssdk/src/main/java/com/glia/widgets/chat/ChatActivity.java index 9f86ef97a..d6b71d877 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/chat/ChatActivity.java +++ b/widgetssdk/src/main/java/com/glia/widgets/chat/ChatActivity.java @@ -5,6 +5,7 @@ import android.os.Bundle; import android.os.Parcelable; +import androidx.activity.EdgeToEdge; import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -138,6 +139,7 @@ public static Intent getIntent( @Override protected void onCreate(@Nullable Bundle savedInstanceState) { + EdgeToEdge.enable(this); super.onCreate(savedInstanceState); Logger.i(TAG, "Create Chat screen"); setContentView(R.layout.chat_activity); 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 c223c5ce5..17e7de4c3 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/chat/ChatView.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/chat/ChatView.kt @@ -29,7 +29,6 @@ import com.glia.androidsdk.chat.AttachmentFile import com.glia.androidsdk.screensharing.ScreenSharing import com.glia.widgets.Constants import com.glia.widgets.GliaWidgets -import com.glia.widgets.locale.LocaleString import com.glia.widgets.R import com.glia.widgets.UiTheme import com.glia.widgets.chat.adapter.ChatAdapter @@ -52,11 +51,11 @@ import com.glia.widgets.di.Dependencies import com.glia.widgets.filepreview.ui.FilePreviewActivity import com.glia.widgets.helper.Logger import com.glia.widgets.helper.SimpleTextWatcher +import com.glia.widgets.helper.SimpleWindowInsetsAndAnimationHandler import com.glia.widgets.helper.TAG import com.glia.widgets.helper.Utils import com.glia.widgets.helper.addColorFilter import com.glia.widgets.helper.asActivity -import com.glia.widgets.helper.changeStatusBarColor import com.glia.widgets.helper.fileName import com.glia.widgets.helper.getColorCompat import com.glia.widgets.helper.getColorStateListCompat @@ -69,6 +68,7 @@ import com.glia.widgets.helper.layoutInflater import com.glia.widgets.helper.requireActivity import com.glia.widgets.helper.setLocaleContentDescription import com.glia.widgets.helper.setLocaleHint +import com.glia.widgets.locale.LocaleString import com.glia.widgets.view.Dialogs import com.glia.widgets.view.SingleChoiceCardView.OnOptionClickedListener import com.glia.widgets.view.dialog.base.DialogDelegate @@ -110,9 +110,6 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In private var isInBottom = true private var theme: UiTheme by Delegates.notNull() - // needed for setting status bar color back when view is gone - private var defaultStatusBarColor: Int? = null - private var statusBarColor: Int by Delegates.notNull() private var onTitleUpdatedListener: OnTitleUpdatedListener? = null private var onEndListener: OnEndListener? = null private var onMinimizeListener: OnMinimizeListener? = null @@ -195,6 +192,7 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In setupViewAppearance() setupViewActions() setupControllers() + SimpleWindowInsetsAndAnimationHandler(this, appBarOrToolBar = binding.appBarView) } /** @@ -204,11 +202,7 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In fun setUiTheme(uiTheme: UiTheme?) { if (uiTheme == null) return theme = theme.getFullHybridTheme(uiTheme) - theme.brandPrimaryColor?.let(::getColorCompat)?.also { statusBarColor = it } setupViewAppearance() - if (isVisible) { - handleStatusBarColor() - } } /** @@ -415,6 +409,8 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In context.startActivity( FilePreviewActivity.intent(context, attachmentFile), options.toBundle() ) + + insetsController?.hideKeyboard() } override fun fileIsNotReadyForPreview() { @@ -515,7 +511,8 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In DialogState.VisitorCode -> { Logger.e(TAG, "DialogController callback in ChatView with MODE_VISITOR_CODE") } // Should never happen inside ChatView - else -> { /* noop */ } + else -> { /* noop */ + } } } } @@ -573,15 +570,10 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In private fun showChat() { visibility = VISIBLE - handleStatusBarColor() } private fun hideChat() { visibility = INVISIBLE - if (defaultStatusBarColor != null) { - changeStatusBarColor(defaultStatusBarColor!!) - defaultStatusBarColor = null - } insetsController?.hideKeyboard() } @@ -610,7 +602,6 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In private fun setDefaultTheme(typedArray: TypedArray) { theme = Utils.getThemeFromTypedArray(typedArray, this.context) theme = theme.getFullHybridTheme(Dependencies.sdkConfigurationManager.uiTheme) - theme.brandPrimaryColor?.let(::getColorCompat)?.also { statusBarColor = it } } private fun initConfigurations() { @@ -695,16 +686,6 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In applyTheme(Dependencies.gliaThemeManager.theme) } - private fun handleStatusBarColor() { - val activity = context.requireActivity() - if (defaultStatusBarColor == null) { - defaultStatusBarColor = activity.window.statusBarColor - if (controller != null && controller!!.isChatVisible) { - changeStatusBarColor(statusBarColor) - } - } - } - private fun setupViewActions() { binding.chatEditText.addTextChangedListener(textWatcher) binding.sendButton.setOnClickListener { @@ -876,9 +857,6 @@ internal class ChatView(context: Context, attrs: AttributeSet?, defStyleAttr: In private fun applyHeaderTheme(headerTheme: HeaderTheme) { binding.appBarView.applyHeaderTheme(headerTheme) - headerTheme.background?.fill?.primaryColor?.also { color -> - statusBarColor = color - } } private fun applyInputTheme(inputTheme: InputTheme) { diff --git a/widgetssdk/src/main/java/com/glia/widgets/filepreview/ui/FilePreviewActivity.kt b/widgetssdk/src/main/java/com/glia/widgets/filepreview/ui/FilePreviewActivity.kt index 41ace6b0c..d2a7b7ec5 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/filepreview/ui/FilePreviewActivity.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/filepreview/ui/FilePreviewActivity.kt @@ -11,6 +11,7 @@ import android.os.Environment import android.view.Menu import android.view.MenuItem import android.view.View +import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.core.content.FileProvider @@ -22,9 +23,9 @@ import com.glia.widgets.R import com.glia.widgets.databinding.FilePreviewActivityBinding import com.glia.widgets.di.Dependencies import com.glia.widgets.helper.Logger +import com.glia.widgets.helper.SimpleWindowInsetsAndAnimationHandler import com.glia.widgets.helper.TAG import com.glia.widgets.helper.fileProviderAuthority -import com.glia.widgets.helper.setContentDescription import com.glia.widgets.helper.setLocaleContentDescription import com.glia.widgets.helper.showToast import java.io.File @@ -63,7 +64,9 @@ internal class FilePreviewActivity : AppCompatActivity(), FilePreviewContract.Vi } override fun onCreate(savedInstanceState: Bundle?) { + enableEdgeToEdge() super.onCreate(savedInstanceState) + SimpleWindowInsetsAndAnimationHandler(binding.root, binding.toolbar) Logger.i(TAG, "Create File Preview screen") setContentView(binding.root) title = localeProvider.getString(R.string.android_preview_title) @@ -111,7 +114,7 @@ internal class FilePreviewActivity : AppCompatActivity(), FilePreviewContract.Vi } override fun onSupportNavigateUp(): Boolean { - onBackPressed() + onBackPressedDispatcher.onBackPressed() return true } diff --git a/widgetssdk/src/main/java/com/glia/widgets/helper/Insets.kt b/widgetssdk/src/main/java/com/glia/widgets/helper/Insets.kt index dbe56a45d..00eab7bf1 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/helper/Insets.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/helper/Insets.kt @@ -1,3 +1,5 @@ +@file:JvmName("Insets") + package com.glia.widgets.helper import android.view.View @@ -12,7 +14,9 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsControllerCompat import androidx.core.view.updateLayoutParams import androidx.core.view.updateMargins +import androidx.core.view.updatePadding +@get:JvmName("insetsControllerCompat") internal val Window.insetsControllerCompat: WindowInsetsControllerCompat get() = WindowCompat.getInsetsController(this, decorView) @@ -52,8 +56,9 @@ internal typealias WindowInsetsAnimationCallback = (insets: Insets) -> Unit */ internal class SimpleWindowInsetsAndAnimationHandler( private val target: View, + private val appBarOrToolBar: View? = null, @DispatchMode mode: Int = DISPATCH_MODE_STOP, - private val callback: WindowInsetsAnimationCallback + private val callback: WindowInsetsAnimationCallback? = null ) : WindowInsetsAnimationCompat.Callback(mode), OnApplyWindowInsetsListener { private var keyboardAnimationInProgress = false @@ -85,7 +90,7 @@ internal class SimpleWindowInsetsAndAnimationHandler( target.updateLayoutParams { updateMargins(bottom = combinedInsets.bottom) } - callback(combinedInsets) + callback?.invoke(combinedInsets) return WindowInsetsCompat.CONSUMED } @@ -94,8 +99,9 @@ internal class SimpleWindowInsetsAndAnimationHandler( if (!keyboardAnimationInProgress) { insets.getInsets(WindowInsetsCompat.Type.systemBars()).apply { v.updateLayoutParams { - updateMargins(left, top, right, bottom) + updateMargins(left, appBarOrToolBar?.let { 0 } ?: top, right, bottom) } + appBarOrToolBar?.updatePadding(top = top) } } diff --git a/widgetssdk/src/main/java/com/glia/widgets/helper/ViewExtensions.kt b/widgetssdk/src/main/java/com/glia/widgets/helper/ViewExtensions.kt index 8c61dea93..ea31630e1 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/helper/ViewExtensions.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/helper/ViewExtensions.kt @@ -30,16 +30,12 @@ import androidx.core.widget.TextViewCompat import com.airbnb.lottie.LottieAnimationView import com.airbnb.lottie.LottieProperty import com.airbnb.lottie.model.KeyPath -import com.glia.widgets.locale.LocaleString import com.glia.widgets.di.Dependencies +import com.glia.widgets.locale.LocaleString import com.glia.widgets.locale.StringKeyPair -import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.button.MaterialButton import com.squareup.picasso.Callback import com.squareup.picasso.Picasso -import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers -import io.reactivex.rxjava3.core.Observable -import io.reactivex.rxjava3.schedulers.Schedulers internal fun View.getColorCompat(@ColorRes resId: Int) = ContextCompat.getColor(context, resId) internal fun View.getColorStateListCompat(@ColorRes resId: Int) = @@ -76,10 +72,6 @@ internal fun ProgressBar.applyProgressColorTheme(@ColorInt progressColor: Int?) progressColor?.also { indeterminateTintList = ColorStateList.valueOf(it) } } -internal fun View.changeStatusBarColor(color: Int?) { - color?.run { context.asActivity()?.window?.statusBarColor = this } -} - internal fun View.applyShadow(@ColorInt color: Int?) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && color != null) { outlineSpotShadowColor = color @@ -87,18 +79,6 @@ internal fun View.applyShadow(@ColorInt color: Int?) { } } -internal fun MaterialToolbar.applyToolbarTheme( - @ColorInt backgroundColor: Int?, - @ColorInt navigationIconColor: Int? -) { - backgroundColor?.let { - backgroundTintList = ColorStateList.valueOf(it) - } - navigationIconColor?.let { - navigationIcon?.setTint(navigationIconColor) - } -} - internal fun MaterialButton.applyButtonTheme( @ColorInt backgroundColor: Int?, @ColorInt textColor: Int?, 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 61fdc6757..fe7cf3700 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageCenterView.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/messagecenter/MessageCenterView.kt @@ -4,21 +4,17 @@ import android.Manifest import android.content.Context import android.content.pm.PackageManager import android.content.res.TypedArray -import android.graphics.Color import android.net.Uri import android.os.Parcelable import android.util.AttributeSet -import android.view.Window import android.widget.LinearLayout import androidx.annotation.VisibleForTesting import androidx.core.content.ContextCompat import androidx.core.content.withStyledAttributes import androidx.core.graphics.Insets import androidx.core.view.ViewCompat -import androidx.core.view.WindowCompat import androidx.core.view.isVisible import com.glia.widgets.Constants -import com.glia.widgets.locale.LocaleString import com.glia.widgets.R import com.glia.widgets.UiTheme import com.glia.widgets.core.configuration.EngagementConfiguration @@ -31,14 +27,13 @@ import com.glia.widgets.helper.Logger import com.glia.widgets.helper.SimpleWindowInsetsAndAnimationHandler import com.glia.widgets.helper.TAG import com.glia.widgets.helper.Utils -import com.glia.widgets.helper.asActivity -import com.glia.widgets.helper.changeStatusBarColor import com.glia.widgets.helper.getColorCompat import com.glia.widgets.helper.hideKeyboard import com.glia.widgets.helper.insetsController import com.glia.widgets.helper.isKeyboardVisible import com.glia.widgets.helper.layoutInflater import com.glia.widgets.helper.rootWindowInsetsCompat +import com.glia.widgets.locale.LocaleString import com.glia.widgets.view.Dialogs import com.glia.widgets.view.dialog.base.DialogDelegate import com.glia.widgets.view.dialog.base.DialogDelegateImpl @@ -80,12 +75,6 @@ internal class MessageCenterView( private val messageView: MessageView? get() = binding?.messageView private val confirmationView: ConfirmationScreenView? get() = binding?.confirmationView - // Is needed for setting status bar color back when the view is gone - private var defaultStatusBarColor: Int? = null - private var statusBarColor: Int by Delegates.notNull() - - private val window: Window? by lazy { context.asActivity()?.window } - private val dialogCallback: DialogContract.Controller.Callback = DialogContract.Controller.Callback { onDialogState(it) } @@ -93,17 +82,9 @@ internal class MessageCenterView( init { isSaveEnabled = true orientation = VERTICAL - defaultStatusBarColor = window?.statusBarColor // Is needed to overlap existing app bar in existing view with this view's app bar. ViewCompat.setElevation(this, Constants.WIDGETS_SDK_LAYER_ELEVATION) readTypedArray(attrs, defStyleAttr, defStyleRes) - - handleInsetChanges() - } - - private fun handleInsetChanges() { - WindowCompat.setDecorFitsSystemWindows(window ?: return, false) - SimpleWindowInsetsAndAnimationHandler(this) { onKeyboardAnimation(it) } } private fun onKeyboardAnimation(insets: Insets) { @@ -124,6 +105,7 @@ internal class MessageCenterView( override fun setupViewAppearance() { // This is done to avoid view appearance when a visitor is not authenticated. binding = MessageCenterViewBinding.inflate(layoutInflater, this) + SimpleWindowInsetsAndAnimationHandler(this, appBar) { onKeyboardAnimation(it) } controller?.ensureMessageCenterAvailability() setupAppBarUnifiedTheme(unifiedTheme?.secureConversationsWelcomeScreenTheme?.headerTheme) @@ -134,12 +116,6 @@ internal class MessageCenterView( private fun setupAppBarUnifiedTheme(headerTheme: HeaderTheme?) { appBar?.applyHeaderTheme(headerTheme) - - headerTheme?.background?.fill?.primaryColor?.also { - statusBarColor = it - } - - changeStatusBarColor(statusBarColor) } private fun readTypedArray(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) { @@ -150,7 +126,6 @@ internal class MessageCenterView( private fun setDefaultTheme(typedArray: TypedArray) { theme = Utils.getThemeFromTypedArray(typedArray, this.context) - statusBarColor = theme.brandPrimaryColor?.let(::getColorCompat) ?: Color.TRANSPARENT } private fun initCallbacks() { @@ -187,7 +162,6 @@ internal class MessageCenterView( } private fun showUnAuthenticatedDialog() { - changeStatusBarColor(Color.TRANSPARENT) showDialog { Dialogs.showUnAuthenticatedDialog(context, theme) { controller?.dismissCurrentDialog() @@ -308,11 +282,6 @@ internal class MessageCenterView( detachDialogController() } - override fun onDetachedFromWindow() { - super.onDetachedFromWindow() - changeStatusBarColor(defaultStatusBarColor ?: return) - } - private fun attachDialogController() { controller?.addCallback(dialogCallback) } diff --git a/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyActivity.java b/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyActivity.java index ecc7f342e..174220e78 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyActivity.java +++ b/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyActivity.java @@ -2,6 +2,7 @@ import android.os.Bundle; +import androidx.activity.EdgeToEdge; import androidx.appcompat.app.AppCompatActivity; import androidx.core.view.WindowCompat; import androidx.core.view.WindowInsetsControllerCompat; @@ -11,14 +12,14 @@ import com.glia.widgets.R; import com.glia.widgets.UiTheme; import com.glia.widgets.di.Dependencies; -import com.glia.widgets.helper.InsetsKt; +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 { @@ -28,6 +29,8 @@ public class SurveyActivity extends AppCompatActivity implements SurveyView.OnFi @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); @@ -69,7 +72,7 @@ public void finishAndRemoveTask() { private void hideSoftKeyboard() { WindowInsetsControllerCompat insetsController = WindowCompat.getInsetsController(getWindow(), findViewById(R.id.survey_view)); - InsetsKt.hideKeyboard(insetsController); + Insets.hideKeyboard(insetsController); } private void prepareSurveyView() { 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 bbadbe9f5..f7b4bb03e 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyView.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/survey/SurveyView.kt @@ -17,6 +17,7 @@ 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 @@ -83,6 +84,7 @@ internal class SurveyView(context: Context, attrs: AttributeSet?, defStyleAttr: setupViewAppearance() initCallbacks() initAdapter() + SimpleWindowInsetsAndAnimationHandler(this) } override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { @@ -223,6 +225,14 @@ internal class SurveyView(context: Context, attrs: AttributeSet?, defStyleAttr: private fun initAdapter() { surveyAdapter = SurveyAdapter(this) recyclerView.adapter = surveyAdapter + + recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + super.onScrollStateChanged(recyclerView, newState) + + insetsController?.hideKeyboard() + } + }) } private fun initCallbacks() { diff --git a/widgetssdk/src/main/java/com/glia/widgets/view/header/AppBarView.kt b/widgetssdk/src/main/java/com/glia/widgets/view/header/AppBarView.kt index 07d37fb22..59d0f63ab 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/view/header/AppBarView.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/view/header/AppBarView.kt @@ -1,6 +1,7 @@ package com.glia.widgets.view.header import android.content.Context +import android.content.res.ColorStateList import android.util.AttributeSet import android.view.MenuItem import android.widget.TextView @@ -11,7 +12,6 @@ import androidx.core.view.children import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.core.widget.TextViewCompat -import com.glia.widgets.locale.LocaleString import com.glia.widgets.R import com.glia.widgets.UiTheme import com.glia.widgets.databinding.AppBarBinding @@ -21,7 +21,6 @@ import com.glia.widgets.helper.applyButtonTheme import com.glia.widgets.helper.applyIconColorTheme import com.glia.widgets.helper.applyImageColorTheme import com.glia.widgets.helper.applyTextTheme -import com.glia.widgets.helper.applyToolbarTheme import com.glia.widgets.helper.getColorCompat import com.glia.widgets.helper.getColorStateListCompat import com.glia.widgets.helper.getFontCompat @@ -30,8 +29,9 @@ import com.glia.widgets.helper.layoutInflater import com.glia.widgets.helper.setLocaleContentDescription import com.glia.widgets.helper.setLocaleNavigationContentDescription import com.glia.widgets.helper.setLocaleText -import com.glia.widgets.helper.setTintCompat import com.glia.widgets.helper.setText +import com.glia.widgets.helper.setTintCompat +import com.glia.widgets.locale.LocaleString import com.glia.widgets.view.unifiedui.applyButtonTheme import com.glia.widgets.view.unifiedui.applyColorTheme import com.glia.widgets.view.unifiedui.applyTextTheme @@ -93,7 +93,7 @@ internal class AppBarView @JvmOverloads constructor( R.styleable.AppBarView_android_backgroundTint, R.attr.gliaBrandPrimaryColor ) - binding.toolbar.backgroundTintList = getColorStateListCompat(backgroundTintList) + this@AppBarView.backgroundTintList = getColorStateListCompat(backgroundTintList) Utils.getTypedArrayStringValue(this, R.styleable.AppBarView_titleText)?.also { binding.title.text = it @@ -117,25 +117,21 @@ internal class AppBarView @JvmOverloads constructor( // icons uiTheme.iconAppBarBack?.also(binding.toolbar::setNavigationIcon) uiTheme.iconLeaveQueue?.also(leaveQueueIcon::setIcon) - uiTheme.iconEndScreenShare?.also { - endScreenShareButton.setImageResource(it) - } + uiTheme.iconEndScreenShare?.also(endScreenShareButton::setImageResource) // colors val brandPrimaryColor = uiTheme.brandPrimaryColor?.let(::getColorCompat) val baseLightColor = uiTheme.baseLightColor?.let(::getColorCompat) val systemNegativeColor = uiTheme.systemNegativeColor?.let(::getColorCompat) - val exitQueueButtonColor = uiTheme.gliaChatHeaderExitQueueButtonTintColor?.let(::getColorCompat) - ?: baseLightColor + val exitQueueButtonColor = uiTheme.gliaChatHeaderExitQueueButtonTintColor?.let(::getColorCompat) ?: baseLightColor val endScreenShareButtonColor = uiTheme.endScreenShareTintColor?.let(::getColorCompat) val chatHeaderTitleColor = uiTheme.gliaChatHeaderTitleTintColor?.let(::getColorCompat) val chatHeaderHomeButtonColor = uiTheme.gliaChatHeaderHomeButtonTintColor?.let(::getColorCompat) val textFont = uiTheme.fontRes?.let(::getFontCompat) - binding.toolbar.applyToolbarTheme( - backgroundColor = brandPrimaryColor, - navigationIconColor = chatHeaderHomeButtonColor - ) + chatHeaderHomeButtonColor?.also { binding.toolbar.setNavigationIconTint(it) } + brandPrimaryColor?.also { backgroundTintList = ColorStateList.valueOf(it) } + leaveQueueIcon.applyIconColorTheme(exitQueueButtonColor) endScreenShareButton.applyImageColorTheme(endScreenShareButtonColor) binding.title.applyTextTheme(chatHeaderTitleColor, textFont) @@ -220,7 +216,7 @@ internal class AppBarView @JvmOverloads constructor( internal fun applyHeaderTheme(headerTheme: HeaderTheme?) { headerTheme?.apply { - binding.toolbar.applyColorTheme(background?.fill) + applyColorTheme(background?.fill) backButton?.iconColor?.also { binding.toolbar.setNavigationIconTint(it.primaryColor) } text?.also(::applyTitleTheme) closeButton?.iconColor?.also { leaveQueueIcon.icon?.setTintCompat(it.primaryColor) } diff --git a/widgetssdk/src/main/java/com/glia/widgets/webbrowser/WebBrowserActivity.kt b/widgetssdk/src/main/java/com/glia/widgets/webbrowser/WebBrowserActivity.kt index 47823436b..3ee454337 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/webbrowser/WebBrowserActivity.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/webbrowser/WebBrowserActivity.kt @@ -4,10 +4,10 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.os.Bundle -import com.glia.widgets.locale.LocaleString import com.glia.widgets.base.FadeTransitionActivity import com.glia.widgets.databinding.WebBrowserAvtivityBinding import com.glia.widgets.helper.getParcelable +import com.glia.widgets.locale.LocaleString /** * Glia internal class. 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 9513053a2..600f12b24 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/webbrowser/WebBrowserView.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/webbrowser/WebBrowserView.kt @@ -2,7 +2,6 @@ package com.glia.widgets.webbrowser import android.content.Context import android.content.res.TypedArray -import android.graphics.Color import android.net.Uri import android.util.AttributeSet import android.view.Window @@ -13,16 +12,15 @@ import android.widget.LinearLayout import androidx.core.content.withStyledAttributes import androidx.core.view.ViewCompat import com.glia.widgets.Constants -import com.glia.widgets.locale.LocaleString 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.changeStatusBarColor -import com.glia.widgets.helper.getColorCompat 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 @@ -52,21 +50,17 @@ internal class WebBrowserView( private val appBar: AppBarView? get() = binding?.appBarView private val webView: WebView? get() = binding?.webView - // Is needed for setting status bar color back when the view is gone - private var defaultStatusBarColor: Int? = null - private var statusBarColor: Int by Delegates.notNull() - private val window: Window? by lazy { context.asActivity()?.window } init { isSaveEnabled = true orientation = VERTICAL - defaultStatusBarColor = window?.statusBarColor // Is needed to overlap existing app bar in existing view with this view's app bar. ViewCompat.setElevation(this, Constants.WIDGETS_SDK_LAYER_ELEVATION) readTypedArray(attrs, defStyleAttr, defStyleRes) setupViewAppearance() + SimpleWindowInsetsAndAnimationHandler(this, appBar) } @JvmOverloads @@ -93,11 +87,6 @@ internal class WebBrowserView( webView?.loadUrl(url) } - override fun onDetachedFromWindow() { - super.onDetachedFromWindow() - changeStatusBarColor(defaultStatusBarColor ?: return) - } - private fun setupViewAppearance() { // This is done to avoid view appearance when a visitor is not authenticated. binding = WebBrowserViewBinding.inflate(layoutInflater, this) @@ -109,12 +98,6 @@ internal class WebBrowserView( private fun setupAppBarUnifiedTheme(headerTheme: HeaderTheme?) { appBar?.applyHeaderTheme(headerTheme) - - headerTheme?.background?.fill?.primaryColor?.also { - statusBarColor = it - } - - changeStatusBarColor(statusBarColor) } private fun readTypedArray(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) { @@ -125,7 +108,6 @@ internal class WebBrowserView( private fun setDefaultTheme(typedArray: TypedArray) { theme = Utils.getThemeFromTypedArray(typedArray, this.context) - statusBarColor = theme.brandPrimaryColor?.let(::getColorCompat) ?: Color.TRANSPARENT } private fun initCallbacks() { diff --git a/widgetssdk/src/main/res/layout/app_bar.xml b/widgetssdk/src/main/res/layout/app_bar.xml index 5d8749428..af034daac 100644 --- a/widgetssdk/src/main/res/layout/app_bar.xml +++ b/widgetssdk/src/main/res/layout/app_bar.xml @@ -7,8 +7,11 @@ @@ -22,22 +25,22 @@ + android:layout_marginEnd="@dimen/glia_large" + android:orientation="horizontal"> + android:src="@drawable/ic_screensharing_off" + android:visibility="gone" /> + android:visibility="gone" + tools:text="@string/general_end" /> diff --git a/widgetssdk/src/main/res/layout/message_center_view.xml b/widgetssdk/src/main/res/layout/message_center_view.xml index d980d427e..f0c46ec50 100644 --- a/widgetssdk/src/main/res/layout/message_center_view.xml +++ b/widgetssdk/src/main/res/layout/message_center_view.xml @@ -1,6 +1,5 @@ - 20dp + 4dp 0dp diff --git a/widgetssdk/src/main/res/values/themes.xml b/widgetssdk/src/main/res/values/themes.xml index 89d0b1a17..2fd1286fa 100644 --- a/widgetssdk/src/main/res/values/themes.xml +++ b/widgetssdk/src/main/res/values/themes.xml @@ -31,14 +31,10 @@ ?attr/gliaIconEndScreenShare ?attr/gliaIconScreenSharingDialog ?attr/gliaSendMessageButtonTintColor - ?attr/gliaChatBackgroundColor ?attr/gliaChatHeaderTitleTintColor ?attr/gliaChatHeaderHomeButtonTintColor - - ?attr/gliaChatHeaderExitQueueButtonTintColor - - + ?attr/gliaChatHeaderExitQueueButtonTintColor ?attr/gliaChatStartingHeadingTextColor ?attr/gliaChatStartingCaptionTextColor ?attr/gliaChatStartedHeadingTextColor @@ -52,12 +48,8 @@ ?attr/gliaNewMessagesDividerTextColor ?attr/gliaBotActionButtonBackgroundColor ?attr/gliaBotActionButtonTextColor - - ?attr/gliaBotActionButtonSelectedBackgroundColor - - ?attr/gliaBotActionButtonSelectedTextColor - - + ?attr/gliaBotActionButtonSelectedBackgroundColor + ?attr/gliaBotActionButtonSelectedTextColor ?attr/gliaHeaderEndButtonStyle ?attr/buttonBarPositiveButtonStyle ?attr/buttonBarNegativeButtonStyle @@ -66,9 +58,7 @@ ?attr/chatHeadStyle - - ?attr/gliaAlertDialogButtonUseVerticalAlignment - + ?attr/gliaAlertDialogButtonUseVerticalAlignment ?attr/whiteLabel @style/ThemeOverlay.Glia.Chat @@ -82,13 +72,11 @@ -