From 6d82ac7c5968ca608e6be35bb78f2f037c930346 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 4 Dec 2019 20:22:04 +0100 Subject: [PATCH] Add default param values --- .../src/main/java/im/vector/matrix/rx/RxRoom.kt | 3 ++- .../src/main/java/im/vector/matrix/rx/RxSession.kt | 4 +++- .../android/api/session/room/RoomDirectoryService.kt | 8 ++++++-- .../matrix/android/api/session/room/RoomService.kt | 8 +++++--- .../api/session/room/members/MembershipService.kt | 11 ++++++++--- .../features/home/room/detail/RoomDetailViewModel.kt | 9 +++++---- .../features/home/room/list/RoomListViewModel.kt | 2 +- .../notifications/NotificationBroadcastReceiver.kt | 4 ++-- .../features/roomdirectory/RoomDirectoryViewModel.kt | 2 +- .../roomdirectory/roompreview/RoomPreviewViewModel.kt | 2 +- 10 files changed, 34 insertions(+), 19 deletions(-) diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt index 96f2de9cdc..bc0a866117 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt @@ -57,7 +57,8 @@ class RxRoom(private val room: Room) { room.loadRoomMembersIfNeeded(MatrixCallbackSingle(it)).toSingle(it) } - fun joinRoom(reason: String?, viaServers: List = emptyList()): Single = Single.create { + fun joinRoom(reason: String? = null, + viaServers: List = emptyList()): Single = Single.create { room.join(reason, viaServers, MatrixCallbackSingle(it)).toSingle(it) } diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt index 1ef1c8cadb..5a42dbb804 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt @@ -76,7 +76,9 @@ class RxSession(private val session: Session) { session.searchUsersDirectory(search, limit, excludedUserIds, MatrixCallbackSingle(it)).toSingle(it) } - fun joinRoom(roomId: String, reason: String?, viaServers: List = emptyList()): Single = Single.create { + fun joinRoom(roomId: String, + reason: String? = null, + viaServers: List = emptyList()): Single = Single.create { session.joinRoom(roomId, reason, viaServers, MatrixCallbackSingle(it)).toSingle(it) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomDirectoryService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomDirectoryService.kt index 8d03c70efa..c0e413f83b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomDirectoryService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomDirectoryService.kt @@ -30,12 +30,16 @@ interface RoomDirectoryService { /** * Get rooms from directory */ - fun getPublicRooms(server: String?, publicRoomsParams: PublicRoomsParams, callback: MatrixCallback): Cancelable + fun getPublicRooms(server: String?, + publicRoomsParams: PublicRoomsParams, + callback: MatrixCallback): Cancelable /** * Join a room by id */ - fun joinRoom(roomId: String, reason: String?, callback: MatrixCallback): Cancelable + fun joinRoom(roomId: String, + reason: String? = null, + callback: MatrixCallback): Cancelable /** * Fetches the overall metadata about protocols supported by the homeserver. diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt index 71a9a8e4fa..98abce5898 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt @@ -30,7 +30,8 @@ interface RoomService { /** * Create a room asynchronously */ - fun createRoom(createRoomParams: CreateRoomParams, callback: MatrixCallback): Cancelable + fun createRoom(createRoomParams: CreateRoomParams, + callback: MatrixCallback): Cancelable /** * Join a room by id @@ -39,7 +40,7 @@ interface RoomService { * @param viaServers the servers to attempt to join the room through. One of the servers must be participating in the room. */ fun joinRoom(roomId: String, - reason: String?, + reason: String? = null, viaServers: List = emptyList(), callback: MatrixCallback): Cancelable @@ -71,5 +72,6 @@ interface RoomService { /** * Mark all rooms as read */ - fun markAllAsRead(roomIds: List, callback: MatrixCallback): Cancelable + fun markAllAsRead(roomIds: List, + callback: MatrixCallback): Cancelable } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt index 0f487880b7..b750c5347e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt @@ -52,16 +52,21 @@ interface MembershipService { /** * Invite a user in the room */ - fun invite(userId: String, reason: String?, callback: MatrixCallback): Cancelable + fun invite(userId: String, + reason: String? = null, + callback: MatrixCallback): Cancelable /** * Join the room, or accept an invitation. */ - fun join(reason: String?, viaServers: List = emptyList(), callback: MatrixCallback): Cancelable + fun join(reason: String? = null, + viaServers: List = emptyList(), + callback: MatrixCallback): Cancelable /** * Leave the room, or reject an invitation. */ - fun leave(reason: String?, callback: MatrixCallback): Cancelable + fun leave(reason: String? = null, + callback: MatrixCallback): Cancelable } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt index abdcc46f6a..00a31db455 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt @@ -200,9 +200,10 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro invisibleEventsObservable.accept(action) } - fun getMember(userId: String) : RoomMember? { - return room.getRoomMember(userId) + fun getMember(userId: String): RoomMember? { + return room.getRoomMember(userId) } + /** * Convert a send mode to a draft and save the draft */ @@ -266,7 +267,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro } } session.rx() - .joinRoom(roomId, null, viaServer) + .joinRoom(roomId, viaServers = viaServer) .map { roomId } .execute { copy(tombstoneEventHandling = it) @@ -557,7 +558,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro } private fun handleAcceptInvite() { - room.join(null, callback = object : MatrixCallback {}) + room.join(callback = object : MatrixCallback {}) } private fun handleEditAction(action: RoomDetailAction.EnterEditMode) { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListViewModel.kt index 8e9e76099d..a9ea831723 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListViewModel.kt @@ -123,7 +123,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, ) } - session.getRoom(roomId)?.join(null, emptyList(), object : MatrixCallback { + session.getRoom(roomId)?.join(callback = object : MatrixCallback { override fun onSuccess(data: Unit) { // We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data. // Instead, we wait for the room to be joined diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationBroadcastReceiver.kt b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationBroadcastReceiver.kt index 447137d263..c9dc131b42 100644 --- a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationBroadcastReceiver.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationBroadcastReceiver.kt @@ -74,14 +74,14 @@ class NotificationBroadcastReceiver : BroadcastReceiver() { private fun handleJoinRoom(roomId: String) { activeSessionHolder.getSafeActiveSession()?.let { session -> session.getRoom(roomId) - ?.join(null, emptyList(), object : MatrixCallback {}) + ?.join(callback = object : MatrixCallback {}) } } private fun handleRejectRoom(roomId: String) { activeSessionHolder.getSafeActiveSession()?.let { session -> session.getRoom(roomId) - ?.leave(null, object : MatrixCallback {}) + ?.leave(callback = object : MatrixCallback {}) } } diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/RoomDirectoryViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/RoomDirectoryViewModel.kt index 3f8b6883ab..d89f0e2b99 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/RoomDirectoryViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/RoomDirectoryViewModel.kt @@ -214,7 +214,7 @@ class RoomDirectoryViewModel @AssistedInject constructor(@Assisted initialState: ) } - session.joinRoom(action.roomId, null, emptyList(), object : MatrixCallback { + session.joinRoom(action.roomId, callback = object : MatrixCallback { override fun onSuccess(data: Unit) { // We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data. // Instead, we wait for the room to be joined diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/roompreview/RoomPreviewViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/roompreview/RoomPreviewViewModel.kt index 42659b2b20..54c86537d2 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/roompreview/RoomPreviewViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/roompreview/RoomPreviewViewModel.kt @@ -97,7 +97,7 @@ class RoomPreviewViewModel @AssistedInject constructor(@Assisted initialState: R ) } - session.joinRoom(state.roomId, null, emptyList(), object : MatrixCallback { + session.joinRoom(state.roomId, callback = object : MatrixCallback { override fun onSuccess(data: Unit) { // We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data. // Instead, we wait for the room to be joined