Various fixes after merge
- Fix compile - Fix counting chats marked unread - Fix counting chats with unread messages Change-Id: Ibf928c5380a1b7ec25f2c510b97ee4f726fe7c0d
This commit is contained in:
parent
0e601aa8f0
commit
811950cb18
|
@ -49,7 +49,7 @@ interface ReadService {
|
||||||
/**
|
/**
|
||||||
* Mark a room as unread, or remove an existing unread marker.
|
* Mark a room as unread, or remove an existing unread marker.
|
||||||
*/
|
*/
|
||||||
fun setMarkedUnread(markedUnread: Boolean, callback: MatrixCallback<Unit>)
|
suspend fun setMarkedUnread(markedUnread: Boolean)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an event is already read, ie. your read receipt is set on a more recent event.
|
* Check if an event is already read, ie. your read receipt is set on a more recent event.
|
||||||
|
|
|
@ -18,8 +18,11 @@ package org.matrix.android.sdk.api.session.room.summary
|
||||||
|
|
||||||
data class RoomAggregateNotificationCount(
|
data class RoomAggregateNotificationCount(
|
||||||
val notificationCount: Int,
|
val notificationCount: Int,
|
||||||
val highlightCount: Int
|
val highlightCount: Int,
|
||||||
|
val unreadCount: Int,
|
||||||
|
val markedUnreadCount: Int
|
||||||
) {
|
) {
|
||||||
val totalCount = notificationCount + highlightCount
|
val totalCount = notificationCount + highlightCount + markedUnreadCount
|
||||||
val isHighlight = highlightCount > 0
|
val isHighlight = highlightCount > 0
|
||||||
|
val markedUnread = markedUnreadCount > 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ internal class DefaultReadService @AssistedInject constructor(
|
||||||
)
|
)
|
||||||
setReadMarkersTask.execute(taskParams)
|
setReadMarkersTask.execute(taskParams)
|
||||||
// Automatically unset unread marker
|
// Automatically unset unread marker
|
||||||
setMarkedUnreadFlag(false, callback)
|
setMarkedUnreadFlag(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun setReadReceipt(eventId: String) {
|
override suspend fun setReadReceipt(eventId: String) {
|
||||||
|
@ -72,23 +72,19 @@ internal class DefaultReadService @AssistedInject constructor(
|
||||||
setReadMarkersTask.execute(params)
|
setReadMarkersTask.execute(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setMarkedUnread(markedUnread: Boolean, callback: MatrixCallback<Unit>) {
|
override suspend fun setMarkedUnread(markedUnread: Boolean) {
|
||||||
if (markedUnread) {
|
if (markedUnread) {
|
||||||
setMarkedUnreadFlag(true, callback)
|
setMarkedUnreadFlag(true)
|
||||||
} else {
|
} else {
|
||||||
// We want to both remove unread marker and update read receipt position,
|
// We want to both remove unread marker and update read receipt position,
|
||||||
// i.e., we want what markAsRead does
|
// i.e., we want what markAsRead does
|
||||||
markAsRead(ReadService.MarkAsReadParams.READ_RECEIPT, callback)
|
markAsRead(ReadService.MarkAsReadParams.READ_RECEIPT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setMarkedUnreadFlag(markedUnread: Boolean, callback: MatrixCallback<Unit>) {
|
private suspend fun setMarkedUnreadFlag(markedUnread: Boolean) {
|
||||||
val params = SetMarkedUnreadTask.Params(roomId, markedUnread = markedUnread)
|
val params = SetMarkedUnreadTask.Params(roomId, markedUnread = markedUnread)
|
||||||
setMarkedUnreadTask
|
setMarkedUnreadTask.execute(params)
|
||||||
.configureWith(params) {
|
|
||||||
this.callback = callback
|
|
||||||
}
|
|
||||||
.executeBy(taskExecutor)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isEventRead(eventId: String): Boolean {
|
override fun isEventRead(eventId: String): Boolean {
|
||||||
|
|
|
@ -54,9 +54,8 @@ internal class DefaultSetMarkedUnreadTask @Inject constructor(
|
||||||
|
|
||||||
if (isMarkedUnread(monarchy.realmConfiguration, params.roomId) != params.markedUnread) {
|
if (isMarkedUnread(monarchy.realmConfiguration, params.roomId) != params.markedUnread) {
|
||||||
updateDatabase(params.roomId, params.markedUnread)
|
updateDatabase(params.roomId, params.markedUnread)
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver, canRetry = true) {
|
||||||
isRetryable = true
|
accountDataApi.setRoomAccountData(userId, params.roomId, EventType.MARKED_UNREAD, params.markedUnreadContent)
|
||||||
apiCall = accountDataApi.setRoomAccountData(userId, params.roomId, EventType.MARKED_UNREAD, params.markedUnreadContent)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotification
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
import org.matrix.android.sdk.api.util.toOptional
|
import org.matrix.android.sdk.api.util.toOptional
|
||||||
import org.matrix.android.sdk.internal.database.mapper.RoomSummaryMapper
|
import org.matrix.android.sdk.internal.database.mapper.RoomSummaryMapper
|
||||||
|
import org.matrix.android.sdk.internal.database.model.RoomEntityFields
|
||||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
||||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
|
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
|
||||||
import org.matrix.android.sdk.internal.database.query.findByAlias
|
import org.matrix.android.sdk.internal.database.query.findByAlias
|
||||||
|
@ -152,9 +153,14 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
|
||||||
val roomSummariesQuery = roomSummariesQuery(realm, queryParams)
|
val roomSummariesQuery = roomSummariesQuery(realm, queryParams)
|
||||||
val notifCount = roomSummariesQuery.sum(RoomSummaryEntityFields.NOTIFICATION_COUNT).toInt()
|
val notifCount = roomSummariesQuery.sum(RoomSummaryEntityFields.NOTIFICATION_COUNT).toInt()
|
||||||
val highlightCount = roomSummariesQuery.sum(RoomSummaryEntityFields.HIGHLIGHT_COUNT).toInt()
|
val highlightCount = roomSummariesQuery.sum(RoomSummaryEntityFields.HIGHLIGHT_COUNT).toInt()
|
||||||
|
// TODO-SC-merge: respect setting for selecting right field here (HAS_UNREAD_CONTENT_MESSAGES, HAS_UNREAD_MESSAGES, HAS_UNREAD_ORIGINAL_CONTENT_MESSAGES)
|
||||||
|
val unreadCount = roomSummariesQuery(realm, queryParams).equalTo(RoomSummaryEntityFields.HAS_UNREAD_ORIGINAL_CONTENT_MESSAGES, true).count().toInt()
|
||||||
|
val markedUnreadCount = roomSummariesQuery(realm, queryParams).equalTo(RoomSummaryEntityFields.MARKED_UNREAD, true).count().toInt()
|
||||||
notificationCount = RoomAggregateNotificationCount(
|
notificationCount = RoomAggregateNotificationCount(
|
||||||
notifCount,
|
notifCount,
|
||||||
highlightCount
|
highlightCount,
|
||||||
|
unreadCount,
|
||||||
|
markedUnreadCount
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return notificationCount!!
|
return notificationCount!!
|
||||||
|
|
|
@ -128,6 +128,7 @@ abstract class BaseEventItem<H : BaseEventItem.BaseHolder> : VectorEpoxyModel<H>
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
open fun setBubbleLayout(holder: H, bubbleStyle: String, bubbleStyleSetting: String, reverseBubble: Boolean) {
|
open fun setBubbleLayout(holder: H, bubbleStyle: String, bubbleStyleSetting: String, reverseBubble: Boolean) {
|
||||||
|
/* TODO-SC-merge: read receipt layout alignment
|
||||||
val defaultDirection = holder.readReceiptsView.resources.configuration.layoutDirection;
|
val defaultDirection = holder.readReceiptsView.resources.configuration.layoutDirection;
|
||||||
val defaultRtl = defaultDirection == View.LAYOUT_DIRECTION_RTL
|
val defaultRtl = defaultDirection == View.LAYOUT_DIRECTION_RTL
|
||||||
val reverseDirection = if (defaultRtl) View.LAYOUT_DIRECTION_LTR else View.LAYOUT_DIRECTION_RTL
|
val reverseDirection = if (defaultRtl) View.LAYOUT_DIRECTION_LTR else View.LAYOUT_DIRECTION_RTL
|
||||||
|
@ -156,6 +157,7 @@ abstract class BaseEventItem<H : BaseEventItem.BaseHolder> : VectorEpoxyModel<H>
|
||||||
|
|
||||||
// Also set rtl to have members fill from the natural side
|
// Also set rtl to have members fill from the natural side
|
||||||
setFlatRtl(holder.readReceiptsView, if (dualBubbles) reverseDirection else defaultDirection, defaultDirection)
|
setFlatRtl(holder.readReceiptsView, if (dualBubbles) reverseDirection else defaultDirection, defaultDirection)
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,12 +99,6 @@ class RoomListFragment @Inject constructor(
|
||||||
private val adapterInfosList = mutableListOf<SectionAdapterInfo>()
|
private val adapterInfosList = mutableListOf<SectionAdapterInfo>()
|
||||||
private var concatAdapter : ConcatAdapter? = null
|
private var concatAdapter : ConcatAdapter? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
|
|
||||||
context?.let { roomListViewModel.initWithContext(it, roomListParams.displayMode) }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
views.stateView.contentView = views.roomListView
|
views.stateView.contentView = views.roomListView
|
||||||
|
@ -166,9 +160,11 @@ class RoomListFragment @Inject constructor(
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
|
|
||||||
|
/* TODO-SC-merge: remember expand state for priority headers
|
||||||
withState(roomListViewModel) {
|
withState(roomListViewModel) {
|
||||||
state -> context?.let { state.persistWithContext(it, roomListParams.displayMode) }
|
state -> context?.let { state.persistWithContext(it, roomListParams.displayMode) }
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showFailure(throwable: Throwable) {
|
override fun showFailure(throwable: Throwable) {
|
||||||
|
@ -281,7 +277,9 @@ class RoomListFragment @Inject constructor(
|
||||||
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
||||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||||
notificationCount = counts.totalCount,
|
notificationCount = counts.totalCount,
|
||||||
isHighlighted = counts.isHighlight
|
isHighlighted = counts.isHighlight,
|
||||||
|
unread = counts.unreadCount,
|
||||||
|
markedUnread = counts.markedUnread
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
||||||
|
|
|
@ -98,6 +98,7 @@ class RoomListViewModel @Inject constructor(
|
||||||
it.roomTagQueryFilter = RoomTagQueryFilter(true, null, null)
|
it.roomTagQueryFilter = RoomTagQueryFilter(true, null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO-SC why no low priority?
|
||||||
addSection(sections, R.string.bottom_action_people_x) {
|
addSection(sections, R.string.bottom_action_people_x) {
|
||||||
it.memberships = listOf(Membership.JOIN)
|
it.memberships = listOf(Membership.JOIN)
|
||||||
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
|
@ -155,19 +156,31 @@ class RoomListViewModel @Inject constructor(
|
||||||
it.memberships = listOf(Membership.JOIN)
|
it.memberships = listOf(Membership.JOIN)
|
||||||
it.roomCategoryFilter = RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS
|
it.roomCategoryFilter = RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS
|
||||||
}
|
}
|
||||||
|
} else if (initialState.displayMode == RoomListDisplayMode.ALL) {
|
||||||
|
addSection(sections, R.string.invitations_header, true) {
|
||||||
|
it.memberships = listOf(Membership.INVITE)
|
||||||
|
}
|
||||||
|
addSection(sections, R.string.bottom_action_favourites) {
|
||||||
|
it.memberships = listOf(Membership.JOIN)
|
||||||
|
it.roomTagQueryFilter = RoomTagQueryFilter(true, null, null)
|
||||||
|
}
|
||||||
|
addSection(sections, R.string.normal_priority_header) {
|
||||||
|
it.memberships = listOf(Membership.JOIN)
|
||||||
|
it.roomTagQueryFilter = RoomTagQueryFilter(false, false, false)
|
||||||
|
}
|
||||||
|
addSection(sections, R.string.low_priority_header) {
|
||||||
|
it.memberships = listOf(Membership.JOIN)
|
||||||
|
it.roomTagQueryFilter = RoomTagQueryFilter(null, true, null)
|
||||||
|
}
|
||||||
|
addSection(sections, R.string.system_alerts_header) {
|
||||||
|
it.memberships = listOf(Membership.JOIN)
|
||||||
|
it.roomTagQueryFilter = RoomTagQueryFilter(null, null, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sections
|
sections
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initWithContext(context: Context, displayMode: RoomListDisplayMode) {
|
|
||||||
vectorPreferences = VectorPreferences(context)
|
|
||||||
setState {
|
|
||||||
// RoomListViewState.initWithContext
|
|
||||||
this.initWithContext(context, displayMode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun handle(action: RoomListAction) {
|
override fun handle(action: RoomListAction) {
|
||||||
when (action) {
|
when (action) {
|
||||||
is RoomListAction.SelectRoom -> handleSelectRoom(action)
|
is RoomListAction.SelectRoom -> handleSelectRoom(action)
|
||||||
|
@ -362,15 +375,16 @@ class RoomListViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleSetMarkedUnread(action: RoomListAction.SetMarkedUnread) {
|
private fun handleSetMarkedUnread(action: RoomListAction.SetMarkedUnread) {
|
||||||
session.getRoom(action.roomId)?.setMarkedUnread(action.markedUnread, object : MatrixCallback<Unit> {
|
val room = session.getRoom(action.roomId)
|
||||||
override fun onSuccess(data: Unit) {
|
if (room != null) {
|
||||||
_viewEvents.post(RoomListViewEvents.Done)
|
viewModelScope.launch {
|
||||||
}
|
try {
|
||||||
|
room.setMarkedUnread(action.markedUnread)
|
||||||
override fun onFailure(failure: Throwable) {
|
} catch (failure: Exception) {
|
||||||
_viewEvents.post(RoomListViewEvents.Failure(failure))
|
_viewEvents.post(RoomListViewEvents.Failure(failure))
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleLeaveRoom(action: RoomListAction.LeaveRoom) {
|
private fun handleLeaveRoom(action: RoomListAction.LeaveRoom) {
|
||||||
|
|
|
@ -26,6 +26,6 @@ data class RoomsSection(
|
||||||
val sectionName: String,
|
val sectionName: String,
|
||||||
val livePages: LiveData<PagedList<RoomSummary>>,
|
val livePages: LiveData<PagedList<RoomSummary>>,
|
||||||
val isExpanded: MutableLiveData<Boolean> = MutableLiveData(true),
|
val isExpanded: MutableLiveData<Boolean> = MutableLiveData(true),
|
||||||
val notificationCount: MutableLiveData<RoomAggregateNotificationCount> = MutableLiveData(RoomAggregateNotificationCount(0, 0)),
|
val notificationCount: MutableLiveData<RoomAggregateNotificationCount> = MutableLiveData(RoomAggregateNotificationCount(0, 0, 0, 0)),
|
||||||
val notifyOfLocalEcho: Boolean = false
|
val notifyOfLocalEcho: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
|
@ -35,7 +35,10 @@ class SectionHeaderAdapter constructor(
|
||||||
val isExpanded: Boolean = true,
|
val isExpanded: Boolean = true,
|
||||||
val notificationCount: Int = 0,
|
val notificationCount: Int = 0,
|
||||||
val isHighlighted: Boolean = false,
|
val isHighlighted: Boolean = false,
|
||||||
val isHidden: Boolean = true
|
val isHidden: Boolean = true,
|
||||||
|
// SC additions
|
||||||
|
val unread: Int = 0,
|
||||||
|
val markedUnread: Boolean = true
|
||||||
)
|
)
|
||||||
|
|
||||||
lateinit var roomsSectionData: RoomsSectionData
|
lateinit var roomsSectionData: RoomsSectionData
|
||||||
|
@ -84,7 +87,7 @@ class SectionHeaderAdapter constructor(
|
||||||
val expandedArrowDrawable = ContextCompat.getDrawable(binding.root.context, expandedArrowDrawableRes)?.also {
|
val expandedArrowDrawable = ContextCompat.getDrawable(binding.root.context, expandedArrowDrawableRes)?.also {
|
||||||
DrawableCompat.setTint(it, tintColor)
|
DrawableCompat.setTint(it, tintColor)
|
||||||
}
|
}
|
||||||
binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted))
|
binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted, roomsSectionData.unread, roomsSectionData.markedUnread))
|
||||||
binding.roomCategoryTitleView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
|
binding.roomCategoryTitleView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,13 @@ sealed class ActivityOtherThemes(@StyleRes val light: Int,
|
||||||
|
|
||||||
object Launcher : ActivityOtherThemes(
|
object Launcher : ActivityOtherThemes(
|
||||||
R.style.AppTheme_Launcher,
|
R.style.AppTheme_Launcher,
|
||||||
R.style.AppTheme_Launcher
|
R.style.AppTheme_Launcher,
|
||||||
|
R.style.AppTheme_Launcher,
|
||||||
|
R.style.AppTheme_Launcher_SC,
|
||||||
|
R.style.AppTheme_Launcher_SC,
|
||||||
|
R.style.AppTheme_Launcher_SC,
|
||||||
|
R.style.AppTheme_Launcher_SC,
|
||||||
|
R.style.AppTheme_Launcher_SC,
|
||||||
)
|
)
|
||||||
|
|
||||||
object AttachmentsPreview : ActivityOtherThemes(
|
object AttachmentsPreview : ActivityOtherThemes(
|
||||||
|
|
Loading…
Reference in New Issue