Hide username color override if unused

Change-Id: I93e40b06c518398ad27458b6425ce0bcae8ebd57
This commit is contained in:
SpiritCroc 2022-03-02 16:39:56 +01:00
parent fd72d55dd0
commit b26b3186ac
2 changed files with 13 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import im.vector.app.core.epoxy.profiles.buildProfileSection
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.ui.list.genericFooterItem
import im.vector.app.features.settings.VectorPreferences
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.room.model.Membership
@ -34,6 +35,7 @@ import javax.inject.Inject
class RoomMemberProfileController @Inject constructor(
private val stringProvider: StringProvider,
private val colorProvider: ColorProvider,
private val vectorPreferences: VectorPreferences,
private val session: Session
) : TypedEpoxyController<RoomMemberProfileViewState>() {
@ -186,6 +188,7 @@ class RoomMemberProfileController @Inject constructor(
// More
buildProfileSection(stringProvider.getString(R.string.room_profile_section_more))
if (vectorPreferences.canOverrideUserColors()) {
buildProfileAction(
id = "overrideColor",
editable = false,
@ -194,6 +197,7 @@ class RoomMemberProfileController @Inject constructor(
divider = !state.isMine,
action = { callback?.onOverrideColorClicked() }
)
}
if (!state.isMine) {
val membership = state.asyncMembership() ?: return

View File

@ -1023,6 +1023,15 @@ class VectorPreferences @Inject constructor(private val context: Context, privat
}, MatrixItemColorProvider.USER_COLORING_DEFAULT) ?: MatrixItemColorProvider.USER_COLORING_DEFAULT
}
fun canOverrideUserColors(): Boolean {
return MatrixItemColorProvider.USER_COLORING_FROM_ID in listOf(
userColorMode(isDirect = false, isPublic = false),
userColorMode(isDirect = false, isPublic = true),
userColorMode(isDirect = true, isPublic = false),
userColorMode(isDirect = true, isPublic = true),
)
}
// SC addition
fun loadRoomAtFirstUnread(): Boolean {
// https://github.com/vector-im/element-android/issues/5092