From 6d53d0e12f3fe992e1f358e45a388f51c502379b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 5 Feb 2021 12:08:24 +0100 Subject: [PATCH] Give theme to the integration manager as per Element Web https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/ScalarAuthClient.js#L277 --- .../app/features/widgets/WidgetArgsBuilder.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/widgets/WidgetArgsBuilder.kt b/vector/src/main/java/im/vector/app/features/widgets/WidgetArgsBuilder.kt index 198278a794..daca84add4 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/WidgetArgsBuilder.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/WidgetArgsBuilder.kt @@ -16,11 +16,16 @@ package im.vector.app.features.widgets +import android.content.Context import im.vector.app.core.di.ActiveSessionHolder +import im.vector.app.features.themes.ThemeUtils import org.matrix.android.sdk.api.session.widgets.model.Widget import javax.inject.Inject -class WidgetArgsBuilder @Inject constructor(private val sessionHolder: ActiveSessionHolder) { +class WidgetArgsBuilder @Inject constructor( + private val sessionHolder: ActiveSessionHolder, + private val context: Context +) { @Suppress("UNCHECKED_CAST") fun buildIntegrationManagerArgs(roomId: String, integId: String?, screen: String?): WidgetArgs { @@ -38,11 +43,20 @@ class WidgetArgsBuilder @Inject constructor(private val sessionHolder: ActiveSes urlParams = mapOf( "screen" to normalizedScreen, "integ_id" to integId, - "room_id" to roomId + "room_id" to roomId, + "theme" to getTheme() ).filterNotNull() ) } + private fun getTheme(): String { + return if (ThemeUtils.isLightTheme(context)) { + "light" + } else { + "dark" + } + } + @Suppress("UNCHECKED_CAST") fun buildStickerPickerArgs(roomId: String, widget: Widget): WidgetArgs { val widgetId = widget.widgetId