diff --git a/CHANGES.md b/CHANGES.md index d7bd5da965..563fee9c43 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Features ✨: Improvements 🙌: - Rework sending Event management (#154) - New room creation screen: set topic and avatar in the room creation form (#2078) + - Toggle Low priority tag (#1490) Bugfix 🐛: - Messages encrypted with no way to decrypt after SDK update from 0.18 to 1.0.0 (#2252) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt index f170c098bc..9455a83aff 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt @@ -63,8 +63,13 @@ data class RoomSummary constructor( val hasNewMessages: Boolean get() = notificationCount != 0 + val isLowPriority: Boolean + get() = hasTag(RoomTag.ROOM_TAG_LOW_PRIORITY) + val isFavorite: Boolean - get() = tags.any { it.name == RoomTag.ROOM_TAG_FAVOURITE } + get() = hasTag(RoomTag.ROOM_TAG_FAVOURITE) + + fun hasTag(tag: String) = tags.any { it.name == tag } val canStartCall: Boolean get() = joinedMembersCount == 2 diff --git a/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetRoomPreviewItem.kt b/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetRoomPreviewItem.kt index a495f14b6e..105388d87b 100644 --- a/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetRoomPreviewItem.kt +++ b/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetRoomPreviewItem.kt @@ -44,8 +44,10 @@ abstract class BottomSheetRoomPreviewItem : VectorEpoxyModel(R.id.bottomSheetRoomPreviewAvatar) val roomName by bind(R.id.bottomSheetRoomPreviewName) + val roomLowPriority by bind(R.id.bottomSheetRoomPreviewLowPriority) val roomFavorite by bind(R.id.bottomSheetRoomPreviewFavorite) val roomSettings by bind(R.id.bottomSheetRoomPreviewSettings) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListAction.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListAction.kt index 1b05c3f2fd..4a6c1c16fc 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListAction.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListAction.kt @@ -27,7 +27,7 @@ sealed class RoomListAction : VectorViewModelAction { data class RejectInvitation(val roomSummary: RoomSummary) : RoomListAction() data class FilterWith(val filter: String) : RoomListAction() data class ChangeRoomNotificationState(val roomId: String, val notificationState: RoomNotificationState) : RoomListAction() - data class ToggleFavorite(val roomId: String) : RoomListAction() + data class ToggleTag(val roomId: String, val tag: String) : RoomListAction() data class LeaveRoom(val roomId: String) : RoomListAction() object MarkAllRoomsRead : RoomListAction() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index aa10196956..f1d35a74d5 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -52,6 +52,7 @@ import kotlinx.android.synthetic.main.fragment_room_list.* import org.matrix.android.sdk.api.failure.Failure import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.RoomSummary +import org.matrix.android.sdk.api.session.room.model.tag.RoomTag import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState import javax.inject.Inject @@ -233,7 +234,10 @@ class RoomListFragment @Inject constructor( navigator.openRoomProfile(requireActivity(), quickAction.roomId) } is RoomListQuickActionsSharedAction.Favorite -> { - roomListViewModel.handle(RoomListAction.ToggleFavorite(quickAction.roomId)) + roomListViewModel.handle(RoomListAction.ToggleTag(quickAction.roomId, RoomTag.ROOM_TAG_FAVOURITE)) + } + is RoomListQuickActionsSharedAction.LowPriority -> { + roomListViewModel.handle(RoomListAction.ToggleTag(quickAction.roomId, RoomTag.ROOM_TAG_LOW_PRIORITY)) } is RoomListQuickActionsSharedAction.Leave -> { AlertDialog.Builder(requireContext()) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt index d94a8010ba..3263fb9e03 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt @@ -70,7 +70,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, is RoomListAction.MarkAllRoomsRead -> handleMarkAllRoomsRead() is RoomListAction.LeaveRoom -> handleLeaveRoom(action) is RoomListAction.ChangeRoomNotificationState -> handleChangeNotificationMode(action) - is RoomListAction.ToggleFavorite -> handleToggleFavorite(action) + is RoomListAction.ToggleTag -> handleToggleTag(action) }.exhaustive } @@ -172,18 +172,18 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, }) } - private fun handleToggleFavorite(action: RoomListAction.ToggleFavorite) { + private fun handleToggleTag(action: RoomListAction.ToggleTag) { session.getRoom(action.roomId)?.let { val callback = object : MatrixCallback { override fun onFailure(failure: Throwable) { _viewEvents.post(RoomListViewEvents.Failure(failure)) } } - if (it.roomSummary()?.isFavorite == false) { - // Set favorite tag. We do not handle the order for the moment - it.addTag(RoomTag.ROOM_TAG_FAVOURITE, 0.5, callback) + if (it.roomSummary()?.hasTag(action.tag) == false) { + // Set the tag. We do not handle the order for the moment + it.addTag(action.tag, 0.5, callback) } else { - it.deleteTag(RoomTag.ROOM_TAG_FAVOURITE, callback) + it.deleteTag(action.tag, callback) } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt index ccd38125f9..e3a5db4b97 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt @@ -89,8 +89,9 @@ class RoomListQuickActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), R sharedActionViewModel.post(quickAction) // Do not dismiss for all the actions when (quickAction) { - is RoomListQuickActionsSharedAction.Favorite -> Unit - else -> dismiss() + is RoomListQuickActionsSharedAction.LowPriority -> Unit + is RoomListQuickActionsSharedAction.Favorite -> Unit + else -> dismiss() } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt index ed52dcfdad..ebacdbd1eb 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt @@ -47,9 +47,11 @@ class RoomListQuickActionsEpoxyController @Inject constructor( avatarRenderer(avatarRenderer) matrixItem(roomSummary.toMatrixItem()) stringProvider(stringProvider) + izLowPriority(roomSummary.isLowPriority) izFavorite(roomSummary.isFavorite) settingsClickListener { listener?.didSelectMenuAction(RoomListQuickActionsSharedAction.Settings(roomSummary.roomId)) } favoriteClickListener { listener?.didSelectMenuAction(RoomListQuickActionsSharedAction.Favorite(roomSummary.roomId)) } + lowPriorityClickListener { listener?.didSelectMenuAction(RoomListQuickActionsSharedAction.LowPriority(roomSummary.roomId)) } } // Notifications diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsSharedAction.kt b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsSharedAction.kt index 5ef705d5b0..075dca0c52 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsSharedAction.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsSharedAction.kt @@ -52,6 +52,10 @@ sealed class RoomListQuickActionsSharedAction( R.drawable.ic_room_actions_settings ) + data class LowPriority(val roomId: String) : RoomListQuickActionsSharedAction( + R.string.room_list_quick_actions_low_priority_add, + R.drawable.ic_low_priority_24) + data class Favorite(val roomId: String) : RoomListQuickActionsSharedAction( R.string.room_list_quick_actions_favorite_add, R.drawable.ic_star_24dp) diff --git a/vector/src/main/res/drawable/ic_low_priority_24.xml b/vector/src/main/res/drawable/ic_low_priority_24.xml new file mode 100644 index 0000000000..5beef2f58e --- /dev/null +++ b/vector/src/main/res/drawable/ic_low_priority_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/vector/src/main/res/layout/item_bottom_sheet_room_preview.xml b/vector/src/main/res/layout/item_bottom_sheet_room_preview.xml index 74781468b2..fbd7e45d4f 100644 --- a/vector/src/main/res/layout/item_bottom_sheet_room_preview.xml +++ b/vector/src/main/res/layout/item_bottom_sheet_room_preview.xml @@ -38,11 +38,24 @@ android:textSize="14sp" android:textStyle="bold" app:layout_constraintBottom_toBottomOf="@+id/bottomSheetRoomPreviewAvatar" - app:layout_constraintEnd_toStartOf="@+id/bottomSheetRoomPreviewFavorite" + app:layout_constraintEnd_toStartOf="@+id/bottomSheetRoomPreviewLowPriority" app:layout_constraintStart_toEndOf="@id/bottomSheetRoomPreviewAvatar" app:layout_constraintTop_toTopOf="@id/bottomSheetRoomPreviewAvatar" tools:text="@tools:sample/full_names" /> + + "Settings" "Add to favorites" "Remove from favorites" + "Add to low priority" + "Remove from low priority" "Leave the room" "%1$s made no changes" "You made no changes"