38 Commits
Author SHA1 Message Date
kalarina 572e5e224b Release 1.1.6 2026-11-16 15:59:20 +02:00
kalarina 92dfd31faf Personal access key for the SkySparkle server and first-launch guide
The SkySparkle server no longer has a shared public address: each user
creates a key in their account at skysparkle.cc and the app connects to
https://skysparkle.cc/dns/<key>. The key is entered in Settings under the
server or in the new two-page guide shown on first launch. Without a key
the home screen shows a hint and the service explains why it did not start.
2026-11-16 10:54:48 +02:00
kalarina 3b4d9b049b Screenshot: drop ads from the HaGeZi Pro description 2026-11-14 22:11:27 +02:00
kalarina 618a9403c7 Screenshot: block trackers and malware instead of ads 2026-11-14 21:58:39 +02:00
kalarina 582511607c Revert "Remove block ads screenshot"
This reverts commit d6f77045e3.
2026-11-14 21:56:11 +02:00
kalarina d6f77045e3 Remove block ads screenshot 2026-11-14 21:55:08 +02:00
kalarina f3000b7706 README: point Obtainium link to GitHub 2026-11-14 19:23:20 +02:00
kalarina 3c026aaec3 Merge pull request #9 from kalarina-bit/dns-host
Release 1.1.5: use skysparkle.cc/dns-query
2026-11-13 18:30:59 +02:00
kalarina 1818973abc Release 1.1.5 2026-11-13 18:29:34 +02:00
kalarina f6a98b8785 Use skysparkle.cc/dns-query for the SkySparkle server 2026-11-13 18:29:34 +02:00
kalarina 1fb87a1e99 Merge pull request #8 from kalarina-bit/readme-sponsor
Add Skysparkle sponsor section to README
2026-11-13 17:23:44 +02:00
kalarina 667b1b2dc5 Add Skysparkle sponsor section to README 2026-11-13 17:22:31 +02:00
kalarina 399fc5ea36 Release 1.1.4 2026-11-12 17:41:54 +02:00
kalarina 83789c8510 Update dependencies, add a version catalog, backup rules and locale config
- Compose BOM 2026.09.00, Activity 1.13.0, Lifecycle 2.11.0, coroutines
  1.11.0, OkHttp 5.4.0, Kotlin 2.4.20; compileSdk 37 for the new AndroidX.
- Versions move to gradle/libs.versions.toml.
- The VPN service runs as a systemExempted foreground service, the type
  Android provides for active VPN apps, instead of specialUse.
- dataExtractionRules keep everything out of backups and device transfer;
  localeConfig lets the language be picked in Android settings.
- .gitignore keeps signing keys (*.jks, *.keystore) out of the repository.
2026-11-12 17:24:21 +02:00
kalarina 64728e5fcd Tell the user when protection stops and check the server address in the service
- When the tunnel stops working, a notification says that DNS is no longer
  encrypted (new "Protection alerts" channel).
- The service no longer brings up a tunnel for a server address that is
  not a valid HTTPS URL (always-on VPN or a restart by the system), and
  says so in a notification.
- With "Block connections without VPN" on, a notification explains that
  the DNS server cannot be reached.
- The tunnel is closed only after its reader thread has left.
- Turning protection off from the quick settings tile needs an unlocked phone.
2026-11-12 17:24:21 +02:00
kalarina 2578af2bed Make bootstrap addresses work with HTTP/3 and bound response and list sizes
- HttpEngine resolves the server with system DNS and ignores bootstrap
  addresses. When it cannot resolve the name and the server has bootstrap
  addresses, the session switches to OkHttp, which connects to them.
- AdBlock and URL rules with a path (||example.com/ads/, |http://example.com/x|)
  are skipped instead of blocking the whole domain.
- A DoH response without Content-Length is read only up to the DNS size
  limit; blocklist downloads are limited to 256 MB, and lines over 4 KB are
  skipped without being read into memory.
2026-11-12 17:24:21 +02:00
kalarina 6d015e9527 Keep blocklists out of the heap to fix out-of-memory crash on large lists
The merged blocklist was built as one LongArray next to every per-list
array and the merge copies; with ~7M domains this ran out of memory on
256 MB heaps (Galaxy A07) and the uncaught error took the VPN down.

Lists and the merged set are now memory-mapped files: the merge streams
from the list files into merged.bin, which is reused at start-up while
the switched-on lists are unchanged. Downloads sort in their own buffer
instead of copying, and the update job no longer crashes the app if it
still runs out of memory.
2026-11-12 10:46:27 +02:00
kalarina fb0c13bbcc Add dnsforge.de (unfiltered) to built-in DoH servers 2026-11-11 21:15:21 +02:00
kalarina 4ef8cef4e8 Expand call for volunteer designers 2026-11-10 15:33:26 +02:00
kalarina 64a122fe25 Add call for volunteer designers to README 2026-11-10 15:30:49 +02:00
kalarina 180a9a65fd Move Google Play notice to the top of README 2026-11-08 17:26:06 +02:00
kalarina 845e975c05 Add Google Play closed testing notice to README 2026-11-08 17:23:02 +02:00
kalarina 0ceeb84e98 Fix unreadable app names on the Apps screen (#6) 2026-11-06 17:16:51 +02:00
kalarina 5ddff1b257 Release 1.1.3 2026-11-06 16:15:02 +02:00
kalarina bc9d855997 Name other sites in Company dominance
The share outside the known companies is now split by site names taken from
the domains of recent queries (cdn.example.co.uk shows as Example). Domains
are read only from the in-memory log; the saved statistics still keep numbers
only.
2026-11-06 16:11:58 +02:00
kalarina 8f4355a624 Group recent activity by domain
Queries for the same domain (A, AAAA, HTTPS and other types) now share one
row that shows all requested types, the number of queries and the status
and time of the newest one. Refs #4
2026-11-05 19:08:33 +02:00
kalarina 359bd09b9e Add GitHub issue and pull request templates 2026-11-05 18:44:17 +02:00
kalarina d09a6bac6b Update README screenshots 2026-11-03 13:08:44 +02:00
kalarina 25dcb5cb7f Update store screenshots 2026-11-03 13:06:47 +02:00
kalarina 95c4a1b1ba Fit the German 1.0.10 changelog into 500 characters 2026-11-03 12:45:59 +02:00
kalarina 33eca31c65 Add the 1.1.2 changelog and shorten the German 1.0.10 one to F-Droid's limit 2026-11-03 12:45:52 +02:00
kalarina 54b600b1ca Release v1.1.2 2026-11-02 16:01:22 +02:00
kalarina 5ff10463a3 Release 1.1.1 2026-10-31 09:58:49 +02:00
kalarina 1ec3cf780a Use filled Material Symbols icons 2026-10-31 09:58:49 +02:00
kalarina 2057ce8e8d Sharper screenshots 2026-10-31 09:38:07 +02:00
kalarina 482d3b22a1 Update screenshots 2026-10-30 21:42:35 +02:00
kalarina 107f07cf55 Release 1.1.0 2026-10-30 20:08:37 +02:00
kalarina 1db29ee44a Redesign the app
New look based on the SparkleDNS concept: a dark theme, a floating
bottom panel with Home, Activity and Settings, and pages for the
blocklists, apps and About.

- Home: big ON/OFF switch, the current server, 24-hour stats and chart
- Activity: requests, blocked, average time and cache share for 24 hours
  or 7 days, company dominance, and the live log with search and filter
- Blocklists: HaGeZi Pro preset next to Pro++ and TIF, lists can be
  switched off without deleting them, automatic updates (daily or
  weekly, optionally Wi-Fi only) through JobScheduler
- Settings: server list, custom server, server test and per-app DNS
- Hourly numbers for the charts are kept on the device, without domains

The server list now ships with the app; it is no longer downloaded
from the repository.
2026-10-30 19:58:08 +02:00
164 changed files with 5330 additions and 2086 deletions
+28
View File
@@ -0,0 +1,28 @@
---
name: Bug report
about: Something doesn't work as expected
title: "[Bug] "
---
**What happened**
**Steps to reproduce**
1.
2.
3.
**What you expected**
**Environment**
- App version:
- Installed from: Gitea / GitHub / F-Droid / Google Play
- Device and Android version:
- DoH server in use:
- Network: Wi-Fi / mobile data
**Screenshots or logs** (optional — please remove domains you don't want to share)
+5
View File
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Main repository on git.skysparkle.cc
url: https://git.skysparkle.cc/kalarina/Sparkledns
about: This GitHub repository is a mirror. Issues are welcome here and on Gitea.
@@ -0,0 +1,15 @@
---
name: DoH server or blocklist
about: Suggest a DoH server or blocklist preset
title: "[Preset] "
---
- Type: DoH server / blocklist
- Name:
- URL:
- Homepage or documentation:
- Privacy policy (DoH servers) or license (blocklists):
- Donation page (DoH servers, optional):
- [ ] DoH server: public and supports RFC 8484
- [ ] Blocklist: public and actively maintained
+18
View File
@@ -0,0 +1,18 @@
---
name: Feature request
about: Suggest an idea that fits the app
title: "[Feature] "
---
<!-- Please check the "Out of scope" list in CONTRIBUTING.md before opening this. -->
**What problem does this solve**
**Proposed solution**
**Alternatives you considered**
- [ ] I'd like to implement this myself
+12
View File
@@ -0,0 +1,12 @@
---
name: Translation fix
about: Report a wrong or awkward translation
title: "[Translation] "
---
<!-- Currently supported: English, Russian. For a new language, open a feature request first. -->
- Language:
- Screen or place in the app:
- Current text:
- Suggested text:
+17
View File
@@ -0,0 +1,17 @@
## What does this change
## Related issue
Closes #
## Checklist
- [ ] Discussed in an issue first (not needed for small fixes)
- [ ] `./gradlew assembleDebug` builds
- [ ] Tested on a device or emulator (Android version: )
- [ ] DNS queries only go to the selected DoH server
- [ ] No ads, analytics, trackers or Google Play Services / Firebase dependencies
- [ ] New strings added to `values/strings.xml` (missing translations noted below)
- [ ] Screenshots added for UI changes
- [ ] I agree that my contribution is licensed under GPL-3.0-or-later
+3
View File
@@ -4,3 +4,6 @@ local.properties
.idea/
*.iml
.DS_Store
# Signing keys must never be committed
*.jks
*.keystore
+4 -22
View File
@@ -9,7 +9,7 @@ Issues and pull requests go to the repository on [Gitea](https://git.skysparkle.
## Ways to help
- **Report a bug** — use the *Bug report* template.
- **Add a DoH server** — add one line to [`servers/servers.txt`](servers/servers.txt), see [Adding a DoH server](#adding-a-doh-server).
- **Add a DoH server** — open an issue with the *DoH server or blocklist* template, see [Adding a DoH server](#adding-a-doh-server).
- **Suggest a blocklist** — use the *DoH server or blocklist* template.
- **Suggest a feature** — use the *Feature request* template; check [Out of scope](#out-of-scope) first.
- **Fix a translation** — use the *Translation fix* template or send a pull request.
@@ -38,27 +38,9 @@ These will not be accepted:
## Adding a DoH server
The server list lives in [`servers/servers.txt`](servers/servers.txt). The app downloads it when the user taps **Update server list**, so a new server reaches users without a new release.
Servers ship with the app in [`Providers.kt`](app/src/main/java/cc/skysparkle/sparkledns/Providers.kt), so a new server reaches users with the next release. The app never downloads a server list.
To add a server, open the file on Gitea, click **Edit**, add one line at the end and send it as a pull request:
```
Name | DoH URL | Privacy policy | h3 | Donation page
```
- **Name** — how the server appears in the app, up to 40 characters.
- **DoH URL** — the full `https://` address of the DoH endpoint.
- **Privacy policy** — an `https://` link to the operator's privacy policy. Lines without one are ignored.
- **h3** — optional. Add it only if the server supports HTTP/3.
- **Donation page** — optional. An `https://` link to the operator's own page for donations or support. The app shows it as a coin button next to the privacy policy. Only link to a page the operator runs or names on its website — no affiliate or third-party fundraising links.
Leave out any optional column you don't need; the app recognises them by their content. Examples:
```
Example DNS | https://dns.example.org/dns-query | https://example.org/privacy | h3 | https://example.org/donate
Example DNS | https://dns.example.org/dns-query | https://example.org/privacy | https://example.org/donate
Example DNS | https://dns.example.org/dns-query | https://example.org/privacy
```
To suggest a server, open an issue with the *DoH server or blocklist* template, or send a pull request that adds one entry to `Providers.builtIn` with the server's name, DoH URL, privacy policy link, bootstrap IPs, whether it supports HTTP/3 and, optionally, the operator's own donation page.
The server must:
@@ -69,7 +51,7 @@ The server must:
Before sending, check that it works: in the app choose **Custom server**, enter the URL and tap **Test server**.
Please don't change the lines of the servers that ship with the app (SkySparkle, Quad9, Digitale Gesellschaft, UncensoredDNS, Freifunk München): the app always keeps their built-in addresses and links. To fix one of their links, open an issue instead. If you are unsure whether a server fits, open an issue with the *DoH server or blocklist* template instead.
If you are unsure whether a server fits, open an issue with the *DoH server or blocklist* template first.
## Blocklists
+23 -9
View File
@@ -9,23 +9,27 @@
A local VPN that captures only DNS traffic and sends every query to the DoH server you choose (RFC 8484). Everything else goes through your normal connection.
</p>
> [!IMPORTANT]
> **SparkleDNS is coming to Google Play!** The app is now in closed testing there ahead of the public release. Ideas, wishes and suggestions for improvement are very welcome — send them wherever is easiest for you: an issue on [Gitea](https://git.skysparkle.cc/kalarina/Sparkledns/issues) or [GitHub](https://github.com/kalarina-bit/Sparkledns/issues), or an email to [cuken107@proton.me](mailto:cuken107@proton.me).
> [!NOTE]
> **Looking for designers!** SparkleDNS is looking for volunteer designers to help with icons, logos, animations, cover art (store graphics) and UI design. This is unpaid help for an open-source project. If you're interested, write to [cuken107@proton.me](mailto:cuken107@proton.me).
<p align="center">
<a href="https://github.com/kalarina-bit/Sparkledns/releases/latest"><img src="https://img.shields.io/github/v/release/kalarina-bit/Sparkledns?style=for-the-badge&label=release&labelColor=1b1b1b&color=2e7d32" alt="Latest release"></a>
</p>
<p align="center">
<a href="https://f-droid.org/packages/cc.skysparkle.sparkledns/"><img src="assets/get-it-on%20(1).png" height="56" alt="Get it on F-Droid"></a>
<a href="https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://git.skysparkle.cc/kalarina/Sparkledns"><img src="assets/badge_obtainium.png" height="56" alt="Get it on Obtainium"></a>
<a href="https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://github.com/kalarina-bit/Sparkledns"><img src="assets/badge_obtainium.png" height="56" alt="Get it on Obtainium"></a>
<a href="https://github.com/kalarina-bit/Sparkledns/releases/latest"><img src="assets/get-it-on-github.png" height="56" alt="Get it on GitHub"></a>
<a href="https://git.skysparkle.cc/kalarina/Sparkledns/releases"><img src="assets/get-it-on-gitea.png" height="56" alt="Get it on Gitea"></a>
</p>
<p align="center">
<img src="assets/screenshots/1-your-dns-your-choice.png" width="160" alt="Your DNS, your choice">
<img src="assets/screenshots/2-protected.png" width="160" alt="Protected via SkySparkle">
<img src="assets/screenshots/3-stay-informed.png" width="160" alt="Stay informed">
<img src="assets/screenshots/4-block-your-way.png" width="160" alt="Block your way">
<img src="assets/screenshots/5-choose-your-own-route.png" width="160" alt="Choose your own route">
<img src="assets/screenshots/1-private-dns-left.png" width="160" alt="Private DNS in one tap"><img src="assets/screenshots/2-private-dns-right.png" width="160" alt="You're protected">
<img src="assets/screenshots/3-see-every-request.png" width="160" alt="See every request">
<img src="assets/screenshots/4-block-trackers-and-malware.png" width="160" alt="Block trackers and malware">
</p>
> [!TIP]
@@ -36,15 +40,15 @@
- 🔌 **One-tap connect/disconnect**, with a Quick Settings tile
- 🔄 **Switch servers on the fly** — the tunnel restarts automatically
- 🚀 **Built-in server test** showing protocol and latency
- 📊 **Live query monitor** with stats, filters and one-tap blocking
- 📊 **Activity** — 24-hour and 7-day charts, share of the biggest companies, and a live log with filters and one-tap blocking. Numbers stay on the device
- 📱 **Per-app DNS** — chosen apps bypass the tunnel
- 🚫 **Custom blocklists** — your own domains plus hosts/domain/AdBlock lists by URL (HaGeZi Pro++ and TIF presets)
- 🚫 **Custom blocklists** — your own domains plus hosts/domain/AdBlock lists by URL (HaGeZi Pro, Pro++ and TIF presets), updated automatically every day or week, on Wi-Fi only if you like
- 🔓 **No analytics, no Google Play Services**
## <img src="assets/icon-install.png" width="32" alt=""> Installation
- **[F-Droid](https://f-droid.org/packages/cc.skysparkle.sparkledns/)** — install and update through the F-Droid client.
- **[Obtainium](https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://git.skysparkle.cc/kalarina/Sparkledns)** — installs the APK straight from Gitea releases and keeps it up to date.
- **[Obtainium](https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://github.com/kalarina-bit/Sparkledns)** — installs the APK straight from GitHub releases and keeps it up to date.
- **Manually** — download the latest APK from [GitHub](https://github.com/kalarina-bit/Sparkledns/releases/latest) or [Gitea](https://git.skysparkle.cc/kalarina/Sparkledns/releases), allow installs from unknown sources for the app you open it with (Settings → Apps → Special access → Install unknown apps), then open the `.apk` and confirm.
## <img src="assets/icon-verify.png" width="32" alt=""> Verifying a download
@@ -81,6 +85,16 @@ Requires JDK 17+ and Android SDK 36.
Bug reports, DoH server and blocklist suggestions, translation fixes and pull requests are welcome in the [issue tracker](https://git.skysparkle.cc/kalarina/Sparkledns/issues). Please read [CONTRIBUTING.md](CONTRIBUTING.md) first — it explains what fits the project and how to send changes. To open an issue or a pull request, [create an account](https://git.skysparkle.cc/user/sign_up) on this Gitea.
## 💙 Sponsor
<p align="center">
<a href="https://skysparkle.cc"><img src="assets/skysparkle.svg" width="72" alt="Skysparkle"></a>
</p>
<p align="center">
SparkleDNS is sponsored and supported by <a href="https://skysparkle.cc"><b>Skysparkle</b></a> — independent encrypted DNS from Lithuania and the app’s default DoH server.
</p>
## 📄 License
[GNU General Public License v3.0 only](LICENSE).
+30 -14
View File
@@ -1,11 +1,12 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.plugin.compose")
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
}
android {
namespace = "cc.skysparkle.sparkledns"
compileSdk = 36
// The current AndroidX libraries require it
compileSdk = 37
defaultConfig {
applicationId = "cc.skysparkle.sparkledns"
@@ -13,8 +14,8 @@ android {
targetSdk = 36
// Single source of truth: the About screen reads these through BuildConfig.
// Kept as plain literals so F-Droid can detect new versions. Code = major * 10000 + minor * 100 + patch.
versionCode = 10010
versionName = "1.0.10"
versionCode = 10106
versionName = "1.1.6"
}
buildTypes {
@@ -49,6 +50,21 @@ android {
includeInBundle = false
}
packaging {
resources {
// Library files the app never reads: Kotlin metadata for reflection, the coroutines debug
// agent, version markers for tooling and OkHttp's public suffix list, which only cookies use
excludes += listOf(
"/META-INF/*.version",
"/META-INF/*.kotlin_module",
"/kotlin/**",
"/kotlin-tooling-metadata.json",
"/DebugProbesKt.bin",
"/okhttp3/internal/publicsuffix/**",
)
}
}
testOptions {
// android.util.Log and friends are no-ops in JVM unit tests
unitTests.isReturnDefaultValues = true
@@ -56,17 +72,17 @@ android {
}
dependencies {
implementation(platform("androidx.compose:compose-bom:2025.09.00"))
implementation("androidx.activity:activity-compose:1.10.1")
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.material3:material3")
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.material3)
// Already pulled in by Compose at this version; declared because the app uses it directly
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.okhttp)
// Debug builds only, never part of a release
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.14")
debugImplementation(libs.leakcanary.android)
testImplementation("junit:junit:4.13.2")
testImplementation(libs.junit)
}
+11 -5
View File
@@ -6,7 +6,9 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED" />
<!-- Keeps the scheduled blocklist update after a reboot -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- Lists launcher apps for per-app DNS settings without QUERY_ALL_PACKAGES -->
<queries>
@@ -19,6 +21,8 @@
<application
android:name=".SparkleApp"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:localeConfig="@xml/locales_config"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
@@ -38,7 +42,7 @@
<service
android:name=".DohVpnService"
android:exported="false"
android:foregroundServiceType="specialUse"
android:foregroundServiceType="systemExempted"
android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter>
<action android:name="android.net.VpnService" />
@@ -46,11 +50,13 @@
<meta-data
android:name="android.net.VpnService.SUPPORTS_ALWAYS_ON"
android:value="true" />
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="Local DNS-over-HTTPS VPN that keeps encrypted DNS active while the user has it enabled" />
</service>
<service
android:name=".BlocklistUpdateJob"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name=".DnsTileService"
android:exported="true"
@@ -40,6 +40,7 @@ import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
@@ -73,6 +74,7 @@ private val Frameworks = listOf(
OpenSourceItem("AndroidX Activity", "The Android Open Source Project", APACHE_2, APACHE_2_URL, "https://developer.android.com/jetpack/androidx/releases/activity"),
OpenSourceItem("OkHttp", "Square, Inc.", APACHE_2, APACHE_2_URL, "https://square.github.io/okhttp/"),
OpenSourceItem("Okio", "Square, Inc.", APACHE_2, APACHE_2_URL, "https://square.github.io/okio/"),
OpenSourceItem("Material Symbols", "Google", APACHE_2, APACHE_2_URL, "https://github.com/google/material-design-icons"),
OpenSourceItem(
"Android HttpEngine (Cronet)", "The Chromium Authors", "BSD 3-Clause",
"https://chromium.googlesource.com/chromium/src/+/main/LICENSE", "https://developer.android.com/reference/android/net/http/HttpEngine",
@@ -125,7 +127,7 @@ private fun AboutContent(modifier: Modifier, onOpenLicenses: () -> Unit) {
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
Image(
painterResource(R.drawable.app_logo),
remember { AppLogo.get(context) },
contentDescription = null,
modifier = Modifier
.size(104.dp)
@@ -155,13 +157,13 @@ private fun AboutContent(modifier: Modifier, onOpenLicenses: () -> Unit) {
}
OutlinedButton(onClick = { openUrl(context, PRIVACY_POLICY) }, modifier = Modifier.fillMaxWidth()) {
Icon(painterResource(R.drawable.ic_shield_search), contentDescription = null, modifier = Modifier.size(18.dp))
Icon(painterResource(R.drawable.ic_policy), contentDescription = null, modifier = Modifier.size(18.dp))
Spacer(Modifier.width(8.dp))
Text(stringResource(R.string.about_privacy_policy))
}
OutlinedButton(onClick = { openUrl(context, SOURCE_CODE) }, modifier = Modifier.fillMaxWidth()) {
Icon(painterResource(R.drawable.ic_android), contentDescription = null, modifier = Modifier.size(18.dp))
Icon(painterResource(R.drawable.ic_code), contentDescription = null, modifier = Modifier.size(18.dp))
Spacer(Modifier.width(8.dp))
Text(stringResource(R.string.about_source))
}
@@ -0,0 +1,607 @@
package cc.skysparkle.sparkledns
import android.content.ClipData
import android.content.ClipboardManager
import android.widget.Toast
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.background
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.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.verticalScroll
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
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.runtime.structuralEqualityPolicy
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
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
import androidx.lifecycle.compose.collectAsStateWithLifecycle
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),
BLOCKED(R.string.status_blocked),
CACHED(R.string.status_cached),
ERRORS(R.string.mon_errors),
}
private val TimeFormat = SimpleDateFormat("HH:mm:ss", Locale.ROOT)
// Colors of the company slices, then the rest
private val SliceColors = listOf(Palette.Accent, Color(0xFFE6E8EE), Color(0xFF7C69E8), Color(0xFFC9A36A))
private val OtherColor = Palette.Track
private class Slice(val label: String, val share: Float, val color: Color)
// One row of the log: every query for a domain, shown by its newest one. A data class, so a
// rebuilt list with the same groups counts as unchanged.
private data class DomainGroup(val latest: QueryEntry, val types: List<Int>, val count: Int)
// The log is newest first, so the first entry of a domain is its newest one and the groups come
// out in the order their domains were last asked for. Names differ only in letter case when a
// resolver randomizes it, so they are compared in lower case.
private fun groupByDomain(entries: List<QueryEntry>): List<DomainGroup> {
class Builder(val latest: QueryEntry) {
val types = LinkedHashSet<Int>()
var count = 0
}
val groups = LinkedHashMap<String, Builder>()
for (entry in entries) {
val group = groups.getOrPut(entry.domain.lowercase(Locale.ROOT)) { Builder(entry) }
group.types += entry.type
group.count++
}
// Types in numeric order: A, then AAAA, then HTTPS
return groups.values.map { DomainGroup(it.latest, it.types.sorted(), it.count) }
}
@Composable
fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
val custom by Blocklist.custom.collectAsStateWithLifecycle()
val customSet = remember(custom) { custom.toHashSet() }
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("") }
OnQueryLogChange {
entries = QueryLog.snapshot()
summary = StatsStore.summary(period.hours)
}
val statsVersion by StatsStore.version.collectAsStateWithLifecycle()
LaunchedEffect(period, statsVersion) { summary = StatsStore.summary(period.hours) }
// Filtered and grouped by domain again only when the log, the filter or the search changes,
// and the list below is updated only when the result differs: new entries that the filter
// hides change nothing
val visible by remember {
derivedStateOf(structuralEqualityPolicy()) {
val term = search.trim()
val matching = entries.filter { e ->
val matchesFilter = when (filter) {
ActivityFilter.ALL -> true
ActivityFilter.BLOCKED -> e.status == QueryStatus.BLOCKED
ActivityFilter.CACHED -> e.status == QueryStatus.CACHED
ActivityFilter.ERRORS -> e.status == QueryStatus.FAILED
}
matchesFilter && (term.isEmpty() || e.domain.contains(term, ignoreCase = true))
}
groupByDomain(matching)
}
}
val canClear by remember { derivedStateOf { entries.isNotEmpty() } }
fun toggleBlock(domain: String, unblock: Boolean) {
scope.launch {
val result = withContext(Dispatchers.IO) {
tryEdit {
if (unblock) {
Blocklist.removeCustom(context, domain)
true
} else {
Blocklist.addCustom(context, domain)
}
}
}
val ok = result.getOrElse {
showEditError(context, it)
return@launch
}
val message = when {
!ok -> context.getString(R.string.bl_invalid)
unblock -> context.getString(R.string.mon_unblocked, domain)
else -> context.getString(R.string.mon_blocked_added, domain)
}
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}
}
fun copy(domain: String) {
context.getSystemService(ClipboardManager::class.java)
.setPrimaryClip(ClipData.newPlainText("domain", domain))
}
val wide = windowWidth() >= WideLayoutWidth
val side = sidePadding(windowWidth(), if (wide) MaxWideContentWidth else MaxContentWidth)
val clear = {
QueryLog.clear()
entries = emptyList()
}
// The log rows, shared by the one- and two-column layouts
val log: LazyListScope.() -> Unit = {
item(key = "recent") {
RecentHeader(canClear, clear, Modifier.padding(top = if (wide) 0.dp else 24.dp))
}
item(key = "search") {
LogSearch(
search = search,
onSearch = { search = it },
filter = filter,
onFilter = { filter = it },
modifier = Modifier.padding(top = 6.dp, bottom = 4.dp),
)
}
if (visible.isEmpty()) {
item(key = "empty") {
EmptyState(
R.drawable.ic_tab_monitor,
stringResource(if (entries.isEmpty()) R.string.mon_empty else R.string.mon_no_match),
)
}
}
// Keyed by domain, so a new query for a domain moves its row to the top instead of adding one
itemsIndexed(
visible,
key = { _, group -> "domain:" + group.latest.domain.lowercase(Locale.ROOT) },
contentType = { _, _ -> "query" },
) { index, group ->
val entry = group.latest
val blockedByMe = entry.domain in customSet
QueryRow(
modifier = Modifier.animateItem(),
entry = entry,
types = group.types,
count = group.count,
first = index == 0,
blockedByMe = blockedByMe,
onBlock = { toggleBlock(entry.domain, unblock = false) },
onUnblock = { toggleBlock(entry.domain, unblock = true) },
onCopy = { copy(entry.domain) },
)
}
}
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, entries, 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, entries, Modifier.padding(top = 20.dp)) }
log()
}
}
}
@Composable
private fun ActivityHeader(period: StatsPeriod, onPeriod: (StatsPeriod) -> Unit) {
Row(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = 44.dp),
verticalAlignment = Alignment.CenterVertically,
) {
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, recent: List<QueryEntry>, modifier: Modifier = Modifier) {
val other = stringResource(R.string.companies_other)
val slices = remember(summary, recent, other) { companySlices(summary, recent, other) }
Column(
modifier = modifier
.fillMaxWidth()
.appCard()
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
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 < MIN_COMPANY_REQUESTS) {
Text(
stringResource(R.string.companies_wait, summary.total, MIN_COMPANY_REQUESTS),
color = Palette.Fg3,
fontSize = 13.sp,
)
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) {
Donut(slices, Modifier.size(104.dp))
Spacer(Modifier.width(20.dp))
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(8.dp)) {
slices.forEach { slice ->
Row(verticalAlignment = Alignment.CenterVertically) {
Box(
Modifier
.size(8.dp)
.clip(CircleShape)
.background(slice.color)
)
Spacer(Modifier.width(8.dp))
Text(
slice.label,
color = Palette.Fg,
fontSize = 12.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f),
)
Text(percentLabel(slice.share), color = Palette.Fg, fontSize = 12.sp, fontWeight = FontWeight.Bold)
}
}
}
}
}
}
}
// 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)}%"
}
// Shares of the known companies over the period. The statistics keep no domains, so the share
// left over is split by the names of the recent queries to other domains, from the log in memory.
// Then the four largest slices and everything else; empty slices are left out.
private fun companySlices(summary: StatsSummary, recent: List<QueryEntry>, otherLabel: String): List<Slice> {
if (summary.total == 0L) return emptyList()
val shares = HashMap<String, Float>()
for (company in Company.entries) {
val count = summary.companies[company.ordinal]
if (count > 0) shares[company.label] = count.toFloat() / summary.total
}
val unknownShare = (1f - shares.values.sum()).coerceAtLeast(0f)
val names = HashMap<String, Int>()
var unknownCount = 0
for (entry in recent) {
if (Companies.of(entry.domain) != null) continue
unknownCount++
Companies.nameOf(entry.domain)?.let { names.merge(it, 1, Int::plus) }
}
// Queries without a name (local names, reverse lookups) stay in the rest
if (unknownCount > 0) {
for ((name, count) in names) shares.merge(name, unknownShare * count / unknownCount, Float::plus)
}
val slices = shares.entries
.sortedByDescending { it.value }
.take(SliceColors.size)
.mapIndexed { index, (label, share) -> Slice(label, share, SliceColors[index]) }
val rest = (1f - slices.sumOf { it.share.toDouble() }.toFloat()).coerceAtLeast(0f)
return if (rest >= 0.005f) slices + Slice(otherLabel, rest, OtherColor) else slices
}
@Composable
private fun Donut(slices: List<Slice>, modifier: Modifier = Modifier) {
// The ring's geometry is worked out when the size changes, not every frame
Spacer(
modifier.drawWithCache {
val width = 14.dp.toPx()
val stroke = Stroke(width = width)
val diameter = size.minDimension - width
val topLeft = Offset((size.width - diameter) / 2f, (size.height - diameter) / 2f)
val arcSize = Size(diameter, diameter)
onDrawBehind {
drawArc(OtherColor, 0f, 360f, useCenter = false, topLeft = topLeft, size = arcSize, style = stroke)
var start = -90f
slices.forEach { slice ->
val sweep = slice.share * 360f
if (sweep > 0f) {
drawArc(slice.color, start, sweep, useCenter = false, topLeft = topLeft, size = arcSize, style = stroke)
}
start += sweep
}
}
}
)
}
@Composable
private fun QueryRow(
modifier: Modifier,
entry: QueryEntry,
types: List<Int>,
count: Int,
first: Boolean,
blockedByMe: Boolean,
onBlock: () -> Unit,
onUnblock: () -> Unit,
onCopy: () -> Unit,
) {
var menu by remember { mutableStateOf(false) }
val (avatarBackground, avatarColor) = when (entry.status) {
QueryStatus.BLOCKED -> Palette.Blocked.copy(alpha = 0.14f) to Palette.Blocked
QueryStatus.CACHED -> CachedColor.copy(alpha = 0.14f) to CachedColor
QueryStatus.FAILED -> WarningColor.copy(alpha = 0.14f) to WarningColor
QueryStatus.OK -> Color(0xFF2A2C33) to Palette.Fg
}
val detail = when (entry.status) {
QueryStatus.OK -> stringResource(R.string.mon_ms, entry.latencyMs)
QueryStatus.CACHED -> stringResource(R.string.status_cached)
QueryStatus.BLOCKED -> stringResource(if (blockedByMe) R.string.bl_my else R.string.tab_blocklist)
QueryStatus.FAILED -> stringResource(R.string.status_failed)
}
// "A, AAAA, HTTPS · ×3 · 256 ms"; the status and time are those of the newest query
val typeNames = types.joinToString(", ") { DnsMessage.typeName(it) }
val summary = if (count > 1) "$typeNames · ×$count · $detail" else "$typeNames · $detail"
Box(modifier.fillMaxWidth()) {
Column {
if (!first) HorizontalDivider(color = Palette.Line)
Row(
modifier = Modifier
.fillMaxWidth()
.clickable { menu = true }
.padding(vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Box(
modifier = Modifier
.size(34.dp)
.clip(CircleShape)
.background(avatarBackground),
contentAlignment = Alignment.Center,
) {
Text(initialOf(entry.domain), color = avatarColor, fontSize = 13.sp, fontWeight = FontWeight.ExtraBold)
}
Spacer(Modifier.width(12.dp))
Column(Modifier.weight(1f)) {
Text(
entry.domain,
color = Palette.Fg,
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(
summary,
color = Palette.Fg3,
fontSize = 12.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
Spacer(Modifier.width(8.dp))
Column(horizontalAlignment = Alignment.End) {
if (entry.status == QueryStatus.BLOCKED) {
Text(stringResource(R.string.status_blocked), color = Palette.Blocked, fontSize = 12.sp, fontWeight = FontWeight.Bold)
} else if (entry.status == QueryStatus.FAILED) {
Text(stringResource(R.string.status_failed), color = WarningColor, fontSize = 12.sp, fontWeight = FontWeight.Bold)
}
Text(TimeFormat.format(Date(entry.time)), color = Palette.Fg3, fontSize = 12.sp)
}
}
}
DropdownMenu(expanded = menu, onDismissRequest = { menu = false }) {
if (blockedByMe) {
DropdownMenuItem(
text = { Text(stringResource(R.string.mon_unblock)) },
leadingIcon = { MenuIcon(R.drawable.ic_check) },
onClick = {
menu = false
onUnblock()
},
)
} else if (entry.status != QueryStatus.BLOCKED) {
DropdownMenuItem(
text = { Text(stringResource(R.string.mon_block)) },
leadingIcon = { MenuIcon(R.drawable.ic_tab_block) },
onClick = {
menu = false
onBlock()
},
)
}
DropdownMenuItem(
text = { Text(stringResource(R.string.copy)) },
leadingIcon = { MenuIcon(R.drawable.ic_copy) },
onClick = {
menu = false
onCopy()
},
)
}
}
}
@Composable
private fun MenuIcon(@DrawableRes icon: Int) {
Icon(painterResource(icon), contentDescription = null, tint = Palette.Fg2, modifier = Modifier.size(20.dp))
}
// First letter of the main part of a domain: "a" for app-measurement.com, "g" for www.google.com
private fun initialOf(domain: String): String {
val parts = domain.split('.').filter { it.isNotEmpty() }
val main = if (parts.size >= 2) parts[parts.size - 2] else parts.firstOrNull().orEmpty()
return main.firstOrNull { it.isLetterOrDigit() }?.toString() ?: "·"
}
@@ -4,85 +4,194 @@ import androidx.activity.compose.BackHandler
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
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.draw.shadow
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
private enum class Tab(@StringRes val label: Int, @DrawableRes val icon: Int) {
HOME(R.string.tab_home, R.drawable.ic_tab_home),
MONITOR(R.string.tab_monitor, R.drawable.ic_tab_monitor),
APPS(R.string.tab_apps, R.drawable.ic_tab_apps),
BLOCKLIST(R.string.tab_blocklist, R.drawable.ic_tab_block),
ABOUT(R.string.tab_about, R.drawable.ic_tab_info),
// The three tabs of the bottom panel, then the pages opened from them
private enum class Screen(@StringRes val label: Int, @DrawableRes val icon: Int, val isTab: Boolean) {
HOME(R.string.tab_home, R.drawable.ic_tab_home, true),
ACTIVITY(R.string.tab_activity, R.drawable.ic_tab_monitor, true),
SETTINGS(R.string.tab_settings, R.drawable.ic_tab_settings, true),
BLOCKLIST(R.string.blocklist_title, R.drawable.ic_tab_block, false),
APPS(R.string.settings_apps, R.drawable.ic_tab_apps, false),
ABOUT(R.string.tab_about, R.drawable.ic_tab_info, false),
}
private val Tabs = Screen.entries.filter { it.isTab }
@Composable
fun AppShell() {
var tab by rememberSaveable { mutableStateOf(Tab.HOME) }
var tab by rememberSaveable { mutableStateOf(Screen.HOME) }
var page by rememberSaveable { mutableStateOf<Screen?>(null) }
val current = page ?: tab
// Back leads to Home first; only Home closes the app
BackHandler(enabled = tab != Tab.HOME) { tab = Tab.HOME }
// Back closes an open page first, then leads to Home; only Home closes the app
BackHandler(enabled = page == null && tab != Screen.HOME) { tab = Screen.HOME }
BackHandler(enabled = page != null) { page = null }
Scaffold(
bottomBar = {
NavigationBar {
Tab.entries.forEach { item ->
NavigationBarItem(
selected = tab == item,
onClick = { tab = item },
icon = { Icon(painterResource(item.icon), contentDescription = null) },
label = {
Text(stringResource(item.label), maxLines = 1, overflow = TextOverflow.Ellipsis)
},
)
}
}
},
) { padding ->
// Screens drift a little in the direction of the tab that was picked and cross-fade
val navInset = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()
// Room under the last item of a tab, so it can scroll clear of the floating panel
val tabBottom = navInset + 112.dp
val pageBottom = navInset + 24.dp
Box(
Modifier
.fillMaxSize()
.background(Palette.Bg)
) {
AnimatedContent(
targetState = tab,
targetState = current,
transitionSpec = {
val forward = targetState.ordinal > initialState.ordinal
val shift = { width: Int -> if (forward) width / 8 else -width / 8 }
// Pages slide in from the side; tabs drift a little towards the tab that was picked
val pageMove = targetState.isTab != initialState.isTab
val forward = if (pageMove) !targetState.isTab else targetState.ordinal > initialState.ordinal
val divisor = if (pageMove) 3 else 8
val shift = { width: Int -> if (forward) width / divisor else -width / divisor }
(fadeIn(Motion.enterFade) + slideInHorizontally(Motion.slide) { shift(it) }) togetherWith
(fadeOut(Motion.exitFade) + slideOutHorizontally(Motion.slide) { -shift(it) })
},
modifier = Modifier
.fillMaxSize()
.padding(padding)
.consumeWindowInsets(padding)
.statusBarsPadding()
.imePadding(),
label = "tabs",
) { current ->
label = "screens",
) { screen ->
val modifier = Modifier.fillMaxSize()
when (current) {
Tab.HOME -> HomeScreen(modifier)
Tab.MONITOR -> MonitorScreen(modifier)
Tab.APPS -> AppsScreen(modifier)
Tab.BLOCKLIST -> BlocklistScreen(modifier)
Tab.ABOUT -> AboutScreen(modifier)
when (screen) {
Screen.HOME -> HomeScreen(
bottomPadding = tabBottom,
onOpenBlocklist = { page = Screen.BLOCKLIST },
onOpenServers = { tab = Screen.SETTINGS },
modifier = modifier,
)
Screen.ACTIVITY -> ActivityScreen(bottomPadding = tabBottom, modifier = modifier)
Screen.SETTINGS -> SettingsScreen(
bottomPadding = tabBottom,
onOpenApps = { page = Screen.APPS },
onOpenAbout = { page = Screen.ABOUT },
modifier = modifier,
)
Screen.BLOCKLIST -> BlocklistScreen(bottomPadding = pageBottom, onBack = { page = null }, modifier = modifier)
Screen.APPS -> SubPage(stringResource(R.string.settings_apps), onBack = { page = null }, modifier = modifier) {
AppsScreen(Modifier.fillMaxSize())
}
Screen.ABOUT -> SubPage(stringResource(R.string.tab_about), onBack = { page = null }, modifier = modifier) {
AboutScreen(Modifier.fillMaxSize())
}
}
}
AnimatedVisibility(
visible = page == null,
enter = fadeIn(Motion.enterFade),
exit = fadeOut(Motion.exitFade),
modifier = Modifier.align(Alignment.BottomCenter),
) {
Box(contentAlignment = Alignment.BottomCenter) {
// Content scrolling under the panel fades out instead of being cut off
Box(
Modifier
.fillMaxWidth()
.height(120.dp + navInset)
.background(Brush.verticalGradient(0f to Color.Transparent, 0.7f to Palette.Bg))
)
NavPill(
current = tab,
onSelect = { tab = it },
modifier = Modifier
.navigationBarsPadding()
.padding(bottom = 20.dp),
)
}
}
}
}
// Floating bottom panel: dark, with the picked tab lit in the accent color
@Composable
private fun NavPill(current: Screen, onSelect: (Screen) -> Unit, modifier: Modifier = Modifier) {
val shape = RoundedCornerShape(30.dp)
Row(
modifier = modifier
.shadow(18.dp, shape)
.clip(shape)
.background(Palette.Nav)
.border(1.dp, Color.White.copy(alpha = 0.07f), shape)
.padding(6.dp)
.selectableGroup(),
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
Tabs.forEach { item -> NavItem(item, selected = item == current, onSelect = onSelect) }
}
}
// One tab of the panel. Its own composable, so a color animation recomposes only the tabs that
// change instead of the whole panel; the background is read only when drawing.
@Composable
private fun NavItem(item: Screen, selected: Boolean, onSelect: (Screen) -> Unit) {
val background by animateColorAsState(
if (selected) Palette.AccentSoft else Color.Transparent,
animationSpec = Motion.color,
label = "navBackground",
)
val tint by animateColorAsState(
if (selected) Palette.Accent else Palette.NavIcon,
animationSpec = Motion.color,
label = "navTint",
)
val label = stringResource(item.label)
Box(
modifier = Modifier
.size(width = 58.dp, height = 44.dp)
.clip(RoundedCornerShape(22.dp))
.drawBehind { drawRect(background) }
.selectable(selected = selected, onClick = { onSelect(item) }, role = Role.Tab)
.semantics { contentDescription = label },
contentAlignment = Alignment.Center,
) {
Icon(painterResource(item.icon), contentDescription = null, tint = tint, modifier = Modifier.size(22.dp))
}
}
@@ -33,7 +33,6 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TriStateCheckbox
@@ -338,7 +337,7 @@ private fun AppRow(modifier: Modifier, app: AppItem, enabled: Boolean, last: Boo
)
}
Spacer(Modifier.width(12.dp))
Switch(checked = enabled, onCheckedChange = null)
AppSwitch(checked = enabled, onCheckedChange = null)
}
}
}
@@ -0,0 +1,70 @@
package cc.skysparkle.sparkledns
import android.app.job.JobInfo
import android.app.job.JobParameters
import android.app.job.JobScheduler
import android.app.job.JobService
import android.content.ComponentName
import android.content.Context
import android.util.Log
import java.util.concurrent.TimeUnit
enum class UpdateInterval(val days: Long) { OFF(0), DAILY(1), WEEKLY(7) }
// Downloads newer versions of the user's blocklists in the background. Uses the system
// JobScheduler, so the app needs no extra library and nothing runs while the conditions are not met.
object AutoUpdate {
private const val JOB_ID = 4201
// JobInfo.networkType is deprecated in favour of NetworkRequest, which needs API 28
@Suppress("DEPRECATION")
fun apply(context: Context) {
val prefs = Prefs(context)
val scheduler = context.getSystemService(JobScheduler::class.java) ?: return
val interval = prefs.updateInterval
if (interval == UpdateInterval.OFF) {
scheduler.cancel(JOB_ID)
return
}
val period = TimeUnit.DAYS.toMillis(interval.days)
val network = if (prefs.updateWifiOnly) JobInfo.NETWORK_TYPE_UNMETERED else JobInfo.NETWORK_TYPE_ANY
// Scheduling the same job again would start its period over, so an unchanged one is kept
val existing = scheduler.getPendingJob(JOB_ID)
if (existing != null && existing.intervalMillis == period && existing.networkType == network) return
val job = JobInfo.Builder(JOB_ID, ComponentName(context, BlocklistUpdateJob::class.java))
.setPeriodic(period)
.setRequiredNetworkType(network)
.setRequiresBatteryNotLow(true)
.setPersisted(true)
.build()
try {
scheduler.schedule(job)
} catch (e: RuntimeException) {
Log.w("SparkleDNS", "Cannot schedule blocklist updates", e)
}
}
}
class BlocklistUpdateJob : JobService() {
override fun onStartJob(params: JobParameters): Boolean {
Thread({
// A failed download is retried later with the system's back-off
val retry = try {
!Blocklist.updateAllNow(applicationContext)
} catch (e: Exception) {
Log.w("SparkleDNS", "Blocklist update failed", e)
true
} catch (e: OutOfMemoryError) {
// Must not take the VPN down with it; retrying would only run out of memory again
Log.e("SparkleDNS", "Blocklist update ran out of memory", e)
false
}
jobFinished(params, retry)
}, "blocklist-update").start()
return true
}
// Downloads cannot be cut short halfway; the next run picks up where this one stopped
override fun onStopJob(params: JobParameters): Boolean = true
}
@@ -12,6 +12,7 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import okhttp3.OkHttpClient
import okhttp3.Request
import okio.BufferedSource
import org.json.JSONArray
import org.json.JSONObject
import java.io.BufferedOutputStream
@@ -20,14 +21,17 @@ import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.IOException
import java.nio.LongBuffer
import java.nio.channels.FileChannel
import java.security.MessageDigest
import java.util.concurrent.TimeUnit
data class RemoteList(val url: String, val count: Int, val updated: Long)
// A switched-off list keeps its file, so switching it on again needs no download
data class RemoteList(val url: String, val count: Int, val updated: Long, val enabled: Boolean = true)
// Blocks a domain together with all its subdomains. Changes apply instantly, no reconnect needed.
// Domains are kept as sorted 64-bit hashes: about 8 bytes per entry, so million-entry lists fit easily.
// Domains are kept as sorted 64-bit hashes in files that are memory-mapped, not read into the heap:
// lists with millions of entries cost page cache, not app memory, so low-end phones cope too.
object Blocklist {
const val ALL_LISTS = "*"
@@ -59,15 +63,22 @@ object Blocklist {
// Downloaded lists and own domains are kept apart, so editing a few own domains
// does not rebuild a set that can hold millions of entries
@Volatile
private var listHashes = LongArray(0)
private var listHashes: LongBuffer = EMPTY_SET
@Volatile
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)) }
// Reads the saved lists unless something did already, such as the background update job
fun ensureLoaded(context: Context) {
synchronized(lock) { ensureLoaded(BlocklistStore(context)) }
}
fun setEnabled(context: Context, value: Boolean) {
BlocklistStore(context).enabled = value
@@ -104,6 +115,15 @@ object Blocklist {
reloadListHashes(store)
}
fun setListEnabled(context: Context, url: String, value: Boolean) = synchronized(lock) {
val store = BlocklistStore(context)
ensureLoaded(store)
val updated = _lists.value.map { if (it.url == url) it.copy(enabled = value) else it }
store.saveLists(updated)
_lists.value = updated
reloadListHashes(store)
}
// Downloads run in the background, outside the lock, so editing own domains never waits for them.
// Returns false when another download is already running.
fun download(context: Context, url: String): Boolean {
@@ -125,11 +145,12 @@ object Blocklist {
return true
}
// Switched-off lists are skipped: nobody uses them until they are switched on again
fun updateAll(context: Context): Boolean {
if (_lists.value.isEmpty() || !_busy.compareAndSet(null, ALL_LISTS)) return false
val current = _lists.value.filter { it.enabled }
if (current.isEmpty() || !_busy.compareAndSet(null, ALL_LISTS)) return false
_error.value = null
val store = BlocklistStore(context.applicationContext)
val current = _lists.value
scope.launch {
try {
val fresh = current.mapNotNull { list ->
@@ -150,10 +171,38 @@ object Blocklist {
return true
}
// Blocking, for the background update job. Returns false when a list could not be downloaded.
fun updateAllNow(context: Context): Boolean {
val store = BlocklistStore(context.applicationContext)
synchronized(lock) { ensureLoaded(store) }
val current = _lists.value.filter { it.enabled }
// Nothing to do, or the user is updating right now
if (current.isEmpty() || !_busy.compareAndSet(null, ALL_LISTS)) return true
var ok = true
try {
val fresh = current.mapNotNull { list ->
try {
store.download(list.url, list)
} catch (e: Exception) {
Log.w("SparkleDNS", "Cannot update ${list.url}", e)
ok = false
null
}
}
commit(store, fresh)
} catch (e: IOException) {
Log.w("SparkleDNS", "Cannot save updated lists", e)
ok = false
} finally {
_busy.value = null
}
return ok
}
private fun commit(store: BlocklistStore, fresh: List<RemoteList>) = synchronized(lock) {
ensureLoaded(store)
val byUrl = fresh.associateBy { it.url }
val kept = _lists.value.map { byUrl[it.url] ?: it }
val kept = _lists.value.map { old -> byUrl[old.url]?.copy(enabled = old.enabled) ?: old }
val added = fresh.filter { new -> kept.none { it.url == new.url } }
val updated = kept + added
store.saveLists(updated)
@@ -173,10 +222,16 @@ object Blocklist {
customHashes = LongArray(custom.size) { DomainHash.of(custom[it]) }.sortUnique()
reloadListHashes(store)
loaded = true
_ready.value = true
}
private fun reloadListHashes(store: BlocklistStore) {
listHashes = mergeSorted(_lists.value.map { store.loadListHashes(it.url) })
try {
listHashes = store.mergedHashes(_lists.value.filter { it.enabled })
} catch (e: IOException) {
// Out of storage: the lists in use stay active until the next change
Log.w("SparkleDNS", "Cannot merge blocklists", e)
}
_total.value = unionSize(listHashes, customHashes)
}
@@ -187,51 +242,81 @@ object Blocklist {
}
}
// True when the name or one of its parent domains is in either sorted hash set
internal fun isBlockedIn(name: String, lists: LongArray, custom: LongArray): Boolean {
if (lists.isEmpty() && custom.isEmpty()) return false
val domain = name.trimEnd('.')
// True when the name or one of its parent domains is in either sorted hash set. Runs for every
// query, so trailing dots are skipped by index rather than trimmed off a copy of the name.
internal fun isBlockedIn(name: String, lists: LongBuffer, custom: LongArray): Boolean {
if (lists.limit() == 0 && custom.isEmpty()) return false
val end = nameEnd(name)
var start = 0
while (true) {
val hash = DomainHash.of(domain, start)
if (lists.binarySearch(hash) >= 0 || custom.binarySearch(hash) >= 0) return true
val dot = domain.indexOf('.', start)
if (dot < 0) return false
val hash = DomainHash.of(name, start, end)
if (lists.containsSorted(hash) || custom.binarySearch(hash) >= 0) return true
val dot = name.indexOf('.', start)
if (dot < 0 || dot >= end) return false
start = dot + 1
}
}
// Number of distinct entries in both sorted sets; the custom set is small
internal fun unionSize(lists: LongArray, custom: LongArray): Int =
lists.size + custom.count { lists.binarySearch(it) < 0 }
// Merges sorted, duplicate-free arrays in linear time instead of sorting their concatenation
internal fun mergeSorted(parts: List<LongArray>): LongArray {
var arrays = parts.filter { it.isNotEmpty() }.map { if (it.isSortedUnique()) it else it.copyOf().sortUnique() }
if (arrays.isEmpty()) return LongArray(0)
while (arrays.size > 1) {
arrays = arrays.chunked(2).map { if (it.size == 2) mergeTwo(it[0], it[1]) else it[0] }
}
return arrays[0]
// Length of the name without trailing dots
internal fun nameEnd(name: String): Int {
var end = name.length
while (end > 0 && name[end - 1] == '.') end--
return end
}
private fun mergeTwo(a: LongArray, b: LongArray): LongArray {
val out = LongArray(a.size + b.size)
var i = 0
var j = 0
var n = 0
while (i < a.size && j < b.size) {
val x = a[i]
val y = b[j]
internal val EMPTY_SET: LongBuffer = LongBuffer.wrap(LongArray(0))
// Binary search by absolute index, so several threads can read the same buffer at once
internal fun LongBuffer.containsSorted(value: Long): Boolean {
var low = 0
var high = limit() - 1
while (low <= high) {
val mid = (low + high) ushr 1
val v = get(mid)
when {
x < y -> { out[n++] = x; i++ }
x > y -> { out[n++] = y; j++ }
else -> { out[n++] = x; i++; j++ }
v < value -> low = mid + 1
v > value -> high = mid - 1
else -> return true
}
}
while (i < a.size) out[n++] = a[i++]
while (j < b.size) out[n++] = b[j++]
return if (n == out.size) out else out.copyOf(n)
return false
}
// Number of distinct entries in both sorted sets; the custom set is small
internal fun unionSize(lists: LongBuffer, custom: LongArray): Int =
lists.limit() + custom.count { !lists.containsSorted(it) }
// Merges sorted, duplicate-free sets in one pass and hands each value to [emit] once, in order.
// Only the read positions are kept in memory, so inputs and output can be files of any size.
internal fun mergeSortedInto(parts: List<LongBuffer>, emit: (Long) -> Unit): Int {
val sets = parts.filter { it.limit() > 0 }
val pos = IntArray(sets.size)
var count = 0
while (true) {
var min = 0L
var found = false
for (i in sets.indices) {
if (pos[i] < sets[i].limit()) {
val v = sets[i].get(pos[i])
if (!found || v < min) {
min = v
found = true
}
}
}
if (!found) return count
for (i in sets.indices) if (pos[i] < sets[i].limit() && sets[i].get(pos[i]) == min) pos[i]++
emit(min)
count++
}
}
// In-memory variant for small sets; inputs that are not sorted yet are sorted first
internal fun mergeSorted(parts: List<LongArray>): LongArray {
val sorted = parts.map { LongBuffer.wrap(if (it.isSortedUnique()) it else it.copyOf().sortUnique()) }
val out = LongList()
mergeSortedInto(sorted) { out.add(it) }
return out.toArray()
}
private fun LongArray.isSortedUnique(): Boolean {
@@ -243,10 +328,10 @@ internal object DomainHash {
private const val FNV_OFFSET = -3750763034362895579L // 0xcbf29ce484222325
private const val FNV_PRIME = 1099511628211L
// FNV-1a over the domain starting at [start], so parent domains are hashed without substrings
fun of(s: String, start: Int = 0): Long {
// FNV-1a over the characters from [start] to [end], so parent domains are hashed without substrings
fun of(s: String, start: Int = 0, end: Int = s.length): Long {
var h = FNV_OFFSET
for (i in start until s.length) {
for (i in start until end) {
h = h xor s[i].code.toLong()
h *= FNV_PRIME
}
@@ -265,6 +350,20 @@ private class LongList {
}
fun toArray(): LongArray = data.copyOf(size)
// Sorts the filled part in place and drops duplicates, without copying; returns the new size
fun sortUnique(): Int {
if (size < 2) return size
java.util.Arrays.sort(data, 0, size)
var n = 1
for (i in 1 until size) if (data[i] != data[n - 1]) data[n++] = data[i]
size = n
return n
}
fun writeTo(out: DataOutputStream) {
for (i in 0 until size) out.writeLong(data[i])
}
}
// Sorts in place and drops duplicates
@@ -277,8 +376,12 @@ private fun LongArray.sortUnique(): LongArray {
}
private class BlocklistStore(context: Context) {
private val dir = File(context.filesDir, "blocklist").apply { mkdirs() }
private val sp = context.getSharedPreferences("blocklist", Context.MODE_PRIVATE)
private val appContext = context.applicationContext
// Created on first use: switching blocking on or off, which happens on the main thread,
// touches only the settings
private val dir by lazy { File(appContext.filesDir, "blocklist").apply { mkdirs() } }
private val sp = appContext.getSharedPreferences("blocklist", Context.MODE_PRIVATE)
var enabled: Boolean
get() = sp.getBoolean("enabled", true)
@@ -301,7 +404,7 @@ private class BlocklistStore(context: Context) {
val array = JSONArray(raw)
(0 until array.length()).map {
val o = array.getJSONObject(it)
RemoteList(o.getString("url"), o.getInt("count"), o.getLong("updated"))
RemoteList(o.getString("url"), o.getInt("count"), o.getLong("updated"), o.getBoolean("enabled"))
}
}.getOrDefault(emptyList())
}
@@ -309,28 +412,53 @@ private class BlocklistStore(context: Context) {
fun saveLists(lists: List<RemoteList>) {
val array = JSONArray()
lists.forEach {
array.put(JSONObject().put("url", it.url).put("count", it.count).put("updated", it.updated))
array.put(
JSONObject().put("url", it.url).put("count", it.count).put("updated", it.updated).put("enabled", it.enabled)
)
}
sp.edit().putString("lists", array.toString()).commit()
}
fun loadListHashes(url: String): LongArray {
val file = binFile(url)
if (!file.exists()) migrateText(url)?.let { return it }
if (!file.exists()) return LongArray(0)
fun loadListHashes(url: String): LongBuffer = map(binFile(url)) ?: EMPTY_SET
// One list is used as it is; several are merged into one file, which is reused at the next
// start as long as the switched-on lists have not changed
fun mergedHashes(lists: List<RemoteList>): LongBuffer {
if (lists.size < 2) {
mergedFile.delete()
return lists.firstOrNull()?.let { loadListHashes(it.url) } ?: EMPTY_SET
}
val signature = hash(lists.sortedBy { it.url }.joinToString("\n") { "${it.url} ${it.count} ${it.updated}" })
if (sp.getString(MERGED_KEY, null) == signature) map(mergedFile)?.let { return it }
val parts = lists.map { loadListHashes(it.url) }
val tmp = File.createTempFile("merged_", ".tmp", dir)
try {
DataOutputStream(BufferedOutputStream(FileOutputStream(tmp), 64 * 1024)).use { out ->
mergeSortedInto(parts) { out.writeLong(it) }
}
if (!tmp.renameTo(mergedFile)) throw IOException("Cannot save lists")
} finally {
tmp.delete()
}
sp.edit().putString(MERGED_KEY, signature).commit()
return map(mergedFile) ?: EMPTY_SET
}
// The mapping stays valid after the file is replaced or deleted, so readers are never cut off
private fun map(file: File): LongBuffer? {
if (!file.exists()) return null
return runCatching {
FileInputStream(file).use { stream ->
val channel = stream.channel
val result = LongArray((channel.size() / 8).toInt())
channel.map(FileChannel.MapMode.READ_ONLY, 0, result.size * 8L).asLongBuffer().get(result)
result
val bytes = channel.size() / 8 * 8
if (bytes == 0L) EMPTY_SET else channel.map(FileChannel.MapMode.READ_ONLY, 0, bytes).asLongBuffer()
}
}.getOrDefault(LongArray(0))
}.getOrNull()
}
fun deleteListFile(url: String) {
binFile(url).delete()
textFile(url).delete()
sp.edit().remove(etagKey(url)).remove(modifiedKey(url)).apply()
}
@@ -348,30 +476,29 @@ private class BlocklistStore(context: Context) {
if (!response.isSuccessful) throw IOException("HTTP ${response.code}")
val body = response.body ?: throw IOException("Empty response")
val parsed = LongList()
body.charStream().buffered().useLines { lines ->
lines.forEach { line ->
val domain = BlocklistParser.parseLine(line) ?: return@forEach
BlocklistParser.readLimitedLines(body.source()) { line ->
val domain = BlocklistParser.parseLine(line) ?: return@readLimitedLines
// Far above the largest common lists; keeps a wrong URL from exhausting memory
if (parsed.size >= MAX_LIST_DOMAINS) throw IOException("List too large")
parsed.add(DomainHash.of(domain))
}
}
val result = parsed.toArray().sortUnique()
if (result.isEmpty()) throw IOException("No domains found")
write(url, result)
// Sorted inside the download buffer: a list with millions of entries is never copied
val count = parsed.sortUnique()
if (count == 0) throw IOException("No domains found")
write(url, parsed)
sp.edit()
.putOrRemove(etagKey(url), response.header("ETag"))
.putOrRemove(modifiedKey(url), response.header("Last-Modified"))
.apply()
return RemoteList(url, result.size, System.currentTimeMillis())
return RemoteList(url, count, System.currentTimeMillis())
}
}
private fun write(url: String, data: LongArray) {
private fun write(url: String, data: LongList) {
val tmp = File.createTempFile("list_", ".tmp", dir)
try {
DataOutputStream(BufferedOutputStream(FileOutputStream(tmp), 64 * 1024)).use { out ->
data.forEach { out.writeLong(it) }
data.writeTo(out)
}
if (!tmp.renameTo(binFile(url))) throw IOException("Cannot save list")
} finally {
@@ -379,16 +506,6 @@ private class BlocklistStore(context: Context) {
}
}
// Lists saved by older versions as plain text are converted once
private fun migrateText(url: String): LongArray? {
val text = textFile(url)
if (!text.exists()) return null
val result = text.readLines().map { DomainHash.of(it) }.toLongArray().sortUnique()
runCatching { write(url, result) }
text.delete()
return result
}
private fun etagKey(url: String) = "etag_${hash(url)}"
private fun modifiedKey(url: String) = "modified_${hash(url)}"
@@ -396,7 +513,7 @@ private class BlocklistStore(context: Context) {
if (value == null) remove(key) else putString(key, value)
private fun binFile(url: String) = File(dir, "list_${hash(url)}.bin")
private fun textFile(url: String) = File(dir, "list_${hash(url)}.txt")
private val mergedFile get() = File(dir, "merged.bin")
private fun hash(url: String) = MessageDigest.getInstance("SHA-256").digest(url.toByteArray())
.take(8).joinToString("") { "%02x".format(it) }
@@ -404,6 +521,8 @@ private class BlocklistStore(context: Context) {
companion object {
const val MAX_LIST_DOMAINS = 4_000_000
private const val MERGED_KEY = "merged"
val client: OkHttpClient by lazy {
Http.client.newBuilder()
.readTimeout(60, TimeUnit.SECONDS)
@@ -414,6 +533,59 @@ private class BlocklistStore(context: Context) {
// Understands hosts files, plain domain lists, AdBlock rules (||domain^) and dnsmasq / unbound syntax
object BlocklistParser {
/** A list larger than this is refused; the biggest common lists are well below it. */
const val MAX_LIST_BYTES = 256L * 1024 * 1024
/** Longer lines (no blocklist entry is that long) are skipped, not read into memory. */
const val MAX_LINE_BYTES = 4096L
/**
* Reads [source] line by line within [MAX_LIST_BYTES] in total and [MAX_LINE_BYTES] per
* line, so a wrong URL (a binary file, a page with no line breaks) cannot fill the memory.
*/
fun readLimitedLines(source: BufferedSource, onLine: (String) -> Unit) {
var total = 0L
fun consumed(bytes: Long) {
total += bytes
if (total > MAX_LIST_BYTES) throw IOException("List too large")
}
while (true) {
val newline = source.indexOf('\n'.code.toByte(), 0, MAX_LINE_BYTES + 1)
when {
newline >= 0 -> {
onLine(source.readUtf8(newline))
source.skip(1)
consumed(newline + 1)
}
source.exhausted() -> return
source.request(MAX_LINE_BYTES + 1) -> {
// Overlong line: drop it piece by piece up to its end
while (true) {
// Only what is already buffered: the next line may start right after the break
val end = source.buffer.indexOf('\n'.code.toByte())
if (end >= 0) {
source.skip(end + 1)
consumed(end + 1)
break
}
val chunk = source.buffer.size
if (chunk == 0L) return
source.skip(chunk)
consumed(chunk)
if (!source.request(1)) return
}
}
else -> {
// Last line without a line break
val rest = source.buffer.size
onLine(source.readUtf8())
consumed(rest)
return
}
}
}
}
private val WHITESPACE = Regex("\\s+")
private val IGNORED = setOf(
"localhost", "localhost.localdomain", "local", "broadcasthost",
@@ -429,6 +601,8 @@ object BlocklistParser {
// Fast path for AdBlock-style lists such as HaGeZi: ||domain^
if (line.startsWith("||")) {
val end = line.indexOfAny(charArrayOf('^', '$', '/'), 2)
// ||example.com/ads/ blocks one path in a browser; as DNS it would block the whole site
if (end >= 0 && line[end] == '/' && hasPath(line.substring(end))) return null
return normalize(if (end >= 0) line.substring(2, end) else line.substring(2))
}
if (DNSMASQ.any { line.startsWith(it) }) return normalize(line.substringAfter("=/").substringBefore('/'))
@@ -438,9 +612,17 @@ object BlocklistParser {
val parts = line.substringBefore('#').trim().split(WHITESPACE)
val candidate = if (parts.size >= 2 && looksLikeIp(parts[0])) parts[1] else parts[0]
if (candidate.lowercase() in IGNORED) return null
// A URL with a path (|http://example.com/x|) stands for one page, not for the domain
val afterScheme = candidate.substringAfter("://")
val slash = afterScheme.indexOf('/')
if (slash >= 0 && hasPath(afterScheme.substring(slash))) return null
return normalize(candidate)
}
// "/", "/^" or "/|" only end the host; anything longer is a path
private fun hasPath(fromSlash: String): Boolean =
fromSlash.trimEnd('^', '|').length > 1
fun normalize(input: String): String? {
var s = input.trim().lowercase()
s = s.substringAfter("://")
@@ -2,38 +2,42 @@ package cc.skysparkle.sparkledns
import android.content.Context
import android.net.Uri
import android.text.format.DateUtils
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.border
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.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.ZeroCornerSize
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.AssistChip
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Switch
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
@@ -45,49 +49,74 @@ 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.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
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.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.IOException
import java.text.DateFormat
import java.util.Date
private class Preset(val name: String, val url: String, @StringRes val description: Int)
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(
"HaGeZi Pro++" to "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/pro.plus.txt",
"HaGeZi TIF" to "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/tif.txt",
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),
)
private val TopShape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp)
private val BottomShape = RoundedCornerShape(bottomStart = 20.dp, bottomEnd = 20.dp)
@Composable
fun BlocklistScreen(modifier: Modifier = Modifier) {
fun BlocklistScreen(bottomPadding: Dp, onBack: () -> Unit, modifier: Modifier = Modifier) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
val prefs = remember { Prefs(context) }
var showNote by remember { mutableStateOf(!prefs.isHintDismissed(HINT_BLOCKLIST)) }
val side = sidePadding(windowWidth())
val enabled by Blocklist.enabled.collectAsStateWithLifecycle()
val total by Blocklist.total.collectAsStateWithLifecycle()
val custom by Blocklist.custom.collectAsStateWithLifecycle()
val lists by Blocklist.lists.collectAsStateWithLifecycle()
var domainInput by rememberSaveable { mutableStateOf("") }
var domainError by remember { mutableStateOf(false) }
var urlInput by rememberSaveable { mutableStateOf("") }
// Downloads live in Blocklist, so they keep running and stay visible across tab switches
// Downloads live in Blocklist, so they keep running and stay visible when the page is closed
val busy by Blocklist.busy.collectAsStateWithLifecycle()
val error by Blocklist.error.collectAsStateWithLifecycle()
val lastError = remember { arrayOf("") } // kept while the card animates out
error?.let { lastError[0] = it }
val shownError = rememberLast(error).orEmpty()
var search by rememberSaveable { mutableStateOf("") }
var domainsOpen by rememberSaveable { mutableStateOf(false) }
var domainInput by rememberSaveable { mutableStateOf("") }
var domainError by remember { mutableStateOf(false) }
var showAddList by rememberSaveable { mutableStateOf(false) }
var showUpdates by rememberSaveable { mutableStateOf(false) }
var interval by remember { mutableStateOf(prefs.updateInterval) }
var wifiOnly by remember { mutableStateOf(prefs.updateWifiOnly) }
val term = search.trim()
fun matches(vararg texts: String) = term.isEmpty() || texts.any { it.contains(term, ignoreCase = true) }
val presetUrls = remember { Presets.map { it.url }.toSet() }
val ownLists = lists.filter { it.url !in presetUrls }
val shownDomains = if (term.isEmpty()) custom else custom.filter { it.contains(term, ignoreCase = true) }
fun addDomain() {
val input = domainInput
@@ -101,74 +130,111 @@ fun BlocklistScreen(modifier: Modifier = Modifier) {
}
}
fun addList() {
val url = urlInput.trim()
if (url.isNotEmpty() && Blocklist.download(context, url)) urlInput = ""
}
// Own domains are lazy rows, so hundreds of them are not all composed when the tab opens.
// Together they look like the card they used to be in: same color and shape, split per row.
val cardColor = CardDefaults.cardColors().containerColor
val cardShape = MaterialTheme.shapes.medium
val cardTop = cardShape.copy(bottomStart = ZeroCornerSize, bottomEnd = ZeroCornerSize)
val cardBottom = cardShape.copy(topStart = ZeroCornerSize, topEnd = ZeroCornerSize)
LazyColumn(
modifier = modifier.fillMaxSize(),
contentPadding = PaddingValues(16.dp),
modifier = modifier,
contentPadding = PaddingValues(start = side, end = side, bottom = bottomPadding),
) {
item(key = "summary") {
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
Card(Modifier.fillMaxWidth()) {
Row(Modifier.padding(16.dp), verticalAlignment = Alignment.CenterVertically) {
IconBadge(
R.drawable.ic_tab_block,
tint = if (enabled) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.outline,
size = 52.dp,
)
Spacer(Modifier.width(16.dp))
Column(Modifier.weight(1f)) {
Text(stringResource(R.string.bl_title), style = MaterialTheme.typography.titleMedium)
Text(
formatCount(total.toLong()),
style = MaterialTheme.typography.headlineSmall,
fontWeight = FontWeight.SemiBold,
)
Text(
stringResource(R.string.bl_total_label),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Switch(checked = enabled, onCheckedChange = { Blocklist.setEnabled(context, it) })
}
}
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)
item(key = "header") {
PageHeader(
title = stringResource(R.string.blocklist_title),
onBack = onBack,
action = {
AppSwitch(checked = enabled, onCheckedChange = { Blocklist.setEnabled(context, it) })
},
)
}
SectionHeader(stringResource(R.string.bl_my), icon = R.drawable.ic_tab_block)
item(key = "search") {
SearchField(
value = search,
onValueChange = { search = it },
placeholder = stringResource(R.string.bl_search),
modifier = Modifier.padding(top = 4.dp),
)
}
item(key = "updates") {
UpdatesRow(
interval = interval,
wifiOnly = wifiOnly,
onClick = { showUpdates = true },
modifier = Modifier.padding(top = 12.dp),
)
}
item(key = "error") {
AnimatedVisibility(visible = error != null, enter = Motion.expandIn, exit = Motion.collapseOut) {
Box(Modifier.padding(top = 12.dp)) {
HintCard(
stringResource(R.string.bl_download_failed, shownError),
icon = R.drawable.ic_alert,
tint = Palette.Blocked,
)
}
}
}
item(key = "custom") {
Column(
Modifier
.padding(top = 12.dp)
.fillMaxWidth()
.background(cardColor, if (custom.isEmpty()) cardShape else cardTop)
.padding(top = 8.dp, bottom = if (custom.isEmpty()) 8.dp else 0.dp)
items(Presets.filter { matches(it.name) }, key = { "preset:${it.url}" }) { preset ->
val list = lists.firstOrNull { it.url == preset.url }
val downloading = busy == preset.url || (busy == Blocklist.ALL_LISTS && list?.enabled == true)
BlocklistCard(
title = preset.name,
description = stringResource(preset.description),
source = "hagezi",
sourceUrl = HAGEZI_HOME,
info = listInfo(list, downloading),
checked = list?.enabled == true || busy == preset.url,
// A list that is not downloaded yet waits for a running download to finish
switchEnabled = list != null || busy == null,
progress = downloading,
onCheckedChange = { on ->
if (list == null) {
if (on) Blocklist.download(context, preset.url)
} else {
scope.editBlocklist(context) { Blocklist.setListEnabled(context, preset.url, on) }
}
},
modifier = Modifier
.animateItem()
.padding(top = 12.dp),
)
}
items(ownLists.filter { matches(it.url) }, key = { "list:${it.url}" }) { list ->
val uri = remember(list.url) { Uri.parse(list.url) }
val downloading = busy == list.url || (busy == Blocklist.ALL_LISTS && list.enabled)
BlocklistCard(
title = uri.lastPathSegment ?: uri.host ?: list.url,
description = stringResource(R.string.list_added_by_you),
source = uri.host ?: "",
sourceUrl = null,
info = listInfo(list, downloading),
checked = list.enabled,
switchEnabled = true,
progress = downloading,
onCheckedChange = { on -> scope.editBlocklist(context) { Blocklist.setListEnabled(context, list.url, on) } },
onDelete = if (busy == null) {
{ scope.editBlocklist(context) { Blocklist.removeList(context, list.url) } }
} else {
null
},
modifier = Modifier
.animateItem()
.padding(top = 12.dp),
)
}
item(key = "domains") {
MyDomainsHeader(
count = custom.size,
open = domainsOpen,
onToggle = { domainsOpen = !domainsOpen },
shape = if (domainsOpen) TopShape else CardShape,
modifier = Modifier.padding(top = 12.dp),
) {
// Input to add a domain; the accent button matches the rest of the app
Row(
modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp),
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 12.dp),
verticalAlignment = Alignment.CenterVertically,
) {
OutlinedTextField(
@@ -177,222 +243,428 @@ fun BlocklistScreen(modifier: Modifier = Modifier) {
placeholder = { Text(stringResource(R.string.bl_domain_hint), maxLines = 1) },
singleLine = true,
isError = domainError,
shape = RoundedCornerShape(14.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = { addDomain() }),
modifier = Modifier.weight(1f),
)
Spacer(Modifier.width(8.dp))
FilledTonalButton(onClick = ::addDomain, enabled = domainInput.isNotBlank()) {
Icon(painterResource(R.drawable.ic_add_domain), contentDescription = null, modifier = Modifier.size(18.dp))
Button(
onClick = ::addDomain,
enabled = domainInput.isNotBlank(),
shape = RoundedCornerShape(14.dp),
contentPadding = PaddingValues(horizontal = 18.dp),
modifier = Modifier.height(56.dp),
) {
Icon(painterResource(R.drawable.ic_add), contentDescription = null, modifier = Modifier.size(18.dp))
Spacer(Modifier.width(6.dp))
Text(stringResource(R.string.add))
Text(stringResource(R.string.add), fontWeight = FontWeight.Bold)
}
}
AnimatedVisibility(visible = domainError, enter = Motion.expandIn, exit = Motion.collapseOut) {
Text(
stringResource(R.string.bl_invalid),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.error,
modifier = Modifier.padding(horizontal = 16.dp),
color = Palette.Blocked,
fontSize = 12.sp,
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 8.dp),
)
}
if (custom.isEmpty()) {
Text(
stringResource(R.string.bl_empty_custom),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
color = Palette.Fg3,
fontSize = 13.sp,
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 8.dp),
)
}
}
}
itemsIndexed(custom, key = { _, domain -> "domain:$domain" }, contentType = { _, _ -> "domain" }) { index, domain ->
val last = index == custom.lastIndex
Column(
// Own domains are lazy rows, so hundreds of them are not all composed at once.
// Together with the header above they look like one card.
if (domainsOpen) {
itemsIndexed(shownDomains, key = { _, domain -> "domain:$domain" }, contentType = { _, _ -> "domain" }) { index, domain ->
val last = index == shownDomains.lastIndex
DomainRow(
domain = domain,
shape = if (last) BottomShape else RectangleShape,
onDelete = { scope.editBlocklist(context) { Blocklist.removeCustom(context, domain) } },
modifier = Modifier.animateItem(),
)
}
if (shownDomains.isEmpty()) {
item(key = "domains-end") {
Box(
Modifier
.animateItem()
.fillMaxWidth()
.background(cardColor, if (last) cardBottom else RectangleShape)
.padding(bottom = if (last) 8.dp else 0.dp)
.height(8.dp)
.clip(BottomShape)
.background(Palette.Card)
)
}
}
}
item(key = "add") {
Box(
Modifier
.fillMaxWidth()
.padding(top = 24.dp),
contentAlignment = Alignment.Center,
) {
InsetDivider(16)
Button(
onClick = { showAddList = true },
enabled = busy == null,
shape = RoundedCornerShape(24.dp),
contentPadding = PaddingValues(start = 16.dp, end = 22.dp),
modifier = Modifier.height(48.dp),
) {
Icon(painterResource(R.drawable.ic_add), contentDescription = null, modifier = Modifier.size(20.dp))
Spacer(Modifier.width(8.dp))
Text(stringResource(R.string.bl_add_list), fontWeight = FontWeight.ExtraBold)
}
}
}
}
if (showAddList) {
AddListDialog(
busy = busy != null,
onAdd = { url -> Blocklist.download(context, url) },
onDismiss = { showAddList = false },
)
}
if (showUpdates) {
UpdatesDialog(
interval = interval,
wifiOnly = wifiOnly,
canUpdateNow = busy == null && lists.any { it.enabled },
onInterval = {
interval = it
prefs.updateInterval = it
AutoUpdate.apply(context)
},
onWifiOnly = {
wifiOnly = it
prefs.updateWifiOnly = it
AutoUpdate.apply(context)
},
onUpdateNow = {
Blocklist.updateAll(context)
showUpdates = false
},
onDismiss = { showUpdates = false },
)
}
}
@Composable
private fun listInfo(list: RemoteList?, downloading: Boolean): String = when {
downloading -> stringResource(R.string.bl_updating)
list == null -> stringResource(R.string.list_not_downloaded)
else -> stringResource(
R.string.bl_list_info,
formatCount(list.count.toLong()),
DateUtils.getRelativeTimeSpanString(list.updated, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS).toString(),
)
}
@Composable
private fun UpdatesRow(interval: UpdateInterval, wifiOnly: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier) {
val shape = RoundedCornerShape(16.dp)
val label = stringResource(intervalLabel(interval))
val wifi = stringResource(R.string.auto_wifi)
val summary = if (interval != UpdateInterval.OFF && wifiOnly) "$label · $wifi" else label
Row(
modifier = modifier
.fillMaxWidth()
.clip(shape)
.border(1.dp, Palette.Line, shape)
.clickable(onClick = onClick)
.padding(horizontal = 14.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(painterResource(R.drawable.ic_update), contentDescription = null, tint = Palette.Accent, modifier = Modifier.size(20.dp))
Spacer(Modifier.width(12.dp))
Column(Modifier.weight(1f)) {
Text(stringResource(R.string.auto_update), color = Palette.Fg, fontSize = 14.sp, fontWeight = FontWeight.Bold)
Text(summary, color = Palette.Fg2, fontSize = 12.sp)
}
Chevron()
}
}
@StringRes
private fun intervalLabel(interval: UpdateInterval): Int = when (interval) {
UpdateInterval.OFF -> R.string.auto_off
UpdateInterval.DAILY -> R.string.auto_daily
UpdateInterval.WEEKLY -> R.string.auto_weekly
}
@Composable
private fun BlocklistCard(
title: String,
description: String,
source: String,
sourceUrl: String?,
info: String,
checked: Boolean,
switchEnabled: Boolean,
progress: Boolean,
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
onDelete: (() -> Unit)? = null,
) {
val context = LocalContext.current
Column(
modifier = modifier
.fillMaxWidth()
.appCard()
.padding(start = 16.dp, end = 10.dp, top = 6.dp, bottom = 14.dp),
) {
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.heightIn(min = 48.dp)) {
Text(
title,
color = Palette.Fg,
fontSize = 15.sp,
fontWeight = FontWeight.ExtraBold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f),
)
if (onDelete != null) DeleteButton(onDelete)
AppSwitch(checked = checked, onCheckedChange = onCheckedChange, enabled = switchEnabled)
}
Text(
description,
color = Palette.Fg2,
fontSize = 12.sp,
lineHeight = 17.sp,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.padding(end = 6.dp),
)
Row(
modifier = Modifier.padding(top = 6.dp, end = 6.dp),
verticalAlignment = Alignment.CenterVertically,
) {
if (source.isNotEmpty()) {
Text(
source,
color = Palette.Accent,
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
modifier = if (sourceUrl != null) Modifier.clickable { openUrl(context, sourceUrl) } else Modifier,
)
Text(" · ", color = Palette.Fg3, fontSize = 12.sp)
}
Text(info, color = Palette.Fg3, fontSize = 12.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
AnimatedVisibility(visible = progress, enter = Motion.expandIn, exit = Motion.collapseOut) {
LinearProgressIndicator(
modifier = Modifier
.fillMaxWidth()
.padding(top = 10.dp, end = 6.dp),
color = Palette.Accent,
trackColor = Palette.Track,
)
}
}
}
@Composable
private fun MyDomainsHeader(
count: Int,
open: Boolean,
onToggle: () -> Unit,
shape: Shape,
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
val chevron by animateFloatAsState(if (open) 180f else 0f, Motion.rotation, label = "chevron")
Column(
modifier = modifier
.fillMaxWidth()
.clip(shape)
.background(Palette.Card),
) {
Row(
modifier = Modifier
.fillMaxWidth()
.clickable(onClick = onToggle)
.padding(start = 16.dp, end = 14.dp, top = 14.dp, bottom = 14.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Text(stringResource(R.string.bl_my), color = Palette.Fg, fontSize = 15.sp, fontWeight = FontWeight.ExtraBold)
Text(
stringResource(R.string.my_domains_desc),
color = Palette.Fg2,
fontSize = 12.sp,
lineHeight = 17.sp,
)
}
Spacer(Modifier.width(10.dp))
Text(
formatCount(count.toLong()),
color = Palette.Accent,
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier
.clip(RoundedCornerShape(10.dp))
.background(Palette.AccentSoft)
.padding(horizontal = 8.dp, vertical = 3.dp),
)
Spacer(Modifier.width(6.dp))
Icon(
painterResource(R.drawable.ic_expand),
contentDescription = null,
tint = Palette.Fg3,
modifier = Modifier
.size(20.dp)
.graphicsLayer { rotationZ = chevron },
)
}
AnimatedVisibility(visible = open, enter = Motion.expandIn, exit = Motion.collapseOut) {
Column { content() }
}
}
}
@Composable
private fun DomainRow(domain: String, shape: Shape, onDelete: () -> Unit, modifier: Modifier = Modifier) {
Column(
modifier
.fillMaxWidth()
.clip(shape)
.background(Palette.Card)
) {
ListDivider()
Row(
modifier = Modifier.padding(start = 16.dp, end = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Text(domain, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis)
IconButton(onClick = { scope.editBlocklist(context) { Blocklist.removeCustom(context, domain) } }) {
Icon(painterResource(R.drawable.ic_delete), stringResource(R.string.delete), Modifier.size(20.dp))
}
}
}
}
item(key = "lists") {
Column(Modifier.padding(top = 12.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {
SectionHeader(
stringResource(R.string.bl_lists),
icon = R.drawable.ic_list,
action = {
TextButton(
onClick = { Blocklist.updateAll(context) },
enabled = lists.isNotEmpty() && busy == null,
) {
Icon(painterResource(R.drawable.ic_refresh), contentDescription = null, modifier = Modifier.size(18.dp))
Spacer(Modifier.width(6.dp))
Text(stringResource(if (busy == Blocklist.ALL_LISTS) R.string.bl_updating else R.string.bl_update_all))
}
},
)
Card(Modifier.fillMaxWidth()) {
Column(
Modifier
.animateContentSize(Motion.size)
.padding(vertical = 8.dp)
) {
lists.forEachIndexed { index, list ->
if (index > 0) InsetDivider(68)
ListRow(
list = list,
updating = busy == list.url || busy == Blocklist.ALL_LISTS,
actionsEnabled = busy == null,
onRefresh = { Blocklist.download(context, list.url) },
onDelete = { scope.editBlocklist(context) { Blocklist.removeList(context, list.url) } },
)
}
if (lists.isNotEmpty()) InsetDivider(16)
Row(
modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
OutlinedTextField(
value = urlInput,
onValueChange = { urlInput = it },
placeholder = { Text(stringResource(R.string.bl_list_url), maxLines = 1) },
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = { if (busy == null) addList() }),
modifier = Modifier.weight(1f),
)
Spacer(Modifier.width(8.dp))
FilledTonalButton(
onClick = ::addList,
enabled = urlInput.isNotBlank() && busy == null,
) {
Icon(painterResource(R.drawable.ic_add), contentDescription = null, modifier = Modifier.size(18.dp))
Spacer(Modifier.width(6.dp))
Text(stringResource(R.string.add))
}
}
// A new list being added has no row yet, so its progress shows under the input
val addingNew = busy != null && busy != Blocklist.ALL_LISTS && lists.none { it.url == busy }
AnimatedVisibility(visible = addingNew, enter = Motion.expandIn, exit = Motion.collapseOut) {
LinearProgressIndicator(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 4.dp),
)
}
}
}
val missingPresets = Presets.filter { (_, url) -> lists.none { it.url == url } }
AnimatedVisibility(visible = missingPresets.isNotEmpty(), enter = Motion.expandIn, exit = Motion.collapseOut) {
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
SectionHeader(stringResource(R.string.bl_presets))
Row(
modifier = Modifier.horizontalScroll(rememberScrollState()),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
missingPresets.forEach { (name, url) ->
AssistChip(
onClick = { Blocklist.download(context, url) },
enabled = busy == null,
leadingIcon = {
Icon(painterResource(R.drawable.ic_add), contentDescription = null, modifier = Modifier.size(18.dp))
},
label = { Text(if (busy == url) stringResource(R.string.bl_updating) else name) },
)
}
}
}
}
AnimatedVisibility(visible = error != null, enter = Motion.expandIn, exit = Motion.collapseOut) {
HintCard(
stringResource(R.string.bl_download_failed, lastError[0]),
icon = R.drawable.ic_alert,
tint = MaterialTheme.colorScheme.error,
)
}
}
}
}
}
@Composable
private fun InsetDivider(start: Int) {
HorizontalDivider(
modifier = Modifier.padding(start = start.dp),
color = MaterialTheme.colorScheme.outlineVariant.copy(alpha = 0.5f),
)
}
@Composable
private fun ListRow(
list: RemoteList,
updating: Boolean,
actionsEnabled: Boolean,
onRefresh: () -> Unit,
onDelete: () -> Unit,
) {
val uri = remember(list.url) { Uri.parse(list.url) }
val title = uri.lastPathSegment ?: list.url
val updated = remember(list.updated) {
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(Date(list.updated))
}
Column {
Row(
modifier = Modifier.padding(start = 16.dp, end = 4.dp, top = 8.dp, bottom = 8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
IconBadge(R.drawable.ic_list, size = 40.dp)
Spacer(Modifier.width(12.dp))
Column(Modifier.weight(1f)) {
Text(title, style = MaterialTheme.typography.titleSmall, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(
uri.host ?: "",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
domain,
color = Palette.Fg,
fontSize = 14.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f),
)
Text(
if (updating) stringResource(R.string.bl_updating)
else stringResource(R.string.bl_list_info, formatCount(list.count.toLong()), updated),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
DeleteButton(onDelete)
}
}
}
@Composable
private fun DeleteButton(onClick: () -> Unit) {
IconButton(onClick = onClick) {
Icon(
painterResource(R.drawable.ic_delete),
contentDescription = stringResource(R.string.delete),
tint = Palette.Fg3,
modifier = Modifier.size(20.dp),
)
}
IconButton(onClick = onRefresh, enabled = actionsEnabled) {
Icon(painterResource(R.drawable.ic_refresh), stringResource(R.string.bl_update_all), Modifier.size(20.dp))
}
IconButton(onClick = onDelete, enabled = actionsEnabled) {
Icon(painterResource(R.drawable.ic_delete), stringResource(R.string.delete), Modifier.size(20.dp))
@Composable
private fun AddListDialog(busy: Boolean, onAdd: (String) -> Boolean, onDismiss: () -> Unit) {
var url by rememberSaveable { mutableStateOf("") }
fun submit() {
if (url.isNotBlank() && onAdd(url.trim())) onDismiss()
}
AlertDialog(
onDismissRequest = onDismiss,
title = { Text(stringResource(R.string.bl_add_list)) },
text = {
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text(stringResource(R.string.bl_note), color = Palette.Fg2, fontSize = 13.sp)
OutlinedTextField(
value = url,
onValueChange = { url = it },
label = { Text(stringResource(R.string.bl_list_url)) },
placeholder = { Text("https://", maxLines = 1) },
singleLine = true,
shape = RoundedCornerShape(14.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = { submit() }),
modifier = Modifier.fillMaxWidth(),
)
}
AnimatedVisibility(visible = updating, enter = Motion.expandIn, exit = Motion.collapseOut) {
LinearProgressIndicator(
},
confirmButton = {
Button(onClick = ::submit, enabled = url.isNotBlank() && !busy, shape = RoundedCornerShape(14.dp)) {
Text(stringResource(R.string.add), fontWeight = FontWeight.Bold)
}
},
dismissButton = {
TextButton(onClick = onDismiss) { Text(stringResource(R.string.cancel)) }
},
containerColor = Palette.CardHigh,
)
}
@Composable
private fun UpdatesDialog(
interval: UpdateInterval,
wifiOnly: Boolean,
canUpdateNow: Boolean,
onInterval: (UpdateInterval) -> Unit,
onWifiOnly: (Boolean) -> Unit,
onUpdateNow: () -> Unit,
onDismiss: () -> Unit,
) {
AlertDialog(
onDismissRequest = onDismiss,
title = { Text(stringResource(R.string.auto_update)) },
text = {
Column {
UpdateInterval.entries.forEach { option ->
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 68.dp, end = 16.dp, bottom = 8.dp),
.clip(RoundedCornerShape(12.dp))
.selectable(selected = option == interval, onClick = { onInterval(option) }, role = Role.RadioButton)
.padding(vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
RadioButton(selected = option == interval, onClick = null)
Spacer(Modifier.width(12.dp))
Text(stringResource(intervalLabel(option)), color = Palette.Fg, fontSize = 15.sp)
}
}
HorizontalDivider(modifier = Modifier.padding(vertical = 8.dp), color = Palette.Line)
val wifiEnabled = interval != UpdateInterval.OFF
Row(
modifier = Modifier
.fillMaxWidth()
.toggleable(value = wifiOnly, enabled = wifiEnabled, role = Role.Switch, onValueChange = onWifiOnly)
.graphicsLayer { alpha = if (wifiEnabled) 1f else 0.45f }
.padding(vertical = 6.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Text(stringResource(R.string.auto_wifi), color = Palette.Fg, fontSize = 15.sp)
Text(stringResource(R.string.auto_wifi_desc), color = Palette.Fg3, fontSize = 12.sp)
}
Spacer(Modifier.width(12.dp))
AppSwitch(checked = wifiOnly, onCheckedChange = null, enabled = wifiEnabled)
}
}
},
confirmButton = {
TextButton(onClick = onDismiss) { Text(stringResource(R.string.done)) }
},
dismissButton = {
TextButton(onClick = onUpdateNow, enabled = canUpdateNow) { Text(stringResource(R.string.auto_update_now)) }
},
containerColor = Palette.CardHigh,
)
}
}
}
// Blocklist edits write to storage, which can fail (a full disk, for one)
internal inline fun <T> tryEdit(action: () -> T): Result<T> =
@@ -410,5 +682,3 @@ internal fun showEditError(context: Context, error: Throwable) {
val reason = error.message ?: error.javaClass.simpleName
Toast.makeText(context, context.getString(R.string.test_fail, reason), Toast.LENGTH_LONG).show()
}
private const val HINT_BLOCKLIST = "blocklist"
@@ -0,0 +1,115 @@
package cc.skysparkle.sparkledns
import java.util.Locale
import java.util.TreeMap
// The position of each company is saved in StatsStore: add new ones at the end only
enum class Company(val label: String) {
GOOGLE("Google"),
APPLE("Apple"),
META("Meta"),
AMAZON("Amazon"),
MICROSOFT("Microsoft"),
BYTEDANCE("ByteDance"),
X("X"),
YANDEX("Yandex"),
SAMSUNG("Samsung"),
XIAOMI("Xiaomi"),
}
// Tells which big company a domain belongs to, for the Company dominance card.
// Matches the domain and every parent of it against a small built-in table.
object Companies {
private const val GOOGLE_PREFIX = "google."
// Second-level labels that belong to a country's suffix: example.co.uk, example.com.br
private val COUNTRY_SECOND_LEVELS = setOf("co", "com", "net", "org", "gov", "edu", "ac", "or", "ne", "go")
// Names that are not public sites: reverse lookups and local networks
private val PRIVATE_TLDS = setOf("arpa", "local", "lan", "home", "internal", "localhost")
// Hashes of the domains, sorted, with the company of each at the same index: this runs for
// every query, and parent domains are looked up by hash without copying the name
private val hashes: LongArray
private val owners: Array<Company>
init {
val table = TreeMap<Long, Company>()
fun add(company: Company, vararg domains: String) = domains.forEach { table[DomainHash.of(it)] = company }
add(
Company.GOOGLE,
"google.com", "googleapis.com", "gstatic.com", "googleusercontent.com", "googlevideo.com",
"youtube.com", "youtu.be", "ytimg.com", "ggpht.com", "gvt1.com", "gvt2.com", "1e100.net",
"android.com", "googlesyndication.com", "googleadservices.com", "doubleclick.net",
"google-analytics.com", "googletagmanager.com", "googletagservices.com", "app-measurement.com",
"firebaseio.com", "firebase.com", "crashlytics.com", "withgoogle.com", "googlemail.com",
"gmail.com", "blogspot.com", "admob.com", "goo.gl",
)
add(
Company.APPLE,
"apple.com", "icloud.com", "icloud-content.com", "mzstatic.com", "apple-dns.net", "aaplimg.com",
"cdn-apple.com", "itunes.com", "me.com", "apple.news", "apple-cloudkit.com", "appleid.com",
)
add(
Company.META,
"facebook.com", "facebook.net", "fbcdn.net", "fbsbx.com", "fb.com", "instagram.com",
"cdninstagram.com", "whatsapp.com", "whatsapp.net", "messenger.com", "meta.com", "oculus.com",
"threads.net", "graph.facebook.com",
)
add(
Company.AMAZON,
"amazon.com", "amazonaws.com", "media-amazon.com", "ssl-images-amazon.com", "cloudfront.net",
"amazon-adsystem.com", "a2z.com", "primevideo.com", "aiv-cdn.net", "twitch.tv", "ttvnw.net",
"amazon.de", "amazon.co.uk", "amazontrust.com",
)
add(
Company.MICROSOFT,
"microsoft.com", "live.com", "outlook.com", "office.com", "office.net", "office365.com", "msn.com",
"bing.com", "windows.com", "windows.net", "windowsupdate.com", "azure.com", "azureedge.net",
"skype.com", "xbox.com", "xboxlive.com", "linkedin.com", "licdn.com", "github.com",
"githubusercontent.com", "msftncsi.com", "msedge.net", "microsoftonline.com", "sharepoint.com",
)
add(
Company.BYTEDANCE,
"tiktok.com", "tiktokv.com", "tiktokcdn.com", "tiktokcdn-us.com", "byteoversea.com",
"ibytedtos.com", "bytedance.com", "capcut.com", "byteimg.com",
)
add(Company.X, "twitter.com", "x.com", "twimg.com", "t.co")
add(Company.YANDEX, "yandex.ru", "yandex.net", "yandex.com", "ya.ru", "yastatic.net", "yandex.by", "yandex.kz")
add(Company.SAMSUNG, "samsung.com", "samsungapps.com", "samsungcloud.com", "samsungqbe.com", "samsungosp.com")
add(Company.XIAOMI, "xiaomi.com", "xiaomi.net", "mi.com", "miui.com", "mi-img.com")
hashes = table.keys.toLongArray()
owners = table.values.toTypedArray()
}
fun of(name: String): Company? {
// Names from the tunnel are lowercase already; anything else is lowercased once
val domain = if (name.any { it.isUpperCase() }) name.lowercase() else name
val end = nameEnd(domain)
var start = 0
while (start < end) {
val index = hashes.binarySearch(DomainHash.of(domain, start, end))
if (index >= 0) return owners[index]
// Google's country sites: google.de, google.co.uk, google.com.br
if (end - start - GOOGLE_PREFIX.length in 1..6 && domain.startsWith(GOOGLE_PREFIX, start)) return Company.GOOGLE
val dot = domain.indexOf('.', start)
if (dot < 0 || dot >= end) return null
start = dot + 1
}
return null
}
// A readable name for a domain of no known company, taken from its main label:
// "cdn.example.co.uk" gives "Example". Null for IP addresses, local names and bare labels.
fun nameOf(name: String): String? {
val labels = name.lowercase(Locale.ROOT).split('.').filter { it.isNotEmpty() }
if (labels.size < 2) return null
val tld = labels.last()
if (tld in PRIVATE_TLDS || tld.all { it.isDigit() }) return null
var index = labels.size - 2
if (tld.length == 2 && labels.size >= 3 && labels[index] in COUNTRY_SECOND_LEVELS) index--
return labels[index].replaceFirstChar { it.titlecase(Locale.ROOT) }
}
}
@@ -5,6 +5,8 @@ import android.content.Context
import android.os.Build
import android.os.Process
import android.os.StrictMode
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import java.io.File
import java.io.PrintWriter
import java.io.StringWriter
@@ -17,18 +19,23 @@ class SparkleApp : Application() {
Thread({
// Reads what the first screen needs before it asks, so its first frame does not wait on storage
Prefs(this).providerId
CrashLog.preload(this)
CrashLog.load(this)
StatsStore.init(this)
AutoUpdate.apply(this)
// Lists can hold millions of entries; loading them should not take CPU from the first frames
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND)
runCatching { Blocklist.reload(this) }
runCatching { Blocklist.ensureLoaded(this) }
}, "startup-load").start()
}
// The VPN keeps the process running long after the screens are gone; decoded app icons
// (up to 10 MB) can be rendered again the next time the Apps tab opens
// (up to 10 MB) and the logo can be rendered again the next time they are shown
override fun onTrimMemory(level: Int) {
super.onTrimMemory(level)
if (level >= TRIM_MEMORY_UI_HIDDEN) clearAppIconCache()
if (level >= TRIM_MEMORY_UI_HIDDEN) {
clearAppIconCache()
AppLogo.clear()
}
}
// Debug builds only: logs disk and network access on the main thread, leaked closeables and the like
@@ -42,13 +49,18 @@ class SparkleApp : Application() {
object CrashLog {
private const val FILE_NAME = "last_crash.txt"
// Null when there is no report, and until the startup thread has read it
private val _report = MutableStateFlow<String?>(null)
val report: StateFlow<String?> = _report
fun install(context: Context) {
val file = File(context.filesDir, FILE_NAME)
val appContext = context.applicationContext
val previous = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler { thread, error ->
runCatching {
val trace = StringWriter().also { error.printStackTrace(PrintWriter(it)) }.toString()
file.writeText(
// Looked up only now: install() runs on the main thread at start-up
File(appContext.filesDir, FILE_NAME).writeText(
"Thread: ${thread.name}\n" +
"Android ${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT}), " +
"${Build.MANUFACTURER} ${Build.MODEL}\n\n$trace"
@@ -58,24 +70,14 @@ object CrashLog {
}
}
@Volatile
private var preloaded = false
@Volatile
private var report: String? = null
fun preload(context: Context) {
report = load(context)
preloaded = true
// Runs on the startup thread, so the main thread never reads the file
fun load(context: Context) {
_report.value = runCatching { File(context.filesDir, FILE_NAME).takeIf { it.exists() }?.readText() }.getOrNull()
}
fun read(context: Context): String? = if (preloaded) report else load(context)
fun clear(context: Context) {
report = null
File(context.filesDir, FILE_NAME).delete()
_report.value = null
val appContext = context.applicationContext
Thread({ File(appContext.filesDir, FILE_NAME).delete() }, "crash-clear").start()
}
private fun load(context: Context): String? =
runCatching { File(context.filesDir, FILE_NAME).takeIf { it.exists() }?.readText() }.getOrNull()
}
@@ -10,7 +10,7 @@ class DnsCache(
private class Entry(
val response: ByteArray,
val ttlOffsets: IntArray,
// Offset and value of each TTL field, one pair after another
val ttls: IntArray,
val storedAt: Long,
val expiresAt: Long,
@@ -35,7 +35,12 @@ class DnsCache(
out[0] = query[0]
out[1] = query[1]
val elapsed = ((now - entry.storedAt) / 1000).toInt()
entry.ttlOffsets.forEachIndexed { i, off -> put32(out, off, maxOf(entry.ttls[i] - elapsed, 0)) }
val ttls = entry.ttls
var i = 0
while (i < ttls.size) {
put32(out, ttls[i], maxOf(ttls[i + 1] - elapsed, 0))
i += 2
}
return out
}
@@ -45,26 +50,32 @@ class DnsCache(
val rcode = response[3].toInt() and 0x0F
if (rcode != 0 && rcode != 3) return // only NOERROR and NXDOMAIN
val records = parseTtls(response) ?: return
val minTtl = if (records.first.isEmpty()) NO_RECORDS_TTL else records.second.min()
val ttls = parseTtls(response) ?: return
var minTtl = if (ttls.isEmpty()) NO_RECORDS_TTL else Int.MAX_VALUE
var i = 1
while (i < ttls.size) {
minTtl = minOf(minTtl, ttls[i])
i += 2
}
val ttl = minOf(minTtl, MAX_TTL)
if (ttl <= 0) return
val now = clock()
val entry = Entry(response.copyOf(), records.first, records.second, now, now + ttl * 1000L)
val entry = Entry(response.copyOf(), ttls, now, now + ttl * 1000L)
synchronized(map) { map[key] = entry }
}
// Offsets and values of every TTL field except the EDNS OPT pseudo-record
private fun parseTtls(msg: ByteArray): Pair<IntArray, IntArray>? {
// Offset and value of every TTL field except the EDNS OPT pseudo-record, as pairs in one array
private fun parseTtls(msg: ByteArray): IntArray? {
var pos = 12
repeat(u16(msg, 4)) {
pos = skipName(msg, pos) ?: return null
pos += 4
}
val total = u16(msg, 6) + u16(msg, 8) + u16(msg, 10)
val offsets = ArrayList<Int>(total)
val values = ArrayList<Int>(total)
// The counts come from the server; the array grows only if a message really has that many
var ttls = IntArray(2 * minOf(total, 16))
var n = 0
repeat(total) {
pos = skipName(msg, pos) ?: return null
if (pos + 10 > msg.size) return null
@@ -72,13 +83,14 @@ class DnsCache(
val ttlOffset = pos + 4
val rdLength = u16(msg, pos + 8)
if (type != TYPE_OPT) {
offsets += ttlOffset
values += minOf(u32(msg, ttlOffset), Int.MAX_VALUE.toLong()).toInt()
if (n == ttls.size) ttls = ttls.copyOf(n * 2)
ttls[n++] = ttlOffset
ttls[n++] = minOf(u32(msg, ttlOffset), Int.MAX_VALUE.toLong()).toInt()
}
pos += 10 + rdLength
if (pos > msg.size) return null
}
return offsets.toIntArray() to values.toIntArray()
return if (n == ttls.size) ttls else ttls.copyOf(n)
}
private fun keyOf(query: ByteArray): String? {
@@ -59,6 +59,15 @@ class DnsTileService : TileService() {
return
}
}
// Turning protection off needs an unlocked phone, like other security toggles
if (running && isLocked) {
unlockAndRun { toggle(running) }
return
}
toggle(running)
}
private fun toggle(running: Boolean) {
val action = if (running) DohVpnService.ACTION_STOP else DohVpnService.ACTION_START
try {
startService(Intent(this, DohVpnService::class.java).setAction(action))
@@ -5,6 +5,7 @@ import android.net.ConnectivityManager
import android.net.Network
import android.net.http.HttpEngine
import android.net.http.HttpException
import android.net.http.NetworkException
import android.net.http.UploadDataProvider
import android.net.http.UploadDataSink
import android.net.http.UrlRequest
@@ -74,7 +75,10 @@ class DohClient(context: Context, provider: DohProvider) {
private fun createTransport(context: Context, provider: DohProvider): Transport {
if (provider.http3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
try {
return Http3Transport(context, provider)
val http3 = Http3Transport(context, provider)
// HttpEngine resolves the host with system DNS and cannot use fixed addresses
return if (provider.bootstrap.isEmpty()) http3
else BootstrapFallbackTransport(http3) { OkHttpTransport(context, provider) }
} catch (e: Throwable) {
Log.w(TAG, "HttpEngine unavailable, falling back to HTTP/2", e)
}
@@ -89,6 +93,38 @@ private interface Transport {
fun shutdown()
}
private class UnresolvedHostException(cause: Throwable) : IOException("Host not resolved", cause)
// HTTP/3 first; once the network fails to resolve the server's name, the rest of the session
// goes over OkHttp, which connects to the bootstrap addresses instead
private class BootstrapFallbackTransport(
private val http3: Transport,
createFallback: () -> Transport,
) : Transport {
private val fallback = lazy(createFallback)
@Volatile private var useFallback = false
override val lastProtocol: String?
get() = if (useFallback) fallback.value.lastProtocol else http3.lastProtocol
override fun query(message: ByteArray): ByteArray {
if (!useFallback) {
try {
return http3.query(message)
} catch (e: UnresolvedHostException) {
Log.w(TAG, "Server name not resolved over HTTP/3, using bootstrap addresses")
useFallback = true
}
}
return fallback.value.query(message)
}
override fun shutdown() {
http3.shutdown()
if (fallback.isInitialized()) fallback.value.shutdown()
}
}
private class OkHttpTransport(context: Context, private val provider: DohProvider) : Transport {
private val url by lazy { provider.url.toHttpUrl() }
@@ -140,7 +176,11 @@ private class OkHttpTransport(context: Context, private val provider: DohProvide
if (!response.isSuccessful) throw IOException("HTTP ${response.code}")
val body = response.body ?: throw IOException("Empty response")
if (body.contentLength() > MAX_DNS_SIZE) throw IOException("Response too large")
return body.bytes()
// Without Content-Length the size is only known while reading: stop one byte past the limit
val source = body.source()
source.request(MAX_DNS_SIZE + 1L)
if (source.buffer.size > MAX_DNS_SIZE) throw IOException("Response too large")
return source.buffer.readByteArray()
}
}
@@ -220,7 +260,11 @@ private class Http3Transport(context: Context, private val provider: DohProvider
}
override fun onFailed(request: UrlRequest, info: UrlResponseInfo?, error: HttpException) {
result.completeExceptionally(IOException(error.message, error))
val unresolved = error is NetworkException &&
error.errorCode == NetworkException.ERROR_HOSTNAME_NOT_RESOLVED
result.completeExceptionally(
if (unresolved) UnresolvedHostException(error) else IOException(error.message, error)
)
}
override fun onCanceled(request: UrlRequest, info: UrlResponseInfo?) {
@@ -20,6 +20,7 @@ import android.system.StructPollfd
import android.util.Log
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.IOException
@@ -34,7 +35,11 @@ private const val WORKERS = 16
private const val TAG = "SparkleDNS"
private const val CHANNEL_ID = "vpn_status"
private const val NOTIFICATION_ID = 1
// Separate channel with normal importance: losing protection must not go unnoticed
private const val ALERT_CHANNEL_ID = "vpn_alerts"
private const val ALERT_NOTIFICATION_ID = 2
private const val MAX_BAD_PACKETS = 100
private const val READER_JOIN_MS = 1000L
// Android's resolver retries after 5 s, so an older lookup no longer has anyone waiting for it
private const val QUEUE_TIMEOUT_MS = 5000L
@@ -87,6 +92,7 @@ class DohVpnService : VpnService() {
override fun onDestroy() {
stopSession()
StatsStore.flush()
super.onDestroy()
}
@@ -95,6 +101,19 @@ class DohVpnService : VpnService() {
val provider = prefs.resolve()
val excluded = prefs.excludedApps
// The app checks the address before connecting, but always-on VPN and a restart by the
// system start the service directly. A tunnel with a broken URL would fail every lookup.
if (provider.url.toHttpUrlOrNull()?.isHttps != true) {
Log.e(TAG, "Server address is not a valid HTTPS URL, not starting")
stopSession()
showAlert(
R.string.alert_bad_url_title,
if (provider.id == Providers.DEFAULT_ID) R.string.alert_no_key_text else R.string.alert_bad_url_text,
)
stopSelf()
return
}
val builder = Builder()
.setSession(provider.displayName(this))
.addAddress(TUN_ADDRESS, 32)
@@ -123,13 +142,28 @@ class DohVpnService : VpnService() {
stopSelf()
return
}
session = Session(tun, DohClient(this, provider), ::onSessionFailed).also { it.start() }
val next = try {
Session(tun, DohClient(this, provider), ::onSessionFailed)
} catch (e: IOException) {
// A tunnel nobody reads would swallow every DNS lookup on the device
runCatching { tun.close() }
throw e
}
session = next.also { it.start() }
runCatching { previous?.stop() }
_active.value = provider
_activeExcluded.value = excluded
showNotification(provider)
DnsTileService.refresh(this)
getSystemService(NotificationManager::class.java)?.cancel(ALERT_NOTIFICATION_ID)
// With "Block connections without VPN" the app, excluded from its own tunnel, cannot reach
// the DoH server, so every lookup would fail
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && isLockdownEnabled) {
Log.w(TAG, "Lockdown mode is on, the DoH server is not reachable")
showAlert(R.string.alert_lockdown_title, R.string.alert_lockdown_text)
}
}
private fun stopSession() {
@@ -149,10 +183,34 @@ class DohVpnService : VpnService() {
if (session !== failed) return@post
Log.e(TAG, "Tunnel stopped working, disconnecting")
stopSession()
// DNS goes unencrypted from here on; the user has to know
showAlert(R.string.alert_stopped_title, R.string.alert_stopped_text)
stopSelf()
}
}
private fun showAlert(titleRes: Int, textRes: Int) {
val manager = getSystemService(NotificationManager::class.java) ?: return
manager.createNotificationChannel(
NotificationChannel(ALERT_CHANNEL_ID, getString(R.string.alert_channel), NotificationManager.IMPORTANCE_DEFAULT)
)
val openApp = PendingIntent.getActivity(
this, 2,
Intent(this, MainActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
PendingIntent.FLAG_IMMUTABLE,
)
val text = getString(textRes)
val notification = Notification.Builder(this, ALERT_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(getString(titleRes))
.setContentText(text)
.setStyle(Notification.BigTextStyle().bigText(text))
.setContentIntent(openApp)
.setAutoCancel(true)
.build()
runCatching { manager.notify(ALERT_NOTIFICATION_ID, notification) }
}
private fun showNotification(provider: DohProvider) {
val manager = getSystemService(NotificationManager::class.java) ?: return
manager.createNotificationChannel(
@@ -188,7 +246,7 @@ class DohVpnService : VpnService() {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED)
} else {
startForeground(NOTIFICATION_ID, notification)
}
@@ -209,6 +267,10 @@ private class Session(
private val pool = Executors.newFixedThreadPool(WORKERS)
private val cache = DnsCache()
private val output = FileOutputStream(tun.fileDescriptor)
// stop() closes the write end, which wakes the reader at once. Otherwise the reader would have
// to wake up on a timer to notice that the session ended, also while the device sleeps.
private val wakeup = ParcelFileDescriptor.createPipe()
private val reader = Thread(::readLoop, "tun-reader")
fun start() = reader.start()
@@ -216,6 +278,10 @@ private class Session(
fun stop() {
if (!alive.getAndSet(false)) return
pool.shutdownNow()
runCatching { wakeup[1].close() }
// The pipe wakes the reader at once; let it leave before its descriptor is closed and
// possibly reused by something else
if (Thread.currentThread() !== reader) runCatching { reader.join(READER_JOIN_MS) }
runCatching { tun.close() }
closer.execute {
try {
@@ -229,16 +295,28 @@ private class Session(
private fun readLoop() {
val input = FileInputStream(tun.fileDescriptor)
val buf = ByteArray(MTU)
val pollFd = StructPollfd().apply {
val tunFd = StructPollfd().apply {
fd = tun.fileDescriptor
events = OsConstants.POLLIN.toShort()
}
val wakeupFd = StructPollfd().apply {
fd = wakeup[0].fileDescriptor
events = OsConstants.POLLIN.toShort()
}
val fds = arrayOf(tunFd, wakeupFd)
var badPackets = 0
try {
while (alive.get()) {
val n = try {
if (Os.poll(arrayOf(pollFd), 500) <= 0) continue
// Sleeps until a packet arrives or stop() closes the pipe
if (Os.poll(fds, -1) <= 0) continue
if (wakeupFd.revents.toInt() != 0) {
// Only stop() touches the pipe, so this ends the loop
readerFailed(null)
return
}
input.read(buf)
} catch (e: ErrnoException) {
if (e.errno == OsConstants.EINTR) continue
@@ -267,6 +345,9 @@ private class Session(
}
}
}
} finally {
runCatching { wakeup[0].close() }
}
}
// stop() closes the tunnel, which also ends the loop; only an unexpected end is a failure
@@ -0,0 +1,758 @@
package cc.skysparkle.sparkledns
import android.Manifest
import android.app.Activity
import android.content.ClipData
import android.content.ClipboardManager
import android.content.pm.PackageManager
import android.net.VpnService
import android.os.Build
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
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.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
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
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
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
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.drawWithCache
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.PathEffect
import androidx.compose.ui.graphics.StrokeCap
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
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.drawText
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.rememberTextMeasurer
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
import java.util.Locale
import java.util.TimeZone
import kotlin.math.ceil
import kotlin.math.roundToInt
private const val HOUR_MS = 3_600_000L
// One bar of the chart: an hour, or a day in the 7-day view
private data class Bar(val total: Long, val blocked: Long)
// Bars with the labels under them: the first hour of the day view, or every day of the week.
// A refresh that brings equal data leaves the chart alone.
private data class Chart(val period: StatsPeriod, val bars: List<Bar>, val labels: List<String>)
private val ChartLabelStyle = TextStyle(color = Palette.Fg3, fontSize = 10.sp)
// Where the three grip lines on the knob of the power switch sit, as fractions of its width
private val KnobLines = floatArrayOf(0.29f, 0.5f, 0.71f)
@Composable
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 period by rememberSaveable { mutableStateOf(StatsPeriod.DAY) }
var summary by remember { mutableStateOf(StatsStore.summary(period.hours)) }
var chartData by remember { mutableStateOf(buildChart(period)) }
fun refreshStats() {
summary = StatsStore.summary(period.hours)
chartData = buildChart(period)
}
OnQueryLogChange { refreshStats() }
val statsVersion by StatsStore.version.collectAsStateWithLifecycle()
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() }
val canConnect = selected.url.toHttpUrlOrNull()?.isHttps == true
val needsKey = selected.id == Providers.DEFAULT_ID && !canConnect
val shown = active ?: selected
val usesHttp3 = shown.http3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
val crashReport by CrashLog.report.collectAsStateWithLifecycle()
val shownReport = rememberLast(crashReport).orEmpty() // kept while the card animates out
// Strict Private DNS makes Android ignore the VPN's DNS server; followed while Home is visible
val privateDnsHost by remember { privateDnsHosts(context) }.collectAsStateWithLifecycle(initialValue = null)
var busy by rememberVpnBusy(active)
val vpnPermission = rememberLauncherForActivityResult(
ActivityResultContracts.StartActivityForResult()
) {
if (it.resultCode == Activity.RESULT_OK) sendAction(context, DohVpnService.ACTION_START)
else busy = false
}
fun connectVpn() {
val permission = VpnService.prepare(context)
if (permission != null) vpnPermission.launch(permission)
else sendAction(context, DohVpnService.ACTION_START)
}
// The status notification is optional: connect whatever the user answers
val notificationPermission = rememberLauncherForActivityResult(
ActivityResultContracts.RequestPermission()
) { connectVpn() }
fun toggle() {
if (busy) return
busy = true
haptics.performHapticFeedback(if (running) HapticFeedbackType.ToggleOff else HapticFeedbackType.ToggleOn)
if (running) {
sendAction(context, DohVpnService.ACTION_STOP)
return
}
val needsNotificationPermission = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
context.checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED
if (needsNotificationPermission) notificationPermission.launch(Manifest.permission.POST_NOTIFICATIONS)
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,
)
if (needsKey && !running) {
HintCard(
text = stringResource(R.string.key_needed),
icon = R.drawable.ic_alert,
tint = Palette.Accent,
action = { TextButton(onClick = onOpenServers) { Text(stringResource(R.string.key_add)) } },
)
}
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(chartData, 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
.verticalScroll(rememberScrollState())
.drawWithCache {
// Soft light behind the logo while protected. The gradient depends on the size only;
// the fade is applied as alpha when drawing.
val center = Offset(size.width / 2f, 0f)
val radius = size.width * 0.65f
val light = Brush.radialGradient(
colors = listOf(Palette.Accent.copy(alpha = 0.22f), Color.Transparent),
center = center,
radius = radius,
)
onDrawBehind {
if (glow > 0f) drawCircle(brush = light, radius = radius, center = center, alpha = glow)
}
}
.padding(start = side, end = side, top = 16.dp, bottom = bottomPadding),
verticalArrangement = Arrangement.spacedBy(20.dp),
) {
Image(
remember { AppLogo.get(context) },
contentDescription = null,
modifier = Modifier
.size(44.dp)
.align(Alignment.CenterHorizontally),
)
AnimatedVisibility(visible = crashReport != null, enter = Motion.expandIn, exit = Motion.collapseOut) {
CrashCard(
report = shownReport,
onCopy = {
context.getSystemService(ClipboardManager::class.java)
.setPrimaryClip(ClipData.newPlainText("SparkleDNS crash", shownReport))
},
onDismiss = { CrashLog.clear(context) },
)
}
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()
}
}
}
@Composable
private fun StatusCard(
running: Boolean,
providerName: String,
http3: Boolean,
enabled: Boolean,
onToggle: () -> Unit,
onOpenServers: () -> Unit,
) {
Column(
modifier = Modifier
.fillMaxWidth()
.appCard()
.padding(horizontal = 20.dp, vertical = 24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
AnimatedContent(
targetState = running,
transitionSpec = { fadeIn(Motion.enterFade) togetherWith fadeOut(Motion.exitFade) },
label = "status",
) { on ->
Text(
stringResource(if (on) R.string.home_protected else R.string.home_unprotected),
color = Palette.Fg,
fontSize = 24.sp,
fontWeight = FontWeight.ExtraBold,
letterSpacing = (-0.3).sp,
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(
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)
.clip(CircleShape)
.drawBehind { drawRect(dot) }
)
Spacer(Modifier.width(8.dp))
val via = stringResource(R.string.home_via, providerName) + if (http3) " · HTTP/3" else ""
Text(
if (running) via else stringResource(R.string.home_off_desc),
color = Palette.Fg2,
fontSize = 13.sp,
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(8.dp))
PowerToggle(on = running, enabled = enabled, onToggle = onToggle)
}
}
// The big ON / OFF switch; the white knob slides across. The animated color and position are
// read only when drawing and placing, so the animation does not recompose the switch every frame.
@Composable
private fun PowerToggle(on: Boolean, enabled: Boolean, onToggle: () -> Unit) {
val track by animateColorAsState(if (on) Palette.Accent else Palette.Track, Motion.color, label = "track")
val knob by animateDpAsState(if (on) 70.dp else 0.dp, tween(320, easing = Motion.Emphasized), label = "knob")
val description = stringResource(if (on) R.string.disconnect else R.string.connect)
Box(
modifier = Modifier
.size(width = 120.dp, height = 50.dp)
.graphicsLayer { alpha = if (enabled) 1f else 0.5f }
.clip(RoundedCornerShape(25.dp))
.drawBehind { drawRect(track) }
.toggleable(value = on, enabled = enabled, role = Role.Switch, onValueChange = { onToggle() })
.semantics { contentDescription = description }
.padding(5.dp),
) {
Text(
stringResource(if (on) R.string.toggle_on else R.string.toggle_off),
color = if (on) Palette.AccentInk else Palette.Fg2,
fontSize = 15.sp,
fontWeight = FontWeight.ExtraBold,
letterSpacing = 0.6.sp,
modifier = Modifier
.align(if (on) Alignment.CenterStart else Alignment.CenterEnd)
.padding(horizontal = 12.dp),
)
Box(
modifier = Modifier
.offset { IntOffset(knob.roundToPx(), 0) }
.size(40.dp)
.clip(CircleShape)
.background(Color.White),
contentAlignment = Alignment.Center,
) {
Canvas(Modifier.size(14.dp)) {
val stroke = 1.6.dp.toPx()
KnobLines.forEach { fraction ->
drawLine(
color = Palette.Fg3,
start = Offset(size.width * fraction, size.height * 0.21f),
end = Offset(size.width * fraction, size.height * 0.79f),
strokeWidth = stroke,
cap = StrokeCap.Round,
)
}
}
}
}
}
@Composable
private fun PrivateDnsWarning(privateDnsHost: String?, prefs: Prefs) {
val context = LocalContext.current
val shownHost = rememberLast(privateDnsHost).orEmpty()
var dismissedHost by remember { mutableStateOf(prefs.dismissedPrivateDns) }
AnimatedVisibility(
visible = privateDnsHost != null && privateDnsHost != dismissedHost,
enter = Motion.expandIn,
exit = Motion.collapseOut,
) {
HintCard(
text = stringResource(R.string.hint, shownHost),
icon = R.drawable.ic_alert,
tint = WarningColor,
action = {
TextButton(onClick = { openNetworkSettings(context) }) { Text(stringResource(R.string.open_settings)) }
},
onDismiss = {
dismissedHost = shownHost
prefs.dismissedPrivateDns = shownHost
},
)
}
}
@Composable
fun StatBlock(value: String, label: String, modifier: Modifier = Modifier, valueColor: Color = Palette.Fg) {
Column(modifier, verticalArrangement = Arrangement.spacedBy(3.dp)) {
Text(value, color = valueColor, fontSize = 21.sp, fontWeight = FontWeight.ExtraBold, maxLines = 1)
Text(label, color = Palette.Fg2, fontSize = 12.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
@Composable
private fun ChartSection(chart: Chart, 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 (chart.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(chart.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 (chart.period == StatsPeriod.DAY) {
Text(chart.labels.firstOrNull().orEmpty(), color = Palette.Fg3, fontSize = 11.sp, modifier = Modifier.weight(1f))
Text(stringResource(R.string.chart_now), color = Palette.Fg3, fontSize = 11.sp)
} else {
chart.labels.forEachIndexed { index, label ->
Text(
label,
color = if (index == chart.labels.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(8.dp)
.clip(RoundedCornerShape(2.dp))
.background(color)
)
Spacer(Modifier.width(6.dp))
Text(label, color = Palette.Fg2, fontSize = 11.sp)
}
}
// 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(bars: List<Bar>, modifier: Modifier = Modifier) {
val measurer = rememberTextMeasurer()
// Scale, grid and grid labels are worked out when the bars or the size change, not every frame
Spacer(
modifier.drawWithCache {
val n = bars.size
if (n == 0) return@drawWithCache onDrawBehind {}
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 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()))
val stub = 2.dp.toPx()
val minBar = 4.dp.toPx()
val minBlocked = 2.dp.toPx()
val gridWidth = 1.dp.toPx()
val dash = PathEffect.dashPathEffect(floatArrayOf(3.dp.toPx(), 4.dp.toPx()))
fun height(value: Long) = value.toFloat() / maxValue * span
val grid = listOf(maxValue / 2, maxValue).filter { it > 0 }.map { value ->
val y = base - height(value)
val labelTop = y - 14.dp.toPx()
// The same constraints drawText() would use for a label at this spot
val label = measurer.measure(
text = formatCompact(value),
style = ChartLabelStyle,
constraints = Constraints(
maxWidth = ceil(size.width).roundToInt().coerceAtLeast(0),
maxHeight = ceil(size.height - labelTop).roundToInt().coerceAtLeast(0),
),
layoutDirection = layoutDirection,
density = this,
)
GridLine(y, labelTop, label)
}
onDrawBehind {
grid.forEach { line ->
drawLine(
color = Palette.Line,
start = Offset(0f, line.y),
end = Offset(size.width, line.y),
strokeWidth = gridWidth,
pathEffect = dash,
)
drawText(line.label, topLeft = Offset(0f, line.labelTop))
}
bars.forEachIndexed { index, bar ->
val x = index * slot + (slot - barWidth) / 2
if (bar.total == 0L) {
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(minBar)
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(minBlocked, 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))
}
}
}
}
}
)
}
private class GridLine(val y: Float, val labelTop: Float, val label: TextLayoutResult)
// 1, 2 or 5 times a power of ten, at least [value]: keeps the grid labels round
private fun niceCeiling(value: Long): Long {
var magnitude = 1L
while (magnitude * 10 <= value) magnitude *= 10
for (factor in longArrayOf(1, 2, 5)) {
if (factor * magnitude >= value) return factor * magnitude
}
return 10 * magnitude
}
// Date formats of the chart for the current locale and time zone. The chart is refreshed up to
// once a second, so they are kept rather than built anew each time. Main thread only.
private class ChartFormats(val locale: Locale, val zone: String) {
val hour = SimpleDateFormat("HH:00", locale)
val day = SimpleDateFormat("EEE", locale)
}
private var chartFormats: ChartFormats? = null
private fun chartFormats(): ChartFormats {
val locale = Locale.getDefault()
val zone = TimeZone.getDefault().id
return chartFormats?.takeIf { it.locale == locale && it.zone == zone }
?: ChartFormats(locale, zone).also { chartFormats = it }
}
// 24 hourly bars, or 7 bars for the calendar days of the last week (today last)
private fun buildChart(period: StatsPeriod, now: Long = System.currentTimeMillis()): Chart {
val hours = StatsStore.hourly(period.hours, now)
val firstHour = now / HOUR_MS - (hours.size - 1)
val formats = chartFormats()
if (period == StatsPeriod.DAY) {
// Only the first hour gets a label; the other end of the axis says "now"
val label = formats.hour.format(Date(firstHour * HOUR_MS))
return Chart(period, hours.map { Bar(it.total, it.blocked) }, listOf(label))
}
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
}
}
return Chart(period, List(7) { Bar(totals[it], blocked[it]) }, dayStarts.map { formats.day.format(Date(it)) })
}
private enum class BlocklistOffer { NONE, SWITCH_ON, FIRST_LIST }
@Composable
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
.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(if (idle) Palette.Track else Palette.Accent),
contentAlignment = Alignment.Center,
) {
Icon(
painterResource(R.drawable.ic_privacy),
contentDescription = null,
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(
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)
}
}
}
}
}
@@ -1,583 +1,108 @@
package cc.skysparkle.sparkledns
import android.Manifest
import android.app.Activity
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.ConnectivityManager
import android.net.LinkProperties
import android.net.Network
import android.net.Uri
import android.net.VpnService
import android.os.Build
import android.os.Bundle
import android.os.SystemClock
import android.provider.Settings
import androidx.activity.ComponentActivity
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
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.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.darkColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.rememberCoroutineScope
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.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
AppLogo.preload(this)
enableEdgeToEdge()
setContent {
MaterialTheme(colorScheme = AppColors) { AppShell() }
MaterialTheme(colorScheme = AppColors) {
// There is no Surface at the root, so text and icons without an explicit color
// would fall back to black and disappear on the dark background
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
// First launch: the guide explains the access key before the app opens
var onboarded by rememberSaveable { mutableStateOf(Prefs(this@MainActivity).onboardingDone) }
if (onboarded) AppShell() else OnboardingScreen(onDone = { onboarded = true })
}
}
}
}
}
private val AppColors = darkColorScheme(
primary = Color(0xFF7FB2FF),
onPrimary = Color(0xFF00285C),
background = Color(0xFF0F1115),
surface = Color(0xFF0F1115),
)
private val ProtectedContainer = Color(0xFF16233A)
private class TestResult(val ok: Boolean, val text: String)
internal class TestResult(val ok: Boolean, val text: String)
// How long a tap on Connect, Disconnect or Switch blocks further taps if the VPN state never changes
private const val BUSY_TIMEOUT_MS = 5000L
// Keeps test and sync results across rotation and process death
private val TestResultSaver = Saver<TestResult?, String>(
// Set by a tap until the VPN state changes or the attempt gives up, so a double tap neither
// starts two connections nor switches the VPN back on right after turning it off
@Composable
internal fun rememberVpnBusy(active: DohProvider?): MutableState<Boolean> {
val busy = remember { mutableStateOf(false) }
LaunchedEffect(active) { busy.value = false }
LaunchedEffect(busy.value) {
if (busy.value) {
delay(BUSY_TIMEOUT_MS)
busy.value = false
}
}
return busy
}
// Keeps test results across rotation and process death
internal val TestResultSaver = Saver<TestResult?, String>(
save = { result -> result?.let { (if (it.ok) "1" else "0") + it.text } },
restore = { saved -> TestResult(saved.startsWith("1"), saved.drop(1)) },
)
@Composable
fun HomeScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val prefs = remember { Prefs(context) }
val active by DohVpnService.active.collectAsStateWithLifecycle()
val running = active != null
val scope = rememberCoroutineScope()
val stats = rememberLiveStats()
var selected by remember { mutableStateOf(prefs.providerId) }
val servers by ServerList.servers.collectAsStateWithLifecycle()
var syncing by remember { mutableStateOf(false) }
var syncResult by rememberSaveable(stateSaver = TestResultSaver) { mutableStateOf<TestResult?>(null) }
var shownSync by rememberSaveable(stateSaver = TestResultSaver) { mutableStateOf<TestResult?>(null) }
var customUrl by remember { mutableStateOf(prefs.customUrl) }
var customBootstrap by remember { mutableStateOf(prefs.customBootstrap) }
var customHttp3 by remember { mutableStateOf(prefs.customHttp3) }
var testResult by rememberSaveable(stateSaver = TestResultSaver) { mutableStateOf<TestResult?>(null) }
var shownResult by rememberSaveable(stateSaver = TestResultSaver) { mutableStateOf<TestResult?>(null) } // kept while the card animates out
var testing by remember { mutableStateOf(false) }
val crashReport = remember { CrashLog.read(context) }
// Strict Private DNS makes Android ignore the VPN's DNS server; followed while Home is visible
val privateDnsHost by remember { privateDnsHosts(context) }.collectAsStateWithLifecycle(initialValue = null)
var crashVisible by remember { mutableStateOf(crashReport != null) }
val isCustom = selected == Providers.CUSTOM_ID
val customValid = remember(customUrl) { customUrl.trim().toHttpUrlOrNull()?.isHttps == true }
val canConnect = !isCustom || customValid
val selectedProvider = remember(selected, customUrl, customBootstrap, customHttp3, servers) { prefs.resolve() }
val customName = stringResource(R.string.custom)
fun nameOf(p: DohProvider) = if (p.id == Providers.CUSTOM_ID) customName else p.name
val shownProvider = active ?: selectedProvider
val usesHttp3 = shownProvider.http3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
// Picking a server never touches a live connection; switching is an explicit action
val pendingSwitch = active?.let { it != selectedProvider && canConnect } == true
// Set by a tap until the VPN state changes or the attempt gives up, so a double tap neither
// starts two connections nor switches the VPN back on right after turning it off
var busy by remember { mutableStateOf(false) }
LaunchedEffect(active) { busy = false }
LaunchedEffect(busy) {
if (busy) {
delay(BUSY_TIMEOUT_MS)
busy = false
}
}
val vpnPermission = rememberLauncherForActivityResult(
ActivityResultContracts.StartActivityForResult()
) {
if (it.resultCode == Activity.RESULT_OK) sendAction(context, DohVpnService.ACTION_START)
else busy = false
}
fun connectVpn() {
val permission = VpnService.prepare(context)
if (permission != null) vpnPermission.launch(permission)
else sendAction(context, DohVpnService.ACTION_START)
}
// The status notification is optional: connect whatever the user answers
val notificationPermission = rememberLauncherForActivityResult(
ActivityResultContracts.RequestPermission()
) { connectVpn() }
fun toggle() {
if (busy) return
busy = true
if (running) {
sendAction(context, DohVpnService.ACTION_STOP)
return
}
val needsNotificationPermission = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
context.checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED
if (needsNotificationPermission) notificationPermission.launch(Manifest.permission.POST_NOTIFICATIONS)
else connectVpn()
}
fun select(id: String) {
selected = id
prefs.providerId = id
testResult = null
}
// A server removed from the list falls back to the default one
LaunchedEffect(servers) {
if (selected != Providers.CUSTOM_ID && servers.none { it.id == selected }) select(Providers.default.id)
}
val syncOk = stringResource(R.string.servers_updated)
val syncFail = stringResource(R.string.servers_update_failed)
fun syncServers() {
syncing = true
syncResult = null
scope.launch {
val result = withContext(Dispatchers.IO) {
runCatching { ServerList.sync(context) }
.fold(
onSuccess = { TestResult(true, syncOk) },
onFailure = { TestResult(false, syncFail.format(it.message ?: it.javaClass.simpleName)) },
)
}
shownSync = result
syncResult = result
syncing = false
}
}
fun runTest() {
val provider = prefs.resolve()
testing = true
testResult = null
scope.launch {
val result = withContext(Dispatchers.IO) { testProvider(context, provider) }
shownResult = result
testResult = result
testing = false
}
}
Column(
modifier = modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(horizontal = 16.dp, vertical = 12.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
AnimatedVisibility(visible = crashVisible, enter = Motion.expandIn, exit = Motion.collapseOut) {
val report = crashReport.orEmpty()
CrashCard(
report = report,
onCopy = {
context.getSystemService(ClipboardManager::class.java)
.setPrimaryClip(ClipData.newPlainText("SparkleDNS crash", report))
},
onDismiss = { CrashLog.clear(context); crashVisible = false },
)
}
StatusHero(
running = running,
providerName = nameOf(shownProvider),
http3 = usesHttp3,
stats = stats,
canConnect = canConnect,
busy = busy,
switchTo = if (pendingSwitch) nameOf(selectedProvider) else null,
onToggle = ::toggle,
onSwitch = {
if (!busy) {
busy = true
sendAction(context, DohVpnService.ACTION_START)
}
},
)
SectionHeader(stringResource(R.string.servers)) {
if (syncing) {
Box(Modifier.size(48.dp), contentAlignment = Alignment.Center) {
CircularProgressIndicator(Modifier.size(20.dp), strokeWidth = 2.dp)
}
} else {
IconButton(onClick = ::syncServers) {
Icon(
painterResource(R.drawable.ic_refresh),
contentDescription = stringResource(R.string.servers_update),
modifier = Modifier.size(20.dp),
)
}
}
}
AnimatedVisibility(visible = syncResult != null, enter = Motion.expandIn, exit = Motion.collapseOut) {
shownSync?.let { result ->
HintCard(
text = result.text,
icon = if (result.ok) R.drawable.ic_check else R.drawable.ic_alert,
tint = if (result.ok) CachedColor else MaterialTheme.colorScheme.error,
onDismiss = { syncResult = null },
)
}
}
Card(Modifier.fillMaxWidth()) {
Column(Modifier.padding(vertical = 6.dp)) {
servers.forEachIndexed { index, p ->
if (index > 0) RowDivider()
ProviderRow(
title = p.name,
subtitle = hostOf(p.url),
selected = selected == p.id,
onPolicy = p.policy?.let { url -> { openUrl(context, url) } },
onDonate = p.donate?.let { url -> { openUrl(context, url) } },
) { select(p.id) }
}
RowDivider()
ProviderRow(
title = stringResource(R.string.custom),
subtitle = hostOf(customUrl),
selected = isCustom,
) { select(Providers.CUSTOM_ID) }
}
}
AnimatedVisibility(visible = isCustom, enter = Motion.expandIn, exit = Motion.collapseOut) {
Card(Modifier.fillMaxWidth()) {
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
OutlinedTextField(
value = customUrl,
onValueChange = { customUrl = it; prefs.customUrl = it },
label = { Text(stringResource(R.string.custom_url)) },
singleLine = true,
isError = !customValid,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Next),
modifier = Modifier.fillMaxWidth(),
)
if (!customValid) {
Text(
stringResource(R.string.invalid_url),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.error,
)
}
OutlinedTextField(
value = customBootstrap,
onValueChange = { customBootstrap = it; prefs.customBootstrap = it },
label = { Text(stringResource(R.string.custom_bootstrap)) },
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Done),
modifier = Modifier.fillMaxWidth(),
)
Row(
modifier = Modifier
.fillMaxWidth()
.toggleable(
value = customHttp3,
role = Role.Switch,
onValueChange = { customHttp3 = it; prefs.customHttp3 = it },
)
.padding(vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Text(stringResource(R.string.http3), style = MaterialTheme.typography.bodyLarge)
Text(
stringResource(R.string.http3_note),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Spacer(Modifier.width(12.dp))
Switch(checked = customHttp3, onCheckedChange = null)
}
}
}
}
OutlinedButton(
onClick = ::runTest,
enabled = !testing && canConnect,
modifier = Modifier
.fillMaxWidth()
.height(48.dp),
) { Text(stringResource(if (testing) R.string.testing else R.string.test)) }
AnimatedVisibility(visible = testResult != null, enter = Motion.expandIn, exit = Motion.collapseOut) {
shownResult?.let { result ->
HintCard(
text = result.text,
icon = if (result.ok) R.drawable.ic_check else R.drawable.ic_alert,
tint = if (result.ok) CachedColor else MaterialTheme.colorScheme.error,
onDismiss = { testResult = null },
)
}
}
val lastHost = remember { arrayOf("") }
privateDnsHost?.let { lastHost[0] = it }
var dismissedDnsHost by remember { mutableStateOf(prefs.dismissedPrivateDns) }
AnimatedVisibility(
visible = privateDnsHost != null && privateDnsHost != dismissedDnsHost,
enter = Motion.expandIn,
exit = Motion.collapseOut,
) {
HintCard(
text = stringResource(R.string.hint, lastHost[0]),
icon = R.drawable.ic_alert,
tint = WarningColor,
action = {
TextButton(onClick = { openNetworkSettings(context) }) { Text(stringResource(R.string.open_settings)) }
},
onDismiss = {
dismissedDnsHost = lastHost[0]
prefs.dismissedPrivateDns = lastHost[0]
},
)
}
}
}
@Composable
private fun StatusHero(
running: Boolean,
providerName: String,
http3: Boolean,
stats: QueryStats,
canConnect: Boolean,
busy: Boolean,
switchTo: String?,
onToggle: () -> Unit,
onSwitch: () -> Unit,
) {
val accent by animateColorAsState(
if (running) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.outline,
animationSpec = Motion.color,
label = "accent",
)
val container by animateColorAsState(
if (running) ProtectedContainer else MaterialTheme.colorScheme.surfaceContainerHighest,
animationSpec = Motion.color,
label = "container",
)
val ringAlpha by animateFloatAsState(if (running) 1f else 0f, Motion.rotation, label = "ring")
Card(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(containerColor = container),
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(20.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
Box(Modifier.size(124.dp), contentAlignment = Alignment.Center) {
if (ringAlpha > 0f) PulseRing(accent, ringAlpha)
Box(
modifier = Modifier
.size(92.dp)
.clip(CircleShape)
.background(accent.copy(alpha = 0.18f)),
contentAlignment = Alignment.Center,
) {
Icon(
painterResource(R.drawable.ic_privacy),
contentDescription = null,
tint = accent,
modifier = Modifier.size(52.dp),
)
}
}
AnimatedContent(
targetState = running,
transitionSpec = { fadeIn(Motion.enterFade) togetherWith fadeOut(Motion.exitFade) },
label = "status",
) { on ->
Text(
stringResource(if (on) R.string.status_on else R.string.status_off),
style = MaterialTheme.typography.headlineSmall,
)
}
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
stringResource(R.string.via, providerName),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
if (http3) {
Spacer(Modifier.width(8.dp))
Pill("HTTP/3", accent)
}
}
AnimatedVisibility(visible = running, enter = Motion.expandIn, exit = Motion.collapseOut) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
StatColumn(formatCount(stats.total), stringResource(R.string.mon_queries), Modifier.weight(1f))
StatDivider()
StatColumn(formatCount(stats.blocked), stringResource(R.string.mon_blocked), Modifier.weight(1f))
StatDivider()
StatColumn(cachePercent(stats), stringResource(R.string.mon_cached), Modifier.weight(1f))
}
}
Button(
onClick = onToggle,
enabled = (running || canConnect) && !busy,
modifier = Modifier
.fillMaxWidth()
.height(52.dp),
) {
AnimatedContent(
targetState = running,
transitionSpec = { fadeIn(Motion.enterFade) togetherWith fadeOut(Motion.exitFade) },
label = "toggle",
) { on -> Text(stringResource(if (on) R.string.disconnect else R.string.connect)) }
}
// Remembers the last name so the button keeps its label while it animates out
val lastSwitch = remember { arrayOf("") }
if (switchTo != null) lastSwitch[0] = switchTo
AnimatedVisibility(visible = switchTo != null, enter = Motion.expandIn, exit = Motion.collapseOut) {
OutlinedButton(onClick = onSwitch, enabled = !busy, modifier = Modifier.fillMaxWidth()) {
Icon(painterResource(R.drawable.ic_switch), contentDescription = null, modifier = Modifier.size(18.dp))
Spacer(Modifier.width(8.dp))
Text(stringResource(R.string.switch_to, lastSwitch[0]))
}
}
}
}
}
@Composable
private fun PulseRing(color: Color, visibility: Float) {
val transition = rememberInfiniteTransition(label = "pulse")
val progress by transition.animateFloat(
initialValue = 0f,
targetValue = 1f,
animationSpec = infiniteRepeatable(tween(1800, easing = LinearEasing)),
label = "progress",
)
Box(
Modifier
.size(124.dp)
.graphicsLayer {
val scale = 0.74f + 0.26f * progress
scaleX = scale
scaleY = scale
alpha = (1f - progress) * visibility
}
.clip(CircleShape)
.background(color.copy(alpha = 0.28f))
)
}
@Composable
private fun CrashCard(report: String, onCopy: () -> Unit, onDismiss: () -> Unit) {
internal fun CrashCard(report: String, onCopy: () -> Unit, onDismiss: () -> Unit) {
Card(
modifier = Modifier.fillMaxWidth(),
shape = RoundedCornerShape(20.dp),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer),
) {
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
@@ -601,74 +126,9 @@ private fun CrashCard(report: String, onCopy: () -> Unit, onDismiss: () -> Unit)
}
}
@Composable
private fun ProviderRow(
title: String,
subtitle: String,
selected: Boolean,
onPolicy: (() -> Unit)? = null,
onDonate: (() -> Unit)? = null,
onClick: () -> Unit,
) {
val highlight by animateColorAsState(
if (selected) MaterialTheme.colorScheme.primary.copy(alpha = 0.08f) else Color.Transparent,
animationSpec = Motion.color,
label = "highlight",
)
Row(
modifier = Modifier
.fillMaxWidth()
.background(highlight)
.selectable(selected = selected, onClick = onClick, role = Role.RadioButton)
.padding(horizontal = 12.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
) {
RadioButton(selected = selected, onClick = null)
Spacer(Modifier.width(12.dp))
Column(Modifier.weight(1f)) {
Text(title, style = MaterialTheme.typography.bodyLarge)
Text(
subtitle,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
if (onDonate != null) {
IconButton(onClick = onDonate, modifier = Modifier.size(40.dp)) {
Icon(
painterResource(R.drawable.ic_donate),
contentDescription = stringResource(R.string.donate),
tint = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.size(18.dp),
)
}
}
if (onPolicy != null) {
IconButton(onClick = onPolicy, modifier = Modifier.size(40.dp)) {
Icon(
painterResource(R.drawable.ic_policy),
contentDescription = stringResource(R.string.about_privacy_policy),
tint = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.size(18.dp),
)
}
}
}
}
@Composable
private fun RowDivider() {
HorizontalDivider(
modifier = Modifier.padding(start = 60.dp),
color = MaterialTheme.colorScheme.outlineVariant.copy(alpha = 0.5f),
)
}
// Hostname of strict Private DNS (DNS-over-TLS) on the current network, null when it is Automatic or Off.
// Android reports the current state on registration and every change after it.
private fun privateDnsHosts(context: Context): Flow<String?> {
internal fun privateDnsHosts(context: Context): Flow<String?> {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) return flowOf(null)
val cm = context.applicationContext.getSystemService(ConnectivityManager::class.java) ?: return flowOf(null)
return callbackFlow {
@@ -686,13 +146,13 @@ private fun privateDnsHosts(context: Context): Flow<String?> {
}.distinctUntilChanged()
}
private fun openNetworkSettings(context: Context) {
internal fun openNetworkSettings(context: Context) {
runCatching {
context.startActivity(Intent(Settings.ACTION_WIRELESS_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
}
}
private fun hostOf(url: String): String =
internal fun hostOf(url: String): String =
runCatching { Uri.parse(url.trim()).host }.getOrNull()?.takeIf { it.isNotEmpty() } ?: url
internal fun sendAction(context: Context, action: String) {
@@ -700,7 +160,7 @@ internal fun sendAction(context: Context, action: String) {
}
// Runs from the app process, which is excluded from the VPN, so it tests the server directly
private fun testProvider(context: Context, provider: DohProvider): TestResult {
internal fun testProvider(context: Context, provider: DohProvider): TestResult {
val client = DohClient(context, provider)
return try {
val t0 = SystemClock.elapsedRealtime()
@@ -1,303 +0,0 @@
package cc.skysparkle.sparkledns
import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
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.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.FilterChip
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.Text
import androidx.compose.runtime.Composable
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.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
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
private enum class MonitorFilter { ALL, BLOCKED, ERRORS }
private val TimeFormat = SimpleDateFormat("HH:mm:ss", Locale.ROOT)
@Composable
fun MonitorScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
val custom by Blocklist.custom.collectAsStateWithLifecycle()
val customSet = remember(custom) { custom.toHashSet() }
var entries by remember { mutableStateOf(QueryLog.snapshot()) }
var stats by remember { mutableStateOf(QueryLog.stats()) }
var filter by rememberSaveable { mutableStateOf(MonitorFilter.ALL) }
var search by rememberSaveable { mutableStateOf("") }
OnQueryLogChange {
entries = QueryLog.snapshot()
stats = QueryLog.stats()
}
val visible = remember(entries, filter, search) {
val term = search.trim()
entries.filter { e ->
val matchesFilter = when (filter) {
MonitorFilter.ALL -> true
MonitorFilter.BLOCKED -> e.status == QueryStatus.BLOCKED
MonitorFilter.ERRORS -> e.status == QueryStatus.FAILED
}
matchesFilter && (term.isEmpty() || e.domain.contains(term, ignoreCase = true))
}
}
fun toggleBlock(domain: String, unblock: Boolean) {
scope.launch {
val result = withContext(Dispatchers.IO) {
tryEdit {
if (unblock) {
Blocklist.removeCustom(context, domain)
true
} else {
Blocklist.addCustom(context, domain)
}
}
}
val ok = result.getOrElse {
showEditError(context, it)
return@launch
}
val message = when {
!ok -> context.getString(R.string.bl_invalid)
unblock -> context.getString(R.string.mon_unblocked, domain)
else -> context.getString(R.string.mon_blocked_added, domain)
}
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}
}
LazyColumn(
modifier = modifier.fillMaxSize(),
contentPadding = PaddingValues(16.dp),
) {
item {
Card(Modifier.fillMaxWidth()) {
Row(
modifier = Modifier.padding(vertical = 16.dp),
verticalAlignment = Alignment.CenterVertically,
) {
StatColumn(formatCount(stats.total), stringResource(R.string.mon_queries), Modifier.weight(1f))
StatDivider()
StatColumn(cachePercent(stats), stringResource(R.string.mon_cached), Modifier.weight(1f))
StatDivider()
StatColumn(formatCount(stats.blocked), stringResource(R.string.mon_blocked), Modifier.weight(1f))
StatDivider()
StatColumn(
stringResource(R.string.mon_ms, stats.avgLatencyMs),
stringResource(R.string.mon_latency),
Modifier.weight(1f),
)
}
}
}
item {
Row(
modifier = Modifier.padding(top = 12.dp),
verticalAlignment = Alignment.CenterVertically,
) {
// Chips scroll sideways on narrow screens instead of squeezing the clear button
Row(
modifier = Modifier
.weight(1f)
.horizontalScroll(rememberScrollState()),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
FilterChip(
selected = filter == MonitorFilter.ALL,
onClick = { filter = MonitorFilter.ALL },
label = { Text(stringResource(R.string.mon_all)) },
)
FilterChip(
selected = filter == MonitorFilter.BLOCKED,
onClick = { filter = MonitorFilter.BLOCKED },
label = { Text(stringResource(R.string.status_blocked)) },
leadingIcon = { ChipIcon(R.drawable.ic_tab_block) },
)
FilterChip(
selected = filter == MonitorFilter.ERRORS,
onClick = { filter = MonitorFilter.ERRORS },
label = { Text(stringResource(R.string.mon_errors)) },
leadingIcon = { ChipIcon(R.drawable.ic_alert) },
)
}
IconButton(
onClick = {
QueryLog.clear()
entries = emptyList()
stats = QueryLog.stats()
},
enabled = entries.isNotEmpty() || stats.total > 0,
) {
Icon(painterResource(R.drawable.ic_clear), stringResource(R.string.mon_clear), Modifier.size(22.dp))
}
}
}
item {
OutlinedTextField(
value = search,
onValueChange = { search = it },
placeholder = { Text(stringResource(R.string.mon_search)) },
leadingIcon = { Icon(painterResource(R.drawable.ic_search), contentDescription = null) },
singleLine = true,
shape = RoundedCornerShape(50),
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 12.dp),
)
}
if (visible.isEmpty()) {
item(key = "empty") {
val text = stringResource(if (entries.isEmpty()) R.string.mon_empty else R.string.mon_no_match)
Box(Modifier.animateItem()) { EmptyState(R.drawable.ic_tab_monitor, text) }
}
}
itemsIndexed(visible, key = { _, e -> e.id }, contentType = { _, _ -> "query" }) { index, entry ->
val inCustom = entry.domain in customSet
QueryRow(
modifier = Modifier.animateItem(),
entry = entry,
first = index == 0,
last = index == visible.lastIndex,
showBlock = !inCustom && entry.status != QueryStatus.BLOCKED,
showUnblock = inCustom,
onBlock = { toggleBlock(entry.domain, unblock = false) },
onUnblock = { toggleBlock(entry.domain, unblock = true) },
)
}
}
}
@Composable
private fun ChipIcon(icon: Int) {
Icon(painterResource(icon), contentDescription = null, modifier = Modifier.size(18.dp))
}
@Composable
fun EmptyState(icon: Int, text: String) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 40.dp),
horizontalAlignment = Alignment.CenterHorizontally,
) {
IconBadge(icon, MaterialTheme.colorScheme.onSurfaceVariant, size = 64.dp)
Spacer(Modifier.height(12.dp))
Text(
text,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
textAlign = TextAlign.Center,
)
}
}
@Composable
private fun QueryRow(
modifier: Modifier,
entry: QueryEntry,
first: Boolean,
last: Boolean,
showBlock: Boolean,
showUnblock: Boolean,
onBlock: () -> Unit,
onUnblock: () -> Unit,
) {
val (icon, color: Color) = when (entry.status) {
QueryStatus.OK -> R.drawable.ic_check to MaterialTheme.colorScheme.primary
QueryStatus.CACHED -> R.drawable.ic_check to CachedColor
QueryStatus.BLOCKED -> R.drawable.ic_tab_block to MaterialTheme.colorScheme.error
QueryStatus.FAILED -> R.drawable.ic_alert to WarningColor
}
val label = when (entry.status) {
QueryStatus.OK -> stringResource(R.string.mon_ms, entry.latencyMs)
QueryStatus.CACHED -> stringResource(R.string.status_cached)
QueryStatus.BLOCKED -> stringResource(R.string.status_blocked)
QueryStatus.FAILED -> stringResource(R.string.status_failed)
}
Column(
modifier
.fillMaxWidth()
.background(groupedBackground, groupedShape(first, last))
) {
if (!first) {
HorizontalDivider(
modifier = Modifier.padding(start = 60.dp),
color = MaterialTheme.colorScheme.outlineVariant.copy(alpha = 0.5f),
)
}
Row(
modifier = Modifier.padding(start = 12.dp, end = 4.dp, top = 8.dp, bottom = 8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
IconBadge(icon, color, size = 36.dp)
Spacer(Modifier.width(12.dp))
Column(Modifier.weight(1f)) {
Text(entry.domain, style = MaterialTheme.typography.bodyMedium, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(
"${TimeFormat.format(Date(entry.time))} · ${DnsMessage.typeName(entry.type)}",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Spacer(Modifier.width(8.dp))
Pill(label, color)
when {
showBlock -> IconButton(onClick = onBlock) {
Icon(painterResource(R.drawable.ic_tab_block), stringResource(R.string.mon_block), Modifier.size(20.dp))
}
showUnblock -> IconButton(onClick = onUnblock) {
Icon(painterResource(R.drawable.ic_check), stringResource(R.string.mon_unblock), Modifier.size(20.dp))
}
else -> Spacer(Modifier.width(48.dp))
}
}
}
}
@@ -1,6 +1,5 @@
package cc.skysparkle.sparkledns
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.FiniteAnimationSpec
import androidx.compose.animation.core.tween
@@ -25,6 +24,4 @@ object Motion {
val expandIn = fadeIn(enterFade) + expandVertically(size)
val collapseOut = fadeOut(exitFade) + shrinkVertically(size)
fun sizeTransform() = SizeTransform(clip = false) { _, _ -> size }
}
@@ -0,0 +1,200 @@
package cc.skysparkle.sparkledns
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
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.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
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.Button
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
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.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
// Shown once on first launch: what the app does, then how to get the personal access key
// for the Skysparkle server. Skipping leaves the key empty; other servers stay available.
@Composable
fun OnboardingScreen(onDone: () -> Unit) {
val context = LocalContext.current
val prefs = remember { Prefs(context) }
var page by rememberSaveable { mutableIntStateOf(0) }
var keyInput by rememberSaveable { mutableStateOf(prefs.skysparkleKey) }
val keyValid = SkysparkleKey.parse(keyInput) != null
fun finish(useKey: Boolean) {
if (useKey) {
prefs.skysparkleKey = SkysparkleKey.parse(keyInput) ?: ""
prefs.providerId = Providers.DEFAULT_ID
}
prefs.onboardingDone = true
onDone()
}
BackHandler(enabled = page > 0) { page-- }
Box(
Modifier
.fillMaxSize()
.background(Palette.Bg)
.statusBarsPadding()
.navigationBarsPadding()
.imePadding(),
contentAlignment = Alignment.TopCenter,
) {
Column(
Modifier
.widthIn(max = 520.dp)
.fillMaxSize()
.padding(horizontal = 24.dp, vertical = 20.dp),
) {
Dots(count = 2, current = page)
AnimatedContent(
targetState = page,
transitionSpec = {
val forward = targetState > initialState
(fadeIn(Motion.enterFade) + slideInHorizontally(Motion.slide) { if (forward) it / 4 else -it / 4 }) togetherWith
(fadeOut(Motion.exitFade) + slideOutHorizontally(Motion.slide) { if (forward) -it / 4 else it / 4 })
},
modifier = Modifier.weight(1f),
label = "onboarding",
) { current ->
Column(
Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(top = 40.dp, bottom = 16.dp),
verticalArrangement = Arrangement.spacedBy(14.dp),
) {
if (current == 0) {
Image(
bitmap = AppLogo.get(context),
contentDescription = null,
modifier = Modifier
.size(72.dp)
.clip(RoundedCornerShape(20.dp)),
)
Spacer(Modifier.height(8.dp))
Title(stringResource(R.string.onb_welcome_title))
Body(stringResource(R.string.onb_welcome_text))
Spacer(Modifier.height(8.dp))
Step(1, stringResource(R.string.onb_point_encrypt))
Step(2, stringResource(R.string.onb_point_block))
Step(3, stringResource(R.string.onb_point_independent))
} else {
Title(stringResource(R.string.onb_key_title))
Body(stringResource(R.string.onb_key_text))
Spacer(Modifier.height(4.dp))
Step(1, stringResource(R.string.onb_key_step1))
Step(2, stringResource(R.string.onb_key_step2))
Step(3, stringResource(R.string.onb_key_step3))
Spacer(Modifier.height(4.dp))
Column(Modifier.fillMaxWidth().appCard().padding(top = 16.dp)) {
KeyField(
value = keyInput,
valid = keyValid,
onChange = { keyInput = it },
onGetKey = { openUrl(context, SkysparkleKey.SIGNUP_URL) },
)
}
}
}
}
if (page == 0) {
Button(
onClick = { page = 1 },
shape = RoundedCornerShape(16.dp),
modifier = Modifier.fillMaxWidth().height(52.dp),
) { Text(stringResource(R.string.onb_next), fontWeight = FontWeight.Bold) }
} else {
Button(
onClick = { finish(useKey = true) },
enabled = keyValid,
shape = RoundedCornerShape(16.dp),
modifier = Modifier.fillMaxWidth().height(52.dp),
) { Text(stringResource(R.string.onb_done), fontWeight = FontWeight.Bold) }
TextButton(onClick = { finish(useKey = false) }, modifier = Modifier.fillMaxWidth()) {
Text(stringResource(R.string.onb_skip), color = Palette.Fg3)
}
}
}
}
}
@Composable
private fun Title(text: String) {
Text(text, color = Palette.Fg, fontSize = 30.sp, lineHeight = 34.sp, fontWeight = FontWeight.ExtraBold, letterSpacing = (-0.5).sp)
}
@Composable
private fun Body(text: String) {
Text(text, color = Palette.Fg2, fontSize = 16.sp, lineHeight = 23.sp)
}
@Composable
private fun Step(number: Int, text: String) {
Row(verticalAlignment = Alignment.Top) {
Box(
Modifier
.size(26.dp)
.clip(CircleShape)
.background(Palette.AccentSoft),
contentAlignment = Alignment.Center,
) {
Text(number.toString(), color = Palette.Accent, fontSize = 13.sp, fontWeight = FontWeight.Bold)
}
Spacer(Modifier.width(12.dp))
Text(text, color = Palette.Fg, fontSize = 15.sp, lineHeight = 21.sp, modifier = Modifier.padding(top = 2.dp))
}
}
@Composable
private fun Dots(count: Int, current: Int) {
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
repeat(count) { i ->
Box(
Modifier
.height(4.dp)
.width(if (i == current) 22.dp else 10.dp)
.clip(CircleShape)
.background(if (i == current) Palette.Accent else Palette.Track),
)
}
}
}
@@ -3,9 +3,10 @@ package cc.skysparkle.sparkledns
import java.io.ByteArrayOutputStream
import kotlin.random.Random
// IPv4 addresses are kept as plain numbers, so parsing a query allocates only its payload
class UdpPacket(
val srcIp: ByteArray,
val dstIp: ByteArray,
val srcIp: Int,
val dstIp: Int,
val srcPort: Int,
val dstPort: Int,
val payload: ByteArray,
@@ -29,8 +30,8 @@ object Packet {
if (end <= ihl + 8) return null
return UdpPacket(
srcIp = buf.copyOfRange(12, 16),
dstIp = buf.copyOfRange(16, 20),
srcIp = i32(buf, 12),
dstIp = i32(buf, 16),
srcPort = u16(buf, ihl),
dstPort = dstPort,
payload = buf.copyOfRange(ihl + 8, end),
@@ -47,8 +48,8 @@ object Packet {
p[6] = 0x40 // don't fragment
p[8] = 64
p[9] = 17
query.dstIp.copyInto(p, 12)
query.srcIp.copyInto(p, 16)
put32(p, 12, query.dstIp)
put32(p, 16, query.srcIp)
put16(p, 10, checksum(p, 0, 20, 0))
put16(p, 20, query.dstPort)
@@ -123,7 +124,9 @@ object DnsMessage {
fun question(msg: ByteArray): Question? {
if (msg.size < 12 || u16(msg, 4) < 1) return null
val name = StringBuilder()
// Sized up front, so the builder does not grow: a valid name has at most 253 characters,
// and never more than the message has bytes after the header
val name = StringBuilder(minOf(msg.size - 12, 253))
var p = 12
while (true) {
if (p >= msg.size) return null
@@ -180,6 +183,8 @@ internal fun put32(b: ByteArray, off: Int, value: Int) {
internal fun u32(b: ByteArray, off: Int): Long =
((u16(b, off).toLong()) shl 16) or u16(b, off + 2).toLong()
internal fun i32(b: ByteArray, off: Int): Int = (u16(b, off) shl 16) or u16(b, off + 2)
// Returns the offset right after a (possibly compressed) DNS name
internal fun skipName(b: ByteArray, start: Int): Int? {
var p = start
@@ -5,10 +5,6 @@ import android.content.Context
class Prefs(context: Context) {
private val sp = context.applicationContext.getSharedPreferences("doh", Context.MODE_PRIVATE)
init {
ServerList.ensureLoaded(context.applicationContext)
}
var providerId: String
get() = sp.getString(KEY_PROVIDER, null) ?: Providers.default.id
set(value) = sp.edit().putString(KEY_PROVIDER, value).apply()
@@ -25,10 +21,29 @@ class Prefs(context: Context) {
get() = sp.getBoolean(KEY_HTTP3, false)
set(value) = sp.edit().putBoolean(KEY_HTTP3, value).apply()
// Access key for the Skysparkle server, created in the account at skysparkle.cc
var skysparkleKey: String
get() = sp.getString(KEY_SKYSPARKLE, null) ?: ""
set(value) = sp.edit().putString(KEY_SKYSPARKLE, value).apply()
// The first-launch guide was finished or skipped
var onboardingDone: Boolean
get() = sp.getBoolean(KEY_ONBOARDING, false)
set(value) = sp.edit().putBoolean(KEY_ONBOARDING, value).apply()
var excludedApps: Set<String>
get() = sp.getStringSet(KEY_EXCLUDED, null)?.toSet() ?: emptySet()
set(value) = sp.edit().putStringSet(KEY_EXCLUDED, value).apply()
var updateInterval: UpdateInterval
get() = UpdateInterval.entries.getOrNull(sp.getInt(KEY_UPDATE_INTERVAL, UpdateInterval.DAILY.ordinal))
?: UpdateInterval.DAILY
set(value) = sp.edit().putInt(KEY_UPDATE_INTERVAL, value.ordinal).apply()
var updateWifiOnly: Boolean
get() = sp.getBoolean(KEY_UPDATE_WIFI_ONLY, true)
set(value) = sp.edit().putBoolean(KEY_UPDATE_WIFI_ONLY, value).apply()
// Hint cards the user closed with the X
fun isHintDismissed(key: String): Boolean =
sp.getStringSet(KEY_HINTS, null)?.contains(key) == true
@@ -43,11 +58,13 @@ class Prefs(context: Context) {
get() = sp.getString(KEY_PRIVATE_DNS, null) ?: ""
set(value) = sp.edit().putString(KEY_PRIVATE_DNS, value).apply()
fun resolve(): DohProvider =
if (providerId == Providers.CUSTOM_ID) {
// Without a key the Skysparkle entry has an empty address, so it cannot connect
fun resolve(): DohProvider = when (providerId) {
Providers.CUSTOM_ID ->
DohProvider(Providers.CUSTOM_ID, "Custom", customUrl.trim(), parseIps(customBootstrap), customHttp3)
} else {
Providers.byId(providerId)
else -> Providers.byId(providerId).let {
if (it.id == Providers.DEFAULT_ID) it.copy(url = SkysparkleKey.url(skysparkleKey)) else it
}
}
private companion object {
@@ -56,7 +73,11 @@ class Prefs(context: Context) {
const val KEY_BOOTSTRAP = "custom_bootstrap"
const val KEY_HTTP3 = "custom_http3"
const val KEY_EXCLUDED = "excluded_apps"
const val KEY_SKYSPARKLE = "skysparkle_key"
const val KEY_ONBOARDING = "onboarding_done"
const val KEY_HINTS = "dismissed_hints"
const val KEY_PRIVATE_DNS = "dismissed_private_dns"
const val KEY_UPDATE_INTERVAL = "update_interval"
const val KEY_UPDATE_WIFI_ONLY = "update_wifi_only"
}
}
@@ -1,13 +1,6 @@
package cc.skysparkle.sparkledns
import android.content.Context
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import okhttp3.Request
import java.io.File
import java.io.IOException
import java.util.concurrent.TimeUnit
data class DohProvider(
val id: String,
@@ -23,14 +16,16 @@ object Providers {
const val CUSTOM_ID = "custom"
const val DEFAULT_ID = "skysparkle"
// Shipped with the app and used until the list from the repository is downloaded
// Servers ship with the app; new ones arrive with app updates
val builtIn = listOf(
// The address is personal: Prefs.resolve() adds the access key from skysparkle.cc
DohProvider(
"skysparkle", "SkySparkle", "https://blog.skysparkle.cc/dns-query",
"skysparkle", "SkySparkle", SkysparkleKey.BASE_URL,
http3 = true, policy = "https://skysparkle.cc/privacy?lang=en",
),
DohProvider(
"quad9", "Quad9", "https://dns.quad9.net/dns-query", listOf("9.9.9.9", "149.112.112.112"),
http3 = true,
policy = "https://quad9.net/service/privacy/",
donate = "https://quad9.net/donate/",
),
@@ -50,111 +45,36 @@ object Providers {
policy = "https://ffmuc.net/dns-privacy/",
donate = "https://spende.ffmuc.net/",
),
DohProvider(
"dnsforge", "dnsforge.de", "https://blank.dnsforge.de/dns-query",
listOf("78.47.71.194", "138.199.149.249"),
policy = "https://adminforge.de/datenschutz/",
donate = "https://adminforge.de/unterstuetzen/",
),
)
val list: List<DohProvider> get() = ServerList.servers.value
// The project's own server stays the default whatever order the list uses
val default: DohProvider get() = list.firstOrNull { it.id == DEFAULT_ID } ?: list.first()
val default: DohProvider = builtIn.firstOrNull { it.id == DEFAULT_ID } ?: builtIn.first()
fun byId(id: String): DohProvider = list.firstOrNull { it.id == id } ?: default
fun byId(id: String): DohProvider = builtIn.firstOrNull { it.id == id } ?: default
}
// The server list kept in the project repository, so servers can change without an app update
object ServerList {
const val SOURCE = "https://git.skysparkle.cc/kalarina/Sparkledns/raw/branch/main/servers/servers.txt"
private const val FILE = "servers.txt"
private const val MAX_BYTES = 64 * 1024
private const val MAX_SERVERS = 50
// Personal access keys for the Skysparkle server. Each account at skysparkle.cc creates its own
// keys; the server answers only /dns/<key>, there is no shared public address.
object SkysparkleKey {
const val BASE_URL = "https://skysparkle.cc/dns/"
const val SIGNUP_URL = "https://skysparkle.cc/login#register"
private val KEY = Regex("^[A-Za-z0-9_-]{24}$")
private val IN_URL = Regex("/dns/([A-Za-z0-9_-]{24})(?:[/?#].*)?$")
private val _servers = MutableStateFlow(Providers.builtIn)
val servers: StateFlow<List<DohProvider>> = _servers
@Volatile private var loaded = false
private val client by lazy {
Http.client.newBuilder()
.readTimeout(30, TimeUnit.SECONDS)
.build()
// Accepts the key itself or the whole address copied from the account page
fun parse(input: String): String? {
val text = input.trim()
if (KEY.matches(text)) return text
return IN_URL.find(text)?.groupValues?.get(1)
}
fun ensureLoaded(context: Context) {
if (loaded) return
synchronized(this) {
if (loaded) return
val cached = runCatching { File(context.filesDir, FILE).readText() }.getOrNull()
cached?.let(::parse)?.takeIf { it.isNotEmpty() }?.let { _servers.value = it }
loaded = true
}
}
// Blocking: call off the main thread. Returns the number of servers in the new list.
fun sync(context: Context): Int {
val request = Request.Builder().url(SOURCE).build()
val text = client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("HTTP ${response.code}")
val body = response.body ?: throw IOException("Empty response")
if (body.contentLength() > MAX_BYTES) throw IOException("List too large")
val bytes = body.byteStream().readNBytesCompat(MAX_BYTES + 1)
if (bytes.size > MAX_BYTES) throw IOException("List too large")
String(bytes, Charsets.UTF_8)
}
val parsed = parse(text)
if (parsed.isEmpty()) throw IOException("No servers found")
val file = File(context.filesDir, FILE)
val tmp = File(context.filesDir, "$FILE.tmp")
tmp.writeText(text)
if (!tmp.renameTo(file)) {
tmp.delete()
throw IOException("Cannot save list")
}
_servers.value = parsed
loaded = true
return parsed.size
}
// Format per line: Name | DoH URL | privacy policy URL | h3 (optional) | donation URL (optional).
// The optional columns are recognised by content, so either can be left out. See CONTRIBUTING.md.
fun parse(text: String): List<DohProvider> {
val builtInByHost = Providers.builtIn.associateBy { it.url.toHttpUrlOrNull()?.host }
val seen = HashSet<String>()
val result = ArrayList<DohProvider>()
for (raw in text.lineSequence()) {
val line = raw.trim()
if (line.isEmpty() || line.startsWith("#")) continue
val cols = line.split('|').map { it.trim() }
if (cols.size < 3) continue
val name = cols[0].take(40)
val url = cols[1].toHttpUrlOrNull()
val policy = cols[2].takeIf { it.toHttpUrlOrNull()?.isHttps == true }
if (name.isEmpty() || url == null || !url.isHttps) continue
val extras = cols.drop(3)
val http3 = extras.any { it.equals("h3", ignoreCase = true) }
val donate = extras.firstOrNull { it.toHttpUrlOrNull()?.isHttps == true }
// Shipped servers keep their address, id and links, so an edited list cannot redirect them
val pinned = builtInByHost[url.host]
val server = pinned
?: if (policy == null) continue
else DohProvider(url.host, name, cols[1], http3 = http3, policy = policy, donate = donate)
if (!seen.add(server.id)) continue
result += server
if (result.size >= MAX_SERVERS) break
}
return result
}
}
private fun java.io.InputStream.readNBytesCompat(limit: Int): ByteArray {
val out = java.io.ByteArrayOutputStream()
val buffer = ByteArray(8192)
var total = 0
while (total < limit) {
val read = read(buffer, 0, minOf(buffer.size, limit - total))
if (read < 0) break
out.write(buffer, 0, read)
total += read
}
return out.toByteArray()
fun url(key: String): String = parse(key)?.let { BASE_URL + it } ?: ""
}
fun parseIps(raw: String): List<String> =
@@ -16,28 +16,19 @@ class QueryEntry(
val latencyMs: Int,
)
data class QueryStats(
val total: Long,
val cached: Long,
val blocked: Long,
val failed: Long,
val avgLatencyMs: Int,
)
// In-memory only: nothing is written to disk or sent anywhere
// In-memory only: nothing is written to disk or sent anywhere. StatsStore keeps hourly
// numbers without domains for the charts.
object QueryLog {
private const val MAX_ENTRIES = 500
private val entries = ArrayDeque<QueryEntry>()
private var nextId = 0L
private var total = 0L
private var cached = 0L
private var blocked = 0L
private var failed = 0L
private var latencySum = 0L
private var latencyCount = 0L
private val version = MutableStateFlow(0L)
// The last snapshot, handed out again while the log has not changed
private var lastSnapshot: List<QueryEntry> = emptyList()
private var snapshotVersion = 0L
// Fires right away, then at most once a second while queries keep coming: a busy log refreshes
// the screen no more often than the old one-second polling did, and an idle one not at all
fun changes(): Flow<Long> = version.transform {
@@ -47,40 +38,32 @@ object QueryLog {
fun add(question: DnsMessage.Question?, status: QueryStatus, latencyMs: Int) {
if (question == null) return
val time = System.currentTimeMillis()
synchronized(this) {
if (entries.size >= MAX_ENTRIES) entries.removeFirst()
entries.addLast(
QueryEntry(nextId++, System.currentTimeMillis(), question.name.ifEmpty { "." }, question.type, status, latencyMs)
)
total++
when (status) {
QueryStatus.OK -> { latencySum += latencyMs; latencyCount++ }
QueryStatus.CACHED -> cached++
QueryStatus.BLOCKED -> blocked++
QueryStatus.FAILED -> failed++
}
entries.addLast(QueryEntry(nextId++, time, question.name.ifEmpty { "." }, question.type, status, latencyMs))
version.value++
}
// Hourly numbers for the charts; outside the lock above, as it takes a lock of its own
StatsStore.record(status, latencyMs, Companies.of(question.name), time)
}
// Newest first. Builds a real copy: on API 35+ List.reversed() resolves to a live JDK view,
// and on older devices that method does not exist at all
// and on older devices that method does not exist at all. While the log does not change the
// same list comes back, so a screen refreshed with it has nothing to update.
@Synchronized
fun snapshot(): List<QueryEntry> = List(entries.size) { entries[entries.size - 1 - it] }
@Synchronized
fun stats() = QueryStats(
total = total,
cached = cached,
blocked = blocked,
failed = failed,
avgLatencyMs = if (latencyCount == 0L) 0 else (latencySum / latencyCount).toInt(),
)
fun snapshot(): List<QueryEntry> {
val current = version.value
if (snapshotVersion != current) {
lastSnapshot = List(entries.size) { entries[entries.size - 1 - it] }
snapshotVersion = current
}
return lastSnapshot
}
@Synchronized
fun clear() {
entries.clear()
total = 0; cached = 0; blocked = 0; failed = 0; latencySum = 0; latencyCount = 0
version.value++
}
}
@@ -0,0 +1,379 @@
package cc.skysparkle.sparkledns
import androidx.annotation.DrawableRes
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
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.rememberScrollState
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
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.drawBehind
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
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.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
@Composable
fun SettingsScreen(
bottomPadding: Dp,
onOpenApps: () -> Unit,
onOpenAbout: () -> Unit,
modifier: Modifier = Modifier,
) {
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) }
var customUrl by remember { mutableStateOf(prefs.customUrl) }
var customBootstrap by remember { mutableStateOf(prefs.customBootstrap) }
var customHttp3 by remember { mutableStateOf(prefs.customHttp3) }
var keyInput by remember { mutableStateOf(prefs.skysparkleKey) }
var testResult by rememberSaveable(stateSaver = TestResultSaver) { mutableStateOf<TestResult?>(null) }
var shownResult by rememberSaveable(stateSaver = TestResultSaver) { mutableStateOf<TestResult?>(null) } // kept while the card animates out
var testing by remember { mutableStateOf(false) }
val excludedCount = remember { prefs.excludedApps.size }
val isCustom = selected == Providers.CUSTOM_ID
val customValid = remember(customUrl) { customUrl.trim().toHttpUrlOrNull()?.isHttps == true }
val keyValid = remember(keyInput) { SkysparkleKey.parse(keyInput) != null }
val selectedProvider = remember(selected, customUrl, customBootstrap, customHttp3, keyInput) { prefs.resolve() }
val canConnect = selectedProvider.url.toHttpUrlOrNull()?.isHttps == true
// Picking a server never touches a live connection; switching is an explicit action
val pendingSwitch = active?.let { it != selectedProvider && canConnect } == true
var busy by rememberVpnBusy(active)
fun select(id: String) {
selected = id
prefs.providerId = id
testResult = null
}
fun runTest() {
val provider = prefs.resolve()
testing = true
testResult = null
scope.launch {
val result = withContext(Dispatchers.IO) { testProvider(context, provider) }
shownResult = result
testResult = result
testing = false
}
}
Column(
modifier = modifier
.verticalScroll(rememberScrollState())
.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))
SectionLabel(stringResource(R.string.servers), Modifier.padding(top = 8.dp))
Column(Modifier.fillMaxWidth().appCard()) {
Providers.builtIn.forEachIndexed { index, provider ->
if (index > 0) ListDivider()
ServerRow(
title = provider.name,
subtitle = hostOf(provider.url) + if (provider.http3) " · HTTP/3" else "",
selected = selected == provider.id,
onPolicy = provider.policy?.let { url -> { openUrl(context, url) } },
onDonate = provider.donate?.let { url -> { openUrl(context, url) } },
onClick = { select(provider.id) },
)
if (provider.id == Providers.DEFAULT_ID) {
AnimatedVisibility(visible = selected == Providers.DEFAULT_ID, enter = Motion.expandIn, exit = Motion.collapseOut) {
KeyField(
value = keyInput,
valid = keyValid,
onChange = {
keyInput = it
// Saved as the bare key, also when the whole address was pasted
prefs.skysparkleKey = SkysparkleKey.parse(it) ?: it.trim()
testResult = null
},
onGetKey = { openUrl(context, SkysparkleKey.SIGNUP_URL) },
)
}
}
}
ListDivider()
ServerRow(
title = stringResource(R.string.custom),
subtitle = if (customUrl.trim() == "https://" || customUrl.isBlank()) "DNS-over-HTTPS (RFC 8484)" else hostOf(customUrl),
selected = isCustom,
onClick = { select(Providers.CUSTOM_ID) },
)
AnimatedVisibility(visible = isCustom, enter = Motion.expandIn, exit = Motion.collapseOut) {
Column(
Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
OutlinedTextField(
value = customUrl,
onValueChange = { customUrl = it; prefs.customUrl = it },
label = { Text(stringResource(R.string.custom_url)) },
singleLine = true,
isError = !customValid,
shape = RoundedCornerShape(14.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Next),
modifier = Modifier.fillMaxWidth(),
)
if (!customValid) {
Text(stringResource(R.string.invalid_url), color = Palette.Blocked, fontSize = 12.sp)
}
OutlinedTextField(
value = customBootstrap,
onValueChange = { customBootstrap = it; prefs.customBootstrap = it },
label = { Text(stringResource(R.string.custom_bootstrap)) },
singleLine = true,
shape = RoundedCornerShape(14.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Done),
modifier = Modifier.fillMaxWidth(),
)
Row(
modifier = Modifier
.fillMaxWidth()
.toggleable(
value = customHttp3,
role = Role.Switch,
onValueChange = { customHttp3 = it; prefs.customHttp3 = it },
)
.padding(vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Text(stringResource(R.string.http3), color = Palette.Fg, fontSize = 15.sp)
Text(stringResource(R.string.http3_note), color = Palette.Fg3, fontSize = 12.sp)
}
Spacer(Modifier.width(12.dp))
AppSwitch(checked = customHttp3, onCheckedChange = null)
}
}
}
}
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
OutlinedButton(
onClick = ::runTest,
enabled = !testing && canConnect,
shape = RoundedCornerShape(16.dp),
modifier = Modifier
.weight(1f)
.height(48.dp),
) {
Icon(painterResource(R.drawable.ic_speed), contentDescription = null, modifier = Modifier.size(18.dp))
Spacer(Modifier.width(8.dp))
Text(stringResource(if (testing) R.string.testing else R.string.test), maxLines = 1)
}
// The button keeps its label while it animates out
val switchName = rememberLast(if (pendingSwitch) selectedProvider.displayName(context) else null).orEmpty()
AnimatedVisibility(visible = pendingSwitch, modifier = Modifier.weight(1f)) {
Button(
onClick = {
if (!busy) {
busy = true
sendAction(context, DohVpnService.ACTION_START)
}
},
enabled = !busy,
shape = RoundedCornerShape(16.dp),
modifier = Modifier
.fillMaxWidth()
.height(48.dp),
) {
Icon(painterResource(R.drawable.ic_swap), contentDescription = null, modifier = Modifier.size(18.dp))
Spacer(Modifier.width(8.dp))
Text(
stringResource(R.string.switch_to, switchName),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}
}
AnimatedVisibility(visible = testResult != null, enter = Motion.expandIn, exit = Motion.collapseOut) {
shownResult?.let { result ->
HintCard(
text = result.text,
icon = if (result.ok) R.drawable.ic_check else R.drawable.ic_alert,
tint = if (result.ok) CachedColor else Palette.Blocked,
onDismiss = { testResult = null },
)
}
}
SectionLabel(stringResource(R.string.settings_general), Modifier.padding(top = 8.dp))
Column(Modifier.fillMaxWidth().appCard()) {
NavRow(
icon = R.drawable.ic_tab_apps,
title = stringResource(R.string.settings_apps),
subtitle = if (excludedCount > 0) stringResource(R.string.apps_count, excludedCount)
else stringResource(R.string.settings_apps_desc),
onClick = onOpenApps,
)
ListDivider()
NavRow(
icon = R.drawable.ic_tab_info,
title = stringResource(R.string.tab_about),
subtitle = "${stringResource(R.string.about_version)} ${BuildConfig.VERSION_NAME}",
onClick = onOpenAbout,
)
}
}
}
// Access key for the Skysparkle server, with a link to the account page where keys are made
@Composable
internal fun KeyField(value: String, valid: Boolean, onChange: (String) -> Unit, onGetKey: () -> Unit, modifier: Modifier = Modifier) {
val showError = value.isNotBlank() && !valid
Column(
modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
OutlinedTextField(
value = value,
onValueChange = onChange,
label = { Text(stringResource(R.string.key_label)) },
singleLine = true,
isError = showError,
shape = RoundedCornerShape(14.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Done),
modifier = Modifier.fillMaxWidth(),
)
Text(
stringResource(if (showError) R.string.key_invalid else R.string.key_hint),
color = if (showError) Palette.Blocked else Palette.Fg3,
fontSize = 12.sp,
)
OutlinedButton(onClick = onGetKey, shape = RoundedCornerShape(14.dp)) {
Text(stringResource(R.string.key_get))
}
}
}
@Composable
private fun ServerRow(
title: String,
subtitle: String,
selected: Boolean,
onPolicy: (() -> Unit)? = null,
onDonate: (() -> Unit)? = null,
onClick: () -> Unit,
) {
val highlight by animateColorAsState(
if (selected) Palette.Accent.copy(alpha = 0.06f) else Color.Transparent,
animationSpec = Motion.color,
label = "highlight",
)
Row(
modifier = Modifier
.fillMaxWidth()
// Read when drawing, so the fade does not recompose the row every frame
.drawBehind { drawRect(highlight) }
.selectable(selected = selected, onClick = onClick, role = Role.RadioButton)
.heightIn(min = 60.dp)
.padding(start = 16.dp, end = 8.dp, top = 8.dp, bottom = 8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Text(
title,
color = Palette.Fg,
fontSize = 15.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(subtitle, color = Palette.Fg3, fontSize = 12.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
if (onDonate != null) LinkButton(R.drawable.ic_donate, stringResource(R.string.donate), onDonate)
if (onPolicy != null) LinkButton(R.drawable.ic_policy, stringResource(R.string.about_privacy_policy), onPolicy)
Spacer(Modifier.width(4.dp))
if (selected) {
Icon(
painterResource(R.drawable.ic_check),
contentDescription = null,
tint = Palette.Accent,
modifier = Modifier.size(22.dp),
)
} else {
Spacer(Modifier.size(22.dp))
}
Spacer(Modifier.width(6.dp))
}
}
// Small button next to a server that opens one of its pages
@Composable
private fun LinkButton(@DrawableRes icon: Int, description: String, onClick: () -> Unit) {
IconButton(onClick = onClick, modifier = Modifier.size(40.dp)) {
Icon(painterResource(icon), contentDescription = description, tint = Palette.Fg3, modifier = Modifier.size(18.dp))
}
}
@Composable
private fun NavRow(@DrawableRes icon: Int, title: String, subtitle: String, onClick: () -> Unit) {
Row(
modifier = Modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.heightIn(min = 60.dp)
.padding(start = 16.dp, end = 12.dp, top = 10.dp, bottom = 10.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(painterResource(icon), contentDescription = null, tint = Palette.Accent, modifier = Modifier.size(24.dp))
Spacer(Modifier.width(14.dp))
Column(Modifier.weight(1f)) {
Text(title, color = Palette.Fg, fontSize = 15.sp, fontWeight = FontWeight.Bold)
Text(subtitle, color = Palette.Fg3, fontSize = 12.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
Chevron()
}
}
@@ -0,0 +1,259 @@
package cc.skysparkle.sparkledns
import android.content.Context
import android.util.Log
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.DataInputStream
import java.io.DataOutputStream
import java.io.File
import java.util.concurrent.Executors
class StatsSummary(
val total: Long,
val blocked: Long,
val cached: Long,
val avgLatencyMs: Int,
// Requests per company, indexed by Company.ordinal
val companies: LongArray,
)
class HourPoint(val total: Long, val blocked: Long)
// Hourly counters of the last 7 days for the charts. Only numbers are kept, never domains,
// and they never leave the device.
object StatsStore {
private const val HOUR_MS = 3_600_000L
private const val FILE = "stats.bin"
private const val SAVE_INTERVAL_MS = 60_000L
private val counters = HourlyCounters()
private var file: File? = null
// Bumped when the numbers change without a new query: loaded from disk
private val _version = MutableStateFlow(0)
val version: StateFlow<Int> = _version
private var lastSave = 0L
private var dirty = false
// Counts every change, so summary() can hand out its last result while nothing changed
private var changes = 0L
private var lastSummary: StatsSummary? = null
private var summaryChanges = 0L
private var summaryHours = 0
private var summaryHour = 0L
// Saves happen off the VPN threads, one at a time
private val writer = Executors.newSingleThreadExecutor { Thread(it, "stats-writer").apply { isDaemon = true } }
// The file is read outside the lock, so neither the DNS threads nor the screens wait for
// storage. Queries counted before it was read are added to the saved numbers.
fun init(context: Context) {
val target = File(context.filesDir, FILE)
val saved = read(target)
synchronized(this) {
file = target
if (saved != null) counters.merge(saved)
changes++
}
_version.value++
}
fun record(status: QueryStatus, latencyMs: Int, company: Company?, now: Long = System.currentTimeMillis()) {
val save = synchronized(this) {
counters.record(status, latencyMs, company, now / HOUR_MS)
changes++
dirty = true
if (file != null && now - lastSave >= SAVE_INTERVAL_MS) {
lastSave = now
true
} else {
false
}
}
// The writer thread encodes the numbers itself, so this DNS thread only hands the job over
if (save) writer.execute(::save)
}
// Totals of the last [hours] hours, the current one included. While nothing changed the same
// object comes back, so a screen refreshed with it has nothing to recompose.
fun summary(hours: Int, now: Long = System.currentTimeMillis()): StatsSummary = synchronized(this) {
val current = now / HOUR_MS
lastSummary?.takeIf { summaryChanges == changes && summaryHours == hours && summaryHour == current }
?: counters.summary(hours, current).also {
lastSummary = it
summaryChanges = changes
summaryHours = hours
summaryHour = current
}
}
// One point per hour, oldest first, ending with the current hour
fun hourly(hours: Int, now: Long = System.currentTimeMillis()): List<HourPoint> =
synchronized(this) { counters.hourly(hours, now / HOUR_MS) }
// Saves what is not on disk yet; called when the VPN stops
fun flush() {
val save = synchronized(this) {
if (file != null && dirty) {
lastSave = System.currentTimeMillis()
true
} else {
false
}
}
if (save) writer.execute(::save)
}
// Runs on the writer thread
private fun save() {
val (target, bytes) = synchronized(this) {
val current = file ?: return
dirty = false
current to counters.encode()
}
try {
val tmp = File(target.parentFile, "$FILE.tmp")
tmp.writeBytes(bytes)
if (!tmp.renameTo(target)) tmp.delete()
} catch (e: Exception) {
Log.w("SparkleDNS", "Cannot save statistics", e)
}
}
private fun read(source: File): HourlyCounters? {
if (!source.exists()) return null
return try {
HourlyCounters.decode(source.readBytes())
} catch (e: Exception) {
Log.w("SparkleDNS", "Cannot read statistics", e)
null
}
}
}
// The numbers behind StatsStore: a ring of hourly rows, each remembering which hour (since the
// epoch) it holds. Plain data without locks or Android; StatsStore takes care of both.
internal class HourlyCounters {
val hourIds = LongArray(HOURS) { -1L }
val rows = Array(HOURS) { LongArray(FIELDS) }
fun record(status: QueryStatus, latencyMs: Int, company: Company?, hour: Long) {
val row = row(hour)
row[TOTAL]++
when (status) {
QueryStatus.BLOCKED -> row[BLOCKED]++
QueryStatus.CACHED -> row[CACHED]++
QueryStatus.OK -> {
row[LATENCY_SUM] += latencyMs.toLong()
row[LATENCY_COUNT]++
}
QueryStatus.FAILED -> Unit
}
if (company != null) row[FIRST_COMPANY + company.ordinal]++
}
// Totals of the last [hours] hours up to [currentHour]
fun summary(hours: Int, currentHour: Long): StatsSummary {
val sums = LongArray(FIELDS)
for (back in 0 until hours.coerceIn(1, HOURS)) {
val id = currentHour - back
val index = slot(id)
if (hourIds[index] != id) continue
val row = rows[index]
for (field in 0 until FIELDS) sums[field] += row[field]
}
return StatsSummary(
total = sums[TOTAL],
blocked = sums[BLOCKED],
cached = sums[CACHED],
avgLatencyMs = if (sums[LATENCY_COUNT] == 0L) 0 else (sums[LATENCY_SUM] / sums[LATENCY_COUNT]).toInt(),
companies = sums.copyOfRange(FIRST_COMPANY, FIELDS),
)
}
// One point per hour, oldest first, ending with [currentHour]
fun hourly(hours: Int, currentHour: Long): List<HourPoint> {
val count = hours.coerceIn(1, HOURS)
return List(count) { position ->
val id = currentHour - (count - 1 - position)
val index = slot(id)
if (hourIds[index] == id) HourPoint(rows[index][TOTAL], rows[index][BLOCKED]) else HourPoint(0, 0)
}
}
// Saved hours are added to the ones counted since the start; a slot keeps the newer hour
fun merge(saved: HourlyCounters) {
for (index in 0 until HOURS) {
val id = saved.hourIds[index]
when {
id < 0 || id < hourIds[index] -> Unit
id == hourIds[index] -> for (field in 0 until FIELDS) rows[index][field] += saved.rows[index][field]
else -> {
hourIds[index] = id
saved.rows[index].copyInto(rows[index])
}
}
}
}
fun encode(): ByteArray {
val bytes = ByteArrayOutputStream(12 + HOURS * (FIELDS + 1) * 8)
DataOutputStream(bytes).use { out ->
out.writeInt(FORMAT)
out.writeInt(FIELDS)
out.writeInt(HOURS)
for (index in 0 until HOURS) {
out.writeLong(hourIds[index])
rows[index].forEach { out.writeLong(it) }
}
}
return bytes.toByteArray()
}
private fun slot(id: Long): Int = (((id % HOURS) + HOURS) % HOURS).toInt()
private fun row(id: Long): LongArray {
val index = slot(id)
if (hourIds[index] != id) {
hourIds[index] = id
rows[index].fill(0L)
}
return rows[index]
}
companion object {
const val HOURS = 24 * 7
private const val FORMAT = 1
// Per hour: total, blocked, cached, latency sum and count, then one counter per company
private const val TOTAL = 0
private const val BLOCKED = 1
private const val CACHED = 2
private const val LATENCY_SUM = 3
private const val LATENCY_COUNT = 4
const val FIRST_COMPANY = 5
val FIELDS = FIRST_COMPANY + Company.entries.size
// Files from a version with fewer companies load fine: the new counters start at zero.
// Null for a file of another format.
fun decode(bytes: ByteArray): HourlyCounters? {
DataInputStream(ByteArrayInputStream(bytes)).use { input ->
if (input.readInt() != FORMAT) return null
val fields = input.readInt()
if (input.readInt() != HOURS || fields < FIRST_COMPANY) return null
val result = HourlyCounters()
for (index in 0 until HOURS) {
result.hourIds[index] = input.readLong()
for (field in 0 until fields) {
val value = input.readLong()
if (field < FIELDS) result.rows[index][field] = value
}
}
return result
}
}
}
}
@@ -0,0 +1,275 @@
package cc.skysparkle.sparkledns
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
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
import androidx.compose.foundation.layout.heightIn
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
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Switch
import androidx.compose.material3.SwitchDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.darkColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
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
// One dark palette for the whole app
object Palette {
val Bg = Color(0xFF08090B)
val Card = Color(0xFF17181C)
val CardHigh = Color(0xFF1E2026)
val Line = Color(0xFF24262C)
val Track = Color(0xFF3A3C44)
val Fg = Color(0xFFF2F3F5)
val Fg2 = Color(0xFF9A9DA6)
val Fg3 = Color(0xFF7E828C)
val Accent = Color(0xFF7FB2FF)
val AccentSoft = Color(0x297FB2FF)
val AccentInk = Color(0xFF0A0B0D)
val Blocked = Color(0xFFFF6B7D)
val Nav = Color(0xEB1E2026)
val NavIcon = Color(0xFF8A8E98)
}
internal val AppColors = darkColorScheme(
primary = Palette.Accent,
onPrimary = Palette.AccentInk,
primaryContainer = Color(0xFF22324A),
onPrimaryContainer = Palette.Accent,
secondary = Palette.Accent,
onSecondary = Palette.AccentInk,
secondaryContainer = Color(0xFF22324A),
onSecondaryContainer = Palette.Accent,
background = Palette.Bg,
onBackground = Palette.Fg,
surface = Palette.Bg,
onSurface = Palette.Fg,
surfaceVariant = Palette.Card,
onSurfaceVariant = Palette.Fg2,
surfaceContainerLowest = Palette.Bg,
surfaceContainerLow = Palette.Card,
surfaceContainer = Palette.Card,
surfaceContainerHigh = Palette.CardHigh,
surfaceContainerHighest = Palette.Card,
outline = Palette.Track,
outlineVariant = Palette.Line,
error = Palette.Blocked,
onError = Palette.AccentInk,
errorContainer = Color(0xFF3A1C22),
onErrorContainer = Color(0xFFFFD9DE),
)
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
fun AppSwitch(
checked: Boolean,
onCheckedChange: ((Boolean) -> Unit)?,
modifier: Modifier = Modifier,
enabled: Boolean = true,
) {
Switch(
checked = checked,
onCheckedChange = onCheckedChange,
modifier = modifier,
enabled = enabled,
colors = appSwitchColors(),
)
}
@Composable
private fun appSwitchColors() = SwitchDefaults.colors(
checkedThumbColor = Color.White,
checkedTrackColor = Palette.Accent,
checkedBorderColor = Palette.Accent,
uncheckedThumbColor = Palette.Fg2,
uncheckedTrackColor = Palette.Track,
uncheckedBorderColor = Palette.Track,
)
// Big bold title of a main tab
@Composable
fun ScreenTitle(text: String, modifier: Modifier = Modifier) {
Text(
text,
modifier = modifier,
color = Palette.Fg,
fontSize = 24.sp,
fontWeight = FontWeight.ExtraBold,
letterSpacing = (-0.3).sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
@Composable
fun SectionLabel(text: String, modifier: Modifier = Modifier) {
Text(
text,
modifier = modifier.padding(start = 4.dp, top = 8.dp, bottom = 2.dp),
color = Palette.Fg2,
fontSize = 13.sp,
fontWeight = FontWeight.Bold,
)
}
// Back arrow and title of a page opened from a tab
@Composable
fun PageHeader(
title: String,
onBack: () -> Unit,
modifier: Modifier = Modifier,
action: (@Composable () -> Unit)? = null,
) {
Row(
modifier = modifier
.fillMaxWidth()
.heightIn(min = 56.dp)
.padding(start = 4.dp, end = 12.dp),
verticalAlignment = Alignment.CenterVertically,
) {
IconButton(onClick = onBack) {
Icon(painterResource(R.drawable.ic_back), contentDescription = stringResource(R.string.back), tint = Palette.Fg)
}
Text(
title,
modifier = Modifier.weight(1f),
color = Palette.Fg,
fontSize = 20.sp,
fontWeight = FontWeight.ExtraBold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
action?.invoke()
}
}
// 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) {
Box(modifier, contentAlignment = Alignment.TopCenter) {
Column(
Modifier
.fillMaxHeight()
.widthIn(max = MaxContentWidth + 32.dp)
.fillMaxWidth()
) {
PageHeader(title, onBack)
Box(
Modifier
.weight(1f)
.fillMaxSize()
.navigationBarsPadding(),
content = content,
)
}
}
}
private val SearchTextStyle = TextStyle(color = Palette.Fg, fontSize = 14.sp)
@Composable
fun SearchField(
value: String,
onValueChange: (String) -> Unit,
placeholder: String,
modifier: Modifier = Modifier,
trailing: (@Composable () -> Unit)? = null,
) {
Row(
modifier = modifier
.fillMaxWidth()
.height(48.dp)
.clip(RoundedCornerShape(16.dp))
.background(Palette.Card)
.padding(start = 14.dp, end = if (trailing != null) 2.dp else 14.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
painterResource(R.drawable.ic_search),
contentDescription = null,
tint = Palette.Fg3,
modifier = Modifier.size(18.dp),
)
Spacer(Modifier.width(10.dp))
Box(Modifier.weight(1f), contentAlignment = Alignment.CenterStart) {
if (value.isEmpty()) {
Text(placeholder, color = Palette.Fg3, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
BasicTextField(
value = value,
onValueChange = onValueChange,
modifier = Modifier.fillMaxWidth(),
singleLine = true,
textStyle = SearchTextStyle,
cursorBrush = SolidColor(Palette.Accent),
)
}
trailing?.invoke()
}
}
// Thin line between the rows of a card
@Composable
fun ListDivider(modifier: Modifier = Modifier) {
HorizontalDivider(modifier = modifier.padding(horizontal = 16.dp), color = Palette.Line)
}
// The arrow at the end of a row that opens something
@Composable
fun Chevron(modifier: Modifier = Modifier) {
Icon(
painterResource(R.drawable.ic_chevron),
contentDescription = null,
tint = Palette.Fg3,
modifier = modifier.size(20.dp),
)
}
@@ -1,18 +1,17 @@
package cc.skysparkle.sparkledns
import android.content.Context
import androidx.annotation.DrawableRes
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.animation.togetherWith
import androidx.annotation.StringRes
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
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
@@ -28,21 +27,21 @@ 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.rememberUpdatedState
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.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.res.imageResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
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
@@ -52,6 +51,28 @@ import java.util.Locale
val CachedColor = Color(0xFF7FD1AE)
val WarningColor = Color(0xFFFFB86B)
// The 512 px logo, decoded once while the screens are in use. Home shows it each time the tab
// opens, and decoding it there would cost the main thread a frame.
object AppLogo {
@Volatile
private var bitmap: ImageBitmap? = null
// Started with the activity, so the first frame of Home usually finds the logo decoded
fun preload(context: Context) {
if (bitmap != null) return
val appContext = context.applicationContext
Thread({ runCatching { get(appContext) } }, "logo-load").start()
}
@Synchronized
fun get(context: Context): ImageBitmap =
bitmap ?: ImageBitmap.imageResource(context.resources, R.drawable.app_logo).also { bitmap = it }
fun clear() {
bitmap = null
}
}
// Icon on a soft circle of its own color
@Composable
fun IconBadge(@DrawableRes icon: Int, tint: Color = MaterialTheme.colorScheme.primary, size: Dp = 40.dp) {
@@ -66,52 +87,6 @@ fun IconBadge(@DrawableRes icon: Int, tint: Color = MaterialTheme.colorScheme.pr
}
}
@Composable
fun SectionHeader(
title: String,
@DrawableRes icon: Int? = null,
modifier: Modifier = Modifier,
action: (@Composable () -> Unit)? = null,
) {
Row(
modifier = modifier
.fillMaxWidth()
.heightIn(min = 40.dp)
.padding(top = 8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
if (icon != null) {
Icon(
painterResource(icon),
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.size(18.dp),
)
Spacer(Modifier.width(8.dp))
}
Text(
title,
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.weight(1f),
)
action?.invoke()
}
}
@Composable
fun Pill(text: String, color: Color) {
Text(
text,
style = MaterialTheme.typography.labelMedium,
color = color,
modifier = Modifier
.clip(RoundedCornerShape(50))
.background(color.copy(alpha = 0.14f))
.padding(horizontal = 10.dp, vertical = 3.dp),
)
}
@Composable
fun HintCard(
text: String,
@@ -160,39 +135,14 @@ fun HintCard(
}
}
@Composable
fun StatColumn(value: String, label: String, modifier: Modifier = Modifier) {
Column(modifier, horizontalAlignment = Alignment.CenterHorizontally) {
// Numbers roll up when they change
AnimatedContent(
targetState = value,
transitionSpec = {
(slideInVertically(Motion.slide) { it / 2 } + fadeIn(Motion.enterFade)) togetherWith
(slideOutVertically(Motion.slide) { -it / 2 } + fadeOut(Motion.exitFade)) using
Motion.sizeTransform()
},
label = "stat",
) { shown ->
Text(shown, style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.SemiBold, maxLines = 1)
}
Text(
label,
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
textAlign = TextAlign.Center,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
}
}
private class Last<T>(var value: T?)
// The last non-null value, so a card can keep showing its text while it animates out
@Composable
fun StatDivider() {
Box(
Modifier
.size(width = 1.dp, height = 32.dp)
.background(MaterialTheme.colorScheme.outlineVariant)
)
fun <T : Any> rememberLast(value: T?): T? {
val last = remember { Last<T>(null) }
if (value != null) last.value = value
return last.value
}
// Runs [onChange] when the query log changes, at most once a second and only while the screen
@@ -208,13 +158,6 @@ fun OnQueryLogChange(onChange: () -> Unit) {
}
}
@Composable
fun rememberLiveStats(): QueryStats {
var stats by remember { mutableStateOf(QueryLog.stats()) }
OnQueryLogChange { stats = QueryLog.stats() }
return stats
}
// Called from composition only, i.e. on the main thread; rebuilt when the locale changes
private var countFormat: Pair<Locale, NumberFormat>? = null
@@ -225,9 +168,6 @@ fun formatCount(value: Long): String {
return format.format(value)
}
fun cachePercent(stats: QueryStats): String =
"${if (stats.total == 0L) 0 else stats.cached * 100 / stats.total}%"
// Rows of one visual group share a background; only the outer corners are rounded
fun groupedShape(first: Boolean, last: Boolean, radius: Dp = 16.dp) = RoundedCornerShape(
topStart = if (first) radius else 0.dp,
@@ -238,3 +178,58 @@ fun groupedShape(first: Boolean, last: Boolean, radius: Dp = 16.dp) = RoundedCor
val groupedBackground: Color
@Composable get() = MaterialTheme.colorScheme.surfaceContainerHighest
// Short numbers for stat tiles: 812, 7.27k, 48.1k, 312k, 1.2M (decimal separator of the locale)
fun formatCompact(value: Long): String {
val locale = Locale.getDefault()
return when {
value < 1_000 -> formatCount(value)
value < 10_000 -> String.format(locale, "%.2fk", value / 1_000.0)
value < 100_000 -> String.format(locale, "%.1fk", value / 1_000.0)
value < 1_000_000 -> String.format(locale, "%.0fk", value / 1_000.0)
else -> String.format(locale, "%.1fM", value / 1_000_000.0)
}
}
@Composable
fun EmptyState(icon: Int, text: String) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 40.dp),
horizontalAlignment = Alignment.CenterHorizontally,
) {
IconBadge(icon, MaterialTheme.colorScheme.onSurfaceVariant, size = 64.dp)
Spacer(Modifier.height(12.dp))
Text(
text,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
textAlign = TextAlign.Center,
)
}
}
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))
}
}
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "add" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M132.0,191.5L123.0,191.5L122.3,191.0L122.0,133.0L64.0,132.7L63.5,132.0L63.5,123.0L64.0,122.3L122.0,122.0L122.3,64.0L123.0,63.5L132.0,63.5L132.7,64.0L133.0,122.0L191.0,122.3L191.5,123.0L191.5,132.0L191.0,132.7L133.0,133.0L132.7,191.0Z" />
android:pathData="M 11.5 12.5 H 6 v -1 h 5.5 V 6 h 1 v 5.5 H 18 v 1 h -5.5 V 18 h -1 z" />
</vector>
@@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M175.0,214.5L29.0,214.5L28.5,214.0L28.5,34.0L29.0,33.3L124.0,33.3L124.5,34.0L124.5,75.0L125.0,75.7L226.3,76.0L226.5,164.0L226.0,164.5L217.0,164.5L215.7,164.0L215.7,87.0L215.0,86.5L172.0,86.5L125.0,86.5L124.5,87.0L124.5,118.0L125.0,118.5L149.0,118.5L150.0,119.0L150.0,129.0L126.0,129.3L124.7,130.0L125.0,161.0L149.0,161.3L150.0,162.0L150.0,171.0L149.0,171.7L125.0,172.0L124.7,203.0L126.0,203.7L175.0,203.7L175.5,205.0L175.5,214.0ZM71.3,75.0L71.0,44.0L39.5,44.0L39.3,75.0L40.0,75.7L70.0,75.7ZM114.0,75.0L114.0,45.0L113.5,44.0L82.0,44.0L82.0,75.0L83.0,75.7L113.0,75.7ZM71.3,118.0L71.0,86.7L40.0,86.5L39.3,87.0L39.3,118.0L40.0,118.5L70.0,118.5ZM114.0,118.0L114.0,87.0L113.0,86.5L83.0,86.5L82.0,87.0L82.0,118.0L83.0,118.5L113.0,118.5ZM186.0,129.0L175.7,129.0L175.5,119.0L176.0,118.5L185.0,118.5L186.3,119.0ZM71.0,161.0L71.0,129.5L40.0,129.3L39.3,130.0L39.5,161.0ZM114.0,161.0L114.0,130.0L113.0,129.3L83.0,129.3L82.0,130.0L82.0,160.0L82.5,161.0ZM186.0,171.5L176.0,171.7L175.5,171.0L175.5,162.0L176.0,161.3L186.0,161.5ZM71.3,203.0L71.0,172.0L39.5,172.0L39.3,203.0L40.0,203.7L70.0,203.7ZM114.0,203.0L114.0,173.0L113.5,172.0L82.0,172.0L82.0,203.0L83.0,203.7L113.0,203.7ZM226.0,235.7L217.0,235.7L215.7,235.0L215.7,215.0L215.0,214.5L195.0,214.5L194.5,214.0L194.5,205.0L195.0,203.7L215.0,203.7L215.7,203.0L216.0,182.7L226.0,182.5L226.5,183.0L226.5,203.0L227.0,203.7L247.5,204.0L247.7,214.0L247.0,214.5L227.0,214.5L226.5,215.0L226.5,235.0Z" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "error" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M137.0,223.0L130.0,223.5L117.0,223.0L105.0,221.0L98.0,219.0L90.0,216.0L80.0,211.0L68.0,203.0L60.0,196.0L53.7,189.0L47.7,181.0L43.5,174.0L37.7,162.0L34.7,153.0L31.7,135.0L31.5,125.0L32.0,117.0L34.0,105.0L36.0,98.0L39.0,90.0L44.0,80.0L52.0,68.0L59.0,60.0L66.0,53.7L74.0,47.7L81.0,43.5L93.0,37.7L102.0,34.7L120.0,31.7L130.0,31.5L138.0,32.0L150.0,34.0L157.0,36.0L165.0,39.0L175.0,44.0L187.0,52.0L195.0,59.0L201.3,66.0L207.3,74.0L211.5,81.0L217.3,93.0L220.3,102.0L223.3,120.0L223.5,130.0L223.0,138.0L221.0,150.0L219.0,157.0L216.0,165.0L211.0,175.0L203.0,187.0L196.0,195.0L189.0,201.3L181.0,207.3L174.0,211.5L162.0,217.3L153.0,220.3ZM139.0,212.0L145.0,211.3L159.0,207.3L167.0,203.7L174.0,199.5L185.0,191.0L193.7,182.0L199.0,175.0L207.0,160.0L209.3,153.0L211.5,144.0L212.5,136.0L212.7,123.0L211.3,110.0L207.3,96.0L203.7,88.0L199.5,81.0L191.0,70.0L182.0,61.3L175.0,56.0L160.0,48.0L153.0,45.7L144.0,43.5L136.0,42.5L123.0,42.3L110.0,43.7L96.0,47.7L88.0,51.3L81.0,55.5L70.0,64.0L61.3,73.0L56.0,80.0L48.0,95.0L45.7,102.0L43.5,111.0L42.5,119.0L42.3,132.0L43.7,145.0L47.7,159.0L51.3,167.0L55.5,174.0L64.0,185.0L73.0,193.7L80.0,199.0L95.0,207.0L102.0,209.3L111.0,211.5L123.0,212.7L132.0,212.7ZM132.0,139.7L123.0,139.7L122.3,139.0L122.3,77.0L123.0,75.7L132.0,75.7L132.7,77.0L132.7,139.0ZM128.0,175.0L126.0,175.0L123.0,173.3L121.3,171.0L121.0,169.0L122.0,165.0L124.0,163.0L128.0,162.0L131.0,163.0L132.0,164.0L133.0,165.0L134.0,168.0L133.5,171.0L132.3,173.0L130.0,174.7Z" />
android:pathData="M 12 16.462 q .262 0 .439 -.177 q .176 -.177 .176 -.439 q 0 -.261 -.177 -.438 T 12 15.23 t -.438 .177 t -.177 .438 t .177 .439 t .438 .177 m -.5 -3.308 h 1 v -6 h -1 z M 12.003 21 q -1.866 0 -3.51 -.708 q -1.643 -.709 -2.859 -1.924 t -1.925 -2.856 T 3 12.003 t .709 -3.51 Q 4.417 6.85 5.63 5.634 t 2.857 -1.925 T 11.997 3 t 3.51 .709 q 1.643 .708 2.859 1.922 t 1.925 2.857 t .709 3.509 t -.708 3.51 t -1.924 2.859 t -2.856 1.925 t -3.509 .709" />
</vector>
-10
View File
@@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M226.0,181.0L29.0,181.0L28.5,180.0L28.7,177.0L32.0,161.0L36.0,150.0L44.0,135.0L49.0,128.0L59.0,117.3L67.0,110.7L76.0,105.0L76.7,104.0L59.7,74.0L60.0,70.0L62.0,68.0L65.0,67.0L66.0,67.0L69.3,69.0L87.0,98.7L99.0,94.7L102.0,94.3L107.0,92.7L113.0,91.7L126.0,90.7L140.0,91.5L148.0,92.7L159.0,95.5L165.0,98.0L168.0,98.7L173.0,91.0L173.0,90.0L177.0,84.0L184.0,71.0L186.0,68.7L188.0,67.3L191.0,67.0L193.0,68.0L195.3,71.0L195.0,75.0L186.0,90.0L186.0,91.0L182.0,97.0L179.0,103.0L178.0,104.0L187.0,110.0L196.7,118.0L205.0,127.0L212.3,137.0L217.7,147.0L223.3,162.0L223.7,165.0L225.3,170.0L225.7,175.0L226.3,177.0L226.7,180.0ZM83.5,156.0L87.0,155.3L90.3,153.0L93.0,149.0L93.5,146.0L93.3,142.0L92.5,140.0L90.0,136.7L86.0,134.3L81.0,133.7L76.0,135.7L74.3,137.0L72.3,140.0L71.3,144.0L71.7,149.0L74.3,153.0L77.0,155.0L83.0,156.3ZM174.0,156.0L177.0,155.3L180.0,153.3L182.0,151.0L183.3,148.0L183.7,144.0L183.3,141.0L180.7,137.0L177.0,134.5L172.0,133.7L168.0,134.7L164.7,137.0L162.0,141.0L161.3,145.0L161.7,148.0L162.7,150.0L166.0,154.0L169.0,155.5L173.0,156.3Z" />
</vector>
+4 -5
View File
@@ -1,11 +1,10 @@
<!-- Material Symbols Light "arrow-back" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M128.0,201.7L127.0,201.7L53.3,128.0L53.3,127.0L127.0,53.3L128.0,53.3L134.7,60.0L134.3,61.0L74.3,121.0L73.7,122.0L74.0,122.3L201.0,122.3L202.3,123.0L202.3,132.0L201.0,132.7L73.5,133.0L134.3,194.0L134.7,195.0Z" />
android:pathData="m 6.921 12.5 l 5.793 5.792 L 12 19 l -7 -7 l 7 -7 l .714 .708 L 6.92 11.5 H 19 v 1 z" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "check-circle" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M101.0,184.0L49.0,132.0L48.5,131.0L49.0,130.3L56.0,123.7L101.0,168.7L102.0,168.3L199.0,71.3L200.0,72.0L206.0,78.0L206.3,79.0Z" />
android:pathData="m 10.562 15.908 l 6.396 -6.396 l -.708 -.708 l -5.688 5.688 l -2.85 -2.85 l -.708 .708 z M 12.003 21 q -1.866 0 -3.51 -.708 q -1.643 -.709 -2.859 -1.924 t -1.925 -2.856 T 3 12.003 t .709 -3.51 Q 4.417 6.85 5.63 5.634 t 2.857 -1.925 T 11.997 3 t 3.51 .709 q 1.643 .708 2.859 1.922 t 1.925 2.857 t .709 3.509 t -.708 3.51 t -1.924 2.859 t -2.856 1.925 t -3.509 .709" />
</vector>
+10
View File
@@ -0,0 +1,10 @@
<!-- Material Symbols Light "chevron-right" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="m 13.292 12 l -4.6 -4.6 l .708 -.708 L 14.708 12 L 9.4 17.308 l -.708 -.708 z" />
</vector>
-10
View File
@@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M127.0,202.3L49.0,202.3L48.0,202.0L32.0,186.0L30.0,183.0L28.3,179.0L27.7,176.0L28.0,171.0L30.0,166.0L35.0,160.0L142.0,49.0L147.0,45.7L152.0,44.7L157.0,45.0L160.0,46.0L165.0,49.7L209.3,94.0L213.3,100.0L214.0,104.0L214.0,109.0L211.0,116.0ZM227.0,202.3L167.7,202.0L178.0,191.5L227.0,191.5L227.5,192.0L227.5,201.0Z" />
</vector>
+5 -5
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "close" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="#FFFFFFFF"
android:strokeWidth="14"
android:pathData="M64,64L192,192M192,64L64,192" />
android:fillColor="#FFFFFFFF"
android:pathData="m 6.4 18.308 l -.708 -.708 l 5.6 -5.6 l -5.6 -5.6 l .708 -.708 l 5.6 5.6 l 5.6 -5.6 l .708 .708 l -5.6 5.6 l 5.6 5.6 l -.708 .708 l -5.6 -5.6 z" />
</vector>
+10
View File
@@ -0,0 +1,10 @@
<!-- Material Symbols Light "code" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M 8 17.308 L 2.692 12 L 8 6.692 l .714 .714 l -4.6 4.6 L 8.708 16.6 z m 8 0 l -.713 -.714 l 4.6 -4.6 L 15.292 7.4 L 16 6.692 L 21.308 12 z" />
</vector>
+10
View File
@@ -0,0 +1,10 @@
<!-- Material Symbols Light "content-copy" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M 9.116 17 q -.691 0 -1.153 -.462 T 7.5 15.385 V 4.615 q 0 -.69 .463 -1.153 T 9.116 3 h 7.769 q .69 0 1.153 .462 t .462 1.153 v 10.77 q 0 .69 -.462 1.152 T 16.884 17 z m -3 3 q -.691 0 -1.153 -.462 T 4.5 18.385 V 6.615 h 1 v 11.77 q 0 .23 .192 .423 t .423 .192 h 8.77 v 1 z" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "copyright" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M137.0,223.0L130.0,223.5L117.0,223.0L105.0,221.0L98.0,219.0L90.0,216.0L80.0,211.0L68.0,203.0L60.0,196.0L53.7,189.0L47.7,181.0L43.5,174.0L37.7,162.0L34.7,153.0L31.7,135.0L31.5,125.0L32.0,117.0L34.0,105.0L36.0,98.0L39.0,90.0L44.0,80.0L52.0,68.0L59.0,60.0L66.0,53.7L74.0,47.7L81.0,43.5L93.0,37.7L102.0,34.7L120.0,31.7L130.0,31.5L138.0,32.0L150.0,34.0L157.0,36.0L165.0,39.0L175.0,44.0L187.0,52.0L195.0,59.0L201.3,66.0L207.3,74.0L211.5,81.0L217.3,93.0L220.3,102.0L223.3,120.0L223.5,130.0L223.0,138.0L221.0,150.0L219.0,157.0L216.0,165.0L211.0,175.0L203.0,187.0L196.0,195.0L189.0,201.3L181.0,207.3L174.0,211.5L162.0,217.3L153.0,220.3ZM139.0,212.0L145.0,211.3L159.0,207.3L167.0,203.7L174.0,199.5L185.0,191.0L193.7,182.0L199.0,175.0L207.0,160.0L209.3,153.0L211.5,144.0L212.5,136.0L212.7,123.0L211.3,110.0L207.3,96.0L203.7,88.0L199.5,81.0L191.0,70.0L182.0,61.3L175.0,56.0L160.0,48.0L153.0,45.7L144.0,43.5L136.0,42.5L123.0,42.3L110.0,43.7L96.0,47.7L88.0,51.3L81.0,55.5L70.0,64.0L61.3,73.0L56.0,80.0L48.0,95.0L45.7,102.0L43.5,111.0L42.5,119.0L42.3,132.0L43.7,145.0L47.7,159.0L51.3,167.0L55.5,174.0L64.0,185.0L73.0,193.7L80.0,199.0L95.0,207.0L102.0,209.3L111.0,211.5L123.0,212.7L132.0,212.7ZM151.0,164.3L106.0,164.7L103.0,164.0L101.5,162.0L100.7,160.0L100.7,96.0L102.0,92.0L104.0,90.7L149.0,90.3L152.0,91.0L153.5,93.0L154.3,95.0L154.0,111.3L144.0,111.5L143.5,111.0L143.5,102.0L143.0,100.7L112.0,100.7L111.5,102.0L111.7,154.0L143.0,154.3L143.5,153.0L143.5,144.0L144.0,143.5L154.0,143.7L154.3,159.0L153.0,163.0Z" />
android:pathData="M 10 15.5 h 4 q .213 0 .356 -.144 T 14.5 15 v -1.5 h -1 v 1 h -3 v -5 h 3 v 1 h 1 V 9 q 0 -.214 -.144 -.357 T 14 8.5 h -4 q -.213 0 -.356 .144 T 9.5 9 v 6 q 0 .213 .144 .356 T 10 15.5 m 2.003 5.5 q -1.867 0 -3.51 -.708 q -1.643 -.709 -2.859 -1.924 t -1.925 -2.856 T 3 12.003 t .709 -3.51 Q 4.417 6.85 5.63 5.634 t 2.857 -1.925 T 11.997 3 t 3.51 .709 q 1.643 .708 2.859 1.922 t 1.925 2.857 t .709 3.509 t -.708 3.51 t -1.924 2.859 t -2.856 1.925 t -3.509 .709" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "delete" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M179.0,212.3L79.0,212.7L75.0,212.0L71.0,210.0L67.7,207.0L65.0,203.0L63.7,199.0L63.5,196.0L63.5,64.0L63.0,63.5L54.0,63.5L52.7,63.0L53.0,53.0L95.0,52.7L95.5,52.0L95.5,45.0L96.0,44.5L159.0,44.5L159.5,45.0L159.5,52.0L160.0,52.7L202.0,53.0L202.3,63.0L201.0,63.5L192.0,63.5L191.5,64.0L191.5,197.0L190.5,202.0L189.0,205.0L185.0,209.3L182.0,211.3ZM114.7,180.0L114.7,86.0L114.0,84.7L105.0,84.7L104.0,85.0L104.0,180.0L105.0,180.7L114.0,180.7ZM151.0,180.0L151.0,86.0L150.0,84.7L141.0,84.7L140.3,86.0L140.3,180.0L141.0,180.7L150.0,180.7Z" />
android:pathData="M 7.616 20 q -.691 0 -1.153 -.462 T 6 18.384 V 6 H 5 V 5 h 4 v -.77 h 6 V 5 h 4 v 1 h -1 v 12.385 q 0 .69 -.462 1.153 T 16.384 20 z m 2.192 -3 h 1 V 8 h -1 z m 3.384 0 h 1 V 8 h -1 z" />
</vector>
@@ -0,0 +1,10 @@
<!-- Material Symbols Light "delete-sweep" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M 14.885 17.5 v -1 h 3 v 1 z m 0 -8 v -1 h 6 v 1 z m 0 4 v -1 h 5 v 1 z M 4.115 8 h -1 V 7 h 3.731 v -.885 h 2.538 V 7 h 3.732 v 1 h -1 v 8.385 q 0 .69 -.463 1.153 T 10.5 18 H 5.73 q -.69 0 -1.152 -.462 t -.462 -1.153 z" />
</vector>
+5 -16
View File
@@ -1,21 +1,10 @@
<!-- Material Symbols Light "volunteer-activism" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M128,38 A90,90 0 1,1 128,218 A90,90 0 1,1 128,38 Z"
android:strokeColor="#FFFFFFFF"
android:strokeWidth="11" />
<path
android:pathData="M156,99 C151,88 141,82 128,82 C112,82 100,91 100,105 C100,120 113,125 128,128 C144,131 158,137 158,153 C158,167 145,175 128,175 C113,175 101,168 97,156"
android:strokeColor="#FFFFFFFF"
android:strokeWidth="11"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M128,64 L128,82 M128,175 L128,193"
android:strokeColor="#FFFFFFFF"
android:strokeWidth="11"
android:strokeLineCap="round" />
android:fillColor="#FFFFFFFF"
android:pathData="M 6.385 19.583 v -6.737 h 2.08 q .137 0 .283 .028 t .283 .078 l 6.021 2.21 q .446 .163 .736 .536 q .289 .373 .289 .839 q 0 .275 -.18 .446 t -.443 .17 h -1.202 q -.51 0 -.995 -.06 t -.951 -.226 l -1.792 -.644 l -.287 .744 l 1.964 .675 q .472 .16 .976 .22 q .504 .061 1.021 .061 h 5.158 q .685 0 1.17 .45 T 21 19.5 l -6.994 2.308 z m -4 1.417 v -8.154 h 3 V 21 z m 13.307 -8.615 l -3.765 -3.608 q -.66 -.635 -1.101 -1.422 q -.442 -.788 -.442 -1.709 q 0 -1.106 .77 -1.876 T 13.032 3 q .819 0 1.49 .443 t 1.171 1.076 q .5 -.633 1.172 -1.076 q .67 -.443 1.49 -.443 q 1.106 0 1.876 .77 T 21 5.646 q 0 .921 -.438 1.709 t -1.099 1.422 z" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "keyboard-arrow-down" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M128.0,201.7L127.0,201.7L53.3,128.0L53.3,127.0L60.0,120.3L61.0,120.7L121.0,180.7L122.0,181.3L122.3,181.0L122.3,54.0L123.0,52.7L132.0,52.7L132.7,54.0L133.0,181.5L194.0,120.7L195.0,120.3L201.7,127.0L201.7,128.0Z" />
android:pathData="M 12 14.708 L 6.692 9.4 l .708 -.708 l 4.6 4.6 l 4.6 -4.6 l .708 .708 z" />
</vector>
+10
View File
@@ -0,0 +1,10 @@
<!-- Material Symbols Light "filter-alt" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M 11.77 19 q -.33 0 -.55 -.22 t -.22 -.55 v -5.576 L 5.604 5.83 q -.202 -.27 -.055 -.55 t .47 -.28 h 11.962 q .323 0 .47 .28 q .147 .282 -.055 .55 L 13 12.655 v 5.577 q 0 .328 -.22 .549 t -.55 .22 z" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "headphones" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M206.0,180.3L84.0,180.7L80.0,180.0L76.0,178.0L73.0,175.0L69.7,170.0L68.7,164.0L68.7,49.0L70.0,42.0L71.7,39.0L75.0,35.3L79.0,32.7L82.0,31.7L85.0,31.5L202.0,31.5L207.0,32.5L213.0,36.0L215.3,39.0L217.3,43.0L218.3,48.0L218.3,163.0L218.0,167.0L215.0,174.0L212.0,177.0ZM131.0,156.0L138.0,154.7L142.0,152.3L148.0,146.0L150.3,140.0L151.0,135.0L151.0,74.0L172.0,73.7L175.0,73.0L177.0,71.7L178.0,71.0L180.0,66.0L179.0,62.0L177.7,60.0L175.0,58.0L171.0,57.3L151.0,57.3L148.0,57.7L145.0,60.0L143.0,63.0L142.7,65.0L142.7,118.0L142.0,118.7L139.0,116.0L138.0,116.0L137.0,115.0L132.0,113.7L126.0,113.7L122.0,114.7L118.0,116.7L114.0,120.0L111.0,124.0L109.5,127.0L108.5,131.0L108.5,139.0L109.7,143.0L112.7,148.0L118.0,153.0L122.0,155.0L129.0,156.3ZM177.0,212.0L175.0,212.7L52.0,212.7L48.0,212.0L44.0,210.0L41.0,207.0L37.7,202.0L36.7,196.0L36.7,76.0L38.0,72.0L40.0,70.5L44.0,70.5L46.3,72.0L47.5,75.0L47.5,196.0L49.3,200.0L52.0,201.7L55.0,202.3L175.0,202.3L178.0,203.7L179.3,206.0L179.0,210.0Z" />
android:pathData="M 8.077 20 H 5.616 q -.691 0 -1.153 -.462 T 4 18.384 V 12 q 0 -1.664 .626 -3.118 T 6.34 6.34 t 2.542 -1.714 T 12 4 t 3.118 .626 T 17.66 6.34 t 1.714 2.542 T 20 12 v 6.385 q 0 .69 -.462 1.152 T 18.384 20 h -2.461 v -6.154 H 19 V 12 q 0 -2.925 -2.037 -4.962 T 12 5 T 7.038 7.038 T 5 12 v 1.846 h 3.077 z" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "sports-esports" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M131.0,222.0L128.0,222.5L123.0,222.0L113.0,217.0L100.0,209.0L99.0,209.0L93.0,205.0L80.0,198.0L74.0,194.0L73.0,194.0L67.0,190.0L54.0,183.0L48.0,179.0L44.7,175.0L42.7,170.0L42.3,167.0L42.7,149.0L44.0,145.0L47.0,141.0L53.0,136.7L122.0,97.0L122.0,84.0L119.0,83.5L112.0,80.0L106.7,75.0L102.7,68.0L100.7,59.0L101.5,52.0L103.0,47.0L107.0,41.0L112.0,36.3L117.0,33.5L123.0,31.7L127.0,31.5L131.0,31.7L137.0,33.0L144.0,37.0L150.3,44.0L152.3,48.0L153.3,51.0L154.3,58.0L154.0,62.0L152.5,68.0L149.0,74.0L145.0,78.3L142.0,80.7L137.0,83.3L134.0,83.7L132.7,85.0L133.0,97.0L148.0,106.0L149.0,106.0L155.0,110.0L161.0,113.0L162.0,114.0L168.0,117.0L169.0,118.0L175.0,121.0L181.0,125.0L182.0,125.0L188.0,129.0L201.0,136.0L207.0,140.0L210.3,144.0L211.3,146.0L212.7,152.0L212.3,170.0L211.0,174.0L208.0,178.0L202.0,182.3L173.0,198.7L164.0,204.3L136.0,220.3ZM129.5,182.0L193.7,145.0L190.0,142.0L177.0,135.0L171.0,131.0L170.0,131.0L164.0,127.0L151.0,120.0L138.0,112.0L133.0,109.7L132.7,143.0L132.0,143.5L123.0,143.5L122.3,143.0L122.0,109.5L62.0,143.7L61.0,145.0L84.0,158.0L90.0,162.0L91.0,162.0L104.0,170.0L110.0,173.0L116.0,177.0L117.0,177.0L123.0,181.0L127.0,182.5Z" />
android:pathData="M 4.512 18 q -.762 0 -1.18 -.551 t -.32 -1.23 L 4.1 8.604 q .167 -1.132 .991 -1.868 Q 5.916 6 7.05 6 h 9.9 q 1.135 0 1.959 .736 t .991 1.868 l 1.089 7.615 q .098 .679 -.32 1.23 t -1.18 .551 q -.333 0 -.6 -.101 t -.508 -.341 L 15.823 15 H 8.177 l -2.558 2.558 q -.24 .24 -.507 .341 t -.6 .101 M 17 12.808 q .329 0 .568 -.24 t .24 -.568 t -.24 -.568 t -.568 -.24 t -.568 .24 t -.24 .568 t .24 .568 t .568 .24 m -2 -3 q .329 0 .568 -.24 t .24 -.568 t -.24 -.568 t -.568 -.24 t -.568 .24 t -.24 .568 t .24 .568 t .568 .24 m -6.942 2.884 h .884 v -1.75 h 1.75 v -.884 h -1.75 v -1.75 h -.884 v 1.75 h -1.75 v .884 h 1.75 z" />
</vector>
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "image" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M206.0,180.3L84.0,180.7L80.0,180.0L76.0,178.0L73.0,175.0L69.7,170.0L68.7,164.0L68.7,49.0L70.0,42.0L71.7,39.0L75.0,35.3L79.0,32.7L82.0,31.7L85.0,31.5L202.0,31.5L207.0,32.5L213.0,36.0L215.3,39.0L217.3,43.0L218.3,48.0L218.3,163.0L218.0,167.0L215.0,174.0L212.0,177.0ZM179.0,212.7L52.0,212.7L48.0,212.0L44.0,210.0L41.0,207.0L37.7,202.0L36.7,196.0L37.0,70.5L38.0,70.0L47.0,70.0L47.5,71.0L47.5,196.0L49.3,200.0L52.0,201.7L55.0,202.3L179.0,202.3L179.5,203.0L179.5,212.0ZM189.3,145.0L164.7,112.0L161.0,107.3L160.0,107.0L135.0,138.5L134.0,139.0L133.0,138.0L118.0,120.0L117.0,120.0L97.5,145.0L98.0,145.5L188.0,145.5Z" />
android:pathData="M 5.616 20 q -.691 0 -1.153 -.462 T 4 18.384 V 5.616 q 0 -.691 .463 -1.153 T 5.616 4 h 12.769 q .69 0 1.153 .463 T 20 5.616 v 12.769 q 0 .69 -.462 1.153 T 18.384 20 z M 7.5 16.5 h 9.154 l -2.827 -3.77 l -2.615 3.308 l -1.75 -2.115 z" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "map" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M159.0,212.0L103.0,192.0L95.0,189.7L89.0,192.3L87.0,192.7L84.0,194.3L82.0,194.7L76.0,197.3L74.0,197.7L71.0,199.3L69.0,199.7L52.0,206.3L49.0,206.5L44.3,204.0L42.3,200.0L42.3,67.0L42.5,65.0L45.0,61.0L49.0,58.7L96.0,43.0L152.0,63.0L160.0,65.3L166.0,62.7L168.0,62.3L171.0,60.7L173.0,60.3L179.0,57.7L181.0,57.3L184.0,55.7L186.0,55.3L203.0,48.7L206.0,48.5L208.0,49.0L211.0,51.0L212.7,54.0L212.5,191.0L209.0,195.3L205.0,197.3L199.0,199.3L196.0,199.7ZM154.3,198.0L154.0,74.0L150.0,73.0L140.0,69.0L130.0,66.0L101.0,55.7L100.7,180.0L102.0,181.0L109.0,183.0L142.0,195.0L153.0,198.5L154.0,198.5Z" />
android:pathData="m 15 19.923 l -6 -2.1 l -3.958 1.53 q -.384 .143 -.713 -.083 T 4 18.634 V 6.404 q 0 -.268 .13 -.489 t .378 -.307 L 9 4.077 l 6 2.1 l 3.958 -1.53 q .384 -.143 .713 .054 t .329 .588 v 12.384 q 0 .287 -.159 .498 q -.158 .212 -.426 .298 z m -.5 -1.22 v -11.7 l -5 -1.745 v 11.7 z" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "news" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M201.0,212.0L198.0,212.7L58.0,212.7L55.0,212.3L51.0,211.0L47.0,208.0L43.7,203.0L42.3,198.0L42.3,58.0L42.7,55.0L44.0,51.0L48.0,46.3L52.0,43.7L57.0,42.3L165.0,42.3L166.0,42.7L212.3,89.0L212.5,199.0L211.0,204.0L208.0,208.0L205.0,210.3ZM201.7,95.0L160.0,53.3L159.5,54.0L159.5,95.0L160.0,95.5L201.0,95.5ZM127.5,95.0L127.5,86.0L127.0,84.7L79.7,85.0L79.5,95.0L80.0,95.5L127.0,95.5ZM175.5,132.0L175.5,123.0L175.0,122.3L80.0,122.3L79.5,123.0L79.5,132.0L80.0,132.7L175.0,132.7ZM175.3,170.0L175.5,160.0L175.0,159.5L80.0,159.5L79.5,160.0L79.5,169.0L80.0,170.3Z" />
android:pathData="M 5.616 20 q -.691 0 -1.153 -.462 T 4 18.384 V 5.616 q 0 -.691 .463 -1.153 T 5.616 4 h 9.961 L 20 8.423 v 9.962 q 0 .69 -.462 1.153 T 18.384 20 z M 7.5 16 h 9 v -1 h -9 z m 0 -3.5 h 9 v -1 h -9 z M 15 9 h 4 l -4 -4 z M 7.5 9 H 12 V 8 H 7.5 z" />
</vector>
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "business-center" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M211.0,212.3L47.0,212.7L43.0,212.0L39.0,210.0L35.7,207.0L33.0,203.0L31.7,199.0L31.5,196.0L31.5,90.0L32.5,85.0L34.0,82.0L39.0,77.0L41.0,75.7L45.0,74.5L95.0,74.3L95.5,73.0L95.5,58.0L97.0,52.0L99.7,48.0L103.0,45.0L106.0,43.3L111.0,42.3L144.0,42.3L148.0,43.0L152.0,45.0L156.0,49.0L158.3,53.0L159.3,56.0L159.5,73.0L160.0,74.3L208.0,74.3L212.0,75.0L216.0,77.0L220.0,81.0L222.3,85.0L223.3,88.0L223.5,197.0L222.5,202.0L221.0,205.0L216.0,210.0L214.0,211.3ZM148.5,74.0L148.3,57.0L147.0,55.0L145.0,53.7L142.0,52.7L113.0,52.7L110.0,53.7L108.0,55.0L106.5,58.0L106.3,73.0L107.0,74.3Z" />
android:pathData="M 4.616 20 q -.691 0 -1.153 -.462 T 3 18.384 V 14.5 h 7 V 16 h 4 v -1.5 h 7 v 3.885 q 0 .69 -.462 1.152 T 19.385 20 z M 11 15 v -2 h 2 v 2 z m -8 -1.5 V 8.616 q 0 -.691 .463 -1.153 T 4.615 7 H 9 V 5.615 q 0 -.69 .463 -1.153 T 10.616 4 h 2.769 q .69 0 1.153 .462 T 15 5.615 V 7 h 4.385 q .69 0 1.152 .463 T 21 8.616 V 13.5 h -7 V 12 h -4 v 1.5 z M 10 7 h 4 V 5.615 q 0 -.23 -.192 -.423 T 13.385 5 h -2.77 q -.23 0 -.423 .192 T 10 5.615 z" />
</vector>
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "forum" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M219.0,228.0L218.0,228.7L40.0,228.7L39.0,228.0L39.0,187.0L38.0,186.3L32.0,186.3L31.0,186.0L30.7,185.0L31.0,146.0L32.0,144.0L34.0,142.7L36.0,142.3L61.0,142.3L64.0,143.5L65.3,145.0L66.0,148.0L66.0,186.0L59.0,186.3L57.7,187.0L58.0,218.0L155.0,218.0L155.0,154.0L154.0,153.0L130.0,153.0L125.0,152.5L119.0,151.0L111.0,147.0L106.3,143.0L102.0,138.0L98.7,132.0L96.7,125.0L96.7,114.0L99.0,106.0L103.0,99.0L112.0,90.0L122.0,84.0L123.5,75.0L125.5,69.0L129.0,63.0L135.0,56.3L143.0,50.7L147.0,48.7L153.0,47.3L154.0,46.7L166.0,46.7L173.0,48.5L180.0,52.0L186.0,56.7L191.0,62.0L196.3,72.0L198.3,84.0L206.0,88.0L210.0,91.0L216.7,98.0L220.0,103.0L222.7,109.0L224.3,117.0L224.3,121.0L223.0,129.0L222.0,132.0L220.0,135.0L220.0,136.0L214.3,143.0L209.0,147.3L203.0,150.5L197.0,152.3L190.0,153.0L167.0,153.0L165.7,154.0L165.7,217.0L166.0,218.0L167.0,218.3L218.0,218.3L219.0,219.0ZM52.0,131.0L49.0,131.5L44.0,131.0L40.0,128.3L37.7,125.0L36.5,120.0L37.0,116.0L39.0,112.0L44.0,108.5L48.0,107.7L54.0,109.3L57.0,111.5L59.3,115.0L59.7,118.0L60.3,119.0L59.5,124.0L57.0,128.0Z" />
android:pathData="M 7.23 16.23 q -.326 0 -.547 -.22 q -.221 -.222 -.221 -.549 v -1 h 11.75 l .634 .635 V 6 h 1 q .327 0 .548 .221 t .222 .548 v 12.539 l -3.078 -3.077 z m -3.845 -.691 V 3.769 q 0 -.327 .22 -.548 Q 3.828 3 4.155 3 h 11.923 q .327 0 .548 .221 t .221 .548 v 7.923 q 0 .327 -.221 .549 q -.221 .22 -.548 .22 H 6.462 z" />
</vector>
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "android" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M147.0,223.5L108.0,223.5L107.5,223.0L106.7,218.0L106.3,212.0L105.7,210.0L105.3,204.0L104.7,202.0L103.7,193.0L91.0,187.0L83.0,181.0L75.0,183.7L70.0,186.3L68.0,186.7L56.0,192.3L54.0,192.3L34.7,159.0L34.7,158.0L37.0,156.0L58.0,140.3L58.7,139.0L57.7,130.0L58.7,116.0L56.0,113.0L54.0,112.0L52.0,110.0L34.5,97.0L38.0,90.0L42.0,84.0L42.0,83.0L54.0,63.0L58.0,64.0L82.0,74.5L92.0,67.7L103.0,62.5L104.0,60.0L107.0,35.0L108.0,31.5L147.0,31.5L147.5,32.0L148.3,38.0L150.7,59.0L152.0,63.0L153.0,63.0L163.0,68.0L172.0,74.3L178.0,71.7L180.0,71.3L183.0,69.7L185.0,69.3L195.0,64.7L201.0,62.7L220.3,96.0L220.3,97.0L218.0,99.0L195.5,116.0L196.3,121.0L196.5,128.0L196.3,133.0L195.3,139.0L196.0,140.0L220.0,158.0L220.0,159.0L219.0,160.0L204.0,187.0L201.0,192.0L200.0,192.5L172.0,180.5L161.0,188.3L153.0,191.7L151.3,193.0L151.0,194.0L148.0,220.0ZM129.0,154.0L134.0,153.3L138.0,152.0L143.0,149.0L146.5,146.0L149.0,143.0L152.0,138.0L153.5,133.0L153.7,125.0L153.3,121.0L150.3,114.0L145.0,107.7L142.0,105.0L137.0,102.5L127.0,100.7L120.0,101.7L117.0,102.7L113.0,104.7L107.0,110.0L104.0,114.0L102.5,117.0L101.0,122.0L100.5,128.0L101.7,136.0L105.3,143.0L110.0,148.0L116.0,152.0L119.0,153.0L124.0,154.0Z" />
android:pathData="M 2.692 17.02 q .206 -2.272 1.398 -4.173 q 1.192 -1.9 3.176 -3.02 l -1.562 -2.7 q -.131 -.206 -.066 -.408 q .066 -.202 .277 -.327 q .2 -.106 .393 -.04 q .192 .065 .319 .256 l 1.565 2.715 q 1.82 -.764 3.808 -.764 t 3.808 .764 l 1.565 -2.715 q .127 -.19 .32 -.256 q .192 -.066 .391 .04 q .212 .125 .278 .327 q .065 .202 -.066 .408 l -1.561 2.7 q 1.983 1.12 3.175 3.02 q 1.192 1.901 1.398 4.172 z m 5.08 -2.328 q .445 0 .75 -.307 q .305 -.308 .305 -.753 t -.308 -.75 t -.752 -.305 t -.75 .308 t -.306 .752 q 0 .446 .308 .75 t .753 .305 m 8.462 0 q .445 0 .75 -.307 q .304 -.308 .304 -.753 t -.307 -.75 t -.753 -.305 t -.75 .308 t -.305 .752 t .307 .75 t .753 .305" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "movie" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M206.0,180.3L84.0,180.7L80.0,180.0L76.0,178.0L73.0,175.0L69.7,170.0L68.7,164.0L68.7,49.0L70.0,42.0L71.7,39.0L75.0,35.3L79.0,32.7L82.0,31.7L85.0,31.5L202.0,31.5L207.0,32.5L213.0,36.0L215.3,39.0L217.3,43.0L218.3,48.0L218.3,163.0L218.0,167.0L215.0,174.0L212.0,177.0ZM177.0,212.0L175.0,212.7L52.0,212.7L48.0,212.0L44.0,210.0L41.0,207.0L37.7,202.0L36.7,196.0L36.7,76.0L38.0,72.0L40.0,70.5L44.0,70.5L46.3,72.0L47.5,75.0L47.5,196.0L49.3,200.0L52.0,201.7L55.0,202.3L175.0,202.3L178.0,203.7L179.3,206.0L179.0,210.0ZM129.5,139.0L131.0,138.7L135.0,136.3L173.0,111.7L175.5,109.0L176.3,106.0L175.3,103.0L173.0,100.7L160.0,92.0L156.0,90.0L132.0,74.0L127.0,73.3L124.0,75.0L122.3,79.0L122.3,134.0L125.0,138.0L127.0,139.0Z" />
android:pathData="m 4.616 5 l 1.5 3 h 3 l -1.5 -3 h 2 l 1.5 3 h 3 l -1.5 -3 h 2 l 1.5 3 h 3 l -1.5 -3 h 1.769 q .69 0 1.153 .463 T 21 6.616 v 10.769 q 0 .69 -.462 1.153 T 19.385 19 H 4.615 q -.69 0 -1.152 -.462 T 3 17.384 V 6.616 q 0 -.691 .463 -1.153 T 4.615 5" />
</vector>
-10
View File
@@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M122.0,212.5L56.0,212.5L54.0,212.0L49.0,209.3L47.3,208.0L43.7,203.0L42.3,198.0L42.3,58.0L43.0,54.0L47.0,47.3L52.0,43.7L57.0,42.3L197.0,42.3L201.0,43.0L207.7,47.0L211.3,52.0L212.7,57.0L212.7,122.0L212.0,122.5L201.0,120.0L191.0,119.3L182.0,120.0L171.0,122.5L80.0,122.3L79.5,123.0L79.5,132.0L80.0,132.7L149.0,133.0L148.0,134.3L142.0,139.0L136.0,145.3L131.0,152.0L128.0,157.0L128.0,158.0L127.0,159.0L127.0,160.0L125.0,162.3L80.0,162.3L79.5,163.0L79.5,172.0L80.0,173.0L121.0,173.0L121.5,174.0L119.7,184.0L119.3,194.0L119.7,202.0L120.7,208.0L122.3,212.0ZM175.5,92.0L175.5,83.0L175.0,82.0L80.0,82.0L79.5,83.0L79.5,92.0L80.0,92.7L175.0,92.7ZM196.0,235.0L189.0,235.3L182.0,234.5L174.0,232.0L173.0,231.0L167.0,228.0L160.3,222.0L155.0,215.0L151.7,209.0L149.5,201.0L149.3,196.0L148.7,193.0L149.5,184.0L152.0,176.0L155.0,171.0L155.0,170.0L159.0,165.0L167.0,157.7L176.0,152.7L182.0,151.3L183.0,150.7L192.0,150.0L201.0,151.0L208.0,153.0L209.0,154.0L210.0,154.0L215.0,157.0L219.0,160.0L226.3,168.0L231.3,177.0L233.3,183.0L234.3,192.0L233.5,201.0L231.5,208.0L227.5,216.0L221.0,223.7L212.0,230.3L208.0,232.3L202.0,234.3ZM171.5,199.0L174.0,197.0L175.3,194.0L175.3,191.0L174.3,189.0L171.0,186.0L167.0,185.7L165.0,186.3L163.0,188.0L161.5,191.0L161.3,194.0L162.0,196.0L163.5,198.0L166.0,199.5L168.0,200.0ZM195.0,199.0L198.0,196.0L198.5,194.0L198.3,190.0L196.0,187.0L192.0,185.5L190.0,185.7L186.0,188.0L184.5,191.0L184.7,195.0L185.7,197.0L189.0,199.5L191.0,200.0ZM218.0,199.0L220.0,197.5L221.5,195.0L221.3,190.0L219.0,187.0L216.0,185.7L213.0,185.7L210.0,187.3L208.0,190.0L207.5,192.0L207.7,195.0L209.0,197.0L212.0,199.5L216.0,199.7Z" />
</vector>
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "encrypted" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M128.0,242.3L124.0,241.5L112.0,236.0L111.0,236.0L110.0,235.0L109.0,235.0L108.0,234.0L107.0,234.0L102.0,231.0L99.0,230.0L86.0,222.0L79.0,217.0L68.0,208.0L58.3,198.0L49.7,187.0L42.7,176.0L37.7,166.0L34.7,159.0L30.7,147.0L28.3,136.0L27.7,135.0L27.3,131.0L26.7,130.0L25.3,118.0L24.7,116.0L23.5,95.0L23.7,79.0L25.0,62.0L26.0,58.0L28.0,54.0L30.7,50.0L35.0,45.7L41.0,41.7L43.0,41.3L46.0,39.7L105.0,20.3L108.0,18.7L114.0,16.7L122.0,14.7L127.0,14.3L133.0,14.7L140.0,16.5L164.0,25.0L211.0,40.5L218.0,44.0L224.3,50.0L227.0,54.0L229.3,59.0L229.7,62.0L230.3,63.0L231.5,83.0L231.3,102.0L230.5,114.0L228.5,129.0L226.0,141.0L221.0,157.0L219.0,161.0L217.0,167.0L216.0,168.0L216.0,169.0L215.0,170.0L210.0,180.0L204.0,189.0L196.0,198.7L188.0,207.0L178.0,215.3L167.0,223.3L155.0,230.3L141.0,237.3L139.0,237.7L134.0,240.3ZM128.5,225.0L139.0,220.5L151.0,214.3L161.0,208.0L170.0,201.3L185.0,187.0L191.3,179.0L198.0,169.0L199.0,166.0L200.0,165.0L203.0,159.0L203.0,158.0L207.0,149.0L209.0,141.0L210.0,139.0L212.0,130.0L214.5,113.0L215.5,98.0L215.5,83.0L214.3,65.0L213.7,63.0L211.0,59.0L209.0,57.5L204.0,55.0L185.0,49.0L133.0,31.0L127.0,30.3L123.0,30.7L87.0,42.7L84.0,44.3L49.0,55.7L46.0,57.3L43.0,60.0L40.5,66.0L39.5,83.0L39.5,98.0L40.7,115.0L41.3,117.0L41.7,122.0L43.7,133.0L44.3,134.0L44.7,138.0L47.3,145.0L47.7,148.0L51.7,158.0L57.7,170.0L64.3,180.0L70.0,187.0L81.0,198.0L91.0,206.0L105.0,215.0L106.0,215.0L110.0,217.5L127.0,225.5Z" />
android:pathData="M 10.98 14.5 h 2.04 l -.556 -3.09 q .442 -.154 .73 -.543 T 13.48 10 q 0 -.613 -.434 -1.047 q -.433 -.434 -1.047 -.434 t -1.047 .434 T 10.519 10 q 0 .479 .288 .867 t .73 .542 z M 12 20.962 q -3.014 -.895 -5.007 -3.651 T 5 11.1 V 5.692 l 7 -2.615 l 7 2.615 V 11.1 q 0 3.454 -1.993 6.21 T 12 20.963" />
</vector>
+4 -8
View File
@@ -1,14 +1,10 @@
<!-- Material Symbols Light "policy" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
<path
android:pathData="M128,38 L58,67 L58,120 C58,165 90,200 128,217 C166,200 198,165 198,120 L198,67 Z"
android:strokeColor="#FFFFFFFF"
android:strokeWidth="11"
android:strokeLineJoin="round" />
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M127.5,86.0 L135.8,111.6 L162.7,111.6 L140.9,127.4 L149.2,152.9 L127.5,137.1 L105.8,152.9 L114.1,127.4 L92.3,111.6 L119.2,111.6 Z" />
android:pathData="M 12 20.962 q -3.014 -.895 -5.007 -3.651 T 5 11.1 V 5.692 l 7 -2.615 l 7 2.615 V 11.1 q 0 1.498 -.422 2.88 t -1.14 2.674 l -2.95 -2.95 q .237 -.379 .375 -.814 Q 15 12.454 15 12 q 0 -1.246 -.877 -2.123 T 12 9 t -2.123 .877 T 9 12 t .877 2.123 T 12 15 q .487 0 .941 -.147 q .455 -.147 .828 -.441 l 3.071 3.065 q -1.011 1.167 -2.18 2.11 T 12 20.962 M 12 14 q -.825 0 -1.412 -.587 T 10 12 t .588 -1.412 T 12 10 t 1.413 .588 T 14 12 t -.587 1.413 T 12 14" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "verified-user" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M196.0,182.0L186.0,182.0L174.0,180.0L157.0,174.0L152.0,171.0L145.3,165.0L140.7,159.0L133.7,147.0L130.0,143.0L128.0,142.7L125.0,143.3L122.0,146.0L113.0,161.0L106.7,168.0L101.0,172.3L87.0,178.3L84.0,178.7L80.0,180.3L76.0,180.7L75.0,181.3L65.0,182.3L58.0,182.0L46.0,180.0L29.0,174.0L27.5,172.0L24.7,164.0L24.3,161.0L22.7,157.0L20.7,147.0L19.5,137.0L19.7,118.0L19.0,117.0L14.0,117.0L13.7,116.0L21.3,86.0L22.0,85.3L27.0,85.0L28.0,82.0L30.0,80.7L56.0,77.3L57.0,76.7L58.0,77.0L76.0,75.3L78.0,74.7L89.0,74.3L94.0,73.7L123.0,72.7L153.0,73.3L176.0,74.7L206.0,78.0L227.0,81.5L227.7,84.0L228.5,85.0L233.0,85.3L233.7,86.0L241.3,116.0L241.0,117.0L234.0,117.0L233.5,118.0L234.0,131.0L233.3,142.0L231.0,157.0L228.0,171.0L227.0,173.3L220.0,176.3L218.0,176.7L215.0,178.3L212.0,178.7L208.0,180.3L204.0,180.7L203.0,181.3ZM198.0,173.0L207.0,171.3L216.0,168.3L219.0,166.7L220.3,164.0L224.0,144.0L225.0,126.0L223.3,106.0L220.0,90.0L219.0,89.0L198.0,86.0L173.0,83.5L131.0,81.7L109.0,82.0L107.0,85.0L103.0,95.0L97.0,113.0L96.0,118.0L94.0,124.0L89.5,147.0L87.7,168.0L88.0,168.3L91.0,166.7L93.0,166.3L98.0,163.3L104.0,158.0L113.0,143.0L115.0,141.0L116.0,139.0L118.3,137.0L122.0,134.7L128.0,133.7L134.0,135.0L138.0,138.0L144.3,147.0L149.7,156.0L155.0,162.0L158.0,164.0L169.0,169.0L179.0,172.0L190.0,173.5ZM56.3,172.0L59.0,151.0L63.0,131.0L63.0,129.0L69.0,105.0L75.3,86.0L75.5,85.0L75.0,84.3L64.0,85.3L63.0,86.0L58.5,96.0L54.5,107.0L49.0,127.0L45.5,148.0L44.0,169.0L45.0,170.3L51.0,172.0L55.0,172.7ZM35.3,164.0L36.7,146.0L40.0,126.0L45.0,107.0L50.0,93.0L52.0,89.0L52.0,86.7L50.0,87.3L38.0,88.7L35.0,90.0L31.0,104.0L28.5,120.0L28.5,137.0L29.7,146.0L32.7,159.0L35.0,165.0Z" />
android:pathData="M 10.95 14.858 L 15.908 9.9 l -.714 -.713 l -4.244 4.244 l -2.138 -2.139 l -.714 .714 z M 12 20.96 q -3.013 -.894 -5.007 -3.65 T 5 11.1 V 5.692 l 7 -2.615 l 7 2.615 V 11.1 q 0 3.454 -1.993 6.21 T 12 20.963" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "refresh" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M139.0,212.3L138.3,211.0L138.3,202.0L139.0,201.3L149.0,198.3L161.0,192.3L169.0,186.3L176.3,179.0L183.0,170.0L188.5,158.0L190.5,150.0L191.5,141.0L191.3,131.0L189.3,120.0L187.3,114.0L184.3,108.0L181.3,103.0L175.0,95.0L170.0,90.0L165.0,86.0L159.0,82.0L155.0,80.0L154.0,80.0L153.0,79.0L146.0,76.7L135.0,74.5L122.0,74.5L121.7,75.0L137.7,91.0L130.0,98.5L100.3,69.0L130.0,39.3L131.0,39.7L137.3,46.0L137.0,47.0L121.0,63.0L122.0,63.5L135.0,63.7L148.0,66.0L157.0,69.0L158.0,70.0L159.0,70.0L163.0,72.0L171.0,77.0L176.0,81.0L185.0,90.0L187.3,93.0L190.3,97.0L196.3,108.0L200.3,120.0L202.3,137.0L201.5,149.0L198.5,162.0L192.0,176.0L184.0,187.0L173.0,197.3L164.0,203.3L151.0,209.3L148.0,209.7L144.0,211.3L140.0,211.7ZM116.0,211.7L107.0,210.0L98.0,207.0L88.0,202.0L81.0,197.0L71.7,188.0L64.7,179.0L58.7,168.0L58.3,166.0L55.7,160.0L53.7,151.0L52.7,139.0L53.5,128.0L55.7,118.0L58.0,111.0L63.0,101.0L69.0,92.0L75.0,85.5L82.5,93.0L76.0,100.0L72.0,106.0L68.0,114.0L66.0,120.0L64.5,126.0L63.5,136.0L63.7,145.0L65.7,156.0L68.7,164.0L74.3,174.0L79.0,180.0L87.0,188.0L94.0,193.0L102.0,197.0L109.0,199.5L116.0,201.0L116.7,202.0L116.7,211.0Z" />
android:pathData="M 12.077 19 q -2.931 0 -4.966 -2.033 q -2.034 -2.034 -2.034 -4.964 t 2.034 -4.966 T 12.077 5 q 1.783 0 3.339 .847 q 1.555 .847 2.507 2.365 V 5 h 1 v 5.23 h -5.23 v -1 h 3.7 q -.782 -1.495 -2.198 -2.363 T 12.077 6 q -2.5 0 -4.25 1.75 T 6.077 12 t 1.75 4.25 t 4.25 1.75 q 1.925 0 3.475 -1.1 t 2.175 -2.9 h 1.062 q -.662 2.246 -2.514 3.623 T 12.077 19" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "search" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M208.0,214.0L207.0,214.0L141.0,148.0L140.0,148.0L131.0,154.3L122.0,158.3L116.0,159.7L115.0,160.3L112.0,160.7L111.0,161.3L99.0,162.0L89.0,161.0L76.0,157.0L67.0,152.0L63.0,149.0L56.7,143.0L52.3,138.0L47.7,131.0L42.7,120.0L40.7,111.0L40.3,96.0L41.0,89.0L44.5,77.0L48.0,70.0L52.0,64.0L59.0,56.3L64.0,52.0L70.0,48.0L78.0,43.7L89.0,40.7L97.0,39.7L104.0,39.7L115.0,41.0L125.0,44.0L136.0,50.0L141.0,54.0L148.0,61.0L154.3,70.0L158.3,78.0L161.3,88.0L162.3,96.0L162.3,105.0L160.0,118.0L154.0,132.0L148.3,140.0L214.0,206.0L214.7,207.0L214.0,208.0ZM106.0,151.0L116.0,149.3L124.0,146.3L130.0,142.7L135.0,138.7L142.0,131.0L146.5,124.0L150.0,115.0L151.5,106.0L151.3,93.0L149.3,84.0L144.3,74.0L140.0,68.0L134.0,62.0L130.0,59.0L121.0,54.0L113.0,51.5L106.0,50.5L94.0,50.7L85.0,52.7L76.0,56.7L66.0,64.3L60.0,71.0L54.0,82.0L52.0,89.0L50.7,100.0L51.7,112.0L52.3,113.0L53.7,119.0L59.7,130.0L69.0,140.0L73.0,143.0L80.0,147.0L85.0,149.0L91.0,150.5L99.0,151.3Z" />
android:pathData="m 19.485 20.154 l -6.262 -6.262 q -.75 .639 -1.725 .989 t -1.96 .35 q -2.402 0 -4.066 -1.663 T 3.808 9.503 T 5.47 5.436 t 4.064 -1.667 t 4.068 1.664 T 15.268 9.5 q 0 1.042 -.369 2.017 t -.97 1.668 l 6.262 6.261 z M 9.539 14.23 q 1.99 0 3.36 -1.37 t 1.37 -3.361 t -1.37 -3.36 t -3.36 -1.37 t -3.361 1.37 t -1.37 3.36 t 1.37 3.36 t 3.36 1.37" />
</vector>
@@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M127.0,223.0L116.0,219.0L108.0,215.0L107.0,214.0L106.0,214.0L92.0,204.0L82.0,194.0L74.7,185.0L68.7,176.0L63.7,167.0L57.7,152.0L57.3,149.0L55.7,145.0L53.7,133.0L52.7,119.0L52.7,61.0L54.0,59.7L56.0,59.3L59.0,57.7L64.0,56.3L67.0,54.7L72.0,53.3L75.0,51.7L80.0,50.3L83.0,48.7L88.0,47.3L91.0,45.7L96.0,44.3L99.0,42.7L104.0,41.3L107.0,39.7L112.0,38.3L126.0,32.7L128.0,32.5L202.0,60.0L202.3,118.0L201.0,135.0L199.0,145.0L195.0,158.0L191.0,167.0L188.0,172.0L188.0,173.0L181.0,184.0L179.0,186.0L146.0,153.5L137.0,158.3L132.0,159.3L121.0,159.0L116.0,157.5L111.0,155.0L107.0,152.0L103.0,148.0L100.7,145.0L98.0,140.0L95.7,131.0L95.7,124.0L97.5,116.0L100.0,111.0L103.0,107.0L107.0,103.0L110.0,100.7L115.0,98.0L124.0,95.7L131.0,95.7L139.0,97.5L144.0,100.0L148.0,103.0L154.3,110.0L157.0,115.0L158.3,119.0L159.3,124.0L159.3,132.0L157.0,140.0L154.3,146.0L177.0,168.7L178.0,169.0L182.0,161.0L182.0,160.0L183.0,159.0L187.0,148.0L189.0,141.0L190.5,133.0L191.5,121.0L191.5,68.0L191.0,67.3L127.0,43.7L124.0,45.3L108.0,50.7L105.0,52.3L100.0,53.7L97.0,55.3L92.0,56.7L89.0,58.3L84.0,59.7L78.0,62.3L73.0,63.7L70.0,65.3L65.0,66.7L63.5,68.0L63.5,121.0L64.7,135.0L65.3,136.0L65.7,140.0L67.3,145.0L67.7,148.0L69.7,154.0L71.3,157.0L71.7,159.0L76.7,169.0L83.3,179.0L90.7,188.0L100.0,197.0L110.0,204.0L122.0,210.0L128.0,211.7L132.0,210.3L141.0,206.3L153.0,198.5L159.5,206.0L159.0,207.0L146.0,215.3L136.0,220.3ZM133.5,148.0L136.0,147.3L139.7,145.0L145.5,139.0L148.5,132.0L148.3,122.0L147.3,119.0L145.5,116.0L144.0,114.0L139.0,109.5L132.0,106.5L122.0,106.7L119.0,107.7L116.0,109.5L114.0,111.0L109.5,116.0L106.5,123.0L106.7,133.0L107.7,136.0L109.5,139.0L111.0,141.0L116.0,145.5L123.0,148.5L129.0,148.7Z" />
</vector>
+10
View File
@@ -0,0 +1,10 @@
<!-- Material Symbols Light "speed" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M 10.758 15.192 q .452 .452 1.18 .415 q .73 -.038 1.078 -.515 l 5.253 -7.323 l -7.361 5.216 q -.496 .334 -.559 1.035 t .409 1.172 M 5.1 19 q -.28 0 -.512 -.141 q -.232 -.142 -.392 -.386 q -.592 -1.021 -.894 -2.158 T 3 14 q 0 -1.864 .71 -3.506 q .711 -1.642 1.927 -2.857 Q 6.852 6.42 8.494 5.71 T 12 5 q 1.858 0 3.485 .698 t 2.852 1.901 t 1.938 2.817 t .72 3.472 q .005 1.24 -.294 2.409 t -.903 2.253 q -.14 .244 -.382 .347 q -.241 .103 -.522 .103 z" />
</vector>
+10
View File
@@ -0,0 +1,10 @@
<!-- Material Symbols Light "swap-horizontal-circle" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="m 9.692 17.308 l .708 -.708 l -2.089 -2.1 H 13 v -1 H 8.312 l 2.088 -2.1 l -.708 -.708 L 6.385 14 z m 4.616 -4 L 17.616 10 l -3.308 -3.308 l -.708 .708 l 2.089 2.1 H 11 v 1 h 4.689 L 13.6 12.6 z M 12.003 21 q -1.866 0 -3.51 -.708 q -1.643 -.709 -2.859 -1.924 t -1.925 -2.856 T 3 12.003 t .709 -3.51 Q 4.417 6.85 5.63 5.634 t 2.857 -1.925 T 11.997 3 t 3.51 .709 q 1.643 .708 2.859 1.922 t 1.925 2.857 t .709 3.509 t -.708 3.51 t -1.924 2.859 t -2.856 1.925 t -3.509 .709" />
</vector>
-10
View File
@@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M178.0,144.3L177.0,144.0L170.3,137.0L202.0,105.0L201.0,104.0L125.0,104.0L124.3,103.0L124.3,94.0L125.0,93.5L202.0,93.5L202.7,93.0L170.7,61.0L170.3,60.0L177.0,53.3L178.0,53.3L223.3,99.0ZM78.0,201.3L77.0,201.7L31.7,156.0L77.0,110.7L78.0,110.7L84.3,117.0L84.7,118.0L52.7,150.0L53.0,150.5L130.0,150.7L130.7,152.0L130.7,160.0L130.0,161.3L53.0,161.5L52.7,162.0L84.7,194.0L84.3,195.0Z" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "apps" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M67.0,76.3L61.0,76.5L57.0,75.0L52.7,71.0L50.7,67.0L50.5,61.0L52.0,57.0L56.0,52.7L60.0,50.7L66.0,50.5L70.0,52.0L74.3,56.0L76.3,60.0L76.5,66.0L75.0,70.0L71.0,74.3ZM131.0,76.3L125.0,76.5L121.0,75.0L116.7,71.0L114.7,67.0L114.5,61.0L116.0,57.0L120.0,52.7L124.0,50.7L130.0,50.5L134.0,52.0L138.3,56.0L140.3,60.0L140.5,66.0L139.0,70.0L135.0,74.3ZM195.0,76.3L189.0,76.5L185.0,75.0L180.7,71.0L178.7,67.0L178.5,61.0L180.0,57.0L184.0,52.7L188.0,50.7L194.0,50.5L198.0,52.0L202.3,56.0L204.3,60.0L204.5,66.0L203.0,70.0L199.0,74.3ZM67.0,140.3L61.0,140.5L57.0,139.0L52.7,135.0L50.7,131.0L50.5,125.0L52.0,121.0L56.0,116.7L60.0,114.7L66.0,114.5L70.0,116.0L74.3,120.0L76.3,124.0L76.5,130.0L75.0,134.0L71.0,138.3ZM131.0,140.3L125.0,140.5L121.0,139.0L116.7,135.0L114.7,131.0L114.5,125.0L116.0,121.0L120.0,116.7L124.0,114.7L130.0,114.5L134.0,116.0L138.3,120.0L140.3,124.0L140.5,130.0L139.0,134.0L135.0,138.3ZM195.0,140.3L189.0,140.5L185.0,139.0L180.7,135.0L178.7,131.0L178.5,125.0L180.0,121.0L184.0,116.7L188.0,114.7L194.0,114.5L198.0,116.0L202.3,120.0L204.3,124.0L204.5,130.0L203.0,134.0L199.0,138.3ZM67.0,204.3L61.0,204.5L57.0,203.0L52.7,199.0L50.7,195.0L50.5,189.0L52.0,185.0L56.0,180.7L60.0,178.7L66.0,178.5L70.0,180.0L74.3,184.0L76.3,188.0L76.5,194.0L75.0,198.0L71.0,202.3ZM131.0,204.3L125.0,204.5L121.0,203.0L116.7,199.0L114.7,195.0L114.5,189.0L116.0,185.0L120.0,180.7L124.0,178.7L130.0,178.5L134.0,180.0L138.3,184.0L140.3,188.0L140.5,194.0L139.0,198.0L135.0,202.3ZM195.0,204.3L189.0,204.5L185.0,203.0L180.7,199.0L178.7,195.0L178.5,189.0L180.0,185.0L184.0,180.7L188.0,178.7L194.0,178.5L198.0,180.0L202.3,184.0L204.3,188.0L204.5,194.0L203.0,198.0L199.0,202.3Z" />
android:pathData="M 6 19.23 q -.508 0 -.87 -.36 T 4.77 18 t .36 -.87 t .87 -.36 t .87 .36 t .36 .87 t -.36 .87 t -.87 .36 m 6 0 q -.508 0 -.87 -.36 t -.36 -.87 t .36 -.87 t .87 -.36 t .87 .36 t .36 .87 t -.36 .87 t -.87 .36 m 6 0 q -.508 0 -.87 -.36 t -.36 -.87 t .36 -.87 t .87 -.36 t .87 .36 t .36 .87 t -.36 .87 t -.87 .36 m -12 -6 q -.508 0 -.87 -.36 T 4.77 12 t .36 -.87 t .87 -.36 t .87 .36 t .36 .87 t -.36 .87 t -.87 .36 m 6 0 q -.508 0 -.87 -.36 t -.36 -.87 t .36 -.87 t .87 -.36 t .87 .36 t .36 .87 t -.36 .87 t -.87 .36 m 6 0 q -.508 0 -.87 -.36 t -.36 -.87 t .36 -.87 t .87 -.36 t .87 .36 t .36 .87 t -.36 .87 t -.87 .36 m -12 -6 q -.508 0 -.87 -.36 T 4.77 6 t .36 -.87 t .87 -.36 t .87 .36 t .36 .87 t -.36 .87 t -.87 .36 m 6 0 q -.508 0 -.87 -.36 T 10.77 6 t .36 -.87 t .87 -.36 t .87 .36 t .36 .87 t -.36 .87 t -.87 .36 m 6 0 q -.508 0 -.87 -.36 T 16.77 6 t .36 -.87 t .87 -.36 t .87 .36 t .36 .87 t -.36 .87 t -.87 .36" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "do-not-disturb-on" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M137.0,223.0L130.0,223.5L117.0,223.0L105.0,221.0L98.0,219.0L90.0,216.0L80.0,211.0L68.0,203.0L60.0,196.0L53.7,189.0L47.7,181.0L43.5,174.0L37.7,162.0L34.7,153.0L31.7,135.0L31.5,125.0L32.0,117.0L34.0,105.0L36.0,98.0L39.0,90.0L44.0,80.0L52.0,68.0L59.0,60.0L66.0,53.7L74.0,47.7L81.0,43.5L93.0,37.7L102.0,34.7L120.0,31.7L130.0,31.5L138.0,32.0L150.0,34.0L157.0,36.0L165.0,39.0L175.0,44.0L187.0,52.0L195.0,59.0L201.3,66.0L207.3,74.0L211.5,81.0L217.3,93.0L220.3,102.0L223.3,120.0L223.5,130.0L223.0,138.0L221.0,150.0L219.0,157.0L216.0,165.0L211.0,175.0L203.0,187.0L196.0,195.0L189.0,201.3L181.0,207.3L174.0,211.5L162.0,217.3L153.0,220.3ZM192.0,183.0L194.0,181.0L201.0,171.0L207.0,159.0L210.0,150.0L212.0,140.0L212.7,132.0L212.7,123.0L211.3,110.0L207.3,96.0L203.7,88.0L199.5,81.0L191.0,70.0L182.0,61.3L175.0,56.0L169.0,52.5L160.0,48.0L153.0,45.7L144.0,43.5L136.0,42.5L119.0,42.5L106.0,44.7L94.0,48.7L86.0,52.7L77.0,58.7L73.0,62.0L71.7,64.0L191.0,183.3ZM139.0,212.0L149.0,210.3L158.0,207.3L165.0,204.3L175.0,198.3L182.0,193.0L183.3,191.0L64.0,71.7L63.0,72.0L58.0,78.0L54.0,84.0L54.0,85.0L53.0,86.0L49.0,94.0L44.7,107.0L42.5,119.0L42.5,136.0L43.7,145.0L47.7,159.0L51.3,167.0L59.0,179.0L64.0,185.0L73.0,193.7L80.0,199.0L85.0,202.0L95.0,207.0L102.0,209.3L111.0,211.5L123.0,212.7L132.0,212.7Z" />
android:pathData="M 7.5 12.5 h 9 v -1 h -9 z m 4.503 8.5 q -1.866 0 -3.51 -.708 q -1.643 -.709 -2.859 -1.924 t -1.925 -2.856 T 3 12.003 t .709 -3.51 Q 4.417 6.85 5.63 5.634 t 2.857 -1.925 T 11.997 3 t 3.51 .709 q 1.643 .708 2.859 1.922 t 1.925 2.857 t .709 3.509 t -.708 3.51 t -1.924 2.859 t -2.856 1.925 t -3.509 .709" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "shield" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M128.0,242.3L124.0,241.5L112.0,236.0L111.0,236.0L110.0,235.0L109.0,235.0L108.0,234.0L107.0,234.0L102.0,231.0L99.0,230.0L86.0,222.0L79.0,217.0L68.0,208.0L58.3,198.0L49.7,187.0L42.7,176.0L37.7,166.0L34.7,159.0L30.7,147.0L28.3,136.0L27.7,135.0L27.3,131.0L26.7,130.0L25.3,118.0L24.7,116.0L23.5,95.0L23.7,79.0L25.0,62.0L26.0,58.0L28.0,54.0L30.7,50.0L35.0,45.7L41.0,41.7L43.0,41.3L46.0,39.7L105.0,20.3L108.0,18.7L114.0,16.7L122.0,14.7L127.0,14.3L133.0,14.7L140.0,16.5L164.0,25.0L211.0,40.5L218.0,44.0L224.3,50.0L227.0,54.0L229.3,59.0L229.7,62.0L230.3,63.0L231.5,83.0L231.3,102.0L230.5,114.0L228.5,129.0L226.0,141.0L221.0,157.0L219.0,161.0L217.0,167.0L216.0,168.0L216.0,169.0L215.0,170.0L210.0,180.0L204.0,189.0L196.0,198.7L188.0,207.0L178.0,215.3L167.0,223.3L155.0,230.3L141.0,237.3L139.0,237.7L134.0,240.3ZM128.5,225.0L139.0,220.5L151.0,214.3L161.0,208.0L170.0,201.3L185.0,187.0L191.3,179.0L198.0,169.0L199.0,166.0L200.0,165.0L203.0,159.0L203.0,158.0L207.0,149.0L209.0,141.0L210.0,139.0L212.0,130.0L214.5,113.0L215.5,98.0L215.5,83.0L214.3,65.0L213.7,63.0L211.0,59.0L209.0,57.5L204.0,55.0L185.0,49.0L133.0,31.0L127.0,30.3L123.0,30.7L87.0,42.7L84.0,44.3L49.0,55.7L46.0,57.3L43.0,60.0L40.5,66.0L39.5,83.0L39.5,98.0L40.7,115.0L41.3,117.0L41.7,122.0L43.7,133.0L44.3,134.0L44.7,138.0L47.3,145.0L47.7,148.0L51.7,158.0L57.7,170.0L64.3,180.0L70.0,187.0L81.0,198.0L91.0,206.0L105.0,215.0L106.0,215.0L110.0,217.5L127.0,225.5Z" />
android:pathData="M 12 20.962 q -3.014 -.895 -5.007 -3.651 T 5 11.1 V 5.692 l 7 -2.615 l 7 2.615 V 11.1 q 0 3.454 -1.993 6.21 T 12 20.963" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "info" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M131.0,74.0L127.0,74.3L122.0,73.3L120.0,72.3L115.7,69.0L112.5,64.0L111.7,61.0L111.5,57.0L112.7,52.0L115.0,48.0L118.0,45.0L122.0,43.0L129.0,42.3L132.0,42.7L134.0,43.5L138.0,46.0L140.0,48.0L142.5,52.0L143.5,57.0L143.3,62.0L141.0,67.0L136.0,72.0ZM138.0,212.5L118.0,212.7L116.7,212.0L116.7,105.0L117.0,104.0L118.0,103.7L137.0,103.7L138.0,104.0L138.3,105.0Z" />
android:pathData="M 11.5 16.5 h 1 V 11 h -1 z m .5 -6.923 q .262 0 .439 -.177 t .176 -.439 t -.177 -.438 T 12 8.346 t -.438 .177 t -.177 .439 t .177 .438 t .438 .177 M 12.003 21 q -1.867 0 -3.51 -.708 q -1.643 -.709 -2.859 -1.924 t -1.925 -2.856 T 3 12.003 t .709 -3.51 Q 4.417 6.85 5.63 5.634 t 2.857 -1.925 T 11.997 3 t 3.51 .709 q 1.643 .708 2.859 1.922 t 1.925 2.857 t .709 3.509 t -.708 3.51 t -1.924 2.859 t -2.856 1.925 t -3.509 .709" />
</vector>
+4 -4
View File
@@ -1,10 +1,10 @@
<!-- Material Symbols Light "analytics" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="M223.0,128.7L214.0,128.7L212.7,128.0L212.7,69.0L211.0,66.0L209.0,64.0L206.0,63.5L47.0,63.7L45.0,65.0L42.5,68.0L42.3,96.0L41.0,96.7L32.0,96.7L31.5,96.0L31.5,69.0L32.5,64.0L36.0,58.0L39.0,55.7L43.0,53.7L48.0,52.7L206.0,52.7L213.0,54.0L216.0,55.7L219.7,59.0L222.3,63.0L223.3,66.0L223.5,128.0ZM76.0,175.3L74.0,175.5L71.0,174.7L68.7,172.0L49.3,133.0L32.0,132.7L31.5,132.0L31.5,123.0L32.0,122.3L53.0,122.3L56.0,123.3L59.5,129.0L74.0,157.7L75.0,157.0L76.0,154.0L77.0,153.0L77.0,152.0L79.0,149.0L79.0,148.0L80.0,147.0L80.0,146.0L81.0,145.0L81.0,144.0L82.0,143.0L82.0,142.0L83.0,141.0L83.0,140.0L84.0,139.0L84.0,138.0L85.0,137.0L85.0,136.0L86.0,135.0L86.0,134.0L87.0,133.0L88.0,130.0L89.0,129.0L89.0,128.0L90.0,127.0L90.0,126.0L91.0,125.0L91.0,124.0L92.0,123.0L92.0,122.0L93.0,121.0L93.0,120.0L94.0,119.0L94.0,118.0L95.0,117.0L96.0,114.0L97.0,113.0L97.0,112.0L98.0,111.0L99.0,108.0L100.0,107.0L100.0,106.0L101.0,105.0L102.0,102.0L103.0,101.0L103.0,100.0L104.0,99.0L104.0,98.0L105.0,97.0L106.0,94.0L107.0,93.0L107.0,92.0L109.0,89.0L109.0,88.0L110.0,87.0L110.0,86.0L111.0,85.0L111.0,84.0L114.0,80.7L117.0,80.0L119.0,80.5L121.0,82.0L122.3,84.0L142.3,124.0L142.0,125.0L135.0,130.7L134.0,131.3L133.7,131.0L117.3,98.0L117.0,97.5L116.0,98.0L78.5,173.0ZM187.0,223.0L180.0,223.5L171.0,222.5L166.0,221.0L155.0,215.0L149.7,210.0L144.7,204.0L140.7,196.0L139.3,190.0L138.7,189.0L138.3,179.0L139.0,172.0L141.0,165.0L145.0,157.0L148.0,154.0L150.0,151.0L158.0,144.7L166.0,140.7L173.0,138.7L183.0,138.3L190.0,139.0L197.0,141.0L205.0,145.5L212.3,152.0L217.0,158.0L220.3,164.0L222.7,172.0L223.5,180.0L223.0,188.0L221.0,196.0L217.0,204.0L209.0,213.0L203.0,217.3L195.0,221.3ZM116.0,202.0L49.0,202.3L42.0,201.0L40.0,200.0L35.3,196.0L32.7,192.0L31.7,189.0L31.5,159.0L32.0,158.3L41.0,158.3L42.3,159.0L42.3,186.0L44.0,189.0L46.0,191.0L49.0,191.5L113.0,191.5L113.7,192.0L114.3,194.0ZM183.3,184.0L203.3,164.0L198.0,158.5L177.3,179.0L182.0,183.7L183.0,184.3Z" />
android:pathData="M 7.73 16.5 h 1 V 12 h -1 z m 7.54 0 h 1 V 7 h -1 z m -3.77 0 h 1 V 14 h -1 z m 0 -4.5 h 1 v -2 h -1 z m -5.884 8 q -.691 0 -1.153 -.462 T 4 18.384 V 5.616 q 0 -.691 .463 -1.153 T 5.616 4 h 12.769 q .69 0 1.153 .463 T 20 5.616 v 12.769 q 0 .69 -.462 1.153 T 18.384 20 z" />
</vector>
@@ -0,0 +1,10 @@
<!-- Material Symbols Light "settings" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="m 10.135 21 l -.362 -2.892 q -.479 -.145 -1.035 -.454 q -.557 -.31 -.947 -.664 l -2.668 1.135 l -1.865 -3.25 l 2.306 -1.739 q -.045 -.27 -.073 -.558 q -.03 -.288 -.03 -.559 q 0 -.252 .03 -.53 q .028 -.278 .073 -.626 L 3.258 9.126 l 1.865 -3.212 L 7.771 7.03 q .448 -.373 .97 -.673 q .52 -.3 1.013 -.464 L 10.134 3 h 3.732 l .361 2.912 q .575 .202 1.016 .463 t .909 .654 l 2.725 -1.115 l 1.865 3.211 l -2.382 1.796 q .082 .31 .092 .569 t .01 .51 q 0 .233 -.02 .491 q -.019 .259 -.088 .626 l 2.344 1.758 l -1.865 3.25 l -2.681 -1.154 q -.467 .393 -.94 .673 t -.985 .445 L 13.866 21 z m 1.838 -6.5 q 1.046 0 1.773 -.727 T 14.473 12 t -.727 -1.773 t -1.773 -.727 q -1.052 0 -1.776 .727 T 9.473 12 t .724 1.773 t 1.776 .727" />
</vector>
+10
View File
@@ -0,0 +1,10 @@
<!-- Material Symbols Light "update" by Google, Apache License 2.0 -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M 12.02 20 q -1.664 0 -3.119 -.626 T 6.359 17.66 t -1.714 -2.542 T 4.02 12 t .626 -3.118 T 6.36 6.34 T 8.9 4.626 T 12.019 4 q 1.723 0 3.282 .712 q 1.559 .711 2.718 1.984 V 4.308 h 1 v 4.154 h -4.153 v -1 h 2.48 q -1.044 -1.15 -2.41 -1.806 Q 13.572 5 12.02 5 Q 9.094 5 7.057 7.038 T 5.019 12 t 2.038 4.963 T 12.019 19 q 2.625 0 4.569 -1.71 t 2.35 -4.29 h 1.012 q -.356 3.021 -2.62 5.01 Q 15.066 20 12.02 20 m 3.146 -4.146 l -3.647 -3.646 V 7 h 1 v 4.792 l 3.354 3.354 z" />
</vector>
+74 -15
View File
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="status_on">Geschützt</string>
<string name="status_off">Getrennt</string>
<string name="via">über %1$s</string>
<string name="connect">Verbinden</string>
<string name="disconnect">Trennen</string>
<string name="servers">DNS-over-HTTPS-Server</string>
@@ -26,14 +23,10 @@
<string name="notif_title">Geschützt über %1$s</string>
<string name="notif_text">DNS über HTTPS ist aktiv</string>
<string name="tab_home">Start</string>
<string name="tab_monitor">Monitor</string>
<string name="tab_apps">Apps</string>
<string name="tab_blocklist">Sperrliste</string>
<string name="tab_about">Info</string>
<string name="mon_queries">Anfragen</string>
<string name="mon_cached">Aus dem Cache</string>
<string name="mon_blocked">Blockiert</string>
<string name="mon_latency">Ø Latenz</string>
<string name="mon_ms">%1$d ms</string>
<string name="mon_all">Alle</string>
<string name="mon_errors">Fehler</string>
@@ -60,12 +53,9 @@
<string name="bl_invalid">Ungültige Domain</string>
<string name="bl_empty_custom">Noch keine Domains</string>
<string name="delete">Löschen</string>
<string name="bl_lists">Listen</string>
<string name="bl_update_all">Alle aktualisieren</string>
<string name="bl_updating">Wird aktualisiert…</string>
<string name="bl_list_url">Listen-URL</string>
<string name="bl_list_info">%1$s Domains · %2$s</string>
<string name="bl_presets">Beliebte Listen</string>
<string name="bl_download_failed">Download fehlgeschlagen: %1$s</string>
<string name="about_desc">DNS-Anfragen verschlüsseln, ohne den gesamten Verkehr über ein VPN zu leiten.</string>
<string name="about_version">Version</string>
@@ -90,13 +80,82 @@
<string name="licenses_data">Sperrlisten-Daten (bei Bedarf geladen, nicht enthalten)</string>
<string name="license_view">Lizenz ansehen</string>
<string name="back">Zurück</string>
<string name="bl_total_label">Domains blockiert</string>
<string name="about_source">Quellcode</string>
<string name="open_settings">Einstellungen</string>
<string name="mon_no_match">Nichts passt zum Filter</string>
<string name="bl_title">Blockierung</string>
<string name="servers_update">Serverliste aktualisieren</string>
<string name="servers_updated">Serverliste aktualisiert</string>
<string name="servers_update_failed">Serverliste konnte nicht aktualisiert werden: %1$s</string>
<string name="no_browser">Keine App zum Öffnen dieses Links gefunden</string>
<string name="toggle_on">AN</string>
<string name="toggle_off">AUS</string>
<string name="home_protected">Du bist geschützt</string>
<string name="home_unprotected">Du bist nicht geschützt</string>
<string name="home_via">Verschlüsselt über %1$s</string>
<string name="home_off_desc">DNS läuft wie gewohnt über dein Netzwerk</string>
<string name="stat_requests">Anfragen</string>
<string name="stat_avg">Ø Zeit</string>
<string name="chart_now">Jetzt</string>
<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="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 und andere Websites geht.</string>
<string name="companies_other">Andere</string>
<string name="recent_title">Letzte Anfragen</string>
<string name="filter">Filter</string>
<string name="bl_search">Listen suchen</string>
<string name="auto_update">Automatisch aktualisieren</string>
<string name="auto_off">Aus</string>
<string name="auto_daily">Täglich</string>
<string name="auto_weekly">Wöchentlich</string>
<string name="auto_wifi">Nur über WLAN</string>
<string name="auto_wifi_desc">Keine Updates über mobile Daten</string>
<string name="auto_update_now">Jetzt aktualisieren</string>
<string name="done">Fertig</string>
<string name="cancel">Abbrechen</string>
<string name="preset_pro_desc">Ausgewogener Schutz vor Werbung, Tracking und Malware. Die beste Wahl für jeden Tag.</string>
<string name="preset_proplus_desc">Maximaler Schutz. Kann Anmeldungen in manchen Apps und Links stören.</string>
<string name="preset_tif_desc">Bedrohungsdaten: Domains für Malware, Phishing, Betrug und Cryptojacking.</string>
<string name="list_added_by_you">Von dir per URL hinzugefügt.</string>
<string name="list_not_downloaded">Noch nicht heruntergeladen</string>
<string name="my_domains_desc">Domains, die du selbst blockiert hast. Subdomains werden ebenfalls blockiert.</string>
<string name="bl_add_list">Neue Blockliste hinzufügen</string>
<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>
<string name="alert_channel">Schutzwarnungen</string>
<string name="alert_stopped_title">DNS-Schutz beendet</string>
<string name="alert_stopped_text">Der Tunnel funktioniert nicht mehr, DNS ist nicht mehr verschlüsselt. Öffne SparkleDNS, um dich erneut zu verbinden.</string>
<string name="alert_bad_url_title">DNS-Schutz nicht gestartet</string>
<string name="alert_bad_url_text">Die Serveradresse ist keine gültige HTTPS-URL. Öffne SparkleDNS und prüfe den Server.</string>
<string name="alert_lockdown_title">DNS-Server nicht erreichbar</string>
<string name="alert_lockdown_text">„Verbindungen ohne VPN blockieren“ ist aktiv, daher erreicht SparkleDNS den DNS-Server nicht und Anfragen schlagen fehl. Schalte es in den VPN-Einstellungen von Android aus.</string>
<string name="key_label">Zugangsschlüssel</string>
<string name="key_hint">Füge den Schlüssel oder die ganze Adresse aus deinem Konto auf skysparkle.cc ein</string>
<string name="key_invalid">Das sieht nicht wie ein Schlüssel aus. Kopiere ihn erneut auf der Seite „Schlüssel“.</string>
<string name="key_get">Kostenlosen Schlüssel holen</string>
<string name="key_needed">Der SkySparkle-Server braucht einen persönlichen Zugangsschlüssel. Er ist kostenlos: Erstelle ein Konto auf skysparkle.cc und füge den Schlüssel hinzu.</string>
<string name="key_add">Schlüssel hinzufügen</string>
<string name="alert_no_key_text">Der SkySparkle-Server braucht einen Zugangsschlüssel. Öffne SparkleDNS und füge deinen Schlüssel unter Einstellungen hinzu.</string>
<string name="onb_welcome_title">Willkommen bei SparkleDNS</string>
<string name="onb_welcome_text">Privates DNS für dein ganzes Handy, ohne Server der großen Tech-Konzerne.</string>
<string name="onb_point_encrypt">Verschlüsselt jede DNS-Anfrage mit DNS-over-HTTPS</string>
<string name="onb_point_block">Blockiert Werbung und Tracker in allen Apps</string>
<string name="onb_point_independent">Nur unabhängige Server, nie Google oder Cloudflare</string>
<string name="onb_key_title">Hol dir deinen Zugangsschlüssel</string>
<string name="onb_key_text">Der SkySparkle-Server arbeitet mit einem persönlichen Schlüssel. Der kostenlose Tarif hat Grenzen, die bezahlten nicht.</string>
<string name="onb_key_step1">Erstelle ein kostenloses Konto auf skysparkle.cc</string>
<string name="onb_key_step2">Öffne „Schlüssel“ und erstelle einen Schlüssel für dieses Handy</string>
<string name="onb_key_step3">Kopiere den Schlüssel oder die Adresse und füge sie unten ein</string>
<string name="onb_next">Weiter</string>
<string name="onb_done">Starten</string>
<string name="onb_skip">Überspringen, ich wähle einen anderen Server</string>
</resources>
+74 -15
View File
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="status_on">保護中</string>
<string name="status_off">未接続</string>
<string name="via">%1$s 経由</string>
<string name="connect">接続</string>
<string name="disconnect">切断</string>
<string name="servers">DNS-over-HTTPS サーバー</string>
@@ -26,14 +23,10 @@
<string name="notif_title">%1$s 経由で保護中</string>
<string name="notif_text">DNS over HTTPS が有効です</string>
<string name="tab_home">ホーム</string>
<string name="tab_monitor">モニター</string>
<string name="tab_apps">アプリ</string>
<string name="tab_blocklist">ブロックリスト</string>
<string name="tab_about">情報</string>
<string name="mon_queries">クエリ</string>
<string name="mon_cached">キャッシュから</string>
<string name="mon_blocked">ブロック済み</string>
<string name="mon_latency">平均遅延</string>
<string name="mon_ms">%1$d ms</string>
<string name="mon_all">すべて</string>
<string name="mon_errors">エラー</string>
@@ -60,12 +53,9 @@
<string name="bl_invalid">無効なドメイン</string>
<string name="bl_empty_custom">まだドメインはありません</string>
<string name="delete">削除</string>
<string name="bl_lists">リスト</string>
<string name="bl_update_all">すべて更新</string>
<string name="bl_updating">更新中…</string>
<string name="bl_list_url">リストの URL</string>
<string name="bl_list_info">%1$s ドメイン · %2$s</string>
<string name="bl_presets">人気のリスト</string>
<string name="bl_download_failed">ダウンロードに失敗しました: %1$s</string>
<string name="about_desc">すべての通信をVPNに通さずに、DNSリクエストを暗号化します。</string>
<string name="about_version">バージョン</string>
@@ -90,13 +80,82 @@
<string name="licenses_data">ブロックリストのデータ(必要なときにダウンロード、同梱なし)</string>
<string name="license_view">ライセンスを見る</string>
<string name="back">戻る</string>
<string name="bl_total_label">件のドメインをブロック</string>
<string name="about_source">ソースコード</string>
<string name="open_settings">設定</string>
<string name="mon_no_match">フィルターに一致するものはありません</string>
<string name="bl_title">ブロック</string>
<string name="servers_update">サーバーリストを更新</string>
<string name="servers_updated">サーバーリストを更新しました</string>
<string name="servers_update_failed">サーバーリストを更新できませんでした: %1$s</string>
<string name="no_browser">このリンクを開けるアプリがありません</string>
<string name="toggle_on">オン</string>
<string name="toggle_off">オフ</string>
<string name="home_protected">保護されています</string>
<string name="home_unprotected">保護されていません</string>
<string name="home_via">%1$s で暗号化</string>
<string name="home_off_desc">DNS は通常どおりネットワークを経由します</string>
<string name="stat_requests">リクエスト</string>
<string name="stat_avg">平均時間</string>
<string name="chart_now">現在</string>
<string name="period_24h">24 時間</string>
<string name="period_7d">7 日間</string>
<string name="home_lists_info">有効なリスト: %1$d · ルール: %2$s</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="recent_title">最近のアクティビティ</string>
<string name="filter">フィルター</string>
<string name="bl_search">リストを検索</string>
<string name="auto_update">自動更新</string>
<string name="auto_off">オフ</string>
<string name="auto_daily">毎日</string>
<string name="auto_weekly">毎週</string>
<string name="auto_wifi">Wi-Fi のみ</string>
<string name="auto_wifi_desc">モバイルデータでは更新しない</string>
<string name="auto_update_now">今すぐ更新</string>
<string name="done">完了</string>
<string name="cancel">キャンセル</string>
<string name="preset_pro_desc">広告・トラッキング・マルウェアからのバランスの取れた保護。普段使いに最適です。</string>
<string name="preset_proplus_desc">最大限の保護。一部のアプリのログインやリンクが動かなくなることがあります。</string>
<string name="preset_tif_desc">脅威インテリジェンス: マルウェア、フィッシング、詐欺、クリプトジャッキングのドメイン。</string>
<string name="list_added_by_you">URL から追加したリストです。</string>
<string name="list_not_downloaded">未ダウンロード</string>
<string name="my_domains_desc">自分でブロックしたドメイン。サブドメインもブロックされます。</string>
<string name="bl_add_list">ブロックリストを追加</string>
<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>
<string name="alert_channel">保護に関する警告</string>
<string name="alert_stopped_title">DNS 保護が停止しました</string>
<string name="alert_stopped_text">トンネルが動作しなくなったため、DNS は暗号化されていません。SparkleDNS を開いて再接続してください。</string>
<string name="alert_bad_url_title">DNS 保護を開始できません</string>
<string name="alert_bad_url_text">サーバーのアドレスが有効な HTTPS URL ではありません。SparkleDNS を開いてサーバーを確認してください。</string>
<string name="alert_lockdown_title">DNS サーバーに接続できません</string>
<string name="alert_lockdown_text">「VPN なしの接続をブロック」がオンのため、SparkleDNS は DNS サーバーに接続できず、名前解決に失敗します。Android の VPN 設定でオフにしてください。</string>
<string name="key_label">アクセスキー</string>
<string name="key_hint">skysparkle.cc のアカウントからキーまたはアドレス全体を貼り付けてください</string>
<string name="key_invalid">キーの形式ではありません。「キー」ページからもう一度コピーしてください。</string>
<string name="key_get">無料のキーを取得</string>
<string name="key_needed">SkySparkle サーバーには個人用のアクセスキーが必要です。無料です:skysparkle.cc でアカウントを作成してキーを追加してください。</string>
<string name="key_add">キーを追加</string>
<string name="alert_no_key_text">SkySparkle サーバーにはアクセスキーが必要です。SparkleDNS を開いて「設定」でキーを追加してください。</string>
<string name="onb_welcome_title">SparkleDNS へようこそ</string>
<string name="onb_welcome_text">大手 IT 企業のサーバーを使わない、スマホ全体のプライベート DNS。</string>
<string name="onb_point_encrypt">DNS-over-HTTPS ですべての DNS 問い合わせを暗号化</string>
<string name="onb_point_block">すべてのアプリで広告とトラッカーをブロック</string>
<string name="onb_point_independent">独立系サーバーのみ。Google や Cloudflare は使いません</string>
<string name="onb_key_title">アクセスキーを取得</string>
<string name="onb_key_text">SkySparkle サーバーは個人用キーで動作します。無料プランには制限があり、有料プランにはありません。</string>
<string name="onb_key_step1">skysparkle.cc で無料アカウントを作成</string>
<string name="onb_key_step2">「キー」を開き、このスマホ用のキーを作成</string>
<string name="onb_key_step3">キーまたはアドレスをコピーして下に貼り付け</string>
<string name="onb_next">次へ</string>
<string name="onb_done">開始</string>
<string name="onb_skip">スキップして別のサーバーを選ぶ</string>
</resources>
+74 -15
View File
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="status_on">Apsaugota</string>
<string name="status_off">Atsijungta</string>
<string name="via">per %1$s</string>
<string name="connect">Prisijungti</string>
<string name="disconnect">Atsijungti</string>
<string name="servers">DNS-over-HTTPS serveris</string>
@@ -26,14 +23,10 @@
<string name="notif_title">Apsaugota per %1$s</string>
<string name="notif_text">DNS per HTTPS įjungtas</string>
<string name="tab_home">Pradžia</string>
<string name="tab_monitor">Stebėjimas</string>
<string name="tab_apps">Programėlės</string>
<string name="tab_blocklist">Blokavimo sąrašas</string>
<string name="tab_about">Apie</string>
<string name="mon_queries">Užklausos</string>
<string name="mon_cached">Iš talpyklos</string>
<string name="mon_blocked">Užblokuota</string>
<string name="mon_latency">Vid. delsa</string>
<string name="mon_ms">%1$d ms</string>
<string name="mon_all">Visos</string>
<string name="mon_errors">Klaidos</string>
@@ -60,12 +53,9 @@
<string name="bl_invalid">Netinkamas domenas</string>
<string name="bl_empty_custom">Domenų dar nėra</string>
<string name="delete">Ištrinti</string>
<string name="bl_lists">Sąrašai</string>
<string name="bl_update_all">Atnaujinti visus</string>
<string name="bl_updating">Atnaujinama…</string>
<string name="bl_list_url">Sąrašo URL</string>
<string name="bl_list_info">%1$s domenų · %2$s</string>
<string name="bl_presets">Populiarūs sąrašai</string>
<string name="bl_download_failed">Atsisiųsti nepavyko: %1$s</string>
<string name="about_desc">Šifruokite DNS užklausas, nenukreipdami viso srauto per VPN.</string>
<string name="about_version">Versija</string>
@@ -90,13 +80,82 @@
<string name="licenses_data">Blokavimo sąrašų duomenys (atsisiunčiami pagal poreikį, neįtraukti)</string>
<string name="license_view">Peržiūrėti licenciją</string>
<string name="back">Atgal</string>
<string name="bl_total_label">užblokuotų domenų</string>
<string name="about_source">Šaltinio kodas</string>
<string name="open_settings">Nustatymai</string>
<string name="mon_no_match">Filtro neatitinka niekas</string>
<string name="bl_title">Blokavimas</string>
<string name="servers_update">Atnaujinti serverių sąrašą</string>
<string name="servers_updated">Serverių sąrašas atnaujintas</string>
<string name="servers_update_failed">Nepavyko atnaujinti serverių sąrašo: %1$s</string>
<string name="no_browser">Nerasta programėlės šiai nuorodai atidaryti</string>
<string name="toggle_on">ĮJ.</string>
<string name="toggle_off">IŠJ.</string>
<string name="home_protected">Jūs apsaugoti</string>
<string name="home_unprotected">Jūs neapsaugoti</string>
<string name="home_via">Šifruojama per %1$s</string>
<string name="home_off_desc">DNS eina per jūsų tinklą kaip įprasta</string>
<string name="stat_requests">Užklausos</string>
<string name="stat_avg">Vid. laikas</string>
<string name="chart_now">Dabar</string>
<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="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 ir kitoms svetainėms.</string>
<string name="companies_other">Kitos</string>
<string name="recent_title">Naujausios užklausos</string>
<string name="filter">Filtras</string>
<string name="bl_search">Ieškoti sąrašų</string>
<string name="auto_update">Automatinis atnaujinimas</string>
<string name="auto_off">Išjungta</string>
<string name="auto_daily">Kasdien</string>
<string name="auto_weekly">Kas savaitę</string>
<string name="auto_wifi">Tik per Wi-Fi</string>
<string name="auto_wifi_desc">Neatnaujinti per mobiliuosius duomenis</string>
<string name="auto_update_now">Atnaujinti dabar</string>
<string name="done">Atlikta</string>
<string name="cancel">Atšaukti</string>
<string name="preset_pro_desc">Subalansuota apsauga nuo reklamų, sekimo ir kenkėjiškų svetainių. Geriausias pasirinkimas kasdien.</string>
<string name="preset_proplus_desc">Didžiausia apsauga. Gali sutrikdyti prisijungimą kai kuriose programėlėse ir nuorodas.</string>
<string name="preset_tif_desc">Grėsmių žvalgybos duomenys: kenkėjiški, sukčiavimo ir kriptovaliutų kasimo domenai.</string>
<string name="list_added_by_you">Pridėjote jūs pagal nuorodą.</string>
<string name="list_not_downloaded">Dar neatsisiųsta</string>
<string name="my_domains_desc">Domenai, kuriuos užblokavote patys. Blokuojami ir subdomenai.</string>
<string name="bl_add_list">Pridėti blokavimo sąrašą</string>
<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>
<string name="alert_channel">Apsaugos įspėjimai</string>
<string name="alert_stopped_title">DNS apsauga išjungta</string>
<string name="alert_stopped_text">Tunelis nustojo veikti, DNS nebešifruojamas. Atidarykite SparkleDNS, kad prisijungtumėte iš naujo.</string>
<string name="alert_bad_url_title">DNS apsauga nepaleista</string>
<string name="alert_bad_url_text">Serverio adresas nėra tinkamas HTTPS adresas. Atidarykite SparkleDNS ir patikrinkite serverį.</string>
<string name="alert_lockdown_title">DNS serveris nepasiekiamas</string>
<string name="alert_lockdown_text">Įjungta „Blokuoti ryšius be VPN“, todėl SparkleDNS negali pasiekti DNS serverio ir užklausos nepavyksta. Išjunkite tai Android VPN nustatymuose.</string>
<string name="key_label">Prieigos raktas</string>
<string name="key_hint">Įklijuokite raktą arba visą adresą iš savo paskyros skysparkle.cc</string>
<string name="key_invalid">Tai nepanašu į raktą. Nukopijuokite jį dar kartą puslapyje „Raktai“.</string>
<string name="key_get">Gauti nemokamą raktą</string>
<string name="key_needed">SkySparkle serveriui reikia asmeninio prieigos rakto. Tai nemokama: susikurkite paskyrą skysparkle.cc ir pridėkite raktą.</string>
<string name="key_add">Pridėti raktą</string>
<string name="alert_no_key_text">SkySparkle serveriui reikia prieigos rakto. Atidarykite SparkleDNS ir pridėkite raktą skiltyje „Nustatymai“.</string>
<string name="onb_welcome_title">Sveiki atvykę į SparkleDNS</string>
<string name="onb_welcome_text">Privatus DNS visam telefonui, be didžiųjų technologijų įmonių serverių.</string>
<string name="onb_point_encrypt">Šifruoja kiekvieną DNS užklausą per DNS-over-HTTPS</string>
<string name="onb_point_block">Blokuoja reklamas ir sekiklius visose programėlėse</string>
<string name="onb_point_independent">Tik nepriklausomi serveriai, jokio Google ar Cloudflare</string>
<string name="onb_key_title">Gaukite prieigos raktą</string>
<string name="onb_key_text">SkySparkle serveris veikia su asmeniniu raktu. Nemokamas planas turi apribojimų, mokami – ne.</string>
<string name="onb_key_step1">Susikurkite nemokamą paskyrą skysparkle.cc</string>
<string name="onb_key_step2">Atidarykite „Raktai“ ir sukurkite raktą šiam telefonui</string>
<string name="onb_key_step3">Nukopijuokite raktą arba adresą ir įklijuokite žemiau</string>
<string name="onb_next">Toliau</string>
<string name="onb_done">Pradėti</string>
<string name="onb_skip">Praleisti, pasirinksiu kitą serverį</string>
</resources>
+74 -15
View File
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="status_on">Защищено</string>
<string name="status_off">Отключено</string>
<string name="via">через %1$s</string>
<string name="connect">Подключить</string>
<string name="disconnect">Отключить</string>
<string name="servers">Сервер DNS-over-HTTPS</string>
@@ -26,14 +23,10 @@
<string name="notif_title">Защищено через %1$s</string>
<string name="notif_text">DNS через HTTPS активен</string>
<string name="tab_home">Главная</string>
<string name="tab_monitor">Монитор</string>
<string name="tab_apps">Приложения</string>
<string name="tab_blocklist">Блоклист</string>
<string name="tab_about">О программе</string>
<string name="mon_queries">Запросы</string>
<string name="mon_cached">Из кэша</string>
<string name="mon_blocked">Заблокировано</string>
<string name="mon_latency">Средняя задержка</string>
<string name="mon_ms">%1$d мс</string>
<string name="mon_all">Все</string>
<string name="mon_errors">Ошибки</string>
@@ -60,12 +53,9 @@
<string name="bl_invalid">Неверный домен</string>
<string name="bl_empty_custom">Пока пусто</string>
<string name="delete">Удалить</string>
<string name="bl_lists">Списки</string>
<string name="bl_update_all">Обновить все</string>
<string name="bl_updating">Обновление…</string>
<string name="bl_list_url">URL списка</string>
<string name="bl_list_info">%1$s доменов · %2$s</string>
<string name="bl_presets">Популярные списки</string>
<string name="bl_download_failed">Ошибка загрузки: %1$s</string>
<string name="about_desc">Шифруйте DNS-запросы, не пропуская весь трафик через VPN.</string>
<string name="about_version">Версия</string>
@@ -90,13 +80,82 @@
<string name="licenses_data">Данные блоклистов (загружаются по запросу, не входят в приложение)</string>
<string name="license_view">Текст лицензии</string>
<string name="back">Назад</string>
<string name="bl_total_label">доменов заблокировано</string>
<string name="about_source">Исходный код</string>
<string name="open_settings">Настройки</string>
<string name="mon_no_match">Ничего не найдено</string>
<string name="bl_title">Блокировка</string>
<string name="servers_update">Обновить список серверов</string>
<string name="servers_updated">Список серверов обновлён</string>
<string name="servers_update_failed">Не удалось обновить список серверов: %1$s</string>
<string name="no_browser">Не найдено приложение, чтобы открыть ссылку</string>
<string name="toggle_on">ВКЛ</string>
<string name="toggle_off">ВЫКЛ</string>
<string name="home_protected">Вы защищены</string>
<string name="home_unprotected">Вы не защищены</string>
<string name="home_via">Шифруется через %1$s</string>
<string name="home_off_desc">DNS идёт через вашу сеть как обычно</string>
<string name="stat_requests">Запросы</string>
<string name="stat_avg">Среднее время</string>
<string name="chart_now">Сейчас</string>
<string name="period_24h">24 часа</string>
<string name="period_7d">7 дней</string>
<string name="home_lists_info">Включено списков: %1$d · правил: %2$s</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="recent_title">Последние запросы</string>
<string name="filter">Фильтр</string>
<string name="bl_search">Поиск списков</string>
<string name="auto_update">Автообновление</string>
<string name="auto_off">Выкл</string>
<string name="auto_daily">Ежедневно</string>
<string name="auto_weekly">Еженедельно</string>
<string name="auto_wifi">Только по Wi-Fi</string>
<string name="auto_wifi_desc">Не обновлять через мобильный интернет</string>
<string name="auto_update_now">Обновить сейчас</string>
<string name="done">Готово</string>
<string name="cancel">Отмена</string>
<string name="preset_pro_desc">Сбалансированная защита от рекламы, трекинга и вредоносных сайтов. Лучший выбор на каждый день.</string>
<string name="preset_proplus_desc">Максимальная защита. Может ломать вход в некоторые приложения и ссылки.</string>
<string name="preset_tif_desc">Данные об угрозах: вредоносные, фишинговые, мошеннические и майнинговые домены.</string>
<string name="list_added_by_you">Добавлен вами по ссылке.</string>
<string name="list_not_downloaded">Ещё не загружен</string>
<string name="my_domains_desc">Домены, которые вы заблокировали сами. Поддомены блокируются тоже.</string>
<string name="bl_add_list">Добавить блок-лист</string>
<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>
<string name="alert_channel">Предупреждения о защите</string>
<string name="alert_stopped_title">Защита DNS отключена</string>
<string name="alert_stopped_text">Туннель перестал работать, DNS больше не шифруется. Откройте SparkleDNS, чтобы подключиться снова.</string>
<string name="alert_bad_url_title">Защита DNS не запущена</string>
<string name="alert_bad_url_text">Адрес сервера не является корректным HTTPS-адресом. Откройте SparkleDNS и проверьте сервер.</string>
<string name="alert_lockdown_title">DNS-сервер недоступен</string>
<string name="alert_lockdown_text">Включено «Блокировать соединения без VPN», поэтому SparkleDNS не может связаться с DNS-сервером и запросы не проходят. Отключите это в настройках VPN Android.</string>
<string name="key_label">Ключ доступа</string>
<string name="key_hint">Вставьте ключ или весь адрес из аккаунта на skysparkle.cc</string>
<string name="key_invalid">Это не похоже на ключ. Скопируйте его ещё раз на странице «Ключи».</string>
<string name="key_get">Получить бесплатный ключ</string>
<string name="key_needed">Серверу SkySparkle нужен личный ключ доступа. Это бесплатно: создайте аккаунт на skysparkle.cc и добавьте ключ.</string>
<string name="key_add">Добавить ключ</string>
<string name="alert_no_key_text">Серверу SkySparkle нужен ключ доступа. Откройте SparkleDNS и добавьте ключ в разделе «Настройки».</string>
<string name="onb_welcome_title">Добро пожаловать в SparkleDNS</string>
<string name="onb_welcome_text">Приватный DNS для всего телефона, без серверов крупных корпораций.</string>
<string name="onb_point_encrypt">Шифрует каждый DNS-запрос через DNS-over-HTTPS</string>
<string name="onb_point_block">Блокирует рекламу и трекеры во всех приложениях</string>
<string name="onb_point_independent">Только независимые серверы, без Google и Cloudflare</string>
<string name="onb_key_title">Получите ключ доступа</string>
<string name="onb_key_text">Сервер SkySparkle работает по личному ключу. У бесплатного тарифа есть ограничения, у платных — нет.</string>
<string name="onb_key_step1">Создайте бесплатный аккаунт на skysparkle.cc</string>
<string name="onb_key_step2">Откройте «Ключи» и создайте ключ для этого телефона</string>
<string name="onb_key_step3">Скопируйте ключ или адрес и вставьте ниже</string>
<string name="onb_next">Далее</string>
<string name="onb_done">Начать</string>
<string name="onb_skip">Пропустить, выберу другой сервер</string>
</resources>
+74 -15
View File
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="status_on">已保护</string>
<string name="status_off">未连接</string>
<string name="via">通过 %1$s</string>
<string name="connect">连接</string>
<string name="disconnect">断开</string>
<string name="servers">DNS-over-HTTPS 服务器</string>
@@ -26,14 +23,10 @@
<string name="notif_title">已通过 %1$s 保护</string>
<string name="notif_text">DNS over HTTPS 已启用</string>
<string name="tab_home">首页</string>
<string name="tab_monitor">监控</string>
<string name="tab_apps">应用</string>
<string name="tab_blocklist">屏蔽列表</string>
<string name="tab_about">关于</string>
<string name="mon_queries">查询</string>
<string name="mon_cached">来自缓存</string>
<string name="mon_blocked">已屏蔽</string>
<string name="mon_latency">平均延迟</string>
<string name="mon_ms">%1$d 毫秒</string>
<string name="mon_all">全部</string>
<string name="mon_errors">错误</string>
@@ -60,12 +53,9 @@
<string name="bl_invalid">域名无效</string>
<string name="bl_empty_custom">还没有域名</string>
<string name="delete">删除</string>
<string name="bl_lists">列表</string>
<string name="bl_update_all">全部更新</string>
<string name="bl_updating">正在更新…</string>
<string name="bl_list_url">列表 URL</string>
<string name="bl_list_info">%1$s 个域名 · %2$s</string>
<string name="bl_presets">热门列表</string>
<string name="bl_download_failed">下载失败:%1$s</string>
<string name="about_desc">加密 DNS 请求,无需让全部流量经过 VPN。</string>
<string name="about_version">版本</string>
@@ -90,13 +80,82 @@
<string name="licenses_data">屏蔽列表数据(按需下载,未内置)</string>
<string name="license_view">查看许可</string>
<string name="back">返回</string>
<string name="bl_total_label">个域名已屏蔽</string>
<string name="about_source">源代码</string>
<string name="open_settings">设置</string>
<string name="mon_no_match">没有符合筛选条件的内容</string>
<string name="bl_title">屏蔽</string>
<string name="servers_update">更新服务器列表</string>
<string name="servers_updated">服务器列表已更新</string>
<string name="servers_update_failed">无法更新服务器列表:%1$s</string>
<string name="no_browser">没有可以打开此链接的应用</string>
<string name="toggle_on">开</string>
<string name="toggle_off">关</string>
<string name="home_protected">已受保护</string>
<string name="home_unprotected">未受保护</string>
<string name="home_via">通过 %1$s 加密</string>
<string name="home_off_desc">DNS 照常通过你的网络</string>
<string name="stat_requests">请求</string>
<string name="stat_avg">平均耗时</string>
<string name="chart_now">现在</string>
<string name="period_24h">24 小时</string>
<string name="period_7d">7 天</string>
<string name="home_lists_info">已启用列表:%1$d · 规则:%2$s</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="recent_title">最近活动</string>
<string name="filter">筛选</string>
<string name="bl_search">搜索列表</string>
<string name="auto_update">自动更新</string>
<string name="auto_off">关闭</string>
<string name="auto_daily">每天</string>
<string name="auto_weekly">每周</string>
<string name="auto_wifi">仅限 Wi-Fi</string>
<string name="auto_wifi_desc">不使用移动数据更新</string>
<string name="auto_update_now">立即更新</string>
<string name="done">完成</string>
<string name="cancel">取消</string>
<string name="preset_pro_desc">均衡地拦截广告、跟踪和恶意软件。日常使用的最佳选择。</string>
<string name="preset_proplus_desc">最强保护。可能导致部分应用登录和链接失效。</string>
<string name="preset_tif_desc">威胁情报:恶意软件、钓鱼、诈骗和挖矿劫持域名。</string>
<string name="list_added_by_you">你通过网址添加。</string>
<string name="list_not_downloaded">尚未下载</string>
<string name="my_domains_desc">你自己屏蔽的域名。子域名也会被屏蔽。</string>
<string name="bl_add_list">添加屏蔽列表</string>
<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>
<string name="alert_channel">保护警告</string>
<string name="alert_stopped_title">DNS 保护已停止</string>
<string name="alert_stopped_text">隧道已停止工作,DNS 不再加密。请打开 SparkleDNS 重新连接。</string>
<string name="alert_bad_url_title">DNS 保护未启动</string>
<string name="alert_bad_url_text">服务器地址不是有效的 HTTPS 网址。请打开 SparkleDNS 检查服务器。</string>
<string name="alert_lockdown_title">无法连接 DNS 服务器</string>
<string name="alert_lockdown_text">已开启“屏蔽未使用 VPN 的连接”,SparkleDNS 无法连接 DNS 服务器,解析会失败。请在 Android 的 VPN 设置中关闭该选项。</string>
<string name="key_label">访问密钥</string>
<string name="key_hint">粘贴 skysparkle.cc 账户中的密钥或完整地址</string>
<string name="key_invalid">这看起来不像密钥。请在“密钥”页面重新复制。</string>
<string name="key_get">获取免费密钥</string>
<string name="key_needed">SkySparkle 服务器需要个人访问密钥。完全免费:在 skysparkle.cc 创建账户并添加密钥。</string>
<string name="key_add">添加密钥</string>
<string name="alert_no_key_text">SkySparkle 服务器需要访问密钥。请打开 SparkleDNS,在“设置”中添加密钥。</string>
<string name="onb_welcome_title">欢迎使用 SparkleDNS</string>
<string name="onb_welcome_text">为整部手机提供私密 DNS,不使用大型科技公司的服务器。</string>
<string name="onb_point_encrypt">通过 DNS-over-HTTPS 加密每一次 DNS 查询</string>
<string name="onb_point_block">在所有应用中拦截广告和跟踪器</string>
<string name="onb_point_independent">只使用独立服务器,不用 Google 或 Cloudflare</string>
<string name="onb_key_title">获取访问密钥</string>
<string name="onb_key_text">SkySparkle 服务器使用个人密钥。免费套餐有限制,付费套餐没有。</string>
<string name="onb_key_step1">在 skysparkle.cc 创建免费账户</string>
<string name="onb_key_step2">打开“密钥”,为这部手机创建密钥</string>
<string name="onb_key_step3">复制密钥或地址,粘贴到下方</string>
<string name="onb_next">下一步</string>
<string name="onb_done">开始</string>
<string name="onb_skip">跳过,我选择其他服务器</string>
</resources>
+74 -15
View File
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">SparkleDNS</string>
<string name="status_on">Protected</string>
<string name="status_off">Disconnected</string>
<string name="via">via %1$s</string>
<string name="connect">Connect</string>
<string name="disconnect">Disconnect</string>
<string name="servers">DNS-over-HTTPS server</string>
@@ -27,14 +24,10 @@
<string name="notif_title">Protected via %1$s</string>
<string name="notif_text">DNS over HTTPS is active</string>
<string name="tab_home">Home</string>
<string name="tab_monitor">Monitor</string>
<string name="tab_apps">Apps</string>
<string name="tab_blocklist">Blocklist</string>
<string name="tab_about">About</string>
<string name="mon_queries">Queries</string>
<string name="mon_cached">From cache</string>
<string name="mon_blocked">Blocked</string>
<string name="mon_latency">Avg latency</string>
<string name="mon_ms">%1$d ms</string>
<string name="mon_all">All</string>
<string name="mon_errors">Errors</string>
@@ -61,12 +54,9 @@
<string name="bl_invalid">Invalid domain</string>
<string name="bl_empty_custom">No domains yet</string>
<string name="delete">Delete</string>
<string name="bl_lists">Lists</string>
<string name="bl_update_all">Update all</string>
<string name="bl_updating">Updating…</string>
<string name="bl_list_url">List URL</string>
<string name="bl_list_info">%1$s domains · %2$s</string>
<string name="bl_presets">Popular lists</string>
<string name="bl_download_failed">Download failed: %1$s</string>
<string name="about_desc">Encrypt DNS requests without routing all your traffic through a VPN.</string>
<string name="about_version">Version</string>
@@ -91,13 +81,82 @@
<string name="licenses_data">Blocklist data (downloaded on demand, not bundled)</string>
<string name="license_view">View license</string>
<string name="back">Back</string>
<string name="bl_total_label">domains blocked</string>
<string name="about_source">Source code</string>
<string name="open_settings">Settings</string>
<string name="mon_no_match">Nothing matches the filter</string>
<string name="bl_title">Blocking</string>
<string name="servers_update">Update server list</string>
<string name="servers_updated">Server list updated</string>
<string name="servers_update_failed">Couldn\'t update the server list: %1$s</string>
<string name="no_browser">No app found to open this link</string>
<string name="toggle_on">ON</string>
<string name="toggle_off">OFF</string>
<string name="home_protected">You\'re protected</string>
<string name="home_unprotected">You\'re not protected</string>
<string name="home_via">Encrypted via %1$s</string>
<string name="home_off_desc">DNS goes through your network as usual</string>
<string name="stat_requests">Requests</string>
<string name="stat_avg">Avg. time</string>
<string name="chart_now">Now</string>
<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="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 and other sites.</string>
<string name="companies_other">Other</string>
<string name="recent_title">Recent activity</string>
<string name="filter">Filter</string>
<string name="bl_search">Search lists</string>
<string name="auto_update">Auto-update</string>
<string name="auto_off">Off</string>
<string name="auto_daily">Daily</string>
<string name="auto_weekly">Weekly</string>
<string name="auto_wifi">Wi-Fi only</string>
<string name="auto_wifi_desc">Skip updates on mobile data</string>
<string name="auto_update_now">Update now</string>
<string name="done">Done</string>
<string name="cancel">Cancel</string>
<string name="preset_pro_desc">Balanced protection from ads, tracking and malware. The best choice for everyday use.</string>
<string name="preset_proplus_desc">Maximum protection. Can break some app logins and links.</string>
<string name="preset_tif_desc">Threat intelligence feeds: malware, phishing, scam and cryptojacking domains.</string>
<string name="list_added_by_you">Added by you from a URL.</string>
<string name="list_not_downloaded">Not downloaded yet</string>
<string name="my_domains_desc">Domains you blocked yourself. Subdomains are blocked too.</string>
<string name="bl_add_list">Add new blocklist</string>
<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>
<string name="alert_channel">Protection alerts</string>
<string name="alert_stopped_title">DNS protection stopped</string>
<string name="alert_stopped_text">The tunnel stopped working, so DNS is no longer encrypted. Open SparkleDNS to connect again.</string>
<string name="alert_bad_url_title">DNS protection not started</string>
<string name="alert_bad_url_text">The server address is not a valid HTTPS URL. Open SparkleDNS and check the server.</string>
<string name="alert_lockdown_title">DNS server unreachable</string>
<string name="alert_lockdown_text">\"Block connections without VPN\" is on, so SparkleDNS cannot reach the DNS server and lookups fail. Turn it off in Android VPN settings.</string>
<string name="key_label">Access key</string>
<string name="key_hint">Paste the key or the whole address from your account at skysparkle.cc</string>
<string name="key_invalid">This doesn\'t look like a key. Copy it again from the Keys page.</string>
<string name="key_get">Get a free key</string>
<string name="key_needed">The SkySparkle server needs a personal access key. It is free: create an account at skysparkle.cc and add the key.</string>
<string name="key_add">Add key</string>
<string name="alert_no_key_text">The SkySparkle server needs an access key. Open SparkleDNS and add your key in Settings.</string>
<string name="onb_welcome_title">Welcome to SparkleDNS</string>
<string name="onb_welcome_text">Private DNS for your whole phone, without big-tech servers.</string>
<string name="onb_point_encrypt">Encrypts every DNS lookup with DNS-over-HTTPS</string>
<string name="onb_point_block">Blocks ads and trackers in all apps</string>
<string name="onb_point_independent">Uses only independent servers, never Google or Cloudflare</string>
<string name="onb_key_title">Get your access key</string>
<string name="onb_key_text">The SkySparkle server works with a personal key. The free plan has limits; paid plans have none.</string>
<string name="onb_key_step1">Create a free account at skysparkle.cc</string>
<string name="onb_key_step2">Open Keys and create a key for this phone</string>
<string name="onb_key_step3">Copy the key or the address and paste it below</string>
<string name="onb_next">Next</string>
<string name="onb_done">Start</string>
<string name="onb_skip">Skip, I\'ll choose another server</string>
</resources>
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.SparkleDNS" parent="android:Theme.Material.NoActionBar">
<item name="android:windowBackground">#FF0F1115</item>
<item name="android:windowBackground">#FF08090B</item>
</style>
</resources>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
<cloud-backup>
<exclude domain="root" />
<exclude domain="database" />
<exclude domain="sharedpref" />
<exclude domain="file" />
</cloud-backup>
<device-transfer>
<exclude domain="root" />
<exclude domain="database" />
<exclude domain="sharedpref" />
<exclude domain="file" />
</device-transfer>
</data-extraction-rules>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
<locale android:name="en" />
<locale android:name="de" />
<locale android:name="ja" />
<locale android:name="lt" />
<locale android:name="ru" />
<locale android:name="zh" />
</locale-config>
@@ -5,14 +5,17 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import java.nio.LongBuffer
class BlocklistMatchTest {
private fun set(vararg domains: String) = domains.map { DomainHash.of(it) }.sorted().toLongArray()
private fun buf(vararg domains: String) = LongBuffer.wrap(set(*domains))
private fun buf(values: LongArray) = LongBuffer.wrap(values)
@Test
fun blocksDomainsAndTheirSubdomains() {
val lists = set("ads.example.com")
val lists = buf("ads.example.com")
val custom = set("tracker.net")
assertTrue(isBlockedIn("ads.example.com", lists, custom))
@@ -21,7 +24,16 @@ class BlocklistMatchTest {
assertFalse(isBlockedIn("example.com", lists, custom))
assertFalse(isBlockedIn("badads.example.com", lists, custom))
assertFalse(isBlockedIn("tracker.network", lists, custom))
assertFalse(isBlockedIn("ads.example.com", LongArray(0), LongArray(0)))
assertFalse(isBlockedIn("ads.example.com", EMPTY_SET, LongArray(0)))
}
@Test
fun skipsTrailingDots() {
val lists = buf("example.com")
assertTrue(isBlockedIn("www.example.com..", lists, LongArray(0)))
assertFalse(isBlockedIn("example.org.", lists, LongArray(0)))
assertFalse(isBlockedIn("...", lists, LongArray(0)))
}
@Test
@@ -42,8 +54,28 @@ class BlocklistMatchTest {
@Test
fun countsEntriesInBothSetsOnce() {
assertEquals(5, unionSize(longArrayOf(1, 2, 3, 4), longArrayOf(2, 5)))
assertEquals(2, unionSize(LongArray(0), longArrayOf(2, 5)))
assertEquals(4, unionSize(longArrayOf(1, 2, 3, 4), LongArray(0)))
assertEquals(5, unionSize(buf(longArrayOf(1, 2, 3, 4)), longArrayOf(2, 5)))
assertEquals(2, unionSize(EMPTY_SET, longArrayOf(2, 5)))
assertEquals(4, unionSize(buf(longArrayOf(1, 2, 3, 4)), LongArray(0)))
}
@Test
fun streamsMergedValuesInOrderOnce() {
val out = ArrayList<Long>()
val count = mergeSortedInto(
listOf(buf(longArrayOf(-5, 1, 4, 9)), buf(longArrayOf(1, 2, 9, 12)), EMPTY_SET, buf(longArrayOf(12, 40)))
) { out.add(it) }
assertEquals(listOf(-5L, 1, 2, 4, 9, 12, 40), out)
assertEquals(7, count)
assertEquals(0, mergeSortedInto(emptyList()) { out.add(it) })
}
@Test
fun findsValuesInSortedBuffer() {
val values = buf(longArrayOf(Long.MIN_VALUE, -3, 0, 7, Long.MAX_VALUE))
listOf(Long.MIN_VALUE, -3L, 0L, 7L, Long.MAX_VALUE).forEach { assertTrue(values.containsSorted(it)) }
listOf(-4L, 1L, 8L).forEach { assertFalse(values.containsSorted(it)) }
assertFalse(EMPTY_SET.containsSorted(0))
}
}
@@ -1,5 +1,6 @@
package cc.skysparkle.sparkledns
import okio.Buffer
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
@@ -49,5 +50,24 @@ class BlocklistParserTest {
val name = "a.b.example.com"
assertEquals(DomainHash.of("example.com"), DomainHash.of(name, name.indexOf("example")))
assertEquals(DomainHash.of(name), DomainHash.of(name, 0))
assertEquals(DomainHash.of("b.example"), DomainHash.of(name, 2, name.indexOf(".com")))
}
@Test
fun rulesWithAPathAreSkippedNotTurnedIntoTheWholeDomain() {
assertNull(BlocklistParser.parseLine("||example.com/ads/"))
assertNull(BlocklistParser.parseLine("|http://example.com/x|"))
assertNull(BlocklistParser.parseLine("https://example.com/banner.js"))
assertEquals("example.com", BlocklistParser.parseLine("||example.com/^"))
assertEquals("example.com", BlocklistParser.parseLine("https://example.com/"))
}
@Test
fun overlongLinesAreSkippedAndTheRestIsRead() {
val long = "x".repeat(BlocklistParser.MAX_LINE_BYTES.toInt() * 3)
val source = Buffer().writeUtf8("a.example\r\n$long\nb.example\nc.example")
val lines = mutableListOf<String>()
BlocklistParser.readLimitedLines(source) { lines += it.trim() }
assertEquals(listOf("a.example", "b.example", "c.example"), lines)
}
}
@@ -0,0 +1,43 @@
package cc.skysparkle.sparkledns
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
class CompaniesTest {
@Test
fun matchesDomainsAndTheirSubdomains() {
assertEquals(Company.GOOGLE, Companies.of("youtube.com"))
assertEquals(Company.GOOGLE, Companies.of("r3---sn-abc.googlevideo.com"))
assertEquals(Company.META, Companies.of("scontent.cdninstagram.com"))
assertEquals(Company.X, Companies.of("t.co"))
assertEquals(Company.MICROSOFT, Companies.of("api.github.com"))
}
@Test
fun ignoresCaseAndTrailingDots() {
assertEquals(Company.APPLE, Companies.of("WWW.Apple.COM"))
assertEquals(Company.AMAZON, Companies.of("s3.amazonaws.com."))
assertEquals(Company.AMAZON, Companies.of("s3.amazonaws.com.."))
}
@Test
fun knowsGoogleCountrySites() {
assertEquals(Company.GOOGLE, Companies.of("google.de"))
assertEquals(Company.GOOGLE, Companies.of("www.google.co.uk"))
assertEquals(Company.GOOGLE, Companies.of("google.com.br"))
assertNull(Companies.of("google.example.org"))
assertNull(Companies.of("google."))
}
@Test
fun leavesOtherDomainsAlone() {
assertNull(Companies.of("example.com"))
assertNull(Companies.of("notyoutube.com"))
assertNull(Companies.of("youtube.com.example"))
assertNull(Companies.of("com"))
assertNull(Companies.of(""))
assertNull(Companies.of("."))
}
}
@@ -0,0 +1,126 @@
package cc.skysparkle.sparkledns
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.DataInputStream
import java.io.DataOutputStream
class HourlyCountersTest {
private val hours = HourlyCounters.HOURS
@Test
fun countsQueriesPerHour() {
val counters = HourlyCounters()
counters.record(QueryStatus.OK, 40, Company.GOOGLE, hour = 100)
counters.record(QueryStatus.OK, 20, null, hour = 100)
counters.record(QueryStatus.BLOCKED, 0, Company.META, hour = 100)
counters.record(QueryStatus.CACHED, 0, null, hour = 99)
counters.record(QueryStatus.FAILED, 5000, null, hour = 99)
val day = counters.summary(24, currentHour = 100)
assertEquals(5L, day.total)
assertEquals(1L, day.blocked)
assertEquals(1L, day.cached)
assertEquals(30, day.avgLatencyMs)
assertEquals(1L, day.companies[Company.GOOGLE.ordinal])
assertEquals(1L, day.companies[Company.META.ordinal])
assertEquals(3L, counters.summary(1, currentHour = 100).total)
val points = counters.hourly(3, currentHour = 100)
assertEquals(listOf(0L, 2L, 3L), points.map { it.total })
assertEquals(listOf(0L, 0L, 1L), points.map { it.blocked })
}
@Test
fun aSlotStartsOverAWeekLater() {
val counters = HourlyCounters()
counters.record(QueryStatus.OK, 10, null, hour = 5)
counters.record(QueryStatus.OK, 10, null, hour = 5L + hours)
assertEquals(1L, counters.summary(hours, currentHour = 5L + hours).total)
assertEquals(0L, counters.summary(1, currentHour = 5).total)
}
@Test
fun savedNumbersReadBackUnchanged() {
val counters = HourlyCounters()
counters.record(QueryStatus.BLOCKED, 0, Company.XIAOMI, hour = 1000)
counters.record(QueryStatus.OK, 12, Company.APPLE, hour = 1001)
val copy = requireNotNull(HourlyCounters.decode(counters.encode()))
assertArrayEquals(counters.hourIds, copy.hourIds)
for (index in 0 until hours) assertArrayEquals(counters.rows[index], copy.rows[index])
}
@Test
fun writesFormatOne() {
val bytes = HourlyCounters().encode()
val input = DataInputStream(ByteArrayInputStream(bytes))
assertEquals(1, input.readInt())
assertEquals(HourlyCounters.FIELDS, input.readInt())
assertEquals(hours, input.readInt())
assertEquals(-1L, input.readLong())
assertEquals(12 + hours * (HourlyCounters.FIELDS + 1) * 8, bytes.size)
}
@Test
fun readsFilesFromVersionsWithFewerCompanies() {
// A file from a version that knew two companies: field n of hour 7 holds n + 1
val fields = HourlyCounters.FIRST_COMPANY + 2
val bytes = ByteArrayOutputStream()
DataOutputStream(bytes).use { out ->
out.writeInt(1)
out.writeInt(fields)
out.writeInt(hours)
for (index in 0 until hours) {
out.writeLong(if (index == 7) 7L else -1L)
for (field in 0 until fields) out.writeLong(if (index == 7) field + 1L else 0L)
}
}
val summary = requireNotNull(HourlyCounters.decode(bytes.toByteArray())).summary(1, currentHour = 7)
assertEquals(1L, summary.total)
assertEquals(2L, summary.blocked)
assertEquals(3L, summary.cached)
assertEquals(0, summary.avgLatencyMs) // latency sum 4, count 5
assertArrayEquals(longArrayOf(6, 7) + LongArray(Company.entries.size - 2), summary.companies)
}
@Test
fun refusesOtherFormats() {
val bytes = HourlyCounters().encode()
bytes[3] = 2
assertNull(HourlyCounters.decode(bytes))
}
@Test
fun mergeKeepsWhatWasCountedBeforeTheFileWasRead() {
val saved = HourlyCounters()
saved.record(QueryStatus.OK, 10, null, hour = 50)
saved.record(QueryStatus.OK, 10, null, hour = 49)
val live = HourlyCounters()
live.record(QueryStatus.BLOCKED, 0, null, hour = 50)
live.merge(saved)
assertEquals(2L, live.summary(1, currentHour = 50).total)
assertEquals(1L, live.summary(1, currentHour = 50).blocked)
assertEquals(3L, live.summary(2, currentHour = 50).total)
// A slot already holding a newer hour keeps it
val later = HourlyCounters()
later.record(QueryStatus.OK, 10, null, hour = 50L + hours)
later.merge(saved)
assertEquals(1L, later.summary(1, currentHour = 50L + hours).total)
}
}
@@ -18,8 +18,8 @@ class PacketTest {
val parsed = requireNotNull(Packet.parseDnsQuery(packet, packet.size))
assertArrayEquals(query, parsed.payload)
assertArrayEquals(client, parsed.srcIp)
assertArrayEquals(server, parsed.dstIp)
assertEquals(i32(client, 0), parsed.srcIp)
assertEquals(i32(server, 0), parsed.dstIp)
assertEquals(40000, parsed.srcPort)
assertEquals(53, parsed.dstPort)
}
@@ -0,0 +1,43 @@
package cc.skysparkle.sparkledns
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotSame
import org.junit.Assert.assertSame
import org.junit.Test
// The screens refresh once a second; a refresh that brings the same object has nothing to update
class RefreshTest {
@Test
fun logSnapshotIsReusedUntilTheLogChanges() {
QueryLog.clear()
val empty = QueryLog.snapshot()
assertSame(empty, QueryLog.snapshot())
QueryLog.add(DnsMessage.Question("example.com", 1), QueryStatus.OK, 10)
QueryLog.add(DnsMessage.Question("example.org", 28), QueryStatus.CACHED, 0)
val filled = QueryLog.snapshot()
assertNotSame(empty, filled)
assertEquals(listOf("example.org", "example.com"), filled.map { it.domain })
assertSame(filled, QueryLog.snapshot())
QueryLog.clear()
assertEquals(0, QueryLog.snapshot().size)
}
@Test
fun summaryIsReusedUntilSomethingChanges() {
val now = 1_000 * 3_600_000L
val first = StatsStore.summary(24, now)
assertSame(first, StatsStore.summary(24, now))
assertNotSame(first, StatsStore.summary(24 * 7, now))
StatsStore.record(QueryStatus.OK, 5, null, now)
val after = StatsStore.summary(24, now)
assertNotSame(first, after)
assertEquals(first.total + 1, after.total)
assertSame(after, StatsStore.summary(24, now))
}
}
@@ -1,71 +0,0 @@
package cc.skysparkle.sparkledns
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Test
class ServerListTest {
@Test
fun readsAllColumns() {
val list = ServerList.parse(
"""
# Name | URL | policy | h3 | donate
Example DNS | https://dns.example.org/dns-query | https://example.org/privacy | h3 | https://example.org/donate
Other | https://doh.other.net/q | https://other.net/policy | https://other.net/give
""".trimIndent()
)
assertEquals(2, list.size)
val first = list[0]
assertEquals("dns.example.org", first.id)
assertEquals("Example DNS", first.name)
assertEquals("https://dns.example.org/dns-query", first.url)
assertEquals("https://example.org/privacy", first.policy)
assertEquals("https://example.org/donate", first.donate)
assertTrue(first.http3)
val second = list[1]
assertFalse(second.http3)
assertEquals("https://other.net/give", second.donate)
}
@Test
fun skipsServersWithoutHttpsOrPolicy() {
val list = ServerList.parse(
"""
Plain | http://dns.example.org/dns-query | https://example.org/privacy
No policy | https://dns.example.org/dns-query | not a url
Too short | https://dns.example.org/dns-query
""".trimIndent()
)
assertTrue(list.isEmpty())
}
@Test
fun shippedServersCannotBeRedirected() {
val quad9 = Providers.builtIn.first { it.id == "quad9" }
val list = ServerList.parse("Fake | https://dns.quad9.net/elsewhere | https://evil.example/policy")
assertSame(quad9, list.single())
}
@Test
fun dropsDuplicatesTrimsNamesAndCapsTheList() {
val long = "N".repeat(60)
val lines = (1..60).joinToString("\n") { "$long | https://dns$it.example/q | https://example.org/p" } +
"\nDuplicate | https://dns1.example/q | https://example.org/p"
val list = ServerList.parse(lines)
assertEquals(50, list.size)
assertEquals(40, list[0].name.length)
assertEquals(list.size, list.map { it.id }.toSet().size)
assertNull(list.firstOrNull { it.name == "Duplicate" })
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

Some files were not shown because too many files have changed in this diff Show More