Rename CreateRoomParamsBuilder to CreateRoomParams for clarity

This commit is contained in:
Benoit Marty 2020-07-11 22:15:26 +02:00
parent ded8acc836
commit e097bd8117
12 changed files with 28 additions and 28 deletions

View file

@ -29,7 +29,7 @@ Translations 🗣:
-
SDK API changes ⚠️:
- CreateRoomParams has been replaced by CreateRoomParamsBuilder
- CreateRoomParams has been updated
Build 🧱:
- Upgrade some dependencies

View file

@ -32,7 +32,7 @@ import im.vector.matrix.android.api.session.pushers.Pusher
import im.vector.matrix.android.api.session.room.RoomSummaryQueryParams
import im.vector.matrix.android.api.session.room.members.ChangeMembershipState
import im.vector.matrix.android.api.session.room.model.RoomSummary
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParamsBuilder
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.android.api.session.sync.SyncState
import im.vector.matrix.android.api.session.user.model.User
import im.vector.matrix.android.api.session.widgets.model.Widget
@ -110,7 +110,7 @@ class RxSession(private val session: Session) {
.startWithCallable { session.getThreePids() }
}
fun createRoom(roomParams: CreateRoomParamsBuilder): Single<String> = singleBuilder {
fun createRoom(roomParams: CreateRoomParams): Single<String> = singleBuilder {
session.createRoom(roomParams, it)
}

View file

@ -30,7 +30,7 @@ import im.vector.matrix.android.api.session.events.model.toContent
import im.vector.matrix.android.api.session.room.Room
import im.vector.matrix.android.api.session.room.model.Membership
import im.vector.matrix.android.api.session.room.model.RoomSummary
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParamsBuilder
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.android.api.session.room.roomSummaryQueryParams
import im.vector.matrix.android.api.session.room.timeline.Timeline
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
@ -65,7 +65,7 @@ class CryptoTestHelper(private val mTestHelper: CommonTestHelper) {
val aliceSession = mTestHelper.createAccount(TestConstants.USER_ALICE, defaultSessionParams)
val roomId = mTestHelper.doSync<String> {
aliceSession.createRoom(CreateRoomParamsBuilder().apply { name = "MyRoom" }, it)
aliceSession.createRoom(CreateRoomParams().apply { name = "MyRoom" }, it)
}
if (encryptedRoom) {
@ -286,7 +286,7 @@ class CryptoTestHelper(private val mTestHelper: CommonTestHelper) {
fun createDM(alice: Session, bob: Session): String {
val roomId = mTestHelper.doSync<String> {
alice.createRoom(
CreateRoomParamsBuilder().apply {
CreateRoomParams().apply {
invitedUserIds.add(bob.myUserId)
setDirectMessage()
enableEncryptionIfInvitedUsersSupportIt = true

View file

@ -27,7 +27,7 @@ import im.vector.matrix.android.api.session.crypto.verification.VerificationTran
import im.vector.matrix.android.api.session.crypto.verification.VerificationTxState
import im.vector.matrix.android.api.session.events.model.toModel
import im.vector.matrix.android.api.session.room.model.RoomDirectoryVisibility
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParamsBuilder
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.android.common.CommonTestHelper
import im.vector.matrix.android.common.CryptoTestHelper
import im.vector.matrix.android.common.SessionTestParams
@ -66,7 +66,7 @@ class KeyShareTests : InstrumentedTest {
// Create an encrypted room and add a message
val roomId = mTestHelper.doSync<String> {
aliceSession.createRoom(
CreateRoomParamsBuilder().apply {
CreateRoomParams().apply {
visibility = RoomDirectoryVisibility.PRIVATE
enableEncryption()
},

View file

@ -20,7 +20,7 @@ import androidx.lifecycle.LiveData
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.session.room.members.ChangeMembershipState
import im.vector.matrix.android.api.session.room.model.RoomSummary
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParamsBuilder
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.android.api.util.Cancelable
import im.vector.matrix.android.api.util.Optional
@ -32,7 +32,7 @@ interface RoomService {
/**
* Create a room asynchronously
*/
fun createRoom(createRoomParams: CreateRoomParamsBuilder,
fun createRoom(createRoomParams: CreateRoomParams,
callback: MatrixCallback<String>): Cancelable
/**

View file

@ -22,7 +22,7 @@ import im.vector.matrix.android.api.session.room.model.RoomDirectoryVisibility
import im.vector.matrix.android.api.session.room.model.RoomHistoryVisibility
import im.vector.matrix.android.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
class CreateRoomParamsBuilder {
class CreateRoomParams {
var visibility: RoomDirectoryVisibility? = null
var roomAliasName: String? = null
var name: String? = null

View file

@ -23,7 +23,7 @@ import im.vector.matrix.android.api.session.room.RoomService
import im.vector.matrix.android.api.session.room.RoomSummaryQueryParams
import im.vector.matrix.android.api.session.room.members.ChangeMembershipState
import im.vector.matrix.android.api.session.room.model.RoomSummary
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParamsBuilder
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.android.api.util.Cancelable
import im.vector.matrix.android.api.util.Optional
import im.vector.matrix.android.internal.session.room.alias.GetRoomIdByAliasTask
@ -49,7 +49,7 @@ internal class DefaultRoomService @Inject constructor(
private val taskExecutor: TaskExecutor
) : RoomService {
override fun createRoom(createRoomParams: CreateRoomParamsBuilder, callback: MatrixCallback<String>): Cancelable {
override fun createRoom(createRoomParams: CreateRoomParams, callback: MatrixCallback<String>): Cancelable {
return createRoomTask
.configureWith(createRoomParams) {
this.callback = callback

View file

@ -22,7 +22,7 @@ import im.vector.matrix.android.api.session.events.model.EventType
import im.vector.matrix.android.api.session.events.model.toContent
import im.vector.matrix.android.api.session.identity.IdentityServiceError
import im.vector.matrix.android.api.session.identity.toMedium
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParamsBuilder
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.android.internal.crypto.DeviceListManager
import im.vector.matrix.android.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
import im.vector.matrix.android.internal.di.AuthenticatedIdentity
@ -43,7 +43,7 @@ internal class CreateRoomParamsInternalBuilder @Inject constructor(
private val accessTokenProvider: AccessTokenProvider
) {
suspend fun build(builder: CreateRoomParamsBuilder): CreateRoomBody {
suspend fun build(builder: CreateRoomParams): CreateRoomBody {
val invite3pids = builder.invite3pids
.takeIf { it.isNotEmpty() }
.let {
@ -85,7 +85,7 @@ internal class CreateRoomParamsInternalBuilder @Inject constructor(
)
}
private fun buildHistoryVisibilityEvent(builder: CreateRoomParamsBuilder): Event? {
private fun buildHistoryVisibilityEvent(builder: CreateRoomParams): Event? {
return builder.historyVisibility
?.let {
val contentMap = mapOf("history_visibility" to it)
@ -100,7 +100,7 @@ internal class CreateRoomParamsInternalBuilder @Inject constructor(
/**
* Add the crypto algorithm to the room creation parameters.
*/
private suspend fun buildEncryptionWithAlgorithmEvent(builder: CreateRoomParamsBuilder): Event? {
private suspend fun buildEncryptionWithAlgorithmEvent(builder: CreateRoomParams): Event? {
if (builder.algorithm == null
&& canEnableEncryption(builder)) {
// Enable the encryption
@ -121,7 +121,7 @@ internal class CreateRoomParamsInternalBuilder @Inject constructor(
}
}
private suspend fun canEnableEncryption(builder: CreateRoomParamsBuilder): Boolean {
private suspend fun canEnableEncryption(builder: CreateRoomParams): Boolean {
return (builder.enableEncryptionIfInvitedUsersSupportIt
&& crossSigningService.isCrossSigningVerified()
&& builder.invite3pids.isEmpty())

View file

@ -18,7 +18,7 @@ package im.vector.matrix.android.internal.session.room.create
import com.zhuinden.monarchy.Monarchy
import im.vector.matrix.android.api.session.room.failure.CreateRoomFailure
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParamsBuilder
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.android.internal.database.awaitNotEmptyResult
import im.vector.matrix.android.internal.database.model.RoomEntity
import im.vector.matrix.android.internal.database.model.RoomEntityFields
@ -38,7 +38,7 @@ import org.greenrobot.eventbus.EventBus
import java.util.concurrent.TimeUnit
import javax.inject.Inject
internal interface CreateRoomTask : Task<CreateRoomParamsBuilder, String>
internal interface CreateRoomTask : Task<CreateRoomParams, String>
internal class DefaultCreateRoomTask @Inject constructor(
private val roomAPI: RoomAPI,
@ -52,7 +52,7 @@ internal class DefaultCreateRoomTask @Inject constructor(
private val eventBus: EventBus
) : CreateRoomTask {
override suspend fun execute(params: CreateRoomParamsBuilder): String {
override suspend fun execute(params: CreateRoomParams): String {
val createRoomParams = createRoomParamsInternalBuilder.build(params)
val createRoomResponse = executeRequest<CreateRoomResponse>(eventBus) {
@ -75,7 +75,7 @@ internal class DefaultCreateRoomTask @Inject constructor(
return roomId
}
private suspend fun handleDirectChatCreation(params: CreateRoomParamsBuilder, roomId: String) {
private suspend fun handleDirectChatCreation(params: CreateRoomParams, roomId: String) {
val otherUserId = params.getFirstInvitedUserId()
?: throw IllegalStateException("You can't create a direct room without an invitedUser")

View file

@ -22,7 +22,7 @@ import com.airbnb.mvrx.ViewModelContext
import com.squareup.inject.assisted.Assisted
import com.squareup.inject.assisted.AssistedInject
import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParamsBuilder
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.rx.rx
import im.vector.riotx.core.extensions.exhaustive
import im.vector.riotx.core.platform.VectorViewModel
@ -54,7 +54,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted
}
private fun createRoomAndInviteSelectedUsers(invitees: Set<PendingInvitee>) {
val roomParams = CreateRoomParamsBuilder()
val roomParams = CreateRoomParams()
.apply {
invitees.forEach {
when (it) {

View file

@ -43,7 +43,7 @@ import im.vector.matrix.android.api.session.crypto.verification.VerificationServ
import im.vector.matrix.android.api.session.crypto.verification.VerificationTransaction
import im.vector.matrix.android.api.session.crypto.verification.VerificationTxState
import im.vector.matrix.android.api.session.events.model.LocalEcho
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParamsBuilder
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.android.api.util.MatrixItem
import im.vector.matrix.android.api.util.toMatrixItem
import im.vector.matrix.android.internal.crypto.crosssigning.fromBase64
@ -235,7 +235,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
pendingRequest = Loading()
)
}
val roomParams = CreateRoomParamsBuilder()
val roomParams = CreateRoomParams()
.apply {
invitedUserIds.add(otherUserId)
setDirectMessage()

View file

@ -28,7 +28,7 @@ import com.squareup.inject.assisted.AssistedInject
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.session.room.model.RoomDirectoryVisibility
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParamsBuilder
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.android.api.session.room.model.create.CreateRoomPreset
import im.vector.riotx.core.platform.EmptyViewEvents
import im.vector.riotx.core.platform.VectorViewModel
@ -84,7 +84,7 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted initialState: Cr
copy(asyncCreateRoomRequest = Loading())
}
val createRoomParams = CreateRoomParamsBuilder()
val createRoomParams = CreateRoomParams()
.apply {
name = state.roomName.takeIf { it.isNotBlank() }
// Directory visibility