Block code styling

This commit is contained in:
Juha Heinanen
2026-08-03 11:51:02 +03:00
parent 4324424a79
commit 9723be2e0b
4 changed files with 20 additions and 41 deletions

View File

@ -5,10 +5,7 @@ import kotlinx.serialization.json.Json
import java.io.File
@Serializable
class BlockRule(
val aor: String = "",
val pattern: String
) {
class BlockRule(val aor: String = "", val pattern: String) {
fun matches(uri: String): Boolean {
if (uri.contains(pattern, ignoreCase = true)) return true
return try {

View File

@ -16,9 +16,7 @@ class Blocked (
fun add() {
BaresipService.blocked.add(this)
val aorBlocked = BaresipService.blocked.filter {
it.aor == this.aor && it.request == this.request
}
val aorBlocked = BaresipService.blocked.filter { it.aor == this.aor && it.request == this.request }
if (aorBlocked.size > blockedSize) {
val oldestToRemove = aorBlocked.first()
BaresipService.blocked.remove(oldestToRemove)

View File

@ -93,18 +93,13 @@ private fun BlockedScreen(navController: NavController, request: String, aor: St
DisposableEffect(lifecycleOwner) {
val observer = LifecycleEventObserver { _, event ->
if (event == Lifecycle.Event.ON_RESUME)
refreshTrigger++
if (event == Lifecycle.Event.ON_RESUME) refreshTrigger++
}
lifecycleOwner.lifecycle.addObserver(observer)
onDispose {
lifecycleOwner.lifecycle.removeObserver(observer)
}
onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
}
BackHandler(enabled = true) {
navController.navigateUp()
}
BackHandler(enabled = true) { navController.navigateUp() }
Scaffold(
modifier = Modifier.fillMaxSize().imePadding(),
@ -117,12 +112,7 @@ private fun BlockedScreen(navController: NavController, request: String, aor: St
},
content = { contentPadding ->
if (isBlockedLoaded)
BlockedContent(
LocalContext.current,
navController,
contentPadding,
account, blocked
)
BlockedContent(LocalContext.current, navController, contentPadding, account, blocked)
},
)
}
@ -167,9 +157,7 @@ private fun TopAppBar(
),
windowInsets = WindowInsets(0, 0, 0, 0),
navigationIcon = {
IconButton(
onClick = { navController.navigateUp() }
) {
IconButton(onClick = { navController.navigateUp() }) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = "Back",
@ -177,9 +165,7 @@ private fun TopAppBar(
}
},
actions = {
IconButton(
onClick = { expanded = !expanded }
) {
IconButton(onClick = { expanded = !expanded }) {
Icon(imageVector = Icons.Filled.Menu, contentDescription = "Menu")
}
CustomElements.DropdownMenu(
@ -275,12 +261,11 @@ private fun Blocked(
.clickable(
enabled = !peerUri.contains("anonymous") && peerUri != unknown,
onClick = {
message.value = String.format(ctx.getString(R.string.blocked_contact_question),
peerUri)
message.value = String.format(
ctx.getString(R.string.blocked_contact_question), peerUri
)
lastButtonText.value = ctx.getString(R.string.add_contact)
lastAction.value = {
navController.navigate("contact/$peerUri/new")
}
lastAction.value = { navController.navigate("contact/$peerUri/new") }
showDialog.value = true
}
)
@ -288,7 +273,8 @@ private fun Blocked(
Text(
text = "\u2022",
modifier = Modifier.padding(start = 8.dp, end = 4.dp),
fontSize = 18.sp)
fontSize = 18.sp
)
Text(
text = Utils.friendlyUri(ctx, peerUri, acc),
fontSize = 18.sp,

View File

@ -93,9 +93,7 @@ fun BlockingScreen(navController: NavController, viewModel: AccountViewModel, ua
Column(modifier = Modifier.background(MaterialTheme.colorScheme.background)) {
Spacer(Modifier.statusBarsPadding())
TopAppBar(
title = {
Text(text = stringResource(R.string.blocking), fontWeight = FontWeight.Bold)
},
title = { Text(text = stringResource(R.string.blocking), fontWeight = FontWeight.Bold) },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
@ -156,7 +154,8 @@ fun BlockingContent(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start
) {
Text(text = blockUnknownTitle,
Text(
text = blockUnknownTitle,
modifier = Modifier
.weight(1f)
.clickable {
@ -187,7 +186,8 @@ fun BlockingContent(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start
) {
Text(text = blockHiddenTitle,
Text(
text = blockHiddenTitle,
modifier = Modifier
.weight(1f)
.clickable {
@ -247,9 +247,7 @@ fun BlockingContent(
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
items(rules) { rule ->
Row(
verticalAlignment = Alignment.CenterVertically,
) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
text = "\u2022",
modifier = Modifier.padding(start = 8.dp, end = 8.dp),