mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
add edge to edge support (while handling special cases for xml vs compose and keyboard handling)
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
4e531ae054
commit
67467c3487
@ -463,7 +463,7 @@ class ChatActivity :
|
|||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.chat_container)) { view, insets ->
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.chat_container)) { view, insets ->
|
||||||
// val statusBarInsets = insets.getInsets(WindowInsetsCompat.Type.statusBars())
|
val statusBarInsets = insets.getInsets(WindowInsetsCompat.Type.statusBars())
|
||||||
val navBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
|
val navBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
|
||||||
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
|
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
|
||||||
|
|
||||||
@ -472,7 +472,7 @@ class ChatActivity :
|
|||||||
|
|
||||||
view.setPadding(
|
view.setPadding(
|
||||||
view.paddingLeft,
|
view.paddingLeft,
|
||||||
0,
|
statusBarInsets.top,
|
||||||
view.paddingRight,
|
view.paddingRight,
|
||||||
bottomPadding
|
bottomPadding
|
||||||
)
|
)
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk - Android Client
|
||||||
|
*
|
||||||
|
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.nextcloud.talk.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.RowScope
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun VerticallyCenteredRow(content: @Composable RowScope.() -> Unit) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxHeight(),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
@ -11,16 +11,18 @@ package com.nextcloud.talk.contacts
|
|||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.statusBarsPadding
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.colorResource
|
import androidx.compose.ui.res.colorResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.contacts.components.AppBar
|
import com.nextcloud.talk.contacts.components.ContactsAppBar
|
||||||
import com.nextcloud.talk.contacts.components.ContactsList
|
import com.nextcloud.talk.contacts.components.ContactsList
|
||||||
|
import com.nextcloud.talk.contacts.components.ContactsSearchAppBar
|
||||||
import com.nextcloud.talk.contacts.components.ConversationCreationOptions
|
import com.nextcloud.talk.contacts.components.ConversationCreationOptions
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -32,35 +34,37 @@ fun ContactsScreen(contactsViewModel: ContactsViewModel, uiState: ContactsUiStat
|
|||||||
val enableAddButton by contactsViewModel.enableAddButton.collectAsStateWithLifecycle()
|
val enableAddButton by contactsViewModel.enableAddButton.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
|
modifier = Modifier
|
||||||
|
.statusBarsPadding(),
|
||||||
topBar = {
|
topBar = {
|
||||||
AppBar(
|
if (isSearchActive) {
|
||||||
title = stringResource(R.string.nc_app_product_name),
|
ContactsSearchAppBar(
|
||||||
searchQuery = searchQuery,
|
searchQuery = searchQuery,
|
||||||
isSearchActive = isSearchActive,
|
onTextChange = {
|
||||||
isAddParticipants = isAddParticipants,
|
contactsViewModel.updateSearchQuery(it)
|
||||||
autocompleteUsers = autocompleteUsers,
|
contactsViewModel.getContactsFromSearchParams()
|
||||||
onEnableSearch = {
|
|
||||||
contactsViewModel.setSearchActive(true)
|
|
||||||
},
|
},
|
||||||
onDisableSearch = {
|
onCloseSearch = {
|
||||||
|
contactsViewModel.updateSearchQuery("")
|
||||||
contactsViewModel.setSearchActive(false)
|
contactsViewModel.setSearchActive(false)
|
||||||
},
|
|
||||||
onUpdateSearchQuery = {
|
|
||||||
contactsViewModel.updateSearchQuery(query = it)
|
|
||||||
},
|
|
||||||
onUpdateAutocompleteUsers = {
|
|
||||||
contactsViewModel.getContactsFromSearchParams()
|
contactsViewModel.getContactsFromSearchParams()
|
||||||
},
|
},
|
||||||
enableAddButton = enableAddButton,
|
enableAddButton = enableAddButton,
|
||||||
clickAddButton = {
|
isAddParticipants = isAddParticipants,
|
||||||
contactsViewModel.modifyClickAddButton(it)
|
clickAddButton = { contactsViewModel.modifyClickAddButton(true) }
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
ContactsAppBar(
|
||||||
|
isAddParticipants = isAddParticipants,
|
||||||
|
autocompleteUsers = autocompleteUsers,
|
||||||
|
onStartSearch = { contactsViewModel.setSearchActive(true) }
|
||||||
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
content = {
|
content = { paddingValues ->
|
||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
.padding(it)
|
.padding(0.dp, paddingValues.calculateTopPadding(), 0.dp, 0.dp)
|
||||||
.background(colorResource(id = R.color.bg_default))
|
.background(colorResource(id = R.color.bg_default))
|
||||||
) {
|
) {
|
||||||
if (!isAddParticipants) {
|
if (!isAddParticipants) {
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.annotation.SuppressLint
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Intent
|
|
||||||
import androidx.compose.foundation.clickable
|
|
||||||
import androidx.compose.foundation.layout.Row
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.wrapContentWidth
|
|
||||||
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.TextButton
|
|
||||||
import androidx.compose.material3.TopAppBar
|
|
||||||
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.stringResource
|
|
||||||
import com.nextcloud.talk.R
|
|
||||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
|
|
||||||
|
|
||||||
@SuppressLint("UnrememberedMutableState")
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
@Suppress("LongParameterList", "LongMethod")
|
|
||||||
@Composable
|
|
||||||
fun AppBar(
|
|
||||||
title: String,
|
|
||||||
searchQuery: String,
|
|
||||||
isSearchActive: Boolean,
|
|
||||||
isAddParticipants: Boolean,
|
|
||||||
autocompleteUsers: List<AutocompleteUser>,
|
|
||||||
onEnableSearch: () -> Unit,
|
|
||||||
onDisableSearch: () -> Unit,
|
|
||||||
onUpdateSearchQuery: (String) -> Unit,
|
|
||||||
onUpdateAutocompleteUsers: () -> Unit,
|
|
||||||
enableAddButton: Boolean,
|
|
||||||
clickAddButton: (Boolean) -> Unit
|
|
||||||
) {
|
|
||||||
val context = LocalContext.current
|
|
||||||
val appTitle = if (!isSearchActive) {
|
|
||||||
title
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
TopAppBar(
|
|
||||||
title = { Text(text = appTitle) },
|
|
||||||
navigationIcon = {
|
|
||||||
IconButton(onClick = {
|
|
||||||
(context as? Activity)?.finish()
|
|
||||||
}) {
|
|
||||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.back_button))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
actions = {
|
|
||||||
if (!isSearchActive) {
|
|
||||||
IconButton(onClick = onEnableSearch) {
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
if (isSearchActive) {
|
|
||||||
Row(modifier = Modifier.fillMaxWidth()) {
|
|
||||||
SearchComponent(
|
|
||||||
text = searchQuery,
|
|
||||||
onTextChange = { searchQuery ->
|
|
||||||
onUpdateSearchQuery(searchQuery)
|
|
||||||
onUpdateAutocompleteUsers()
|
|
||||||
},
|
|
||||||
onDisableSearch = onDisableSearch,
|
|
||||||
modifier = Modifier.weight(1f)
|
|
||||||
)
|
|
||||||
if (isAddParticipants) {
|
|
||||||
TextButton(
|
|
||||||
modifier = Modifier.align(Alignment.CenterVertically).wrapContentWidth(),
|
|
||||||
onClick = {
|
|
||||||
onDisableSearch()
|
|
||||||
onUpdateSearchQuery("")
|
|
||||||
clickAddButton(true)
|
|
||||||
onUpdateAutocompleteUsers()
|
|
||||||
},
|
|
||||||
enabled = enableAddButton
|
|
||||||
) {
|
|
||||||
Text(text = context.getString(R.string.add_participants))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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,103 @@
|
|||||||
|
/*
|
||||||
|
* 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.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
|
||||||
|
|
||||||
|
@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,
|
||||||
|
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
||||||
|
keyboardActions = searchKeyboardActions(searchQuery, keyboardController),
|
||||||
|
colors = searchTextFieldColors()
|
||||||
|
)
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
@ -1,105 +0,0 @@
|
|||||||
/*
|
|
||||||
* Nextcloud Talk - Android Client
|
|
||||||
*
|
|
||||||
* SPDX-FileCopyrightText: 2025 Julius Linus <juliuslinus1@gmail.com>
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.nextcloud.talk.contacts.components
|
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.layout.height
|
|
||||||
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.Icon
|
|
||||||
import androidx.compose.material3.IconButton
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
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.TextStyle
|
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import com.nextcloud.talk.R
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun SearchComponent(
|
|
||||||
text: String,
|
|
||||||
onTextChange: (String) -> Unit,
|
|
||||||
onDisableSearch: () -> Unit,
|
|
||||||
modifier: Modifier = Modifier
|
|
||||||
) {
|
|
||||||
val keyboardController = LocalSoftwareKeyboardController.current
|
|
||||||
TextField(
|
|
||||||
value = text,
|
|
||||||
onValueChange = { onTextChange(it) },
|
|
||||||
modifier = modifier
|
|
||||||
.background(MaterialTheme.colorScheme.background)
|
|
||||||
.height(60.dp),
|
|
||||||
placeholder = { Text(text = stringResource(R.string.nc_search)) },
|
|
||||||
textStyle = TextStyle(fontSize = 16.sp),
|
|
||||||
singleLine = true,
|
|
||||||
leadingIcon = { LeadingIcon(onTextChange, onDisableSearch) },
|
|
||||||
trailingIcon = { TrailingIcon(text, onTextChange) },
|
|
||||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
|
||||||
keyboardActions = searchKeyboardActions(text, keyboardController),
|
|
||||||
colors = searchTextFieldColors(),
|
|
||||||
maxLines = 1
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun searchTextFieldColors() =
|
|
||||||
TextFieldDefaults.colors(
|
|
||||||
focusedIndicatorColor = Color.Transparent,
|
|
||||||
unfocusedIndicatorColor = Color.Transparent,
|
|
||||||
disabledIndicatorColor = Color.Transparent
|
|
||||||
)
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun LeadingIcon(onTextChange: (String) -> Unit, onDisableSearch: () -> Unit) {
|
|
||||||
IconButton(
|
|
||||||
onClick = {
|
|
||||||
onTextChange("")
|
|
||||||
onDisableSearch()
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.AutoMirrored.Default.ArrowBack,
|
|
||||||
contentDescription = stringResource(R.string.back_button)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun TrailingIcon(text: String, onTextChange: (String) -> Unit) {
|
|
||||||
if (text.isNotEmpty()) {
|
|
||||||
IconButton(
|
|
||||||
onClick = { onTextChange("") }
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Close,
|
|
||||||
contentDescription = stringResource(R.string.close_icon)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun searchKeyboardActions(text: String, keyboardController: SoftwareKeyboardController?) =
|
|
||||||
KeyboardActions(
|
|
||||||
onSearch = {
|
|
||||||
if (text.trim().isNotEmpty()) {
|
|
||||||
keyboardController?.hide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
@ -13,7 +13,6 @@ import android.os.Bundle
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.content.res.ResourcesCompat
|
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
@ -28,7 +27,6 @@ import com.nextcloud.talk.databinding.ActivitySharedItemsBinding
|
|||||||
import com.nextcloud.talk.shareditems.adapters.SharedItemsAdapter
|
import com.nextcloud.talk.shareditems.adapters.SharedItemsAdapter
|
||||||
import com.nextcloud.talk.shareditems.model.SharedItemType
|
import com.nextcloud.talk.shareditems.model.SharedItemType
|
||||||
import com.nextcloud.talk.shareditems.viewmodels.SharedItemsViewModel
|
import com.nextcloud.talk.shareditems.viewmodels.SharedItemsViewModel
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_CONVERSATION_NAME
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_CONVERSATION_NAME
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -57,15 +55,11 @@ class SharedItemsActivity : BaseActivity() {
|
|||||||
setSupportActionBar(binding.sharedItemsToolbar)
|
setSupportActionBar(binding.sharedItemsToolbar)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
viewThemeUtils.platform.themeStatusBar(this)
|
initSystemBars()
|
||||||
|
|
||||||
viewThemeUtils.material.themeToolbar(binding.sharedItemsToolbar)
|
viewThemeUtils.material.themeToolbar(binding.sharedItemsToolbar)
|
||||||
viewThemeUtils.material.themeTabLayoutOnSurface(binding.sharedItemsTabs)
|
viewThemeUtils.material.themeTabLayoutOnSurface(binding.sharedItemsTabs)
|
||||||
|
|
||||||
DisplayUtils.applyColorToNavigationBar(
|
|
||||||
this.window,
|
|
||||||
ResourcesCompat.getColor(resources, R.color.bg_default, null)
|
|
||||||
)
|
|
||||||
|
|
||||||
supportActionBar?.title = conversationName
|
supportActionBar?.title = conversationName
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
|
||||||
|
@ -15,9 +15,6 @@ import androidx.activity.enableEdgeToEdge
|
|||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
|
|
||||||
import com.nextcloud.android.common.ui.util.extensions.addSystemBarPaddings
|
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@Suppress("MagicNumber")
|
@Suppress("MagicNumber")
|
||||||
@ -30,27 +27,21 @@ fun AppCompatActivity.adjustUIForAPILevel35(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
enableEdgeToEdge(statusBarStyle, navigationBarStyle)
|
enableEdgeToEdge(statusBarStyle, navigationBarStyle)
|
||||||
|
|
||||||
window.addSystemBarPaddings()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace this with the common lib whenever https://github.com/nextcloud/android-common/pull/668 is merged
|
|
||||||
// and then delete this file
|
|
||||||
fun AppCompatActivity.setStatusBarColor(@ColorInt color: Int) {
|
fun AppCompatActivity.setStatusBarColor(@ColorInt color: Int) {
|
||||||
window.decorView.setOnApplyWindowInsetsListener { view, insets ->
|
window.decorView.setOnApplyWindowInsetsListener { view, insets ->
|
||||||
view.setBackgroundColor(color)
|
view.setBackgroundColor(color)
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||||
val statusBarHeight = insets.getInsets(WindowInsets.Type.statusBars()).top
|
val statusBarHeight = insets.getInsets(WindowInsets.Type.statusBars()).top
|
||||||
val navBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
|
|
||||||
view.setPadding(
|
view.setPadding(
|
||||||
view.paddingLeft,
|
view.paddingLeft,
|
||||||
statusBarHeight,
|
statusBarHeight,
|
||||||
view.paddingRight,
|
view.paddingRight,
|
||||||
navBarInsets.bottom
|
0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_margin="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_marginBottom="36dp"
|
||||||
android:contentDescription="@string/nc_new_conversation"
|
android:contentDescription="@string/nc_new_conversation"
|
||||||
app:borderWidth="0dp"
|
app:borderWidth="0dp"
|
||||||
app:srcCompat="@drawable/ic_pencil_grey600_24dp"
|
app:srcCompat="@drawable/ic_pencil_grey600_24dp"
|
||||||
|
Loading…
Reference in New Issue
Block a user