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

View File

@ -16,6 +16,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
@ -44,12 +45,12 @@ fun NavGraphBuilder.aboutScreenRoute(navController: NavController) {
private fun AboutScreen(onBack: () -> Unit) {
Scaffold(
modifier = Modifier.fillMaxSize().imePadding(),
containerColor = LocalCustomColors.current.background,
containerColor = MaterialTheme.colorScheme.background,
topBar = {
Column(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(
top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
)
@ -70,9 +71,9 @@ private fun AboutScreen(onBack: () -> Unit) {
}
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
titleContentColor = LocalCustomColors.current.onPrimary,
navigationIconContentColor = LocalCustomColors.current.onPrimary,
containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
),
windowInsets = WindowInsets(0, 0, 0, 0)
)
@ -82,9 +83,9 @@ private fun AboutScreen(onBack: () -> Unit) {
Text(
text = AnnotatedString.fromHtml(
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
.padding(horizontal = 16.dp, vertical = 16.dp)
.padding(contentPadding)

View File

@ -13,8 +13,13 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
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.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
@ -66,12 +71,12 @@ fun NavGraphBuilder.accountsScreenRoute(navController: NavController) {
fun AccountsScreen(navController: NavController) {
Scaffold(
modifier = Modifier.fillMaxSize().imePadding(),
containerColor = LocalCustomColors.current.background,
containerColor = MaterialTheme.colorScheme.background,
topBar = {
Column(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(
top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
)
@ -84,9 +89,9 @@ fun AccountsScreen(navController: NavController) {
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary,
containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
),
navigationIcon = {
IconButton(onClick = { navController.popBackStack() }) {
@ -128,17 +133,23 @@ fun AccountsContent(contentPadding: PaddingValues, navController: NavController)
val showAccounts = remember { mutableStateOf(true) }
if (showAccounts.value && BaresipService.uas.value.isNotEmpty()) {
val scrollState = rememberScrollState()
Column(
val lazyListState = rememberLazyListState()
LazyColumn(
state = lazyListState,
modifier = Modifier
.fillMaxWidth()
.padding(contentPadding)
.padding(start = 16.dp, end = 4.dp, top = 8.dp, bottom = 8.dp)
.verticalScrollbar(scrollState)
.verticalScroll(state = scrollState),
.verticalScrollbar(
state = lazyListState,
width = 4.dp,
color = MaterialTheme.colorScheme.outlineVariant
),
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
for (ua in BaresipService.uas.value) {
items(BaresipService.uas.value) { ua ->
val account = ua.account
val aor = account.aor
val text = account.text()
@ -148,13 +159,16 @@ fun AccountsContent(contentPadding: PaddingValues, navController: NavController)
Text(
text = text,
fontSize = 20.sp,
color = LocalCustomColors.current.itemText,
modifier = Modifier.weight(1f).padding(start = 10.dp)
color = MaterialTheme.colorScheme.onBackground,
modifier = Modifier
.weight(1f)
.padding(start = 10.dp)
.clickable {
navController.navigate("account/$aor/old")
}
)
SmallFloatingActionButton(
modifier = Modifier.padding(end = 8.dp),
onClick = {
message.value = String.format(
ctx.getString(R.string.delete_account),
@ -280,6 +294,7 @@ fun NewAccount(navController: NavController) {
)
)
SmallFloatingActionButton(
modifier = Modifier.offset(y = 2.dp),
onClick = {
val account = createNew(ctx, newAor.trim())
if (account != null) {
@ -293,6 +308,7 @@ fun NewAccount(navController: NavController) {
) {
Icon(
imageVector = Icons.Filled.Add,
modifier = Modifier.size(36.dp),
contentDescription = stringResource(R.string.add)
)
}

View File

@ -29,6 +29,7 @@ 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.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
@ -53,6 +54,7 @@ import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import coil.compose.AsyncImage
import com.tutpro.baresip.CustomElements.verticalScrollbar
fun NavGraphBuilder.androidContactScreenRoute(navController: NavController, viewModel: ViewModel) {
composable(
@ -79,12 +81,12 @@ private fun ContactScreen(ctx: Context, viewModel: ViewModel, navController: Nav
}
Scaffold(
modifier = Modifier.fillMaxSize().imePadding(),
containerColor = LocalCustomColors.current.background,
containerColor = MaterialTheme.colorScheme.background,
topBar = {
Column(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding())
) {
TopAppBar(name, navController)
@ -107,9 +109,9 @@ private fun TopAppBar(title: String, navController: NavController) {
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary,
containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
),
windowInsets = WindowInsets(0, 0, 0, 0),
navigationIcon = {
@ -134,7 +136,7 @@ private fun ContactContent(
Column(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(contentPadding)
.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 52.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
@ -192,7 +194,7 @@ private fun ContactName(name: String) {
verticalAlignment = Alignment.CenterVertically,
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
.fillMaxWidth()
.padding(start = 16.dp, end = 4.dp)
.background(LocalCustomColors.current.background),
.background(MaterialTheme.colorScheme.background),
state = lazyListState,
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
@ -220,11 +222,11 @@ private fun Uris(
text = uri.substringAfter(":"),
modifier = Modifier.weight(1f),
fontSize = 18.sp,
color = LocalCustomColors.current.itemText,
color = MaterialTheme.colorScheme.onBackground,
)
Image(
painter = painterResource(R.drawable.message),
colorFilter = ColorFilter.tint(LocalCustomColors.current.itemText),
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onBackground),
contentDescription = "Send Message",
modifier = Modifier.padding(end = 24.dp).clickable {
val aor = viewModel.selectedAor.value
@ -245,7 +247,7 @@ private fun Uris(
)
Image(
painter = painterResource(R.drawable.call_small),
colorFilter = ColorFilter.tint(LocalCustomColors.current.itemText),
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onBackground),
contentDescription = "Call",
modifier = Modifier.clickable {
val aor = viewModel.selectedAor.value

View File

@ -2,6 +2,7 @@ package com.tutpro.baresip
import android.app.Activity
import android.os.Build.VERSION
import android.util.Log
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
@ -9,7 +10,6 @@ import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
@ -28,6 +28,7 @@ fun AppTheme(
val useDynamicColors by remember { BaresipService.dynamicColors }
val useActualDynamicColors = useDynamicColors && VERSION.SDK_INT >= 31
Log.d(TAG, "Use actual dynamic colors: $useActualDynamicColors")
val colorScheme = when {
@ -37,51 +38,71 @@ fun AppTheme(
else
dynamicLightColorScheme(context)
}
useDarkTheme || isSystemInDarkTheme() -> darkColorScheme()
else -> lightColorScheme()
}
val basePalette = if (useDarkTheme) DarkCustomColors else LightCustomColors
val customColorsPalette = basePalette.copy(
background = colorScheme.background,
onBackground = if (useActualDynamicColors)
colorScheme.onBackground
else
basePalette.onBackground,
cardBackground = colorScheme.surfaceVariant,
textFieldBackground = colorScheme.surfaceVariant,
primary = if (useActualDynamicColors)
colorScheme.primary
else
basePalette.primary,
onPrimary = if (useActualDynamicColors)
colorScheme.onPrimary
else
basePalette.onPrimary
useDarkTheme || isSystemInDarkTheme() -> darkColorScheme(
primary = dark_primary,
onPrimary = dark_on_primary,
primaryContainer = dark_primary_container,
onPrimaryContainer = dark_on_primary_container,
secondary = dark_secondary,
onSecondary = dark_on_secondary,
secondaryContainer = dark_secondary_container,
onSecondaryContainer = dark_on_secondary_container,
tertiary = dark_tertiary,
onTertiary = dark_on_tertiary,
tertiaryContainer = dark_tertiary_container,
onTertiaryContainer = dark_on_tertiary_container,
error = dark_error,
onError = dark_on_error,
errorContainer = dark_error_container,
onErrorContainer = dark_on_error_container,
background = dark_background,
onBackground = dark_on_background,
surface = dark_surface,
onSurface = dark_on_surface,
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
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
val insetsController = WindowCompat.getInsetsController(window, view)
// 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
val isBackgroundEffectivelyLight = ColorUtils.calculateLuminance(colorScheme.background.toArgb()) > 0.5
insetsController.isAppearanceLightStatusBars = isBackgroundEffectivelyLight
insetsController.isAppearanceLightNavigationBars = isBackgroundEffectivelyLight
}
}
CompositionLocalProvider(
LocalCustomColors provides customColorsPalette
) {
MaterialTheme(
colorScheme = colorScheme, // MaterialTheme still uses the "normal" colorScheme
content = content
)
}
MaterialTheme(
colorScheme = colorScheme,
content = content
)
}

View File

@ -42,6 +42,7 @@ import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Switch
@ -196,12 +197,12 @@ private fun ContactScreen(
modifier = Modifier
.fillMaxSize()
.imePadding(),
containerColor = LocalCustomColors.current.background,
containerColor = MaterialTheme.colorScheme.background,
topBar = {
Column(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding())
) {
TopAppBar(title, onBack = onBack, onCheck = onCheck)
@ -235,10 +236,10 @@ private fun TopAppBar(title: String, onBack: () -> Unit, onCheck: () -> Unit) {
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary,
actionIconContentColor = LocalCustomColors.current.onPrimary
containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary
),
windowInsets = WindowInsets(0, 0, 0, 0),
navigationIcon = {
@ -285,7 +286,7 @@ private fun ContactContent(
Column(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(contentPadding)
.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 52.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
@ -438,7 +439,7 @@ private fun Avatar(
@Composable
private fun ContactName(name: String, new: Boolean, onNameChange: (String) -> Unit) {
val focusRequester = FocusRequester()
val focusRequester = remember { FocusRequester() }
OutlinedTextField(
value = name,
placeholder = { Text(stringResource(R.string.contact_name)) },
@ -447,7 +448,7 @@ private fun ContactName(name: String, new: Boolean, onNameChange: (String) -> Un
.fillMaxWidth()
.focusRequester(focusRequester),
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)) },
keyboardOptions = KeyboardOptions(
@ -469,7 +470,7 @@ private fun ContactUri(uri: String, onUriChange: (String) -> Unit) {
onValueChange = onUriChange,
modifier = Modifier.fillMaxWidth(),
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)) },
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)
showAlert.value = true
},
color = LocalCustomColors.current.itemText,
color = MaterialTheme.colorScheme.onBackground,
)
Switch(
checked = favorite,
@ -511,7 +512,7 @@ private fun Android(android: Boolean, onAndroidChange: (Boolean) -> Unit) {
Text(
text = stringResource(R.string.android),
modifier = Modifier.weight(1f),
color = LocalCustomColors.current.itemText
color = MaterialTheme.colorScheme.onBackground
)
Switch(
checked = android,

View File

@ -29,6 +29,7 @@ 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.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
@ -86,9 +87,9 @@ private fun CallDetailsScreen(navController: NavController, callRow: CallRow) {
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary,
containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
),
windowInsets = WindowInsets(0, 0, 0, 0),
navigationIcon = {
@ -164,8 +165,7 @@ private fun Details(ctx: Context, details: ArrayList<Details>) {
modifier = Modifier.fillMaxWidth()
.verticalScrollbar(
state = lazyListState,
width = 4.dp,
color = LocalCustomColors.current.gray
width = 4.dp
)
.background(LocalCustomColors.current.background),
state = lazyListState,

View File

@ -34,6 +34,7 @@ import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
@ -152,10 +153,10 @@ private fun TopAppBar(navController: NavController, account: Account, callHistor
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary,
actionIconContentColor = LocalCustomColors.current.onPrimary
containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary
),
windowInsets = WindowInsets(0, 0, 0, 0),
navigationIcon = {
@ -275,9 +276,9 @@ private fun Calls(
.verticalScrollbar(
state = lazyListState,
width = 4.dp,
color = LocalCustomColors.current.gray
color = MaterialTheme.colorScheme.outlineVariant
)
.background(LocalCustomColors.current.background),
.background(MaterialTheme.colorScheme.background),
state = lazyListState,
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
@ -398,13 +399,13 @@ private fun Calls(
count++
}
if (count > 3)
Text("...", color = LocalCustomColors.current.itemText)
Text("...", color = MaterialTheme.colorScheme.onPrimaryContainer)
Text(text = Utils.friendlyUri(ctx, peerUri, account),
modifier = Modifier.padding(start = 8.dp),
fontSize = 18.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
color = LocalCustomColors.current.itemText
color = MaterialTheme.colorScheme.onPrimaryContainer
)
}
}
@ -415,9 +416,9 @@ private fun Calls(
lineHeight = 16.sp,
textAlign = TextAlign.End,
color = if (recordings)
LocalCustomColors.current.accent
MaterialTheme.colorScheme.error
else
LocalCustomColors.current.itemText,
MaterialTheme.colorScheme.onPrimaryContainer,
modifier = Modifier
.padding(end = 16.dp)
.clickable(onClick = {

View File

@ -6,7 +6,6 @@ import android.text.format.DateUtils.isToday
import android.widget.Toast
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
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.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
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.material.icons.Icons
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.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallFloatingActionButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
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.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.TextStyle
@ -175,11 +176,11 @@ private fun ChatScreen(
modifier = Modifier
.fillMaxSize()
.imePadding(),
containerColor = LocalCustomColors.current.background,
containerColor = MaterialTheme.colorScheme.background,
topBar = {
Column(modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding())
) {
TopAppBar(ctx, navController, viewModel, account, peerUri)
@ -227,10 +228,10 @@ private fun TopAppBar(
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary,
actionIconContentColor = LocalCustomColors.current.onPrimary
containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary
),
navigationIcon = {
IconButton(onClick = { backAction(navController, account, peerUri) }) {
@ -351,8 +352,9 @@ private fun Messages(
.verticalScrollbar(
state = lazyListState,
width = 4.dp,
color = LocalCustomColors.current.gray
),
color = MaterialTheme.colorScheme.outlineVariant
)
.background(MaterialTheme.colorScheme.background),
reverseLayout = true,
state = lazyListState,
verticalArrangement = Arrangement.spacedBy(16.dp),
@ -417,17 +419,10 @@ private fun Messages(
RoundedCornerShape(20.dp, 10.dp, 50.dp, 20.dp),
colors = ButtonDefaults.buttonColors(
containerColor =
if (message.direction == MESSAGE_DOWN) {
if (BaresipService.darkTheme.value)
LocalCustomColors.current.secondaryDark
else
LocalCustomColors.current.secondaryLight
} else {
if (BaresipService.darkTheme.value)
LocalCustomColors.current.primaryDark
else
LocalCustomColors.current.primaryLight
}
if (message.direction == MESSAGE_DOWN)
MaterialTheme.colorScheme.secondaryContainer
else
MaterialTheme.colorScheme.primaryContainer
),
modifier = Modifier
.fillMaxWidth()
@ -438,19 +433,11 @@ private fun Messages(
)
) {
Column {
val textColor = if (message.direction == MESSAGE_DOWN)
MaterialTheme.colorScheme.onSecondaryContainer
else
MaterialTheme.colorScheme.onPrimaryContainer
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)
Spacer(modifier = Modifier.weight(1f))
Text(text = info, fontSize = 12.sp, color = textColor)
@ -459,7 +446,7 @@ private fun Messages(
SelectionContainer {
Text(
text = message.message,
color = LocalCustomColors.current.itemText,
color = textColor,
fontWeight = if (message.direction == MESSAGE_DOWN && message.new)
FontWeight.Bold else FontWeight.Normal
)
@ -549,59 +536,68 @@ private fun NewMessage(
if (newMessage.value.text.isNotEmpty())
focusRequester.requestFocus()
}
Image(
painter = painterResource(id = R.drawable.send),
contentDescription = "Send",
contentScale = ContentScale.Crop,
modifier = Modifier
.size(36.dp)
.clickable {
val msgText = newMessage.value.text
if (msgText.isNotEmpty()) {
keyboardController?.hide()
val time = System.currentTimeMillis()
val msg = Message(
aor,
peerUri,
msgText,
time,
MESSAGE_UP_WAIT,
0,
"",
true
)
msg.add()
var msgUri = ""
addMessage(msg)
if (Utils.isTelUri(peerUri))
if (ua.account.telProvider == "") {
dialogMessage.value = String.format(
ctx.getString(R.string.no_telephony_provider),
Utils.plainAor(aor)
)
showDialog.value = true
} else {
msgUri = Utils.telToSip(peerUri, ua.account)
}
else
msgUri = peerUri
if (msgUri != "")
if (Api.message_send(ua.uap, msgUri, msgText, time.toString()) != 0
) {
Toast.makeText(
ctx, "${ctx.getString(R.string.message_failed)}!",
Toast.LENGTH_SHORT
).show()
msg.direction = MESSAGE_UP_FAIL
msg.responseReason = ctx.getString(R.string.message_failed)
} else {
newMessage.value = TextFieldValue("")
viewModel.updateAorPeerMessage(aor, peerUri, "")
keyboardController?.hide()
}
}
SmallFloatingActionButton(
modifier = Modifier.offset(y = 2.dp),
onClick = {
val msgText = newMessage.value.text
if (msgText.isNotEmpty()) {
keyboardController?.hide()
val time = System.currentTimeMillis()
val msg = Message(
aor,
peerUri,
msgText,
time,
MESSAGE_UP_WAIT,
0,
"",
true
)
msg.add()
var msgUri = ""
addMessage(msg)
if (Utils.isTelUri(peerUri))
if (ua.account.telProvider == "") {
dialogMessage.value = String.format(
ctx.getString(R.string.no_telephony_provider),
Utils.plainAor(aor)
)
showDialog.value = true
}
else {
msgUri = Utils.telToSip(peerUri, ua.account)
}
else
msgUri = peerUri
if (msgUri != "")
if (Api.message_send(ua.uap,
msgUri,
msgText,
time.toString()
) != 0) {
Toast.makeText(
ctx, "${ctx.getString(R.string.message_failed)}!",
Toast.LENGTH_SHORT
).show()
msg.direction = MESSAGE_UP_FAIL
msg.responseReason = ctx.getString(R.string.message_failed)
}
else {
newMessage.value = TextFieldValue("")
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)
)
}
}
}

View File

@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
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.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallFloatingActionButton
@ -132,12 +134,12 @@ private fun ChatsScreen(navController: NavController, aor: String) {
modifier = Modifier
.fillMaxSize()
.imePadding(),
containerColor = LocalCustomColors.current.background,
containerColor = MaterialTheme.colorScheme.background,
topBar = {
Column(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding())
) {
TopAppBar(navController, account, uaMessages)
@ -181,10 +183,10 @@ private fun TopAppBar(
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary,
actionIconContentColor = LocalCustomColors.current.onPrimary
containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary
),
navigationIcon = {
IconButton(onClick = { navController.popBackStack() }) {
@ -297,9 +299,9 @@ private fun Chats(
.verticalScrollbar(
state = lazyListState,
width = 4.dp,
color = LocalCustomColors.current.gray
color = MaterialTheme.colorScheme.outlineVariant
)
.background(LocalCustomColors.current.background),
.background(MaterialTheme.colorScheme.background),
reverseLayout = true,
state = lazyListState,
verticalArrangement = Arrangement.spacedBy(16.dp),
@ -380,24 +382,13 @@ private fun Chats(
}
showDialog.value = true
},
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(end = 6.dp),
modifier = Modifier.fillMaxWidth().wrapContentHeight().padding(end = 6.dp),
shape = buttonShape,
border = borderStroke,
color =
if (message.direction == MESSAGE_DOWN) {
if (BaresipService.darkTheme.value)
LocalCustomColors.current.secondaryDark
else
LocalCustomColors.current.secondaryLight
} else {
if (BaresipService.darkTheme.value)
LocalCustomColors.current.primaryDark
else
LocalCustomColors.current.primaryLight
},
color = if (message.direction == MESSAGE_DOWN)
MaterialTheme.colorScheme.secondaryContainer
else
MaterialTheme.colorScheme.primaryContainer
) {
val peer = Utils.friendlyUri(ctx, message.peerUri, account)
val cal = GregorianCalendar()
@ -408,19 +399,11 @@ private fun Chats(
DateFormat.getDateInstance(DateFormat.SHORT)
val info = fmt.format(cal.time)
Column {
val textColor = if (message.direction == MESSAGE_DOWN)
MaterialTheme.colorScheme.onSecondaryContainer
else
MaterialTheme.colorScheme.onPrimaryContainer
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)
Spacer(modifier = Modifier.weight(1f))
Text(text = info, color = textColor, fontSize = 12.sp)
@ -431,7 +414,7 @@ private fun Chats(
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = TextStyle(
color = LocalCustomColors.current.itemText,
color = textColor,
fontWeight = if (message.direction == MESSAGE_DOWN && message.new)
FontWeight.Bold else FontWeight.Normal,
fontSize = 16.sp
@ -537,8 +520,7 @@ private fun NewChatPeer(ctx: Context, navController: NavController, account: Acc
.fillMaxWidth()
.heightIn(max = 180.dp)
.verticalScrollbar(
state = lazyListState,
color = LocalCustomColors.current.gray
state = lazyListState
),
horizontalAlignment = Alignment.Start,
state = lazyListState
@ -619,7 +601,7 @@ private fun NewChatPeer(ctx: Context, navController: NavController, account: Acc
}
Spacer(Modifier.width(4.dp))
SmallFloatingActionButton(
modifier = Modifier.padding(end = 4.dp),
modifier = Modifier.padding(end = 4.dp).offset(y = 2.dp),
onClick = {
showSuggestions = false
val peerText = newPeer.trim()
@ -640,8 +622,8 @@ private fun NewChatPeer(ctx: Context, navController: NavController, account: Acc
newPeer = ""
focusManager.clearFocus()
},
containerColor = LocalCustomColors.current.accent,
contentColor = LocalCustomColors.current.background
containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
) {
Icon(
imageVector = Icons.Filled.Add,

View File

@ -234,8 +234,7 @@ private fun Codecs(codecs: SnapshotStateList<Codec>, onUpdateCodecs: (List<Codec
.padding(end = 4.dp)
.verticalScrollbar(
state = draggableState.listState,
width = 4.dp,
color = LocalCustomColors.current.gray
width = 4.dp
),
state = draggableState.listState,
contentPadding = PaddingValues(start = 12.dp, end = 12.dp),

View File

@ -9,6 +9,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
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.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallFloatingActionButton
import androidx.compose.material3.Text
@ -78,12 +80,12 @@ private fun ContactsScreen(navController: NavController, viewModel: ViewModel) {
Scaffold(
modifier = Modifier.fillMaxSize().imePadding(),
containerColor = LocalCustomColors.current.background,
containerColor = MaterialTheme.colorScheme.background,
topBar = {
Column(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(
top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
)
@ -96,9 +98,9 @@ private fun ContactsScreen(navController: NavController, viewModel: ViewModel) {
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary
containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
),
navigationIcon = {
IconButton(onClick = { navController.popBackStack() }) {
@ -113,9 +115,11 @@ private fun ContactsScreen(navController: NavController, viewModel: ViewModel) {
}
},
floatingActionButton = {
SmallFloatingActionButton(onClick = { navController.navigate("baresip_contact//new") },
containerColor = LocalCustomColors.current.accent,
contentColor = LocalCustomColors.current.background
SmallFloatingActionButton(
modifier = Modifier.offset(x = 2.dp),
onClick = { navController.navigate("baresip_contact//new") },
containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
) {
Icon(imageVector = Icons.Filled.Add,
modifier = Modifier.size(36.dp),
@ -144,6 +148,8 @@ private fun ContactsContent(
val neutralText = remember { mutableStateOf("") }
val neutralAction = remember { mutableStateOf({}) }
Log.d("THEME_TEST", "ContactsScreen Primary: ${MaterialTheme.colorScheme.primary}")
if (showDialog.value)
AlertDialog(
showDialog = showDialog,
@ -161,13 +167,13 @@ private fun ContactsContent(
LazyColumn(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(contentPadding)
.padding(start = 16.dp, end = 4.dp, top = 16.dp, bottom = 64.dp)
.verticalScrollbar(
state = lazyListState,
width = 4.dp,
color = LocalCustomColors.current.gray
color = MaterialTheme.colorScheme.outlineVariant
),
state = lazyListState,
verticalArrangement = Arrangement.spacedBy(10.dp),
@ -288,8 +294,8 @@ private fun ContactsContent(
SmallFloatingActionButton(
modifier = Modifier.padding(end = 10.dp),
onClick = { navController.navigate("baresip_contact/${name}/old") },
containerColor = LocalCustomColors.current.background,
contentColor = LocalCustomColors.current.secondary
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
contentColor = MaterialTheme.colorScheme.onTertiaryContainer
) {
Icon(
imageVector = Icons.Filled.Edit,

View File

@ -58,17 +58,17 @@ data class CustomColors(
)
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_on_primary_container = Color(0xFF032133)
val light_secondary = Color(0xFF00B9A1)
val light_on_secondary = Color(0xffe0e0e0)
val light_secondary_container = Color(0xFF9DE6DC)
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_tertiary_container = Color(0xFFE6CDD5)
val light_on_tertiary_container = Color(0xFF332227)
val light_tertiary_container = Color(0xFFDAD2E6)
val light_on_tertiary_container = Color(0xFF2B2533)
val light_error = Color(0xFFF77445)
val light_on_error = Color(0xffe0e0e0)
val light_error_container = Color(0xFFE6BFB1)
@ -105,10 +105,10 @@ val dark_secondary = Color(0xFF7FE6D8)
val dark_on_secondary = Color(0xFF004C43)
val dark_secondary_container = Color(0xFF006659)
val dark_on_secondary_container = Color(0xFF9DE6DC)
val dark_tertiary = Color(0xFFE6C3CE)
val dark_on_tertiary = Color(0xFF4C323B)
val dark_tertiary_container = Color(0xFF66434F)
val dark_on_tertiary_container = Color(0xFFE6CDD5)
val dark_tertiary = Color(0xFFD5CAE6)
val dark_on_tertiary = Color(0xFF40384C)
val dark_tertiary_container = Color(0xFF564A66)
val dark_on_tertiary_container = Color(0xFFDAD2E6)
val dark_error = Color(0xFFE6AF9C)
val dark_on_error = Color(0xFF4C2415)
val dark_error_container = Color(0xFF66301D)

View File

@ -65,8 +65,10 @@ import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.OutlinedTextFieldDefaults
@ -456,12 +458,12 @@ private fun MainScreen(
modifier = Modifier
.fillMaxSize()
.imePadding(),
containerColor = LocalCustomColors.current.background,
containerColor = MaterialTheme.colorScheme.background,
topBar = {
Column(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(
top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
)
@ -525,8 +527,9 @@ private fun TopAppBar(
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
titleContentColor = LocalCustomColors.current.onPrimary
containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary
),
windowInsets = WindowInsets(0, 0, 0, 0),
actions = {
@ -542,11 +545,13 @@ private fun TopAppBar(
recImage = if (BaresipService.isRecOn) {
Api.module_load("sndfile")
recOnImage
} else {
}
else {
Api.module_unload("sndfile")
recOffImage
}
} else
}
else
Toast.makeText(ctx, R.string.rec_in_call, Toast.LENGTH_SHORT)
.show()
},
@ -557,9 +562,9 @@ private fun TopAppBar(
}
),
tint = if (BaresipService.isRecOn)
LocalCustomColors.current.accent
MaterialTheme.colorScheme.error
else
LocalCustomColors.current.onPrimary,
MaterialTheme.colorScheme.onPrimary,
contentDescription = null
)
@ -576,7 +581,8 @@ private fun TopAppBar(
if (BaresipService.isMicMuted) {
viewModel.updateMicIcon(R.drawable.mic_off)
Api.calls_mute(true)
} else {
}
else {
viewModel.updateMicIcon(R.drawable.mic_on)
Api.calls_mute(false)
}
@ -589,9 +595,9 @@ private fun TopAppBar(
},
),
tint = if (BaresipService.isMicMuted)
LocalCustomColors.current.accent
MaterialTheme.colorScheme.error
else
LocalCustomColors.current.onPrimary,
MaterialTheme.colorScheme.onPrimary,
contentDescription = null
)
@ -623,9 +629,9 @@ private fun TopAppBar(
},
),
tint = if (Utils.isSpeakerPhoneOn(am))
LocalCustomColors.current.accent
MaterialTheme.colorScheme.error
else
LocalCustomColors.current.onPrimary,
MaterialTheme.colorScheme.onPrimary,
contentDescription = null
)
@ -637,7 +643,7 @@ private fun TopAppBar(
Icon(
imageVector = Icons.Filled.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,
Modifier.size(buttonSize),
tint = if (vmIcon == R.drawable.voicemail)
LocalCustomColors.current.onBackground
MaterialTheme.colorScheme.secondary
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),
contentDescription = null,
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,
Modifier.size(buttonSize),
tint = if (messagesIcon == R.drawable.messages)
LocalCustomColors.current.onBackground
MaterialTheme.colorScheme.secondary
else
LocalCustomColors.current.accent
MaterialTheme.colorScheme.error
)
}
@ -769,9 +775,9 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
contentDescription = null,
Modifier.size(buttonSize),
tint = if (callsIcon == R.drawable.calls)
LocalCustomColors.current.onBackground
MaterialTheme.colorScheme.secondary
else
LocalCustomColors.current.accent
MaterialTheme.colorScheme.error
)
}
@ -792,9 +798,9 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
contentDescription = null,
modifier = Modifier.size(buttonSize),
tint = if (dialpadIcon == R.drawable.dialpad_off)
LocalCustomColors.current.onBackground
MaterialTheme.colorScheme.secondary
else
LocalCustomColors.current.accent
MaterialTheme.colorScheme.error
)
}
}
@ -916,7 +922,8 @@ private fun MainContent(navController: NavController, viewModel: ViewModel, cont
showCall(ctx, viewModel, ua)
}
}
} else if (offset > swipeThreshold) {
}
else if (offset > swipeThreshold) {
if (uas.value.isNotEmpty()) {
val curPos = UserAgent.findAorIndex(viewModel.selectedAor.value)
val newPos = when (curPos) {
@ -1013,7 +1020,8 @@ private fun AccountSpinner(ctx: Context, viewModel: ViewModel, navController: Na
if (Api.account_regint(acc.accp) > 0) {
Api.account_set_regint(acc.accp, 0)
Api.ua_unregister(ua.uap)
} else {
}
else {
Api.account_set_regint(
acc.accp,
acc.configuredRegInt
@ -1027,8 +1035,8 @@ private fun AccountSpinner(ctx: Context, viewModel: ViewModel, navController: Na
)
},
colors = ButtonColors(
containerColor = LocalCustomColors.current.grayLight,
contentColor = LocalCustomColors.current.dark,
containerColor = MaterialTheme.colorScheme.surfaceVariant,
contentColor = MaterialTheme.colorScheme.onSurfaceVariant,
disabledContainerColor = LocalCustomColors.current.grayLight,
disabledContentColor = LocalCustomColors.current.dark
),
@ -1064,7 +1072,8 @@ private fun AccountSpinner(ctx: Context, viewModel: ViewModel, navController: Na
if (Api.account_regint(acc.accp) > 0) {
Api.account_set_regint(acc.accp, 0)
Api.ua_unregister(ua.uap)
} else {
}
else {
Api.account_set_regint(
acc.accp,
acc.configuredRegInt
@ -1087,8 +1096,9 @@ private fun AccountSpinner(ctx: Context, viewModel: ViewModel, navController: Na
androidx.compose.material3.DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
containerColor = MaterialTheme.colorScheme.surfaceContainer,
) {
uas.value.forEachIndexed { _, ua ->
uas.value.forEachIndexed { index, ua ->
val acc = ua.account
DropdownMenuItem(
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
.fillMaxWidth()
.verticalScrollbar(
state = lazyListState,
color = LocalCustomColors.current.gray
state = lazyListState
),
horizontalAlignment = Alignment.Start,
state = lazyListState
@ -1494,7 +1506,7 @@ private fun CallRow(ctx: Context, viewModel: ViewModel) {
Text(
text = stringResource(R.string.call_transfer),
fontSize = 20.sp,
color = LocalCustomColors.current.alert,
color = MaterialTheme.colorScheme.error,
)
var transferUri by remember { mutableStateOf("") }
val suggestions by remember { contactNames }
@ -1569,8 +1581,7 @@ private fun CallRow(ctx: Context, viewModel: ViewModel) {
modifier = Modifier
.fillMaxWidth()
.verticalScrollbar(
state = lazyListState,
color = LocalCustomColors.current.gray
state = lazyListState
),
horizontalAlignment = Alignment.Start,
state = lazyListState,
@ -1696,7 +1707,7 @@ private fun CallRow(ctx: Context, viewModel: ViewModel) {
else
R.string.call
).uppercase(),
color = LocalCustomColors.current.primary
color = MaterialTheme.colorScheme.primary
)
}
}
@ -1819,7 +1830,7 @@ private fun CallRow(ctx: Context, viewModel: ViewModel) {
private fun OnHoldNotice() {
OutlinedButton(
onClick = {},
border = BorderStroke(1.dp, LocalCustomColors.current.accent),
border = BorderStroke(1.dp, MaterialTheme.colorScheme.error),
modifier = Modifier.padding(16.dp),
shape = RoundedCornerShape(20)
) {

View File

@ -35,6 +35,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
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.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
@ -47,6 +49,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Switch
@ -148,13 +151,15 @@ private fun SettingsScreen(
}
Scaffold(
modifier = Modifier.fillMaxSize().imePadding(),
containerColor = LocalCustomColors.current.background,
modifier = Modifier
.fillMaxSize()
.imePadding(),
containerColor = MaterialTheme.colorScheme.background,
topBar = {
Column(
modifier = Modifier
.fillMaxWidth()
.background(LocalCustomColors.current.background)
.background(MaterialTheme.colorScheme.background)
.padding(
top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
)
@ -167,10 +172,10 @@ private fun SettingsScreen(
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = LocalCustomColors.current.primary,
navigationIconContentColor = LocalCustomColors.current.onPrimary,
titleContentColor = LocalCustomColors.current.onPrimary,
actionIconContentColor = LocalCustomColors.current.onPrimary
containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary
),
navigationIcon = {
IconButton(onClick = onBack) {
@ -1247,39 +1252,45 @@ private fun SettingsContent(
save = true
}
val scrollState = rememberScrollState()
val lazyListState = rememberLazyListState()
Column(
LazyColumn(
state = lazyListState,
modifier = Modifier
.fillMaxWidth()
.padding(contentPadding)
.padding(start = 16.dp, end = 4.dp, top = 16.dp, bottom = 8.dp)
.verticalScrollbar(scrollState)
.verticalScroll(state = scrollState),
.verticalScrollbar(
state = lazyListState,
width = 4.dp,
color = MaterialTheme.colorScheme.outlineVariant
),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
StartAutomatically()
ListenAddress()
AddressFamily()
DnsServers()
TlsCertificateFile(activity)
VerifyServer()
CaFile(activity)
UserAgent()
AudioSettings(navController)
Contacts(activity)
Ringtone(ctx)
BatteryOptimizations()
DarkTheme()
if (VERSION.SDK_INT >= 31)
DynamicColors()
ColorBlind()
ProximitySensing()
if (VERSION.SDK_INT >= 29)
DefaultDialer()
Debug()
SipTrace()
Reset(onRestartApp)
item { StartAutomatically() }
item { ListenAddress() }
item { AddressFamily() }
item { DnsServers() }
item { TlsCertificateFile(activity) }
item { VerifyServer() }
item { CaFile(activity) }
item { UserAgent() }
item { AudioSettings(navController) }
item { Contacts(activity) }
item { Ringtone(ctx) }
item { BatteryOptimizations() }
item { DarkTheme() }
if (VERSION.SDK_INT >= 31) {
item { DynamicColors() }
}
item { ColorBlind() }
item { ProximitySensing() }
if (VERSION.SDK_INT >= 29) {
item { DefaultDialer() }
}
item { Debug() }
item { SipTrace() }
item { Reset(onRestartApp) }
}
}

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>

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>