Fixes after rebase
This commit is contained in:
parent
ddf9e5055e
commit
e8328858ab
117 changed files with 310 additions and 295 deletions
|
|
@ -22,7 +22,7 @@ import javax.crypto.spec.GCMParameterSpec
|
|||
*/
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class AESEncryptionDecryptionService() : EncryptionDecryptionService {
|
||||
class AESEncryptionDecryptionService : EncryptionDecryptionService {
|
||||
override fun createEncryptionCipher(key: SecretKey): Cipher {
|
||||
return Cipher.getInstance(AESEncryptionSpecs.CIPHER_TRANSFORMATION).apply {
|
||||
init(Cipher.ENCRYPT_MODE, key)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ import io.element.android.libraries.matrix.api.core.SessionId
|
|||
import io.element.android.libraries.matrix.api.core.ThreadId
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultDeepLinkCreator @Inject constructor() : DeepLinkCreator {
|
||||
@Inject
|
||||
class DefaultDeepLinkCreator : DeepLinkCreator {
|
||||
override fun create(sessionId: SessionId, roomId: RoomId?, threadId: ThreadId?): String {
|
||||
return buildString {
|
||||
append("$SCHEME://$HOST/")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import io.element.android.libraries.matrix.api.core.ThreadId
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultDeeplinkParser: DeeplinkParser {
|
||||
class DefaultDeeplinkParser : DeeplinkParser {
|
||||
override fun getFromIntent(intent: Intent): DeeplinkData? {
|
||||
return intent
|
||||
.takeIf { it.action == Intent.ACTION_VIEW }
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
/*
|
||||
* Copyright 2022-2024 New Vector 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.di
|
||||
|
||||
abstract class AppScope private constructor()
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import config.BuildTimeConfig
|
||||
import extension.buildConfigFieldStr
|
||||
import extension.setupDependencyInjection
|
||||
|
||||
/*
|
||||
* Copyright 2022-2024 New Vector Ltd.
|
||||
|
|
@ -14,6 +15,8 @@ plugins {
|
|||
alias(libs.plugins.kotlin.serialization)
|
||||
}
|
||||
|
||||
setupDependencyInjection()
|
||||
|
||||
android {
|
||||
namespace = "io.element.android.libraries.matrix.api"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ package io.element.android.libraries.matrix.api.mxc
|
|||
import dev.zacsweers.metro.Inject
|
||||
|
||||
@Inject
|
||||
class MxcTools() {
|
||||
class MxcTools {
|
||||
/**
|
||||
* Regex to match a Matrix Content (mxc://) URI.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ interface ClientBuilderProvider {
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class RustClientBuilderProvider() : ClientBuilderProvider {
|
||||
class RustClientBuilderProvider : ClientBuilderProvider {
|
||||
override fun provide(): ClientBuilder {
|
||||
return ClientBuilder()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import org.matrix.rustcomponents.sdk.sdkGitSha
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class RustSdkMetadata() : SdkMetadata {
|
||||
class RustSdkMetadata : SdkMetadata {
|
||||
override val sdkGitSha: String
|
||||
get() = sdkGitSha()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import org.matrix.rustcomponents.sdk.QrCodeData
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class RustQrCodeLoginDataFactory() : MatrixQrCodeLoginDataFactory {
|
||||
class RustQrCodeLoginDataFactory : MatrixQrCodeLoginDataFactory {
|
||||
override fun parseQrCodeData(data: ByteArray): Result<MatrixQrCodeLoginData> {
|
||||
return runCatchingExceptions { SdkQrCodeLoginData(QrCodeData.fromBytes(data)) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import java.security.KeyStoreException
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultUserCertificatesProvider() : UserCertificatesProvider {
|
||||
class DefaultUserCertificatesProvider : UserCertificatesProvider {
|
||||
/**
|
||||
* Get additional user-installed certificates from the `AndroidCAStore` `Keystore`.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ private const val SECRET_SIZE = 256
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultPassphraseGenerator() : PassphraseGenerator {
|
||||
class DefaultPassphraseGenerator : PassphraseGenerator {
|
||||
override fun generatePassphrase(): String? {
|
||||
val key = ByteArray(size = SECRET_SIZE)
|
||||
SecureRandom().nextBytes(key)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import io.element.android.libraries.matrix.api.permalink.MatrixToConverter
|
|||
*/
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultMatrixToConverter() : MatrixToConverter {
|
||||
class DefaultMatrixToConverter : MatrixToConverter {
|
||||
/**
|
||||
* Try to convert a URL from an element web instance or from a client permalink to a matrix.to url.
|
||||
* To be successfully converted, URL path should contain one of the [SUPPORTED_PATHS].
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.matrix.rustcomponents.sdk.matrixToUserPermalink
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultPermalinkBuilder() : PermalinkBuilder {
|
||||
class DefaultPermalinkBuilder : PermalinkBuilder {
|
||||
override fun permalinkForUser(userId: UserId): Result<String> {
|
||||
if (!MatrixPatterns.isUserId(userId.value)) {
|
||||
return Result.failure(PermalinkBuilderError.InvalidData)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import org.matrix.rustcomponents.sdk.initPlatform
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class RustInitPlatformService() : InitPlatformService {
|
||||
class RustInitPlatformService : InitPlatformService {
|
||||
override fun init(tracingConfiguration: TracingConfiguration) {
|
||||
initPlatform(
|
||||
config = tracingConfiguration.map(),
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ interface TimelineEventTypeFilterFactory {
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class RustTimelineEventTypeFilterFactory() : TimelineEventTypeFilterFactory {
|
||||
class RustTimelineEventTypeFilterFactory : TimelineEventTypeFilterFactory {
|
||||
override fun create(listStateEventType: List<StateEventType>): TimelineEventTypeFilter {
|
||||
return TimelineEventTypeFilter.exclude(
|
||||
listStateEventType.map { stateEventType ->
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import io.element.android.libraries.matrix.api.room.alias.RoomAliasHelper
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultRoomAliasHelper() : RoomAliasHelper {
|
||||
class DefaultRoomAliasHelper : RoomAliasHelper {
|
||||
override fun roomAliasNameFromRoomDisplayName(name: String): String {
|
||||
return org.matrix.rustcomponents.sdk.roomAliasNameFromRoomDisplayName(name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import kotlinx.coroutines.flow.runningFold
|
|||
|
||||
@SingleIn(RoomScope::class)
|
||||
@Inject
|
||||
class RoomMemberProfilesCache() {
|
||||
class RoomMemberProfilesCache {
|
||||
private val cache = MutableStateFlow(mapOf<UserId, RoomMember>())
|
||||
val updateFlow = cache.drop(1).runningFold(0) { acc, _ -> acc + 1 }
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import kotlinx.coroutines.flow.runningFold
|
|||
|
||||
@SingleIn(RoomScope::class)
|
||||
@Inject
|
||||
class RoomNamesCache() {
|
||||
class RoomNamesCache {
|
||||
private val cache = MutableStateFlow(mapOf<RoomIdOrAlias, String?>())
|
||||
val updateFlow = cache.drop(1).runningFold(0) { acc, _ -> acc + 1 }
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import io.element.android.libraries.mediaviewer.impl.gallery.root.MediaGalleryRo
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultMediaGalleryEntryPoint() : MediaGalleryEntryPoint {
|
||||
class DefaultMediaGalleryEntryPoint : MediaGalleryEntryPoint {
|
||||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): MediaGalleryEntryPoint.NodeBuilder {
|
||||
val plugins = ArrayList<Plugin>()
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import io.element.android.libraries.mediaviewer.impl.viewer.MediaViewerNode
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultMediaViewerEntryPoint() : MediaViewerEntryPoint {
|
||||
class DefaultMediaViewerEntryPoint : MediaViewerEntryPoint {
|
||||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): MediaViewerEntryPoint.NodeBuilder {
|
||||
val plugins = ArrayList<Plugin>()
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import io.element.android.libraries.mediaviewer.impl.model.MediaItem
|
|||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
@Inject
|
||||
class MediaItemsPostProcessor() {
|
||||
class MediaItemsPostProcessor {
|
||||
fun process(
|
||||
mediaItems: List<MediaItem>,
|
||||
): GroupedMediaItems {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import io.element.android.libraries.mediaviewer.api.util.FileExtensionExtractor
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class FileExtensionExtractorWithValidation() : FileExtensionExtractor {
|
||||
class FileExtensionExtractorWithValidation : FileExtensionExtractor {
|
||||
override fun extractFromName(name: String): String {
|
||||
val fileExtension = name.substringAfterLast('.', "")
|
||||
// Makes sure the extension is known by the system, otherwise default to binary extension.
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import io.element.android.libraries.mediaviewer.impl.model.eventId
|
|||
* (keyOffset = -1)
|
||||
*/
|
||||
@Inject
|
||||
class PagerKeysHandler() {
|
||||
class PagerKeysHandler {
|
||||
private data class Data(
|
||||
val mediaItems: List<MediaItem>,
|
||||
val keyOffset: Long,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||
@ContributesBinding(AppScope::class)
|
||||
@SingleIn(AppScope::class)
|
||||
@Inject
|
||||
class DefaultOidcActionFlow() : OidcActionFlow {
|
||||
class DefaultOidcActionFlow : OidcActionFlow {
|
||||
private val mutableStateFlow = MutableStateFlow<OidcAction?>(null)
|
||||
|
||||
override fun post(oidcAction: OidcAction) {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ interface ComposablePermissionStateProvider {
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class AccompanistPermissionStateProvider() : ComposablePermissionStateProvider {
|
||||
class AccompanistPermissionStateProvider : ComposablePermissionStateProvider {
|
||||
@Composable
|
||||
override fun provide(permission: String, onPermissionResult: (Boolean) -> Unit): PermissionState {
|
||||
return rememberPermissionState(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import dev.zacsweers.metro.ContributesBinding
|
|||
import dev.zacsweers.metro.Inject
|
||||
import dev.zacsweers.metro.SingleIn
|
||||
import io.element.android.libraries.androidutils.preferences.DefaultPreferencesCorruptionHandlerFactory
|
||||
import io.element.android.libraries.di.ApplicationContext
|
||||
import io.element.android.libraries.di.annotations.ApplicationContext
|
||||
import io.element.android.libraries.preferences.api.store.PreferenceDataStoreFactory
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ interface ReplyMessageExtractor {
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class AndroidReplyMessageExtractor() : ReplyMessageExtractor {
|
||||
class AndroidReplyMessageExtractor : ReplyMessageExtractor {
|
||||
override fun getReplyMessage(intent: Intent): String? {
|
||||
return RemoteInput.getResultsFromIntent(intent)
|
||||
?.getCharSequence(NotificationBroadcastReceiver.KEY_TEXT_REPLY)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import kotlinx.coroutines.flow.SharedFlow
|
|||
|
||||
@SingleIn(AppScope::class)
|
||||
@Inject
|
||||
class DiagnosticPushHandler() {
|
||||
class DiagnosticPushHandler {
|
||||
private val _state = MutableSharedFlow<Unit>()
|
||||
val state: SharedFlow<Unit> = _state
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import kotlinx.coroutines.flow.SharedFlow
|
|||
|
||||
@SingleIn(AppScope::class)
|
||||
@Inject
|
||||
class NotificationClickHandler() {
|
||||
class NotificationClickHandler {
|
||||
private val _state = MutableSharedFlow<Unit>(extraBufferCapacity = 1)
|
||||
val state: SharedFlow<Unit> = _state
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import dev.zacsweers.metro.Inject
|
|||
import io.element.android.libraries.pushproviders.api.PushData
|
||||
|
||||
@Inject
|
||||
class FirebasePushParser() {
|
||||
class FirebasePushParser {
|
||||
fun parse(message: Map<String, String?>): PushData? {
|
||||
val pushDataFirebase = PushDataFirebase(
|
||||
eventId = message["event_id"],
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@ interface GuardServiceStarter {
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class NoopGuardServiceStarter() : GuardServiceStarter
|
||||
class NoopGuardServiceStarter : GuardServiceStarter
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import io.element.android.libraries.pushproviders.api.PushData
|
|||
import kotlinx.serialization.json.Json
|
||||
|
||||
@Inject
|
||||
class UnifiedPushParser() {
|
||||
class UnifiedPushParser {
|
||||
private val json by lazy { Json { ignoreUnknownKeys = true } }
|
||||
|
||||
fun parse(message: ByteArray, clientSecret: String): PushData? {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ data class RegistrationResult(
|
|||
|
||||
@SingleIn(AppScope::class)
|
||||
@Inject
|
||||
class EndpointRegistrationHandler() {
|
||||
class EndpointRegistrationHandler {
|
||||
private val _state = MutableSharedFlow<RegistrationResult>()
|
||||
val state: SharedFlow<RegistrationResult> = _state
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import java.util.UUID
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultPushClientSecretFactory() : PushClientSecretFactory {
|
||||
class DefaultPushClientSecretFactory : PushClientSecretFactory {
|
||||
override fun create(): String {
|
||||
return UUID.randomUUID().toString()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import io.element.android.libraries.roomselect.api.RoomSelectEntryPoint
|
|||
|
||||
@ContributesBinding(SessionScope::class)
|
||||
@Inject
|
||||
class DefaultRoomSelectEntryPoint() : RoomSelectEntryPoint {
|
||||
class DefaultRoomSelectEntryPoint : RoomSelectEntryPoint {
|
||||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): RoomSelectEntryPoint.NodeBuilder {
|
||||
val plugins = ArrayList<Plugin>()
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import io.element.android.libraries.troubleshoot.api.NotificationTroubleShootEnt
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultNotificationTroubleShootEntryPoint() : NotificationTroubleShootEntryPoint {
|
||||
class DefaultNotificationTroubleShootEntryPoint : NotificationTroubleShootEntryPoint {
|
||||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): NotificationTroubleShootEntryPoint.NodeBuilder {
|
||||
val plugins = ArrayList<Plugin>()
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import io.element.android.libraries.troubleshoot.api.PushHistoryEntryPoint
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class DefaultPushHistoryEntryPoint() : PushHistoryEntryPoint {
|
||||
class DefaultPushHistoryEntryPoint : PushHistoryEntryPoint {
|
||||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): PushHistoryEntryPoint.NodeBuilder {
|
||||
val plugins = ArrayList<Plugin>()
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import kotlin.math.sqrt
|
|||
*/
|
||||
@ContributesBinding(RoomScope::class)
|
||||
@Inject
|
||||
class DBovAudioLevelCalculator() : AudioLevelCalculator {
|
||||
class DBovAudioLevelCalculator : AudioLevelCalculator {
|
||||
override fun calculateAudioLevel(buffer: ShortArray): Float {
|
||||
return buffer.rms().dBov().normalize().coerceIn(0f, 1f)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ object VoiceRecorderModule {
|
|||
}
|
||||
|
||||
@Provides
|
||||
fun provideVoiceFileConfig(): VoiceFileConfig =
|
||||
public fun provideVoiceFileConfig(): VoiceFileConfig =
|
||||
VoiceFileConfig(
|
||||
cacheSubdir = "voice_recordings",
|
||||
fileExt = "ogg",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue