mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-18 19:19:33 +01:00
Added intent handling on item click
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
parent
93fa89fb81
commit
b707cebf6f
@ -66,6 +66,9 @@
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewParameterProviderOnFirstParameter" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
|
@ -194,6 +194,7 @@ class ContactItem(
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VIEW_TYPE = FlexibleItemViewType.CONTACT_ITEM
|
||||
private const val FULLY_OPAQUE: Float = 1.0f
|
||||
private const val SEMI_TRANSPARENT: Float = 0.38f
|
||||
}
|
||||
|
@ -6,14 +6,13 @@
|
||||
*/
|
||||
package com.nextcloud.talk.adapters.items
|
||||
|
||||
class FlexibleItemViewType {
|
||||
companion object {
|
||||
const val CONVERSATION_ITEM: Int = 1120391230
|
||||
const val LOAD_MORE_RESULTS_ITEM: Int = 1120391231
|
||||
const val MESSAGE_RESULT_ITEM: Int = 1120391232
|
||||
const val MESSAGES_TEXT_HEADER_ITEM: Int = 1120391233
|
||||
const val POLL_RESULT_HEADER_ITEM: Int = 1120391234
|
||||
const val POLL_RESULT_VOTER_ITEM: Int = 1120391235
|
||||
const val POLL_RESULT_VOTERS_OVERVIEW_ITEM: Int = 1120391236
|
||||
}
|
||||
object FlexibleItemViewType {
|
||||
const val CONVERSATION_ITEM: Int = 1120391230
|
||||
const val LOAD_MORE_RESULTS_ITEM: Int = 1120391231
|
||||
const val MESSAGE_RESULT_ITEM: Int = 1120391232
|
||||
const val MESSAGES_TEXT_HEADER_ITEM: Int = 1120391233
|
||||
const val POLL_RESULT_HEADER_ITEM: Int = 1120391234
|
||||
const val POLL_RESULT_VOTER_ITEM: Int = 1120391235
|
||||
const val POLL_RESULT_VOTERS_OVERVIEW_ITEM: Int = 1120391236
|
||||
const val CONTACT_ITEM: Int = 2131558687
|
||||
}
|
||||
|
@ -12,6 +12,11 @@ import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||
|
||||
interface ContactsRepository {
|
||||
suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall
|
||||
suspend fun createRoom(roomType: String, sourceType: String, userId: String, conversationName: String?): RoomOverall
|
||||
suspend fun createRoom(
|
||||
roomType: String,
|
||||
sourceType: String?,
|
||||
userId: String,
|
||||
conversationName: String?
|
||||
): RoomOverall
|
||||
fun getImageUri(avatarId: String, requestBigSize: Boolean): String
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class ContactsRepositoryImpl(
|
||||
|
||||
override suspend fun createRoom(
|
||||
roomType: String,
|
||||
sourceType: String,
|
||||
sourceType: String?,
|
||||
userId: String,
|
||||
conversationName: String?
|
||||
): RoomOverall {
|
||||
|
@ -87,7 +87,7 @@ class ContactsViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
fun createRoom(roomType: String, sourceType: String, userId: String, conversationName: String?) {
|
||||
fun createRoom(roomType: String, sourceType: String?, userId: String, conversationName: String?) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
val room = repository.createRoom(
|
||||
|
@ -83,6 +83,7 @@ import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.contacts.ContactsActivityCompose
|
||||
import com.nextcloud.talk.contacts.ContactsUiState
|
||||
import com.nextcloud.talk.contacts.ContactsViewModel
|
||||
import com.nextcloud.talk.contacts.RoomUiState
|
||||
import com.nextcloud.talk.conversationlist.viewmodels.ConversationsListViewModel
|
||||
import com.nextcloud.talk.data.network.NetworkMonitor
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
@ -398,6 +399,24 @@ class ConversationsListActivity :
|
||||
}.collect()
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
contactsViewModel.roomViewState.onEach { state ->
|
||||
when (state) {
|
||||
is RoomUiState.Success -> {
|
||||
val conversation = state.conversation
|
||||
val bundle = Bundle()
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, conversation?.token)
|
||||
val chatIntent = Intent(context, ChatActivity::class.java)
|
||||
chatIntent.putExtras(bundle)
|
||||
chatIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
startActivity(chatIntent)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}.collect()
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
contactsViewModel.contactsViewState.onEach { state ->
|
||||
when (state) {
|
||||
@ -1304,6 +1323,16 @@ class ConversationsListActivity :
|
||||
ConversationItem.VIEW_TYPE -> {
|
||||
handleConversation((Objects.requireNonNull(item) as ConversationItem).model)
|
||||
}
|
||||
|
||||
ContactItem.VIEW_TYPE -> {
|
||||
val contact = item as ContactItem
|
||||
contactsViewModel.createRoom(
|
||||
"1",
|
||||
null,
|
||||
contact.model.actorId!!,
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user