diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/registration/RegistrationFlowResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/registration/RegistrationFlowResponse.kt index 7512454052..dd5a553193 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/registration/RegistrationFlowResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/registration/RegistrationFlowResponse.kt @@ -76,7 +76,7 @@ fun RegistrationFlowResponse.toFlowResult(): FlowResult { this.flows?.forEach { it.stages?.mapTo(allFlowTypes) { type -> type } } allFlowTypes.forEach { type -> - val isMandatory = flows?.all { type in it.stages ?: emptyList() } == true + val isMandatory = flows?.all { type in it.stages.orEmpty() } == true val stage = when (type) { LoginFlowTypes.RECAPTCHA -> Stage.ReCaptcha(isMandatory, ((params?.get(type) as? Map<*, *>)?.get("public_key") as? String) @@ -88,7 +88,7 @@ fun RegistrationFlowResponse.toFlowResult(): FlowResult { else -> Stage.Other(isMandatory, type, (params?.get(type) as? Map<*, *>)) } - if (type in completedStages ?: emptyList()) { + if (type in completedStages.orEmpty()) { completedStage.add(stage) } else { missingStage.add(stage) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt index d529cf4ae5..7badb26d8a 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt @@ -262,7 +262,7 @@ internal class DefaultCryptoService @Inject constructor( override fun onSuccess(data: DevicesListResponse) { // Save in local DB - cryptoStore.saveMyDevicesInfo(data.devices ?: emptyList()) + cryptoStore.saveMyDevicesInfo(data.devices.orEmpty()) callback.onSuccess(data) } } @@ -446,7 +446,7 @@ internal class DefaultCryptoService @Inject constructor( } override fun getCryptoDeviceInfo(userId: String): List { - return cryptoStore.getUserDeviceList(userId) ?: emptyList() + return cryptoStore.getUserDeviceList(userId).orEmpty() } override fun getLiveCryptoDeviceInfo(): LiveData> { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/EnsureOlmSessionsForUsersAction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/EnsureOlmSessionsForUsersAction.kt index 5766ee9980..1d452f4515 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/EnsureOlmSessionsForUsersAction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/EnsureOlmSessionsForUsersAction.kt @@ -34,7 +34,7 @@ internal class EnsureOlmSessionsForUsersAction @Inject constructor(private val o suspend fun handle(users: List): MXUsersDevicesMap { Timber.v("## ensureOlmSessionsForUsers() : ensureOlmSessionsForUsers $users") val devicesByUser = users.associateWith { userId -> - val devices = cryptoStore.getUserDevices(userId)?.values ?: emptyList() + val devices = cryptoStore.getUserDevices(userId)?.values.orEmpty() devices.filter { // Don't bother setting up session to ourself diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt index 59ffa5f874..4c66f63d6a 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt @@ -103,7 +103,7 @@ internal class MXMegolmDecryption(private val userId: String, senderCurve25519Key = olmDecryptionResult.senderKey, claimedEd25519Key = olmDecryptionResult.keysClaimed?.get("ed25519"), forwardingCurve25519KeyChain = olmDecryptionResult.forwardingCurve25519KeyChain - ?: emptyList() + .orEmpty() ) } else { throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_FIELDS, MXCryptoError.MISSING_FIELDS_REASON) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmEncryption.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmEncryption.kt index a9b84a8e48..fc40331af2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmEncryption.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmEncryption.kt @@ -44,7 +44,7 @@ internal class MXOlmEncryption( ensureSession(userIds) val deviceInfos = ArrayList() for (userId in userIds) { - val devices = cryptoStore.getUserDevices(userId)?.values ?: emptyList() + val devices = cryptoStore.getUserDevices(userId)?.values.orEmpty() for (device in devices) { val key = device.identityKey() if (key == olmDevice.deviceCurve25519Key) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt index 7064663995..6af96f886d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt @@ -450,7 +450,7 @@ internal class RealmCryptoStore @Inject constructor( } ) return Transformations.map(liveData) { - it.firstOrNull() ?: emptyList() + it.firstOrNull().orEmpty() } } @@ -480,7 +480,7 @@ internal class RealmCryptoStore @Inject constructor( } ) return Transformations.map(liveData) { - it.firstOrNull() ?: emptyList() + it.firstOrNull().orEmpty() } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/PushRulesMapper.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/PushRulesMapper.kt index a0f644a7cf..4425582a9b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/PushRulesMapper.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/PushRulesMapper.kt @@ -45,7 +45,7 @@ internal object PushRulesMapper { private fun fromActionStr(actionsStr: String?): List { try { - return actionsStr?.let { moshiActionsAdapter.fromJson(it) } ?: emptyList() + return actionsStr?.let { moshiActionsAdapter.fromJson(it) }.orEmpty() } catch (e: Throwable) { Timber.e(e, "## failed to map push rule actions <$actionsStr>") return emptyList() diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt index 20651069b0..9d3da20b0e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt @@ -49,7 +49,7 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa membership = roomSummaryEntity.membership, versioningState = roomSummaryEntity.versioningState, readMarkerId = roomSummaryEntity.readMarkerId, - userDrafts = roomSummaryEntity.userDrafts?.userDrafts?.map { DraftMapper.map(it) } ?: emptyList(), + userDrafts = roomSummaryEntity.userDrafts?.userDrafts?.map { DraftMapper.map(it) }.orEmpty(), canonicalAlias = roomSummaryEntity.canonicalAlias, aliases = roomSummaryEntity.aliases.toList(), isEncrypted = roomSummaryEntity.isEncrypted, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/TimelineEventMapper.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/TimelineEventMapper.kt index 4bd9b9855b..49710e2ade 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/TimelineEventMapper.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/TimelineEventMapper.kt @@ -49,7 +49,7 @@ internal class TimelineEventMapper @Inject constructor(private val readReceiptsS it.user }?.sortedByDescending { it.originServerTs - } ?: emptyList() + }.orEmpty() ) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt index 6e0adccfb9..d6c1a3ada8 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt @@ -131,7 +131,7 @@ internal class RoomSummaryUpdater @Inject constructor( ?.canonicalAlias val roomAliases = ContentMapper.map(lastAliasesEvent?.content).toModel()?.aliases - ?: emptyList() + .orEmpty() roomSummaryEntity.aliases.clear() roomSummaryEntity.aliases.addAll(roomAliases) roomSummaryEntity.flatAliases = roomAliases.joinToString(separator = "|", prefix = "|") diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/draft/DraftRepository.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/draft/DraftRepository.kt index b00bf2aadb..8740567fc8 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/draft/DraftRepository.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/draft/DraftRepository.kt @@ -143,7 +143,7 @@ class DraftRepository @Inject constructor(private val monarchy: Monarchy) { } ) return Transformations.map(liveData) { - it.firstOrNull() ?: emptyList() + it.firstOrNull().orEmpty() } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/read/DefaultReadService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/read/DefaultReadService.kt index 59a7dc4b9c..252c8a31fd 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/read/DefaultReadService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/read/DefaultReadService.kt @@ -111,7 +111,7 @@ internal class DefaultReadService @AssistedInject constructor( { readReceiptsSummaryMapper.map(it) } ) return Transformations.map(liveRealmData) { - it.firstOrNull() ?: emptyList() + it.firstOrNull().orEmpty() } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/UpdateQuickReactionTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/UpdateQuickReactionTask.kt index 6ec316e9a4..9684161c4e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/UpdateQuickReactionTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/UpdateQuickReactionTask.kt @@ -48,7 +48,7 @@ internal class DefaultUpdateQuickReactionTask @Inject constructor(private val mo monarchy.doWithRealm { realm -> res = updateQuickReaction(realm, params.reaction, params.oppositeReaction, params.eventId) } - return UpdateQuickReactionTask.Result(res?.first, res?.second ?: emptyList()) + return UpdateQuickReactionTask.Result(res?.first, res?.second.orEmpty()) } private fun updateQuickReaction(realm: Realm, reaction: String, oppositeReaction: String, eventId: String): Pair?> { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/terms/TermsResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/terms/TermsResponse.kt index 7c6451e3a0..394ee958ac 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/terms/TermsResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/terms/TermsResponse.kt @@ -44,7 +44,7 @@ data class TermsResponse( version = tos[VERSION] as? String ) } - }?.filterNotNull() ?: emptyList() + }?.filterNotNull().orEmpty() } private companion object { diff --git a/vector/src/main/java/im/vector/riotx/features/attachments/preview/AttachmentsPreviewActivity.kt b/vector/src/main/java/im/vector/riotx/features/attachments/preview/AttachmentsPreviewActivity.kt index 6c91f70131..21febd81a9 100644 --- a/vector/src/main/java/im/vector/riotx/features/attachments/preview/AttachmentsPreviewActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/attachments/preview/AttachmentsPreviewActivity.kt @@ -43,7 +43,7 @@ class AttachmentsPreviewActivity : VectorBaseActivity(), ToolbarConfigurable { } fun getOutput(intent: Intent): List { - return intent.getParcelableArrayListExtra(ATTACHMENTS_PREVIEW_RESULT) ?: emptyList() + return intent.getParcelableArrayListExtra(ATTACHMENTS_PREVIEW_RESULT).orEmpty() } fun getKeepOriginalSize(intent: Intent): Boolean { diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewModel.kt b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewModel.kt index 7c5086afa7..9693b6a4ad 100644 --- a/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewModel.kt @@ -151,8 +151,8 @@ class DiscoverySettingsViewModel @AssistedInject constructor( private fun changeThreePidState(threePid: ThreePid, state: Async) { setState { - val currentMails = emailList() ?: emptyList() - val phones = phoneNumbersList() ?: emptyList() + val currentMails = emailList().orEmpty() + val phones = phoneNumbersList().orEmpty() copy( emailList = Success( currentMails.map { @@ -178,8 +178,8 @@ class DiscoverySettingsViewModel @AssistedInject constructor( private fun changeThreePidSubmitState(threePid: ThreePid, submitState: Async) { setState { - val currentMails = emailList() ?: emptyList() - val phones = phoneNumbersList() ?: emptyList() + val currentMails = emailList().orEmpty() + val phones = phoneNumbersList().orEmpty() copy( emailList = Success( currentMails.map { diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt index b17fb87f50..4e5d37af6c 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt @@ -123,12 +123,12 @@ class HomeDetailFragment @Inject constructor( ?.navigator ?.requestSessionVerification(requireContext(), newest.deviceId ?: "") unknownDeviceDetectorSharedViewModel.handle( - UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(newest.deviceId?.let { listOf(it) } ?: emptyList()) + UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(newest.deviceId?.let { listOf(it) }.orEmpty()) ) } dismissedAction = Runnable { unknownDeviceDetectorSharedViewModel.handle( - UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(newest.deviceId?.let { listOf(it) } ?: emptyList()) + UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(newest.deviceId?.let { listOf(it) }.orEmpty()) ) } } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt index 1455e2f8d8..86a9ee678e 100755 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt @@ -382,7 +382,7 @@ class VectorPreferences @Inject constructor(private val context: Context) { fun getUnknownDeviceDismissedList(): List { return tryThis { defaultPrefs.getStringSet(SETTINGS_UNKNOWN_DEVICE_DISMISSED_LIST, null)?.toList() - } ?: emptyList() + }.orEmpty() } /** diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt index 491890de7e..76065b63ea 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt @@ -415,7 +415,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( session.cryptoService().fetchDevicesList(object : MatrixCallback { override fun onSuccess(data: DevicesListResponse) { if (isAdded) { - refreshCryptographyPreference(data.devices ?: emptyList()) + refreshCryptographyPreference(data.devices.orEmpty()) } }