diff --git a/app/src/main/java/com/nextcloud/talk/contacts/ContactsActivityCompose.kt b/app/src/main/java/com/nextcloud/talk/contacts/ContactsActivityCompose.kt index b35ce93c5..d8625af87 100644 --- a/app/src/main/java/com/nextcloud/talk/contacts/ContactsActivityCompose.kt +++ b/app/src/main/java/com/nextcloud/talk/contacts/ContactsActivityCompose.kt @@ -12,6 +12,7 @@ import android.app.Activity import android.content.Context import android.content.Intent import android.os.Bundle +import android.util.Log import androidx.activity.compose.setContent import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box @@ -197,6 +198,8 @@ fun ContactItemRow( fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel) { val searchQuery by contactsViewModel.searchQuery.collectAsState() val searchState = contactsViewModel.searchState.collectAsState() + val addParticipantsUiState = contactsViewModel.addParticipantsUiState.collectAsState() + val conversationToken:String? = null TopAppBar( title = { Text(text = title) }, @@ -217,11 +220,38 @@ fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel Text( text = stringResource(id = R.string.nc_contacts_done), modifier = Modifier.clickable { + for(contacts in contactsViewModel.selectedParticipantsList){ + contacts.let { contact -> + contactsViewModel.addParticipants( + conversationToken, + contact.id!!, + contact.source!! + ) + } + } } ) } } ) + val state = addParticipantsUiState.value + when(state){ + is AddParticipantsUiState.Error -> { + val errorMessage = state.message + Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Text(text = "Error: $errorMessage", color = Color.Red) + } + + } + is AddParticipantsUiState.None -> { + + + } + is AddParticipantsUiState.Success -> { + val conversation = state.participants + Log.d("ContactsActivityCompose", "$conversation") + } + } if (searchState.value) { Row { DisplaySearch( @@ -232,13 +262,6 @@ fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel }, contactsViewModel = contactsViewModel ) - if (contactsViewModel.isAddParticipantsView.value) { - Text( - text = stringResource(id = R.string.nc_contacts_done), - modifier = Modifier.clickable { - } - ) - } } } } diff --git a/app/src/main/java/com/nextcloud/talk/contacts/ContactsRepository.kt b/app/src/main/java/com/nextcloud/talk/contacts/ContactsRepository.kt index b1e224474..e610909c2 100644 --- a/app/src/main/java/com/nextcloud/talk/contacts/ContactsRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/contacts/ContactsRepository.kt @@ -15,5 +15,5 @@ interface ContactsRepository { suspend fun getContacts(searchQuery: String?, shareTypes: List): AutocompleteOverall suspend fun createRoom(roomType: String, sourceType: String, userId: String, conversationName: String?): RoomOverall fun getImageUri(avatarId: String, requestBigSize: Boolean): String - suspend fun addParticipants(conversationToken: String, userId: String, sourceType: String): AddParticipantOverall + suspend fun addParticipants(conversationToken: String?, userId: String, sourceType: String): AddParticipantOverall } diff --git a/app/src/main/java/com/nextcloud/talk/contacts/ContactsRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/contacts/ContactsRepositoryImpl.kt index 8d0af8656..04634ff4c 100644 --- a/app/src/main/java/com/nextcloud/talk/contacts/ContactsRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/contacts/ContactsRepositoryImpl.kt @@ -77,7 +77,7 @@ class ContactsRepositoryImpl( } override suspend fun addParticipants( - conversationToken: String, + conversationToken: String?, userId: String, sourceType: String ): AddParticipantOverall { diff --git a/app/src/main/java/com/nextcloud/talk/contacts/ContactsViewModel.kt b/app/src/main/java/com/nextcloud/talk/contacts/ContactsViewModel.kt index fe553a277..ac0c7596a 100644 --- a/app/src/main/java/com/nextcloud/talk/contacts/ContactsViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/contacts/ContactsViewModel.kt @@ -96,7 +96,7 @@ class ContactsViewModel @Inject constructor( fun getImageUri(avatarId: String, requestBigSize: Boolean): String { return repository.getImageUri(avatarId, requestBigSize) } - fun addParticipants(conversationToken: String, userId: String, sourceType: String) { + fun addParticipants(conversationToken: String?, userId: String, sourceType: String){ viewModelScope.launch { try { val participantsOverall = repository.addParticipants(conversationToken, userId, sourceType) diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index 9b9d74f54..d7ef33ffc 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -79,6 +79,7 @@ import com.nextcloud.talk.api.NcApi import com.nextcloud.talk.application.NextcloudTalkApplication import com.nextcloud.talk.arbitrarystorage.ArbitraryStorageManager import com.nextcloud.talk.chat.ChatActivity +import com.nextcloud.talk.contacts.ContactsActivity import com.nextcloud.talk.contacts.ContactsActivityCompose import com.nextcloud.talk.conversationlist.viewmodels.ConversationsListViewModel import com.nextcloud.talk.data.network.NetworkMonitor @@ -1066,7 +1067,7 @@ class ConversationsListActivity : conversation.type === ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL private fun showNewConversationsScreen() { - val intent = Intent(context, ContactsActivityCompose::class.java) + val intent = Intent(context, ContactsActivity::class.java) intent.putExtra(KEY_NEW_CONVERSATION, true) startActivity(intent) }