mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-22 04:55:29 +03:00
Created a public conversation
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
2959d8e13a
commit
3db1f72981
4 changed files with 24 additions and 8 deletions
|
@ -67,6 +67,7 @@ import com.nextcloud.talk.contacts.ContactsActivityCompose
|
|||
import com.nextcloud.talk.contacts.RoomUiState
|
||||
import com.nextcloud.talk.contacts.loadImage
|
||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
|
||||
import com.nextcloud.talk.models.json.conversations.ConversationEnums
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -415,6 +416,7 @@ fun ConversationOptions(icon: Int? = null, text: Int, switch: @Composable (() ->
|
|||
@Composable
|
||||
fun CreateConversation(conversationCreationViewModel: ConversationCreationViewModel, context: Context) {
|
||||
val roomUiState by conversationCreationViewModel.roomViewState.collectAsState()
|
||||
val participants = conversationCreationViewModel.selectedParticipants.collectAsState().value.toSet()
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
@ -426,9 +428,9 @@ fun CreateConversation(conversationCreationViewModel: ConversationCreationViewMo
|
|||
Button(
|
||||
onClick = {
|
||||
val roomType = if (conversationCreationViewModel.isGuestsAllowed.value) {
|
||||
"ROOM_TYPE_PUBLIC"
|
||||
ConversationEnums.ConversationType.ROOM_PUBLIC_CALL
|
||||
} else {
|
||||
"ROOM_TYPE_PRIVATE"
|
||||
ConversationEnums.ConversationType.ROOM_GROUP_CALL
|
||||
}
|
||||
conversationCreationViewModel.createRoom(
|
||||
roomType,
|
||||
|
@ -446,6 +448,9 @@ fun CreateConversation(conversationCreationViewModel: ConversationCreationViewMo
|
|||
if (token != null) {
|
||||
conversationCreationViewModel.allowGuests(token, conversationCreationViewModel.isGuestsAllowed.value)
|
||||
}
|
||||
for (participant in participants) {
|
||||
participant.id?.let { conversationCreationViewModel.addParticipants(token, it, participant.source!!) }
|
||||
}
|
||||
val bundle = Bundle()
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, token)
|
||||
val chatIntent = Intent(context, ChatActivity::class.java)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
package com.nextcloud.talk.conversationcreation
|
||||
|
||||
import com.nextcloud.talk.models.json.conversations.ConversationEnums
|
||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||
import com.nextcloud.talk.models.json.generic.GenericOverall
|
||||
import com.nextcloud.talk.models.json.participants.AddParticipantOverall
|
||||
|
@ -17,6 +18,6 @@ interface ConversationCreationRepository {
|
|||
suspend fun renameConversation(roomToken: String, roomNameNew: String?): GenericOverall
|
||||
suspend fun setConversationDescription(roomToken: String, description: String?): GenericOverall
|
||||
suspend fun addParticipants(conversationToken: String?, userId: String, sourceType: String): AddParticipantOverall
|
||||
suspend fun createRoom(roomType: String, conversationName: String?): RoomOverall
|
||||
suspend fun createRoom(roomType: ConversationEnums.ConversationType?, conversationName: String?): RoomOverall
|
||||
fun getImageUri(avatarId: String, requestBigSize: Boolean): String
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ package com.nextcloud.talk.conversationcreation
|
|||
import com.nextcloud.talk.api.NcApiCoroutines
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.models.RetrofitBucket
|
||||
import com.nextcloud.talk.models.json.conversations.ConversationEnums
|
||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||
import com.nextcloud.talk.models.json.generic.GenericOverall
|
||||
import com.nextcloud.talk.models.json.participants.AddParticipantOverall
|
||||
|
@ -87,13 +88,16 @@ class ConversationCreationRepositoryImpl(
|
|||
)
|
||||
}
|
||||
|
||||
override suspend fun createRoom(roomType: String, conversationName: String?): RoomOverall {
|
||||
override suspend fun createRoom(
|
||||
roomType: ConversationEnums.ConversationType?,
|
||||
conversationName: String?
|
||||
): RoomOverall {
|
||||
val retrofitBucket: RetrofitBucket =
|
||||
if (roomType == "ROOM_TYPE_PUBLIC") {
|
||||
if (roomType == ConversationEnums.ConversationType.ROOM_PUBLIC_CALL) {
|
||||
ApiUtils.getRetrofitBucketForCreateRoom(
|
||||
apiVersion,
|
||||
currentUser.baseUrl!!,
|
||||
"ROOM_TYPE_PUBLIC",
|
||||
ROOM_TYPE_PUBLIC,
|
||||
null,
|
||||
null,
|
||||
conversationName
|
||||
|
@ -102,7 +106,7 @@ class ConversationCreationRepositoryImpl(
|
|||
ApiUtils.getRetrofitBucketForCreateRoom(
|
||||
apiVersion,
|
||||
currentUser.baseUrl!!,
|
||||
"ROOM_TYPE_GROUP",
|
||||
ROOM_TYPE_GROUP,
|
||||
null,
|
||||
null,
|
||||
conversationName
|
||||
|
@ -137,4 +141,9 @@ class ConversationCreationRepositoryImpl(
|
|||
|
||||
return AllowGuestsResult(result.ocs!!.meta!!.statusCode == STATUS_CODE_OK && allow)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ROOM_TYPE_PUBLIC = "3"
|
||||
private const val ROOM_TYPE_GROUP = "2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.nextcloud.talk.contacts.AddParticipantsUiState
|
|||
import com.nextcloud.talk.contacts.RoomUiState
|
||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
|
||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||
import com.nextcloud.talk.models.json.conversations.ConversationEnums
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -85,7 +86,7 @@ class ConversationCreationViewModel @Inject constructor(
|
|||
return repository.getImageUri(avatarId, requestBigSize)
|
||||
}
|
||||
|
||||
fun createRoom(roomType: String, conversationName: String?) {
|
||||
fun createRoom(roomType: ConversationEnums.ConversationType?, conversationName: String?) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
val room = repository.createRoom(
|
||||
|
|
Loading…
Reference in a new issue