Merge branch 'main' into wallet
# Conflicts: # features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesFlowNode.kt # features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesNavigator.kt # features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesNode.kt # features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt # features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/MessageComposerPresenter.kt # features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/suggestions/SuggestionsPickerView.kt # features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/suggestions/SuggestionsProcessor.kt # features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/threads/ThreadedMessagesNode.kt # features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/topbars/MessagesViewTopBar.kt # libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/ResolvedSuggestion.kt
This commit is contained in:
commit
0ef6b69a79
912 changed files with 17051 additions and 4425 deletions
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api
|
||||
|
||||
/**
|
||||
* Provides information about the capabilities of the homeserver.
|
||||
*
|
||||
* Spec: https://spec.matrix.org/latest/client-server-api/#capabilities-negotiation
|
||||
*/
|
||||
interface HomeserverCapabilitiesProvider {
|
||||
/**
|
||||
* Manually refresh the capabilities of the homeserver performing a network request.
|
||||
*/
|
||||
suspend fun refresh(): Result<Unit>
|
||||
|
||||
/**
|
||||
* Indicates whether the homeserver allows the user to change their display name.
|
||||
*/
|
||||
suspend fun canChangeDisplayName(): Result<Boolean>
|
||||
|
||||
/**
|
||||
* Indicates whether the homeserver allows the user to change their avatar URL.
|
||||
*/
|
||||
suspend fun canChangeAvatarUrl(): Result<Boolean>
|
||||
}
|
||||
|
|
@ -225,6 +225,8 @@ interface MatrixClient {
|
|||
* Resets the cached client `well-known` config by the SDK.
|
||||
*/
|
||||
suspend fun resetWellKnownConfig(): Result<Unit>
|
||||
|
||||
fun homeserverCapabilities(): HomeserverCapabilitiesProvider
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.auth
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
|
||||
data class ElementClassicSession(
|
||||
val userId: UserId,
|
||||
val homeserverUrl: String?,
|
||||
val secrets: String?,
|
||||
val roomKeysVersion: String?,
|
||||
val doesContainBackupKey: Boolean,
|
||||
)
|
||||
|
|
@ -14,6 +14,7 @@ import io.element.android.libraries.matrix.api.auth.external.ExternalSession
|
|||
import io.element.android.libraries.matrix.api.auth.qrlogin.MatrixQrCodeLoginData
|
||||
import io.element.android.libraries.matrix.api.auth.qrlogin.QrCodeLoginStep
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
|
||||
interface MatrixAuthenticationService {
|
||||
/**
|
||||
|
|
@ -52,6 +53,20 @@ interface MatrixAuthenticationService {
|
|||
*/
|
||||
suspend fun cancelOidcLogin(): Result<Unit>
|
||||
|
||||
/**
|
||||
* Set the existing data about Element Classic session, if any.
|
||||
*/
|
||||
fun setElementClassicSession(session: ElementClassicSession?)
|
||||
|
||||
/**
|
||||
* Check if the provided secrets from Element Classic session contain a key backup.
|
||||
*/
|
||||
fun doSecretsContainBackupKey(
|
||||
userId: UserId,
|
||||
secrets: String,
|
||||
backupInfo: String,
|
||||
): Boolean
|
||||
|
||||
/**
|
||||
* Attempt to login using the [callbackUrl] provided by the Oidc page.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,6 +27,16 @@ sealed interface RoomIdOrAlias : Parcelable {
|
|||
is Id -> roomId.value
|
||||
is Alias -> roomAlias.value
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun from(id: String): RoomIdOrAlias? {
|
||||
return when {
|
||||
MatrixPatterns.isRoomId(id) -> Id(RoomId(id))
|
||||
MatrixPatterns.isRoomAlias(id) -> Alias(RoomAlias(id))
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun RoomId.toRoomIdOrAlias() = RoomIdOrAlias.Id(this)
|
||||
|
|
|
|||
|
|
@ -17,3 +17,18 @@ interface MxcTools {
|
|||
*/
|
||||
fun mxcUri2FilePath(mxcUri: String): String?
|
||||
}
|
||||
|
||||
/**
|
||||
* "mxc" scheme, including "://". So "mxc://".
|
||||
*/
|
||||
const val MATRIX_CONTENT_URI_SCHEME = "mxc://"
|
||||
|
||||
/**
|
||||
* Return true if the String starts with "mxc://".
|
||||
*/
|
||||
fun String.isMxcUrl() = startsWith(MATRIX_CONTENT_URI_SCHEME)
|
||||
|
||||
/**
|
||||
* Remove the "mxc://" prefix. No op if the String is not a Mxc URL.
|
||||
*/
|
||||
fun String.removeMxcPrefix() = removePrefix(MATRIX_CONTENT_URI_SCHEME)
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ sealed interface NotificationContent {
|
|||
data object PolicyRuleRoom : StateEvent
|
||||
data object PolicyRuleServer : StateEvent
|
||||
data object PolicyRuleUser : StateEvent
|
||||
data object RoomAliases : StateEvent
|
||||
data object RoomAvatar : StateEvent
|
||||
data object RoomCanonicalAlias : StateEvent
|
||||
data object RoomCreate : StateEvent
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import io.element.android.libraries.matrix.api.room.knock.KnockRequest
|
|||
import io.element.android.libraries.matrix.api.room.location.LiveLocationShare
|
||||
import io.element.android.libraries.matrix.api.room.powerlevels.RoomPowerLevelsValues
|
||||
import io.element.android.libraries.matrix.api.room.powerlevels.UserRoleChange
|
||||
import io.element.android.libraries.matrix.api.room.threads.ThreadsListService
|
||||
import io.element.android.libraries.matrix.api.roomdirectory.RoomVisibility
|
||||
import io.element.android.libraries.matrix.api.timeline.Timeline
|
||||
import io.element.android.libraries.matrix.api.widget.MatrixWidgetDriver
|
||||
|
|
@ -44,6 +45,8 @@ interface JoinedRoom : BaseRoom {
|
|||
*/
|
||||
val liveTimeline: Timeline
|
||||
|
||||
val threadsListService: ThreadsListService
|
||||
|
||||
/**
|
||||
* Create a new timeline.
|
||||
* @param createTimelineParams contains parameters about how to filter the timeline. Will also configure the date separators.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ sealed interface StateEventType {
|
|||
data object PolicyRuleServer : StateEventType
|
||||
data object PolicyRuleUser : StateEventType
|
||||
data object CallMember : StateEventType
|
||||
data object RoomAliases : StateEventType
|
||||
data object RoomAvatar : StateEventType
|
||||
data object RoomCanonicalAlias : StateEventType
|
||||
data object RoomCreate : StateEventType
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.room.threads
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.matrix.api.core.EventId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.core.toThreadId
|
||||
import io.element.android.libraries.matrix.api.timeline.item.event.EventContent
|
||||
import io.element.android.libraries.matrix.api.timeline.item.event.ProfileDetails
|
||||
|
||||
@Immutable
|
||||
data class ThreadListItem(
|
||||
val rootEvent: ThreadListItemEvent,
|
||||
val latestEvent: ThreadListItemEvent?,
|
||||
val numberOfReplies: Long,
|
||||
) {
|
||||
val threadId = rootEvent.eventId.toThreadId()
|
||||
}
|
||||
|
||||
@Immutable
|
||||
data class ThreadListItemEvent(
|
||||
val eventId: EventId,
|
||||
val senderId: UserId,
|
||||
val senderProfile: ProfileDetails,
|
||||
val isOwn: Boolean,
|
||||
val content: EventContent?,
|
||||
val timestamp: Long,
|
||||
)
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.room.threads
|
||||
|
||||
sealed interface ThreadListPaginationStatus {
|
||||
data class Idle(
|
||||
val hasMoreToLoad: Boolean,
|
||||
) : ThreadListPaginationStatus
|
||||
|
||||
data object Loading : ThreadListPaginationStatus
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.room.threads
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface ThreadsListService {
|
||||
fun subscribeToItemUpdates(): Flow<List<ThreadListItem>>
|
||||
fun subscribeToPaginationUpdates(): Flow<ThreadListPaginationStatus>
|
||||
suspend fun paginate(): Result<Unit>
|
||||
suspend fun reset(): Result<Unit>
|
||||
fun destroy()
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.timeline
|
||||
|
||||
enum class MsgType {
|
||||
MSG_TYPE_TEXT,
|
||||
MSG_TYPE_EMOTE,
|
||||
|
||||
// For future support
|
||||
MSG_TYPE_SNOW,
|
||||
|
||||
// For future support
|
||||
MSG_TYPE_CONFETTI,
|
||||
}
|
||||
|
|
@ -69,6 +69,8 @@ interface Timeline : AutoCloseable {
|
|||
body: String,
|
||||
htmlBody: String?,
|
||||
intentionalMentions: List<IntentionalMention>,
|
||||
msgType: MsgType = MsgType.MSG_TYPE_TEXT,
|
||||
asPlainText: Boolean = false,
|
||||
): Result<Unit>
|
||||
|
||||
/**
|
||||
|
|
@ -102,6 +104,7 @@ interface Timeline : AutoCloseable {
|
|||
htmlBody: String?,
|
||||
intentionalMentions: List<IntentionalMention>,
|
||||
fromNotification: Boolean = false,
|
||||
msgType: MsgType = MsgType.MSG_TYPE_TEXT,
|
||||
): Result<Unit>
|
||||
|
||||
suspend fun sendImage(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ sealed interface OtherState {
|
|||
data object PolicyRuleRoom : OtherState
|
||||
data object PolicyRuleServer : OtherState
|
||||
data object PolicyRuleUser : OtherState
|
||||
data object RoomAliases : OtherState
|
||||
data class RoomAvatar(val url: String?) : OtherState
|
||||
data object RoomCanonicalAlias : OtherState
|
||||
data object RoomCreate : OtherState
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.core
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Test
|
||||
|
||||
class UserIdTest {
|
||||
@Test
|
||||
fun `valid user id`() {
|
||||
val userId = UserId("@alice:example.org")
|
||||
assertThat(userId.extractedDisplayName).isEqualTo("alice")
|
||||
assertThat(userId.domainName).isEqualTo("example.org")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue