Sticker picker: pass dark/light theme

Change-Id: I3c0152cab2d991c4439c10834a06b4c2753510e1
This commit is contained in:
SpiritCroc 2021-01-19 18:16:14 +01:00
parent 41e9e1e4f5
commit 783212961c
4 changed files with 26 additions and 3 deletions

View File

@ -32,6 +32,7 @@ Here you can find some extra features and changes compared to Element Android (w
- Some different icons - Some different icons
- Emoji-only messages with increased size: also for messages that have spaces between emojis - Emoji-only messages with increased size: also for messages that have spaces between emojis
- Also fallback to other user's avatar for 2-person-rooms not marked as DM - Also fallback to other user's avatar for 2-person-rooms not marked as DM
- Pass theme to stickerpicker (tested with maunium-stickerpicker)
- ... - ...
- Sometimes bug fixes for issues in Element, when found during internal testing - Sometimes bug fixes for issues in Element, when found during internal testing
- Sometimes additional bugs ;) - Sometimes additional bugs ;)

View File

@ -65,6 +65,7 @@ import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.settings.VectorSettingsActivity import im.vector.app.features.settings.VectorSettingsActivity
import im.vector.app.features.share.SharedData import im.vector.app.features.share.SharedData
import im.vector.app.features.terms.ReviewTermsActivity import im.vector.app.features.terms.ReviewTermsActivity
import im.vector.app.features.themes.ThemeUtils
import im.vector.app.features.widgets.WidgetActivity import im.vector.app.features.widgets.WidgetActivity
import im.vector.app.features.widgets.WidgetArgsBuilder import im.vector.app.features.widgets.WidgetArgsBuilder
import org.matrix.android.sdk.api.session.crypto.verification.IncomingSasVerificationTransaction import org.matrix.android.sdk.api.session.crypto.verification.IncomingSasVerificationTransaction
@ -279,7 +280,7 @@ class DefaultNavigator @Inject constructor(
activityResultLauncher: ActivityResultLauncher<Intent>, activityResultLauncher: ActivityResultLauncher<Intent>,
roomId: String, roomId: String,
widget: Widget) { widget: Widget) {
val widgetArgs = widgetArgsBuilder.buildStickerPickerArgs(roomId, widget) val widgetArgs = widgetArgsBuilder.buildStickerPickerArgs(roomId, widget, ThemeUtils.getWidgetTheme(context))
val intent = WidgetActivity.newIntent(context, widgetArgs) val intent = WidgetActivity.newIntent(context, widgetArgs)
activityResultLauncher.launch(intent) activityResultLauncher.launch(intent)
} }

View File

@ -125,6 +125,26 @@ object ThemeUtils {
} }
} }
/**
* @return true if current theme is black (darker than dark)
*/
fun isBlackTheme(context: Context): Boolean {
return when (getApplicationTheme(context)) {
THEME_BLACK_VALUE,
THEME_SC_VALUE,
THEME_SC_COLORED_VALUE -> true
else -> false
}
}
fun getWidgetTheme(context: Context): String {
return when {
isLightTheme(context) -> "light"
isBlackTheme(context) -> "black"
else -> "dark"
}
}
/** /**
* Provides the selected application theme * Provides the selected application theme
* *

View File

@ -44,7 +44,7 @@ class WidgetArgsBuilder @Inject constructor(private val sessionHolder: ActiveSes
} }
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun buildStickerPickerArgs(roomId: String, widget: Widget): WidgetArgs { fun buildStickerPickerArgs(roomId: String, widget: Widget, theme: String): WidgetArgs {
val widgetId = widget.widgetId val widgetId = widget.widgetId
val baseUrl = widget.computedUrl ?: throw IllegalStateException() val baseUrl = widget.computedUrl ?: throw IllegalStateException()
return WidgetArgs( return WidgetArgs(
@ -54,7 +54,8 @@ class WidgetArgsBuilder @Inject constructor(private val sessionHolder: ActiveSes
widgetId = widgetId, widgetId = widgetId,
urlParams = mapOf( urlParams = mapOf(
"widgetId" to widgetId, "widgetId" to widgetId,
"room_id" to roomId "room_id" to roomId,
"theme" to theme
).filterNotNull() ).filterNotNull()
) )
} }