mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-21 17:05:39 +03:00
Sticker picker: pass dark/light theme
Change-Id: I3c0152cab2d991c4439c10834a06b4c2753510e1
This commit is contained in:
parent
41e9e1e4f5
commit
783212961c
4 changed files with 26 additions and 3 deletions
|
@ -32,6 +32,7 @@ Here you can find some extra features and changes compared to Element Android (w
|
|||
- Some different icons
|
||||
- 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
|
||||
- Pass theme to stickerpicker (tested with maunium-stickerpicker)
|
||||
- ...
|
||||
- Sometimes bug fixes for issues in Element, when found during internal testing
|
||||
- Sometimes additional bugs ;)
|
||||
|
|
|
@ -65,6 +65,7 @@ import im.vector.app.features.settings.VectorPreferences
|
|||
import im.vector.app.features.settings.VectorSettingsActivity
|
||||
import im.vector.app.features.share.SharedData
|
||||
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.WidgetArgsBuilder
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.IncomingSasVerificationTransaction
|
||||
|
@ -279,7 +280,7 @@ class DefaultNavigator @Inject constructor(
|
|||
activityResultLauncher: ActivityResultLauncher<Intent>,
|
||||
roomId: String,
|
||||
widget: Widget) {
|
||||
val widgetArgs = widgetArgsBuilder.buildStickerPickerArgs(roomId, widget)
|
||||
val widgetArgs = widgetArgsBuilder.buildStickerPickerArgs(roomId, widget, ThemeUtils.getWidgetTheme(context))
|
||||
val intent = WidgetActivity.newIntent(context, widgetArgs)
|
||||
activityResultLauncher.launch(intent)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -44,7 +44,7 @@ class WidgetArgsBuilder @Inject constructor(private val sessionHolder: ActiveSes
|
|||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun buildStickerPickerArgs(roomId: String, widget: Widget): WidgetArgs {
|
||||
fun buildStickerPickerArgs(roomId: String, widget: Widget, theme: String): WidgetArgs {
|
||||
val widgetId = widget.widgetId
|
||||
val baseUrl = widget.computedUrl ?: throw IllegalStateException()
|
||||
return WidgetArgs(
|
||||
|
@ -54,7 +54,8 @@ class WidgetArgsBuilder @Inject constructor(private val sessionHolder: ActiveSes
|
|||
widgetId = widgetId,
|
||||
urlParams = mapOf(
|
||||
"widgetId" to widgetId,
|
||||
"room_id" to roomId
|
||||
"room_id" to roomId,
|
||||
"theme" to theme
|
||||
).filterNotNull()
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue