Room list actions: fix some UI issues and render selected notification state
This commit is contained in:
parent
00ca5dc70a
commit
8030c44f44
@ -20,12 +20,17 @@ import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.riotx.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.riotx.core.resources.ColorProvider
|
||||
import im.vector.riotx.features.themes.ThemeUtils
|
||||
|
||||
/**
|
||||
* A action for bottom sheet.
|
||||
@ -43,6 +48,8 @@ abstract class BottomSheetItemAction : VectorEpoxyModel<BottomSheetItemAction.Ho
|
||||
@EpoxyAttribute
|
||||
var expanded = false
|
||||
@EpoxyAttribute
|
||||
var selected = false
|
||||
@EpoxyAttribute
|
||||
var subMenuItem = false
|
||||
@EpoxyAttribute
|
||||
lateinit var listener: View.OnClickListener
|
||||
@ -51,20 +58,30 @@ abstract class BottomSheetItemAction : VectorEpoxyModel<BottomSheetItemAction.Ho
|
||||
holder.view.setOnClickListener {
|
||||
listener.onClick(it)
|
||||
}
|
||||
|
||||
holder.startSpace.isVisible = subMenuItem
|
||||
holder.icon.setImageResource(iconRes)
|
||||
holder.text.setText(textRes)
|
||||
holder.expand.isVisible = showExpand
|
||||
holder.selected.isInvisible = !selected
|
||||
if (showExpand) {
|
||||
holder.expand.setImageResource(if (expanded) R.drawable.ic_material_expand_less_black else R.drawable.ic_material_expand_more_black)
|
||||
val expandDrawable = if (expanded) {
|
||||
ContextCompat.getDrawable(holder.view.context, R.drawable.ic_material_expand_less_black)
|
||||
} else {
|
||||
ContextCompat.getDrawable(holder.view.context, R.drawable.ic_material_expand_more_black)
|
||||
}
|
||||
expandDrawable?.also {
|
||||
val tintColor = ThemeUtils.getColor(holder.view.context, R.attr.riotx_text_secondary)
|
||||
DrawableCompat.setTint(it, tintColor)
|
||||
}
|
||||
holder.text.setCompoundDrawablesWithIntrinsicBounds(null, null, expandDrawable, null)
|
||||
} else {
|
||||
holder.text.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
val startSpace by bind<View>(R.id.action_start_space)
|
||||
val icon by bind<ImageView>(R.id.action_icon)
|
||||
val text by bind<TextView>(R.id.action_title)
|
||||
val expand by bind<ImageView>(R.id.action_expand)
|
||||
val startSpace by bind<View>(R.id.actionStartSpace)
|
||||
val icon by bind<ImageView>(R.id.actionIcon)
|
||||
val text by bind<TextView>(R.id.actionTitle)
|
||||
val selected by bind<ImageView>(R.id.actionSelected)
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Listener, O
|
||||
roomListViewModel.accept(RoomListActions.ChangeRoomNotificationState(quickActions.roomId, RoomNotificationState.MUTE))
|
||||
}
|
||||
is RoomListQuickActions.Settings -> {
|
||||
navigator.openRoomSettings(requireContext(), quickActions.roomId)
|
||||
vectorBaseActivity.notImplemented("Opening room settings")
|
||||
}
|
||||
is RoomListQuickActions.Leave -> {
|
||||
roomListViewModel.accept(RoomListActions.LeaveRoom(quickActions.roomId))
|
||||
|
@ -17,6 +17,7 @@ package im.vector.riotx.features.home.room.list.actions
|
||||
|
||||
import android.view.View
|
||||
import com.airbnb.epoxy.TypedEpoxyController
|
||||
import im.vector.matrix.android.api.session.room.notification.RoomNotificationState
|
||||
import im.vector.riotx.EmojiCompatFontProvider
|
||||
import im.vector.riotx.core.date.VectorDateFormatter
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.BottomSheetItemAction_
|
||||
@ -53,10 +54,12 @@ class RoomListQuickActionsEpoxyController @Inject constructor(private val string
|
||||
bottomSheetItemSeparator {
|
||||
id("notifications_separator")
|
||||
}
|
||||
RoomListQuickActions.NotificationsAllNoisy(roomSummary.roomId).toBottomSheetItem(0)
|
||||
RoomListQuickActions.NotificationsAll(roomSummary.roomId).toBottomSheetItem(1)
|
||||
RoomListQuickActions.NotificationsMentionsOnly(roomSummary.roomId).toBottomSheetItem(2)
|
||||
RoomListQuickActions.NotificationsMute(roomSummary.roomId).toBottomSheetItem(3)
|
||||
|
||||
val selectedRoomState = state.roomNotificationState()
|
||||
RoomListQuickActions.NotificationsAllNoisy(roomSummary.roomId).toBottomSheetItem(0, selectedRoomState)
|
||||
RoomListQuickActions.NotificationsAll(roomSummary.roomId).toBottomSheetItem(1, selectedRoomState)
|
||||
RoomListQuickActions.NotificationsMentionsOnly(roomSummary.roomId).toBottomSheetItem(2, selectedRoomState)
|
||||
RoomListQuickActions.NotificationsMute(roomSummary.roomId).toBottomSheetItem(3, selectedRoomState)
|
||||
|
||||
// Leave
|
||||
bottomSheetItemSeparator {
|
||||
@ -65,9 +68,18 @@ class RoomListQuickActionsEpoxyController @Inject constructor(private val string
|
||||
RoomListQuickActions.Leave(roomSummary.roomId).toBottomSheetItem(5)
|
||||
}
|
||||
|
||||
private fun RoomListQuickActions.toBottomSheetItem(index: Int) {
|
||||
private fun RoomListQuickActions.toBottomSheetItem(index: Int, roomNotificationState: RoomNotificationState? = null) {
|
||||
val selected = when (this) {
|
||||
is RoomListQuickActions.NotificationsAllNoisy -> roomNotificationState == RoomNotificationState.ALL_MESSAGES_NOISY
|
||||
is RoomListQuickActions.NotificationsAll -> roomNotificationState == RoomNotificationState.ALL_MESSAGES
|
||||
is RoomListQuickActions.NotificationsMentionsOnly -> roomNotificationState == RoomNotificationState.MENTIONS_ONLY
|
||||
is RoomListQuickActions.NotificationsMute -> roomNotificationState == RoomNotificationState.MUTE
|
||||
is RoomListQuickActions.Settings,
|
||||
is RoomListQuickActions.Leave -> false
|
||||
}
|
||||
return BottomSheetItemAction_()
|
||||
.id("action_$index")
|
||||
.selected(selected)
|
||||
.iconRes(iconResId)
|
||||
.textRes(titleRes)
|
||||
.listener(View.OnClickListener { listener?.didSelectMenuAction(this) })
|
||||
|
4
vector/src/main/res/drawable/ic_check_white_24dp.xml
Normal file
4
vector/src/main/res/drawable/ic_check_white_24dp.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:viewportHeight="24.0" android:viewportWidth="24.0" android:width="24dp">
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
|
||||
</vector>
|
@ -1,52 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="50dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/layout_horizontal_margin"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingRight="@dimen/layout_horizontal_margin"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<Space
|
||||
android:id="@+id/action_start_space"
|
||||
android:id="@+id/actionStartSpace"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/action_icon"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:id="@+id/actionIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/actionStartSpace"
|
||||
android:scaleType="center"
|
||||
android:tint="?riotx_text_secondary"
|
||||
tools:src="@drawable/ic_delete" />
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/actionStartSpace"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@drawable/ic_room_actions_notifications_all" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/action_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/actionTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="40dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:drawablePadding="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textColor="?riotx_text_secondary"
|
||||
android:textSize="17sp"
|
||||
tools:text="@string/delete" />
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/actionSelected"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@id/actionStartSpace"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_default="wrap"
|
||||
tools:text="zbla azjazjaz s sdkqdskdsqk kqsdkdqsk kdqsksqdk" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/action_expand"
|
||||
android:id="@+id/actionSelected"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:tint="?riotx_text_secondary"
|
||||
android:src="@drawable/ic_check_white_24dp"
|
||||
android:tint="@color/riotx_accent"
|
||||
android:visibility="gone"
|
||||
tools:src="@drawable/ic_material_expand_more_black"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user