Work on migrating from local custom colors to material theme colors

This commit is contained in:
Juha Heinanen
2025-10-19 19:51:16 +03:00
parent 317652fd16
commit 80c75eda64
16 changed files with 360 additions and 323 deletions
@@ -16,6 +16,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBar
@@ -44,12 +45,12 @@ fun NavGraphBuilder.aboutScreenRoute(navController: NavController) {
private fun AboutScreen(onBack: () -> Unit) { private fun AboutScreen(onBack: () -> Unit) {
Scaffold( Scaffold(
modifier = Modifier.fillMaxSize().imePadding(), modifier = Modifier.fillMaxSize().imePadding(),
containerColor = LocalCustomColors.current.background, containerColor = MaterialTheme.colorScheme.background,
topBar = { topBar = {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding( .padding(
top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding() top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
) )
@@ -70,9 +71,9 @@ private fun AboutScreen(onBack: () -> Unit) {
} }
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = LocalCustomColors.current.onPrimary, titleContentColor = MaterialTheme.colorScheme.onPrimary,
navigationIconContentColor = LocalCustomColors.current.onPrimary, navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
), ),
windowInsets = WindowInsets(0, 0, 0, 0) windowInsets = WindowInsets(0, 0, 0, 0)
) )
@@ -82,9 +83,9 @@ private fun AboutScreen(onBack: () -> Unit) {
Text( Text(
text = AnnotatedString.fromHtml( text = AnnotatedString.fromHtml(
htmlString = stringResource(R.string.about_text, BuildConfig.VERSION_NAME), htmlString = stringResource(R.string.about_text, BuildConfig.VERSION_NAME),
linkStyles = TextLinkStyles(SpanStyle(color = LocalCustomColors.current.accent)) linkStyles = TextLinkStyles(SpanStyle(color = MaterialTheme.colorScheme.error))
), ),
color = LocalCustomColors.current.itemText, color = MaterialTheme.colorScheme.onBackground,
modifier = Modifier modifier = Modifier
.padding(horizontal = 16.dp, vertical = 16.dp) .padding(horizontal = 16.dp, vertical = 16.dp)
.padding(contentPadding) .padding(contentPadding)
@@ -13,8 +13,13 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
@@ -66,12 +71,12 @@ fun NavGraphBuilder.accountsScreenRoute(navController: NavController) {
fun AccountsScreen(navController: NavController) { fun AccountsScreen(navController: NavController) {
Scaffold( Scaffold(
modifier = Modifier.fillMaxSize().imePadding(), modifier = Modifier.fillMaxSize().imePadding(),
containerColor = LocalCustomColors.current.background, containerColor = MaterialTheme.colorScheme.background,
topBar = { topBar = {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding( .padding(
top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding() top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
) )
@@ -84,9 +89,9 @@ fun AccountsScreen(navController: NavController) {
) )
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary, navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary, titleContentColor = MaterialTheme.colorScheme.onPrimary,
), ),
navigationIcon = { navigationIcon = {
IconButton(onClick = { navController.popBackStack() }) { IconButton(onClick = { navController.popBackStack() }) {
@@ -128,17 +133,23 @@ fun AccountsContent(contentPadding: PaddingValues, navController: NavController)
val showAccounts = remember { mutableStateOf(true) } val showAccounts = remember { mutableStateOf(true) }
if (showAccounts.value && BaresipService.uas.value.isNotEmpty()) { if (showAccounts.value && BaresipService.uas.value.isNotEmpty()) {
val scrollState = rememberScrollState()
Column( val lazyListState = rememberLazyListState()
LazyColumn(
state = lazyListState,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(contentPadding) .padding(contentPadding)
.padding(start = 16.dp, end = 4.dp, top = 8.dp, bottom = 8.dp) .padding(start = 16.dp, end = 4.dp, top = 8.dp, bottom = 8.dp)
.verticalScrollbar(scrollState) .verticalScrollbar(
.verticalScroll(state = scrollState), state = lazyListState,
width = 4.dp,
color = MaterialTheme.colorScheme.outlineVariant
),
verticalArrangement = Arrangement.spacedBy(4.dp), verticalArrangement = Arrangement.spacedBy(4.dp),
) { ) {
for (ua in BaresipService.uas.value) { items(BaresipService.uas.value) { ua ->
val account = ua.account val account = ua.account
val aor = account.aor val aor = account.aor
val text = account.text() val text = account.text()
@@ -148,13 +159,16 @@ fun AccountsContent(contentPadding: PaddingValues, navController: NavController)
Text( Text(
text = text, text = text,
fontSize = 20.sp, fontSize = 20.sp,
color = LocalCustomColors.current.itemText, color = MaterialTheme.colorScheme.onBackground,
modifier = Modifier.weight(1f).padding(start = 10.dp) modifier = Modifier
.weight(1f)
.padding(start = 10.dp)
.clickable { .clickable {
navController.navigate("account/$aor/old") navController.navigate("account/$aor/old")
} }
) )
SmallFloatingActionButton( SmallFloatingActionButton(
modifier = Modifier.padding(end = 8.dp),
onClick = { onClick = {
message.value = String.format( message.value = String.format(
ctx.getString(R.string.delete_account), ctx.getString(R.string.delete_account),
@@ -280,6 +294,7 @@ fun NewAccount(navController: NavController) {
) )
) )
SmallFloatingActionButton( SmallFloatingActionButton(
modifier = Modifier.offset(y = 2.dp),
onClick = { onClick = {
val account = createNew(ctx, newAor.trim()) val account = createNew(ctx, newAor.trim())
if (account != null) { if (account != null) {
@@ -293,6 +308,7 @@ fun NewAccount(navController: NavController) {
) { ) {
Icon( Icon(
imageVector = Icons.Filled.Add, imageVector = Icons.Filled.Add,
modifier = Modifier.size(36.dp),
contentDescription = stringResource(R.string.add) contentDescription = stringResource(R.string.add)
) )
} }
@@ -29,6 +29,7 @@ import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBar
@@ -53,6 +54,7 @@ import androidx.navigation.NavType
import androidx.navigation.compose.composable import androidx.navigation.compose.composable
import androidx.navigation.navArgument import androidx.navigation.navArgument
import coil.compose.AsyncImage import coil.compose.AsyncImage
import com.tutpro.baresip.CustomElements.verticalScrollbar
fun NavGraphBuilder.androidContactScreenRoute(navController: NavController, viewModel: ViewModel) { fun NavGraphBuilder.androidContactScreenRoute(navController: NavController, viewModel: ViewModel) {
composable( composable(
@@ -79,12 +81,12 @@ private fun ContactScreen(ctx: Context, viewModel: ViewModel, navController: Nav
} }
Scaffold( Scaffold(
modifier = Modifier.fillMaxSize().imePadding(), modifier = Modifier.fillMaxSize().imePadding(),
containerColor = LocalCustomColors.current.background, containerColor = MaterialTheme.colorScheme.background,
topBar = { topBar = {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()) .padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding())
) { ) {
TopAppBar(name, navController) TopAppBar(name, navController)
@@ -107,9 +109,9 @@ private fun TopAppBar(title: String, navController: NavController) {
) )
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary, navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary, titleContentColor = MaterialTheme.colorScheme.onPrimary,
), ),
windowInsets = WindowInsets(0, 0, 0, 0), windowInsets = WindowInsets(0, 0, 0, 0),
navigationIcon = { navigationIcon = {
@@ -134,7 +136,7 @@ private fun ContactContent(
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding(contentPadding) .padding(contentPadding)
.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 52.dp), .padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 52.dp),
verticalArrangement = Arrangement.spacedBy(12.dp), verticalArrangement = Arrangement.spacedBy(12.dp),
@@ -192,7 +194,7 @@ private fun ContactName(name: String) {
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start horizontalArrangement = Arrangement.Start
) { ) {
Text(name, fontSize = 24.sp, color = LocalCustomColors.current.itemText) Text(name, fontSize = 24.sp, color = MaterialTheme.colorScheme.onBackground)
} }
} }
@@ -208,7 +210,7 @@ private fun Uris(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(start = 16.dp, end = 4.dp) .padding(start = 16.dp, end = 4.dp)
.background(LocalCustomColors.current.background), .background(MaterialTheme.colorScheme.background),
state = lazyListState, state = lazyListState,
verticalArrangement = Arrangement.spacedBy(12.dp), verticalArrangement = Arrangement.spacedBy(12.dp),
) { ) {
@@ -220,11 +222,11 @@ private fun Uris(
text = uri.substringAfter(":"), text = uri.substringAfter(":"),
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
fontSize = 18.sp, fontSize = 18.sp,
color = LocalCustomColors.current.itemText, color = MaterialTheme.colorScheme.onBackground,
) )
Image( Image(
painter = painterResource(R.drawable.message), painter = painterResource(R.drawable.message),
colorFilter = ColorFilter.tint(LocalCustomColors.current.itemText), colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onBackground),
contentDescription = "Send Message", contentDescription = "Send Message",
modifier = Modifier.padding(end = 24.dp).clickable { modifier = Modifier.padding(end = 24.dp).clickable {
val aor = viewModel.selectedAor.value val aor = viewModel.selectedAor.value
@@ -245,7 +247,7 @@ private fun Uris(
) )
Image( Image(
painter = painterResource(R.drawable.call_small), painter = painterResource(R.drawable.call_small),
colorFilter = ColorFilter.tint(LocalCustomColors.current.itemText), colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onBackground),
contentDescription = "Call", contentDescription = "Call",
modifier = Modifier.clickable { modifier = Modifier.clickable {
val aor = viewModel.selectedAor.value val aor = viewModel.selectedAor.value
@@ -2,6 +2,7 @@ package com.tutpro.baresip
import android.app.Activity import android.app.Activity
import android.os.Build.VERSION import android.os.Build.VERSION
import android.util.Log
import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme import androidx.compose.material3.darkColorScheme
@@ -9,7 +10,6 @@ import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.SideEffect import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
@@ -28,6 +28,7 @@ fun AppTheme(
val useDynamicColors by remember { BaresipService.dynamicColors } val useDynamicColors by remember { BaresipService.dynamicColors }
val useActualDynamicColors = useDynamicColors && VERSION.SDK_INT >= 31 val useActualDynamicColors = useDynamicColors && VERSION.SDK_INT >= 31
Log.d(TAG, "Use actual dynamic colors: $useActualDynamicColors") Log.d(TAG, "Use actual dynamic colors: $useActualDynamicColors")
val colorScheme = when { val colorScheme = when {
@@ -37,51 +38,71 @@ fun AppTheme(
else else
dynamicLightColorScheme(context) dynamicLightColorScheme(context)
} }
useDarkTheme || isSystemInDarkTheme() -> darkColorScheme() useDarkTheme || isSystemInDarkTheme() -> darkColorScheme(
else -> lightColorScheme() primary = dark_primary,
} onPrimary = dark_on_primary,
primaryContainer = dark_primary_container,
val basePalette = if (useDarkTheme) DarkCustomColors else LightCustomColors onPrimaryContainer = dark_on_primary_container,
secondary = dark_secondary,
val customColorsPalette = basePalette.copy( onSecondary = dark_on_secondary,
background = colorScheme.background, secondaryContainer = dark_secondary_container,
onBackground = if (useActualDynamicColors) onSecondaryContainer = dark_on_secondary_container,
colorScheme.onBackground tertiary = dark_tertiary,
else onTertiary = dark_on_tertiary,
basePalette.onBackground, tertiaryContainer = dark_tertiary_container,
cardBackground = colorScheme.surfaceVariant, onTertiaryContainer = dark_on_tertiary_container,
textFieldBackground = colorScheme.surfaceVariant, error = dark_error,
primary = if (useActualDynamicColors) onError = dark_on_error,
colorScheme.primary errorContainer = dark_error_container,
else onErrorContainer = dark_on_error_container,
basePalette.primary, background = dark_background,
onPrimary = if (useActualDynamicColors) onBackground = dark_on_background,
colorScheme.onPrimary surface = dark_surface,
else onSurface = dark_on_surface,
basePalette.onPrimary surfaceVariant = dark_surfaceVariant,
onSurfaceVariant = dark_on_surfaceVariant,
outline = dark_outline
) )
else -> lightColorScheme(
primary = light_primary,
onPrimary = light_on_primary,
primaryContainer = light_primary_container,
onPrimaryContainer = light_on_primary_container,
secondary = light_secondary,
onSecondary = light_on_secondary,
secondaryContainer = light_secondary_container,
onSecondaryContainer = light_on_secondary_container,
tertiary = light_tertiary,
onTertiary = light_on_tertiary,
tertiaryContainer = light_tertiary_container,
onTertiaryContainer = light_on_tertiary_container,
error = light_error,
onError = light_on_error,
errorContainer = light_error_container,
onErrorContainer = light_on_error_container,
background = light_background,
onBackground = light_on_background,
surface = light_surface,
onSurface = light_on_surface,
surfaceVariant = light_surfaceVariant,
onSurfaceVariant = light_on_surfaceVariant,
outline = light_outline
)
}
val view = LocalView.current val view = LocalView.current
if (!view.isInEditMode) { if (!view.isInEditMode) {
SideEffect { SideEffect {
val window = (view.context as Activity).window val window = (view.context as Activity).window
val insetsController = WindowCompat.getInsetsController(window, view) val insetsController = WindowCompat.getInsetsController(window, view)
val isBackgroundEffectivelyLight = ColorUtils.calculateLuminance(colorScheme.background.toArgb()) > 0.5
// A common threshold for luminance is 0.5. Colors with luminance > 0.5 are considered light.
val isBackgroundEffectivelyLight = ColorUtils.calculateLuminance(customColorsPalette.background.toArgb()) > 0.5
insetsController.isAppearanceLightStatusBars = isBackgroundEffectivelyLight insetsController.isAppearanceLightStatusBars = isBackgroundEffectivelyLight
insetsController.isAppearanceLightNavigationBars = isBackgroundEffectivelyLight insetsController.isAppearanceLightNavigationBars = isBackgroundEffectivelyLight
} }
} }
CompositionLocalProvider( MaterialTheme(
LocalCustomColors provides customColorsPalette colorScheme = colorScheme,
) { content = content
MaterialTheme( )
colorScheme = colorScheme, // MaterialTheme still uses the "normal" colorScheme
content = content
)
}
} }
@@ -42,6 +42,7 @@ import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
@@ -196,12 +197,12 @@ private fun ContactScreen(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.imePadding(), .imePadding(),
containerColor = LocalCustomColors.current.background, containerColor = MaterialTheme.colorScheme.background,
topBar = { topBar = {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()) .padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding())
) { ) {
TopAppBar(title, onBack = onBack, onCheck = onCheck) TopAppBar(title, onBack = onBack, onCheck = onCheck)
@@ -235,10 +236,10 @@ private fun TopAppBar(title: String, onBack: () -> Unit, onCheck: () -> Unit) {
) )
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary, navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary, titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = LocalCustomColors.current.onPrimary actionIconContentColor = MaterialTheme.colorScheme.onPrimary
), ),
windowInsets = WindowInsets(0, 0, 0, 0), windowInsets = WindowInsets(0, 0, 0, 0),
navigationIcon = { navigationIcon = {
@@ -285,7 +286,7 @@ private fun ContactContent(
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding(contentPadding) .padding(contentPadding)
.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 52.dp), .padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 52.dp),
verticalArrangement = Arrangement.spacedBy(12.dp), verticalArrangement = Arrangement.spacedBy(12.dp),
@@ -438,7 +439,7 @@ private fun Avatar(
@Composable @Composable
private fun ContactName(name: String, new: Boolean, onNameChange: (String) -> Unit) { private fun ContactName(name: String, new: Boolean, onNameChange: (String) -> Unit) {
val focusRequester = FocusRequester() val focusRequester = remember { FocusRequester() }
OutlinedTextField( OutlinedTextField(
value = name, value = name,
placeholder = { Text(stringResource(R.string.contact_name)) }, placeholder = { Text(stringResource(R.string.contact_name)) },
@@ -447,7 +448,7 @@ private fun ContactName(name: String, new: Boolean, onNameChange: (String) -> Un
.fillMaxWidth() .fillMaxWidth()
.focusRequester(focusRequester), .focusRequester(focusRequester),
textStyle = androidx.compose.ui.text.TextStyle( textStyle = androidx.compose.ui.text.TextStyle(
fontSize = 18.sp, color = LocalCustomColors.current.itemText fontSize = 18.sp, color = MaterialTheme.colorScheme.onBackground
), ),
label = { Text(stringResource(R.string.contact_name)) }, label = { Text(stringResource(R.string.contact_name)) },
keyboardOptions = KeyboardOptions( keyboardOptions = KeyboardOptions(
@@ -469,7 +470,7 @@ private fun ContactUri(uri: String, onUriChange: (String) -> Unit) {
onValueChange = onUriChange, onValueChange = onUriChange,
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
textStyle = androidx.compose.ui.text.TextStyle( textStyle = androidx.compose.ui.text.TextStyle(
fontSize = 18.sp, color = LocalCustomColors.current.itemText fontSize = 18.sp, color = MaterialTheme.colorScheme.onBackground
), ),
label = { Text(stringResource(R.string.sip_or_tel_uri)) }, label = { Text(stringResource(R.string.sip_or_tel_uri)) },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text) keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text)
@@ -492,7 +493,7 @@ private fun Favorite(ctx: Context, favorite: Boolean, onFavoriteChange: (Boolean
alertMessage.value = ctx.getString(R.string.favorite_help) alertMessage.value = ctx.getString(R.string.favorite_help)
showAlert.value = true showAlert.value = true
}, },
color = LocalCustomColors.current.itemText, color = MaterialTheme.colorScheme.onBackground,
) )
Switch( Switch(
checked = favorite, checked = favorite,
@@ -511,7 +512,7 @@ private fun Android(android: Boolean, onAndroidChange: (Boolean) -> Unit) {
Text( Text(
text = stringResource(R.string.android), text = stringResource(R.string.android),
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
color = LocalCustomColors.current.itemText color = MaterialTheme.colorScheme.onBackground
) )
Switch( Switch(
checked = android, checked = android,
@@ -29,6 +29,7 @@ import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBar
@@ -86,9 +87,9 @@ private fun CallDetailsScreen(navController: NavController, callRow: CallRow) {
) )
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary, navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary, titleContentColor = MaterialTheme.colorScheme.onPrimary,
), ),
windowInsets = WindowInsets(0, 0, 0, 0), windowInsets = WindowInsets(0, 0, 0, 0),
navigationIcon = { navigationIcon = {
@@ -164,8 +165,7 @@ private fun Details(ctx: Context, details: ArrayList<Details>) {
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
.verticalScrollbar( .verticalScrollbar(
state = lazyListState, state = lazyListState,
width = 4.dp, width = 4.dp
color = LocalCustomColors.current.gray
) )
.background(LocalCustomColors.current.background), .background(LocalCustomColors.current.background),
state = lazyListState, state = lazyListState,
@@ -34,6 +34,7 @@ import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBar
@@ -152,10 +153,10 @@ private fun TopAppBar(navController: NavController, account: Account, callHistor
) )
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary, navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary, titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = LocalCustomColors.current.onPrimary actionIconContentColor = MaterialTheme.colorScheme.onPrimary
), ),
windowInsets = WindowInsets(0, 0, 0, 0), windowInsets = WindowInsets(0, 0, 0, 0),
navigationIcon = { navigationIcon = {
@@ -275,9 +276,9 @@ private fun Calls(
.verticalScrollbar( .verticalScrollbar(
state = lazyListState, state = lazyListState,
width = 4.dp, width = 4.dp,
color = LocalCustomColors.current.gray color = MaterialTheme.colorScheme.outlineVariant
) )
.background(LocalCustomColors.current.background), .background(MaterialTheme.colorScheme.background),
state = lazyListState, state = lazyListState,
verticalArrangement = Arrangement.spacedBy(12.dp), verticalArrangement = Arrangement.spacedBy(12.dp),
) { ) {
@@ -398,13 +399,13 @@ private fun Calls(
count++ count++
} }
if (count > 3) if (count > 3)
Text("...", color = LocalCustomColors.current.itemText) Text("...", color = MaterialTheme.colorScheme.onPrimaryContainer)
Text(text = Utils.friendlyUri(ctx, peerUri, account), Text(text = Utils.friendlyUri(ctx, peerUri, account),
modifier = Modifier.padding(start = 8.dp), modifier = Modifier.padding(start = 8.dp),
fontSize = 18.sp, fontSize = 18.sp,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
color = LocalCustomColors.current.itemText color = MaterialTheme.colorScheme.onPrimaryContainer
) )
} }
} }
@@ -415,9 +416,9 @@ private fun Calls(
lineHeight = 16.sp, lineHeight = 16.sp,
textAlign = TextAlign.End, textAlign = TextAlign.End,
color = if (recordings) color = if (recordings)
LocalCustomColors.current.accent MaterialTheme.colorScheme.error
else else
LocalCustomColors.current.itemText, MaterialTheme.colorScheme.onPrimaryContainer,
modifier = Modifier modifier = Modifier
.padding(end = 16.dp) .padding(end = 16.dp)
.clickable(onClick = { .clickable(onClick = {
@@ -6,7 +6,6 @@ import android.text.format.DateUtils.isToday
import android.widget.Toast import android.widget.Toast
import androidx.activity.compose.BackHandler import androidx.activity.compose.BackHandler
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
@@ -20,6 +19,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.statusBars
@@ -34,14 +34,17 @@ import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.Send
import androidx.compose.material.icons.outlined.Clear import androidx.compose.material.icons.outlined.Clear
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallFloatingActionButton
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarDefaults
@@ -59,11 +62,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.TextStyle
@@ -175,11 +176,11 @@ private fun ChatScreen(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.imePadding(), .imePadding(),
containerColor = LocalCustomColors.current.background, containerColor = MaterialTheme.colorScheme.background,
topBar = { topBar = {
Column(modifier = Modifier Column(modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()) .padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding())
) { ) {
TopAppBar(ctx, navController, viewModel, account, peerUri) TopAppBar(ctx, navController, viewModel, account, peerUri)
@@ -227,10 +228,10 @@ private fun TopAppBar(
) )
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary, navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary, titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = LocalCustomColors.current.onPrimary actionIconContentColor = MaterialTheme.colorScheme.onPrimary
), ),
navigationIcon = { navigationIcon = {
IconButton(onClick = { backAction(navController, account, peerUri) }) { IconButton(onClick = { backAction(navController, account, peerUri) }) {
@@ -351,8 +352,9 @@ private fun Messages(
.verticalScrollbar( .verticalScrollbar(
state = lazyListState, state = lazyListState,
width = 4.dp, width = 4.dp,
color = LocalCustomColors.current.gray color = MaterialTheme.colorScheme.outlineVariant
), )
.background(MaterialTheme.colorScheme.background),
reverseLayout = true, reverseLayout = true,
state = lazyListState, state = lazyListState,
verticalArrangement = Arrangement.spacedBy(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp),
@@ -417,17 +419,10 @@ private fun Messages(
RoundedCornerShape(20.dp, 10.dp, 50.dp, 20.dp), RoundedCornerShape(20.dp, 10.dp, 50.dp, 20.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
containerColor = containerColor =
if (message.direction == MESSAGE_DOWN) { if (message.direction == MESSAGE_DOWN)
if (BaresipService.darkTheme.value) MaterialTheme.colorScheme.secondaryContainer
LocalCustomColors.current.secondaryDark else
else MaterialTheme.colorScheme.primaryContainer
LocalCustomColors.current.secondaryLight
} else {
if (BaresipService.darkTheme.value)
LocalCustomColors.current.primaryDark
else
LocalCustomColors.current.primaryLight
}
), ),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
@@ -438,19 +433,11 @@ private fun Messages(
) )
) { ) {
Column { Column {
val textColor = if (message.direction == MESSAGE_DOWN)
MaterialTheme.colorScheme.onSecondaryContainer
else
MaterialTheme.colorScheme.onPrimaryContainer
Row { Row {
val textColor =
if (message.direction == MESSAGE_DOWN) {
if (BaresipService.darkTheme.value)
LocalCustomColors.current.secondaryLight
else
LocalCustomColors.current.secondaryDark
} else {
if (BaresipService.darkTheme.value)
LocalCustomColors.current.primaryLight
else
LocalCustomColors.current.primaryDark
}
Text(text = sender, fontSize = 12.sp, color = textColor) Text(text = sender, fontSize = 12.sp, color = textColor)
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
Text(text = info, fontSize = 12.sp, color = textColor) Text(text = info, fontSize = 12.sp, color = textColor)
@@ -459,7 +446,7 @@ private fun Messages(
SelectionContainer { SelectionContainer {
Text( Text(
text = message.message, text = message.message,
color = LocalCustomColors.current.itemText, color = textColor,
fontWeight = if (message.direction == MESSAGE_DOWN && message.new) fontWeight = if (message.direction == MESSAGE_DOWN && message.new)
FontWeight.Bold else FontWeight.Normal FontWeight.Bold else FontWeight.Normal
) )
@@ -549,59 +536,68 @@ private fun NewMessage(
if (newMessage.value.text.isNotEmpty()) if (newMessage.value.text.isNotEmpty())
focusRequester.requestFocus() focusRequester.requestFocus()
} }
Image( SmallFloatingActionButton(
painter = painterResource(id = R.drawable.send), modifier = Modifier.offset(y = 2.dp),
contentDescription = "Send", onClick = {
contentScale = ContentScale.Crop, val msgText = newMessage.value.text
modifier = Modifier if (msgText.isNotEmpty()) {
.size(36.dp) keyboardController?.hide()
.clickable { val time = System.currentTimeMillis()
val msgText = newMessage.value.text val msg = Message(
if (msgText.isNotEmpty()) { aor,
keyboardController?.hide() peerUri,
val time = System.currentTimeMillis() msgText,
val msg = Message( time,
aor, MESSAGE_UP_WAIT,
peerUri, 0,
msgText, "",
time, true
MESSAGE_UP_WAIT, )
0, msg.add()
"", var msgUri = ""
true addMessage(msg)
) if (Utils.isTelUri(peerUri))
msg.add() if (ua.account.telProvider == "") {
var msgUri = "" dialogMessage.value = String.format(
addMessage(msg) ctx.getString(R.string.no_telephony_provider),
if (Utils.isTelUri(peerUri)) Utils.plainAor(aor)
if (ua.account.telProvider == "") { )
dialogMessage.value = String.format( showDialog.value = true
ctx.getString(R.string.no_telephony_provider), }
Utils.plainAor(aor) else {
) msgUri = Utils.telToSip(peerUri, ua.account)
showDialog.value = true }
} else { else
msgUri = Utils.telToSip(peerUri, ua.account) msgUri = peerUri
} if (msgUri != "")
else if (Api.message_send(ua.uap,
msgUri = peerUri msgUri,
if (msgUri != "") msgText,
if (Api.message_send(ua.uap, msgUri, msgText, time.toString()) != 0 time.toString()
) { ) != 0) {
Toast.makeText( Toast.makeText(
ctx, "${ctx.getString(R.string.message_failed)}!", ctx, "${ctx.getString(R.string.message_failed)}!",
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
).show() ).show()
msg.direction = MESSAGE_UP_FAIL msg.direction = MESSAGE_UP_FAIL
msg.responseReason = ctx.getString(R.string.message_failed) msg.responseReason = ctx.getString(R.string.message_failed)
} else { }
newMessage.value = TextFieldValue("") else {
viewModel.updateAorPeerMessage(aor, peerUri, "") newMessage.value = TextFieldValue("")
keyboardController?.hide() viewModel.updateAorPeerMessage(aor, peerUri, "")
} keyboardController?.hide()
} }
} }
) },
containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.Send,
modifier = Modifier.size(28.dp),
contentDescription = stringResource(R.string.add)
)
}
} }
} }
@@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.statusBars
@@ -41,6 +42,7 @@ import androidx.compose.material.icons.outlined.Clear
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallFloatingActionButton import androidx.compose.material3.SmallFloatingActionButton
@@ -132,12 +134,12 @@ private fun ChatsScreen(navController: NavController, aor: String) {
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.imePadding(), .imePadding(),
containerColor = LocalCustomColors.current.background, containerColor = MaterialTheme.colorScheme.background,
topBar = { topBar = {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()) .padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding())
) { ) {
TopAppBar(navController, account, uaMessages) TopAppBar(navController, account, uaMessages)
@@ -181,10 +183,10 @@ private fun TopAppBar(
) )
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary, navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary, titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = LocalCustomColors.current.onPrimary actionIconContentColor = MaterialTheme.colorScheme.onPrimary
), ),
navigationIcon = { navigationIcon = {
IconButton(onClick = { navController.popBackStack() }) { IconButton(onClick = { navController.popBackStack() }) {
@@ -297,9 +299,9 @@ private fun Chats(
.verticalScrollbar( .verticalScrollbar(
state = lazyListState, state = lazyListState,
width = 4.dp, width = 4.dp,
color = LocalCustomColors.current.gray color = MaterialTheme.colorScheme.outlineVariant
) )
.background(LocalCustomColors.current.background), .background(MaterialTheme.colorScheme.background),
reverseLayout = true, reverseLayout = true,
state = lazyListState, state = lazyListState,
verticalArrangement = Arrangement.spacedBy(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp),
@@ -380,24 +382,13 @@ private fun Chats(
} }
showDialog.value = true showDialog.value = true
}, },
modifier = Modifier modifier = Modifier.fillMaxWidth().wrapContentHeight().padding(end = 6.dp),
.fillMaxWidth()
.wrapContentHeight()
.padding(end = 6.dp),
shape = buttonShape, shape = buttonShape,
border = borderStroke, border = borderStroke,
color = color = if (message.direction == MESSAGE_DOWN)
if (message.direction == MESSAGE_DOWN) { MaterialTheme.colorScheme.secondaryContainer
if (BaresipService.darkTheme.value) else
LocalCustomColors.current.secondaryDark MaterialTheme.colorScheme.primaryContainer
else
LocalCustomColors.current.secondaryLight
} else {
if (BaresipService.darkTheme.value)
LocalCustomColors.current.primaryDark
else
LocalCustomColors.current.primaryLight
},
) { ) {
val peer = Utils.friendlyUri(ctx, message.peerUri, account) val peer = Utils.friendlyUri(ctx, message.peerUri, account)
val cal = GregorianCalendar() val cal = GregorianCalendar()
@@ -408,19 +399,11 @@ private fun Chats(
DateFormat.getDateInstance(DateFormat.SHORT) DateFormat.getDateInstance(DateFormat.SHORT)
val info = fmt.format(cal.time) val info = fmt.format(cal.time)
Column { Column {
val textColor = if (message.direction == MESSAGE_DOWN)
MaterialTheme.colorScheme.onSecondaryContainer
else
MaterialTheme.colorScheme.onPrimaryContainer
Row { Row {
val textColor =
if (message.direction == MESSAGE_DOWN) {
if (BaresipService.darkTheme.value)
LocalCustomColors.current.secondaryLight
else
LocalCustomColors.current.secondaryDark
} else {
if (BaresipService.darkTheme.value)
LocalCustomColors.current.primaryLight
else
LocalCustomColors.current.primaryDark
}
Text(text = peer, color = textColor, fontSize = 12.sp) Text(text = peer, color = textColor, fontSize = 12.sp)
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
Text(text = info, color = textColor, fontSize = 12.sp) Text(text = info, color = textColor, fontSize = 12.sp)
@@ -431,7 +414,7 @@ private fun Chats(
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
style = TextStyle( style = TextStyle(
color = LocalCustomColors.current.itemText, color = textColor,
fontWeight = if (message.direction == MESSAGE_DOWN && message.new) fontWeight = if (message.direction == MESSAGE_DOWN && message.new)
FontWeight.Bold else FontWeight.Normal, FontWeight.Bold else FontWeight.Normal,
fontSize = 16.sp fontSize = 16.sp
@@ -537,8 +520,7 @@ private fun NewChatPeer(ctx: Context, navController: NavController, account: Acc
.fillMaxWidth() .fillMaxWidth()
.heightIn(max = 180.dp) .heightIn(max = 180.dp)
.verticalScrollbar( .verticalScrollbar(
state = lazyListState, state = lazyListState
color = LocalCustomColors.current.gray
), ),
horizontalAlignment = Alignment.Start, horizontalAlignment = Alignment.Start,
state = lazyListState state = lazyListState
@@ -619,7 +601,7 @@ private fun NewChatPeer(ctx: Context, navController: NavController, account: Acc
} }
Spacer(Modifier.width(4.dp)) Spacer(Modifier.width(4.dp))
SmallFloatingActionButton( SmallFloatingActionButton(
modifier = Modifier.padding(end = 4.dp), modifier = Modifier.padding(end = 4.dp).offset(y = 2.dp),
onClick = { onClick = {
showSuggestions = false showSuggestions = false
val peerText = newPeer.trim() val peerText = newPeer.trim()
@@ -640,8 +622,8 @@ private fun NewChatPeer(ctx: Context, navController: NavController, account: Acc
newPeer = "" newPeer = ""
focusManager.clearFocus() focusManager.clearFocus()
}, },
containerColor = LocalCustomColors.current.accent, containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = LocalCustomColors.current.background contentColor = MaterialTheme.colorScheme.onSecondaryContainer
) { ) {
Icon( Icon(
imageVector = Icons.Filled.Add, imageVector = Icons.Filled.Add,
@@ -234,8 +234,7 @@ private fun Codecs(codecs: SnapshotStateList<Codec>, onUpdateCodecs: (List<Codec
.padding(end = 4.dp) .padding(end = 4.dp)
.verticalScrollbar( .verticalScrollbar(
state = draggableState.listState, state = draggableState.listState,
width = 4.dp, width = 4.dp
color = LocalCustomColors.current.gray
), ),
state = draggableState.listState, state = draggableState.listState,
contentPadding = PaddingValues(start = 12.dp, end = 12.dp), contentPadding = PaddingValues(start = 12.dp, end = 12.dp),
@@ -9,6 +9,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
@@ -30,6 +31,7 @@ import androidx.compose.material.icons.filled.Edit
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallFloatingActionButton import androidx.compose.material3.SmallFloatingActionButton
import androidx.compose.material3.Text import androidx.compose.material3.Text
@@ -78,12 +80,12 @@ private fun ContactsScreen(navController: NavController, viewModel: ViewModel) {
Scaffold( Scaffold(
modifier = Modifier.fillMaxSize().imePadding(), modifier = Modifier.fillMaxSize().imePadding(),
containerColor = LocalCustomColors.current.background, containerColor = MaterialTheme.colorScheme.background,
topBar = { topBar = {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding( .padding(
top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding() top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
) )
@@ -96,9 +98,9 @@ private fun ContactsScreen(navController: NavController, viewModel: ViewModel) {
) )
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary, navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary titleContentColor = MaterialTheme.colorScheme.onPrimary,
), ),
navigationIcon = { navigationIcon = {
IconButton(onClick = { navController.popBackStack() }) { IconButton(onClick = { navController.popBackStack() }) {
@@ -113,9 +115,11 @@ private fun ContactsScreen(navController: NavController, viewModel: ViewModel) {
} }
}, },
floatingActionButton = { floatingActionButton = {
SmallFloatingActionButton(onClick = { navController.navigate("baresip_contact//new") }, SmallFloatingActionButton(
containerColor = LocalCustomColors.current.accent, modifier = Modifier.offset(x = 2.dp),
contentColor = LocalCustomColors.current.background onClick = { navController.navigate("baresip_contact//new") },
containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
) { ) {
Icon(imageVector = Icons.Filled.Add, Icon(imageVector = Icons.Filled.Add,
modifier = Modifier.size(36.dp), modifier = Modifier.size(36.dp),
@@ -144,6 +148,8 @@ private fun ContactsContent(
val neutralText = remember { mutableStateOf("") } val neutralText = remember { mutableStateOf("") }
val neutralAction = remember { mutableStateOf({}) } val neutralAction = remember { mutableStateOf({}) }
Log.d("THEME_TEST", "ContactsScreen Primary: ${MaterialTheme.colorScheme.primary}")
if (showDialog.value) if (showDialog.value)
AlertDialog( AlertDialog(
showDialog = showDialog, showDialog = showDialog,
@@ -161,13 +167,13 @@ private fun ContactsContent(
LazyColumn( LazyColumn(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding(contentPadding) .padding(contentPadding)
.padding(start = 16.dp, end = 4.dp, top = 16.dp, bottom = 64.dp) .padding(start = 16.dp, end = 4.dp, top = 16.dp, bottom = 64.dp)
.verticalScrollbar( .verticalScrollbar(
state = lazyListState, state = lazyListState,
width = 4.dp, width = 4.dp,
color = LocalCustomColors.current.gray color = MaterialTheme.colorScheme.outlineVariant
), ),
state = lazyListState, state = lazyListState,
verticalArrangement = Arrangement.spacedBy(10.dp), verticalArrangement = Arrangement.spacedBy(10.dp),
@@ -288,8 +294,8 @@ private fun ContactsContent(
SmallFloatingActionButton( SmallFloatingActionButton(
modifier = Modifier.padding(end = 10.dp), modifier = Modifier.padding(end = 10.dp),
onClick = { navController.navigate("baresip_contact/${name}/old") }, onClick = { navController.navigate("baresip_contact/${name}/old") },
containerColor = LocalCustomColors.current.background, containerColor = MaterialTheme.colorScheme.tertiaryContainer,
contentColor = LocalCustomColors.current.secondary contentColor = MaterialTheme.colorScheme.onTertiaryContainer
) { ) {
Icon( Icon(
imageVector = Icons.Filled.Edit, imageVector = Icons.Filled.Edit,
@@ -58,17 +58,17 @@ data class CustomColors(
) )
val light_primary = Color(0xff0ca1fd) val light_primary = Color(0xff0ca1fd)
val light_on_primary = Color(0xffe0e0e0) val light_on_primary = Color(0xFFFFFFFF)
val light_primary_container = Color(0xFFA1CBE6) val light_primary_container = Color(0xFFA1CBE6)
val light_on_primary_container = Color(0xFF032133) val light_on_primary_container = Color(0xFF032133)
val light_secondary = Color(0xFF00B9A1) val light_secondary = Color(0xFF00B9A1)
val light_on_secondary = Color(0xffe0e0e0) val light_on_secondary = Color(0xffe0e0e0)
val light_secondary_container = Color(0xFF9DE6DC) val light_secondary_container = Color(0xFF9DE6DC)
val light_on_secondary_container = Color(0xFF00332C) val light_on_secondary_container = Color(0xFF00332C)
val light_tertiary = Color(0xFF7D5260) val light_tertiary = Color(0xFF9885B5)
val light_on_tertiary = Color(0xffe0e0e0) val light_on_tertiary = Color(0xffe0e0e0)
val light_tertiary_container = Color(0xFFE6CDD5) val light_tertiary_container = Color(0xFFDAD2E6)
val light_on_tertiary_container = Color(0xFF332227) val light_on_tertiary_container = Color(0xFF2B2533)
val light_error = Color(0xFFF77445) val light_error = Color(0xFFF77445)
val light_on_error = Color(0xffe0e0e0) val light_on_error = Color(0xffe0e0e0)
val light_error_container = Color(0xFFE6BFB1) val light_error_container = Color(0xFFE6BFB1)
@@ -105,10 +105,10 @@ val dark_secondary = Color(0xFF7FE6D8)
val dark_on_secondary = Color(0xFF004C43) val dark_on_secondary = Color(0xFF004C43)
val dark_secondary_container = Color(0xFF006659) val dark_secondary_container = Color(0xFF006659)
val dark_on_secondary_container = Color(0xFF9DE6DC) val dark_on_secondary_container = Color(0xFF9DE6DC)
val dark_tertiary = Color(0xFFE6C3CE) val dark_tertiary = Color(0xFFD5CAE6)
val dark_on_tertiary = Color(0xFF4C323B) val dark_on_tertiary = Color(0xFF40384C)
val dark_tertiary_container = Color(0xFF66434F) val dark_tertiary_container = Color(0xFF564A66)
val dark_on_tertiary_container = Color(0xFFE6CDD5) val dark_on_tertiary_container = Color(0xFFDAD2E6)
val dark_error = Color(0xFFE6AF9C) val dark_error = Color(0xFFE6AF9C)
val dark_on_error = Color(0xFF4C2415) val dark_on_error = Color(0xFF4C2415)
val dark_error_container = Color(0xFF66301D) val dark_error_container = Color(0xFF66301D)
@@ -65,8 +65,10 @@ import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults import androidx.compose.material3.CardDefaults
import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.OutlinedTextFieldDefaults import androidx.compose.material3.OutlinedTextFieldDefaults
@@ -456,12 +458,12 @@ private fun MainScreen(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.imePadding(), .imePadding(),
containerColor = LocalCustomColors.current.background, containerColor = MaterialTheme.colorScheme.background,
topBar = { topBar = {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding( .padding(
top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding() top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
) )
@@ -525,8 +527,9 @@ private fun TopAppBar(
) )
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = LocalCustomColors.current.onPrimary titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary
), ),
windowInsets = WindowInsets(0, 0, 0, 0), windowInsets = WindowInsets(0, 0, 0, 0),
actions = { actions = {
@@ -542,11 +545,13 @@ private fun TopAppBar(
recImage = if (BaresipService.isRecOn) { recImage = if (BaresipService.isRecOn) {
Api.module_load("sndfile") Api.module_load("sndfile")
recOnImage recOnImage
} else { }
else {
Api.module_unload("sndfile") Api.module_unload("sndfile")
recOffImage recOffImage
} }
} else }
else
Toast.makeText(ctx, R.string.rec_in_call, Toast.LENGTH_SHORT) Toast.makeText(ctx, R.string.rec_in_call, Toast.LENGTH_SHORT)
.show() .show()
}, },
@@ -557,9 +562,9 @@ private fun TopAppBar(
} }
), ),
tint = if (BaresipService.isRecOn) tint = if (BaresipService.isRecOn)
LocalCustomColors.current.accent MaterialTheme.colorScheme.error
else else
LocalCustomColors.current.onPrimary, MaterialTheme.colorScheme.onPrimary,
contentDescription = null contentDescription = null
) )
@@ -576,7 +581,8 @@ private fun TopAppBar(
if (BaresipService.isMicMuted) { if (BaresipService.isMicMuted) {
viewModel.updateMicIcon(R.drawable.mic_off) viewModel.updateMicIcon(R.drawable.mic_off)
Api.calls_mute(true) Api.calls_mute(true)
} else { }
else {
viewModel.updateMicIcon(R.drawable.mic_on) viewModel.updateMicIcon(R.drawable.mic_on)
Api.calls_mute(false) Api.calls_mute(false)
} }
@@ -589,9 +595,9 @@ private fun TopAppBar(
}, },
), ),
tint = if (BaresipService.isMicMuted) tint = if (BaresipService.isMicMuted)
LocalCustomColors.current.accent MaterialTheme.colorScheme.error
else else
LocalCustomColors.current.onPrimary, MaterialTheme.colorScheme.onPrimary,
contentDescription = null contentDescription = null
) )
@@ -623,9 +629,9 @@ private fun TopAppBar(
}, },
), ),
tint = if (Utils.isSpeakerPhoneOn(am)) tint = if (Utils.isSpeakerPhoneOn(am))
LocalCustomColors.current.accent MaterialTheme.colorScheme.error
else else
LocalCustomColors.current.onPrimary, MaterialTheme.colorScheme.onPrimary,
contentDescription = null contentDescription = null
) )
@@ -637,7 +643,7 @@ private fun TopAppBar(
Icon( Icon(
imageVector = Icons.Filled.Menu, imageVector = Icons.Filled.Menu,
contentDescription = "Menu", contentDescription = "Menu",
tint = LocalCustomColors.current.onPrimary tint = MaterialTheme.colorScheme.onPrimary
) )
} }
@@ -715,9 +721,9 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
contentDescription = null, contentDescription = null,
Modifier.size(buttonSize), Modifier.size(buttonSize),
tint = if (vmIcon == R.drawable.voicemail) tint = if (vmIcon == R.drawable.voicemail)
LocalCustomColors.current.onBackground MaterialTheme.colorScheme.secondary
else else
LocalCustomColors.current.accent MaterialTheme.colorScheme.error
) )
} }
@@ -731,7 +737,7 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
imageVector = ImageVector.vectorResource(R.drawable.contacts), imageVector = ImageVector.vectorResource(R.drawable.contacts),
contentDescription = null, contentDescription = null,
Modifier.size(buttonSize), Modifier.size(buttonSize),
tint = LocalCustomColors.current.onBackground tint = MaterialTheme.colorScheme.secondary
) )
} }
@@ -749,9 +755,9 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
contentDescription = null, contentDescription = null,
Modifier.size(buttonSize), Modifier.size(buttonSize),
tint = if (messagesIcon == R.drawable.messages) tint = if (messagesIcon == R.drawable.messages)
LocalCustomColors.current.onBackground MaterialTheme.colorScheme.secondary
else else
LocalCustomColors.current.accent MaterialTheme.colorScheme.error
) )
} }
@@ -769,9 +775,9 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
contentDescription = null, contentDescription = null,
Modifier.size(buttonSize), Modifier.size(buttonSize),
tint = if (callsIcon == R.drawable.calls) tint = if (callsIcon == R.drawable.calls)
LocalCustomColors.current.onBackground MaterialTheme.colorScheme.secondary
else else
LocalCustomColors.current.accent MaterialTheme.colorScheme.error
) )
} }
@@ -792,9 +798,9 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
contentDescription = null, contentDescription = null,
modifier = Modifier.size(buttonSize), modifier = Modifier.size(buttonSize),
tint = if (dialpadIcon == R.drawable.dialpad_off) tint = if (dialpadIcon == R.drawable.dialpad_off)
LocalCustomColors.current.onBackground MaterialTheme.colorScheme.secondary
else else
LocalCustomColors.current.accent MaterialTheme.colorScheme.error
) )
} }
} }
@@ -916,7 +922,8 @@ private fun MainContent(navController: NavController, viewModel: ViewModel, cont
showCall(ctx, viewModel, ua) showCall(ctx, viewModel, ua)
} }
} }
} else if (offset > swipeThreshold) { }
else if (offset > swipeThreshold) {
if (uas.value.isNotEmpty()) { if (uas.value.isNotEmpty()) {
val curPos = UserAgent.findAorIndex(viewModel.selectedAor.value) val curPos = UserAgent.findAorIndex(viewModel.selectedAor.value)
val newPos = when (curPos) { val newPos = when (curPos) {
@@ -1013,7 +1020,8 @@ private fun AccountSpinner(ctx: Context, viewModel: ViewModel, navController: Na
if (Api.account_regint(acc.accp) > 0) { if (Api.account_regint(acc.accp) > 0) {
Api.account_set_regint(acc.accp, 0) Api.account_set_regint(acc.accp, 0)
Api.ua_unregister(ua.uap) Api.ua_unregister(ua.uap)
} else { }
else {
Api.account_set_regint( Api.account_set_regint(
acc.accp, acc.accp,
acc.configuredRegInt acc.configuredRegInt
@@ -1027,8 +1035,8 @@ private fun AccountSpinner(ctx: Context, viewModel: ViewModel, navController: Na
) )
}, },
colors = ButtonColors( colors = ButtonColors(
containerColor = LocalCustomColors.current.grayLight, containerColor = MaterialTheme.colorScheme.surfaceVariant,
contentColor = LocalCustomColors.current.dark, contentColor = MaterialTheme.colorScheme.onSurfaceVariant,
disabledContainerColor = LocalCustomColors.current.grayLight, disabledContainerColor = LocalCustomColors.current.grayLight,
disabledContentColor = LocalCustomColors.current.dark disabledContentColor = LocalCustomColors.current.dark
), ),
@@ -1064,7 +1072,8 @@ private fun AccountSpinner(ctx: Context, viewModel: ViewModel, navController: Na
if (Api.account_regint(acc.accp) > 0) { if (Api.account_regint(acc.accp) > 0) {
Api.account_set_regint(acc.accp, 0) Api.account_set_regint(acc.accp, 0)
Api.ua_unregister(ua.uap) Api.ua_unregister(ua.uap)
} else { }
else {
Api.account_set_regint( Api.account_set_regint(
acc.accp, acc.accp,
acc.configuredRegInt acc.configuredRegInt
@@ -1087,8 +1096,9 @@ private fun AccountSpinner(ctx: Context, viewModel: ViewModel, navController: Na
androidx.compose.material3.DropdownMenu( androidx.compose.material3.DropdownMenu(
expanded = expanded, expanded = expanded,
onDismissRequest = { expanded = false }, onDismissRequest = { expanded = false },
containerColor = MaterialTheme.colorScheme.surfaceContainer,
) { ) {
uas.value.forEachIndexed { _, ua -> uas.value.forEachIndexed { index, ua ->
val acc = ua.account val acc = ua.account
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
@@ -1110,6 +1120,9 @@ private fun AccountSpinner(ctx: Context, viewModel: ViewModel, navController: Na
) )
} }
) )
if (index < uas.value.size - 1) {
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
}
} }
} }
} }
@@ -1204,8 +1217,7 @@ private fun CallUriRow(ctx: Context, viewModel: ViewModel) {
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.verticalScrollbar( .verticalScrollbar(
state = lazyListState, state = lazyListState
color = LocalCustomColors.current.gray
), ),
horizontalAlignment = Alignment.Start, horizontalAlignment = Alignment.Start,
state = lazyListState state = lazyListState
@@ -1494,7 +1506,7 @@ private fun CallRow(ctx: Context, viewModel: ViewModel) {
Text( Text(
text = stringResource(R.string.call_transfer), text = stringResource(R.string.call_transfer),
fontSize = 20.sp, fontSize = 20.sp,
color = LocalCustomColors.current.alert, color = MaterialTheme.colorScheme.error,
) )
var transferUri by remember { mutableStateOf("") } var transferUri by remember { mutableStateOf("") }
val suggestions by remember { contactNames } val suggestions by remember { contactNames }
@@ -1569,8 +1581,7 @@ private fun CallRow(ctx: Context, viewModel: ViewModel) {
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.verticalScrollbar( .verticalScrollbar(
state = lazyListState, state = lazyListState
color = LocalCustomColors.current.gray
), ),
horizontalAlignment = Alignment.Start, horizontalAlignment = Alignment.Start,
state = lazyListState, state = lazyListState,
@@ -1696,7 +1707,7 @@ private fun CallRow(ctx: Context, viewModel: ViewModel) {
else else
R.string.call R.string.call
).uppercase(), ).uppercase(),
color = LocalCustomColors.current.primary color = MaterialTheme.colorScheme.primary
) )
} }
} }
@@ -1819,7 +1830,7 @@ private fun CallRow(ctx: Context, viewModel: ViewModel) {
private fun OnHoldNotice() { private fun OnHoldNotice() {
OutlinedButton( OutlinedButton(
onClick = {}, onClick = {},
border = BorderStroke(1.dp, LocalCustomColors.current.accent), border = BorderStroke(1.dp, MaterialTheme.colorScheme.error),
modifier = Modifier.padding(16.dp), modifier = Modifier.padding(16.dp),
shape = RoundedCornerShape(20) shape = RoundedCornerShape(20)
) { ) {
@@ -35,6 +35,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
@@ -47,6 +49,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
@@ -148,13 +151,15 @@ private fun SettingsScreen(
} }
Scaffold( Scaffold(
modifier = Modifier.fillMaxSize().imePadding(), modifier = Modifier
containerColor = LocalCustomColors.current.background, .fillMaxSize()
.imePadding(),
containerColor = MaterialTheme.colorScheme.background,
topBar = { topBar = {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.background(LocalCustomColors.current.background) .background(MaterialTheme.colorScheme.background)
.padding( .padding(
top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding() top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
) )
@@ -167,10 +172,10 @@ private fun SettingsScreen(
) )
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary, containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary, navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary, titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = LocalCustomColors.current.onPrimary actionIconContentColor = MaterialTheme.colorScheme.onPrimary
), ),
navigationIcon = { navigationIcon = {
IconButton(onClick = onBack) { IconButton(onClick = onBack) {
@@ -1247,39 +1252,45 @@ private fun SettingsContent(
save = true save = true
} }
val scrollState = rememberScrollState() val lazyListState = rememberLazyListState()
Column( LazyColumn(
state = lazyListState,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(contentPadding) .padding(contentPadding)
.padding(start = 16.dp, end = 4.dp, top = 16.dp, bottom = 8.dp) .padding(start = 16.dp, end = 4.dp, top = 16.dp, bottom = 8.dp)
.verticalScrollbar(scrollState) .verticalScrollbar(
.verticalScroll(state = scrollState), state = lazyListState,
width = 4.dp,
color = MaterialTheme.colorScheme.outlineVariant
),
verticalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp),
) { ) {
StartAutomatically() item { StartAutomatically() }
ListenAddress() item { ListenAddress() }
AddressFamily() item { AddressFamily() }
DnsServers() item { DnsServers() }
TlsCertificateFile(activity) item { TlsCertificateFile(activity) }
VerifyServer() item { VerifyServer() }
CaFile(activity) item { CaFile(activity) }
UserAgent() item { UserAgent() }
AudioSettings(navController) item { AudioSettings(navController) }
Contacts(activity) item { Contacts(activity) }
Ringtone(ctx) item { Ringtone(ctx) }
BatteryOptimizations() item { BatteryOptimizations() }
DarkTheme() item { DarkTheme() }
if (VERSION.SDK_INT >= 31) if (VERSION.SDK_INT >= 31) {
DynamicColors() item { DynamicColors() }
ColorBlind() }
ProximitySensing() item { ColorBlind() }
if (VERSION.SDK_INT >= 29) item { ProximitySensing() }
DefaultDialer() if (VERSION.SDK_INT >= 29) {
Debug() item { DefaultDialer() }
SipTrace() }
Reset(onRestartApp) item { Debug() }
item { SipTrace() }
item { Reset(onRestartApp) }
} }
} }
-5
View File
@@ -1,5 +0,0 @@
<vector android:height="48dp" android:tint="@color/colorAccent"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13h-4v4h-2v-4L7,13v-2h4L11,7h2v4h4v2z"/>
</vector>
-5
View File
@@ -1,5 +0,0 @@
<vector android:height="36dp" android:tint="@color/colorAccent"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="36dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>