Display-name coloring setting
Based on whether a chat is - DM - Room - Public room allow to select whether to color usernames - Uniformly (as previously done in SC themes) - Based on Matrix ID (as previously seen in Element themes) - Based on the user's power level in that room (new!) The setting concerning rooms that are neither DM nor public is also used for deciding whether to use mxid-based avatar coloring or uniform coloring. Change-Id: Ic68a24f4818a193f776a3b14232f887cd229929a
This commit is contained in:
parent
a0adb8c9bd
commit
24a61ee0ff
@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
<attr name="message_highlight_bg_color" format="color" />
|
<attr name="message_highlight_bg_color" format="color" />
|
||||||
|
|
||||||
|
<attr name="user_color_pl_100" format="color" />
|
||||||
|
<attr name="user_color_pl_50" format="color" />
|
||||||
|
<attr name="user_color_pl_0" format="color" />
|
||||||
|
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -60,8 +60,16 @@
|
|||||||
<color name="sc_reaction_background_on_light">@color/accent_sc_50</color>
|
<color name="sc_reaction_background_on_light">@color/accent_sc_50</color>
|
||||||
<color name="sc_reaction_background_on_dark">@color/accent_sc_900</color>
|
<color name="sc_reaction_background_on_dark">@color/accent_sc_900</color>
|
||||||
|
|
||||||
|
<!-- Power-level based username colors -->
|
||||||
|
<color name="user_color_sc_pl_100">#F44336</color>
|
||||||
|
<color name="user_color_sc_pl_50">#2196F3</color>
|
||||||
|
<color name="user_color_sc_pl_0">@color/accent_sc</color>
|
||||||
|
|
||||||
<!-- Exposed Element colors -->
|
<!-- Exposed Element colors -->
|
||||||
<!-- This is actually not an SC color, but the one found in element for ic_material_play_circle PNGs -->
|
<!-- This is actually not an SC color, but the one found in element for ic_material_play_circle PNGs -->
|
||||||
<color name="element_accent_pale">#76cfa6</color>
|
<color name="element_accent_pale">#76cfa6</color>
|
||||||
|
<color name="user_color_element_pl_100">@color/palette_polly</color>
|
||||||
|
<color name="user_color_element_pl_50">@color/palette_azure</color>
|
||||||
|
<color name="user_color_element_pl_0">@color/palette_element_green</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -125,6 +125,9 @@
|
|||||||
<item name="colorAccentPale">@color/element_accent_pale</item>
|
<item name="colorAccentPale">@color/element_accent_pale</item>
|
||||||
<item name="dense_dropdown_text_input">@style/Widget.Vector.TextInputLayout.Dense.ExposedDropdownMenu.Dark.SC</item>
|
<item name="dense_dropdown_text_input">@style/Widget.Vector.TextInputLayout.Dense.ExposedDropdownMenu.Dark.SC</item>
|
||||||
<item name="message_highlight_bg_color">?vctr_header_background</item>
|
<item name="message_highlight_bg_color">?vctr_header_background</item>
|
||||||
|
<item name="user_color_pl_0">@color/user_color_element_pl_0</item>
|
||||||
|
<item name="user_color_pl_50">@color/user_color_element_pl_50</item>
|
||||||
|
<item name="user_color_pl_100">@color/user_color_element_pl_100</item>
|
||||||
|
|
||||||
<item name="android:statusBarColor">@color/android_status_bar_background_dark</item>
|
<item name="android:statusBarColor">@color/android_status_bar_background_dark</item>
|
||||||
<item name="android:navigationBarColor">@color/android_navigation_bar_background_dark</item>
|
<item name="android:navigationBarColor">@color/android_navigation_bar_background_dark</item>
|
||||||
|
@ -125,6 +125,9 @@
|
|||||||
<item name="colorAccentPale">@color/element_accent_pale</item>
|
<item name="colorAccentPale">@color/element_accent_pale</item>
|
||||||
<item name="dense_dropdown_text_input">@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu</item>
|
<item name="dense_dropdown_text_input">@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu</item>
|
||||||
<item name="message_highlight_bg_color">?vctr_header_background</item>
|
<item name="message_highlight_bg_color">?vctr_header_background</item>
|
||||||
|
<item name="user_color_pl_0">@color/user_color_element_pl_0</item>
|
||||||
|
<item name="user_color_pl_50">@color/user_color_element_pl_50</item>
|
||||||
|
<item name="user_color_pl_100">@color/user_color_element_pl_100</item>
|
||||||
|
|
||||||
<!-- Use dark color, to have enough contrast with icons color. windowLightStatusBar is only available in API 23+ -->
|
<!-- Use dark color, to have enough contrast with icons color. windowLightStatusBar is only available in API 23+ -->
|
||||||
<item name="android:statusBarColor">@color/android_status_bar_background_dark</item>
|
<item name="android:statusBarColor">@color/android_status_bar_background_dark</item>
|
||||||
|
@ -87,6 +87,9 @@
|
|||||||
<item name="riotx_unread_unimportant_room_badge">@color/background_floating_sc</item>
|
<item name="riotx_unread_unimportant_room_badge">@color/background_floating_sc</item>
|
||||||
<item name="colorAccentPale">@color/accent_sc_pale</item>
|
<item name="colorAccentPale">@color/accent_sc_pale</item>
|
||||||
<item name="message_highlight_bg_color">@color/accent_sc_alpha25</item>
|
<item name="message_highlight_bg_color">@color/accent_sc_alpha25</item>
|
||||||
|
<item name="user_color_pl_0">@color/user_color_sc_pl_0</item>
|
||||||
|
<item name="user_color_pl_50">@color/user_color_sc_pl_50</item>
|
||||||
|
<item name="user_color_pl_100">@color/user_color_sc_pl_100</item>
|
||||||
|
|
||||||
<item name="android:statusBarColor">@color/background_black_sc</item>
|
<item name="android:statusBarColor">@color/background_black_sc</item>
|
||||||
<item name="android:navigationBarColor">@color/background_black_sc</item>
|
<item name="android:navigationBarColor">@color/background_black_sc</item>
|
||||||
|
@ -87,6 +87,9 @@
|
|||||||
<item name="riotx_unread_unimportant_room_badge">#737373</item><!-- like text_color_secondary_sc_light, but without transparency -->
|
<item name="riotx_unread_unimportant_room_badge">#737373</item><!-- like text_color_secondary_sc_light, but without transparency -->
|
||||||
<item name="colorAccentPale">@color/accent_sc_pale</item>
|
<item name="colorAccentPale">@color/accent_sc_pale</item>
|
||||||
<item name="message_highlight_bg_color">#ffe0e0e0</item>
|
<item name="message_highlight_bg_color">#ffe0e0e0</item>
|
||||||
|
<item name="user_color_pl_0">@color/user_color_sc_pl_0</item>
|
||||||
|
<item name="user_color_pl_50">@color/user_color_sc_pl_50</item>
|
||||||
|
<item name="user_color_pl_100">@color/user_color_sc_pl_100</item>
|
||||||
|
|
||||||
<item name="android:statusBarColor">@color/background_black_sc</item>
|
<item name="android:statusBarColor">@color/background_black_sc</item>
|
||||||
<item name="android:navigationBarColor">@color/background_black_sc</item>
|
<item name="android:navigationBarColor">@color/background_black_sc</item>
|
||||||
|
@ -39,6 +39,7 @@ import im.vector.app.features.home.AvatarRenderer
|
|||||||
import im.vector.app.features.home.CurrentSpaceSuggestedRoomListDataSource
|
import im.vector.app.features.home.CurrentSpaceSuggestedRoomListDataSource
|
||||||
import im.vector.app.features.home.room.detail.RoomDetailPendingActionStore
|
import im.vector.app.features.home.room.detail.RoomDetailPendingActionStore
|
||||||
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
|
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
|
||||||
|
import im.vector.app.features.home.room.detail.timeline.helper.PowerLevelsHolder
|
||||||
import im.vector.app.features.home.room.detail.timeline.helper.RoomSummariesHolder
|
import im.vector.app.features.home.room.detail.timeline.helper.RoomSummariesHolder
|
||||||
import im.vector.app.features.html.EventHtmlRenderer
|
import im.vector.app.features.html.EventHtmlRenderer
|
||||||
import im.vector.app.features.html.VectorHtmlCompressor
|
import im.vector.app.features.html.VectorHtmlCompressor
|
||||||
@ -164,6 +165,8 @@ interface VectorComponent {
|
|||||||
|
|
||||||
fun roomSummaryHolder(): RoomSummariesHolder
|
fun roomSummaryHolder(): RoomSummariesHolder
|
||||||
|
|
||||||
|
fun powerLevelsHolder(): PowerLevelsHolder
|
||||||
|
|
||||||
@Component.Factory
|
@Component.Factory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
fun create(@BindsInstance context: Context): VectorComponent
|
fun create(@BindsInstance context: Context): VectorComponent
|
||||||
|
@ -218,8 +218,8 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AnyThread
|
@AnyThread
|
||||||
fun getPlaceholderDrawable(matrixItem: MatrixItem): Drawable {
|
fun getPlaceholderDrawable(matrixItem: MatrixItem, userInRoomInformation: MatrixItemColorProvider.UserInRoomInformation? = null): Drawable {
|
||||||
val avatarColor = matrixItemColorProvider.getColor(matrixItem)
|
val avatarColor = matrixItemColorProvider.getColor(matrixItem, userInRoomInformation)
|
||||||
return TextDrawable.builder()
|
return TextDrawable.builder()
|
||||||
.beginConfig()
|
.beginConfig()
|
||||||
.bold()
|
.bold()
|
||||||
|
@ -48,6 +48,7 @@ import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrate
|
|||||||
import im.vector.app.features.crypto.verification.SupportedVerificationMethodsProvider
|
import im.vector.app.features.crypto.verification.SupportedVerificationMethodsProvider
|
||||||
import im.vector.app.features.home.room.detail.composer.rainbow.RainbowGenerator
|
import im.vector.app.features.home.room.detail.composer.rainbow.RainbowGenerator
|
||||||
import im.vector.app.features.home.room.detail.sticker.StickerPickerActionHandler
|
import im.vector.app.features.home.room.detail.sticker.StickerPickerActionHandler
|
||||||
|
import im.vector.app.features.home.room.detail.timeline.helper.PowerLevelsHolder
|
||||||
import im.vector.app.features.home.room.detail.timeline.helper.RoomSummariesHolder
|
import im.vector.app.features.home.room.detail.timeline.helper.RoomSummariesHolder
|
||||||
import im.vector.app.features.home.room.detail.timeline.helper.TimelineSettingsFactory
|
import im.vector.app.features.home.room.detail.timeline.helper.TimelineSettingsFactory
|
||||||
import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlRetriever
|
import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlRetriever
|
||||||
@ -114,6 +115,7 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||||||
private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider,
|
private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider,
|
||||||
private val stickerPickerActionHandler: StickerPickerActionHandler,
|
private val stickerPickerActionHandler: StickerPickerActionHandler,
|
||||||
private val roomSummariesHolder: RoomSummariesHolder,
|
private val roomSummariesHolder: RoomSummariesHolder,
|
||||||
|
private val powerLevelsHolder: PowerLevelsHolder,
|
||||||
private val typingHelper: TypingHelper,
|
private val typingHelper: TypingHelper,
|
||||||
private val callManager: WebRtcCallManager,
|
private val callManager: WebRtcCallManager,
|
||||||
private val chatEffectManager: ChatEffectManager,
|
private val chatEffectManager: ChatEffectManager,
|
||||||
@ -163,6 +165,7 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
powerLevelsHolder.clear(room.roomId)
|
||||||
timeline.start()
|
timeline.start()
|
||||||
timeline.addListener(this)
|
timeline.addListener(this)
|
||||||
observeRoomSummary()
|
observeRoomSummary()
|
||||||
@ -213,10 +216,12 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||||||
private fun observePowerLevel() {
|
private fun observePowerLevel() {
|
||||||
PowerLevelsObservableFactory(room).createObservable()
|
PowerLevelsObservableFactory(room).createObservable()
|
||||||
.subscribe {
|
.subscribe {
|
||||||
val canSendMessage = PowerLevelsHelper(it).isUserAllowedToSend(session.myUserId, false, EventType.MESSAGE)
|
val powerLevelsHelper = PowerLevelsHelper(it)
|
||||||
val canInvite = PowerLevelsHelper(it).isUserAbleToInvite(session.myUserId)
|
powerLevelsHolder.set(room.roomId, powerLevelsHelper)
|
||||||
|
val canSendMessage = powerLevelsHelper.isUserAllowedToSend(session.myUserId, false, EventType.MESSAGE)
|
||||||
|
val canInvite = powerLevelsHelper.isUserAbleToInvite(session.myUserId)
|
||||||
val isAllowedToManageWidgets = session.widgetService().hasPermissionsToHandleWidgets(room.roomId)
|
val isAllowedToManageWidgets = session.widgetService().hasPermissionsToHandleWidgets(room.roomId)
|
||||||
val isAllowedToStartWebRTCCall = PowerLevelsHelper(it).isUserAllowedToSend(session.myUserId, false, EventType.CALL_INVITE)
|
val isAllowedToStartWebRTCCall = powerLevelsHelper.isUserAllowedToSend(session.myUserId, false, EventType.CALL_INVITE)
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
canSendMessage = canSendMessage,
|
canSendMessage = canSendMessage,
|
||||||
|
@ -31,8 +31,8 @@ class MessageColorProvider @Inject constructor(
|
|||||||
private val vectorPreferences: VectorPreferences) {
|
private val vectorPreferences: VectorPreferences) {
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun getMemberNameTextColor(matrixItem: MatrixItem): Int {
|
fun getMemberNameTextColor(matrixItem: MatrixItem, userInRoomInformation: MatrixItemColorProvider.UserInRoomInformation? = null): Int {
|
||||||
return matrixItemColorProvider.getColor(matrixItem)
|
return matrixItemColorProvider.getColor(matrixItem, userInRoomInformation)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
|
@ -21,6 +21,7 @@ import androidx.annotation.ColorRes
|
|||||||
import androidx.annotation.VisibleForTesting
|
import androidx.annotation.VisibleForTesting
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.resources.ColorProvider
|
import im.vector.app.core.resources.ColorProvider
|
||||||
|
import im.vector.app.features.settings.VectorPreferences
|
||||||
import im.vector.app.features.themes.ThemeUtils
|
import im.vector.app.features.themes.ThemeUtils
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -29,20 +30,26 @@ import kotlin.math.abs
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class MatrixItemColorProvider @Inject constructor(
|
class MatrixItemColorProvider @Inject constructor(
|
||||||
|
private val vectorPreferences: VectorPreferences,
|
||||||
private val colorProvider: ColorProvider
|
private val colorProvider: ColorProvider
|
||||||
) {
|
) {
|
||||||
private val cache = mutableMapOf<String, Int>()
|
private val cache = mutableMapOf<String, Int>()
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun getColor(matrixItem: MatrixItem): Int {
|
@Suppress("UNUSED_PARAMETER")
|
||||||
if (ThemeUtils.isScTheme(colorProvider.context)) {
|
fun getColor(matrixItem: MatrixItem, userInRoomInformation: UserInRoomInformation? = null): Int {
|
||||||
return colorProvider.getColor(
|
val coloringMode = vectorPreferences.userColorMode(userInRoomInformation?.isDm ?: false, userInRoomInformation?.isPublicRoom ?: false)
|
||||||
when (matrixItem) {
|
return when (coloringMode) {
|
||||||
is MatrixItem.UserItem -> R.color.username_sc_1
|
USER_COLORING_FROM_PL -> {
|
||||||
else -> R.color.avatar_fill_sc_1
|
if (userInRoomInformation?.userPowerLevel == null || userInRoomInformation.userPowerLevel < 30) {
|
||||||
|
colorProvider.getColorFromAttribute(R.attr.user_color_pl_0)
|
||||||
|
} else if (userInRoomInformation.userPowerLevel < 80) {
|
||||||
|
colorProvider.getColorFromAttribute(R.attr.user_color_pl_50)
|
||||||
|
} else {
|
||||||
|
colorProvider.getColorFromAttribute(R.attr.user_color_pl_100)
|
||||||
}
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
USER_COLORING_FROM_ID -> {
|
||||||
return cache.getOrPut(matrixItem.id) {
|
return cache.getOrPut(matrixItem.id) {
|
||||||
colorProvider.getColor(
|
colorProvider.getColor(
|
||||||
when (matrixItem) {
|
when (matrixItem) {
|
||||||
@ -52,6 +59,11 @@ class MatrixItemColorProvider @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else -> {
|
||||||
|
colorProvider.getColorFromAttribute(android.R.attr.colorAccent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ColorRes
|
@ColorRes
|
||||||
@ -81,5 +93,13 @@ class MatrixItemColorProvider @Inject constructor(
|
|||||||
else -> R.color.element_room_01
|
else -> R.color.element_room_01
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Same values as in R.array.user_color_mode_values
|
||||||
|
private const val USER_COLORING_UNIFORM = "uniform"
|
||||||
|
private const val USER_COLORING_FROM_ID = "from-id"
|
||||||
|
private const val USER_COLORING_FROM_PL = "from-pl"
|
||||||
|
const val USER_COLORING_DEFAULT = USER_COLORING_UNIFORM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class UserInRoomInformation(val isDm: Boolean? = null, val isPublicRoom: Boolean? = null, val userPowerLevel: Int? = null)
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ import javax.inject.Inject
|
|||||||
*/
|
*/
|
||||||
class MessageInformationDataFactory @Inject constructor(private val session: Session,
|
class MessageInformationDataFactory @Inject constructor(private val session: Session,
|
||||||
private val roomSummariesHolder: RoomSummariesHolder,
|
private val roomSummariesHolder: RoomSummariesHolder,
|
||||||
|
private val powerLevelsHolder: PowerLevelsHolder,
|
||||||
private val dateFormatter: VectorDateFormatter,
|
private val dateFormatter: VectorDateFormatter,
|
||||||
private val vectorPreferences: VectorPreferences,
|
private val vectorPreferences: VectorPreferences,
|
||||||
private val context: Context) {
|
private val context: Context) {
|
||||||
@ -123,6 +124,13 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
|
|||||||
SendStateDecoration.NONE
|
SendStateDecoration.NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sender power level
|
||||||
|
/*
|
||||||
|
val powerLevelsHelper = session.getRoom(event.roomId)?.getStateEvent(EventType.STATE_ROOM_POWER_LEVELS, QueryStringValue.NoCondition)?.content.toModel<PowerLevelsContent>()?.let { PowerLevelsHelper(it) }
|
||||||
|
val senderPowerLevel = powerLevelsHelper?.getUserPowerLevelValue(event.senderInfo.userId)
|
||||||
|
*/
|
||||||
|
val senderPowerLevel = powerLevelsHolder.get(event.roomId)?.getUserPowerLevelValue(event.senderInfo.userId)
|
||||||
|
|
||||||
return MessageInformationData(
|
return MessageInformationData(
|
||||||
eventId = eventId,
|
eventId = eventId,
|
||||||
senderId = event.root.senderId ?: "",
|
senderId = event.root.senderId ?: "",
|
||||||
@ -165,7 +173,9 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
|
|||||||
} else {
|
} else {
|
||||||
AnonymousReadReceipt.PROCESSING
|
AnonymousReadReceipt.PROCESSING
|
||||||
},
|
},
|
||||||
|
senderPowerLevel = senderPowerLevel,
|
||||||
isDirect = isEffectivelyDirect,
|
isDirect = isEffectivelyDirect,
|
||||||
|
isPublic = roomSummary?.isPublic ?: false,
|
||||||
dmChatPartnerId = dmOtherMemberId,
|
dmChatPartnerId = dmOtherMemberId,
|
||||||
e2eDecoration = e2eDecoration,
|
e2eDecoration = e2eDecoration,
|
||||||
sendStateDecoration = sendStateDecoration
|
sendStateDecoration = sendStateDecoration
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package im.vector.app.features.home.room.detail.timeline.helper
|
||||||
|
|
||||||
|
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
/*
|
||||||
|
You can use this to share user power level helpers within the app.
|
||||||
|
You should probably use this only in the context of the timeline.
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
class PowerLevelsHolder @Inject constructor() {
|
||||||
|
|
||||||
|
private var roomHelpers = HashMap<String, PowerLevelsHelper>()
|
||||||
|
|
||||||
|
fun set(roomId: String, powerLevelsHelper: PowerLevelsHelper) {
|
||||||
|
roomHelpers[roomId] = powerLevelsHelper
|
||||||
|
}
|
||||||
|
|
||||||
|
fun get(roomId: String) = roomHelpers[roomId]
|
||||||
|
|
||||||
|
fun clear() {
|
||||||
|
roomHelpers.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clear(roomId: String) {
|
||||||
|
roomHelpers.remove(roomId)
|
||||||
|
}
|
||||||
|
}
|
@ -42,6 +42,7 @@ import im.vector.app.core.ui.views.SendStateImageView
|
|||||||
import im.vector.app.features.home.AvatarRenderer
|
import im.vector.app.features.home.AvatarRenderer
|
||||||
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
|
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
|
||||||
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
||||||
|
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
|
||||||
import im.vector.app.features.themes.BubbleThemeUtils
|
import im.vector.app.features.themes.BubbleThemeUtils
|
||||||
import im.vector.app.features.themes.ThemeUtils
|
import im.vector.app.features.themes.ThemeUtils
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
@ -223,7 +224,14 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
|||||||
super.unbind(holder)
|
super.unbind(holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Attributes.getMemberNameColor() = messageColorProvider.getMemberNameTextColor(informationData.matrixItem)
|
private fun Attributes.getMemberNameColor() = messageColorProvider.getMemberNameTextColor(
|
||||||
|
informationData.matrixItem,
|
||||||
|
MatrixItemColorProvider.UserInRoomInformation(
|
||||||
|
attributes.informationData.isDirect,
|
||||||
|
attributes.informationData.isPublic,
|
||||||
|
attributes.informationData.senderPowerLevel
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
abstract class Holder(@IdRes stubId: Int) : AbsBaseMessageItem.Holder(stubId) {
|
abstract class Holder(@IdRes stubId: Int) : AbsBaseMessageItem.Holder(stubId) {
|
||||||
val avatarImageView by bind<ImageView>(R.id.messageAvatarImageView)
|
val avatarImageView by bind<ImageView>(R.id.messageAvatarImageView)
|
||||||
|
@ -42,6 +42,8 @@ data class MessageInformationData(
|
|||||||
val sentByMe : Boolean,
|
val sentByMe : Boolean,
|
||||||
val readReceiptAnonymous: AnonymousReadReceipt,
|
val readReceiptAnonymous: AnonymousReadReceipt,
|
||||||
val isDirect: Boolean,
|
val isDirect: Boolean,
|
||||||
|
val isPublic: Boolean,
|
||||||
|
val senderPowerLevel: Int?,
|
||||||
val dmChatPartnerId: String?,
|
val dmChatPartnerId: String?,
|
||||||
val e2eDecoration: E2EDecoration = E2EDecoration.NONE,
|
val e2eDecoration: E2EDecoration = E2EDecoration.NONE,
|
||||||
val sendStateDecoration: SendStateDecoration = SendStateDecoration.NONE
|
val sendStateDecoration: SendStateDecoration = SendStateDecoration.NONE
|
||||||
|
@ -31,6 +31,7 @@ import com.google.android.material.chip.ChipDrawable
|
|||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.glide.GlideRequests
|
import im.vector.app.core.glide.GlideRequests
|
||||||
import im.vector.app.features.home.AvatarRenderer
|
import im.vector.app.features.home.AvatarRenderer
|
||||||
|
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
|
||||||
import org.matrix.android.sdk.api.session.room.send.MatrixItemSpan
|
import org.matrix.android.sdk.api.session.room.send.MatrixItemSpan
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
@ -43,7 +44,8 @@ import java.lang.ref.WeakReference
|
|||||||
class PillImageSpan(private val glideRequests: GlideRequests,
|
class PillImageSpan(private val glideRequests: GlideRequests,
|
||||||
private val avatarRenderer: AvatarRenderer,
|
private val avatarRenderer: AvatarRenderer,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
override val matrixItem: MatrixItem
|
override val matrixItem: MatrixItem,
|
||||||
|
val userInRoomInformation: MatrixItemColorProvider.UserInRoomInformation? = null
|
||||||
) : ReplacementSpan(), MatrixItemSpan {
|
) : ReplacementSpan(), MatrixItemSpan {
|
||||||
|
|
||||||
private val pillDrawable = createChipDrawable()
|
private val pillDrawable = createChipDrawable()
|
||||||
|
@ -25,6 +25,7 @@ import im.vector.app.BuildConfig
|
|||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.di.DefaultSharedPreferences
|
import im.vector.app.core.di.DefaultSharedPreferences
|
||||||
import im.vector.app.features.disclaimer.SHARED_PREF_KEY
|
import im.vector.app.features.disclaimer.SHARED_PREF_KEY
|
||||||
|
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
|
||||||
import im.vector.app.features.homeserver.ServerUrlsRepository
|
import im.vector.app.features.homeserver.ServerUrlsRepository
|
||||||
import im.vector.app.features.themes.ThemeUtils
|
import im.vector.app.features.themes.ThemeUtils
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
@ -196,6 +197,9 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
|||||||
private const val SETTINGS_SIMPLIFIED_MODE = "SETTINGS_SIMPLIFIED_MODE"
|
private const val SETTINGS_SIMPLIFIED_MODE = "SETTINGS_SIMPLIFIED_MODE"
|
||||||
private const val SETTINGS_LABS_ALLOW_MARK_UNREAD = "SETTINGS_LABS_ALLOW_MARK_UNREAD"
|
private const val SETTINGS_LABS_ALLOW_MARK_UNREAD = "SETTINGS_LABS_ALLOW_MARK_UNREAD"
|
||||||
const val SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY = "SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY"
|
const val SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY = "SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY"
|
||||||
|
private const val SETTINGS_USER_COLOR_MODE_DM = "SETTINGS_USER_COLOR_MODE_DM"
|
||||||
|
private const val SETTINGS_USER_COLOR_MODE_DEFAULT = "SETTINGS_USER_COLOR_MODE_DEFAULT"
|
||||||
|
private const val SETTINGS_USER_COLOR_MODE_PUBLIC_ROOM = "SETTINGS_USER_COLOR_MODE_PUBLIC_ROOM"
|
||||||
|
|
||||||
private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH"
|
private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH"
|
||||||
|
|
||||||
@ -968,6 +972,15 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SC addition
|
||||||
|
fun userColorMode(isDirect: Boolean, isPublic: Boolean): String {
|
||||||
|
return defaultPrefs.getString(when {
|
||||||
|
isPublic -> SETTINGS_USER_COLOR_MODE_PUBLIC_ROOM
|
||||||
|
isDirect -> SETTINGS_USER_COLOR_MODE_DM
|
||||||
|
else -> SETTINGS_USER_COLOR_MODE_DEFAULT
|
||||||
|
}, MatrixItemColorProvider.USER_COLORING_DEFAULT) ?: MatrixItemColorProvider.USER_COLORING_DEFAULT
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user enable protecting app access with pin code.
|
* The user enable protecting app access with pin code.
|
||||||
* Currently we use the pin code store to know if the pin is enabled, so this is not used
|
* Currently we use the pin code store to know if the pin is enabled, so this is not used
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.features.settings
|
||||||
|
|
||||||
|
import im.vector.app.R
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class VectorSettingsAdvancedThemeFragment @Inject constructor(
|
||||||
|
//private val vectorPreferences: VectorPreferences
|
||||||
|
) : VectorSettingsBaseFragment() {
|
||||||
|
|
||||||
|
override var titleRes = R.string.settings_advanced_theme_settings
|
||||||
|
override val preferenceXmlRes = R.xml.vector_settings_advanced_theme_settings
|
||||||
|
|
||||||
|
override fun bindPref() {
|
||||||
|
}
|
||||||
|
}
|
@ -206,26 +206,6 @@ object ThemeUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this is SC theme.
|
|
||||||
*
|
|
||||||
* @param context the context
|
|
||||||
* @return true if SC theme is active, false otherwise
|
|
||||||
*/
|
|
||||||
fun isScTheme(context: Context?): Boolean {
|
|
||||||
if (context != null) {
|
|
||||||
mIsScTheme = when (getApplicationTheme(context)) {
|
|
||||||
THEME_SC_LIGHT_VALUE,
|
|
||||||
THEME_SC_VALUE,
|
|
||||||
THEME_SC_DARK_VALUE,
|
|
||||||
THEME_SC_COLORED_VALUE,
|
|
||||||
THEME_SC_DARK_COLORED_VALUE -> true
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mIsScTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if system theme is dark
|
* @return true if system theme is dark
|
||||||
*/
|
*/
|
||||||
|
@ -37,4 +37,16 @@
|
|||||||
<item>@string/prompt_simplified_mode_off</item>
|
<item>@string/prompt_simplified_mode_off</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="user_color_mode_entries" translatable="false">
|
||||||
|
<item>@string/user_colors_uniform</item>
|
||||||
|
<item>@string/user_colors_from_pl</item>
|
||||||
|
<item>@string/user_colors_from_id</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="user_color_mode_values" translatable="false">
|
||||||
|
<item>uniform</item>
|
||||||
|
<item>from-pl</item>
|
||||||
|
<item>from-id</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -69,4 +69,15 @@
|
|||||||
|
|
||||||
<string name="footer_read_receipt_content_description">Message status</string>
|
<string name="footer_read_receipt_content_description">Message status</string>
|
||||||
|
|
||||||
|
<!-- Username colors -->
|
||||||
|
<string name="settings_user_colors_in_dm">User colors in direct chats</string>
|
||||||
|
<string name="settings_user_colors_in_default">User colors in group chats</string>
|
||||||
|
<string name="settings_user_colors_in_public_rooms">User colors in public rooms</string>
|
||||||
|
<string name="user_colors_uniform">Uniform</string>
|
||||||
|
<string name="user_colors_from_pl">Based on power level</string>
|
||||||
|
<string name="user_colors_from_id">Based on Matrix ID</string>
|
||||||
|
|
||||||
|
<string name="settings_advanced_theme_settings">Advanced theme settings</string>
|
||||||
|
<string name="settings_user_colors">User colors</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<im.vector.app.core.preference.VectorPreferenceCategory android:title="@string/settings_user_colors">
|
||||||
|
|
||||||
|
<im.vector.app.core.preference.VectorListPreference
|
||||||
|
android:defaultValue="uniform"
|
||||||
|
android:key="SETTINGS_USER_COLOR_MODE_DM"
|
||||||
|
android:title="@string/settings_user_colors_in_dm"
|
||||||
|
android:summary="%s"
|
||||||
|
android:entries="@array/user_color_mode_entries"
|
||||||
|
android:entryValues="@array/user_color_mode_values" />
|
||||||
|
|
||||||
|
<im.vector.app.core.preference.VectorListPreference
|
||||||
|
android:defaultValue="uniform"
|
||||||
|
android:key="SETTINGS_USER_COLOR_MODE_DEFAULT"
|
||||||
|
android:title="@string/settings_user_colors_in_default"
|
||||||
|
android:summary="%s"
|
||||||
|
android:entries="@array/user_color_mode_entries"
|
||||||
|
android:entryValues="@array/user_color_mode_values" />
|
||||||
|
|
||||||
|
<im.vector.app.core.preference.VectorListPreference
|
||||||
|
android:defaultValue="uniform"
|
||||||
|
android:key="SETTINGS_USER_COLOR_MODE_PUBLIC_ROOM"
|
||||||
|
android:title="@string/settings_user_colors_in_public_rooms"
|
||||||
|
android:summary="%s"
|
||||||
|
android:entries="@array/user_color_mode_entries"
|
||||||
|
android:entryValues="@array/user_color_mode_values" />
|
||||||
|
|
||||||
|
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||||
|
|
||||||
|
</androidx.preference.PreferenceScreen>
|
@ -64,6 +64,10 @@
|
|||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/font_size" />
|
android:title="@string/font_size" />
|
||||||
|
|
||||||
|
<im.vector.app.core.preference.VectorPreference
|
||||||
|
android:title="@string/settings_advanced_theme_settings"
|
||||||
|
app:fragment="im.vector.app.features.settings.VectorSettingsAdvancedThemeFragment" />
|
||||||
|
|
||||||
</im.vector.app.core.preference.VectorPreferenceCategory>
|
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorPreferenceCategory
|
<im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
|
Loading…
x
Reference in New Issue
Block a user