Room profile: fix issue with divider color

This commit is contained in:
Benoit Marty 2020-01-16 20:48:04 +01:00
parent 9eff459ed6
commit b56ee9a377
12 changed files with 76 additions and 18 deletions

View file

@ -15,11 +15,24 @@
*/ */
package im.vector.riotx.core.epoxy package im.vector.riotx.core.epoxy
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass import com.airbnb.epoxy.EpoxyModelClass
import im.vector.riotx.R 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) @EpoxyModelClass(layout = R.layout.item_divider)
abstract class DividerItem : VectorEpoxyModel<DividerItem.Holder>() { abstract class DividerItem : VectorEpoxyModel<DividerItem.Holder>() {
@EpoxyAttribute var color: Int = -1
override fun bind(holder: Holder) {
if (color != -1) {
holder.view.setBackgroundColor(color)
}
}
class Holder : VectorEpoxyHolder() class Holder : VectorEpoxyHolder()
} }

View file

@ -19,7 +19,7 @@ package im.vector.riotx.core.epoxy.profiles
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import com.airbnb.epoxy.EpoxyController import com.airbnb.epoxy.EpoxyController
import im.vector.riotx.core.epoxy.DividerItem_ import im.vector.riotx.core.epoxy.dividerItem
fun EpoxyController.buildProfileSection(title: String) { fun EpoxyController.buildProfileSection(title: String) {
profileSectionItem { profileSectionItem {
@ -31,6 +31,7 @@ fun EpoxyController.buildProfileSection(title: String) {
fun EpoxyController.buildProfileAction( fun EpoxyController.buildProfileAction(
id: String, id: String,
title: String, title: String,
dividerColor: Int,
subtitle: String? = null, subtitle: String? = null,
editable: Boolean = true, editable: Boolean = true,
@DrawableRes icon: Int = 0, @DrawableRes icon: Int = 0,
@ -50,7 +51,10 @@ fun EpoxyController.buildProfileAction(
} }
} }
DividerItem_() if (divider) {
.id("divider_$title") dividerItem {
.addIf(divider, this) id("divider_$title")
color(dividerColor)
}
}
} }

View file

@ -21,11 +21,16 @@ import com.airbnb.epoxy.TypedEpoxyController
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.epoxy.profiles.buildProfileAction import im.vector.riotx.core.epoxy.profiles.buildProfileAction
import im.vector.riotx.core.epoxy.profiles.buildProfileSection import im.vector.riotx.core.epoxy.profiles.buildProfileSection
import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.core.resources.StringProvider import im.vector.riotx.core.resources.StringProvider
import javax.inject.Inject import javax.inject.Inject
class RoomMemberProfileController @Inject constructor(private val stringProvider: StringProvider) class RoomMemberProfileController @Inject constructor(
: TypedEpoxyController<RoomMemberProfileViewState>() { private val stringProvider: StringProvider,
colorProvider: ColorProvider
) : TypedEpoxyController<RoomMemberProfileViewState>() {
private val dividerColor = colorProvider.getColorFromAttribute(R.attr.vctr_list_divider_color)
var callback: Callback? = null var callback: Callback? = null
@ -54,6 +59,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider
buildProfileAction( buildProfileAction(
id = "ignore", id = "ignore",
title = ignoreActionTitle, title = ignoreActionTitle,
dividerColor = dividerColor,
destructive = true, destructive = true,
editable = false, editable = false,
divider = false, divider = false,
@ -72,6 +78,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider
buildProfileAction( buildProfileAction(
id = "learn_more", id = "learn_more",
title = stringProvider.getString(R.string.room_profile_section_security_learn_more), title = stringProvider.getString(R.string.room_profile_section_security_learn_more),
dividerColor = dividerColor,
editable = false, editable = false,
divider = false, divider = false,
subtitle = stringProvider.getString(learnMoreSubtitle), subtitle = stringProvider.getString(learnMoreSubtitle),
@ -85,6 +92,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider
id = "read_receipt", id = "read_receipt",
editable = false, editable = false,
title = stringProvider.getString(R.string.room_member_jump_to_read_receipt), title = stringProvider.getString(R.string.room_member_jump_to_read_receipt),
dividerColor = dividerColor,
action = { callback?.onJumpToReadReceiptClicked() } action = { callback?.onJumpToReadReceiptClicked() }
) )
@ -93,6 +101,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider
buildProfileAction( buildProfileAction(
id = "mention", id = "mention",
title = stringProvider.getString(R.string.room_participants_action_mention), title = stringProvider.getString(R.string.room_participants_action_mention),
dividerColor = dividerColor,
editable = false, editable = false,
divider = ignoreActionTitle != null, divider = ignoreActionTitle != null,
action = { callback?.onMentionClicked() } action = { callback?.onMentionClicked() }
@ -101,6 +110,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider
buildProfileAction( buildProfileAction(
id = "ignore", id = "ignore",
title = ignoreActionTitle, title = ignoreActionTitle,
dividerColor = dividerColor,
destructive = true, destructive = true,
editable = false, editable = false,
divider = false, divider = false,

View file

@ -21,11 +21,16 @@ import com.airbnb.epoxy.TypedEpoxyController
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.epoxy.profiles.buildProfileAction import im.vector.riotx.core.epoxy.profiles.buildProfileAction
import im.vector.riotx.core.epoxy.profiles.buildProfileSection import im.vector.riotx.core.epoxy.profiles.buildProfileSection
import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.core.resources.StringProvider import im.vector.riotx.core.resources.StringProvider
import javax.inject.Inject import javax.inject.Inject
class RoomProfileController @Inject constructor(private val stringProvider: StringProvider) class RoomProfileController @Inject constructor(
: TypedEpoxyController<RoomProfileViewState>() { private val stringProvider: StringProvider,
colorProvider: ColorProvider
) : TypedEpoxyController<RoomProfileViewState>() {
private val dividerColor = colorProvider.getColorFromAttribute(R.attr.vctr_list_divider_color)
var callback: Callback? = null var callback: Callback? = null
@ -53,6 +58,7 @@ class RoomProfileController @Inject constructor(private val stringProvider: Stri
buildProfileAction( buildProfileAction(
id = "learn_more", id = "learn_more",
title = stringProvider.getString(R.string.room_profile_section_security_learn_more), title = stringProvider.getString(R.string.room_profile_section_security_learn_more),
dividerColor = dividerColor,
subtitle = stringProvider.getString(learnMoreSubtitle), subtitle = stringProvider.getString(learnMoreSubtitle),
action = { callback?.onLearnMoreClicked() } action = { callback?.onLearnMoreClicked() }
) )
@ -62,12 +68,14 @@ class RoomProfileController @Inject constructor(private val stringProvider: Stri
buildProfileAction( buildProfileAction(
id = "settings", id = "settings",
title = stringProvider.getString(R.string.room_profile_section_more_settings), title = stringProvider.getString(R.string.room_profile_section_more_settings),
dividerColor = dividerColor,
icon = R.drawable.ic_room_profile_settings, icon = R.drawable.ic_room_profile_settings,
action = { callback?.onSettingsClicked() } action = { callback?.onSettingsClicked() }
) )
buildProfileAction( buildProfileAction(
id = "notifications", id = "notifications",
title = stringProvider.getString(R.string.room_profile_section_more_notifications), title = stringProvider.getString(R.string.room_profile_section_more_notifications),
dividerColor = dividerColor,
icon = R.drawable.ic_room_profile_notification, icon = R.drawable.ic_room_profile_notification,
action = { callback?.onNotificationsClicked() } action = { callback?.onNotificationsClicked() }
) )
@ -75,18 +83,21 @@ class RoomProfileController @Inject constructor(private val stringProvider: Stri
buildProfileAction( buildProfileAction(
id = "member_list", id = "member_list",
title = stringProvider.getQuantityString(R.plurals.room_profile_section_more_member_list, numberOfMembers, numberOfMembers), title = stringProvider.getQuantityString(R.plurals.room_profile_section_more_member_list, numberOfMembers, numberOfMembers),
dividerColor = dividerColor,
icon = R.drawable.ic_room_profile_member_list, icon = R.drawable.ic_room_profile_member_list,
action = { callback?.onMemberListClicked() } action = { callback?.onMemberListClicked() }
) )
buildProfileAction( buildProfileAction(
id = "uploads", id = "uploads",
title = stringProvider.getString(R.string.room_profile_section_more_uploads), title = stringProvider.getString(R.string.room_profile_section_more_uploads),
dividerColor = dividerColor,
icon = R.drawable.ic_room_profile_uploads, icon = R.drawable.ic_room_profile_uploads,
action = { callback?.onUploadsClicked() } action = { callback?.onUploadsClicked() }
) )
buildProfileAction( buildProfileAction(
id = "leave", id = "leave",
title = stringProvider.getString(R.string.room_profile_section_more_leave), title = stringProvider.getString(R.string.room_profile_section_more_leave),
dividerColor = dividerColor,
divider = false, divider = false,
destructive = true, destructive = true,
editable = false, editable = false,

View file

@ -19,20 +19,27 @@ package im.vector.riotx.features.roomprofile.members
import com.airbnb.epoxy.TypedEpoxyController import com.airbnb.epoxy.TypedEpoxyController
import im.vector.matrix.android.api.session.room.model.RoomMemberSummary import im.vector.matrix.android.api.session.room.model.RoomMemberSummary
import im.vector.matrix.android.api.util.toMatrixItem 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.dividerItem
import im.vector.riotx.core.epoxy.profiles.buildProfileSection import im.vector.riotx.core.epoxy.profiles.buildProfileSection
import im.vector.riotx.core.epoxy.profiles.profileMatrixItem 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.core.resources.StringProvider
import im.vector.riotx.features.home.AvatarRenderer import im.vector.riotx.features.home.AvatarRenderer
import javax.inject.Inject import javax.inject.Inject
class RoomMemberListController @Inject constructor(private val avatarRenderer: AvatarRenderer, class RoomMemberListController @Inject constructor(
private val stringProvider: StringProvider) : TypedEpoxyController<RoomMemberListViewState>() { private val avatarRenderer: AvatarRenderer,
private val stringProvider: StringProvider,
colorProvider: ColorProvider
) : TypedEpoxyController<RoomMemberListViewState>() {
interface Callback { interface Callback {
fun onRoomMemberClicked(roomMember: RoomMemberSummary) fun onRoomMemberClicked(roomMember: RoomMemberSummary)
} }
private val dividerColor = colorProvider.getColorFromAttribute(R.attr.vctr_list_divider_color)
var callback: Callback? = null var callback: Callback? = null
init { init {
@ -60,6 +67,7 @@ class RoomMemberListController @Inject constructor(private val avatarRenderer: A
dividerItem { dividerItem {
id("divider_${roomMember.userId}") id("divider_${roomMember.userId}")
color(dividerColor)
} }
} }
} }

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="10dp" /> <corners android:radius="10dp" />
<solid android:color="?vctr_list_divider_color" /> <solid android:color="?vctr_redacted_message_color" />
</shape> </shape>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android" <View xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/quickReactTopDivider" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="?attr/vctr_list_divider_color" /> android:background="?attr/vctr_list_bottom_sheet_divider_color"
tools:layout_height="100dp" />

View file

@ -46,8 +46,11 @@
<attr name="vctr_list_header_primary_text_color" format="color" /> <attr name="vctr_list_header_primary_text_color" format="color" />
<attr name="vctr_list_header_secondary_text_color" format="color" /> <attr name="vctr_list_header_secondary_text_color" format="color" />
<attr name="vctr_list_bottom_sheet_divider_color" format="color" />
<attr name="vctr_list_divider_color" format="color" /> <attr name="vctr_list_divider_color" format="color" />
<attr name="vctr_redacted_message_color" format="color" />
<!-- gradient on the bottom of some activities --> <!-- gradient on the bottom of some activities -->
<attr name="vctr_activity_bottom_gradient_color" format="color" /> <attr name="vctr_activity_bottom_gradient_color" format="color" />

View file

@ -70,7 +70,11 @@
<item name="vctr_tab_home">@color/primary_color_black</item> <item name="vctr_tab_home">@color/primary_color_black</item>
<!--Header/Panel Text Secondary--> <!--Header/Panel Text Secondary-->
<item name="vctr_tab_home_secondary">@color/primary_color_dark_black</item> <item name="vctr_tab_home_secondary">@color/primary_color_dark_black</item>
<item name="vctr_list_divider_color">@color/list_divider_color_black</item>
<item name="vctr_list_bottom_sheet_divider_color">@color/list_divider_color_black</item>
<item name="vctr_list_divider_color">@color/riotx_header_panel_background_black</item>
<item name="vctr_redacted_message_color">@color/list_divider_color_black</item>
<item name="vctr_markdown_block_background_color">#FF4D4D4D</item> <item name="vctr_markdown_block_background_color">#FF4D4D4D</item>

View file

@ -121,7 +121,10 @@
<!--Header/Panel Text Secondary--> <!--Header/Panel Text Secondary-->
<item name="vctr_list_header_secondary_text_color">#FFC8C8CD</item> <item name="vctr_list_header_secondary_text_color">#FFC8C8CD</item>
<item name="vctr_list_divider_color">@color/list_divider_color_dark</item> <item name="vctr_list_bottom_sheet_divider_color">@color/list_divider_color_dark</item>
<item name="vctr_list_divider_color">@color/riotx_header_panel_background_dark</item>
<item name="vctr_redacted_message_color">@color/list_divider_color_dark</item>
<!-- gradient on the home bottom --> <!-- gradient on the home bottom -->
<item name="vctr_activity_bottom_gradient_color">#80000000</item> <item name="vctr_activity_bottom_gradient_color">#80000000</item>

View file

@ -121,7 +121,10 @@
<!--Header/Panel Text Secondary--> <!--Header/Panel Text Secondary-->
<item name="vctr_list_header_secondary_text_color">#FFC8C8CD</item> <item name="vctr_list_header_secondary_text_color">#FFC8C8CD</item>
<item name="vctr_list_divider_color">@color/list_divider_color_light</item> <item name="vctr_list_bottom_sheet_divider_color">@color/list_divider_color_light</item>
<item name="vctr_list_divider_color">@color/riotx_header_panel_background_light</item>
<item name="vctr_redacted_message_color">@color/list_divider_color_light</item>
<!-- gradient on the home bottom --> <!-- gradient on the home bottom -->
<item name="vctr_activity_bottom_gradient_color">#80ffffff</item> <item name="vctr_activity_bottom_gradient_color">#80ffffff</item>

View file

@ -71,8 +71,6 @@
<item name="vctr_list_header_primary_text_color">#7F3C3C3C</item> <item name="vctr_list_header_primary_text_color">#7F3C3C3C</item>
<item name="vctr_list_header_secondary_text_color">#4D3C3C3C</item> <item name="vctr_list_header_secondary_text_color">#4D3C3C3C</item>
<item name="vctr_list_divider_color">@color/list_divider_color_light</item>
<!-- gradient on the home bottom --> <!-- gradient on the home bottom -->
<item name="vctr_activity_bottom_gradient_color">#80ffffff</item> <item name="vctr_activity_bottom_gradient_color">#80ffffff</item>