diff --git a/vector/src/main/java/im/vector/riotx/core/epoxy/DividerItem.kt b/vector/src/main/java/im/vector/riotx/core/epoxy/DividerItem.kt index ab849a6909..379eb33a9c 100644 --- a/vector/src/main/java/im/vector/riotx/core/epoxy/DividerItem.kt +++ b/vector/src/main/java/im/vector/riotx/core/epoxy/DividerItem.kt @@ -15,11 +15,24 @@ */ package im.vector.riotx.core.epoxy +import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass import im.vector.riotx.R +/** + * Default background color is for the bottom sheets (R.attr.vctr_list_bottom_sheet_divider_color). + * To use in fragment, set color using R.attr.vctr_list_divider_color + */ @EpoxyModelClass(layout = R.layout.item_divider) abstract class DividerItem : VectorEpoxyModel() { + @EpoxyAttribute var color: Int = -1 + + override fun bind(holder: Holder) { + if (color != -1) { + holder.view.setBackgroundColor(color) + } + } + class Holder : VectorEpoxyHolder() } diff --git a/vector/src/main/java/im/vector/riotx/core/epoxy/profiles/ProfileItemExtensions.kt b/vector/src/main/java/im/vector/riotx/core/epoxy/profiles/ProfileItemExtensions.kt index 3a9fff52af..32060f577d 100644 --- a/vector/src/main/java/im/vector/riotx/core/epoxy/profiles/ProfileItemExtensions.kt +++ b/vector/src/main/java/im/vector/riotx/core/epoxy/profiles/ProfileItemExtensions.kt @@ -19,7 +19,7 @@ package im.vector.riotx.core.epoxy.profiles import androidx.annotation.DrawableRes import com.airbnb.epoxy.EpoxyController -import im.vector.riotx.core.epoxy.DividerItem_ +import im.vector.riotx.core.epoxy.dividerItem fun EpoxyController.buildProfileSection(title: String) { profileSectionItem { @@ -31,6 +31,7 @@ fun EpoxyController.buildProfileSection(title: String) { fun EpoxyController.buildProfileAction( id: String, title: String, + dividerColor: Int, subtitle: String? = null, editable: Boolean = true, @DrawableRes icon: Int = 0, @@ -50,7 +51,10 @@ fun EpoxyController.buildProfileAction( } } - DividerItem_() - .id("divider_$title") - .addIf(divider, this) + if (divider) { + dividerItem { + id("divider_$title") + color(dividerColor) + } + } } diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt index 6fe9d6e701..23c713068a 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt @@ -21,11 +21,16 @@ import com.airbnb.epoxy.TypedEpoxyController import im.vector.riotx.R import im.vector.riotx.core.epoxy.profiles.buildProfileAction import im.vector.riotx.core.epoxy.profiles.buildProfileSection +import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.StringProvider import javax.inject.Inject -class RoomMemberProfileController @Inject constructor(private val stringProvider: StringProvider) - : TypedEpoxyController() { +class RoomMemberProfileController @Inject constructor( + private val stringProvider: StringProvider, + colorProvider: ColorProvider +) : TypedEpoxyController() { + + private val dividerColor = colorProvider.getColorFromAttribute(R.attr.vctr_list_divider_color) var callback: Callback? = null @@ -54,6 +59,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider buildProfileAction( id = "ignore", title = ignoreActionTitle, + dividerColor = dividerColor, destructive = true, editable = false, divider = false, @@ -72,6 +78,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider buildProfileAction( id = "learn_more", title = stringProvider.getString(R.string.room_profile_section_security_learn_more), + dividerColor = dividerColor, editable = false, divider = false, subtitle = stringProvider.getString(learnMoreSubtitle), @@ -85,6 +92,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider id = "read_receipt", editable = false, title = stringProvider.getString(R.string.room_member_jump_to_read_receipt), + dividerColor = dividerColor, action = { callback?.onJumpToReadReceiptClicked() } ) @@ -93,6 +101,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider buildProfileAction( id = "mention", title = stringProvider.getString(R.string.room_participants_action_mention), + dividerColor = dividerColor, editable = false, divider = ignoreActionTitle != null, action = { callback?.onMentionClicked() } @@ -101,6 +110,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider buildProfileAction( id = "ignore", title = ignoreActionTitle, + dividerColor = dividerColor, destructive = true, editable = false, divider = false, diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt index 37a36fbcf1..44a50ee5e6 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt @@ -21,11 +21,16 @@ import com.airbnb.epoxy.TypedEpoxyController import im.vector.riotx.R import im.vector.riotx.core.epoxy.profiles.buildProfileAction import im.vector.riotx.core.epoxy.profiles.buildProfileSection +import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.StringProvider import javax.inject.Inject -class RoomProfileController @Inject constructor(private val stringProvider: StringProvider) - : TypedEpoxyController() { +class RoomProfileController @Inject constructor( + private val stringProvider: StringProvider, + colorProvider: ColorProvider +) : TypedEpoxyController() { + + private val dividerColor = colorProvider.getColorFromAttribute(R.attr.vctr_list_divider_color) var callback: Callback? = null @@ -53,6 +58,7 @@ class RoomProfileController @Inject constructor(private val stringProvider: Stri buildProfileAction( id = "learn_more", title = stringProvider.getString(R.string.room_profile_section_security_learn_more), + dividerColor = dividerColor, subtitle = stringProvider.getString(learnMoreSubtitle), action = { callback?.onLearnMoreClicked() } ) @@ -62,12 +68,14 @@ class RoomProfileController @Inject constructor(private val stringProvider: Stri buildProfileAction( id = "settings", title = stringProvider.getString(R.string.room_profile_section_more_settings), + dividerColor = dividerColor, icon = R.drawable.ic_room_profile_settings, action = { callback?.onSettingsClicked() } ) buildProfileAction( id = "notifications", title = stringProvider.getString(R.string.room_profile_section_more_notifications), + dividerColor = dividerColor, icon = R.drawable.ic_room_profile_notification, action = { callback?.onNotificationsClicked() } ) @@ -75,18 +83,21 @@ class RoomProfileController @Inject constructor(private val stringProvider: Stri buildProfileAction( id = "member_list", title = stringProvider.getQuantityString(R.plurals.room_profile_section_more_member_list, numberOfMembers, numberOfMembers), + dividerColor = dividerColor, icon = R.drawable.ic_room_profile_member_list, action = { callback?.onMemberListClicked() } ) buildProfileAction( id = "uploads", title = stringProvider.getString(R.string.room_profile_section_more_uploads), + dividerColor = dividerColor, icon = R.drawable.ic_room_profile_uploads, action = { callback?.onUploadsClicked() } ) buildProfileAction( id = "leave", title = stringProvider.getString(R.string.room_profile_section_more_leave), + dividerColor = dividerColor, divider = false, destructive = true, editable = false, diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListController.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListController.kt index 6b7ef74806..7d6bce7bbb 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListController.kt @@ -19,20 +19,27 @@ package im.vector.riotx.features.roomprofile.members import com.airbnb.epoxy.TypedEpoxyController import im.vector.matrix.android.api.session.room.model.RoomMemberSummary import im.vector.matrix.android.api.util.toMatrixItem +import im.vector.riotx.R import im.vector.riotx.core.epoxy.dividerItem import im.vector.riotx.core.epoxy.profiles.buildProfileSection import im.vector.riotx.core.epoxy.profiles.profileMatrixItem +import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.StringProvider import im.vector.riotx.features.home.AvatarRenderer import javax.inject.Inject -class RoomMemberListController @Inject constructor(private val avatarRenderer: AvatarRenderer, - private val stringProvider: StringProvider) : TypedEpoxyController() { +class RoomMemberListController @Inject constructor( + private val avatarRenderer: AvatarRenderer, + private val stringProvider: StringProvider, + colorProvider: ColorProvider +) : TypedEpoxyController() { interface Callback { fun onRoomMemberClicked(roomMember: RoomMemberSummary) } + private val dividerColor = colorProvider.getColorFromAttribute(R.attr.vctr_list_divider_color) + var callback: Callback? = null init { @@ -60,6 +67,7 @@ class RoomMemberListController @Inject constructor(private val avatarRenderer: A dividerItem { id("divider_${roomMember.userId}") + color(dividerColor) } } } diff --git a/vector/src/main/res/drawable/redacted_background.xml b/vector/src/main/res/drawable/redacted_background.xml index 8538e15988..f253a9eaf7 100644 --- a/vector/src/main/res/drawable/redacted_background.xml +++ b/vector/src/main/res/drawable/redacted_background.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/vector/src/main/res/layout/item_divider.xml b/vector/src/main/res/layout/item_divider.xml index d130465e7d..f4fbf87b39 100644 --- a/vector/src/main/res/layout/item_divider.xml +++ b/vector/src/main/res/layout/item_divider.xml @@ -1,6 +1,7 @@ + android:background="?attr/vctr_list_bottom_sheet_divider_color" + tools:layout_height="100dp" /> diff --git a/vector/src/main/res/values/attrs.xml b/vector/src/main/res/values/attrs.xml index aca2a7fa5f..15a3fd3981 100644 --- a/vector/src/main/res/values/attrs.xml +++ b/vector/src/main/res/values/attrs.xml @@ -46,8 +46,11 @@ + + + diff --git a/vector/src/main/res/values/theme_black.xml b/vector/src/main/res/values/theme_black.xml index 7bce009429..b2ddfd5b81 100644 --- a/vector/src/main/res/values/theme_black.xml +++ b/vector/src/main/res/values/theme_black.xml @@ -70,7 +70,11 @@ @color/primary_color_black @color/primary_color_dark_black - @color/list_divider_color_black + + @color/list_divider_color_black + @color/riotx_header_panel_background_black + + @color/list_divider_color_black #FF4D4D4D diff --git a/vector/src/main/res/values/theme_dark.xml b/vector/src/main/res/values/theme_dark.xml index a05081eec7..d6d3526a83 100644 --- a/vector/src/main/res/values/theme_dark.xml +++ b/vector/src/main/res/values/theme_dark.xml @@ -121,7 +121,10 @@ #FFC8C8CD - @color/list_divider_color_dark + @color/list_divider_color_dark + @color/riotx_header_panel_background_dark + + @color/list_divider_color_dark #80000000 diff --git a/vector/src/main/res/values/theme_light.xml b/vector/src/main/res/values/theme_light.xml index 9cea0e52b7..0296bbc804 100644 --- a/vector/src/main/res/values/theme_light.xml +++ b/vector/src/main/res/values/theme_light.xml @@ -121,7 +121,10 @@ #FFC8C8CD - @color/list_divider_color_light + @color/list_divider_color_light + @color/riotx_header_panel_background_light + + @color/list_divider_color_light #80ffffff diff --git a/vector/src/main/res/values/theme_status.xml b/vector/src/main/res/values/theme_status.xml index 421632e64c..7607ce30e9 100644 --- a/vector/src/main/res/values/theme_status.xml +++ b/vector/src/main/res/values/theme_status.xml @@ -71,8 +71,6 @@ #7F3C3C3C #4D3C3C3C - @color/list_divider_color_light - #80ffffff