diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/QueryStringValue.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/QueryStringValue.kt index 4c6b5a9a18..f08c86885d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/QueryStringValue.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/QueryStringValue.kt @@ -21,32 +21,32 @@ package org.matrix.android.sdk.api.query */ sealed interface QueryStringValue { /** - * No condition, i.e. there will be no test on the tested field + * No condition, i.e. there will be no test on the tested field. */ object NoCondition : QueryStringValue /** - * The tested field has to be null + * The tested field has to be null. */ object IsNull : QueryStringValue /** - * The tested field has to be not null + * The tested field has to be not null. */ object IsNotNull : QueryStringValue /** - * The tested field has to be empty + * The tested field has to be empty. */ object IsEmpty : QueryStringValue /** - * The tested field has to not empty + * The tested field has to not empty. */ object IsNotEmpty : QueryStringValue /** - * Interface to check String content + * Interface to check String content. */ sealed interface ContentQueryStringValue : QueryStringValue { val string: String @@ -59,12 +59,12 @@ sealed interface QueryStringValue { data class Equals(override val string: String, override val case: Case = Case.SENSITIVE) : ContentQueryStringValue /** - * The tested field must contain the [string] + * The tested field must contain the [string]. */ data class Contains(override val string: String, override val case: Case = Case.SENSITIVE) : ContentQueryStringValue /** - * Case enum for [ContentQueryStringValue] + * Case enum for [ContentQueryStringValue]. */ enum class Case { /** diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/RoomCategoryFilter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/RoomCategoryFilter.kt index 93decb5c53..c2117adbd3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/RoomCategoryFilter.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/RoomCategoryFilter.kt @@ -17,7 +17,7 @@ package org.matrix.android.sdk.api.query /** - * To filter by Room category + * To filter by Room category. * @see [org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams] */ enum class RoomCategoryFilter { 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 b978feb1e2..1ab23b7a11 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 @@ -28,66 +28,200 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent * It can be retrieved by [org.matrix.android.sdk.api.session.room.Room] and [org.matrix.android.sdk.api.session.room.RoomService] */ data class RoomSummary( + /** + * The roomId of the room. + */ val roomId: String, - // Computed display name + /** + * Computed display name. The value of the state event `m.room.name` if not empty, else can be the value returned + * by [org.matrix.android.sdk.api.RoomDisplayNameFallbackProvider]. + */ val displayName: String = "", + /** + * The value of the live state event `m.room.name`. + */ val name: String = "", + /** + * The value of the live state event `m.room.topic`. + */ val topic: String = "", + /** + * The value of the live state event `m.room.avatar`. + */ val avatarUrl: String = "", + /** + * The value of the live state event `m.room.canonical_alias`. + */ val canonicalAlias: String? = null, + /** + * The list of all the aliases of this room. Content of the live state event `m.room.aliases`. + */ val aliases: List = emptyList(), + /** + * The value of the live state event `m.room.join_rules`. + */ val joinRules: RoomJoinRules? = null, + /** + * True is this room is referenced in the account data `m.direct`. + */ val isDirect: Boolean = false, + /** + * If [isDirect] is true, this is the id of the first other member of this room. + */ val directUserId: String? = null, + /** + * If [isDirect] is true, this it the presence of the first other member of this room. + */ val directUserPresence: UserPresence? = null, + /** + * Number of members who have joined this room. + */ val joinedMembersCount: Int? = 0, + /** + * Number of members who are invited to this room. + */ val invitedMembersCount: Int? = 0, + /** + * Latest [TimelineEvent] which can be displayed in this room. Can be used in the room list. + */ val latestPreviewableEvent: TimelineEvent? = null, + /** + * List of other member ids of this room. + */ val otherMemberIds: List = emptyList(), + /** + * Number of unread message in this room. + */ val notificationCount: Int = 0, + /** + * Number of unread and highlighted message in this room. + */ val highlightCount: Int = 0, + /** + * True if this room has unread messages. + */ val hasUnreadMessages: Boolean = false, + /** + * List of tags in this room. + */ val tags: List = emptyList(), + /** + * Current user membership in this room. + */ val membership: Membership = Membership.NONE, + /** + * Versioning state of this room. + */ val versioningState: VersioningState = VersioningState.NONE, + /** + * Value of `m.fully_read` for this room. + */ val readMarkerId: String? = null, + /** + * Message saved as draft for this room. + */ val userDrafts: List = emptyList(), + /** + * True if this room is encrypted. + */ val isEncrypted: Boolean, + /** + * Timestamp of the `m.room.encryption` state event. + */ val encryptionEventTs: Long?, + /** + * List of users who are currently typing on this room. + */ val typingUsers: List, + /** + * UserId of the user who has invited the current user to this room. + */ val inviterId: String? = null, + /** + * Breadcrumb index, util to sort rooms by last seen. + */ val breadcrumbsIndex: Int = NOT_IN_BREADCRUMBS, + /** + * The room encryption trust level. + * @see [RoomEncryptionTrustLevel] + */ val roomEncryptionTrustLevel: RoomEncryptionTrustLevel? = null, + /** + * True if a message has not been sent in this room. + */ val hasFailedSending: Boolean = false, + /** + * The type of the room. Null for regular room. + * @see [RoomType] + */ val roomType: String? = null, + /** + * List of parent spaces. + */ val spaceParents: List? = null, + /** + * List of children space. + */ val spaceChildren: List? = null, + /** + * List of all the space parents. Will be empty by default, you have to explicitly request it. + */ val flattenParents: List = emptyList(), + /** + * List of all the space parent Ids. + */ val flattenParentIds: List = emptyList(), - val roomEncryptionAlgorithm: RoomEncryptionAlgorithm? = null + /** + * Information about the encryption algorithm, if this room is encrypted. + */ + val roomEncryptionAlgorithm: RoomEncryptionAlgorithm? = null, ) { - + /** + * True if [versioningState] is not [VersioningState.NONE]. + */ val isVersioned: Boolean get() = versioningState != VersioningState.NONE + /** + * True if [notificationCount] is not `0`. + */ val hasNewMessages: Boolean get() = notificationCount != 0 + /** + * True if the room has the tag `m.lowpriority`. + */ val isLowPriority: Boolean get() = hasTag(RoomTag.ROOM_TAG_LOW_PRIORITY) + /** + * True if the room has the tag `m.favourite`. + */ val isFavorite: Boolean get() = hasTag(RoomTag.ROOM_TAG_FAVOURITE) + /** + * True if [joinRules] is [RoomJoinRules.PUBLIC]. + */ val isPublic: Boolean get() = joinRules == RoomJoinRules.PUBLIC + /** + * Test if the room has the provided [tag]. + */ fun hasTag(tag: String) = tags.any { it.name == tag } + /** + * True if a 1-1 call can be started, i.e. the room has exactly 2 joined members. + */ val canStartCall: Boolean get() = joinedMembersCount == 2 companion object { + /** + * Constant to indicated that the room is not on the breadcrumbs. + * Used by [breadcrumbsIndex]. + */ const val NOT_IN_BREADCRUMBS = -1 } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/VersioningState.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/VersioningState.kt index b4e7b10d44..2e1668ebbb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/VersioningState.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/VersioningState.kt @@ -16,8 +16,22 @@ package org.matrix.android.sdk.api.session.room.model +/** + * Enum for the versioning state of a room. + */ enum class VersioningState { + /** + * The room is not versioned. + */ NONE, + + /** + * The room has been upgraded, but the new room is not joined yet. + */ UPGRADED_ROOM_NOT_JOINED, - UPGRADED_ROOM_JOINED + + /** + * The room has been upgraded, and the new room has been joined. + */ + UPGRADED_ROOM_JOINED, }