mirror of
https://github.com/kalarina-bit/Sparkledns.git
synced 2026-11-22 07:36:09 +00:00
Improve Home, Activity and tablet layout
- Content keeps a readable width on tablets; Home and Activity show two columns on wide screens - Home chart: bars per hour or per day, a working 24 h / 7 d switch, a message instead of an empty chart, and more height on tall screens - Company dominance waits for 50 requests and shows whole percents - Home offers to turn on HaGeZi Pro when no list is on, or blocking when it is off - Tapping the server on Home opens the server list; the ON/OFF switch gives haptic feedback
This commit is contained in:
@@ -7,7 +7,6 @@ import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -15,15 +14,18 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
@@ -32,12 +34,10 @@ import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
@@ -54,12 +54,12 @@ import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
private enum class ActivityFilter(@StringRes val label: Int) {
|
||||
ALL(R.string.mon_all),
|
||||
@@ -68,11 +68,6 @@ private enum class ActivityFilter(@StringRes val label: Int) {
|
||||
ERRORS(R.string.mon_errors),
|
||||
}
|
||||
|
||||
private enum class Period(val hours: Int, @StringRes val label: Int) {
|
||||
DAY(24, R.string.period_24h),
|
||||
WEEK(24 * 7, R.string.period_7d),
|
||||
}
|
||||
|
||||
private val TimeFormat = SimpleDateFormat("HH:mm:ss", Locale.ROOT)
|
||||
|
||||
// Colors of the company slices, then the rest
|
||||
@@ -88,12 +83,11 @@ fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
|
||||
val custom by Blocklist.custom.collectAsStateWithLifecycle()
|
||||
val customSet = remember(custom) { custom.toHashSet() }
|
||||
|
||||
var period by rememberSaveable { mutableStateOf(Period.DAY) }
|
||||
var period by rememberSaveable { mutableStateOf(StatsPeriod.DAY) }
|
||||
var entries by remember { mutableStateOf(QueryLog.snapshot()) }
|
||||
var summary by remember { mutableStateOf(StatsStore.summary(period.hours)) }
|
||||
var filter by rememberSaveable { mutableStateOf(ActivityFilter.ALL) }
|
||||
var search by rememberSaveable { mutableStateOf("") }
|
||||
var filterMenu by remember { mutableStateOf(false) }
|
||||
|
||||
OnQueryLogChange {
|
||||
entries = QueryLog.snapshot()
|
||||
@@ -145,112 +139,28 @@ fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
|
||||
.setPrimaryClip(ClipData.newPlainText("domain", domain))
|
||||
}
|
||||
|
||||
LazyColumn(
|
||||
modifier = modifier,
|
||||
contentPadding = PaddingValues(start = 20.dp, end = 20.dp, top = 16.dp, bottom = bottomPadding),
|
||||
) {
|
||||
item(key = "header") {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(min = 44.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
ScreenTitle(stringResource(R.string.tab_activity), Modifier.weight(1f))
|
||||
PeriodChip(stringResource(period.label)) {
|
||||
period = if (period == Period.DAY) Period.WEEK else Period.DAY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item(key = "stats") {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 20.dp, start = 4.dp, end = 4.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) {
|
||||
StatBlock(formatCompact(summary.total), stringResource(R.string.stat_requests), Modifier.weight(1f))
|
||||
StatBlock(formatCompact(summary.blocked), stringResource(R.string.mon_blocked), Modifier.weight(1f))
|
||||
StatBlock(stringResource(R.string.mon_ms, summary.avgLatencyMs), stringResource(R.string.stat_avg), Modifier.weight(1f))
|
||||
val cache = if (summary.total == 0L) 0 else summary.cached * 100 / summary.total
|
||||
StatBlock("$cache%", stringResource(R.string.mon_cached), Modifier.weight(1f))
|
||||
}
|
||||
}
|
||||
|
||||
item(key = "companies") {
|
||||
CompanyCard(summary, Modifier.padding(top = 20.dp))
|
||||
}
|
||||
val wide = windowWidth() >= WideLayoutWidth
|
||||
val side = sidePadding(windowWidth(), if (wide) MaxWideContentWidth else MaxContentWidth)
|
||||
val canClear = entries.isNotEmpty()
|
||||
val clear = {
|
||||
QueryLog.clear()
|
||||
entries = emptyList()
|
||||
}
|
||||
|
||||
// The log rows, shared by the one- and two-column layouts
|
||||
val log: LazyListScope.() -> Unit = {
|
||||
item(key = "recent") {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 24.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
stringResource(R.string.recent_title),
|
||||
color = Palette.Fg,
|
||||
fontSize = 17.sp,
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
IconButton(
|
||||
onClick = {
|
||||
QueryLog.clear()
|
||||
entries = emptyList()
|
||||
},
|
||||
enabled = entries.isNotEmpty(),
|
||||
) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_delete_sweep),
|
||||
contentDescription = stringResource(R.string.mon_clear),
|
||||
tint = Palette.Fg2,
|
||||
modifier = Modifier.size(20.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
RecentHeader(canClear, clear, Modifier.padding(top = if (wide) 0.dp else 24.dp))
|
||||
}
|
||||
|
||||
item(key = "search") {
|
||||
SearchField(
|
||||
value = search,
|
||||
onValueChange = { search = it },
|
||||
placeholder = stringResource(R.string.mon_search),
|
||||
LogSearch(
|
||||
search = search,
|
||||
onSearch = { search = it },
|
||||
filter = filter,
|
||||
onFilter = { filter = it },
|
||||
modifier = Modifier.padding(top = 6.dp, bottom = 4.dp),
|
||||
trailing = {
|
||||
Box {
|
||||
IconButton(onClick = { filterMenu = true }) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_filter),
|
||||
contentDescription = stringResource(R.string.filter),
|
||||
tint = if (filter == ActivityFilter.ALL) Palette.Fg2 else Palette.Accent,
|
||||
modifier = Modifier.size(18.dp),
|
||||
)
|
||||
}
|
||||
DropdownMenu(expanded = filterMenu, onDismissRequest = { filterMenu = false }) {
|
||||
ActivityFilter.entries.forEach { option ->
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(
|
||||
stringResource(option.label),
|
||||
color = if (option == filter) Palette.Accent else Palette.Fg,
|
||||
fontWeight = if (option == filter) FontWeight.Bold else FontWeight.Normal,
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
filter = option
|
||||
filterMenu = false
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
if (visible.isEmpty()) {
|
||||
item(key = "empty") {
|
||||
EmptyState(
|
||||
@@ -259,7 +169,6 @@ fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
itemsIndexed(visible, key = { _, entry -> entry.id }, contentType = { _, _ -> "query" }) { index, entry ->
|
||||
val blockedByMe = entry.domain in customSet
|
||||
QueryRow(
|
||||
@@ -273,24 +182,148 @@ fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (wide) {
|
||||
Row(
|
||||
modifier = modifier.padding(horizontal = side),
|
||||
horizontalArrangement = Arrangement.spacedBy(24.dp),
|
||||
) {
|
||||
Column(
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.fillMaxHeight()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(top = 16.dp, bottom = bottomPadding),
|
||||
) {
|
||||
ActivityHeader(period) { period = it }
|
||||
ActivityStats(summary, Modifier.padding(top = 20.dp))
|
||||
CompanyCard(summary, Modifier.padding(top = 20.dp))
|
||||
}
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.fillMaxHeight(),
|
||||
contentPadding = PaddingValues(top = 16.dp, bottom = bottomPadding),
|
||||
content = log,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
LazyColumn(
|
||||
modifier = modifier,
|
||||
contentPadding = PaddingValues(start = side, end = side, top = 16.dp, bottom = bottomPadding),
|
||||
) {
|
||||
item(key = "header") { ActivityHeader(period) { period = it } }
|
||||
item(key = "stats") { ActivityStats(summary, Modifier.padding(top = 20.dp)) }
|
||||
item(key = "companies") { CompanyCard(summary, Modifier.padding(top = 20.dp)) }
|
||||
log()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PeriodChip(text: String, onClick: () -> Unit) {
|
||||
private fun ActivityHeader(period: StatsPeriod, onPeriod: (StatsPeriod) -> Unit) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(18.dp))
|
||||
.border(1.dp, Palette.Track, RoundedCornerShape(18.dp))
|
||||
.clickable(onClick = onClick)
|
||||
.padding(start = 14.dp, end = 10.dp, top = 8.dp, bottom = 8.dp),
|
||||
.fillMaxWidth()
|
||||
.heightIn(min = 44.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(text, color = Palette.Fg, fontSize = 12.sp, fontWeight = FontWeight.Bold)
|
||||
Spacer(Modifier.width(4.dp))
|
||||
Icon(painterResource(R.drawable.ic_expand), contentDescription = null, tint = Palette.Fg2, modifier = Modifier.size(14.dp))
|
||||
ScreenTitle(stringResource(R.string.tab_activity), Modifier.weight(1f))
|
||||
PeriodChip(period, onPeriod)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ActivityStats(summary: StatsSummary, modifier: Modifier = Modifier) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 4.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) {
|
||||
StatBlock(formatCompact(summary.total), stringResource(R.string.stat_requests), Modifier.weight(1f))
|
||||
StatBlock(formatCompact(summary.blocked), stringResource(R.string.mon_blocked), Modifier.weight(1f))
|
||||
StatBlock(stringResource(R.string.mon_ms, summary.avgLatencyMs), stringResource(R.string.stat_avg), Modifier.weight(1f))
|
||||
val cache = if (summary.total == 0L) 0 else summary.cached * 100 / summary.total
|
||||
StatBlock("$cache%", stringResource(R.string.mon_cached), Modifier.weight(1f))
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RecentHeader(canClear: Boolean, onClear: () -> Unit, modifier: Modifier = Modifier) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(min = 44.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
stringResource(R.string.recent_title),
|
||||
color = Palette.Fg,
|
||||
fontSize = 17.sp,
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
IconButton(onClick = onClear, enabled = canClear) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_delete_sweep),
|
||||
contentDescription = stringResource(R.string.mon_clear),
|
||||
tint = Palette.Fg2,
|
||||
modifier = Modifier.size(20.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LogSearch(
|
||||
search: String,
|
||||
onSearch: (String) -> Unit,
|
||||
filter: ActivityFilter,
|
||||
onFilter: (ActivityFilter) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
var menu by remember { mutableStateOf(false) }
|
||||
SearchField(
|
||||
value = search,
|
||||
onValueChange = onSearch,
|
||||
placeholder = stringResource(R.string.mon_search),
|
||||
modifier = modifier,
|
||||
trailing = {
|
||||
Box {
|
||||
IconButton(onClick = { menu = true }) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_filter),
|
||||
contentDescription = stringResource(R.string.filter),
|
||||
tint = if (filter == ActivityFilter.ALL) Palette.Fg2 else Palette.Accent,
|
||||
modifier = Modifier.size(18.dp),
|
||||
)
|
||||
}
|
||||
DropdownMenu(expanded = menu, onDismissRequest = { menu = false }) {
|
||||
ActivityFilter.entries.forEach { option ->
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(
|
||||
stringResource(option.label),
|
||||
color = if (option == filter) Palette.Accent else Palette.Fg,
|
||||
fontWeight = if (option == filter) FontWeight.Bold else FontWeight.Normal,
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
onFilter(option)
|
||||
menu = false
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// Below this many requests the shares say more about chance than about habits
|
||||
private const val MIN_COMPANY_REQUESTS = 50L
|
||||
|
||||
@Composable
|
||||
private fun CompanyCard(summary: StatsSummary, modifier: Modifier = Modifier) {
|
||||
val other = stringResource(R.string.companies_other)
|
||||
@@ -305,12 +338,19 @@ private fun CompanyCard(summary: StatsSummary, modifier: Modifier = Modifier) {
|
||||
Text(stringResource(R.string.companies_title), color = Palette.Fg, fontSize = 15.sp, fontWeight = FontWeight.Bold)
|
||||
Text(stringResource(R.string.companies_desc), color = Palette.Fg2, fontSize = 12.sp, lineHeight = 17.sp)
|
||||
Spacer(Modifier.size(10.dp))
|
||||
if (summary.total == 0L) {
|
||||
if (summary.total < MIN_COMPANY_REQUESTS) {
|
||||
Text(
|
||||
stringResource(R.string.no_data),
|
||||
stringResource(R.string.companies_wait, summary.total, MIN_COMPANY_REQUESTS),
|
||||
color = Palette.Fg3,
|
||||
fontSize = 13.sp,
|
||||
modifier = Modifier.padding(vertical = 12.dp),
|
||||
)
|
||||
LinearProgressIndicator(
|
||||
progress = { summary.total.toFloat() / MIN_COMPANY_REQUESTS },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 10.dp, bottom = 4.dp),
|
||||
color = Palette.Accent,
|
||||
trackColor = Palette.Track,
|
||||
)
|
||||
} else {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
@@ -334,12 +374,7 @@ private fun CompanyCard(summary: StatsSummary, modifier: Modifier = Modifier) {
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
Text(
|
||||
String.format(Locale.getDefault(), "%.1f%%", slice.share * 100f),
|
||||
color = Palette.Fg,
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
Text(percentLabel(slice.share), color = Palette.Fg, fontSize = 12.sp, fontWeight = FontWeight.Bold)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,7 +383,13 @@ private fun CompanyCard(summary: StatsSummary, modifier: Modifier = Modifier) {
|
||||
}
|
||||
}
|
||||
|
||||
// The four companies with most requests, then everything else
|
||||
// Whole percents; a sliver above zero shows as "<1%" rather than "0%"
|
||||
private fun percentLabel(share: Float): String {
|
||||
val percent = share * 100f
|
||||
return if (percent < 1f) "<1%" else "${Math.round(percent)}%"
|
||||
}
|
||||
|
||||
// The four companies with most requests, then everything else; empty slices are left out
|
||||
private fun companySlices(summary: StatsSummary, otherLabel: String): List<Slice> {
|
||||
if (summary.total == 0L) return emptyList()
|
||||
val top = Company.entries
|
||||
@@ -360,7 +401,7 @@ private fun companySlices(summary: StatsSummary, otherLabel: String): List<Slice
|
||||
Slice(company.label, count.toFloat() / summary.total, SliceColors[index])
|
||||
}
|
||||
val rest = (1f - slices.sumOf { it.share.toDouble() }.toFloat()).coerceAtLeast(0f)
|
||||
return slices + Slice(otherLabel, rest, OtherColor)
|
||||
return if (rest >= 0.005f) slices + Slice(otherLabel, rest, OtherColor) else slices
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -101,6 +101,7 @@ fun AppShell() {
|
||||
Screen.HOME -> HomeScreen(
|
||||
bottomPadding = tabBottom,
|
||||
onOpenBlocklist = { page = Screen.BLOCKLIST },
|
||||
onOpenServers = { tab = Screen.SETTINGS },
|
||||
modifier = modifier,
|
||||
)
|
||||
Screen.ACTIVITY -> ActivityScreen(bottomPadding = tabBottom, modifier = modifier)
|
||||
|
||||
@@ -66,6 +66,10 @@ object Blocklist {
|
||||
private var customHashes = LongArray(0)
|
||||
private var loaded = false
|
||||
|
||||
// False until the saved lists have been read at start-up
|
||||
private val _ready = MutableStateFlow(false)
|
||||
val ready: StateFlow<Boolean> = _ready
|
||||
|
||||
fun isBlocked(name: String): Boolean = _enabled.value && isBlockedIn(name, listHashes, customHashes)
|
||||
|
||||
fun reload(context: Context) = synchronized(lock) { load(BlocklistStore(context)) }
|
||||
@@ -212,6 +216,7 @@ object Blocklist {
|
||||
customHashes = LongArray(custom.size) { DomainHash.of(custom[it]) }.sortUnique()
|
||||
reloadListHashes(store)
|
||||
loaded = true
|
||||
_ready.value = true
|
||||
}
|
||||
|
||||
private fun reloadListHashes(store: BlocklistStore) {
|
||||
|
||||
@@ -75,8 +75,11 @@ private class Preset(val name: String, val url: String, @StringRes val descripti
|
||||
|
||||
private const val HAGEZI_HOME = "https://github.com/hagezi/dns-blocklists"
|
||||
|
||||
// Offered on Home when no list is switched on
|
||||
internal const val HAGEZI_PRO_URL = "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/pro.txt"
|
||||
|
||||
private val Presets = listOf(
|
||||
Preset("HaGeZi Pro", "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/pro.txt", R.string.preset_pro_desc),
|
||||
Preset("HaGeZi Pro", HAGEZI_PRO_URL, R.string.preset_pro_desc),
|
||||
Preset("HaGeZi Pro++", "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/pro.plus.txt", R.string.preset_proplus_desc),
|
||||
Preset("HaGeZi TIF", "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/tif.txt", R.string.preset_tif_desc),
|
||||
)
|
||||
@@ -89,6 +92,7 @@ fun BlocklistScreen(bottomPadding: Dp, onBack: () -> Unit, modifier: Modifier =
|
||||
val context = LocalContext.current
|
||||
val scope = rememberCoroutineScope()
|
||||
val prefs = remember { Prefs(context) }
|
||||
val side = sidePadding(windowWidth())
|
||||
|
||||
val enabled by Blocklist.enabled.collectAsStateWithLifecycle()
|
||||
val custom by Blocklist.custom.collectAsStateWithLifecycle()
|
||||
@@ -129,7 +133,7 @@ fun BlocklistScreen(bottomPadding: Dp, onBack: () -> Unit, modifier: Modifier =
|
||||
|
||||
LazyColumn(
|
||||
modifier = modifier,
|
||||
contentPadding = PaddingValues(start = 20.dp, end = 20.dp, bottom = bottomPadding),
|
||||
contentPadding = PaddingValues(start = side, end = side, bottom = bottomPadding),
|
||||
) {
|
||||
item(key = "header") {
|
||||
PageHeader(
|
||||
|
||||
@@ -25,11 +25,12 @@ import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
@@ -39,6 +40,8 @@ import androidx.compose.foundation.selection.toggleable
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
@@ -47,21 +50,24 @@ import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.geometry.CornerRadius
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Path
|
||||
import androidx.compose.ui.graphics.PathEffect
|
||||
import androidx.compose.ui.graphics.StrokeCap
|
||||
import androidx.compose.ui.graphics.StrokeJoin
|
||||
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
@@ -80,30 +86,45 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import kotlinx.coroutines.delay
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
private const val CHART_HOURS = 24
|
||||
private const val HOUR_MS = 3_600_000L
|
||||
|
||||
// One bar of the chart: an hour, or a day in the 7-day view
|
||||
private class Bar(val total: Long, val blocked: Long, val label: String)
|
||||
|
||||
@Composable
|
||||
fun HomeScreen(bottomPadding: Dp, onOpenBlocklist: () -> Unit, modifier: Modifier = Modifier) {
|
||||
fun HomeScreen(
|
||||
bottomPadding: Dp,
|
||||
onOpenBlocklist: () -> Unit,
|
||||
onOpenServers: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val prefs = remember { Prefs(context) }
|
||||
val haptics = LocalHapticFeedback.current
|
||||
val scope = rememberCoroutineScope()
|
||||
val active by DohVpnService.active.collectAsStateWithLifecycle()
|
||||
val running = active != null
|
||||
val lists by Blocklist.lists.collectAsStateWithLifecycle()
|
||||
val total by Blocklist.total.collectAsStateWithLifecycle()
|
||||
val blocking by Blocklist.enabled.collectAsStateWithLifecycle()
|
||||
val listsReady by Blocklist.ready.collectAsStateWithLifecycle()
|
||||
val download by Blocklist.busy.collectAsStateWithLifecycle()
|
||||
val downloadError by Blocklist.error.collectAsStateWithLifecycle()
|
||||
|
||||
var summary by remember { mutableStateOf(StatsStore.summary(CHART_HOURS)) }
|
||||
var points by remember { mutableStateOf(StatsStore.hourly(CHART_HOURS)) }
|
||||
var period by rememberSaveable { mutableStateOf(StatsPeriod.DAY) }
|
||||
var summary by remember { mutableStateOf(StatsStore.summary(period.hours)) }
|
||||
var bars by remember { mutableStateOf(chartBars(period)) }
|
||||
fun refreshStats() {
|
||||
summary = StatsStore.summary(CHART_HOURS)
|
||||
points = StatsStore.hourly(CHART_HOURS)
|
||||
summary = StatsStore.summary(period.hours)
|
||||
bars = chartBars(period)
|
||||
}
|
||||
OnQueryLogChange { refreshStats() }
|
||||
val statsVersion by StatsStore.version.collectAsStateWithLifecycle()
|
||||
LaunchedEffect(statsVersion) { refreshStats() }
|
||||
LaunchedEffect(statsVersion, period) { refreshStats() }
|
||||
|
||||
// The server is picked in Settings; this screen is composed anew each time it is shown
|
||||
val selected = remember { prefs.resolve() }
|
||||
@@ -148,6 +169,7 @@ fun HomeScreen(bottomPadding: Dp, onOpenBlocklist: () -> Unit, modifier: Modifie
|
||||
fun toggle() {
|
||||
if (busy) return
|
||||
busy = true
|
||||
haptics.performHapticFeedback(if (running) HapticFeedbackType.ToggleOff else HapticFeedbackType.ToggleOn)
|
||||
if (running) {
|
||||
sendAction(context, DohVpnService.ACTION_STOP)
|
||||
return
|
||||
@@ -158,7 +180,76 @@ fun HomeScreen(bottomPadding: Dp, onOpenBlocklist: () -> Unit, modifier: Modifie
|
||||
else connectVpn()
|
||||
}
|
||||
|
||||
// What the blocklist card offers: nothing, switching blocking back on, or a first list
|
||||
val proList = lists.firstOrNull { it.url == HAGEZI_PRO_URL }
|
||||
val offer = when {
|
||||
!listsReady -> BlocklistOffer.NONE
|
||||
!blocking -> BlocklistOffer.SWITCH_ON
|
||||
total == 0 && lists.none { it.enabled } -> BlocklistOffer.FIRST_LIST
|
||||
else -> BlocklistOffer.NONE
|
||||
}
|
||||
fun acceptOffer() {
|
||||
when (offer) {
|
||||
BlocklistOffer.SWITCH_ON -> Blocklist.setEnabled(context, true)
|
||||
BlocklistOffer.FIRST_LIST ->
|
||||
if (proList != null) scope.editBlocklist(context) { Blocklist.setListEnabled(context, HAGEZI_PRO_URL, true) }
|
||||
else Blocklist.download(context, HAGEZI_PRO_URL)
|
||||
BlocklistOffer.NONE -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
val glow by animateFloatAsState(if (running) 1f else 0f, tween(600), label = "glow")
|
||||
val wide = windowWidth() >= WideLayoutWidth
|
||||
val side = sidePadding(windowWidth(), if (wide) MaxWideContentWidth else MaxContentWidth)
|
||||
// A tall screen gets a taller chart instead of empty space under the content
|
||||
val chartHeight = if (wide) {
|
||||
(windowHeight() - 420.dp).coerceIn(160.dp, 360.dp)
|
||||
} else {
|
||||
(windowHeight() - 700.dp).coerceIn(150.dp, 320.dp)
|
||||
}
|
||||
|
||||
val status: @Composable () -> Unit = {
|
||||
StatusCard(
|
||||
running = running,
|
||||
providerName = shown.displayName(context),
|
||||
http3 = usesHttp3,
|
||||
enabled = !busy && (running || canConnect),
|
||||
onToggle = ::toggle,
|
||||
onOpenServers = onOpenServers,
|
||||
)
|
||||
PrivateDnsWarning(privateDnsHost, prefs)
|
||||
}
|
||||
val stats: @Composable () -> Unit = {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 4.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
StatBlock(formatCompact(summary.total), stringResource(R.string.stat_requests), Modifier.weight(1f))
|
||||
StatBlock(
|
||||
formatCompact(summary.blocked),
|
||||
stringResource(R.string.mon_blocked),
|
||||
Modifier.weight(1f),
|
||||
valueColor = Palette.Accent,
|
||||
)
|
||||
StatBlock(stringResource(R.string.mon_ms, summary.avgLatencyMs), stringResource(R.string.stat_avg), Modifier.weight(1f))
|
||||
}
|
||||
}
|
||||
val chart: @Composable () -> Unit = {
|
||||
ChartSection(bars, period, chartHeight, onPeriod = { period = it })
|
||||
}
|
||||
val blocklist: @Composable () -> Unit = {
|
||||
BlocklistCard(
|
||||
info = stringResource(R.string.home_lists_info, lists.count { it.enabled }, formatCount(total.toLong())),
|
||||
offer = offer,
|
||||
downloading = download == HAGEZI_PRO_URL,
|
||||
error = if (offer == BlocklistOffer.FIRST_LIST) downloadError else null,
|
||||
canAccept = download == null,
|
||||
onAccept = ::acceptOffer,
|
||||
onClick = onOpenBlocklist,
|
||||
)
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
@@ -177,7 +268,7 @@ fun HomeScreen(bottomPadding: Dp, onOpenBlocklist: () -> Unit, modifier: Modifie
|
||||
)
|
||||
}
|
||||
}
|
||||
.padding(top = 16.dp, bottom = bottomPadding),
|
||||
.padding(start = side, end = side, top = 16.dp, bottom = bottomPadding),
|
||||
verticalArrangement = Arrangement.spacedBy(20.dp),
|
||||
) {
|
||||
Image(
|
||||
@@ -190,101 +281,33 @@ fun HomeScreen(bottomPadding: Dp, onOpenBlocklist: () -> Unit, modifier: Modifie
|
||||
|
||||
AnimatedVisibility(visible = crashVisible, enter = Motion.expandIn, exit = Motion.collapseOut) {
|
||||
val report = crashReport.orEmpty()
|
||||
Box(Modifier.padding(horizontal = 20.dp)) {
|
||||
CrashCard(
|
||||
report = report,
|
||||
onCopy = {
|
||||
context.getSystemService(ClipboardManager::class.java)
|
||||
.setPrimaryClip(ClipData.newPlainText("SparkleDNS crash", report))
|
||||
},
|
||||
onDismiss = { CrashLog.clear(context); crashVisible = false },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
StatusCard(
|
||||
running = running,
|
||||
providerName = shown.displayName(context),
|
||||
http3 = usesHttp3,
|
||||
enabled = !busy && (running || canConnect),
|
||||
onToggle = ::toggle,
|
||||
modifier = Modifier.padding(horizontal = 20.dp),
|
||||
)
|
||||
|
||||
PrivateDnsWarning(privateDnsHost, prefs, Modifier.padding(horizontal = 20.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 24.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
StatBlock(formatCompact(summary.total), stringResource(R.string.stat_requests), Modifier.weight(1f))
|
||||
StatBlock(
|
||||
formatCompact(summary.blocked),
|
||||
stringResource(R.string.mon_blocked),
|
||||
Modifier.weight(1f),
|
||||
valueColor = Palette.Accent,
|
||||
CrashCard(
|
||||
report = report,
|
||||
onCopy = {
|
||||
context.getSystemService(ClipboardManager::class.java)
|
||||
.setPrimaryClip(ClipData.newPlainText("SparkleDNS crash", report))
|
||||
},
|
||||
onDismiss = { CrashLog.clear(context); crashVisible = false },
|
||||
)
|
||||
StatBlock(stringResource(R.string.mon_ms, summary.avgLatencyMs), stringResource(R.string.stat_avg), Modifier.weight(1f))
|
||||
}
|
||||
|
||||
Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 20.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp, Alignment.End),
|
||||
) {
|
||||
LegendItem(stringResource(R.string.stat_requests), Palette.Accent)
|
||||
LegendItem(stringResource(R.string.mon_blocked), Palette.Muted)
|
||||
}
|
||||
TrafficChart(
|
||||
points,
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.height(150.dp),
|
||||
)
|
||||
val startLabel = remember(points) {
|
||||
val start = System.currentTimeMillis() - (CHART_HOURS - 1) * 3_600_000L
|
||||
SimpleDateFormat("HH:00", Locale.getDefault()).format(Date(start))
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 20.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(startLabel, color = Palette.Fg3, fontSize = 11.sp, modifier = Modifier.weight(1f))
|
||||
Text(
|
||||
stringResource(R.string.period_24h),
|
||||
color = Palette.Fg2,
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.background(Palette.Card)
|
||||
.padding(horizontal = 12.dp, vertical = 6.dp),
|
||||
)
|
||||
Text(
|
||||
stringResource(R.string.chart_now),
|
||||
color = Palette.Fg3,
|
||||
fontSize = 11.sp,
|
||||
textAlign = TextAlign.End,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
if (wide) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(24.dp)) {
|
||||
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(20.dp)) {
|
||||
status()
|
||||
blocklist()
|
||||
}
|
||||
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(20.dp)) {
|
||||
stats()
|
||||
chart()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
status()
|
||||
stats()
|
||||
chart()
|
||||
blocklist()
|
||||
}
|
||||
|
||||
BlocklistRow(
|
||||
info = if (blocking) {
|
||||
stringResource(R.string.home_lists_info, lists.count { it.enabled }, formatCount(total.toLong()))
|
||||
} else {
|
||||
stringResource(R.string.blocking_off)
|
||||
},
|
||||
onClick = onOpenBlocklist,
|
||||
modifier = Modifier.padding(horizontal = 20.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,15 +318,15 @@ private fun StatusCard(
|
||||
http3: Boolean,
|
||||
enabled: Boolean,
|
||||
onToggle: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onOpenServers: () -> Unit,
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.appCard()
|
||||
.padding(horizontal = 20.dp, vertical = 24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) {
|
||||
AnimatedContent(
|
||||
targetState = running,
|
||||
@@ -319,8 +342,16 @@ private fun StatusCard(
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
// Tapping the server opens the server list in Settings
|
||||
val dot by animateColorAsState(if (running) Palette.Accent else Palette.Track, Motion.color, label = "dot")
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.clickable(onClickLabel = stringResource(R.string.change_server), onClick = onOpenServers)
|
||||
.heightIn(min = 40.dp)
|
||||
.padding(start = 10.dp, end = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Box(
|
||||
Modifier
|
||||
.size(7.dp)
|
||||
@@ -336,9 +367,12 @@ private fun StatusCard(
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.weight(1f, fill = false),
|
||||
)
|
||||
Spacer(Modifier.width(2.dp))
|
||||
Chevron(Modifier.size(16.dp))
|
||||
}
|
||||
Spacer(Modifier.height(10.dp))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
PowerToggle(on = running, enabled = enabled, onToggle = onToggle)
|
||||
}
|
||||
}
|
||||
@@ -394,7 +428,7 @@ private fun PowerToggle(on: Boolean, enabled: Boolean, onToggle: () -> Unit) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PrivateDnsWarning(privateDnsHost: String?, prefs: Prefs, modifier: Modifier = Modifier) {
|
||||
private fun PrivateDnsWarning(privateDnsHost: String?, prefs: Prefs) {
|
||||
val context = LocalContext.current
|
||||
val lastHost = remember { arrayOf("") }
|
||||
privateDnsHost?.let { lastHost[0] = it }
|
||||
@@ -403,7 +437,6 @@ private fun PrivateDnsWarning(privateDnsHost: String?, prefs: Prefs, modifier: M
|
||||
visible = privateDnsHost != null && privateDnsHost != dismissedHost,
|
||||
enter = Motion.expandIn,
|
||||
exit = Motion.collapseOut,
|
||||
modifier = modifier,
|
||||
) {
|
||||
HintCard(
|
||||
text = stringResource(R.string.hint, lastHost[0]),
|
||||
@@ -428,12 +461,62 @@ fun StatBlock(value: String, label: String, modifier: Modifier = Modifier, value
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ChartSection(bars: List<Bar>, period: StatsPeriod, height: Dp, onPeriod: (StatsPeriod) -> Unit) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
PeriodChip(period, onPeriod)
|
||||
Spacer(Modifier.weight(1f))
|
||||
LegendItem(stringResource(R.string.stat_requests), Palette.Accent)
|
||||
Spacer(Modifier.width(14.dp))
|
||||
LegendItem(stringResource(R.string.mon_blocked), Palette.Blocked)
|
||||
}
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.height(height),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
if (bars.all { it.total == 0L }) {
|
||||
Text(
|
||||
stringResource(R.string.chart_empty),
|
||||
color = Palette.Fg3,
|
||||
fontSize = 13.sp,
|
||||
lineHeight = 18.sp,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.padding(horizontal = 24.dp),
|
||||
)
|
||||
} else {
|
||||
TrafficChart(bars, Modifier.fillMaxWidth().height(height))
|
||||
}
|
||||
}
|
||||
// Hours: first hour on the left, now on the right. Days: a label under every bar.
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
if (period == StatsPeriod.DAY) {
|
||||
Text(bars.firstOrNull()?.label.orEmpty(), color = Palette.Fg3, fontSize = 11.sp, modifier = Modifier.weight(1f))
|
||||
Text(stringResource(R.string.chart_now), color = Palette.Fg3, fontSize = 11.sp)
|
||||
} else {
|
||||
bars.forEachIndexed { index, bar ->
|
||||
Text(
|
||||
bar.label,
|
||||
color = if (index == bars.lastIndex) Palette.Fg else Palette.Fg3,
|
||||
fontSize = 11.sp,
|
||||
maxLines = 1,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LegendItem(label: String, color: Color) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Box(
|
||||
Modifier
|
||||
.size(width = 12.dp, height = 3.dp)
|
||||
.size(8.dp)
|
||||
.clip(RoundedCornerShape(2.dp))
|
||||
.background(color)
|
||||
)
|
||||
@@ -442,25 +525,26 @@ private fun LegendItem(label: String, color: Color) {
|
||||
}
|
||||
}
|
||||
|
||||
// Requests (accent line with a soft fill) and blocked queries (grey line) per hour
|
||||
// One bar per hour or day: requests in the accent color with the blocked part at the bottom.
|
||||
// Empty slots show a short stub, so a mostly empty day reads as empty instead of broken.
|
||||
@Composable
|
||||
private fun TrafficChart(points: List<HourPoint>, modifier: Modifier = Modifier) {
|
||||
private fun TrafficChart(bars: List<Bar>, modifier: Modifier = Modifier) {
|
||||
val measurer = rememberTextMeasurer()
|
||||
val labelStyle = TextStyle(color = Palette.Fg3, fontSize = 10.sp)
|
||||
Canvas(modifier) {
|
||||
val n = points.size
|
||||
if (n < 2) return@Canvas
|
||||
val maxValue = niceCeiling(points.maxOf { it.total }.coerceAtLeast(1L))
|
||||
val inset = 6.dp.toPx()
|
||||
val top = 14.dp.toPx()
|
||||
val base = size.height - 8.dp.toPx()
|
||||
val n = bars.size
|
||||
if (n == 0) return@Canvas
|
||||
val maxValue = niceCeiling(bars.maxOf { it.total }.coerceAtLeast(1L))
|
||||
val top = 16.dp.toPx()
|
||||
val base = size.height - 2.dp.toPx()
|
||||
val span = base - top
|
||||
val step = (size.width - 2 * inset) / (n - 1)
|
||||
fun x(index: Int) = inset + index * step
|
||||
fun y(value: Long) = base - value.toFloat() / maxValue * span
|
||||
val slot = size.width / n
|
||||
val barWidth = (slot * if (n > 10) 0.62f else 0.5f).coerceAtLeast(2.dp.toPx())
|
||||
val radius = CornerRadius((barWidth / 2).coerceAtMost(4.dp.toPx()))
|
||||
fun height(value: Long) = value.toFloat() / maxValue * span
|
||||
|
||||
listOf(maxValue / 2, maxValue).forEach { value ->
|
||||
val gridY = y(value)
|
||||
listOf(maxValue / 2, maxValue).filter { it > 0 }.forEach { value ->
|
||||
val gridY = base - height(value)
|
||||
drawLine(
|
||||
color = Palette.Line,
|
||||
start = Offset(0f, gridY),
|
||||
@@ -471,44 +555,35 @@ private fun TrafficChart(points: List<HourPoint>, modifier: Modifier = Modifier)
|
||||
drawText(
|
||||
textMeasurer = measurer,
|
||||
text = formatCompact(value),
|
||||
topLeft = Offset(20.dp.toPx(), gridY - 15.dp.toPx()),
|
||||
topLeft = Offset(0f, gridY - 14.dp.toPx()),
|
||||
style = labelStyle,
|
||||
)
|
||||
}
|
||||
|
||||
val line = Path()
|
||||
val area = Path()
|
||||
val blocked = Path()
|
||||
points.forEachIndexed { index, point ->
|
||||
val px = x(index)
|
||||
if (index == 0) {
|
||||
line.moveTo(px, y(point.total))
|
||||
area.moveTo(px, base)
|
||||
area.lineTo(px, y(point.total))
|
||||
blocked.moveTo(px, y(point.blocked))
|
||||
} else {
|
||||
line.lineTo(px, y(point.total))
|
||||
area.lineTo(px, y(point.total))
|
||||
blocked.lineTo(px, y(point.blocked))
|
||||
bars.forEachIndexed { index, bar ->
|
||||
val x = index * slot + (slot - barWidth) / 2
|
||||
if (bar.total == 0L) {
|
||||
val stub = 2.dp.toPx()
|
||||
drawRoundRect(Palette.Line, Offset(x, base - stub), Size(barWidth, stub), CornerRadius(stub / 2))
|
||||
return@forEachIndexed
|
||||
}
|
||||
val current = index == n - 1
|
||||
val h = height(bar.total).coerceAtLeast(4.dp.toPx())
|
||||
drawRoundRect(
|
||||
if (current) Palette.Accent else Palette.Accent.copy(alpha = 0.6f),
|
||||
Offset(x, base - h),
|
||||
Size(barWidth, h),
|
||||
radius,
|
||||
)
|
||||
if (bar.blocked > 0) {
|
||||
val hb = height(bar.blocked).coerceIn(2.dp.toPx(), h)
|
||||
if (hb >= h - radius.x) {
|
||||
drawRoundRect(Palette.Blocked, Offset(x, base - hb), Size(barWidth, hb), radius)
|
||||
} else {
|
||||
drawRect(Palette.Blocked, Offset(x, base - hb), Size(barWidth, hb))
|
||||
}
|
||||
}
|
||||
}
|
||||
area.lineTo(x(n - 1), base)
|
||||
area.close()
|
||||
|
||||
drawPath(area, Palette.Accent.copy(alpha = 0.14f))
|
||||
drawPath(
|
||||
blocked,
|
||||
Palette.Muted,
|
||||
style = Stroke(width = 1.6.dp.toPx(), cap = StrokeCap.Round, join = StrokeJoin.Round),
|
||||
)
|
||||
drawPath(
|
||||
line,
|
||||
Palette.Accent,
|
||||
style = Stroke(width = 2.4.dp.toPx(), cap = StrokeCap.Round, join = StrokeJoin.Round),
|
||||
)
|
||||
val end = Offset(x(n - 1), y(points.last().total))
|
||||
drawCircle(Palette.Bg, radius = 5.dp.toPx(), center = end)
|
||||
drawCircle(Palette.Accent, radius = 5.dp.toPx(), center = end, style = Stroke(width = 2.4.dp.toPx()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,35 +597,112 @@ private fun niceCeiling(value: Long): Long {
|
||||
return 10 * magnitude
|
||||
}
|
||||
|
||||
// 24 hourly bars, or 7 bars for the calendar days of the last week (today last)
|
||||
private fun chartBars(period: StatsPeriod, now: Long = System.currentTimeMillis()): List<Bar> {
|
||||
val hours = StatsStore.hourly(period.hours, now)
|
||||
val firstHour = now / HOUR_MS - (hours.size - 1)
|
||||
if (period == StatsPeriod.DAY) {
|
||||
val format = SimpleDateFormat("HH:00", Locale.getDefault())
|
||||
return hours.mapIndexed { index, point ->
|
||||
Bar(point.total, point.blocked, format.format(Date((firstHour + index) * HOUR_MS)))
|
||||
}
|
||||
}
|
||||
val calendar = Calendar.getInstance()
|
||||
fun dayKey(time: Long): Int {
|
||||
calendar.timeInMillis = time
|
||||
return calendar.get(Calendar.YEAR) * 1000 + calendar.get(Calendar.DAY_OF_YEAR)
|
||||
}
|
||||
val dayStarts = (6 downTo 0).map { back ->
|
||||
calendar.timeInMillis = now
|
||||
calendar.add(Calendar.DAY_OF_YEAR, -back)
|
||||
calendar.timeInMillis
|
||||
}
|
||||
val keys = dayStarts.map { dayKey(it) }
|
||||
val totals = LongArray(7)
|
||||
val blocked = LongArray(7)
|
||||
hours.forEachIndexed { index, point ->
|
||||
val day = keys.indexOf(dayKey((firstHour + index) * HOUR_MS))
|
||||
if (day >= 0) {
|
||||
totals[day] += point.total
|
||||
blocked[day] += point.blocked
|
||||
}
|
||||
}
|
||||
val format = SimpleDateFormat("EEE", Locale.getDefault())
|
||||
return dayStarts.mapIndexed { index, time -> Bar(totals[index], blocked[index], format.format(Date(time))) }
|
||||
}
|
||||
|
||||
private enum class BlocklistOffer { NONE, SWITCH_ON, FIRST_LIST }
|
||||
|
||||
@Composable
|
||||
private fun BlocklistRow(info: String, onClick: () -> Unit, modifier: Modifier = Modifier) {
|
||||
private fun BlocklistCard(
|
||||
info: String,
|
||||
offer: BlocklistOffer,
|
||||
downloading: Boolean,
|
||||
error: String?,
|
||||
canAccept: Boolean,
|
||||
onAccept: () -> Unit,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
val subtitle = when {
|
||||
error != null -> stringResource(R.string.bl_download_failed, error)
|
||||
offer == BlocklistOffer.SWITCH_ON -> stringResource(R.string.blocklist_cta_master)
|
||||
offer == BlocklistOffer.FIRST_LIST -> stringResource(R.string.blocklist_cta_lists)
|
||||
else -> info
|
||||
}
|
||||
Row(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.appCard()
|
||||
.clickable(onClick = onClick)
|
||||
.padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
val idle = offer != BlocklistOffer.NONE
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Palette.Accent),
|
||||
.background(if (idle) Palette.Track else Palette.Accent),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_privacy),
|
||||
contentDescription = null,
|
||||
tint = Palette.AccentInk,
|
||||
tint = if (idle) Palette.Fg2 else Palette.AccentInk,
|
||||
modifier = Modifier.size(22.dp),
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.width(14.dp))
|
||||
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(3.dp)) {
|
||||
Text(stringResource(R.string.blocklist_title), color = Palette.Fg, fontSize = 15.sp, fontWeight = FontWeight.Bold)
|
||||
Text(info, color = Palette.Fg2, fontSize = 12.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(
|
||||
subtitle,
|
||||
color = if (error != null) Palette.Blocked else Palette.Fg2,
|
||||
fontSize = 12.sp,
|
||||
lineHeight = 16.sp,
|
||||
maxLines = 3,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.width(10.dp))
|
||||
if (offer == BlocklistOffer.NONE) {
|
||||
Chevron()
|
||||
} else {
|
||||
Button(
|
||||
onClick = onAccept,
|
||||
enabled = canAccept && !downloading,
|
||||
shape = RoundedCornerShape(14.dp),
|
||||
contentPadding = PaddingValues(horizontal = 14.dp),
|
||||
modifier = Modifier.heightIn(min = 40.dp),
|
||||
) {
|
||||
if (downloading) {
|
||||
CircularProgressIndicator(Modifier.size(16.dp), strokeWidth = 2.dp, color = Palette.Fg2)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(stringResource(R.string.downloading), fontSize = 13.sp, maxLines = 1)
|
||||
} else {
|
||||
Text(stringResource(R.string.turn_on), fontWeight = FontWeight.Bold, fontSize = 13.sp, maxLines = 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
Chevron()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ fun SettingsScreen(
|
||||
val context = LocalContext.current
|
||||
val prefs = remember { Prefs(context) }
|
||||
val scope = rememberCoroutineScope()
|
||||
val side = sidePadding(windowWidth())
|
||||
val active by DohVpnService.active.collectAsStateWithLifecycle()
|
||||
|
||||
var selected by remember { mutableStateOf(prefs.providerId) }
|
||||
@@ -114,7 +115,7 @@ fun SettingsScreen(
|
||||
Column(
|
||||
modifier = modifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(start = 20.dp, end = 20.dp, top = 16.dp, bottom = bottomPadding),
|
||||
.padding(start = side, end = side, top = 16.dp, bottom = bottomPadding),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
ScreenTitle(stringResource(R.string.tab_settings), Modifier.heightIn(min = 44.dp))
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.BoxScope
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@@ -14,6 +15,7 @@ import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
@@ -29,11 +31,13 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
@@ -86,6 +90,24 @@ internal val AppColors = darkColorScheme(
|
||||
|
||||
val CardShape = RoundedCornerShape(20.dp)
|
||||
|
||||
// On tablets content stays this wide and sits in the middle, so rows do not stretch across the screen
|
||||
val MaxContentWidth = 560.dp
|
||||
|
||||
// From this width Home and Activity show two columns side by side
|
||||
val WideLayoutWidth = 840.dp
|
||||
val MaxWideContentWidth = 1040.dp
|
||||
|
||||
// Size of the app window in dp
|
||||
@Composable
|
||||
fun windowWidth(): Dp = LocalConfiguration.current.screenWidthDp.dp
|
||||
|
||||
@Composable
|
||||
fun windowHeight(): Dp = LocalConfiguration.current.screenHeightDp.dp
|
||||
|
||||
// Side padding that keeps content at most [max] wide and at least [min] away from the edges
|
||||
fun sidePadding(available: Dp, max: Dp = MaxContentWidth, min: Dp = 20.dp): Dp =
|
||||
maxOf(min, (available - max) / 2)
|
||||
|
||||
fun Modifier.appCard(): Modifier = clip(CardShape).background(Palette.Card)
|
||||
|
||||
@Composable
|
||||
@@ -174,15 +196,22 @@ fun PageHeader(
|
||||
// A page with a back header around content that is not built for one
|
||||
@Composable
|
||||
fun SubPage(title: String, onBack: () -> Unit, modifier: Modifier = Modifier, content: @Composable BoxScope.() -> Unit) {
|
||||
Column(modifier) {
|
||||
PageHeader(title, onBack)
|
||||
Box(
|
||||
Box(modifier, contentAlignment = Alignment.TopCenter) {
|
||||
Column(
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.fillMaxSize()
|
||||
.navigationBarsPadding(),
|
||||
content = content,
|
||||
)
|
||||
.fillMaxHeight()
|
||||
.widthIn(max = MaxContentWidth + 32.dp)
|
||||
.fillMaxWidth()
|
||||
) {
|
||||
PageHeader(title, onBack)
|
||||
Box(
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.fillMaxSize()
|
||||
.navigationBarsPadding(),
|
||||
content = content,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cc.skysparkle.sparkledns
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.animation.AnimatedContent
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
@@ -8,6 +9,8 @@ import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.animation.slideOutVertically
|
||||
import androidx.compose.animation.togetherWith
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -44,6 +47,7 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
@@ -270,3 +274,27 @@ fun EmptyState(icon: Int, text: String) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
enum class StatsPeriod(val hours: Int, @StringRes val label: Int) {
|
||||
DAY(24, R.string.period_24h),
|
||||
WEEK(24 * 7, R.string.period_7d),
|
||||
}
|
||||
|
||||
// Switches between the last 24 hours and the last 7 days
|
||||
@Composable
|
||||
fun PeriodChip(period: StatsPeriod, onChange: (StatsPeriod) -> Unit) {
|
||||
val shape = RoundedCornerShape(18.dp)
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.clip(shape)
|
||||
.border(1.dp, Palette.Track, shape)
|
||||
.clickable { onChange(if (period == StatsPeriod.DAY) StatsPeriod.WEEK else StatsPeriod.DAY) }
|
||||
.heightIn(min = 36.dp)
|
||||
.padding(start = 14.dp, end = 10.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(stringResource(period.label), color = Palette.Fg, fontSize = 12.sp, fontWeight = FontWeight.Bold)
|
||||
Spacer(Modifier.width(4.dp))
|
||||
Icon(painterResource(R.drawable.ic_expand), contentDescription = null, tint = Palette.Fg2, modifier = Modifier.size(16.dp))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,14 +96,12 @@
|
||||
<string name="period_24h">24 Stunden</string>
|
||||
<string name="period_7d">7 Tage</string>
|
||||
<string name="home_lists_info">Aktive Listen: %1$d · Regeln: %2$s</string>
|
||||
<string name="blocking_off">Blockieren ist aus</string>
|
||||
<string name="blocklist_title">DNS-Blocklisten</string>
|
||||
<string name="tab_activity">Aktivität</string>
|
||||
<string name="tab_settings">Einstellungen</string>
|
||||
<string name="companies_title">Anteil der Konzerne</string>
|
||||
<string name="companies_desc">Welcher Anteil deiner Anfragen an die größten Konzerne geht.</string>
|
||||
<string name="companies_other">Andere</string>
|
||||
<string name="no_data">Noch keine Daten</string>
|
||||
<string name="recent_title">Letzte Anfragen</string>
|
||||
<string name="filter">Filter</string>
|
||||
<string name="bl_search">Listen suchen</string>
|
||||
@@ -126,4 +124,11 @@
|
||||
<string name="settings_general">Allgemein</string>
|
||||
<string name="settings_apps">Apps ohne SparkleDNS</string>
|
||||
<string name="settings_apps_desc">Ausgewählte Apps nutzen das normale DNS des Netzwerks</string>
|
||||
<string name="chart_empty">Noch keine Daten. Nach dem Verbinden füllt sich das Diagramm Stunde für Stunde.</string>
|
||||
<string name="companies_wait">Daten werden gesammelt: %1$d von %2$d Anfragen</string>
|
||||
<string name="blocklist_cta_lists">Keine Liste ist aktiv. Schalte HaGeZi Pro ein, um Werbung und Tracker zu blockieren.</string>
|
||||
<string name="blocklist_cta_master">Blockieren ist aus. Schalte es ein, um Werbung und Tracker zu filtern.</string>
|
||||
<string name="turn_on">Einschalten</string>
|
||||
<string name="downloading">Wird geladen…</string>
|
||||
<string name="change_server">Server wechseln</string>
|
||||
</resources>
|
||||
|
||||
@@ -96,14 +96,12 @@
|
||||
<string name="period_24h">24 時間</string>
|
||||
<string name="period_7d">7 日間</string>
|
||||
<string name="home_lists_info">有効なリスト: %1$d · ルール: %2$s</string>
|
||||
<string name="blocking_off">ブロックはオフです</string>
|
||||
<string name="blocklist_title">DNS ブロックリスト</string>
|
||||
<string name="tab_activity">アクティビティ</string>
|
||||
<string name="tab_settings">設定</string>
|
||||
<string name="companies_title">企業の占有率</string>
|
||||
<string name="companies_desc">リクエストのうち大手企業に送られる割合です。</string>
|
||||
<string name="companies_other">その他</string>
|
||||
<string name="no_data">まだデータがありません</string>
|
||||
<string name="recent_title">最近のアクティビティ</string>
|
||||
<string name="filter">フィルター</string>
|
||||
<string name="bl_search">リストを検索</string>
|
||||
@@ -126,4 +124,11 @@
|
||||
<string name="settings_general">一般</string>
|
||||
<string name="settings_apps">SparkleDNS を使わないアプリ</string>
|
||||
<string name="settings_apps_desc">選んだアプリはネットワークの通常の DNS を使います</string>
|
||||
<string name="chart_empty">まだデータがありません。接続すると 1 時間ごとにグラフが埋まっていきます。</string>
|
||||
<string name="companies_wait">データ収集中: %2$d 件中 %1$d 件</string>
|
||||
<string name="blocklist_cta_lists">有効なリストがありません。HaGeZi Pro をオンにして広告とトラッカーをブロックしましょう。</string>
|
||||
<string name="blocklist_cta_master">ブロックはオフです。オンにすると広告とトラッカーをフィルタリングします。</string>
|
||||
<string name="turn_on">オンにする</string>
|
||||
<string name="downloading">ダウンロード中…</string>
|
||||
<string name="change_server">サーバーを変更</string>
|
||||
</resources>
|
||||
|
||||
@@ -96,14 +96,12 @@
|
||||
<string name="period_24h">24 valandos</string>
|
||||
<string name="period_7d">7 dienos</string>
|
||||
<string name="home_lists_info">Įjungta sąrašų: %1$d · taisyklių: %2$s</string>
|
||||
<string name="blocking_off">Blokavimas išjungtas</string>
|
||||
<string name="blocklist_title">DNS blokavimo sąrašai</string>
|
||||
<string name="tab_activity">Veikla</string>
|
||||
<string name="tab_settings">Nustatymai</string>
|
||||
<string name="companies_title">Įmonių dalis</string>
|
||||
<string name="companies_desc">Kokia jūsų užklausų dalis tenka didžiausioms įmonėms.</string>
|
||||
<string name="companies_other">Kitos</string>
|
||||
<string name="no_data">Duomenų dar nėra</string>
|
||||
<string name="recent_title">Naujausios užklausos</string>
|
||||
<string name="filter">Filtras</string>
|
||||
<string name="bl_search">Ieškoti sąrašų</string>
|
||||
@@ -126,4 +124,11 @@
|
||||
<string name="settings_general">Bendrieji</string>
|
||||
<string name="settings_apps">Programėlės be SparkleDNS</string>
|
||||
<string name="settings_apps_desc">Pasirinktos programėlės naudoja įprastą tinklo DNS</string>
|
||||
<string name="chart_empty">Duomenų dar nėra. Prisijungus grafikas pildysis kas valandą.</string>
|
||||
<string name="companies_wait">Renkami duomenys: %1$d iš %2$d užklausų</string>
|
||||
<string name="blocklist_cta_lists">Neįjungtas nė vienas sąrašas. Įjunkite HaGeZi Pro, kad blokuotumėte reklamas ir sekiklius.</string>
|
||||
<string name="blocklist_cta_master">Blokavimas išjungtas. Įjunkite jį, kad filtruotumėte reklamas ir sekiklius.</string>
|
||||
<string name="turn_on">Įjungti</string>
|
||||
<string name="downloading">Atsisiunčiama…</string>
|
||||
<string name="change_server">Keisti serverį</string>
|
||||
</resources>
|
||||
|
||||
@@ -96,14 +96,12 @@
|
||||
<string name="period_24h">24 часа</string>
|
||||
<string name="period_7d">7 дней</string>
|
||||
<string name="home_lists_info">Включено списков: %1$d · правил: %2$s</string>
|
||||
<string name="blocking_off">Блокировка выключена</string>
|
||||
<string name="blocklist_title">Блок-листы DNS</string>
|
||||
<string name="tab_activity">Активность</string>
|
||||
<string name="tab_settings">Настройки</string>
|
||||
<string name="companies_title">Доля компаний</string>
|
||||
<string name="companies_desc">Какая часть ваших запросов уходит крупнейшим компаниям.</string>
|
||||
<string name="companies_other">Другие</string>
|
||||
<string name="no_data">Данных пока нет</string>
|
||||
<string name="recent_title">Последние запросы</string>
|
||||
<string name="filter">Фильтр</string>
|
||||
<string name="bl_search">Поиск списков</string>
|
||||
@@ -126,4 +124,11 @@
|
||||
<string name="settings_general">Общие</string>
|
||||
<string name="settings_apps">Приложения без SparkleDNS</string>
|
||||
<string name="settings_apps_desc">Выбранные приложения используют обычный DNS сети</string>
|
||||
<string name="chart_empty">Данных пока нет. После подключения график будет заполняться по часам.</string>
|
||||
<string name="companies_wait">Собираем данные: %1$d из %2$d запросов</string>
|
||||
<string name="blocklist_cta_lists">Ни один список не включён. Включите HaGeZi Pro, чтобы блокировать рекламу и трекеры.</string>
|
||||
<string name="blocklist_cta_master">Блокировка выключена. Включите её, чтобы фильтровать рекламу и трекеры.</string>
|
||||
<string name="turn_on">Включить</string>
|
||||
<string name="downloading">Загрузка…</string>
|
||||
<string name="change_server">Сменить сервер</string>
|
||||
</resources>
|
||||
|
||||
@@ -96,14 +96,12 @@
|
||||
<string name="period_24h">24 小时</string>
|
||||
<string name="period_7d">7 天</string>
|
||||
<string name="home_lists_info">已启用列表:%1$d · 规则:%2$s</string>
|
||||
<string name="blocking_off">屏蔽已关闭</string>
|
||||
<string name="blocklist_title">DNS 屏蔽列表</string>
|
||||
<string name="tab_activity">活动</string>
|
||||
<string name="tab_settings">设置</string>
|
||||
<string name="companies_title">公司占比</string>
|
||||
<string name="companies_desc">你的请求中发往大公司的比例。</string>
|
||||
<string name="companies_other">其他</string>
|
||||
<string name="no_data">暂无数据</string>
|
||||
<string name="recent_title">最近活动</string>
|
||||
<string name="filter">筛选</string>
|
||||
<string name="bl_search">搜索列表</string>
|
||||
@@ -126,4 +124,11 @@
|
||||
<string name="settings_general">通用</string>
|
||||
<string name="settings_apps">不使用 SparkleDNS 的应用</string>
|
||||
<string name="settings_apps_desc">选中的应用使用网络的常规 DNS</string>
|
||||
<string name="chart_empty">暂无数据。连接后,图表会按小时逐步填充。</string>
|
||||
<string name="companies_wait">正在收集数据:%1$d / %2$d 个请求</string>
|
||||
<string name="blocklist_cta_lists">没有启用任何列表。开启 HaGeZi Pro 以屏蔽广告和跟踪器。</string>
|
||||
<string name="blocklist_cta_master">屏蔽已关闭。开启后即可过滤广告和跟踪器。</string>
|
||||
<string name="turn_on">开启</string>
|
||||
<string name="downloading">正在下载…</string>
|
||||
<string name="change_server">更换服务器</string>
|
||||
</resources>
|
||||
|
||||
@@ -97,14 +97,12 @@
|
||||
<string name="period_24h">24 hours</string>
|
||||
<string name="period_7d">7 days</string>
|
||||
<string name="home_lists_info">Lists on: %1$d · rules: %2$s</string>
|
||||
<string name="blocking_off">Blocking is off</string>
|
||||
<string name="blocklist_title">DNS Blocklist</string>
|
||||
<string name="tab_activity">Activity</string>
|
||||
<string name="tab_settings">Settings</string>
|
||||
<string name="companies_title">Company dominance</string>
|
||||
<string name="companies_desc">Share of your requests that go to the biggest companies.</string>
|
||||
<string name="companies_other">Other</string>
|
||||
<string name="no_data">No data yet</string>
|
||||
<string name="recent_title">Recent activity</string>
|
||||
<string name="filter">Filter</string>
|
||||
<string name="bl_search">Search lists</string>
|
||||
@@ -127,4 +125,11 @@
|
||||
<string name="settings_general">General</string>
|
||||
<string name="settings_apps">Apps without SparkleDNS</string>
|
||||
<string name="settings_apps_desc">Picked apps use the regular DNS of the network</string>
|
||||
<string name="chart_empty">No data yet. Connect, and the chart fills in hour by hour.</string>
|
||||
<string name="companies_wait">Collecting data: %1$d of %2$d requests</string>
|
||||
<string name="blocklist_cta_lists">No lists are on. Turn on HaGeZi Pro to block ads and trackers.</string>
|
||||
<string name="blocklist_cta_master">Blocking is off. Turn it on to filter ads and trackers.</string>
|
||||
<string name="turn_on">Turn on</string>
|
||||
<string name="downloading">Downloading…</string>
|
||||
<string name="change_server">Change server</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user