Merge branch 'develop' into feature/fga/mark_room_as_favorite

This commit is contained in:
ganfra 2024-02-12 17:08:36 +01:00
commit a8bc0cb4ca
538 changed files with 4465 additions and 1639 deletions

View file

@ -31,6 +31,7 @@ import io.element.android.libraries.matrix.api.poll.PollKind
import io.element.android.libraries.matrix.api.room.location.AssetType
import io.element.android.libraries.matrix.api.room.tags.RoomNotableTags
import io.element.android.libraries.matrix.api.timeline.MatrixTimeline
import io.element.android.libraries.matrix.api.timeline.ReceiptType
import io.element.android.libraries.matrix.api.widget.MatrixWidgetDriver
import io.element.android.libraries.matrix.api.widget.MatrixWidgetSettings
import kotlinx.coroutines.flow.Flow
@ -57,6 +58,7 @@ interface MatrixRoom : Closeable {
val isDm: Boolean get() = isDirect && isOneToOne
val roomInfoFlow: Flow<MatrixRoomInfo>
val roomTypingMembersFlow: Flow<List<UserId>>
/**
* The current notable tags as a Flow.
@ -158,6 +160,17 @@ interface MatrixRoom : Closeable {
suspend fun setIsFavorite(isFavorite: Boolean): Result<Unit>
/**
* Reverts a previously set unread flag, and eventually send a Read Receipt.
* @param receiptType The type of receipt to send. If null, no Read Receipt will be sent.
*/
suspend fun markAsRead(receiptType: ReceiptType?): Result<Unit>
/**
* Sets a flag on the room to indicate that the user has explicitly marked it as unread.
*/
suspend fun markAsUnread(): Result<Unit>
/**
* Share a location message in the room.
*

View file

@ -28,9 +28,15 @@ enum class MessageEventType {
KEY_VERIFICATION_KEY,
KEY_VERIFICATION_MAC,
KEY_VERIFICATION_DONE,
REACTION_SENT,
REACTION,
ROOM_ENCRYPTED,
ROOM_MESSAGE,
ROOM_REDACTION,
STICKER
STICKER,
POLL_END,
POLL_RESPONSE,
POLL_START,
UNSTABLE_POLL_END,
UNSTABLE_POLL_RESPONSE,
UNSTABLE_POLL_START,
}

View file

@ -27,7 +27,19 @@ data class RoomMember(
val powerLevel: Long,
val normalizedPowerLevel: Long,
val isIgnored: Boolean,
)
) {
/**
* Disambiguated display name for the RoomMember.
* If the display name is null, the user ID is returned.
* If the display name is ambiguous, the user ID is appended in parentheses.
* Otherwise, the display name is returned.
*/
val disambiguatedDisplayName: String = when {
displayName == null -> userId.value
isNameAmbiguous -> "$displayName ($userId)"
else -> displayName
}
}
enum class RoomMembershipState {
BAN,

View file

@ -28,29 +28,7 @@ import kotlinx.coroutines.flow.onEach
* It lets load rooms on demand and filter them.
*/
interface DynamicRoomList : RoomList {
sealed interface Filter {
/**
* No filter applied.
*/
data object All : Filter
/**
* Filter only the left rooms.
*/
data object AllNonLeft : Filter
/**
* Filter all rooms.
*/
data object None : Filter
/**
* Filter rooms by normalized room name.
*/
data class NormalizedMatchRoomName(val pattern: String) : Filter
}
val currentFilter: StateFlow<Filter>
val currentFilter: StateFlow<RoomListFilter>
val loadedPages: StateFlow<Int>
val pageSize: Int
@ -68,7 +46,7 @@ interface DynamicRoomList : RoomList {
* Update the filter to apply to the list.
* @param filter the filter to apply.
*/
suspend fun updateFilter(filter: Filter)
suspend fun updateFilter(filter: RoomListFilter)
}
/**

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2024 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.matrix.api.roomlist
sealed interface RoomListFilter {
companion object {
fun all(vararg filters: RoomListFilter): RoomListFilter {
return All(filters.toList())
}
fun any(vararg filters: RoomListFilter): RoomListFilter {
return Any(filters.toList())
}
}
data class All(
val filters: List<RoomListFilter>
) : RoomListFilter
data class Any(
val filters: List<RoomListFilter>
) : RoomListFilter
data object NonLeft : RoomListFilter
data object Unread : RoomListFilter
sealed interface Category : RoomListFilter {
data object Group : Category
data object People : Category
}
data object None : RoomListFilter
data class NormalizedMatchRoomName(
val pattern: String
) : RoomListFilter
data class FuzzyMatchRoomName(
val pattern: String
) : RoomListFilter
}

View file

@ -43,6 +43,7 @@ data class RoomSummaryDetails(
val numUnreadMessages: Int,
val numUnreadMentions: Int,
val numUnreadNotifications: Int,
val isMarkedUnread: Boolean,
val inviter: RoomMember?,
val userDefinedNotificationMode: RoomNotificationMode?,
val hasRoomCall: Boolean,

View file

@ -85,11 +85,7 @@ data class ProfileChangeContent(
data class StateContent(
val stateKey: String,
val content: OtherState
) : EventContent {
fun isVisibleInTimeline(): Boolean {
return content.isVisibleInTimeline()
}
}
) : EventContent
data class FailedToParseMessageLikeContent(
val eventType: String,

View file

@ -41,30 +41,4 @@ sealed interface OtherState {
data object SpaceChild : OtherState
data object SpaceParent : OtherState
data class Custom(val eventType: String) : OtherState
fun isVisibleInTimeline() = when (this) {
// Visible
is RoomAvatar,
is RoomName,
is RoomTopic,
is RoomThirdPartyInvite,
is RoomCreate,
is RoomEncryption,
is Custom -> true
// Hidden
is RoomAliases,
is RoomCanonicalAlias,
is RoomGuestAccess,
is RoomHistoryVisibility,
is RoomJoinRules,
is RoomPinnedEvents,
is RoomPowerLevels,
is RoomServerAcl,
is RoomTombstone,
is SpaceChild,
is SpaceParent,
is PolicyRuleRoom,
is PolicyRuleServer,
is PolicyRuleUser -> false
}
}

View file

@ -25,6 +25,7 @@ data class TracingFilterConfiguration(
private val targetsToLogLevel: Map<Target, LogLevel> = mapOf(
Target.HYPER to LogLevel.WARN,
Target.MATRIX_SDK_CRYPTO to LogLevel.DEBUG,
Target.MATRIX_SDK_CRYPTO_ACCOUNT to LogLevel.TRACE,
Target.MATRIX_SDK_HTTP_CLIENT to LogLevel.DEBUG,
Target.MATRIX_SDK_SLIDING_SYNC to LogLevel.TRACE,
Target.MATRIX_SDK_BASE_SLIDING_SYNC to LogLevel.TRACE,
@ -58,6 +59,7 @@ enum class Target(open val filter: String) {
MATRIX_SDK_FFI("matrix_sdk_ffi"),
MATRIX_SDK_UNIFFI_API("matrix_sdk_ffi::uniffi_api"),
MATRIX_SDK_CRYPTO("matrix_sdk_crypto"),
MATRIX_SDK_CRYPTO_ACCOUNT("matrix_sdk_crypto::olm::account"),
MATRIX_SDK("matrix_sdk"),
MATRIX_SDK_HTTP_CLIENT("matrix_sdk::http_client"),
MATRIX_SDK_CLIENT("matrix_sdk::client"),

View file

@ -21,6 +21,7 @@ import java.util.UUID
interface CallWidgetSettingsProvider {
fun provide(
baseUrl: String,
widgetId: String = UUID.randomUUID().toString()
widgetId: String = UUID.randomUUID().toString(),
encrypted: Boolean,
): MatrixWidgetSettings
}