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 0df86e09d7..cb7453fd62 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 @@ -40,10 +40,14 @@ data class RoomSummary constructor( val joinedMembersCount: Int? = 0, val invitedMembersCount: Int? = 0, val latestPreviewableEvent: TimelineEvent? = null, + val latestPreviewableContentEvent: TimelineEvent? = null, + val latestPreviewableOriginalContentEvent: TimelineEvent? = null, val otherMemberIds: List = emptyList(), val notificationCount: Int = 0, val highlightCount: Int = 0, val hasUnreadMessages: Boolean = false, + val hasUnreadContentMessages: Boolean = false, + val hasUnreadOriginalContentMessages: Boolean = false, val tags: List = emptyList(), val membership: Membership = Membership.NONE, val versioningState: VersioningState = VersioningState.NONE, @@ -70,7 +74,42 @@ data class RoomSummary constructor( val canStartCall: Boolean get() = joinedMembersCount == 2 + fun scHasUnreadMessages(preferenceProvider: RoomSummaryPreferenceProvider?): Boolean { + if (preferenceProvider == null) { + // Fallback to default + return hasUnreadMessages + } + return when(preferenceProvider.getUnreadKind()) { + UNREAD_KIND_ORIGINAL_CONTENT -> hasUnreadOriginalContentMessages + UNREAD_KIND_CONTENT -> hasUnreadContentMessages + // UNREAD_KIND_DEFAULT + else -> hasUnreadMessages + } + } + + fun scLatestPreviewableEvent(preferenceProvider: RoomSummaryPreferenceProvider?): TimelineEvent? { + if (preferenceProvider == null) { + // Fallback to default + return latestPreviewableEvent + } + return when(preferenceProvider.getUnreadKind()) { + UNREAD_KIND_ORIGINAL_CONTENT -> latestPreviewableOriginalContentEvent + UNREAD_KIND_CONTENT -> latestPreviewableContentEvent + // UNREAD_KIND_DEFAULT + else -> latestPreviewableEvent + } + } + companion object { const val NOT_IN_BREADCRUMBS = -1 + // SC addition + const val UNREAD_KIND_DEFAULT = 0 + const val UNREAD_KIND_CONTENT = 1 + const val UNREAD_KIND_ORIGINAL_CONTENT = 2 + } + + // SC addition + interface RoomSummaryPreferenceProvider { + fun getUnreadKind(): Int } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/summary/RoomSummaryConstants.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/summary/RoomSummaryConstants.kt index 2b0132817d..30908ae36b 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/summary/RoomSummaryConstants.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/summary/RoomSummaryConstants.kt @@ -30,4 +30,35 @@ object RoomSummaryConstants { EventType.STICKER, EventType.REACTION ) + + // SC addition | this is the Element behaviour previous to Element v1.0.7 + val PREVIEWABLE_TYPES_ALL = listOf( + // TODO filter message type (KEY_VERIFICATION_READY, etc.) + EventType.MESSAGE, + EventType.STATE_ROOM_NAME, + EventType.STATE_ROOM_TOPIC, + EventType.STATE_ROOM_AVATAR, + EventType.STATE_ROOM_MEMBER, + EventType.STATE_ROOM_HISTORY_VISIBILITY, + EventType.CALL_INVITE, + EventType.CALL_HANGUP, + EventType.CALL_ANSWER, + EventType.ENCRYPTED, + EventType.STATE_ROOM_ENCRYPTION, + EventType.STATE_ROOM_THIRD_PARTY_INVITE, + EventType.STICKER, + EventType.REACTION, + EventType.STATE_ROOM_CREATE + ) + + // SC addition | no reactions in here + val PREVIEWABLE_ORIGINAL_CONTENT_TYPES = listOf( + // TODO filter message type (KEY_VERIFICATION_READY, etc.) + EventType.MESSAGE, + EventType.CALL_INVITE, + EventType.CALL_HANGUP, + EventType.CALL_ANSWER, + EventType.ENCRYPTED, + EventType.STICKER + ) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt index bd2aba3e54..057f69bbd6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt @@ -34,6 +34,12 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa val latestEvent = roomSummaryEntity.latestPreviewableEvent?.let { timelineEventMapper.map(it, buildReadReceipts = false) } + val latestContentEvent = roomSummaryEntity.latestPreviewableContentEvent?.let { + timelineEventMapper.map(it, buildReadReceipts = false) + } + val latestOriginalContentEvent = roomSummaryEntity.latestPreviewableOriginalContentEvent?.let { + timelineEventMapper.map(it, buildReadReceipts = false) + } // typings are updated through the sync where room summary entity gets updated no matter what, so it's ok get there val typingUsers = typingUsersTracker.getTypingUsers(roomSummaryEntity.roomId) @@ -45,12 +51,16 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa avatarUrl = roomSummaryEntity.avatarUrl ?: "", isDirect = roomSummaryEntity.isDirect, latestPreviewableEvent = latestEvent, + latestPreviewableContentEvent = latestContentEvent, + latestPreviewableOriginalContentEvent = latestOriginalContentEvent, joinedMembersCount = roomSummaryEntity.joinedMembersCount, invitedMembersCount = roomSummaryEntity.invitedMembersCount, otherMemberIds = roomSummaryEntity.otherMemberIds.toList(), highlightCount = roomSummaryEntity.highlightCount, notificationCount = roomSummaryEntity.notificationCount, hasUnreadMessages = roomSummaryEntity.hasUnreadMessages, + hasUnreadContentMessages = roomSummaryEntity.hasUnreadContentMessages, + hasUnreadOriginalContentMessages = roomSummaryEntity.hasUnreadOriginalContentMessages, tags = tags, typingUsers = typingUsers, membership = roomSummaryEntity.membership, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt index d6859f1d3f..c0e43a4038 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt @@ -32,6 +32,8 @@ internal open class RoomSummaryEntity( var name: String? = "", var topic: String? = "", var latestPreviewableEvent: TimelineEventEntity? = null, + var latestPreviewableContentEvent: TimelineEventEntity? = null, + var latestPreviewableOriginalContentEvent: TimelineEventEntity? = null, var heroes: RealmList = RealmList(), var joinedMembersCount: Int? = 0, var invitedMembersCount: Int? = 0, @@ -42,6 +44,8 @@ internal open class RoomSummaryEntity( var highlightCount: Int = 0, var readMarkerId: String? = null, var hasUnreadMessages: Boolean = false, + var hasUnreadContentMessages: Boolean = false, + var hasUnreadOriginalContentMessages: Boolean = false, var tags: RealmList = RealmList(), var userDrafts: UserDraftsEntity? = null, var breadcrumbsIndex: Int = RoomSummary.NOT_IN_BREADCRUMBS, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt index f750735bbb..6ead29e2cb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt @@ -126,6 +126,8 @@ internal class DefaultSetReadMarkersTask @Inject constructor( roomSummary.notificationCount = 0 roomSummary.highlightCount = 0 roomSummary.hasUnreadMessages = false + roomSummary.hasUnreadContentMessages = false + roomSummary.hasUnreadOriginalContentMessages = false } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryEventsHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryEventsHelper.kt index dd71bff436..8da5aa326d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryEventsHelper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryEventsHelper.kt @@ -32,6 +32,24 @@ internal object RoomSummaryEventsHelper { filterEdits = true ) + // SC addition + private val previewFiltersScAll = TimelineEventFilters( + filterTypes = true, + allowedTypes = RoomSummaryConstants.PREVIEWABLE_TYPES_ALL, + filterUseless = true, + filterRedacted = false, + filterEdits = true + ) + + // SC addition + private val previewFiltersScOriginalContent = TimelineEventFilters( + filterTypes = true, + allowedTypes = RoomSummaryConstants.PREVIEWABLE_ORIGINAL_CONTENT_TYPES, + filterUseless = true, + filterRedacted = true, + filterEdits = true + ) + fun getLatestPreviewableEvent(realm: Realm, roomId: String): TimelineEventEntity? { return TimelineEventEntity.latestEvent( realm = realm, @@ -40,4 +58,24 @@ internal object RoomSummaryEventsHelper { filters = previewFilters ) } + + // SC addition + fun getLatestPreviewableEventScAll(realm: Realm, roomId: String): TimelineEventEntity? { + return TimelineEventEntity.latestEvent( + realm = realm, + roomId = roomId, + includesSending = true, + filters = previewFiltersScAll + ) + } + + // SC addition + fun getLatestPreviewableEventScOriginalContent(realm: Realm, roomId: String): TimelineEventEntity? { + return TimelineEventEntity.latestEvent( + realm = realm, + roomId = roomId, + includesSending = true, + filters = previewFiltersScOriginalContent + ) + } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt index 0aac30654a..7acf041f09 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt @@ -97,17 +97,29 @@ internal class RoomSummaryUpdater @Inject constructor( .contains(EventEntityFields.CONTENT, "\"algorithm\":\"$MXCRYPTO_ALGORITHM_MEGOLM\"") .findFirst() - val latestPreviewableEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId) + val latestPreviewableEvent = RoomSummaryEventsHelper.getLatestPreviewableEventScAll(realm, roomId) + val latestPreviewableContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId) + val latestPreviewableOriginalContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEventScOriginalContent(realm, roomId) roomSummaryEntity.hasUnreadMessages = roomSummaryEntity.notificationCount > 0 // avoid this call if we are sure there are unread events || !isEventRead(realm.configuration, userId, roomId, latestPreviewableEvent?.eventId) + roomSummaryEntity.hasUnreadContentMessages = roomSummaryEntity.notificationCount > 0 + // avoid this call if we are sure there are unread events + || (latestPreviewableContentEvent != null + && !isEventRead(realm.configuration, userId, roomId, latestPreviewableContentEvent.eventId)) + roomSummaryEntity.hasUnreadOriginalContentMessages = roomSummaryEntity.notificationCount > 0 + // avoid this call if we are sure there are unread events + || (latestPreviewableOriginalContentEvent != null + && !isEventRead(realm.configuration, userId, roomId, latestPreviewableOriginalContentEvent.eventId)) roomSummaryEntity.displayName = roomDisplayNameResolver.resolve(realm, roomId).toString() roomSummaryEntity.avatarUrl = roomAvatarResolver.resolve(realm, roomId) roomSummaryEntity.name = ContentMapper.map(lastNameEvent?.content).toModel()?.name roomSummaryEntity.topic = ContentMapper.map(lastTopicEvent?.content).toModel()?.topic roomSummaryEntity.latestPreviewableEvent = latestPreviewableEvent + roomSummaryEntity.latestPreviewableContentEvent = latestPreviewableContentEvent + roomSummaryEntity.latestPreviewableOriginalContentEvent = latestPreviewableOriginalContentEvent roomSummaryEntity.canonicalAlias = ContentMapper.map(lastCanonicalAliasEvent?.content).toModel() ?.canonicalAlias diff --git a/vector/src/main/java/im/vector/app/features/home/room/ScSdkPreferences.kt b/vector/src/main/java/im/vector/app/features/home/room/ScSdkPreferences.kt new file mode 100644 index 0000000000..63998fc7f7 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/home/room/ScSdkPreferences.kt @@ -0,0 +1,15 @@ +package im.vector.app.features.home.room + +import android.content.Context +import im.vector.app.features.settings.VectorPreferences +import org.matrix.android.sdk.api.session.room.model.RoomSummary +import javax.inject.Inject + +class ScSdkPreferences @Inject constructor(private val vectorPreferences: VectorPreferences?): RoomSummary.RoomSummaryPreferenceProvider { + + constructor(context: Context?) : this(vectorPreferences = context?.let { VectorPreferences(it) }) + + override fun getUnreadKind(): Int { + return vectorPreferences?.roomUnreadKind() ?: RoomSummary.UNREAD_KIND_DEFAULT + } +} diff --git a/vector/src/main/java/im/vector/app/features/home/room/breadcrumbs/BreadcrumbsController.kt b/vector/src/main/java/im/vector/app/features/home/room/breadcrumbs/BreadcrumbsController.kt index 4e6bb124ad..cf56f6d531 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/breadcrumbs/BreadcrumbsController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/breadcrumbs/BreadcrumbsController.kt @@ -21,11 +21,13 @@ import com.airbnb.epoxy.EpoxyController import im.vector.app.core.epoxy.zeroItem import im.vector.app.core.utils.DebouncedClickListener import im.vector.app.features.home.AvatarRenderer +import im.vector.app.features.home.room.ScSdkPreferences import org.matrix.android.sdk.api.util.toMatrixItem import javax.inject.Inject class BreadcrumbsController @Inject constructor( - private val avatarRenderer: AvatarRenderer + private val avatarRenderer: AvatarRenderer, + private val scSdkPreferences: ScSdkPreferences ) : EpoxyController() { var listener: Listener? = null @@ -62,7 +64,7 @@ class BreadcrumbsController @Inject constructor( matrixItem(it.toMatrixItem()) unreadNotificationCount(it.notificationCount) showHighlighted(it.highlightCount > 0) - hasUnreadMessage(it.hasUnreadMessages) + hasUnreadMessage(it.scHasUnreadMessages(scSdkPreferences)) hasDraft(it.userDrafts.isNotEmpty()) itemClickListener( DebouncedClickListener(View.OnClickListener { _ -> diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt index 6bc1ff7e7d..b4c05e6ece 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt @@ -120,6 +120,7 @@ import im.vector.app.features.crypto.keysbackup.restore.KeysBackupRestoreActivit import im.vector.app.features.crypto.util.toImageRes import im.vector.app.features.crypto.verification.VerificationBottomSheet import im.vector.app.features.home.AvatarRenderer +import im.vector.app.features.home.room.ScSdkPreferences import im.vector.app.features.home.room.detail.composer.TextComposerView import im.vector.app.features.home.room.detail.readreceipts.DisplayReadReceiptsBottomSheet import im.vector.app.features.home.room.detail.timeline.TimelineEventController @@ -1022,7 +1023,7 @@ class RoomDetailFragment @Inject constructor( val inviter = state.asyncInviter() if (summary?.membership == Membership.JOIN) { jumpToBottomView.count = summary.notificationCount - jumpToBottomView.drawBadge = summary.hasUnreadMessages + jumpToBottomView.drawBadge = summary.scHasUnreadMessages(ScSdkPreferences(context)) scrollOnHighlightedEventCallback.timeline = roomDetailViewModel.timeline timelineEventController.update(state) inviteView.visibility = View.GONE diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewState.kt index 2f126dc272..768efaf342 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewState.kt @@ -25,6 +25,7 @@ import com.airbnb.mvrx.MvRxState import com.airbnb.mvrx.Uninitialized import im.vector.app.R import im.vector.app.features.home.RoomListDisplayMode +import im.vector.app.features.home.room.ScSdkPreferences import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.RoomSummary @@ -41,7 +42,8 @@ data class RoomListViewState( val isGroupRoomsExpanded: Boolean = true, val isCombinedRoomsExpanded: Boolean = true, val isLowPriorityRoomsExpanded: Boolean = true, - val isServerNoticeRoomsExpanded: Boolean = true + val isServerNoticeRoomsExpanded: Boolean = true, + val scSdkPreferences: ScSdkPreferences? = null ) : MvRxState { companion object { @@ -57,12 +59,15 @@ data class RoomListViewState( return ROOM_LIST_ROOM_EXPANDED_LOW_PRIORITY_PREFIX + displayMode.toString() } + // SC addition fun initWithContext(context: Context, displayMode: RoomListDisplayMode): RoomListViewState { val sp = getSharedPreferences(context) val pref = getRoomListExpandedLowPriorityPref(displayMode) - return copy(isLowPriorityRoomsExpanded = sp.getBoolean(pref, isLowPriorityRoomsExpanded)) + val scSdkPreferences = ScSdkPreferences(context) + return copy(isLowPriorityRoomsExpanded = sp.getBoolean(pref, isLowPriorityRoomsExpanded), scSdkPreferences = scSdkPreferences) } + // SC addition fun persistWithContext(context: Context, displayMode: RoomListDisplayMode) { val sp = getSharedPreferences(context) val pref = getRoomListExpandedLowPriorityPref(displayMode) @@ -97,7 +102,7 @@ data class RoomListViewState( get() = asyncFilteredRooms.invoke() ?.flatMap { it.value } ?.filter { it.membership == Membership.JOIN } - ?.any { it.hasUnreadMessages } + ?.any { it.scHasUnreadMessages(scSdkPreferences) } ?: false } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index 06cb0172d0..a2715e86b4 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -24,6 +24,7 @@ import im.vector.app.core.epoxy.VectorEpoxyModel import im.vector.app.core.resources.StringProvider import im.vector.app.core.utils.DebouncedClickListener import im.vector.app.features.home.AvatarRenderer +import im.vector.app.features.home.room.ScSdkPreferences import im.vector.app.features.home.room.detail.timeline.format.DisplayableEventFormatter import im.vector.app.features.home.room.typing.TypingHelper import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState @@ -36,7 +37,8 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor private val dateFormatter: VectorDateFormatter, private val stringProvider: StringProvider, private val typingHelper: TypingHelper, - private val avatarRenderer: AvatarRenderer) { + private val avatarRenderer: AvatarRenderer, + private val scSdkPreferences: ScSdkPreferences) { fun create(roomSummary: RoomSummary, roomChangeMembershipStates: Map, @@ -84,7 +86,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor val showSelected = selectedRoomIds.contains(roomSummary.roomId) var latestFormattedEvent: CharSequence = "" var latestEventTime: CharSequence = "" - val latestEvent = roomSummary.latestPreviewableEvent + val latestEvent = roomSummary.scLatestPreviewableEvent(scSdkPreferences) if (latestEvent != null) { latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect.not()) latestEventTime = dateFormatter.format(latestEvent.root.originServerTs, DateFormatKind.ROOM_LIST) @@ -103,7 +105,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor .showSelected(showSelected) .hasFailedSending(roomSummary.hasFailedSending) .unreadNotificationCount(unreadCount) - .hasUnreadMessage(roomSummary.hasUnreadMessages) + .hasUnreadMessage(roomSummary.scHasUnreadMessages(scSdkPreferences)) .hasDraft(roomSummary.userDrafts.isNotEmpty()) .itemLongClickListener { _ -> onLongClick?.invoke(roomSummary) ?: false diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 94fabeff3d..f6ccf1a368 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -29,6 +29,7 @@ import im.vector.app.core.di.DefaultSharedPreferences import im.vector.app.features.homeserver.ServerUrlsRepository import im.vector.app.features.themes.ThemeUtils import org.matrix.android.sdk.api.extensions.tryThis +import org.matrix.android.sdk.api.session.room.model.RoomSummary import timber.log.Timber import javax.inject.Inject @@ -177,6 +178,7 @@ class VectorPreferences @Inject constructor(private val context: Context) { // SC additions private const val SETTINGS_SINGLE_OVERVIEW = "SETTINGS_SINGLE_OVERVIEW" + private const val SETTINGS_ROOM_UNREAD_KIND = "SETTINGS_ROOM_UNREAD_KIND" private const val SETTINGS_UNIMPORTANT_COUNTER_BADGE = "SETTINGS_UNIMPORTANT_COUNTER_BADGE" private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH" @@ -842,10 +844,21 @@ class VectorPreferences @Inject constructor(private val context: Context) { return defaultPrefs.getBoolean(SETTINGS_SECURITY_USE_FLAG_SECURE, false) } + // SC addition fun singleOverview(): Boolean { return defaultPrefs.getBoolean(SETTINGS_SINGLE_OVERVIEW, true) } + // SC addition + fun roomUnreadKind(): Int { + val kind = defaultPrefs.getString(SETTINGS_ROOM_UNREAD_KIND, RoomSummary.UNREAD_KIND_CONTENT.toString()) + return try { + Integer.parseInt(kind!!) + } catch (e: Exception) { + RoomSummary.UNREAD_KIND_CONTENT + } + } + // SC addition fun shouldShowUnimportantCounterBadge(): Boolean { return defaultPrefs.getBoolean(SETTINGS_UNIMPORTANT_COUNTER_BADGE, true) diff --git a/vector/src/main/res/values/arrays_sc.xml b/vector/src/main/res/values/arrays_sc.xml index 2c5305c28e..597d84fd73 100644 --- a/vector/src/main/res/values/arrays_sc.xml +++ b/vector/src/main/res/values/arrays_sc.xml @@ -12,4 +12,15 @@ both + + @string/settings_room_unread_kind_default + @string/settings_room_unread_kind_content + @string/settings_room_unread_kind_original_content + + + 0 + 1 + 2 + + diff --git a/vector/src/main/res/xml/vector_settings_preferences.xml b/vector/src/main/res/xml/vector_settings_preferences.xml index 6d6074bf27..f9650b5b0d 100644 --- a/vector/src/main/res/xml/vector_settings_preferences.xml +++ b/vector/src/main/res/xml/vector_settings_preferences.xml @@ -57,6 +57,14 @@ android:summary="@string/settings_single_overview_summary" android:title="@string/settings_single_overview" /> + +