mirror of
https://github.com/kalarina-bit/Sparkledns.git
synced 2026-11-22 15:46:09 +00:00
Add German, Japanese, Lithuanian and Chinese UI, closable hint cards, drop license row from About
This commit is contained in:
@@ -50,7 +50,6 @@ import androidx.compose.ui.unit.dp
|
|||||||
|
|
||||||
private const val PRIVACY_POLICY = "https://skysparkle.cc/privacy?lang=en"
|
private const val PRIVACY_POLICY = "https://skysparkle.cc/privacy?lang=en"
|
||||||
private const val SOURCE_CODE = "https://git.skysparkle.cc/kalarina/Sparkledns"
|
private const val SOURCE_CODE = "https://git.skysparkle.cc/kalarina/Sparkledns"
|
||||||
private const val APP_LICENSE = "GPL-3.0-or-later"
|
|
||||||
|
|
||||||
private const val APACHE_2 = "Apache License 2.0"
|
private const val APACHE_2 = "Apache License 2.0"
|
||||||
private const val APACHE_2_URL = "https://www.apache.org/licenses/LICENSE-2.0"
|
private const val APACHE_2_URL = "https://www.apache.org/licenses/LICENSE-2.0"
|
||||||
@@ -149,7 +148,6 @@ private fun AboutContent(modifier: Modifier, onOpenLicenses: () -> Unit) {
|
|||||||
InfoRow(stringResource(R.string.about_version), BuildConfig.VERSION_NAME)
|
InfoRow(stringResource(R.string.about_version), BuildConfig.VERSION_NAME)
|
||||||
InfoRow(stringResource(R.string.about_protocol), "DNS-over-HTTPS (RFC 8484)")
|
InfoRow(stringResource(R.string.about_protocol), "DNS-over-HTTPS (RFC 8484)")
|
||||||
InfoRow("HTTP/3", http3)
|
InfoRow("HTTP/3", http3)
|
||||||
InfoRow(stringResource(R.string.about_license), APP_LICENSE)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,9 @@ fun AppsScreen(modifier: Modifier = Modifier) {
|
|||||||
var search by rememberSaveable { mutableStateOf("") }
|
var search by rememberSaveable { mutableStateOf("") }
|
||||||
var collapsed by remember { mutableStateOf(setOf(AppGroup.SYSTEM)) }
|
var collapsed by remember { mutableStateOf(setOf(AppGroup.SYSTEM)) }
|
||||||
val pending = active != null && excluded != activeExcluded
|
val pending = active != null && excluded != activeExcluded
|
||||||
|
var showAppsHint by remember { mutableStateOf(!prefs.isHintDismissed(HINT_APPS)) }
|
||||||
|
// Closing the "reconnect" card hides it until the selection changes again
|
||||||
|
var pendingDismissedFor by remember { mutableStateOf<Set<String>?>(null) }
|
||||||
// Uninstalled apps may still be in the saved set; count only the ones on the device
|
// Uninstalled apps may still be in the saved set; count only the ones on the device
|
||||||
val excludedCount = apps?.count { it.packageName in excluded } ?: excluded.size
|
val excludedCount = apps?.count { it.packageName in excluded } ?: excluded.size
|
||||||
val searching = search.isNotBlank()
|
val searching = search.isNotBlank()
|
||||||
@@ -122,8 +125,21 @@ fun AppsScreen(modifier: Modifier = Modifier) {
|
|||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
HintCard(stringResource(R.string.apps_hint), icon = R.drawable.ic_tab_info)
|
AnimatedVisibility(visible = showAppsHint, enter = Motion.expandIn, exit = Motion.collapseOut) {
|
||||||
AnimatedVisibility(visible = pending, enter = Motion.expandIn, exit = Motion.collapseOut) {
|
HintCard(
|
||||||
|
stringResource(R.string.apps_hint),
|
||||||
|
icon = R.drawable.ic_tab_info,
|
||||||
|
onDismiss = {
|
||||||
|
showAppsHint = false
|
||||||
|
prefs.dismissHint(HINT_APPS)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = pending && excluded != pendingDismissedFor,
|
||||||
|
enter = Motion.expandIn,
|
||||||
|
exit = Motion.collapseOut,
|
||||||
|
) {
|
||||||
HintCard(
|
HintCard(
|
||||||
text = stringResource(R.string.apps_pending),
|
text = stringResource(R.string.apps_pending),
|
||||||
icon = R.drawable.ic_refresh,
|
icon = R.drawable.ic_refresh,
|
||||||
@@ -133,6 +149,7 @@ fun AppsScreen(modifier: Modifier = Modifier) {
|
|||||||
Text(stringResource(R.string.reconnect))
|
Text(stringResource(R.string.reconnect))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onDismiss = { pendingDismissedFor = excluded },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,3 +362,5 @@ private fun Drawable.toImageBitmap(size: Int): ImageBitmap {
|
|||||||
draw(canvas)
|
draw(canvas)
|
||||||
return bitmap.asImageBitmap()
|
return bitmap.asImageBitmap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const val HINT_APPS = "apps"
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ private val Presets = listOf(
|
|||||||
fun BlocklistScreen(modifier: Modifier = Modifier) {
|
fun BlocklistScreen(modifier: Modifier = Modifier) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
val prefs = remember { Prefs(context) }
|
||||||
|
var showNote by remember { mutableStateOf(!prefs.isHintDismissed(HINT_BLOCKLIST)) }
|
||||||
|
|
||||||
val enabled by Blocklist.enabled.collectAsState()
|
val enabled by Blocklist.enabled.collectAsState()
|
||||||
val total by Blocklist.total.collectAsState()
|
val total by Blocklist.total.collectAsState()
|
||||||
@@ -124,7 +126,16 @@ fun BlocklistScreen(modifier: Modifier = Modifier) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HintCard(stringResource(R.string.bl_note), icon = R.drawable.ic_tab_info)
|
AnimatedVisibility(visible = showNote, enter = Motion.expandIn, exit = Motion.collapseOut) {
|
||||||
|
HintCard(
|
||||||
|
stringResource(R.string.bl_note),
|
||||||
|
icon = R.drawable.ic_tab_info,
|
||||||
|
onDismiss = {
|
||||||
|
showNote = false
|
||||||
|
prefs.dismissHint(HINT_BLOCKLIST)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
SectionHeader(stringResource(R.string.bl_my), icon = R.drawable.ic_tab_block)
|
SectionHeader(stringResource(R.string.bl_my), icon = R.drawable.ic_tab_block)
|
||||||
|
|
||||||
|
|||||||
@@ -308,13 +308,19 @@ fun HomeScreen(modifier: Modifier = Modifier) {
|
|||||||
text = result.text,
|
text = result.text,
|
||||||
icon = if (result.ok) R.drawable.ic_check else R.drawable.ic_alert,
|
icon = if (result.ok) R.drawable.ic_check else R.drawable.ic_alert,
|
||||||
tint = if (result.ok) CachedColor else MaterialTheme.colorScheme.error,
|
tint = if (result.ok) CachedColor else MaterialTheme.colorScheme.error,
|
||||||
|
onDismiss = { testResult = null },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val lastHost = remember { arrayOf("") }
|
val lastHost = remember { arrayOf("") }
|
||||||
privateDnsHost?.let { lastHost[0] = it }
|
privateDnsHost?.let { lastHost[0] = it }
|
||||||
AnimatedVisibility(visible = privateDnsHost != null, enter = Motion.expandIn, exit = Motion.collapseOut) {
|
var dismissedDnsHost by remember { mutableStateOf(prefs.dismissedPrivateDns) }
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = privateDnsHost != null && privateDnsHost != dismissedDnsHost,
|
||||||
|
enter = Motion.expandIn,
|
||||||
|
exit = Motion.collapseOut,
|
||||||
|
) {
|
||||||
HintCard(
|
HintCard(
|
||||||
text = stringResource(R.string.hint, lastHost[0]),
|
text = stringResource(R.string.hint, lastHost[0]),
|
||||||
icon = R.drawable.ic_alert,
|
icon = R.drawable.ic_alert,
|
||||||
@@ -322,6 +328,10 @@ fun HomeScreen(modifier: Modifier = Modifier) {
|
|||||||
action = {
|
action = {
|
||||||
TextButton(onClick = { openNetworkSettings(context) }) { Text(stringResource(R.string.open_settings)) }
|
TextButton(onClick = { openNetworkSettings(context) }) { Text(stringResource(R.string.open_settings)) }
|
||||||
},
|
},
|
||||||
|
onDismiss = {
|
||||||
|
dismissedDnsHost = lastHost[0]
|
||||||
|
prefs.dismissedPrivateDns = lastHost[0]
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,20 @@ class Prefs(context: Context) {
|
|||||||
get() = sp.getStringSet(KEY_EXCLUDED, null)?.toSet() ?: emptySet()
|
get() = sp.getStringSet(KEY_EXCLUDED, null)?.toSet() ?: emptySet()
|
||||||
set(value) = sp.edit().putStringSet(KEY_EXCLUDED, value).apply()
|
set(value) = sp.edit().putStringSet(KEY_EXCLUDED, value).apply()
|
||||||
|
|
||||||
|
// Hint cards the user closed with the X
|
||||||
|
fun isHintDismissed(key: String): Boolean =
|
||||||
|
sp.getStringSet(KEY_HINTS, null)?.contains(key) == true
|
||||||
|
|
||||||
|
fun dismissHint(key: String) {
|
||||||
|
val current = sp.getStringSet(KEY_HINTS, null)?.toSet() ?: emptySet()
|
||||||
|
sp.edit().putStringSet(KEY_HINTS, current + key).apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
// The Private DNS warning stays closed until the hostname changes
|
||||||
|
var dismissedPrivateDns: String
|
||||||
|
get() = sp.getString(KEY_PRIVATE_DNS, null) ?: ""
|
||||||
|
set(value) = sp.edit().putString(KEY_PRIVATE_DNS, value).apply()
|
||||||
|
|
||||||
fun resolve(): DohProvider =
|
fun resolve(): DohProvider =
|
||||||
if (providerId == Providers.CUSTOM_ID) {
|
if (providerId == Providers.CUSTOM_ID) {
|
||||||
DohProvider(Providers.CUSTOM_ID, "Custom", customUrl.trim(), parseIps(customBootstrap), customHttp3)
|
DohProvider(Providers.CUSTOM_ID, "Custom", customUrl.trim(), parseIps(customBootstrap), customHttp3)
|
||||||
@@ -38,5 +52,7 @@ class Prefs(context: Context) {
|
|||||||
const val KEY_BOOTSTRAP = "custom_bootstrap"
|
const val KEY_BOOTSTRAP = "custom_bootstrap"
|
||||||
const val KEY_HTTP3 = "custom_http3"
|
const val KEY_HTTP3 = "custom_http3"
|
||||||
const val KEY_EXCLUDED = "excluded_apps"
|
const val KEY_EXCLUDED = "excluded_apps"
|
||||||
|
const val KEY_HINTS = "dismissed_hints"
|
||||||
|
const val KEY_PRIVATE_DNS = "dismissed_private_dns"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -35,6 +36,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
@@ -112,13 +114,23 @@ fun HintCard(
|
|||||||
@DrawableRes icon: Int = R.drawable.ic_tab_info,
|
@DrawableRes icon: Int = R.drawable.ic_tab_info,
|
||||||
tint: Color = MaterialTheme.colorScheme.onSurfaceVariant,
|
tint: Color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
action: (@Composable () -> Unit)? = null,
|
action: (@Composable () -> Unit)? = null,
|
||||||
|
onDismiss: (() -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
colors = CardDefaults.cardColors(containerColor = tint.copy(alpha = 0.10f)),
|
colors = CardDefaults.cardColors(containerColor = tint.copy(alpha = 0.10f)),
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(start = 14.dp, end = if (action != null) 6.dp else 14.dp, top = 12.dp, bottom = 12.dp),
|
modifier = Modifier.padding(
|
||||||
|
start = 14.dp,
|
||||||
|
end = when {
|
||||||
|
onDismiss != null -> 4.dp
|
||||||
|
action != null -> 6.dp
|
||||||
|
else -> 14.dp
|
||||||
|
},
|
||||||
|
top = if (onDismiss != null) 6.dp else 12.dp,
|
||||||
|
bottom = if (onDismiss != null) 6.dp else 12.dp,
|
||||||
|
),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
Icon(painterResource(icon), contentDescription = null, tint = tint, modifier = Modifier.size(20.dp))
|
Icon(painterResource(icon), contentDescription = null, tint = tint, modifier = Modifier.size(20.dp))
|
||||||
@@ -130,6 +142,16 @@ fun HintCard(
|
|||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
)
|
)
|
||||||
action?.invoke()
|
action?.invoke()
|
||||||
|
if (onDismiss != null) {
|
||||||
|
IconButton(onClick = onDismiss, modifier = Modifier.size(40.dp)) {
|
||||||
|
Icon(
|
||||||
|
painterResource(R.drawable.ic_close),
|
||||||
|
contentDescription = stringResource(R.string.dismiss),
|
||||||
|
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.size(18.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="256"
|
||||||
|
android:viewportHeight="256">
|
||||||
|
<path
|
||||||
|
android:strokeColor="#FFFFFFFF"
|
||||||
|
android:strokeWidth="14"
|
||||||
|
android:pathData="M64,64L192,192M192,64L64,192" />
|
||||||
|
</vector>
|
||||||
@@ -94,5 +94,4 @@
|
|||||||
<string name="open_settings">Настройки</string>
|
<string name="open_settings">Настройки</string>
|
||||||
<string name="mon_no_match">Ничего не найдено</string>
|
<string name="mon_no_match">Ничего не найдено</string>
|
||||||
<string name="bl_title">Блокировка</string>
|
<string name="bl_title">Блокировка</string>
|
||||||
<string name="about_license">Лицензия</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -95,5 +95,4 @@
|
|||||||
<string name="open_settings">Settings</string>
|
<string name="open_settings">Settings</string>
|
||||||
<string name="mon_no_match">Nothing matches the filter</string>
|
<string name="mon_no_match">Nothing matches the filter</string>
|
||||||
<string name="bl_title">Blocking</string>
|
<string name="bl_title">Blocking</string>
|
||||||
<string name="about_license">License</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user