repo created
This commit is contained in:
commit
93184d21d1
1403 changed files with 189511 additions and 0 deletions
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import autodagger.AutoInjector
|
||||
import com.nextcloud.talk.activities.BaseActivity
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.components.ColoredStatusBar
|
||||
import com.nextcloud.talk.contacts.CompanionClass.Companion.KEY_HIDE_ALREADY_EXISTING_PARTICIPANTS
|
||||
import com.nextcloud.talk.extensions.getParcelableArrayListExtraProvider
|
||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
import javax.inject.Inject
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class ContactsActivity : BaseActivity() {
|
||||
|
||||
@Inject
|
||||
lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||
private lateinit var contactsViewModel: ContactsViewModel
|
||||
|
||||
@SuppressLint("UnrememberedMutableState")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||
contactsViewModel = ViewModelProvider(this, viewModelFactory)[ContactsViewModel::class.java]
|
||||
setContent {
|
||||
val isAddParticipants = intent.getBooleanExtra(BundleKeys.KEY_ADD_PARTICIPANTS, false)
|
||||
val hideAlreadyAddedParticipants = intent.getBooleanExtra(KEY_HIDE_ALREADY_EXISTING_PARTICIPANTS, false)
|
||||
contactsViewModel.updateIsAddParticipants(isAddParticipants)
|
||||
contactsViewModel.hideAlreadyAddedParticipants(hideAlreadyAddedParticipants)
|
||||
if (isAddParticipants) {
|
||||
contactsViewModel.updateShareTypes(
|
||||
listOf(
|
||||
ShareType.Group.shareType,
|
||||
ShareType.Email.shareType,
|
||||
ShareType.Circle.shareType
|
||||
)
|
||||
)
|
||||
contactsViewModel.getContactsFromSearchParams()
|
||||
}
|
||||
val colorScheme = viewThemeUtils.getColorScheme(this)
|
||||
val uiState = contactsViewModel.contactsViewState.collectAsStateWithLifecycle()
|
||||
|
||||
val selectedParticipants = remember {
|
||||
intent?.getParcelableArrayListExtraProvider<AutocompleteUser>("selectedParticipants")
|
||||
?: emptyList()
|
||||
}.toSet().toMutableList()
|
||||
contactsViewModel.updateSelectedParticipants(selectedParticipants)
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme
|
||||
) {
|
||||
ColoredStatusBar()
|
||||
ContactsScreen(
|
||||
contactsViewModel = contactsViewModel,
|
||||
uiState = uiState.value
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CompanionClass {
|
||||
companion object {
|
||||
internal val TAG = ContactsActivity::class.simpleName
|
||||
internal const val ROOM_TYPE_ONE_ONE = "1"
|
||||
const val KEY_HIDE_ALREADY_EXISTING_PARTICIPANTS: String = "KEY_HIDE_ALREADY_EXISTING_PARTICIPANTS"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Your Name <your@email.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts
|
||||
|
||||
import android.app.Application
|
||||
import coil.ImageLoader
|
||||
import coil.ImageLoaderFactory
|
||||
import coil.disk.DiskCache
|
||||
import coil.memory.MemoryCache
|
||||
import coil.util.DebugLogger
|
||||
import com.nextcloud.talk.utils.ContactUtils
|
||||
|
||||
class ContactsApplication :
|
||||
Application(),
|
||||
ImageLoaderFactory {
|
||||
override fun newImageLoader(): ImageLoader {
|
||||
val imageLoader = ImageLoader.Builder(this)
|
||||
.memoryCache {
|
||||
MemoryCache.Builder(this)
|
||||
.maxSizePercent(ContactUtils.CACHE_MEMORY_SIZE_PERCENTAGE)
|
||||
.build()
|
||||
}
|
||||
.diskCache {
|
||||
DiskCache.Builder()
|
||||
.maxSizePercent(ContactUtils.CACHE_DISK_SIZE_PERCENTAGE)
|
||||
.directory(cacheDir)
|
||||
.build()
|
||||
}
|
||||
.logger(DebugLogger())
|
||||
.build()
|
||||
return imageLoader
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts
|
||||
|
||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteOverall
|
||||
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
|
||||
fun getImageUri(avatarId: String, requestBigSize: Boolean): String
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts
|
||||
|
||||
import android.util.Log
|
||||
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.autocomplete.AutocompleteOverall
|
||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.ContactUtils
|
||||
import com.nextcloud.talk.utils.NoSupportedApiException
|
||||
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||
import javax.inject.Inject
|
||||
|
||||
class ContactsRepositoryImpl @Inject constructor(
|
||||
private val ncApiCoroutines: NcApiCoroutines,
|
||||
currentUserProvider: CurrentUserProviderNew
|
||||
) : ContactsRepository {
|
||||
|
||||
private val _currentUser = currentUserProvider.currentUser.blockingGet()
|
||||
val currentUser: User = _currentUser
|
||||
val credentials = ApiUtils.getCredentials(_currentUser.username, _currentUser.token)
|
||||
|
||||
override suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall {
|
||||
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForContactsSearchFor14(
|
||||
currentUser.baseUrl!!,
|
||||
searchQuery
|
||||
)
|
||||
|
||||
val modifiedQueryMap: HashMap<String, Any> = HashMap(retrofitBucket.queryMap)
|
||||
modifiedQueryMap["limit"] = ContactUtils.MAX_CONTACT_LIMIT
|
||||
modifiedQueryMap["shareTypes[]"] = shareTypes
|
||||
val response = ncApiCoroutines.getContactsWithSearchParam(
|
||||
credentials,
|
||||
retrofitBucket.url,
|
||||
shareTypes,
|
||||
modifiedQueryMap
|
||||
)
|
||||
return response
|
||||
}
|
||||
|
||||
override suspend fun createRoom(
|
||||
roomType: String,
|
||||
sourceType: String?,
|
||||
userId: String,
|
||||
conversationName: String?
|
||||
): RoomOverall {
|
||||
val apiVersion =
|
||||
try {
|
||||
ApiUtils.getConversationApiVersion(_currentUser, intArrayOf(ApiUtils.API_V4, 1))
|
||||
} catch (e: NoSupportedApiException) {
|
||||
// There were crash reports for:
|
||||
// Exception java.lang.RuntimeException:
|
||||
// ...
|
||||
// Caused by com.nextcloud.talk.utils.NoSupportedApiException:
|
||||
// at com.nextcloud.talk.utils.ApiUtils.getConversationApiVersion (ApiUtils.kt:134)
|
||||
// at com.nextcloud.talk.contacts.ContactsRepositoryImpl.<init> (ContactsRepositoryImpl.kt:28)
|
||||
//
|
||||
// This could happen because of missing capabilities for user and should be fixed.
|
||||
// As a fallback, API v4 is guessed
|
||||
|
||||
Log.e(TAG, "Failed to get an Api version for conversation.", e)
|
||||
ApiUtils.API_V4
|
||||
}
|
||||
|
||||
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||
version = apiVersion,
|
||||
baseUrl = _currentUser.baseUrl,
|
||||
roomType = roomType,
|
||||
source = sourceType,
|
||||
invite = userId,
|
||||
conversationName = conversationName
|
||||
)
|
||||
val response = ncApiCoroutines.createRoom(
|
||||
credentials,
|
||||
retrofitBucket.url,
|
||||
retrofitBucket.queryMap
|
||||
)
|
||||
return response
|
||||
}
|
||||
|
||||
override fun getImageUri(avatarId: String, requestBigSize: Boolean): String =
|
||||
ApiUtils.getUrlForAvatar(
|
||||
_currentUser.baseUrl,
|
||||
avatarId,
|
||||
requestBigSize
|
||||
)
|
||||
|
||||
companion object {
|
||||
private val TAG = ContactsRepositoryImpl::class.simpleName
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.displayCutoutPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.contacts.components.ContactsAppBar
|
||||
import com.nextcloud.talk.contacts.components.ContactsList
|
||||
import com.nextcloud.talk.contacts.components.ContactsSearchAppBar
|
||||
import com.nextcloud.talk.contacts.components.ConversationCreationOptions
|
||||
|
||||
@Composable
|
||||
fun ContactsScreen(contactsViewModel: ContactsViewModel, uiState: ContactsUiState) {
|
||||
val searchQuery by contactsViewModel.searchQuery.collectAsStateWithLifecycle()
|
||||
val isSearchActive by contactsViewModel.isSearchActive.collectAsStateWithLifecycle()
|
||||
val isAddParticipants by contactsViewModel.isAddParticipantsView.collectAsStateWithLifecycle()
|
||||
val autocompleteUsers by contactsViewModel.selectedParticipantsList.collectAsStateWithLifecycle()
|
||||
val enableAddButton by contactsViewModel.enableAddButton.collectAsStateWithLifecycle()
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
.statusBarsPadding()
|
||||
.displayCutoutPadding(),
|
||||
topBar = {
|
||||
if (isSearchActive) {
|
||||
ContactsSearchAppBar(
|
||||
searchQuery = searchQuery,
|
||||
onTextChange = {
|
||||
contactsViewModel.updateSearchQuery(it)
|
||||
contactsViewModel.getContactsFromSearchParams()
|
||||
},
|
||||
onCloseSearch = {
|
||||
contactsViewModel.updateSearchQuery("")
|
||||
contactsViewModel.setSearchActive(false)
|
||||
contactsViewModel.getContactsFromSearchParams()
|
||||
},
|
||||
enableAddButton = enableAddButton,
|
||||
isAddParticipants = isAddParticipants,
|
||||
clickAddButton = { contactsViewModel.modifyClickAddButton(true) }
|
||||
)
|
||||
} else {
|
||||
ContactsAppBar(
|
||||
isAddParticipants = isAddParticipants,
|
||||
autocompleteUsers = autocompleteUsers,
|
||||
onStartSearch = { contactsViewModel.setSearchActive(true) }
|
||||
)
|
||||
}
|
||||
},
|
||||
content = { paddingValues ->
|
||||
Column(
|
||||
Modifier
|
||||
.background(colorResource(id = R.color.bg_default))
|
||||
.padding(0.dp, paddingValues.calculateTopPadding(), 0.dp, paddingValues.calculateBottomPadding())
|
||||
) {
|
||||
if (!isAddParticipants) {
|
||||
ConversationCreationOptions()
|
||||
}
|
||||
|
||||
ContactsList(
|
||||
contactsUiState = uiState,
|
||||
contactsViewModel = contactsViewModel
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
|
||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
class ContactsViewModel @Inject constructor(private val repository: ContactsRepository) : ViewModel() {
|
||||
|
||||
private val _contactsViewState = MutableStateFlow<ContactsUiState>(ContactsUiState.None)
|
||||
val contactsViewState: StateFlow<ContactsUiState> = _contactsViewState
|
||||
private val _roomViewState = MutableStateFlow<RoomUiState>(RoomUiState.None)
|
||||
val roomViewState: StateFlow<RoomUiState> = _roomViewState
|
||||
private val _searchQuery = MutableStateFlow("")
|
||||
val searchQuery: StateFlow<String> = _searchQuery
|
||||
private val shareTypes: MutableList<String> = mutableListOf(ShareType.User.shareType)
|
||||
val shareTypeList: List<String> = shareTypes
|
||||
private val _isSearchActive = MutableStateFlow(false)
|
||||
val isSearchActive: StateFlow<Boolean> = _isSearchActive
|
||||
private val selectedParticipants = MutableStateFlow<List<AutocompleteUser>>(emptyList())
|
||||
val selectedParticipantsList: StateFlow<List<AutocompleteUser>> = selectedParticipants.asStateFlow()
|
||||
private val _isAddParticipantsView = MutableStateFlow(false)
|
||||
val isAddParticipantsView: StateFlow<Boolean> = _isAddParticipantsView
|
||||
|
||||
private val _enableAddButton = MutableStateFlow(false)
|
||||
val enableAddButton: StateFlow<Boolean> = _enableAddButton
|
||||
|
||||
@Suppress("PropertyName")
|
||||
private val _selectedContacts = MutableStateFlow<List<AutocompleteUser>>(emptyList())
|
||||
|
||||
@Suppress("PropertyName")
|
||||
private val _clickAddButton = MutableStateFlow(false)
|
||||
|
||||
private var hideAlreadyAddedParticipants: Boolean = false
|
||||
|
||||
init {
|
||||
getContactsFromSearchParams()
|
||||
}
|
||||
|
||||
fun updateSearchQuery(query: String) {
|
||||
_searchQuery.value = query
|
||||
}
|
||||
|
||||
fun modifyClickAddButton(value: Boolean) {
|
||||
_clickAddButton.value = value
|
||||
}
|
||||
|
||||
fun selectContact(contact: AutocompleteUser) {
|
||||
val updatedParticipants = selectedParticipants.value + contact
|
||||
selectedParticipants.value = updatedParticipants
|
||||
_selectedContacts.value = _selectedContacts.value + contact
|
||||
}
|
||||
|
||||
fun updateAddButtonState() {
|
||||
if (_selectedContacts.value.isEmpty()) {
|
||||
_enableAddButton.value = false
|
||||
} else {
|
||||
_enableAddButton.value = true
|
||||
}
|
||||
}
|
||||
|
||||
fun deselectContact(contact: AutocompleteUser) {
|
||||
val updatedParticipants = selectedParticipants.value - contact
|
||||
selectedParticipants.value = updatedParticipants
|
||||
_selectedContacts.value = _selectedContacts.value - contact
|
||||
}
|
||||
|
||||
fun updateSelectedParticipants(participants: List<AutocompleteUser>) {
|
||||
selectedParticipants.value = participants
|
||||
}
|
||||
fun setSearchActive(searchState: Boolean) {
|
||||
_isSearchActive.value = searchState
|
||||
}
|
||||
|
||||
fun updateShareTypes(value: List<String>) {
|
||||
shareTypes.addAll(value)
|
||||
}
|
||||
|
||||
fun updateIsAddParticipants(value: Boolean) {
|
||||
_isAddParticipantsView.value = value
|
||||
}
|
||||
|
||||
fun hideAlreadyAddedParticipants(value: Boolean) {
|
||||
hideAlreadyAddedParticipants = value
|
||||
}
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
fun getContactsFromSearchParams(query: String = "") {
|
||||
_contactsViewState.value = ContactsUiState.Loading
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
val contacts = repository.getContacts(
|
||||
if (query != "") query else searchQuery.value,
|
||||
shareTypeList
|
||||
)
|
||||
val contactsList: MutableList<AutocompleteUser>? = contacts.ocs!!.data?.toMutableList()
|
||||
|
||||
if (hideAlreadyAddedParticipants && !_clickAddButton.value) {
|
||||
contactsList?.removeAll(selectedParticipants.value)
|
||||
}
|
||||
if (_clickAddButton.value) {
|
||||
contactsList?.removeAll(selectedParticipants.value)
|
||||
contactsList?.addAll(_selectedContacts.value)
|
||||
}
|
||||
_contactsViewState.value = ContactsUiState.Success(contactsList)
|
||||
} catch (exception: Exception) {
|
||||
_contactsViewState.value = ContactsUiState.Error(exception.message ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
fun createRoom(roomType: String, sourceType: String?, userId: String, conversationName: String?) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
val room = repository.createRoom(
|
||||
roomType,
|
||||
sourceType,
|
||||
userId,
|
||||
conversationName
|
||||
)
|
||||
|
||||
val conversation: Conversation? = room.ocs?.data
|
||||
_roomViewState.value = RoomUiState.Success(conversation)
|
||||
} catch (exception: Exception) {
|
||||
_roomViewState.value = RoomUiState.Error(exception.message ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
fun getImageUri(avatarId: String, requestBigSize: Boolean): String =
|
||||
repository.getImageUri(avatarId, requestBigSize)
|
||||
}
|
||||
|
||||
sealed class ContactsUiState {
|
||||
data object None : ContactsUiState()
|
||||
data object Loading : ContactsUiState()
|
||||
data class Success(val contacts: List<AutocompleteUser>?) : ContactsUiState()
|
||||
data class Error(val message: String) : ContactsUiState()
|
||||
}
|
||||
|
||||
sealed class RoomUiState {
|
||||
data object None : RoomUiState()
|
||||
data class Success(val conversation: Conversation?) : RoomUiState()
|
||||
data class Error(val message: String) : RoomUiState()
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@email.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.Composable
|
||||
import coil.request.ImageRequest
|
||||
import coil.size.Size
|
||||
import coil.transform.CircleCropTransformation
|
||||
import coil.transform.RoundedCornersTransformation
|
||||
|
||||
@Composable
|
||||
fun loadImage(imageUri: String?, context: Context, errorPlaceholderImage: Int): ImageRequest {
|
||||
val imageRequest = ImageRequest.Builder(context)
|
||||
.data(imageUri)
|
||||
.transformations(CircleCropTransformation())
|
||||
.error(errorPlaceholderImage)
|
||||
.placeholder(errorPlaceholderImage)
|
||||
.build()
|
||||
return imageRequest
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun load(imageUri: String?, context: Context, errorPlaceholderImage: Int): ImageRequest {
|
||||
val imageRequest = ImageRequest.Builder(context)
|
||||
.data(imageUri)
|
||||
.size(Size.ORIGINAL)
|
||||
.transformations(RoundedCornersTransformation())
|
||||
.error(errorPlaceholderImage)
|
||||
.placeholder(errorPlaceholderImage)
|
||||
.build()
|
||||
return imageRequest
|
||||
}
|
||||
16
app/src/main/java/com/nextcloud/talk/contacts/ShareType.kt
Normal file
16
app/src/main/java/com/nextcloud/talk/contacts/ShareType.kt
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts
|
||||
|
||||
enum class ShareType(val shareType: String) {
|
||||
User("0"),
|
||||
Group("1"),
|
||||
Email("4"),
|
||||
Remote("5"),
|
||||
Circle("7")
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts.components
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil.compose.AsyncImage
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.contacts.CompanionClass
|
||||
import com.nextcloud.talk.contacts.ContactsViewModel
|
||||
import com.nextcloud.talk.contacts.RoomUiState
|
||||
import com.nextcloud.talk.contacts.loadImage
|
||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
|
||||
@Composable
|
||||
fun ContactItemRow(contact: AutocompleteUser, contactsViewModel: ContactsViewModel, context: Context) {
|
||||
var isSelected by remember { mutableStateOf(contactsViewModel.selectedParticipantsList.value.contains(contact)) }
|
||||
val roomUiState by contactsViewModel.roomViewState.collectAsState()
|
||||
val isAddParticipants = contactsViewModel.isAddParticipantsView.collectAsState()
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(
|
||||
onClick = {
|
||||
if (!isAddParticipants.value) {
|
||||
contactsViewModel.createRoom(
|
||||
CompanionClass.ROOM_TYPE_ONE_ONE,
|
||||
contact.source!!,
|
||||
contact.id!!,
|
||||
null
|
||||
)
|
||||
} else {
|
||||
isSelected = !isSelected
|
||||
if (isSelected) {
|
||||
contactsViewModel.selectContact(contact)
|
||||
contactsViewModel.updateAddButtonState()
|
||||
} else {
|
||||
contactsViewModel.deselectContact(contact)
|
||||
contactsViewModel.updateAddButtonState()
|
||||
}
|
||||
}
|
||||
}
|
||||
),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
val imageUri = contact.id?.let { contactsViewModel.getImageUri(it, true) }
|
||||
val errorPlaceholderImage: Int = R.drawable.account_circle_96dp
|
||||
val loadedImage = loadImage(imageUri, context, errorPlaceholderImage)
|
||||
AsyncImage(
|
||||
model = loadedImage,
|
||||
contentDescription = stringResource(R.string.user_avatar),
|
||||
modifier = Modifier.size(width = 45.dp, height = 45.dp)
|
||||
)
|
||||
Text(modifier = Modifier.padding(16.dp), text = contact.label!!)
|
||||
if (isAddParticipants.value) {
|
||||
if (isSelected) {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Icon(
|
||||
imageVector = ImageVector.vectorResource(id = R.drawable.ic_check_circle),
|
||||
contentDescription = "Selected",
|
||||
tint = Color.Blue,
|
||||
modifier = Modifier.padding(end = 8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
when (roomUiState) {
|
||||
is RoomUiState.Success -> {
|
||||
val conversation = (roomUiState as RoomUiState.Success).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)
|
||||
context.startActivity(chatIntent)
|
||||
}
|
||||
is RoomUiState.Error -> {
|
||||
val errorMessage = (roomUiState as RoomUiState.Error).message
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(text = "Error: $errorMessage", color = Color.Red)
|
||||
}
|
||||
}
|
||||
is RoomUiState.None -> {}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts.components
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.components.VerticallyCenteredRow
|
||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ContactsAppBar(isAddParticipants: Boolean, autocompleteUsers: List<AutocompleteUser>, onStartSearch: () -> Unit) {
|
||||
val context = LocalContext.current
|
||||
TopAppBar(
|
||||
modifier = Modifier
|
||||
.height(60.dp),
|
||||
title = {
|
||||
VerticallyCenteredRow {
|
||||
Text(
|
||||
text = if (isAddParticipants) {
|
||||
stringResource(R.string.nc_participants_add)
|
||||
} else {
|
||||
stringResource(R.string.nc_new_conversation)
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
navigationIcon = {
|
||||
VerticallyCenteredRow {
|
||||
IconButton(onClick = { (context as? Activity)?.finish() }) {
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.back_button))
|
||||
}
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
VerticallyCenteredRow {
|
||||
IconButton(onClick = onStartSearch) {
|
||||
Icon(Icons.Filled.Search, contentDescription = stringResource(R.string.search_icon))
|
||||
}
|
||||
if (isAddParticipants) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.nc_contacts_done),
|
||||
modifier = Modifier.clickable {
|
||||
val resultIntent = Intent().apply {
|
||||
putParcelableArrayListExtra("selectedParticipants", ArrayList(autocompleteUsers))
|
||||
}
|
||||
(context as? Activity)?.setResult(Activity.RESULT_OK, resultIntent)
|
||||
(context as? Activity)?.finish()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts.components
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.nextcloud.talk.contacts.CompanionClass
|
||||
import com.nextcloud.talk.contacts.ContactsViewModel
|
||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun ContactsItem(contacts: List<AutocompleteUser>, contactsViewModel: ContactsViewModel, context: Context) {
|
||||
val groupedContacts: Map<String, List<AutocompleteUser>> = contacts.groupBy { contact ->
|
||||
(
|
||||
if (contact.source == "users") {
|
||||
contact.label?.first()?.uppercase()
|
||||
} else {
|
||||
contact.source?.replaceFirstChar { actorType ->
|
||||
actorType.uppercase()
|
||||
}
|
||||
}
|
||||
).toString()
|
||||
}
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
contentPadding = PaddingValues(
|
||||
top = 10.dp,
|
||||
bottom = 40.dp,
|
||||
start = 10.dp,
|
||||
end = 10.dp
|
||||
),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
groupedContacts.forEach { (initial, contactsForInitial) ->
|
||||
stickyHeader {
|
||||
Column {
|
||||
Surface(Modifier.fillParentMaxWidth()) {
|
||||
Header(initial)
|
||||
}
|
||||
HorizontalDivider(thickness = 0.1.dp, color = Color.Black)
|
||||
}
|
||||
}
|
||||
items(contactsForInitial) { contact ->
|
||||
ContactItemRow(
|
||||
contact = contact,
|
||||
contactsViewModel = contactsViewModel,
|
||||
context = context
|
||||
)
|
||||
Log.d(CompanionClass.TAG, "Contacts:$contact")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts.components
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import com.nextcloud.talk.contacts.CompanionClass
|
||||
import com.nextcloud.talk.contacts.ContactsUiState
|
||||
import com.nextcloud.talk.contacts.ContactsViewModel
|
||||
|
||||
@Composable
|
||||
fun ContactsList(contactsUiState: ContactsUiState, contactsViewModel: ContactsViewModel) {
|
||||
val context = LocalContext.current
|
||||
when (contactsUiState) {
|
||||
is ContactsUiState.None -> {
|
||||
}
|
||||
|
||||
is ContactsUiState.Loading -> {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
}
|
||||
|
||||
is ContactsUiState.Success -> {
|
||||
val contacts = contactsUiState.contacts
|
||||
Log.d(CompanionClass.TAG, "Contacts:$contacts")
|
||||
if (contacts != null) {
|
||||
ContactsItem(contacts, contactsViewModel, context)
|
||||
}
|
||||
}
|
||||
|
||||
is ContactsUiState.Error -> {
|
||||
val errorMessage = contactsUiState.message
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(text = "Error: $errorMessage", color = Color.Red)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts.components
|
||||
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.platform.SoftwareKeyboardController
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.components.VerticallyCenteredRow
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ContactsSearchAppBar(
|
||||
searchQuery: String,
|
||||
onTextChange: (String) -> Unit,
|
||||
onCloseSearch: () -> Unit,
|
||||
enableAddButton: Boolean,
|
||||
isAddParticipants: Boolean,
|
||||
clickAddButton: (Boolean) -> Unit
|
||||
) {
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
|
||||
Surface(
|
||||
modifier = Modifier.height(60.dp)
|
||||
) {
|
||||
VerticallyCenteredRow {
|
||||
IconButton(
|
||||
modifier = Modifier.padding(start = 4.dp),
|
||||
onClick = onCloseSearch
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = stringResource(R.string.back_button)
|
||||
)
|
||||
}
|
||||
|
||||
TextField(
|
||||
value = searchQuery,
|
||||
onValueChange = onTextChange,
|
||||
placeholder = { Text(text = stringResource(R.string.nc_search)) },
|
||||
singleLine = true,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = 8.dp),
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
||||
keyboardActions = searchKeyboardActions(searchQuery, keyboardController),
|
||||
colors = searchTextFieldColors(),
|
||||
trailingIcon = {
|
||||
if (searchQuery.isNotEmpty()) {
|
||||
IconButton(onClick = { onTextChange("") }) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Close,
|
||||
contentDescription = stringResource(R.string.nc_search_clear)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (isAddParticipants) {
|
||||
TextButton(
|
||||
onClick = {
|
||||
onCloseSearch()
|
||||
clickAddButton(true)
|
||||
},
|
||||
enabled = enableAddButton
|
||||
) {
|
||||
Text(text = stringResource(R.string.add_participants))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun searchTextFieldColors() =
|
||||
TextFieldDefaults.colors(
|
||||
focusedIndicatorColor = Color.Transparent,
|
||||
unfocusedIndicatorColor = Color.Transparent,
|
||||
disabledIndicatorColor = Color.Transparent
|
||||
)
|
||||
|
||||
fun searchKeyboardActions(text: String, keyboardController: SoftwareKeyboardController?) =
|
||||
KeyboardActions(
|
||||
onSearch = {
|
||||
if (text.trim().isNotEmpty()) {
|
||||
keyboardController?.hide()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts.components
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.List
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.conversationcreation.ConversationCreationActivity
|
||||
import com.nextcloud.talk.openconversations.ListOpenConversationsActivity
|
||||
|
||||
@Composable
|
||||
fun ConversationCreationOptions() {
|
||||
val context = LocalContext.current
|
||||
Column {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 8.dp)
|
||||
.clickable {
|
||||
val intent = Intent(context, ConversationCreationActivity::class.java)
|
||||
context.startActivity(intent)
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.baseline_chat_bubble_outline_24),
|
||||
modifier = Modifier
|
||||
.width(40.dp)
|
||||
.height(40.dp)
|
||||
.padding(8.dp),
|
||||
contentDescription = null
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentHeight(),
|
||||
text = stringResource(R.string.nc_create_new_conversation),
|
||||
maxLines = 1,
|
||||
fontSize = 16.sp
|
||||
)
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(start = 16.dp, end = 16.dp, top = 8.dp, bottom = 8.dp)
|
||||
.clickable {
|
||||
val intent = Intent(context, ListOpenConversationsActivity::class.java)
|
||||
context.startActivity(intent)
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
Icons.AutoMirrored.Filled.List,
|
||||
modifier = Modifier
|
||||
.width(40.dp)
|
||||
.height(40.dp)
|
||||
.padding(8.dp),
|
||||
contentDescription = null
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentHeight(),
|
||||
text = stringResource(R.string.nc_join_open_conversations),
|
||||
fontSize = 16.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.contacts.components
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.nextcloud.talk.R
|
||||
|
||||
@Composable
|
||||
fun Header(header: String) {
|
||||
Text(
|
||||
text = header,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(colorResource(id = R.color.bg_default))
|
||||
.padding(start = 60.dp),
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue