22 Commits
Author SHA1 Message Date
kalarina 05d4936c90 Add donation card and move repository links to GitHub 2026-11-17 09:41:25 +02:00
kalarina 8a40e86d73 README: point Obtainium link to GitHub 2026-11-14 19:23:24 +02:00
kalarina ef5af5c395 Release 1.0.51 2026-11-12 17:18:17 +02:00
kalarina 0d0daf8a45 Sign presence announcements with their signing time
Wi-Fi presence announcements now carry the time they were signed, and a
known friend's announcement is accepted only if it is at most 15 minutes
old (or ahead). A recorded announcement can no longer be replayed to show
someone as nearby. Each device signs its announcement anew every 5 minutes.

Older versions sign without the time: their announcements are hidden for
known friends, and they in turn hide announcements from this version.
2026-11-12 17:11:40 +02:00
kalarina 6ed42e0bf3 Smaller fixes from the review
- BLE: at most four messages are reassembled at once; presence advertises
  in the balanced mode, a hosted game still in low latency.
- LAN: the socket and its stream are volatile.
- The spectator port and the APK share server listen on the Wi-Fi address
  only; the share server serves four clients at a time.
- Version catalog, per-app language setting (localeConfig) and the Gradle
  distribution checksum.
- NetworkLog writes to the debug log instead of an unread in-memory list;
  Log.d/Log.v are stripped from release builds.
- Remove four unused strings in all languages.
2026-11-12 17:03:06 +02:00
kalarina cac575ed26 Validate what the opponent sends and keep friend images in files
- Images from another device are size-checked before they are decoded,
  shown or stored: more than 4096 px on a side is refused, decoding is
  capped and OutOfMemoryError is caught. A crafted avatar or background
  could otherwise crash the app every time the friend card was drawn.
- Profiles with an out-of-range name, user id, rating or time control are
  refused and the connection is closed; nothing is stored for them. Names
  and ratings from presence are bounded in the friends list too.
- The opponent's clock claim may not exceed what our clock gives them plus
  increment and slack, so a modified client cannot keep its time. The
  increment was also added twice on the receiving side; fixed.
- Joining a player from the nearby list checks that the profile belongs to
  the announced player and flags the opponent as unverified otherwise.
- Friend avatars and backgrounds move from one large settings value to one
  file per image; existing entries are migrated on first read.
- The in-game chat keeps the last 200 messages.
2026-11-12 17:03:05 +02:00
kalarina 77c438ff66 Release 1.0.50
- Rename Board appearance to Appearance and add app color styles:
  Matewave, pastel Lavender, Peach, Mint, Sky and Device (Material You)
- Rating chip on the home screen no longer opens statistics
- Draw and resign button labels no longer cut off
2026-11-11 08:55:51 +02:00
kalarina c2ee9f2c02 Add redesigned screenshots to README 2026-11-10 20:00:28 +02:00
kalarina 9b7e694a81 Redesign store screenshots 2026-11-10 20:00:14 +02:00
kalarina d3ea4d36c3 Update store screenshots and add feature graphic for the new design 2026-11-10 17:16:16 +02:00
kalarina 58f2766c57 Fix missing padding import in SpectatorScreen 2026-11-10 16:37:06 +02:00
kalarina 50cc40ddaf Polish the new design
- Add Unbounded (headings) and Manrope (text) fonts, OFL 1.1, listed in Licenses
- Bring back the misty forest artwork as a darkened backdrop texture
- Add the wave pattern and matewave wordmark on the home screen
- Player cards and a lime running clock on game and spectator screens
- Fix text overflow in home cards; keep lime for the main action only
2026-11-10 16:22:10 +02:00
kalarina b28fd42bfa Bump versionCode to 9 2026-11-10 16:06:00 +02:00
kalarina 570754fabe Release 1.0.49
- Bump version to 1.0.49 (7) and add changelogs for the new design
2026-11-10 16:03:28 +02:00
kalarina 86921dc35c Redesign UI: neon/lime dark theme, new home and profile screens 2026-11-10 16:01:30 +02:00
kalarina 792f1d127f Expand call for volunteer designers 2026-11-10 15:33:23 +02:00
kalarina 6d62019d3b Add call for volunteer designers to README 2026-11-10 15:30:45 +02:00
kalarina f1995cceaa Move Google Play notice to the top of README 2026-11-08 17:26:02 +02:00
kalarina 7e8ca1ec48 Add Google Play closed testing notice to README 2026-11-08 17:22:57 +02:00
kalarina 2751461fa0 Remove the outdated-app check on connect and its messages
- Drop the protocol version gate in the game handshake and its banner
- Admit spectators of any version and drop the update-required dialogs
- Remove the related strings and tests; reword the unverified warning
2026-11-08 11:11:01 +02:00
kalarina f8fce1675f Release 1.0.48
- Keep the vibration switch only in Settings > Sound, with a short subtitle
- Remove the connection log and network counters from the Permissions screen
- Add Material Symbols icons to the Board appearance options
- Bump version to 1.0.48 (6) and add changelogs mentioning the Gitea mirror
2026-11-08 11:05:25 +02:00
kalarina 74ae8458d1 Add GitHub issue and pull request templates 2026-11-05 18:44:15 +02:00
113 changed files with 2225 additions and 881 deletions
+1
View File
@@ -0,0 +1 @@
ko_fi: skysparkle
+27
View File
@@ -0,0 +1,27 @@
---
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:
- Mode: vs AI / puzzles / openings / Bluetooth / LAN
**Screenshots or logs** (optional)
+5
View File
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Support the project on Ko-fi
url: https://ko-fi.com/skysparkle
about: Donations keep the apps and the Skysparkle server running.
+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
@@ -0,0 +1,10 @@
---
name: Puzzle or opening issue
about: Report a wrong puzzle solution or opening line
title: "[Content] "
---
- Puzzle or opening name:
- Position (describe or attach a screenshot):
- What the app expects:
- What you think is correct, and why:
+12
View File
@@ -0,0 +1,12 @@
---
name: Translation fix
about: Report a wrong or awkward translation
title: "[Translation] "
---
<!-- Supported languages: English, Russian, German, Japanese, Lithuanian, Chinese. New languages are not accepted. -->
- 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` and `./gradlew testDebugUnitTest` pass
- [ ] Tested on a device or emulator (Android version: )
- [ ] Multiplayer changes tested on two physical devices
- [ ] 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
+1 -1
View File
@@ -4,7 +4,7 @@ Thanks for wanting to help! This guide explains where to contribute, what fits t
## Where to contribute ## Where to contribute
Issues and pull requests go to the repository on [Gitea](https://git.skysparkle.cc/kalarina/Matewave). Issues and pull requests go to the repository on [GitHub](https://github.com/kalarina-bit/Matewave).
## Ways to help ## Ways to help
+20 -5
View File
@@ -9,15 +9,24 @@
Play against the AI, solve puzzles, learn openings, or play friends nearby over Bluetooth and Wi-Fi/LAN. Play against the AI, solve puzzles, learn openings, or play friends nearby over Bluetooth and Wi-Fi/LAN.
</p> </p>
<p align="center">
<a href="https://ko-fi.com/skysparkle"><img src="https://ko-fi.com/img/githubbutton_sm.svg" alt="Support me on Ko-fi"></a>
</p>
> [!IMPORTANT]
> **Matewave 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 GitHub](https://github.com/kalarina-bit/Matewave/issues), or an email to [cuken107@proton.me](mailto:cuken107@proton.me).
> [!NOTE]
> **Looking for designers!** Matewave 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"> <p align="center">
<a href="https://github.com/kalarina-bit/Matewave/releases/latest"><img src="https://img.shields.io/github/v/release/kalarina-bit/Matewave?style=for-the-badge&label=release&labelColor=1b1b1b&color=2e7d32" alt="Latest release"></a> <a href="https://github.com/kalarina-bit/Matewave/releases/latest"><img src="https://img.shields.io/github/v/release/kalarina-bit/Matewave?style=for-the-badge&label=release&labelColor=1b1b1b&color=2e7d32" alt="Latest release"></a>
</p> </p>
<p align="center"> <p align="center">
<a href="https://f-droid.org/packages/cc.skysparkle.matewave/"><img src="assets/get-it-on%20(1).png" height="56" alt="Get it on F-Droid"></a> <a href="https://f-droid.org/packages/cc.skysparkle.matewave/"><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/Matewave"><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/Matewave"><img src="assets/badge_obtainium.png" height="56" alt="Get it on Obtainium"></a>
<a href="https://github.com/kalarina-bit/Matewave/releases/latest"><img src="assets/get-it-on-github.png" height="56" alt="Get it on GitHub"></a> <a href="https://github.com/kalarina-bit/Matewave/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/Matewave/releases"><img src="assets/get-it-on-gitea.png" height="56" alt="Get it on Gitea"></a>
</p> </p>
<p align="center"> <p align="center">
@@ -44,8 +53,8 @@
## <img src="assets/icon-install.png" width="32" alt=""> Installation ## <img src="assets/icon-install.png" width="32" alt=""> Installation
- **[F-Droid](https://f-droid.org/packages/cc.skysparkle.matewave/)** — install and update through the F-Droid client. - **[F-Droid](https://f-droid.org/packages/cc.skysparkle.matewave/)** — install and update through the F-Droid client.
- **[Obtainium](https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://git.skysparkle.cc/kalarina/Matewave)** — 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/Matewave)** — 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/Matewave/releases/latest) or [Gitea](https://git.skysparkle.cc/kalarina/Matewave/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. - **Manually** — download the latest APK from [GitHub Releases](https://github.com/kalarina-bit/Matewave/releases/latest), 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 ## <img src="assets/icon-verify.png" width="32" alt=""> Verifying a download
@@ -76,7 +85,13 @@ Nearby multiplayer needs two physical devices — the emulator has no real Bluet
## 🤝 Contributing ## 🤝 Contributing
Bug reports, puzzle and opening fixes, translation fixes and pull requests are welcome in the [issue tracker](https://git.skysparkle.cc/kalarina/Matewave/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. Bug reports, puzzle and opening fixes, translation fixes and pull requests are welcome in the [issue tracker](https://github.com/kalarina-bit/Matewave/issues). Please read [CONTRIBUTING.md](CONTRIBUTING.md) first — it explains what fits the project and how to send changes.
## ☕ Support
Matewave is free, open source and has no ads. If it is useful to you, you can support the project on [Ko-fi](https://ko-fi.com/skysparkle) — donations pay for the Skysparkle server and the time spent on the apps.
<a href="https://ko-fi.com/skysparkle"><img src="https://ko-fi.com/img/githubbutton_sm.svg" alt="Support me on Ko-fi"></a>
## 📄 License ## 📄 License
+15 -16
View File
@@ -1,7 +1,6 @@
plugins { plugins {
id("com.android.application") alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
id("org.jetbrains.kotlin.plugin.compose")
} }
android { android {
@@ -13,8 +12,8 @@ android {
applicationId = "cc.skysparkle.matewave" applicationId = "cc.skysparkle.matewave"
minSdk = 26 minSdk = 26
targetSdk = 36 targetSdk = 36
versionCode = 5 versionCode = 11
versionName = "1.0.47" versionName = "1.0.51"
} }
buildTypes { buildTypes {
@@ -86,20 +85,20 @@ androidComponents {
} }
dependencies { dependencies {
implementation(platform("androidx.compose:compose-bom:2026.09.00")) implementation(platform(libs.androidx.compose.bom))
implementation("androidx.compose.material3:material3") implementation(libs.androidx.compose.material3)
implementation("androidx.compose.ui:ui") implementation(libs.androidx.compose.ui)
implementation("androidx.activity:activity-compose:1.13.0") implementation(libs.androidx.activity.compose)
implementation("androidx.core:core-ktx:1.18.0") implementation(libs.androidx.core.ktx)
implementation("androidx.navigation:navigation-compose:2.9.7") implementation(libs.androidx.navigation.compose)
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.11.0") implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.11.0") implementation(libs.kotlinx.coroutines.android)
implementation("com.google.zxing:core:3.5.4") implementation(libs.zxing.core)
testImplementation("junit:junit:4.13.2") testImplementation(libs.junit)
testImplementation("org.json:json:20240303") testImplementation(libs.org.json)
} }
+6
View File
@@ -2,3 +2,9 @@
# reflection. Only keep line numbers so release crash reports stay readable. # reflection. Only keep line numbers so release crash reports stay readable.
-keepattributes SourceFile,LineNumberTable -keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile -renamesourcefileattribute SourceFile
# Debug and verbose logging (NetworkLog included) is stripped from release builds.
-assumenosideeffects class android.util.Log {
public static int d(...);
public static int v(...);
}
+1
View File
@@ -36,6 +36,7 @@
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_title" android:label="@string/app_title"
android:localeConfig="@xml/locales_config"
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
android:theme="@android:style/Theme.Material.NoActionBar" android:theme="@android:style/Theme.Material.NoActionBar"
android:supportsRtl="true"> android:supportsRtl="true">
@@ -1,6 +1,5 @@
package cc.skysparkle.matewave package cc.skysparkle.matewave
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import android.os.Build import android.os.Build
@@ -57,7 +56,7 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
// The app has one dark look: light system bar icons over the background photo. // The app has one dark look: light system bar icons over the dark backdrop.
enableEdgeToEdge( enableEdgeToEdge(
statusBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT), statusBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT),
navigationBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT) navigationBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT)
@@ -74,17 +73,13 @@ class MainActivity : ComponentActivity() {
runCatching { cc.skysparkle.matewave.puzzles.PuzzleRepository.load(appContext) } runCatching { cc.skysparkle.matewave.puzzles.PuzzleRepository.load(appContext) }
} }
cc.skysparkle.matewave.ui.theme.AppThemeState.load(this)
setContent { setContent {
MatewaveTheme { MatewaveTheme {
androidx.compose.foundation.layout.Box( androidx.compose.foundation.layout.Box(
modifier = androidx.compose.ui.Modifier.fillMaxSize() modifier = androidx.compose.ui.Modifier.fillMaxSize()
) { ) {
cc.skysparkle.matewave.ui.components.AppBackgroundImage() cc.skysparkle.matewave.ui.components.AppBackdrop()
androidx.compose.foundation.layout.Box(
modifier = androidx.compose.ui.Modifier
.fillMaxSize()
.background(cc.skysparkle.matewave.ui.theme.PhotoScrim)
)
AppNavHost() AppNavHost()
} }
} }
@@ -338,9 +333,12 @@ private fun AppNavHost() {
viewModel.startVsPlayerNetwork(transport, PieceColor.WHITE, timeControl, isHost = true) viewModel.startVsPlayerNetwork(transport, PieceColor.WHITE, timeControl, isHost = true)
navController.navigate("game") navController.navigate("game")
}, },
onJoin = { type, timeControl, targetId -> onJoin = { type, timeControl, targetId, expectedUserId ->
val transport = if (type == TransportType.BLUETOOTH) bleTransport else lanTransport val transport = if (type == TransportType.BLUETOOTH) bleTransport else lanTransport
viewModel.startVsPlayerNetwork(transport, PieceColor.BLACK, timeControl, isHost = false, targetId = targetId) viewModel.startVsPlayerNetwork(
transport, PieceColor.BLACK, timeControl, isHost = false,
targetId = targetId, expectedUserId = expectedUserId
)
navController.navigate("game") navController.navigate("game")
}, },
onBack = { navController.popBackStack() } onBack = { navController.popBackStack() }
@@ -98,6 +98,12 @@ class GameClock(private val timeControl: TimeControl, private val scope: Corouti
publish() publish()
} }
/** Time left for [side] right now, including the part of the current second already used. */
fun remainingMillis(side: PieceColor): Long {
account()
return if (side == PieceColor.WHITE) whiteLeft else blackLeft
}
fun restore(whiteMillis: Long, blackMillis: Long) { fun restore(whiteMillis: Long, blackMillis: Long) {
if (unlimited) return if (unlimited) return
account() account()
@@ -2,8 +2,12 @@ package cc.skysparkle.matewave.data
import cc.skysparkle.matewave.ai.AiDifficulty import cc.skysparkle.matewave.ai.AiDifficulty
import android.content.Context import android.content.Context
import cc.skysparkle.matewave.network.PeerLimits
import cc.skysparkle.matewave.security.toHex
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
import java.io.File
import java.security.MessageDigest
import kotlin.math.pow import kotlin.math.pow
import kotlin.math.roundToInt import kotlin.math.roundToInt
@@ -111,6 +115,7 @@ object FriendsStore {
private const val PREFS = "chess_friends_prefs" private const val PREFS = "chess_friends_prefs"
private const val KEY_LIST = "friends_json" private const val KEY_LIST = "friends_json"
private const val MAX_FRIENDS = 30 private const val MAX_FRIENDS = 30
private const val IMAGE_DIR = "friend_images"
private var appContext: Context? = null private var appContext: Context? = null
@@ -125,6 +130,36 @@ object FriendsStore {
private fun prefs() = appContext?.getSharedPreferences(PREFS, Context.MODE_PRIVATE) private fun prefs() = appContext?.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
// Avatars and backgrounds live in files, one per image: in the settings XML they made a file
// of up to tens of megabytes that was read at start and rewritten on every change.
private fun imageDir(): File? = appContext?.let { File(it.filesDir, IMAGE_DIR) }
private fun imageFile(userId: String, kind: String): File? {
val dir = imageDir() ?: return null
val digest = MessageDigest.getInstance("SHA-256").digest(userId.toByteArray(Charsets.UTF_8))
return File(dir, "${digest.toHex(16)}_$kind")
}
private fun readImage(userId: String, kind: String): String? =
imageFile(userId, kind)?.takeIf { it.isFile }?.let { runCatching { it.readText() }.getOrNull() }
private fun writeImage(userId: String, kind: String, base64: String?) {
val file = imageFile(userId, kind) ?: return
if (base64 == null) {
file.delete()
return
}
runCatching {
file.parentFile?.mkdirs()
val tmp = File(file.parentFile, file.name + ".tmp")
tmp.writeText(base64)
if (!tmp.renameTo(file)) {
file.delete()
tmp.renameTo(file)
}
}
}
fun list(): List<FriendEntry> = synchronized(lock) { readAll() } fun list(): List<FriendEntry> = synchronized(lock) { readAll() }
private fun readAll(): List<FriendEntry> { private fun readAll(): List<FriendEntry> {
@@ -136,15 +171,21 @@ object FriendsStore {
return emptyList() return emptyList()
} }
val result = ArrayList<FriendEntry>() val result = ArrayList<FriendEntry>()
var hasInlineImages = false
for (i in 0 until arr.length()) { for (i in 0 until arr.length()) {
try { try {
val o = arr.getJSONObject(i) val o = arr.getJSONObject(i)
val userId = o.optString("uid", "").ifBlank { o.getString("name") }
// Older versions kept the images inline; they move to files on the next write.
val inlineAvatar = if (o.has("avatar")) o.getString("avatar") else null
val inlineBackground = if (o.has("background")) o.getString("background") else null
if (inlineAvatar != null || inlineBackground != null) hasInlineImages = true
result.add( result.add(
FriendEntry( FriendEntry(
userId = o.optString("uid", "").ifBlank { o.getString("name") }, userId = userId,
name = o.getString("name"), name = o.getString("name"),
avatarBase64 = if (o.has("avatar")) o.getString("avatar") else null, avatarBase64 = inlineAvatar ?: if (o.optBoolean("a")) readImage(userId, "a") else null,
backgroundBase64 = if (o.has("background")) o.getString("background") else null, backgroundBase64 = inlineBackground ?: if (o.optBoolean("b")) readImage(userId, "b") else null,
elo = o.optInt("elo", 1200), elo = o.optInt("elo", 1200),
lastPlayedMs = o.optLong("t", 0), lastPlayedMs = o.optLong("t", 0),
favorite = o.optBoolean("fav", false), favorite = o.optBoolean("fav", false),
@@ -156,24 +197,35 @@ object FriendsStore {
} }
val sorted = result.sortedByDescending { it.lastPlayedMs } val sorted = result.sortedByDescending { it.lastPlayedMs }
cached = sorted cached = sorted
if (hasInlineImages) writeAll(sorted, previous = emptyList())
return sorted return sorted
} }
private fun writeAll(entries: List<FriendEntry>) { private fun writeAll(entries: List<FriendEntry>, previous: List<FriendEntry> = readAll()) {
val p = prefs() ?: return val p = prefs() ?: return
val before = previous.associateBy { it.userId }
val arr = JSONArray() val arr = JSONArray()
entries.forEach { f -> entries.forEach { f ->
val old = before[f.userId]
// Image files are touched only when the image itself changed.
if (old == null || old.avatarBase64 != f.avatarBase64) writeImage(f.userId, "a", f.avatarBase64)
if (old == null || old.backgroundBase64 != f.backgroundBase64) writeImage(f.userId, "b", f.backgroundBase64)
val o = JSONObject() val o = JSONObject()
o.put("uid", f.userId) o.put("uid", f.userId)
o.put("name", f.name) o.put("name", f.name)
if (f.avatarBase64 != null) o.put("avatar", f.avatarBase64) if (f.avatarBase64 != null) o.put("a", true)
if (f.backgroundBase64 != null) o.put("background", f.backgroundBase64) if (f.backgroundBase64 != null) o.put("b", true)
o.put("elo", f.elo) o.put("elo", f.elo)
o.put("t", f.lastPlayedMs) o.put("t", f.lastPlayedMs)
if (f.favorite) o.put("fav", true) if (f.favorite) o.put("fav", true)
if (f.lastSeenMs > 0) o.put("s", f.lastSeenMs) if (f.lastSeenMs > 0) o.put("s", f.lastSeenMs)
arr.put(o) arr.put(o)
} }
val kept = entries.mapTo(HashSet()) { it.userId }
previous.filter { it.userId !in kept }.forEach { gone ->
writeImage(gone.userId, "a", null)
writeImage(gone.userId, "b", null)
}
p.edit().putString(KEY_LIST, arr.toString()).apply() p.edit().putString(KEY_LIST, arr.toString()).apply()
cached = entries.sortedByDescending { it.lastPlayedMs } cached = entries.sortedByDescending { it.lastPlayedMs }
} }
@@ -182,6 +234,11 @@ object FriendsStore {
synchronized(lock) { readAll() } synchronized(lock) { readAll() }
} }
// Names and ratings also arrive from presence announcements, so they are bounded here too.
private fun cleanName(name: String): String = name.filterNot { it.isISOControl() }.take(PeerLimits.MAX_NAME_CHARS)
private fun cleanElo(elo: Int): Int = elo.coerceIn(PeerLimits.MIN_ELO, PeerLimits.MAX_ELO)
fun updateProfile( fun updateProfile(
userId: String, userId: String,
name: String, name: String,
@@ -192,8 +249,8 @@ object FriendsStore {
synchronized(lock) { synchronized(lock) {
val existing = readAll().firstOrNull { it.userId == userId } ?: return val existing = readAll().firstOrNull { it.userId == userId } ?: return
val updated = existing.copy( val updated = existing.copy(
name = name.ifBlank { existing.name }, name = cleanName(name).ifBlank { existing.name },
elo = if (elo > 0) elo else existing.elo, elo = if (elo > 0) cleanElo(elo) else existing.elo,
avatarBase64 = avatarBase64 ?: existing.avatarBase64, avatarBase64 = avatarBase64 ?: existing.avatarBase64,
backgroundBase64 = backgroundBase64 ?: existing.backgroundBase64 backgroundBase64 = backgroundBase64 ?: existing.backgroundBase64
) )
@@ -217,12 +274,13 @@ object FriendsStore {
backgroundBase64: String? = null backgroundBase64: String? = null
): FriendEntry = synchronized(lock) { ): FriendEntry = synchronized(lock) {
val existing = readAll().firstOrNull { it.userId == userId } val existing = readAll().firstOrNull { it.userId == userId }
val clean = cleanName(name)
val merged = FriendEntry( val merged = FriendEntry(
userId = userId, userId = userId,
name = name.ifBlank { existing?.name ?: name }, name = clean.ifBlank { existing?.name ?: clean },
avatarBase64 = avatarBase64 ?: existing?.avatarBase64, avatarBase64 = avatarBase64 ?: existing?.avatarBase64,
backgroundBase64 = backgroundBase64 ?: existing?.backgroundBase64, backgroundBase64 = backgroundBase64 ?: existing?.backgroundBase64,
elo = if (elo > 0) elo else (existing?.elo ?: 1200), elo = if (elo > 0) cleanElo(elo) else (existing?.elo ?: 1200),
lastPlayedMs = System.currentTimeMillis(), lastPlayedMs = System.currentTimeMillis(),
favorite = existing?.favorite ?: false, favorite = existing?.favorite ?: false,
lastSeenMs = existing?.lastSeenMs ?: 0 lastSeenMs = existing?.lastSeenMs ?: 0
@@ -73,6 +73,9 @@ class BleTransport(
private const val INCOMPLETE_TTL_MS = 30_000L private const val INCOMPLETE_TTL_MS = 30_000L
/** Messages being reassembled at once; each may grow to [MAX_MESSAGE_BYTES]. */
private const val MAX_PARTIAL_MESSAGES = 4
private const val CTRL_TOTAL_MARKER = 0 private const val CTRL_TOTAL_MARKER = 0
private const val CTRL_ACK = 1 private const val CTRL_ACK = 1
private const val CTRL_NACK = 2 private const val CTRL_NACK = 2
@@ -232,6 +235,8 @@ class BleTransport(
role = Role.PERIPHERAL role = Role.PERIPHERAL
hosting = true hosting = true
// Presence may already be advertising in the low-power mode; restart it for hosting.
if (advertisingActive || advertiseCallback != null) startAdvertising()
startPresence() startPresence()
_connectionState.value = ConnectionState.CONNECTING _connectionState.value = ConnectionState.CONNECTING
} }
@@ -300,10 +305,14 @@ class BleTransport(
} }
// One advertisement at a time: a second start would leak the first one. // One advertisement at a time: a second start would leak the first one.
if (advertiseCallback != null) stopAdvertising() if (advertiseCallback != null) stopAdvertising()
// A hosted game should be found at once; plain presence can save the battery.
val settings = AdvertiseSettings.Builder() val settings = AdvertiseSettings.Builder()
.setAdvertiseMode(
.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY) if (hosting) AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY else AdvertiseSettings.ADVERTISE_MODE_BALANCED
.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH) )
.setTxPowerLevel(
if (hosting) AdvertiseSettings.ADVERTISE_TX_POWER_HIGH else AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM
)
.setConnectable(true) .setConnectable(true)
.build() .build()
@@ -790,6 +799,11 @@ class BleTransport(
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
incoming.entries.removeAll { now - it.value.startedAt > INCOMPLETE_TTL_MS } incoming.entries.removeAll { now - it.value.startedAt > INCOMPLETE_TTL_MS }
if (messageId !in incoming && incoming.size >= MAX_PARTIAL_MESSAGES) {
// A peer that starts many messages and never finishes them would fill the memory.
incoming.minByOrNull { it.value.startedAt }?.let { incoming.remove(it.key) }
NetworkLog.log("BLE", "Too many unfinished messages, oldest dropped")
}
val entry = incoming.getOrPut(messageId) { PartialMessage(total, now) } val entry = incoming.getOrPut(messageId) { PartialMessage(total, now) }
if (entry.total != total) { if (entry.total != total) {
incoming[messageId] = PartialMessage(total, now).also { it.parts[index] = payload } incoming[messageId] = PartialMessage(total, now).also { it.parts[index] = payload }
@@ -9,8 +9,8 @@ enum class ConnectionState { DISCONNECTED, CONNECTING, CONNECTED, FAILED }
/** /**
* Wire protocol shared by all transports: one JSON object per message. * Wire protocol shared by all transports: one JSON object per message.
* Game messages travel inside [SignedMsg] once the handshake is done; only * Game messages travel inside [SignedMsg] once the handshake is done; only
* [ProfileMsg] and [PingMsg] are sent in the clear. Bump [PROTOCOL_VERSION] on any * [ProfileMsg] and [PingMsg] are sent in the clear. [PROTOCOL_VERSION] is sent in the
* incompatible change: peers with an older version are rejected during the handshake. * profile for information only; peers are not rejected by version.
*/ */
sealed class GameMessage { sealed class GameMessage {
data class MoveMsg( data class MoveMsg(
@@ -29,6 +29,8 @@ data class LanPeer(
val fingerprint: String = "", val fingerprint: String = "",
val signature: String = "", val signature: String = "",
/** When the announcement was signed, in epoch seconds; 0 if the peer sent none. */
val signedAtSeconds: Long = 0,
/** Raw NSD service name, used to remove the peer when the service is lost. */ /** Raw NSD service name, used to remove the peer when the service is lost. */
val serviceName: String = "", val serviceName: String = "",
/** Tag of the LAN game the peer plays, empty when not in one. */ /** Tag of the LAN game the peer plays, empty when not in one. */
@@ -59,8 +61,22 @@ class LanTransport(
const val RESOLVE_RETRY_MS = 400L const val RESOLVE_RETRY_MS = 400L
fun presencePayload(playerId: String, name: String, elo: Int): String = /**
"presence|$playerId|$name|$elo" * Signed presence announcement. The signing time is part of it, so a recorded
* announcement stops being accepted after [PRESENCE_MAX_AGE_MS]; older versions, which
* signed without it, are no longer accepted at all.
*/
fun presencePayload(playerId: String, name: String, elo: Int, signedAtSeconds: Long): String =
"presence2|$playerId|$name|$elo|$signedAtSeconds"
/** How old (or how far ahead, for a clock set wrong) a signed announcement may be. */
const val PRESENCE_MAX_AGE_MS = 15 * 60_000L
/** The announcement is signed anew this often, well within [PRESENCE_MAX_AGE_MS]. */
const val PRESENCE_RESIGN_MS = 5 * 60_000L
fun isFreshPresence(signedAtSeconds: Long, nowMs: Long): Boolean =
signedAtSeconds > 0 && kotlin.math.abs(nowMs - signedAtSeconds * 1000L) <= PRESENCE_MAX_AGE_MS
} }
override val type = TransportType.LAN override val type = TransportType.LAN
@@ -72,7 +88,8 @@ class LanTransport(
context.getSystemService(Context.NSD_SERVICE) as? NsdManager context.getSystemService(Context.NSD_SERVICE) as? NsdManager
private var serverSocket: ServerSocket? = null private var serverSocket: ServerSocket? = null
private var socket: Socket? = null // Written by the connect and accept paths, read by the writer coroutine.
@Volatile private var socket: Socket? = null
private val socketLock = Any() private val socketLock = Any()
@@ -82,7 +99,7 @@ class LanTransport(
socket = candidate socket = candidate
true true
} }
private var output: OutputStream? = null @Volatile private var output: OutputStream? = null
private val dispatcher = MessageDispatcher() private val dispatcher = MessageDispatcher()
@Volatile private var hosting = false @Volatile private var hosting = false
@@ -91,6 +108,9 @@ class LanTransport(
private var registeredServiceName: String? = null private var registeredServiceName: String? = null
// Re-signs the announcement before it gets too old to be accepted.
private var resignJob: kotlinx.coroutines.Job? = null
private val ownServiceName: String by lazy { private val ownServiceName: String by lazy {
val fingerprint = cc.skysparkle.matewave.security.DeviceKeys.publicKeyFingerprint(context) val fingerprint = cc.skysparkle.matewave.security.DeviceKeys.publicKeyFingerprint(context)
?: cc.skysparkle.matewave.data.DeviceIdentity.deviceId(context).take(12) ?: cc.skysparkle.matewave.data.DeviceIdentity.deviceId(context).take(12)
@@ -211,13 +231,15 @@ class LanTransport(
val profile = cc.skysparkle.matewave.data.ProfileStore.get() val profile = cc.skysparkle.matewave.data.ProfileStore.get()
runCatching { runCatching {
val shownName = profile.name.take(40) val shownName = profile.name.take(40)
val signedAt = System.currentTimeMillis() / 1000L
setAttribute("id", profile.userId) setAttribute("id", profile.userId)
setAttribute("name", shownName) setAttribute("name", shownName)
setAttribute("elo", profile.elo.toString()) setAttribute("elo", profile.elo.toString())
setAttribute("fp", cc.skysparkle.matewave.security.DeviceKeys.publicKeyFingerprint(context) ?: "") setAttribute("fp", cc.skysparkle.matewave.security.DeviceKeys.publicKeyFingerprint(context) ?: "")
setAttribute("ts", signedAt.toString())
cc.skysparkle.matewave.security.DeviceKeys.sign( cc.skysparkle.matewave.security.DeviceKeys.sign(
context, presencePayload(profile.userId, shownName, profile.elo) context, presencePayload(profile.userId, shownName, profile.elo, signedAt)
)?.let { setAttribute("sig", it) } )?.let { setAttribute("sig", it) }
cc.skysparkle.matewave.spectate.SpectatorAdvert.attributes().forEach { (key, value) -> setAttribute(key, value) } cc.skysparkle.matewave.spectate.SpectatorAdvert.attributes().forEach { (key, value) -> setAttribute(key, value) }
} }
@@ -240,9 +262,15 @@ class LanTransport(
nsd.registerService(info, NsdManager.PROTOCOL_DNS_SD, listener) nsd.registerService(info, NsdManager.PROTOCOL_DNS_SD, listener)
} catch (_: Exception) { } catch (_: Exception) {
} }
resignJob = scope.launch {
kotlinx.coroutines.delay(PRESENCE_RESIGN_MS)
republishProfile()
}
} }
private fun unregisterService() { private fun unregisterService() {
resignJob?.cancel()
resignJob = null
val nsd = nsdManager ?: return val nsd = nsdManager ?: return
registrationListener?.let { registrationListener?.let {
try { nsd.unregisterService(it) } catch (_: Exception) {} try { nsd.unregisterService(it) } catch (_: Exception) {}
@@ -362,6 +390,7 @@ class LanTransport(
fingerprint = attr("fp").ifEmpty { fingerprintFromServiceName(info.serviceName ?: "") ?: "" }, fingerprint = attr("fp").ifEmpty { fingerprintFromServiceName(info.serviceName ?: "") ?: "" },
signature = attr("sig"), signature = attr("sig"),
signedAtSeconds = attr("ts").toLongOrNull() ?: 0,
serviceName = info.serviceName ?: "", serviceName = info.serviceName ?: "",
gameTag = game.gameTag, gameTag = game.gameTag,
spectatePort = game.spectatePort spectatePort = game.spectatePort
@@ -1,8 +1,8 @@
package cc.skysparkle.matewave.network package cc.skysparkle.matewave.network
import android.util.Log
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
enum class DisconnectReason(val userText: String, val textRes: Int) { enum class DisconnectReason(val userText: String, val textRes: Int) {
NONE("—", cc.skysparkle.matewave.R.string.reason_unknown), NONE("—", cc.skysparkle.matewave.R.string.reason_unknown),
@@ -18,35 +18,17 @@ enum class DisconnectReason(val userText: String, val textRes: Int) {
PORT_BUSY("Could not open port", cc.skysparkle.matewave.R.string.reason_port_busy) PORT_BUSY("Could not open port", cc.skysparkle.matewave.R.string.reason_port_busy)
} }
data class NetworkEvent(
val at: Long,
val transport: String,
val text: String
)
/** In-memory connection log, copied into the diagnostics report from Settings. */
object NetworkLog { object NetworkLog {
private const val CAPACITY = 60
private val _events = MutableStateFlow<List<NetworkEvent>>(emptyList())
private val _lastReason = MutableStateFlow(DisconnectReason.NONE) private val _lastReason = MutableStateFlow(DisconnectReason.NONE)
val lastReason: StateFlow<DisconnectReason> = _lastReason val lastReason: StateFlow<DisconnectReason> = _lastReason
/** Debug output only: release builds strip Log.d (see proguard-rules.pro). */
fun log(transport: String, text: String) { fun log(transport: String, text: String) {
val event = NetworkEvent(System.currentTimeMillis(), transport, text) Log.d("Matewave/$transport", text)
_events.update { (it + event).takeLast(CAPACITY) }
} }
fun reason(transport: String, reason: DisconnectReason, detail: String? = null) { fun reason(transport: String, reason: DisconnectReason, detail: String? = null) {
_lastReason.value = reason _lastReason.value = reason
log(transport, reason.userText + (detail?.let { ": $it" } ?: "")) log(transport, reason.userText + (detail?.let { ": $it" } ?: ""))
} }
fun asText(): String {
val format = java.text.SimpleDateFormat("HH:mm:ss", java.util.Locale.getDefault())
return _events.value.joinToString("\n") { e ->
"${format.format(java.util.Date(e.at))} [${e.transport}] ${e.text}"
}
}
} }
@@ -37,22 +37,4 @@ object NetworkMetrics {
fun duplicateChunk() { duplicateChunks.incrementAndGet() } fun duplicateChunk() { duplicateChunks.incrementAndGet() }
fun messageCorrupted() { corruptedMessages.incrementAndGet(); touch() } fun messageCorrupted() { corruptedMessages.incrementAndGet(); touch() }
fun messageDropped() { messagesDropped.incrementAndGet(); touch() } fun messageDropped() { messagesDropped.incrementAndGet(); touch() }
private fun retryPercent(): Int {
val sent = chunksSent.get()
if (sent == 0L) return 0
return ((chunkRetries.get() * 100) / sent).toInt()
}
fun asText(res: android.content.res.Resources): String = buildString {
appendLine(res.getString(cc.skysparkle.matewave.R.string.metrics_connect_attempts,
connectAttempts.get(), connectSuccesses.get()))
val last = lastConnectMillis.get()
if (last > 0) appendLine(res.getString(cc.skysparkle.matewave.R.string.metrics_last_connect, last))
appendLine(res.getString(cc.skysparkle.matewave.R.string.metrics_chunks,
chunksSent.get(), chunkRetries.get(), retryPercent()))
appendLine(res.getString(cc.skysparkle.matewave.R.string.metrics_duplicates, duplicateChunks.get()))
appendLine(res.getString(cc.skysparkle.matewave.R.string.metrics_corrupted, corruptedMessages.get()))
appendLine(res.getString(cc.skysparkle.matewave.R.string.metrics_dropped, messagesDropped.get()))
}
} }
@@ -0,0 +1,39 @@
package cc.skysparkle.matewave.network
/** Bounds for what another device may send us; anything outside them is not stored or used. */
object PeerLimits {
const val MAX_NAME_CHARS = 40
const val MAX_USER_ID_CHARS = 64
const val MIN_ELO = 100
const val MAX_ELO = 3000
const val MAX_INITIAL_SECONDS = 3 * 60 * 60
const val MAX_INCREMENT_SECONDS = 180
/** "No time limit" is sent as Int.MAX_VALUE; 0 means the peer sent no time control. */
private fun isTimeControl(initialSeconds: Int, incrementSeconds: Int): Boolean =
(initialSeconds == 0 || initialSeconds == Int.MAX_VALUE || initialSeconds in 1..MAX_INITIAL_SECONDS) &&
incrementSeconds in 0..MAX_INCREMENT_SECONDS
fun isPlausibleName(name: String): Boolean =
name.isNotBlank() && name.length <= MAX_NAME_CHARS && name.none { it.isISOControl() }
fun isPlausibleUserId(userId: String): Boolean =
userId.isNotBlank() && userId.length <= MAX_USER_ID_CHARS && userId.none { it.isISOControl() }
/**
* Checked before the profile is trusted or stored. The fields are signed as they are, so an
* out-of-range profile is refused rather than trimmed.
*/
fun isPlausibleProfile(msg: GameMessage.ProfileMsg): Boolean =
isPlausibleUserId(msg.userId) &&
isPlausibleName(msg.name) &&
msg.elo in MIN_ELO..MAX_ELO &&
isTimeControl(msg.initialSeconds, msg.incrementSeconds)
/**
* The most the opponent's clock may show after their move: what our clock gives them, plus
* the increment and some slack for network delay. A higher claim would mean time not spent.
*/
fun maxOpponentClockAfterMove(localRemainingMs: Long, incrementMs: Long, toleranceMs: Long): Long =
localRemainingMs.coerceAtLeast(0) + incrementMs + toleranceMs
}
@@ -141,13 +141,19 @@ class LocalPresence(
val knownKey = knownPeers.publicKeyOf(id) val knownKey = knownPeers.publicKeyOf(id)
if (knownKey != null) { if (knownKey != null) {
val authentic = peer.signature.isNotEmpty() && DeviceKeys.verify( // A known friend must send a fresh announcement signed with their key: an old one
// recorded and replayed by someone else is not accepted.
val authentic = peer.signature.isNotEmpty() &&
cc.skysparkle.matewave.network.LanTransport.isFreshPresence(peer.signedAtSeconds, lastResultAt) &&
DeviceKeys.verify(
knownKey, knownKey,
cc.skysparkle.matewave.network.LanTransport.presencePayload(peer.playerId, peer.displayName, peer.elo), cc.skysparkle.matewave.network.LanTransport.presencePayload(
peer.playerId, peer.displayName, peer.elo, peer.signedAtSeconds
),
peer.signature peer.signature
) )
if (!authentic) { if (!authentic) {
NetworkLog.log("PRESENCE", "Announcement for $id failed signature check, hidden") NetworkLog.log("PRESENCE", "Announcement for $id is stale or failed signature check, hidden")
return@forEach return@forEach
} }
FriendsStore.updateProfile( FriendsStore.updateProfile(
@@ -6,8 +6,10 @@ import android.net.Uri
/** External links of the app, kept in one place. */ /** External links of the app, kept in one place. */
object AppLinks { object AppLinks {
const val REPOSITORY = "https://git.skysparkle.cc/kalarina/Matewave" const val REPOSITORY = "https://github.com/kalarina-bit/Matewave"
const val REPOSITORY_LABEL = "git.skysparkle.cc/kalarina/Matewave" const val REPOSITORY_LABEL = "github.com/kalarina-bit/Matewave"
const val DONATE = "https://ko-fi.com/skysparkle"
const val DONATE_LABEL = "ko-fi.com/skysparkle"
const val PRIVACY_POLICY = "https://skysparkle.cc/privacy?lang=en" const val PRIVACY_POLICY = "https://skysparkle.cc/privacy?lang=en"
/** Opens a link in the browser; does nothing if no app can open it. */ /** Opens a link in the browser; does nothing if no app can open it. */
@@ -5,10 +5,12 @@ import java.io.File
import java.io.IOException import java.io.IOException
import java.io.OutputStream import java.io.OutputStream
import java.net.Inet4Address import java.net.Inet4Address
import java.net.InetSocketAddress
import java.net.NetworkInterface import java.net.NetworkInterface
import java.net.ServerSocket import java.net.ServerSocket
import java.net.Socket import java.net.Socket
import java.util.Locale import java.util.Locale
import java.util.concurrent.atomic.AtomicInteger
import kotlin.concurrent.thread import kotlin.concurrent.thread
class ApkShareServer(private val apk: File, private val appName: String) { class ApkShareServer(private val apk: File, private val appName: String) {
@@ -17,8 +19,13 @@ class ApkShareServer(private val apk: File, private val appName: String) {
@Volatile @Volatile
private var server: ServerSocket? = null private var server: ServerSocket? = null
private val activeClients = AtomicInteger()
/** Listens on the Wi-Fi address only (all interfaces if none is found), so the APK is not served elsewhere. */
fun start(): Int { fun start(): Int {
val socket = ServerSocket(0) val socket = ServerSocket()
socket.reuseAddress = true
socket.bind(InetSocketAddress(LocalNetwork.wifiInet4(), 0))
server = socket server = socket
thread(name = "apk-share-accept", isDaemon = true) { thread(name = "apk-share-accept", isDaemon = true) {
while (!socket.isClosed) { while (!socket.isClosed) {
@@ -27,7 +34,19 @@ class ApkShareServer(private val apk: File, private val appName: String) {
} catch (e: IOException) { } catch (e: IOException) {
break break
} }
thread(name = "apk-share-client", isDaemon = true) { serve(client) } // A handful of downloads at a time is plenty; more connections are refused.
if (activeClients.incrementAndGet() > MAX_CLIENTS) {
activeClients.decrementAndGet()
runCatching { client.close() }
continue
}
thread(name = "apk-share-client", isDaemon = true) {
try {
serve(client)
} finally {
activeClients.decrementAndGet()
}
}
} }
} }
return socket.localPort return socket.localPort
@@ -78,6 +97,10 @@ class ApkShareServer(private val apk: File, private val appName: String) {
} }
} }
private companion object {
const val MAX_CLIENTS = 4
}
private fun sendText(out: OutputStream, code: Int, reason: String, text: String, withBody: Boolean) { private fun sendText(out: OutputStream, code: Int, reason: String, text: String, withBody: Boolean) {
val body = text.toByteArray(Charsets.UTF_8) val body = text.toByteArray(Charsets.UTF_8)
writeHeader(out, code, reason, "text/plain; charset=utf-8", body.size.toLong()) writeHeader(out, code, reason, "text/plain; charset=utf-8", body.size.toLong())
@@ -117,12 +140,13 @@ class ApkShareServer(private val apk: File, private val appName: String) {
object LocalNetwork { object LocalNetwork {
private val WIFI_PREFIXES = listOf("wlan", "swlan", "ap", "softap", "eth") private val WIFI_PREFIXES = listOf("wlan", "swlan", "ap", "softap", "eth")
fun wifiIpv4(): String? = runCatching { fun wifiInet4(): Inet4Address? = runCatching {
NetworkInterface.getNetworkInterfaces()?.toList().orEmpty() NetworkInterface.getNetworkInterfaces()?.toList().orEmpty()
.filter { nif -> nif.isUp && !nif.isLoopback && WIFI_PREFIXES.any { nif.name.startsWith(it) } } .filter { nif -> nif.isUp && !nif.isLoopback && WIFI_PREFIXES.any { nif.name.startsWith(it) } }
.flatMap { nif -> nif.inetAddresses.toList() } .flatMap { nif -> nif.inetAddresses.toList() }
.filterIsInstance<Inet4Address>() .filterIsInstance<Inet4Address>()
.firstOrNull { it.isSiteLocalAddress } .firstOrNull { it.isSiteLocalAddress }
?.hostAddress
}.getOrNull() }.getOrNull()
fun wifiIpv4(): String? = wifiInet4()?.hostAddress
} }
@@ -27,7 +27,7 @@ class SpectatorClient(
) { ) {
data class Timing(val connectTimeoutMs: Int = 5_000, val silenceTimeoutMs: Int = 15_000) data class Timing(val connectTimeoutMs: Int = 5_000, val silenceTimeoutMs: Int = 15_000)
enum class Failure { UNREACHABLE, FULL, NO_GAME, UPDATE_THIS_APP, UPDATE_HOST_APP } enum class Failure { UNREACHABLE, FULL, NO_GAME }
sealed class Event { sealed class Event {
data class Joined(val welcome: SpectatorMessage.Welcome) : Event() data class Joined(val welcome: SpectatorMessage.Welcome) : Event()
@@ -97,15 +97,10 @@ class SpectatorClient(
val envelope = SpectatorProtocol.decode(read.text) ?: continue val envelope = SpectatorProtocol.decode(read.text) ?: continue
val message = envelope.message val message = envelope.message
if (!joined) { if (!joined) {
// reject keeps its shape across versions, so read it before the version gate.
if (message is SpectatorMessage.Reject) { if (message is SpectatorMessage.Reject) {
emit(Event.JoinFailed(failureOf(message))) emit(Event.JoinFailed(failureOf(message)))
return return
} }
if (envelope.version < minVersion) {
emit(Event.JoinFailed(Failure.UPDATE_HOST_APP))
return
}
if (message is SpectatorMessage.Welcome) { if (message is SpectatorMessage.Welcome) {
joined = true joined = true
emit(Event.Joined(message)) emit(Event.Joined(message))
@@ -133,8 +128,6 @@ class SpectatorClient(
private fun failureOf(reject: SpectatorMessage.Reject): Failure = when (reject.reason) { private fun failureOf(reject: SpectatorMessage.Reject): Failure = when (reject.reason) {
RejectReason.FULL -> Failure.FULL RejectReason.FULL -> Failure.FULL
RejectReason.NO_GAME -> Failure.NO_GAME RejectReason.NO_GAME -> Failure.NO_GAME
RejectReason.UPDATE_REQUIRED ->
if (version < reject.minVersion) Failure.UPDATE_THIS_APP else Failure.UPDATE_HOST_APP
RejectReason.OTHER -> Failure.UNREACHABLE RejectReason.OTHER -> Failure.UNREACHABLE
} }
@@ -141,14 +141,7 @@ class SpectatorHub(
val envelope = (first as? LineResult.Line)?.let { SpectatorProtocol.decode(it.text) } val envelope = (first as? LineResult.Line)?.let { SpectatorProtocol.decode(it.text) }
when (envelope?.message) { when (envelope?.message) {
SpectatorMessage.StatusQuery -> reply(client, status()) SpectatorMessage.StatusQuery -> reply(client, status())
is SpectatorMessage.Hello -> { is SpectatorMessage.Hello -> { spectator = admit(client) }
if (envelope.version < SpectatorProtocol.MIN_COMPATIBLE_VERSION) {
log("Spectator with protocol ${envelope.version} told to update")
reply(client, SpectatorMessage.Reject(RejectReason.UPDATE_REQUIRED, SpectatorProtocol.MIN_COMPATIBLE_VERSION))
} else {
spectator = admit(client)
}
}
else -> Unit else -> Unit
} }
} catch (e: IOException) { } catch (e: IOException) {
@@ -57,7 +57,6 @@ data class SpectatorSnapshot(
enum class RejectReason(val wire: String) { enum class RejectReason(val wire: String) {
FULL("full"), FULL("full"),
UPDATE_REQUIRED("update"),
NO_GAME("no_game"), NO_GAME("no_game"),
OTHER("other"); OTHER("other");
@@ -94,11 +93,7 @@ data class SpectatorEnvelope(val version: Int, val message: SpectatorMessage?)
* the sender's protocol version in "sv". Unknown types are skipped, never fatal. * the sender's protocol version in "sv". Unknown types are skipped, never fatal.
*/ */
object SpectatorProtocol { object SpectatorProtocol {
/** /** Sent with every message for information only; no version is ever refused. */
* Bump on incompatible changes and raise [MIN_COMPATIBLE_VERSION] to the oldest version still
* understood. hello, status and reject keep their shape so any two versions can still tell
* each other that an update is required.
*/
const val VERSION = 1 const val VERSION = 1
const val MIN_COMPATIBLE_VERSION = 1 const val MIN_COMPATIBLE_VERSION = 1
@@ -2,7 +2,6 @@ package cc.skysparkle.matewave.ui.components
import android.content.Context import android.content.Context
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.util.DisplayMetrics
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
@@ -14,12 +13,20 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.ColorMatrix
import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import cc.skysparkle.matewave.R import cc.skysparkle.matewave.R
import cc.skysparkle.matewave.ui.theme.AppBackground
import cc.skysparkle.matewave.ui.theme.AppThemeState
import cc.skysparkle.matewave.ui.theme.ChessGreen
import cc.skysparkle.matewave.ui.theme.Lime
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@@ -32,7 +39,7 @@ private object BackgroundAssetCache {
bitmap?.let { return it } bitmap?.let { return it }
synchronized(this) { synchronized(this) {
bitmap?.let { return it } bitmap?.let { return it }
val metrics: DisplayMetrics = context.resources.displayMetrics val metrics = context.resources.displayMetrics
val target = maxOf(metrics.widthPixels, metrics.heightPixels).coerceAtLeast(1) val target = maxOf(metrics.widthPixels, metrics.heightPixels).coerceAtLeast(1)
val bounds = BitmapFactory.Options().apply { inJustDecodeBounds = true } val bounds = BitmapFactory.Options().apply { inJustDecodeBounds = true }
@@ -55,10 +62,28 @@ private object BackgroundAssetCache {
} }
} }
@Composable /** Slight green cast so the grey mist matches the accent colours. */
fun AppBackgroundImage() { private val ForestTint = ColorFilter.colorMatrix(
val context = LocalContext.current ColorMatrix(
floatArrayOf(
0.80f, 0f, 0f, 0f, 0f,
0f, 0.95f, 0f, 0f, 6f,
0f, 0f, 0.85f, 0f, 2f,
0f, 0f, 0f, 1f, 0f
)
)
)
/** For the other styles the forest turns almost grey, so it never fights their colours. */
private val NeutralForestTint = ColorFilter.colorMatrix(ColorMatrix().apply { setToSaturation(0.12f) })
/**
* The misty forest artwork, deeply darkened so it reads as texture: the mist stays
* visible behind the headings at the top and fades into near-black lower down.
*/
@Composable
fun AppBackdrop() {
val context = LocalContext.current
var bitmap by remember { mutableStateOf(BackgroundAssetCache.cached()) } var bitmap by remember { mutableStateOf(BackgroundAssetCache.cached()) }
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
@@ -67,15 +92,42 @@ fun AppBackgroundImage() {
} }
} }
val image = bitmap Box(modifier = Modifier.fillMaxSize().background(AppBackground)) {
if (image != null) { bitmap?.let { image ->
Image( Image(
bitmap = image, bitmap = image,
contentDescription = null, contentDescription = null,
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop contentScale = ContentScale.Crop,
colorFilter = if (AppThemeState.palette.greenBackdrop) ForestTint else NeutralForestTint
)
}
Box(
modifier = Modifier
.fillMaxSize()
.drawWithCache {
val shade = Brush.verticalGradient(
0.00f to AppBackground.copy(alpha = 0.72f),
0.30f to AppBackground.copy(alpha = 0.80f),
0.60f to AppBackground.copy(alpha = 0.90f),
1.00f to AppBackground.copy(alpha = 0.96f)
)
val glow = Brush.radialGradient(
colors = listOf(ChessGreen.copy(alpha = 0.14f), ChessGreen.copy(alpha = 0f)),
center = Offset(size.width * 0.9f, 0f),
radius = size.maxDimension * 0.5f
)
val lime = Brush.radialGradient(
colors = listOf(Lime.copy(alpha = 0.05f), Lime.copy(alpha = 0f)),
center = Offset(0f, size.height),
radius = size.maxDimension * 0.45f
)
onDrawBehind {
drawRect(shade)
drawRect(glow)
drawRect(lime)
}
}
) )
} else {
Box(modifier = Modifier.fillMaxSize().background(Color(0xFF101413)))
} }
} }
@@ -2,37 +2,45 @@ package cc.skysparkle.matewave.ui.components
import cc.skysparkle.matewave.ui.theme.ink import cc.skysparkle.matewave.ui.theme.ink
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.selected
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import cc.skysparkle.matewave.R import cc.skysparkle.matewave.R
import cc.skysparkle.matewave.ui.theme.UiCornerRadius import cc.skysparkle.matewave.ui.theme.FloatingBarFill
import cc.skysparkle.matewave.ui.theme.Lime
import cc.skysparkle.matewave.ui.theme.OnAccent
import cc.skysparkle.matewave.ui.theme.PanelBorder
enum class BottomTab { HOME, FRIENDS, SETTINGS, ACCOUNT } enum class BottomTab { HOME, FRIENDS, SETTINGS, ACCOUNT }
/** Floating pill; the active tab is a lime circle, the others are plain icons. */
@Composable @Composable
fun AppBottomBar( fun AppBottomBar(
current: BottomTab, current: BottomTab,
@@ -43,22 +51,27 @@ fun AppBottomBar(
accountAvatarBase64: String? = null accountAvatarBase64: String? = null
) { ) {
val shape = RoundedCornerShape(50)
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 24.dp, vertical = 4.dp) .padding(horizontal = 24.dp, vertical = 8.dp)
.background(cc.skysparkle.matewave.ui.theme.FloatingBarFill, RoundedCornerShape(UiCornerRadius)) .clip(shape)
.padding(vertical = 6.dp), .background(FloatingBarFill)
horizontalArrangement = Arrangement.SpaceEvenly .border(1.dp, PanelBorder, shape)
.padding(horizontal = 8.dp, vertical = 8.dp)
.height(52.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically
) { ) {
NavItem(stringResource(R.string.nav_home), current == BottomTab.HOME, onHomeClick) { tint -> NavItem(stringResource(R.string.nav_home), current == BottomTab.HOME, onHomeClick) { tint ->
NavIcon(R.drawable.ic_home, tint) AppIcon(R.drawable.ic_home, size = 24.dp, tint = tint)
} }
NavItem(stringResource(R.string.nav_friends), current == BottomTab.FRIENDS, onFriendsClick) { tint -> NavItem(stringResource(R.string.nav_friends), current == BottomTab.FRIENDS, onFriendsClick) { tint ->
NavIcon(R.drawable.ic_friends, tint) AppIcon(R.drawable.ic_friends, size = 24.dp, tint = tint)
} }
NavItem(stringResource(R.string.nav_settings), current == BottomTab.SETTINGS, onSettingsClick) { tint -> NavItem(stringResource(R.string.nav_settings), current == BottomTab.SETTINGS, onSettingsClick) { tint ->
NavIcon(R.drawable.ic_settings, tint) AppIcon(R.drawable.ic_settings, size = 24.dp, tint = tint)
} }
NavItem(stringResource(R.string.account_title), current == BottomTab.ACCOUNT, onAccountClick) { tint -> NavItem(stringResource(R.string.account_title), current == BottomTab.ACCOUNT, onAccountClick) { tint ->
val bitmap = rememberChatImage(accountAvatarBase64, AVATAR_MAX_DIMENSION_PX) val bitmap = rememberChatImage(accountAvatarBase64, AVATAR_MAX_DIMENSION_PX)
@@ -67,10 +80,10 @@ fun AppBottomBar(
bitmap = bitmap, bitmap = bitmap,
contentDescription = null, contentDescription = null,
contentScale = ContentScale.Crop, contentScale = ContentScale.Crop,
modifier = Modifier.size(24.dp).clip(CircleShape) modifier = Modifier.size(28.dp).clip(CircleShape)
) )
} else { } else {
NavIcon(R.drawable.ic_default_avatar, tint) AppIcon(R.drawable.ic_default_avatar, size = 24.dp, tint = tint)
} }
} }
} }
@@ -84,33 +97,30 @@ private fun RowScope.NavItem(
onClick: () -> Unit, onClick: () -> Unit,
icon: @Composable (tint: Color) -> Unit icon: @Composable (tint: Color) -> Unit
) { ) {
val shape = RoundedCornerShape(UiCornerRadius) val fill by animateColorAsState(if (active) Lime else Lime.copy(alpha = 0f), label = "navFill")
val itemColor = if (active) ink else ink.copy(alpha = 0.7f) Box(
Column(
modifier = Modifier modifier = Modifier
.weight(1f) .weight(1f)
.clip(shape) .semantics {
.background(if (active) ink.copy(alpha = 0.14f) else ink.copy(alpha = 0f), shape) contentDescription = label
.clickable(onClick = onClick) selected = active
.padding(vertical = 8.dp), }
horizontalAlignment = Alignment.CenterHorizontally .clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
role = Role.Tab,
onClick = onClick
),
contentAlignment = Alignment.Center
) { ) {
icon(itemColor) Box(
Spacer(Modifier.height(4.dp)) modifier = Modifier
Text( .size(52.dp)
label, .clip(CircleShape)
color = if (active) itemColor else Color.Transparent, .background(fill),
style = MaterialTheme.typography.labelMedium contentAlignment = Alignment.Center
) ) {
icon(if (active) OnAccent else ink.copy(alpha = 0.6f))
}
} }
} }
@Composable
private fun NavIcon(iconRes: Int, tint: Color) {
Image(
painter = painterResource(iconRes),
contentDescription = null,
colorFilter = ColorFilter.tint(tint),
modifier = Modifier.size(24.dp)
)
}
@@ -22,6 +22,7 @@ import androidx.compose.ui.window.DialogWindowProvider
import cc.skysparkle.matewave.ui.theme.DialogScrimColor import cc.skysparkle.matewave.ui.theme.DialogScrimColor
import cc.skysparkle.matewave.ui.theme.ink import cc.skysparkle.matewave.ui.theme.ink
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@@ -49,8 +50,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.Dialog
val DialogSurface = Color(0xFF262B29) val DialogSurface: Color get() = cc.skysparkle.matewave.ui.theme.Surface1
val DialogAccent = Color(0xFF93DBA3) val DialogAccent: Color get() = cc.skysparkle.matewave.ui.theme.ChessGreen
val DialogShape = RoundedCornerShape(28.dp) val DialogShape = RoundedCornerShape(28.dp)
@Composable @Composable
@@ -115,7 +116,7 @@ fun AppDialog(
} }
.clip(DialogShape) .clip(DialogShape)
.background(DialogSurface) .background(DialogSurface)
.border(1.dp, cc.skysparkle.matewave.ui.theme.PanelBorder, DialogShape)
.clickable( .clickable(
interactionSource = remember { MutableInteractionSource() }, interactionSource = remember { MutableInteractionSource() },
indication = null indication = null
@@ -1,10 +1,9 @@
package cc.skysparkle.matewave.ui.components package cc.skysparkle.matewave.ui.components
import cc.skysparkle.matewave.ui.theme.ink
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.material3.LocalContentColor
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
@@ -17,7 +16,7 @@ import androidx.compose.ui.unit.dp
fun AppIcon( fun AppIcon(
resId: Int, resId: Int,
size: Dp = 20.dp, size: Dp = 20.dp,
tint: Color = ink, tint: Color = LocalContentColor.current,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
contentDescription: String? = null contentDescription: String? = null
) { ) {
@@ -30,6 +29,6 @@ fun AppIcon(
} }
@Composable @Composable
fun ButtonIcon(resId: Int, tint: Color = ink, size: Dp = 18.dp) { fun ButtonIcon(resId: Int, tint: Color = LocalContentColor.current, size: Dp = 18.dp) {
AppIcon(resId, size = size, tint = tint, modifier = Modifier.padding(end = 8.dp)) AppIcon(resId, size = size, tint = tint, modifier = Modifier.padding(end = 8.dp))
} }
@@ -86,21 +86,46 @@ private object DecodedImageCache {
fun put(key: String, bitmap: Bitmap) { cache.put(key, bitmap) } fun put(key: String, bitmap: Bitmap) { cache.put(key, bitmap) }
} }
/** Larger images (from the opponent) are refused; ours never exceed [MAX_DIMENSION_PX]. */
const val MAX_INCOMING_IMAGE_PX = 4096
/** Upper bound for the decoded size when the caller does not ask for a smaller one. */
private const val DEFAULT_DECODE_PX = 1280
/** Width and height of an encoded image, or null if it is not a readable image. */
private fun imageBounds(bytes: ByteArray): Pair<Int, Int>? {
val bounds = BitmapFactory.Options().apply { inJustDecodeBounds = true }
BitmapFactory.decodeByteArray(bytes, 0, bytes.size, bounds)
return if (bounds.outWidth > 0 && bounds.outHeight > 0) bounds.outWidth to bounds.outHeight else null
}
/**
* Checks an image received from another device before it is shown or stored: it must be a
* readable image no larger than [MAX_INCOMING_IMAGE_PX] on either side. A small file can
* declare a huge resolution, and decoding it at full size would run out of memory.
*/
fun isAcceptableIncomingImage(base64: String): Boolean = try {
val size = imageBounds(Base64.decode(base64, Base64.NO_WRAP))
size != null && size.first <= MAX_INCOMING_IMAGE_PX && size.second <= MAX_INCOMING_IMAGE_PX
} catch (e: Exception) {
false
}
fun decodeChatImage(base64: String, maxDimension: Int = 0): Bitmap? { fun decodeChatImage(base64: String, maxDimension: Int = 0): Bitmap? {
return try { return try {
val bytes = Base64.decode(base64, Base64.NO_WRAP) val bytes = Base64.decode(base64, Base64.NO_WRAP)
if (maxDimension <= 0) { // The size is always checked first: the image may come from another device.
BitmapFactory.decodeByteArray(bytes, 0, bytes.size) val (width, height) = imageBounds(bytes) ?: return null
} else { if (width > MAX_INCOMING_IMAGE_PX || height > MAX_INCOMING_IMAGE_PX) return null
val bounds = BitmapFactory.Options().apply { inJustDecodeBounds = true } val target = if (maxDimension > 0) maxDimension else DEFAULT_DECODE_PX
BitmapFactory.decodeByteArray(bytes, 0, bytes.size, bounds)
var sample = 1 var sample = 1
while (maxOf(bounds.outWidth, bounds.outHeight) / (sample * 2) >= maxDimension) sample *= 2 while (maxOf(width, height) / (sample * 2) >= target) sample *= 2
val options = BitmapFactory.Options().apply { inSampleSize = sample } val options = BitmapFactory.Options().apply { inSampleSize = sample }
BitmapFactory.decodeByteArray(bytes, 0, bytes.size, options) BitmapFactory.decodeByteArray(bytes, 0, bytes.size, options)
}
} catch (e: Exception) { } catch (e: Exception) {
null null
} catch (e: OutOfMemoryError) {
null
} }
} }
@@ -42,9 +42,15 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import cc.skysparkle.matewave.R import cc.skysparkle.matewave.R
import cc.skysparkle.matewave.ui.theme.ChessGreen import cc.skysparkle.matewave.ui.theme.ChessGreen
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.LocalContentColor
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.text.style.TextOverflow
import cc.skysparkle.matewave.ui.theme.Lime
import cc.skysparkle.matewave.ui.theme.OnAccent
import cc.skysparkle.matewave.ui.theme.Surface2
import cc.skysparkle.matewave.ui.theme.GlassShape import cc.skysparkle.matewave.ui.theme.GlassShape
import cc.skysparkle.matewave.ui.theme.PanelBorder import cc.skysparkle.matewave.ui.theme.PanelBorder
import cc.skysparkle.matewave.ui.theme.PanelFill
import cc.skysparkle.matewave.ui.theme.TabletMaxContentWidth import cc.skysparkle.matewave.ui.theme.TabletMaxContentWidth
import cc.skysparkle.matewave.ui.theme.glass import cc.skysparkle.matewave.ui.theme.glass
@@ -61,7 +67,7 @@ fun GlassScaffold(
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) { Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) {
Column(modifier = Modifier.fillMaxSize().widthIn(max = TabletMaxContentWidth)) { Column(modifier = Modifier.fillMaxSize().widthIn(max = TabletMaxContentWidth)) {
Row( Row(
modifier = Modifier.fillMaxWidth().statusBarsPadding().padding(horizontal = 4.dp, vertical = 4.dp), modifier = Modifier.fillMaxWidth().statusBarsPadding().padding(start = 4.dp, end = 4.dp, top = 8.dp, bottom = 8.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
if (onBack != null) { if (onBack != null) {
@@ -69,11 +75,12 @@ fun GlassScaffold(
AppIcon( AppIcon(
R.drawable.ic_arrow_back, R.drawable.ic_arrow_back,
size = 24.dp, size = 24.dp,
tint = ChessGreen,
contentDescription = stringResource(R.string.back) contentDescription = stringResource(R.string.back)
) )
} }
} else { } else {
Spacer(Modifier.width(48.dp)) Spacer(Modifier.width(16.dp))
} }
if (titleContent != null) { if (titleContent != null) {
Row(modifier = Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically, content = titleContent) Row(modifier = Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically, content = titleContent)
@@ -81,7 +88,9 @@ fun GlassScaffold(
Text( Text(
title, title,
color = ink, color = ink,
style = MaterialTheme.typography.titleLarge, style = MaterialTheme.typography.headlineSmall,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f) modifier = Modifier.weight(1f)
) )
} }
@@ -122,6 +131,9 @@ private fun Modifier.pressScale(interactionSource: MutableInteractionSource): Mo
return this.graphicsLayer { scaleX = scale; scaleY = scale } return this.graphicsLayer { scaleX = scale; scaleY = scale }
} }
private val PillShape = RoundedCornerShape(50)
/** The main action: a lime pill with dark text and icons. */
@Composable @Composable
fun GlassButton( fun GlassButton(
onClick: () -> Unit, onClick: () -> Unit,
@@ -130,12 +142,13 @@ fun GlassButton(
content: @Composable RowScope.() -> Unit content: @Composable RowScope.() -> Unit
) { ) {
val interaction = remember { MutableInteractionSource() } val interaction = remember { MutableInteractionSource() }
CompositionLocalProvider(LocalContentColor provides OnAccent) {
Row( Row(
modifier = modifier modifier = modifier
.pressScale(interaction) .pressScale(interaction)
.alpha(if (enabled) 1f else 0.4f) .alpha(if (enabled) 1f else 0.4f)
.clip(GlassShape) .clip(PillShape)
.background(ChessGreen) .background(Lime)
.then( .then(
if (enabled) Modifier.clickable( if (enabled) Modifier.clickable(
interactionSource = interaction, interactionSource = interaction,
@@ -143,11 +156,12 @@ fun GlassButton(
onClick = onClick onClick = onClick
) else Modifier ) else Modifier
) )
.padding(horizontal = 20.dp, vertical = 14.dp), .padding(horizontal = 16.dp, vertical = 15.dp),
horizontalArrangement = Arrangement.Center, horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
content = content content = content
) )
}
} }
@Composable @Composable
@@ -162,9 +176,9 @@ fun GlassOutlinedButton(
modifier = modifier modifier = modifier
.pressScale(interaction) .pressScale(interaction)
.alpha(if (enabled) 1f else 0.4f) .alpha(if (enabled) 1f else 0.4f)
.clip(GlassShape) .clip(PillShape)
.background(PanelFill) .background(Surface2)
.border(1.dp, PanelBorder, GlassShape) .border(1.dp, PanelBorder, PillShape)
.then( .then(
if (enabled) Modifier.clickable( if (enabled) Modifier.clickable(
interactionSource = interaction, interactionSource = interaction,
@@ -172,7 +186,7 @@ fun GlassOutlinedButton(
onClick = onClick onClick = onClick
) else Modifier ) else Modifier
) )
.padding(horizontal = 20.dp, vertical = 14.dp), .padding(horizontal = 16.dp, vertical = 15.dp),
horizontalArrangement = Arrangement.Center, horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
content = content content = content
@@ -185,7 +199,7 @@ fun GlassCard(modifier: Modifier = Modifier, content: @Composable ColumnScope.()
modifier = modifier modifier = modifier
.glass() .glass()
.border(1.dp, PanelBorder, GlassShape) .border(1.dp, PanelBorder, GlassShape)
.padding(14.dp), .padding(16.dp),
content = content content = content
) )
} }
@@ -193,7 +207,7 @@ fun GlassCard(modifier: Modifier = Modifier, content: @Composable ColumnScope.()
@Composable @Composable
fun GlassProgress(text: String) { fun GlassProgress(text: String) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {
CircularProgressIndicator(color = ink, modifier = Modifier.padding(2.dp)) CircularProgressIndicator(color = ChessGreen, modifier = Modifier.padding(2.dp))
Text(text, color = ink, style = MaterialTheme.typography.bodyMedium) Text(text, color = ink, style = MaterialTheme.typography.bodyMedium)
} }
} }
@@ -19,6 +19,8 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import cc.skysparkle.matewave.ui.theme.ChessGreen import cc.skysparkle.matewave.ui.theme.ChessGreen
import cc.skysparkle.matewave.ui.theme.OnAccent
import cc.skysparkle.matewave.ui.theme.Surface1
@Composable @Composable
fun SetupSectionLabel(text: String, modifier: Modifier = Modifier) { fun SetupSectionLabel(text: String, modifier: Modifier = Modifier) {
@@ -36,7 +38,7 @@ fun SetupSegmented(options: List<String>, selectedIndex: Int, onSelect: (Int) ->
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.clip(RoundedCornerShape(50)) .clip(RoundedCornerShape(50))
.background(ink.copy(alpha = 0.08f)) .background(Surface1)
.padding(4.dp), .padding(4.dp),
horizontalArrangement = Arrangement.spacedBy(4.dp) horizontalArrangement = Arrangement.spacedBy(4.dp)
) { ) {
@@ -46,12 +48,16 @@ fun SetupSegmented(options: List<String>, selectedIndex: Int, onSelect: (Int) ->
modifier = Modifier modifier = Modifier
.weight(1f) .weight(1f)
.clip(RoundedCornerShape(50)) .clip(RoundedCornerShape(50))
.background(if (selected) ChessGreen.copy(alpha = 0.35f) else Color.Transparent) .background(if (selected) ChessGreen else Color.Transparent)
.clickable { onSelect(index) } .clickable { onSelect(index) }
.padding(vertical = 10.dp), .padding(vertical = 10.dp),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
Text(label, color = ink, style = MaterialTheme.typography.bodyMedium) Text(
label,
color = if (selected) OnAccent else ink.copy(alpha = 0.8f),
style = MaterialTheme.typography.labelLarge
)
} }
} }
} }
@@ -0,0 +1,40 @@
package cc.skysparkle.matewave.ui.components
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.unit.dp
import kotlin.math.PI
import kotlin.math.sin
/**
* The Matewave signature: thin parallel waves drawn behind the content,
* fading towards the bottom of the surface.
*/
fun Modifier.wavePattern(color: Color, lines: Int = 7): Modifier = drawWithCache {
val stroke = Stroke(width = 1.5.dp.toPx(), cap = StrokeCap.Round)
val amplitude = 9.dp.toPx()
val wavelength = size.width * 0.9f
val gap = size.height * 0.55f / lines
val step = 4.dp.toPx()
val paths = List(lines) { i ->
val baseY = gap * (i + 1)
val phase = i * 0.55f
Path().apply {
var x = 0f
moveTo(x, baseY + amplitude * sin(phase))
while (x <= size.width) {
x += step
lineTo(x, baseY + amplitude * sin(2f * PI.toFloat() * x / wavelength + phase))
}
}
}
onDrawBehind {
paths.forEachIndexed { i, path ->
drawPath(path, color = color.copy(alpha = color.alpha * (1f - i.toFloat() / lines)), style = stroke)
}
}
}
@@ -1,6 +1,5 @@
package cc.skysparkle.matewave.ui.screens package cc.skysparkle.matewave.ui.screens
import cc.skysparkle.matewave.ui.components.ListDivider
import cc.skysparkle.matewave.ui.components.ListGroup import cc.skysparkle.matewave.ui.components.ListGroup
import cc.skysparkle.matewave.ui.components.ListRow import cc.skysparkle.matewave.ui.components.ListRow
import cc.skysparkle.matewave.ui.components.SectionCaption import cc.skysparkle.matewave.ui.components.SectionCaption
@@ -45,12 +44,10 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource 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.TextAlign
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import cc.skysparkle.matewave.R import cc.skysparkle.matewave.R
import cc.skysparkle.matewave.ui.components.DialogText import cc.skysparkle.matewave.ui.components.DialogText
import cc.skysparkle.matewave.ui.components.DialogAction import cc.skysparkle.matewave.ui.components.DialogAction
@@ -60,12 +57,19 @@ import cc.skysparkle.matewave.ui.components.BottomTab
import cc.skysparkle.matewave.data.ProfileStore import cc.skysparkle.matewave.data.ProfileStore
import cc.skysparkle.matewave.ui.components.AppIcon import cc.skysparkle.matewave.ui.components.AppIcon
import cc.skysparkle.matewave.ui.components.ButtonIcon import cc.skysparkle.matewave.ui.components.ButtonIcon
import cc.skysparkle.matewave.ui.components.GlassOutlinedButton import cc.skysparkle.matewave.ui.components.GlassButton
import cc.skysparkle.matewave.ui.components.GlassScaffold import cc.skysparkle.matewave.ui.components.GlassScaffold
import cc.skysparkle.matewave.ui.components.rememberChatImage import cc.skysparkle.matewave.ui.components.rememberChatImage
import cc.skysparkle.matewave.ui.components.wavePattern
import cc.skysparkle.matewave.ui.components.encodeImageForChat import cc.skysparkle.matewave.ui.components.encodeImageForChat
import cc.skysparkle.matewave.ui.theme.ChessGreen import cc.skysparkle.matewave.ui.theme.ChessGreen
import cc.skysparkle.matewave.ui.theme.PanelBorder import cc.skysparkle.matewave.ui.theme.PanelBorder
import cc.skysparkle.matewave.ui.theme.GlassShape
import cc.skysparkle.matewave.ui.theme.Lime
import cc.skysparkle.matewave.ui.theme.OnAccent
import cc.skysparkle.matewave.ui.theme.Surface1
import cc.skysparkle.matewave.ui.theme.Surface2
import androidx.compose.foundation.layout.Spacer
import cc.skysparkle.matewave.ui.theme.whiteOutlinedTextFieldColors import cc.skysparkle.matewave.ui.theme.whiteOutlinedTextFieldColors
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -137,109 +141,64 @@ fun AccountScreen(
) )
} }
) { ) {
Box( ProfileHero(
modifier = Modifier profile = profile,
.fillMaxWidth() onPickBackground = { backgroundPicker.launch("image/*") },
.height(168.dp) onPickAvatar = { avatarPicker.launch("image/*") },
.clip(RoundedCornerShape(20.dp)) onEditName = { editingName = true }
.clickable { backgroundPicker.launch("image/*") }
) {
val bgBitmap = rememberChatImage(profile.backgroundBase64)
if (bgBitmap != null) {
Image(
bitmap = bgBitmap,
contentDescription = null,
modifier = Modifier.fillMaxWidth().height(168.dp),
contentScale = ContentScale.Crop
)
} else {
Image(
painter = painterResource(R.drawable.bg_profile_default),
contentDescription = null,
modifier = Modifier.fillMaxWidth().height(168.dp),
contentScale = ContentScale.Crop
)
}
Box(
modifier = Modifier.fillMaxWidth().height(168.dp).background(
Brush.verticalGradient(
0.0f to Color.Black.copy(alpha = 0.30f),
0.55f to Color.Black.copy(alpha = 0.45f),
1.0f to Color.Black.copy(alpha = 0.72f)
)
)
) )
Box( Row(verticalAlignment = Alignment.CenterVertically) {
modifier = Modifier AppIcon(R.drawable.ic_rating, size = 20.dp, tint = Lime)
.align(Alignment.TopEnd) Spacer(Modifier.width(8.dp))
.padding(10.dp)
.size(36.dp)
.clip(CircleShape)
.background(Color.Black.copy(alpha = 0.45f))
.clickable { backgroundPicker.launch("image/*") },
contentAlignment = Alignment.Center
) {
AppIcon(R.drawable.ic_add_photo, size = 20.dp)
}
Column(
modifier = Modifier
.align(Alignment.BottomStart)
.fillMaxWidth()
.padding(horizontal = 18.dp, vertical = 16.dp)
) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Box {
AvatarCircle(
base64 = profile.avatarBase64,
size = 76.dp,
modifier = Modifier.clickable { avatarPicker.launch("image/*") }
)
Box(
modifier = Modifier
.align(Alignment.BottomEnd)
.size(28.dp)
.clip(CircleShape)
.background(ChessGreen)
.clickable { avatarPicker.launch("image/*") },
contentAlignment = Alignment.Center
) {
AppIcon(R.drawable.ic_edit, size = 14.dp)
}
}
Column {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Text( Text(
profile.name, stringResource(R.string.friends_rating, profile.elo),
color = ink, color = ink,
fontSize = 23.sp, style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f)
maxLines = 1,
overflow = TextOverflow.Ellipsis
) )
AppIcon(
R.drawable.ic_edit,
size = 18.dp,
tint = ink.copy(alpha = 0.75f),
modifier = Modifier.clickable { editingName = true }
)
}
Text( Text(
stringResource(R.string.account_header_summary, profile.elo, cc.skysparkle.matewave.stats.Stats.gamesPlayed()), stringResource(R.string.stats_dialog_title),
color = ink.copy(alpha = 0.72f), color = ChessGreen,
style = MaterialTheme.typography.bodyMedium style = MaterialTheme.typography.labelLarge,
modifier = Modifier
.clip(RoundedCornerShape(50))
.border(1.dp, ChessGreen.copy(alpha = 0.6f), RoundedCornerShape(50))
.clickable { showStats = true }
.padding(horizontal = 14.dp, vertical = 6.dp)
) )
} }
if (!profile.levelChosen) {
GlassButton(onClick = { showLevelPicker = true }, modifier = Modifier.fillMaxWidth()) {
ButtonIcon(R.drawable.ic_speed)
Text(stringResource(R.string.account_choose_level), style = MaterialTheme.typography.titleMedium)
} }
} }
StatTiles()
// Progress: the reason to open a profile.
SectionCaption(stringResource(R.string.account_progress))
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp)) {
HighlightCard(
iconRes = R.drawable.ic_study,
title = stringResource(R.string.study_title),
value = "${study.learnedCount}/${study.courses.size} · ★${study.masteredCount}",
modifier = Modifier.weight(1f),
onClick = onStudyClick
)
HighlightCard(
iconRes = R.drawable.ic_puzzle,
title = stringResource(R.string.puzzles_title),
value = "${cc.skysparkle.matewave.stats.Stats.solvedPuzzles().size}",
modifier = Modifier.weight(1f),
onClick = null
)
} }
RatingHistoryCard(elo = profile.elo, onClick = { showStats = true })
if (profile.avatarBase64 != null || profile.backgroundBase64 != null) { if (profile.avatarBase64 != null || profile.backgroundBase64 != null) {
Text( Text(
stringResource(R.string.account_reset_avatar), stringResource(R.string.account_reset_avatar),
@@ -253,43 +212,6 @@ fun AccountScreen(
) )
} }
if (!profile.levelChosen) {
GlassOutlinedButton(onClick = { showLevelPicker = true }, modifier = Modifier.fillMaxWidth()) {
ButtonIcon(R.drawable.ic_speed)
Text(stringResource(R.string.account_choose_level), color = ink)
}
}
// Progress: the reason to open a profile. The rating is shown here once, with its trend.
SectionCaption(stringResource(R.string.account_progress))
ListGroup {
val curve = remember(profile.elo) { cc.skysparkle.matewave.stats.Stats.ratingCurve(profile.elo) }
ListRow(
title = stringResource(R.string.account_rating_row),
icon = R.drawable.ic_rating,
iconTint = ChessGreen,
value = "${profile.elo}",
valueColor = ink,
trailing = { MiniRatingGraph(points = curve, modifier = Modifier.width(64.dp).height(24.dp)) },
chevron = true,
onClick = { showStats = true }
)
ListDivider()
ListRow(
title = stringResource(R.string.study_title),
icon = R.drawable.ic_study,
value = "${study.learnedCount}/${study.courses.size} · ★${study.masteredCount}",
chevron = true,
onClick = onStudyClick
)
ListDivider()
ListRow(
title = stringResource(R.string.puzzles_title),
icon = R.drawable.ic_puzzle,
value = stringResource(R.string.puzzle_solved_count, cc.skysparkle.matewave.stats.Stats.solvedPuzzles().size)
)
}
// Security folded into one row; the details live in a dialog. // Security folded into one row; the details live in a dialog.
if (myFingerprint != null) { if (myFingerprint != null) {
SectionCaption(stringResource(R.string.account_section_security)) SectionCaption(stringResource(R.string.account_section_security))
@@ -393,6 +315,176 @@ fun AccountScreen(
} }
} }
/** Big name over a dimmed cover, with a large avatar in a neon ring, as in the mockup. */
@Composable
private fun ProfileHero(
profile: cc.skysparkle.matewave.data.Profile,
onPickBackground: () -> Unit,
onPickAvatar: () -> Unit,
onEditName: () -> Unit
) {
val heroHeight = 236.dp
Box(
modifier = Modifier
.fillMaxWidth()
.height(heroHeight)
.clip(GlassShape)
.background(Surface1)
) {
val bgBitmap = rememberChatImage(profile.backgroundBase64)
if (bgBitmap != null) {
Image(
bitmap = bgBitmap,
contentDescription = null,
modifier = Modifier.fillMaxWidth().height(heroHeight),
contentScale = ContentScale.Crop,
alpha = 0.45f
)
} else {
Image(
painter = painterResource(R.drawable.bg_profile_default),
contentDescription = null,
modifier = Modifier.fillMaxWidth().height(heroHeight),
contentScale = ContentScale.Crop,
alpha = 0.45f
)
}
Box(
modifier = Modifier.fillMaxWidth().height(heroHeight).background(
Brush.verticalGradient(
0.0f to Surface1.copy(alpha = 0.2f),
0.6f to Surface1.copy(alpha = 0.6f),
1.0f to Surface1.copy(alpha = 0.95f)
)
).wavePattern(ChessGreen.copy(alpha = 0.12f))
)
Box(
modifier = Modifier
.align(Alignment.TopStart)
.padding(12.dp)
.size(36.dp)
.clip(CircleShape)
.background(Color.Black.copy(alpha = 0.45f))
.clickable(onClick = onPickBackground),
contentAlignment = Alignment.Center
) {
AppIcon(R.drawable.ic_add_photo, size = 20.dp)
}
Box(
modifier = Modifier
.align(Alignment.TopEnd)
.padding(top = 16.dp, end = 16.dp)
) {
Box(
modifier = Modifier.size(148.dp).clip(CircleShape).background(ChessGreen),
contentAlignment = Alignment.Center
) {
AvatarCircle(
base64 = profile.avatarBase64,
size = 136.dp,
modifier = Modifier.clickable(onClick = onPickAvatar)
)
}
Box(
modifier = Modifier
.align(Alignment.BottomStart)
.padding(start = 8.dp, bottom = 8.dp)
.size(34.dp)
.clip(CircleShape)
.background(Lime)
.clickable(onClick = onPickAvatar),
contentAlignment = Alignment.Center
) {
AppIcon(R.drawable.ic_edit, size = 16.dp, tint = OnAccent)
}
}
Row(
modifier = Modifier
.align(Alignment.BottomStart)
.fillMaxWidth()
.clickable(onClick = onEditName)
.padding(start = 18.dp, end = 18.dp, bottom = 16.dp),
verticalAlignment = Alignment.Bottom
) {
Text(
profile.name,
color = ink,
style = MaterialTheme.typography.headlineLarge,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f, fill = false)
)
Spacer(Modifier.width(8.dp))
AppIcon(
R.drawable.ic_edit,
size = 18.dp,
tint = ink.copy(alpha = 0.7f),
modifier = Modifier.padding(bottom = 8.dp)
)
}
}
}
@Composable
private fun HighlightCard(
iconRes: Int,
title: String,
value: String,
modifier: Modifier = Modifier,
onClick: (() -> Unit)?
) {
Row(
modifier = modifier
.clip(GlassShape)
.background(Surface1)
.border(1.dp, PanelBorder, GlassShape)
.then(if (onClick != null) Modifier.clickable(onClick = onClick) else Modifier)
.padding(14.dp),
verticalAlignment = Alignment.CenterVertically
) {
Box(
modifier = Modifier.size(40.dp).clip(RoundedCornerShape(14.dp)).background(Surface2),
contentAlignment = Alignment.Center
) {
AppIcon(iconRes, size = 22.dp, tint = ChessGreen)
}
Spacer(Modifier.width(10.dp))
Column(modifier = Modifier.weight(1f)) {
Text(title, color = ink.copy(alpha = 0.6f), style = MaterialTheme.typography.labelSmall, maxLines = 2, overflow = TextOverflow.Ellipsis)
Text(value, color = ink, style = MaterialTheme.typography.titleMedium, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
}
@Composable
private fun RatingHistoryCard(elo: Int, onClick: () -> Unit) {
val curve = remember(elo) { cc.skysparkle.matewave.stats.Stats.ratingCurve(elo) }
Column(
modifier = Modifier
.fillMaxWidth()
.clip(GlassShape)
.background(Surface1)
.border(1.dp, PanelBorder, GlassShape)
.clickable(onClick = onClick)
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
stringResource(R.string.account_rating_row),
color = ink,
style = MaterialTheme.typography.titleMedium,
modifier = Modifier.weight(1f)
)
AppIcon(R.drawable.ic_arrow_forward, size = 20.dp, tint = ink.copy(alpha = 0.6f))
}
MiniRatingGraph(points = curve, modifier = Modifier.fillMaxWidth().height(96.dp), showDots = false)
}
}
private const val MAX_NAME_LENGTH = 20 private const val MAX_NAME_LENGTH = 20
@Composable @Composable
@@ -463,12 +555,12 @@ private fun LevelPickerDialog(onChoose: (Int) -> Unit, onDismiss: () -> Unit) {
} }
) { ) {
SKILL_LEVELS.forEach { level -> SKILL_LEVELS.forEach { level ->
val rowShape = RoundedCornerShape(12.dp) val rowShape = RoundedCornerShape(16.dp)
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.clip(rowShape) .clip(rowShape)
.background(ink.copy(alpha = 0.07f)) .background(Surface2)
.clickable { onChoose(level.elo) } .clickable { onChoose(level.elo) }
.padding(horizontal = 16.dp, vertical = 14.dp), .padding(horizontal = 16.dp, vertical = 14.dp),
horizontalArrangement = Arrangement.SpaceBetween horizontalArrangement = Arrangement.SpaceBetween
@@ -487,7 +579,7 @@ fun AvatarCircle(base64: String?, size: Dp, modifier: Modifier = Modifier) {
modifier = modifier modifier = modifier
.size(size) .size(size)
.clip(CircleShape) .clip(CircleShape)
.background(ChessGreen.copy(alpha = 0.6f)) .background(Surface2)
.border(2.dp, PanelBorder, CircleShape), .border(2.dp, PanelBorder, CircleShape),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
@@ -502,7 +594,7 @@ fun AvatarCircle(base64: String?, size: Dp, modifier: Modifier = Modifier) {
Image( Image(
painter = painterResource(R.drawable.ic_default_avatar), painter = painterResource(R.drawable.ic_default_avatar),
contentDescription = null, contentDescription = null,
colorFilter = ColorFilter.tint(ink), colorFilter = ColorFilter.tint(ink.copy(alpha = 0.8f)),
modifier = Modifier.size(size * 0.8f) modifier = Modifier.size(size * 0.8f)
) )
} }
@@ -12,6 +12,13 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.ui.text.style.TextOverflow
import cc.skysparkle.matewave.ui.theme.AppPalette
import cc.skysparkle.matewave.ui.theme.AppStyle
import cc.skysparkle.matewave.ui.theme.AppThemeState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
@@ -25,7 +32,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
@@ -51,6 +57,13 @@ fun AppearanceScreen(onBack: () -> Unit) {
var openingBar by remember { mutableStateOf(appearance.showOpening) } var openingBar by remember { mutableStateOf(appearance.showOpening) }
GlassScaffold(title = stringResource(R.string.appearance_title), onBack = onBack) { GlassScaffold(title = stringResource(R.string.appearance_title), onBack = onBack) {
Text(
stringResource(R.string.app_style_title),
color = ink,
style = MaterialTheme.typography.titleMedium
)
StylePicker()
Text( Text(
stringResource(R.string.appearance_board_theme), stringResource(R.string.appearance_board_theme),
color = ink, color = ink,
@@ -77,7 +90,7 @@ fun AppearanceScreen(onBack: () -> Unit) {
) )
if (candidate == theme) { if (candidate == theme) {
cc.skysparkle.matewave.ui.components.AppIcon( cc.skysparkle.matewave.ui.components.AppIcon(
R.drawable.ic_check_box, size = 20.dp, tint = Color(0xFF7BE495) R.drawable.ic_check_box, size = 20.dp, tint = cc.skysparkle.matewave.ui.theme.ChessGreen
) )
} }
} }
@@ -85,30 +98,35 @@ fun AppearanceScreen(onBack: () -> Unit) {
} }
AppearanceToggle( AppearanceToggle(
icon = R.drawable.ic_coordinates,
title = stringResource(R.string.appearance_coordinates), title = stringResource(R.string.appearance_coordinates),
subtitle = stringResource(R.string.appearance_coordinates_hint), subtitle = stringResource(R.string.appearance_coordinates_hint),
checked = coords checked = coords
) { coords = it; appearance.showCoordinates = it } ) { coords = it; appearance.showCoordinates = it }
AppearanceToggle( AppearanceToggle(
icon = R.drawable.ic_image_pieces,
title = stringResource(R.string.appearance_image_pieces), title = stringResource(R.string.appearance_image_pieces),
subtitle = stringResource(R.string.appearance_image_pieces_hint), subtitle = stringResource(R.string.appearance_image_pieces_hint),
checked = images checked = images
) { images = it; appearance.useImagePieces = it } ) { images = it; appearance.useImagePieces = it }
AppearanceToggle( AppearanceToggle(
icon = R.drawable.ic_last_move,
title = stringResource(R.string.appearance_last_move), title = stringResource(R.string.appearance_last_move),
subtitle = stringResource(R.string.appearance_last_move_hint), subtitle = stringResource(R.string.appearance_last_move_hint),
checked = lastMove checked = lastMove
) { lastMove = it; appearance.showLastMove = it } ) { lastMove = it; appearance.showLastMove = it }
AppearanceToggle( AppearanceToggle(
icon = R.drawable.ic_check_alert,
title = stringResource(R.string.appearance_check), title = stringResource(R.string.appearance_check),
subtitle = stringResource(R.string.appearance_check_hint), subtitle = stringResource(R.string.appearance_check_hint),
checked = checkGlow checked = checkGlow
) { checkGlow = it; appearance.showCheckHighlight = it } ) { checkGlow = it; appearance.showCheckHighlight = it }
AppearanceToggle( AppearanceToggle(
icon = R.drawable.ic_move_list,
title = stringResource(R.string.appearance_opening_in_game), title = stringResource(R.string.appearance_opening_in_game),
subtitle = stringResource(R.string.appearance_opening_in_game_hint), subtitle = stringResource(R.string.appearance_opening_in_game_hint),
checked = openingBar checked = openingBar
@@ -122,6 +140,85 @@ fun AppearanceScreen(onBack: () -> Unit) {
} }
} }
/** App colour styles as swatches, three per row; the device style follows the wallpaper. */
@Composable
private fun StylePicker() {
val context = LocalContext.current
val selected = AppThemeState.style
val styles = remember { AppStyle.available }
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
styles.chunked(3).forEach { row ->
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
row.forEach { style ->
StyleSwatch(
style = style,
palette = remember(style) { AppThemeState.paletteFor(context, style) },
selected = style == selected,
modifier = Modifier.weight(1f),
onClick = { AppThemeState.select(context, style) }
)
}
repeat(3 - row.size) { Spacer(Modifier.weight(1f)) }
}
}
if (selected == AppStyle.DEVICE) {
Text(
stringResource(R.string.app_style_device_hint),
color = ink.copy(alpha = 0.6f),
style = MaterialTheme.typography.bodySmall
)
}
}
}
@Composable
private fun StyleSwatch(
style: AppStyle,
palette: AppPalette,
selected: Boolean,
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
val shape = RoundedCornerShape(18.dp)
Column(
modifier = modifier
.clip(shape)
.background(palette.surface1)
.border(if (selected) 2.dp else 1.dp, if (selected) palette.accent else PanelBorder, shape)
.clickable(onClick = onClick)
.padding(vertical = 12.dp, horizontal = 6.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(contentAlignment = Alignment.BottomEnd) {
Box(
modifier = Modifier.size(44.dp).clip(CircleShape).background(palette.accent),
contentAlignment = Alignment.Center
) {
if (selected) {
cc.skysparkle.matewave.ui.components.AppIcon(
R.drawable.ic_check_box, size = 20.dp, tint = palette.onAccent
)
}
}
Box(
modifier = Modifier
.size(20.dp)
.clip(CircleShape)
.background(palette.action)
.border(2.dp, palette.surface1, CircleShape)
)
}
Spacer(Modifier.height(8.dp))
Text(
stringResource(style.titleRes),
color = ink,
style = MaterialTheme.typography.labelLarge,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}
@Composable @Composable
private fun ThemePreview(theme: BoardTheme, showPieces: Boolean) { private fun ThemePreview(theme: BoardTheme, showPieces: Boolean) {
val shape = RoundedCornerShape(6.dp) val shape = RoundedCornerShape(6.dp)
@@ -160,6 +257,7 @@ private fun ThemePreview(theme: BoardTheme, showPieces: Boolean) {
@Composable @Composable
private fun AppearanceToggle( private fun AppearanceToggle(
icon: Int,
title: String, title: String,
subtitle: String, subtitle: String,
checked: Boolean, checked: Boolean,
@@ -167,6 +265,7 @@ private fun AppearanceToggle(
) { ) {
GlassCard(modifier = Modifier.fillMaxWidth()) { GlassCard(modifier = Modifier.fillMaxWidth()) {
Row(verticalAlignment = Alignment.CenterVertically) { Row(verticalAlignment = Alignment.CenterVertically) {
cc.skysparkle.matewave.ui.components.ButtonIcon(icon, size = 24.dp)
Column(modifier = Modifier.weight(1f)) { Column(modifier = Modifier.weight(1f)) {
Text(title, color = ink, style = MaterialTheme.typography.titleMedium) Text(title, color = ink, style = MaterialTheme.typography.titleMedium)
Text(subtitle, color = ink.copy(alpha = 0.7f), style = MaterialTheme.typography.bodySmall) Text(subtitle, color = ink.copy(alpha = 0.7f), style = MaterialTheme.typography.bodySmall)
@@ -175,8 +274,8 @@ private fun AppearanceToggle(
checked = checked, checked = checked,
onCheckedChange = onCheckedChange, onCheckedChange = onCheckedChange,
colors = SwitchDefaults.colors( colors = SwitchDefaults.colors(
checkedThumbColor = Color.White, checkedThumbColor = cc.skysparkle.matewave.ui.theme.OnAccent,
checkedTrackColor = Color(0xFF4F8A5B) checkedTrackColor = cc.skysparkle.matewave.ui.theme.ChessGreen
) )
) )
} }
@@ -64,6 +64,8 @@ import cc.skysparkle.matewave.ui.components.GlassButton
import cc.skysparkle.matewave.ui.components.GlassScaffold import cc.skysparkle.matewave.ui.components.GlassScaffold
import cc.skysparkle.matewave.ui.components.rememberPermissionRequester import cc.skysparkle.matewave.ui.components.rememberPermissionRequester
import cc.skysparkle.matewave.ui.theme.ChessGreen import cc.skysparkle.matewave.ui.theme.ChessGreen
import cc.skysparkle.matewave.ui.theme.Lime
import cc.skysparkle.matewave.ui.theme.OnAccent
private enum class Hint { BLUETOOTH_PERMISSION, BLUETOOTH_OFF, WIFI_OFF } private enum class Hint { BLUETOOTH_PERMISSION, BLUETOOTH_OFF, WIFI_OFF }
@@ -75,14 +77,16 @@ private data class NearbyEntry(
val elo: Int?, val elo: Int?,
val type: TransportType, val type: TransportType,
val address: String, val address: String,
val avatar: String? val avatar: String?,
/** Player id from the signed Wi-Fi announcement; checked against the profile after connecting. */
val playerId: String? = null
) )
@Composable @Composable
fun ConnectionScreen( fun ConnectionScreen(
presence: LocalPresence, presence: LocalPresence,
onStartHost: (TimeControl) -> Unit, onStartHost: (TimeControl) -> Unit,
onJoin: (TransportType, TimeControl, targetId: String) -> Unit, onJoin: (TransportType, TimeControl, targetId: String, expectedUserId: String?) -> Unit,
onBack: () -> Unit onBack: () -> Unit
) { ) {
val context = LocalContext.current val context = LocalContext.current
@@ -144,7 +148,8 @@ fun ConnectionScreen(
elo = peer.elo, elo = peer.elo,
type = TransportType.LAN, type = TransportType.LAN,
address = peer.address, address = peer.address,
avatar = friends.firstOrNull { it.userId == peer.playerId }?.avatarBase64 avatar = friends.firstOrNull { it.userId == peer.playerId }?.avatarBase64,
playerId = peer.playerId
) )
} }
val lanFingerprints = peers.values.map { it.fingerprint }.filter { it.isNotEmpty() } val lanFingerprints = peers.values.map { it.fingerprint }.filter { it.isNotEmpty() }
@@ -173,7 +178,7 @@ fun ConnectionScreen(
modifier = Modifier.weight(1f) modifier = Modifier.weight(1f)
) { ) {
ButtonIcon(R.drawable.ic_add, size = 20.dp) ButtonIcon(R.drawable.ic_add, size = 20.dp)
Text(stringResource(R.string.nearby_create), color = ink, style = MaterialTheme.typography.titleMedium, maxLines = 1) Text(stringResource(R.string.nearby_create), style = MaterialTheme.typography.titleMedium, maxLines = 1)
} }
GlassOutlinedButton(onClick = { pickTime = true }) { GlassOutlinedButton(onClick = { pickTime = true }) {
Text(timeControl.shortLabel(), color = ink, maxLines = 1) Text(timeControl.shortLabel(), color = ink, maxLines = 1)
@@ -256,12 +261,12 @@ fun ConnectionScreen(
Spacer(Modifier.width(8.dp)) Spacer(Modifier.width(8.dp))
Text( Text(
stringResource(R.string.players_play), stringResource(R.string.players_play),
color = Color.White, color = OnAccent,
style = MaterialTheme.typography.labelLarge, style = MaterialTheme.typography.labelLarge,
modifier = Modifier modifier = Modifier
.clip(RoundedCornerShape(50)) .clip(RoundedCornerShape(50))
.background(ChessGreen) .background(Lime)
.clickable { onJoin(entry.type, timeControl, entry.address) } .clickable { onJoin(entry.type, timeControl, entry.address, entry.playerId) }
.padding(horizontal = 14.dp, vertical = 6.dp) .padding(horizontal = 14.dp, vertical = 6.dp)
) )
} }
@@ -47,6 +47,8 @@ import cc.skysparkle.matewave.ui.components.ButtonIcon
import cc.skysparkle.matewave.ui.components.BottomTab import cc.skysparkle.matewave.ui.components.BottomTab
import cc.skysparkle.matewave.ui.components.GlassScaffold import cc.skysparkle.matewave.ui.components.GlassScaffold
import cc.skysparkle.matewave.ui.theme.ChessGreen import cc.skysparkle.matewave.ui.theme.ChessGreen
import cc.skysparkle.matewave.ui.theme.Lime
import cc.skysparkle.matewave.ui.theme.OnAccent
import cc.skysparkle.matewave.spectate.FriendGameStatus import cc.skysparkle.matewave.spectate.FriendGameStatus
import cc.skysparkle.matewave.spectate.FriendStatusResolver import cc.skysparkle.matewave.spectate.FriendStatusResolver
import cc.skysparkle.matewave.spectate.NearbyPlayerGame import cc.skysparkle.matewave.spectate.NearbyPlayerGame
@@ -130,7 +132,7 @@ fun FriendsScreen(
Text(stringResource(R.string.friends_nobody_hint), color = ink.copy(alpha = 0.65f), style = MaterialTheme.typography.bodyMedium) Text(stringResource(R.string.friends_nobody_hint), color = ink.copy(alpha = 0.65f), style = MaterialTheme.typography.bodyMedium)
GlassButton(onClick = onPlay, modifier = Modifier.fillMaxWidth()) { GlassButton(onClick = onPlay, modifier = Modifier.fillMaxWidth()) {
ButtonIcon(R.drawable.ic_play) ButtonIcon(R.drawable.ic_play)
Text(stringResource(R.string.friends_play_nearby), color = ink) Text(stringResource(R.string.friends_play_nearby), style = MaterialTheme.typography.titleMedium)
} }
return@GlassScaffold return@GlassScaffold
} }
@@ -234,11 +236,11 @@ private fun displayName(name: String, id: String): String {
private fun PlayChip(onClick: () -> Unit) { private fun PlayChip(onClick: () -> Unit) {
Text( Text(
stringResource(R.string.friends_play), stringResource(R.string.friends_play),
color = Color.White, color = OnAccent,
style = MaterialTheme.typography.labelLarge, style = MaterialTheme.typography.labelLarge,
modifier = Modifier modifier = Modifier
.clip(RoundedCornerShape(50)) .clip(RoundedCornerShape(50))
.background(ChessGreen) .background(Lime)
.clickable(onClick = onClick) .clickable(onClick = onClick)
.padding(horizontal = 14.dp, vertical = 6.dp) .padding(horizontal = 14.dp, vertical = 6.dp)
) )
@@ -384,12 +386,12 @@ private fun WatchChip(status: FriendGameStatus, onClick: () -> Unit) {
} }
Text( Text(
label, label,
color = if (enabled) Color.White else ink.copy(alpha = 0.5f), color = if (enabled) OnAccent else ink.copy(alpha = 0.5f),
style = MaterialTheme.typography.labelLarge, style = MaterialTheme.typography.labelLarge,
maxLines = 1, maxLines = 1,
modifier = Modifier modifier = Modifier
.clip(RoundedCornerShape(50)) .clip(RoundedCornerShape(50))
.background(if (enabled) ChessGreen else ink.copy(alpha = 0.12f)) .background(if (enabled) Lime else ink.copy(alpha = 0.12f))
.then(if (enabled) Modifier.clickable(onClick = onClick) else Modifier) .then(if (enabled) Modifier.clickable(onClick = onClick) else Modifier)
.padding(horizontal = 14.dp, vertical = 6.dp) .padding(horizontal = 14.dp, vertical = 6.dp)
) )
@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.padding
import cc.skysparkle.matewave.ui.theme.ink import cc.skysparkle.matewave.ui.theme.ink
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@@ -49,6 +50,7 @@ import cc.skysparkle.matewave.ui.components.GlassOutlinedButton
import cc.skysparkle.matewave.ui.components.GlassScaffold import cc.skysparkle.matewave.ui.components.GlassScaffold
import cc.skysparkle.matewave.ui.components.PromotionDialog import cc.skysparkle.matewave.ui.components.PromotionDialog
import cc.skysparkle.matewave.ui.theme.ChessGreen import cc.skysparkle.matewave.ui.theme.ChessGreen
import cc.skysparkle.matewave.ui.theme.OnAccent
import cc.skysparkle.matewave.viewmodel.GameMode import cc.skysparkle.matewave.viewmodel.GameMode
import cc.skysparkle.matewave.viewmodel.GameUiState import cc.skysparkle.matewave.viewmodel.GameUiState
import cc.skysparkle.matewave.viewmodel.GameViewModel import cc.skysparkle.matewave.viewmodel.GameViewModel
@@ -177,12 +179,14 @@ fun GameScreen(viewModel: GameViewModel, onExit: () -> Unit) {
Text( Text(
if (state.drawOfferSentByMe) stringResource(R.string.draw_offer_waiting) else stringResource(R.string.offer_draw), if (state.drawOfferSentByMe) stringResource(R.string.draw_offer_waiting) else stringResource(R.string.offer_draw),
color = ink, color = ink,
maxLines = 1 style = MaterialTheme.typography.labelLarge,
maxLines = 1,
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
) )
} }
GlassOutlinedButton(onClick = { confirmResign = true }, modifier = Modifier.weight(1f)) { GlassOutlinedButton(onClick = { confirmResign = true }, modifier = Modifier.weight(1f)) {
ButtonIcon(R.drawable.ic_flag) ButtonIcon(R.drawable.ic_flag)
Text(stringResource(R.string.resign), color = ink, maxLines = 1) Text(stringResource(R.string.resign), color = ink, style = MaterialTheme.typography.labelLarge, maxLines = 1)
} }
} }
ChatButton( ChatButton(
@@ -300,7 +304,7 @@ private fun ChatButton(unreadCount: Int, onClick: () -> Unit) {
.background(ChessGreen), .background(ChessGreen),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
Text(unreadCount.toString(), color = Color.White, fontSize = 11.sp) Text(unreadCount.toString(), color = OnAccent, fontSize = 11.sp)
} }
} }
} }
@@ -460,15 +464,26 @@ private fun PlayerRow(
state.opponentProfile?.avatarBase64 state.opponentProfile?.avatarBase64
) )
} }
Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) { // A card per player; the side to move gets a neon outline and ring.
val cardShape = RoundedCornerShape(18.dp)
Row(
modifier = Modifier
.fillMaxWidth()
.clip(cardShape)
.background(cc.skysparkle.matewave.ui.theme.Surface1)
.border(1.dp, if (active) ChessGreen.copy(alpha = 0.7f) else cc.skysparkle.matewave.ui.theme.PanelBorder, cardShape)
.padding(horizontal = 10.dp, vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Box( Box(
modifier = Modifier modifier = Modifier
.size(8.dp) .size(40.dp)
.clip(CircleShape) .clip(CircleShape)
.background(if (active) ChessGreen else ink.copy(alpha = 0.15f)) .background(if (active) ChessGreen else Color.Transparent),
) contentAlignment = Alignment.Center
Spacer(Modifier.width(10.dp)) ) {
AvatarCircle(base64 = avatar, size = 34.dp) AvatarCircle(base64 = avatar, size = 36.dp)
}
Spacer(Modifier.width(10.dp)) Spacer(Modifier.width(10.dp))
Column(modifier = Modifier.weight(1f)) { Column(modifier = Modifier.weight(1f)) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
@@ -513,21 +528,27 @@ internal fun BigClock(millis: Long, active: Boolean) {
active -> ink active -> ink
else -> ink.copy(alpha = 0.45f) else -> ink.copy(alpha = 0.45f)
} }
// The running clock is a lime pill, like the main action; a low clock turns red.
val fill = when {
low -> Color(0xFFFF6B6B)
active -> cc.skysparkle.matewave.ui.theme.Lime
else -> ink.copy(alpha = 0.06f)
}
val textColor = if (active) cc.skysparkle.matewave.ui.theme.OnAccent else color
Box( Box(
modifier = Modifier modifier = Modifier
.clip(RoundedCornerShape(10.dp)) .clip(RoundedCornerShape(50))
.background(if (active) ink.copy(alpha = 0.12f) else Color.Transparent) .background(fill)
.padding(horizontal = 12.dp, vertical = 6.dp), .padding(horizontal = 14.dp, vertical = 6.dp),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
if (totalSeconds >= NO_LIMIT_THRESHOLD_SECONDS) { if (totalSeconds >= NO_LIMIT_THRESHOLD_SECONDS) {
AppIcon(R.drawable.ic_infinity, size = 28.dp, tint = color) AppIcon(R.drawable.ic_infinity, size = 26.dp, tint = textColor)
} else { } else {
Text( Text(
"%d:%02d".format(totalSeconds / 60, totalSeconds % 60), "%d:%02d".format(totalSeconds / 60, totalSeconds % 60),
color = color, color = textColor,
style = MaterialTheme.typography.headlineSmall, style = MaterialTheme.typography.titleLarge.copy(fontFeatureSettings = "tnum")
fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold
) )
} }
} }
@@ -558,7 +579,6 @@ private fun ConnectionBanner(state: GameUiState) {
private fun TrustBanners(state: GameUiState) { private fun TrustBanners(state: GameUiState) {
val (icon, text, color) = when { val (icon, text, color) = when {
state.opponentUntrusted -> Triple(R.drawable.ic_no_encryption, stringResource(R.string.trust_impersonation), Color(0xFFFF6B6B)) state.opponentUntrusted -> Triple(R.drawable.ic_no_encryption, stringResource(R.string.trust_impersonation), Color(0xFFFF6B6B))
state.opponentOutdated -> Triple(R.drawable.ic_error, stringResource(R.string.trust_outdated), Color(0xFFFF6B6B))
state.opponentUnverified -> Triple(R.drawable.ic_no_encryption, stringResource(R.string.trust_unverified), Color(0xFFFFC46B)) state.opponentUnverified -> Triple(R.drawable.ic_no_encryption, stringResource(R.string.trust_unverified), Color(0xFFFFC46B))
else -> Triple(0, null, Color.Unspecified) else -> Triple(0, null, Color.Unspecified)
} }
@@ -45,6 +45,7 @@ private data class LicenseEntry(
) )
private const val APACHE = "Apache License 2.0" private const val APACHE = "Apache License 2.0"
private const val OFL = "SIL Open Font License 1.1"
private const val AOSP = "The Android Open Source Project" private const val AOSP = "The Android Open Source Project"
private val LIBRARIES = listOf( private val LIBRARIES = listOf(
@@ -109,6 +110,14 @@ private val ASSETS = listOf(
LicenseEntry( LicenseEntry(
"Vector Chess Pieces", "RhosGFX", null, "CC0 1.0", "Vector Chess Pieces", "RhosGFX", null, "CC0 1.0",
"https://rhosgfx.itch.io/vector-chess-pieces", R.string.licenses_note_pieces "https://rhosgfx.itch.io/vector-chess-pieces", R.string.licenses_note_pieces
),
LicenseEntry(
"Unbounded", "The Unbounded Project Authors", null, OFL,
"https://github.com/googlefonts/unbounded", R.string.licenses_note_fonts
),
LicenseEntry(
"Manrope", "The Manrope Project Authors", null, OFL,
"https://github.com/googlefonts/manrope", R.string.licenses_note_fonts
) )
) )
@@ -123,6 +132,7 @@ private val RADIO = listOf(
fun LicensesScreen(onBack: () -> Unit) { fun LicensesScreen(onBack: () -> Unit) {
val context = LocalContext.current val context = LocalContext.current
var showApache by remember { mutableStateOf(false) } var showApache by remember { mutableStateOf(false) }
var showOfl by remember { mutableStateOf(false) }
GlassScaffold(title = stringResource(R.string.licenses_title), onBack = onBack) { GlassScaffold(title = stringResource(R.string.licenses_title), onBack = onBack) {
Text( Text(
@@ -143,6 +153,10 @@ fun LicensesScreen(onBack: () -> Unit) {
SetupSectionLabel(stringResource(R.string.licenses_group_assets)) SetupSectionLabel(stringResource(R.string.licenses_group_assets))
ASSETS.forEach { entry -> LicenseCard(entry) { openUrl(context, entry.url) } } ASSETS.forEach { entry -> LicenseCard(entry) { openUrl(context, entry.url) } }
GlassOutlinedButton(onClick = { showOfl = true }, modifier = Modifier.fillMaxWidth()) {
ButtonIcon(R.drawable.ic_copyright)
Text(stringResource(R.string.licenses_ofl_full), color = ink)
}
SetupSectionLabel(stringResource(R.string.licenses_group_radio)) SetupSectionLabel(stringResource(R.string.licenses_group_radio))
Text( Text(
@@ -154,7 +168,10 @@ fun LicensesScreen(onBack: () -> Unit) {
} }
if (showApache) { if (showApache) {
ApacheLicenseDialog(onDismiss = { showApache = false }) LicenseTextDialog(APACHE, R.raw.license_apache_2_0, "https://www.apache.org/licenses/LICENSE-2.0") { showApache = false }
}
if (showOfl) {
LicenseTextDialog(OFL, R.raw.license_ofl_1_1, "https://openfontlicense.org") { showOfl = false }
} }
} }
@@ -185,20 +202,20 @@ private fun LicenseCard(entry: LicenseEntry, onClick: () -> Unit) {
} }
@Composable @Composable
private fun ApacheLicenseDialog(onDismiss: () -> Unit) { private fun LicenseTextDialog(title: String, rawRes: Int, fallbackUrl: String, onDismiss: () -> Unit) {
val context = LocalContext.current val context = LocalContext.current
val text = remember { val text = remember(rawRes) {
runCatching { runCatching {
context.resources.openRawResource(R.raw.license_apache_2_0) context.resources.openRawResource(rawRes)
.bufferedReader().use { it.readText() } .bufferedReader().use { it.readText() }
}.getOrDefault("https://www.apache.org/licenses/LICENSE-2.0") }.getOrDefault(fallbackUrl)
.trim() .trim()
.split(Regex("\n\\s*\n")) .split(Regex("\n\\s*\n"))
.joinToString("\n\n") { paragraph -> paragraph.lines().joinToString(" ") { it.trim() } } .joinToString("\n\n") { paragraph -> paragraph.lines().joinToString(" ") { it.trim() } }
} }
AppDialog( AppDialog(
onDismissRequest = onDismiss, onDismissRequest = onDismiss,
title = APACHE, title = title,
actions = { DialogAction(stringResource(R.string.chat_close), onDismiss) } actions = { DialogAction(stringResource(R.string.chat_close), onDismiss) }
) { ) {
Column(modifier = Modifier.fillMaxWidth().heightIn(max = 380.dp).verticalScroll(rememberScrollState())) { Column(modifier = Modifier.fillMaxWidth().heightIn(max = 380.dp).verticalScroll(rememberScrollState())) {
@@ -1,17 +1,6 @@
package cc.skysparkle.matewave.ui.screens package cc.skysparkle.matewave.ui.screens
import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.Image
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import cc.skysparkle.matewave.ui.components.ListDivider
import cc.skysparkle.matewave.ui.components.ListGroup
import cc.skysparkle.matewave.ui.components.ListRow
import cc.skysparkle.matewave.ui.components.SectionCaption
import cc.skysparkle.matewave.ui.theme.ink
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.border import androidx.compose.foundation.border
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
@@ -20,20 +9,24 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
@@ -41,33 +34,44 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithCache import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.Path import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.StrokeCap import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.Stroke import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
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.compose.ui.unit.sp
import androidx.compose.foundation.Image
import cc.skysparkle.matewave.R import cc.skysparkle.matewave.R
import cc.skysparkle.matewave.ui.components.DialogText
import cc.skysparkle.matewave.ui.components.DialogAction
import cc.skysparkle.matewave.ui.components.AppDialog
import cc.skysparkle.matewave.stats.Stats import cc.skysparkle.matewave.stats.Stats
import cc.skysparkle.matewave.ui.components.AppBottomBar import cc.skysparkle.matewave.ui.components.AppBottomBar
import cc.skysparkle.matewave.ui.components.AppDialog
import cc.skysparkle.matewave.ui.components.AppIcon
import cc.skysparkle.matewave.ui.components.BottomTab import cc.skysparkle.matewave.ui.components.BottomTab
import cc.skysparkle.matewave.ui.components.DialogAction
import cc.skysparkle.matewave.ui.components.DialogText
import cc.skysparkle.matewave.ui.components.SectionCaption
import cc.skysparkle.matewave.ui.components.displayName
import cc.skysparkle.matewave.ui.components.wavePattern
import cc.skysparkle.matewave.ui.theme.ChessGreen import cc.skysparkle.matewave.ui.theme.ChessGreen
import cc.skysparkle.matewave.ui.theme.TabletMaxContentWidth
import cc.skysparkle.matewave.ui.theme.GlassShape import cc.skysparkle.matewave.ui.theme.GlassShape
import cc.skysparkle.matewave.ui.theme.glass import cc.skysparkle.matewave.ui.theme.HeroTextStyle
import cc.skysparkle.matewave.ui.theme.Lime
import cc.skysparkle.matewave.ui.theme.OnAccent
import cc.skysparkle.matewave.ui.theme.PanelBorder
import cc.skysparkle.matewave.ui.theme.Surface1
import cc.skysparkle.matewave.ui.theme.Surface2
import cc.skysparkle.matewave.ui.theme.TabletMaxContentWidth
import cc.skysparkle.matewave.ui.theme.ink
import cc.skysparkle.matewave.viewmodel.GameViewModel import cc.skysparkle.matewave.viewmodel.GameViewModel
import cc.skysparkle.matewave.viewmodel.ResumeInfo import cc.skysparkle.matewave.viewmodel.ResumeInfo
import cc.skysparkle.matewave.ui.components.displayName
@Composable @Composable
fun MainMenuScreen( fun MainMenuScreen(
@@ -86,13 +90,13 @@ fun MainMenuScreen(
val context = LocalContext.current val context = LocalContext.current
val resumable by viewModel.resumable.collectAsState() val resumable by viewModel.resumable.collectAsState()
val ongoing = resumable val ongoing = resumable
val hasOngoingGame = ongoing != null
val profile = remember { cc.skysparkle.matewave.data.ProfileStore.get() } val profile = remember { cc.skysparkle.matewave.data.ProfileStore.get() }
val lastSetup = remember { cc.skysparkle.matewave.settings.LastGameSetup(context) } val lastSetup = remember { cc.skysparkle.matewave.settings.LastGameSetup(context) }
LaunchedEffect(Unit) { studyViewModel.init(context) } LaunchedEffect(Unit) { studyViewModel.init(context) }
val study by studyViewModel.overview.collectAsState() val study by studyViewModel.overview.collectAsState()
var showRatingGate by remember { mutableStateOf(false) } var showRatingGate by remember { mutableStateOf(false) }
var showStats by remember { mutableStateOf(false) }
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) { Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) {
Column(modifier = Modifier.fillMaxSize().widthIn(max = TabletMaxContentWidth)) { Column(modifier = Modifier.fillMaxSize().widthIn(max = TabletMaxContentWidth)) {
@@ -100,26 +104,39 @@ fun MainMenuScreen(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.statusBarsPadding() .statusBarsPadding()
.padding(top = 16.dp, start = 20.dp, end = 20.dp, bottom = 10.dp), .padding(top = 12.dp, start = 20.dp, end = 20.dp, bottom = 4.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) {
Box(
modifier = Modifier.size(44.dp).clip(CircleShape).background(ChessGreen),
contentAlignment = Alignment.Center
) { ) {
Image( Image(
painter = painterResource(R.drawable.logo_knight), painter = painterResource(R.drawable.logo_knight),
contentDescription = null, contentDescription = null,
modifier = Modifier.size(width = 30.dp, height = 44.dp) modifier = Modifier.size(width = 20.dp, height = 29.dp)
) )
Spacer(Modifier.width(12.dp)) }
Greeting(modifier = Modifier.weight(1f)) Spacer(Modifier.width(10.dp))
// The rating is always in sight.
Text( Text(
"${profile.elo}", "matewave",
color = ink, color = ink,
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.headlineSmall.copy(fontSize = 17.sp, letterSpacing = (-0.3).sp),
maxLines = 1
)
Spacer(Modifier.weight(1f))
// The rating is always in sight.
Row(
modifier = Modifier modifier = Modifier
.clip(RoundedCornerShape(50)) .clip(RoundedCornerShape(50))
.background(ink.copy(alpha = 0.10f)) .background(Surface2)
.padding(horizontal = 12.dp, vertical = 6.dp) .padding(start = 10.dp, end = 14.dp, top = 8.dp, bottom = 8.dp),
) verticalAlignment = Alignment.CenterVertically
) {
AppIcon(R.drawable.ic_rating, size = 18.dp, tint = Lime)
Spacer(Modifier.width(6.dp))
Text("${profile.elo}", color = ink, style = MaterialTheme.typography.titleSmall)
}
} }
Column( Column(
@@ -130,70 +147,71 @@ fun MainMenuScreen(
.verticalScroll(rememberScrollState()), .verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(14.dp) verticalArrangement = Arrangement.spacedBy(14.dp)
) { ) {
// The most urgent thing first: an unfinished game. Hero()
if (ongoing != null) ContinueCard(ongoing, onContinueGame)
Row(horizontalArrangement = Arrangement.spacedBy(12.dp), modifier = Modifier.fillMaxWidth()) { Row(
ModeTile( modifier = Modifier.fillMaxWidth().height(268.dp),
iconRes = R.drawable.ic_ai_app, horizontalArrangement = Arrangement.spacedBy(12.dp)
title = stringResource(R.string.mode_ai_title), ) {
AiCard(
subtitle = stringResource(R.string.mode_ai_subtitle), subtitle = stringResource(R.string.mode_ai_subtitle),
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f).fillMaxHeight(),
onClick = { if (profile.levelChosen) onVsAiClick() else showRatingGate = true } onClick = { if (profile.levelChosen) onVsAiClick() else showRatingGate = true }
) )
ModeTile( Column(
modifier = Modifier.weight(1f).fillMaxHeight(),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
SmallModeCard(
iconRes = R.drawable.ic_versus, iconRes = R.drawable.ic_versus,
title = stringResource(R.string.mode_online_title), title = stringResource(R.string.mode_online_title),
subtitle = stringResource(R.string.mode_online_subtitle), subtitle = stringResource(R.string.mode_online_subtitle),
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f).fillMaxWidth(),
onClick = { if (profile.levelChosen) onVsPlayerClick() else showRatingGate = true } onClick = { if (profile.levelChosen) onVsPlayerClick() else showRatingGate = true }
) )
// The most urgent thing takes this slot: an unfinished game, otherwise a quick rematch.
if (ongoing != null) {
ContinueCard(ongoing, Modifier.weight(1f).fillMaxWidth(), onContinueGame)
} else {
SmallModeCard(
iconRes = R.drawable.ic_quick_game,
title = stringResource(R.string.quick_game_title),
subtitle = stringResource(difficultyName(lastSetup.aiDifficulty)) +
" · " + lastSetup.aiTime.displayName(),
modifier = Modifier.weight(1f).fillMaxWidth(),
onClick = { if (profile.levelChosen) onQuickGame() else showRatingGate = true }
)
}
}
} }
SectionCaption(stringResource(R.string.home_today)) SectionCaption(stringResource(R.string.home_today))
ListGroup { Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp)) {
if (!hasOngoingGame) { val due = study.dueCards > 0
ListRow( LearnCard(
title = stringResource(R.string.quick_game_title), iconRes = if (due) R.drawable.ic_review else R.drawable.ic_study,
subtitle = stringResource( title = stringResource(if (due) R.string.study_review_title else R.string.study_title),
R.string.quick_game_subtitle, subtitle = if (due) {
stringResource(difficultyName(lastSetup.aiDifficulty)), stringResource(R.string.study_review_summary, study.dueCards, study.dueCourses)
lastSetup.aiTime.displayName()
),
icon = R.drawable.ic_quick_game,
iconTint = ChessGreen,
chevron = true,
onClick = { if (profile.levelChosen) onQuickGame() else showRatingGate = true }
)
ListDivider()
}
if (study.dueCards > 0) {
ListRow(
title = stringResource(R.string.study_review_title),
subtitle = stringResource(R.string.study_review_summary, study.dueCards, study.dueCourses),
icon = R.drawable.ic_review,
iconTint = cc.skysparkle.matewave.ui.screens.StarGold,
chevron = true,
onClick = onStudyClick
)
} else { } else {
ListRow( stringResource(R.string.study_menu_subtitle)
title = stringResource(R.string.study_title), },
subtitle = stringResource(R.string.study_menu_subtitle), highlighted = due,
icon = R.drawable.ic_study, modifier = Modifier.weight(1f),
chevron = true,
onClick = onStudyClick onClick = onStudyClick
) )
} LearnCard(
ListDivider() iconRes = R.drawable.ic_puzzle,
ListRow(
title = stringResource(R.string.puzzles_title), title = stringResource(R.string.puzzles_title),
subtitle = stringResource(R.string.puzzles_subtitle), subtitle = stringResource(R.string.puzzle_solved_count, Stats.solvedPuzzles().size),
icon = R.drawable.ic_puzzle, highlighted = false,
chevron = true, modifier = Modifier.weight(1f),
onClick = onPuzzlesClick onClick = onPuzzlesClick
) )
} }
ProgressPanel(elo = profile.elo, onClick = { showStats = true })
Spacer(Modifier.height(4.dp))
} }
Box(modifier = Modifier.navigationBarsPadding()) { Box(modifier = Modifier.navigationBarsPadding()) {
@@ -215,10 +233,11 @@ fun MainMenuScreen(
onDismiss = { showRatingGate = false } onDismiss = { showRatingGate = false }
) )
} }
if (showStats) StatsDialog(onDismiss = { showStats = false })
} }
@Composable @Composable
private fun Greeting(modifier: Modifier = Modifier) { private fun Hero() {
val hour = remember { java.util.Calendar.getInstance().get(java.util.Calendar.HOUR_OF_DAY) } val hour = remember { java.util.Calendar.getInstance().get(java.util.Calendar.HOUR_OF_DAY) }
val greeting = when (hour) { val greeting = when (hour) {
in 5..11 -> stringResource(R.string.greeting_morning) in 5..11 -> stringResource(R.string.greeting_morning)
@@ -226,65 +245,236 @@ private fun Greeting(modifier: Modifier = Modifier) {
in 18..22 -> stringResource(R.string.greeting_evening) in 18..22 -> stringResource(R.string.greeting_evening)
else -> stringResource(R.string.greeting_night) else -> stringResource(R.string.greeting_night)
} }
Column(modifier = modifier) { Box(modifier = Modifier.fillMaxWidth().padding(top = 8.dp)) {
Row(verticalAlignment = Alignment.CenterVertically) { Column(modifier = Modifier.padding(end = 76.dp)) {
Text(greeting, color = ink, style = MaterialTheme.typography.headlineSmall) Text("$greeting 👋", color = ink.copy(alpha = 0.6f), style = MaterialTheme.typography.bodyLarge)
Spacer(Modifier.width(6.dp)) Spacer(Modifier.height(2.dp))
Text("👋", fontSize = 20.sp) Text(
stringResource(R.string.home_hero),
color = ink,
style = HeroTextStyle,
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
} }
Text(stringResource(R.string.greeting_ready), color = ink.copy(alpha = 0.7f), style = MaterialTheme.typography.bodyMedium) Image(
painter = painterResource(R.drawable.piece_white_knight),
contentDescription = null,
modifier = Modifier
.align(Alignment.CenterEnd)
.size(88.dp)
.rotate(-14f)
)
}
}
/** The main mode: a tall neon card with a big piece, like the hero tile of the mockup. */
@Composable
private fun AiCard(subtitle: String, modifier: Modifier = Modifier, onClick: () -> Unit) {
Box(
modifier = modifier
.clip(GlassShape)
.background(ChessGreen)
.wavePattern(OnAccent.copy(alpha = 0.16f))
.clickable(onClick = onClick)
) {
Image(
painter = painterResource(R.drawable.piece_black_king),
contentDescription = null,
modifier = Modifier
.align(Alignment.TopEnd)
.padding(top = 10.dp, end = 4.dp)
.size(108.dp)
.rotate(10f)
)
Column(
modifier = Modifier.align(Alignment.BottomStart).fillMaxWidth().padding(16.dp)
) {
Text(
stringResource(R.string.mode_ai_title),
color = OnAccent,
style = MaterialTheme.typography.headlineSmall.copy(fontSize = 19.sp, lineHeight = 24.sp),
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
Spacer(Modifier.height(4.dp))
Text(
subtitle,
color = OnAccent.copy(alpha = 0.7f),
style = MaterialTheme.typography.bodySmall,
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
}
}
}
@Composable
private fun SmallModeCard(
iconRes: Int,
title: String,
subtitle: String,
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
Column(
modifier = modifier
.clip(GlassShape)
.background(Surface1)
.border(1.dp, PanelBorder, GlassShape)
.clickable(onClick = onClick)
.padding(14.dp)
) {
Row(verticalAlignment = Alignment.CenterVertically) {
Box(
modifier = Modifier.size(34.dp).clip(CircleShape).background(ChessGreen.copy(alpha = 0.14f)),
contentAlignment = Alignment.Center
) {
AppIcon(iconRes, size = 18.dp, tint = ChessGreen)
}
Spacer(Modifier.weight(1f))
ArrowBubble(fill = Surface2, tint = ink)
}
Spacer(Modifier.weight(1f))
Text(title, color = ink, style = MaterialTheme.typography.titleMedium, maxLines = 2, overflow = TextOverflow.Ellipsis)
Text(subtitle, color = ink.copy(alpha = 0.55f), style = MaterialTheme.typography.bodySmall, maxLines = 1, overflow = TextOverflow.Ellipsis)
} }
} }
/** An unfinished game against the AI: move number, whose turn and the clock, one tap to resume. */ /** An unfinished game against the AI: move number, whose turn and the clock, one tap to resume. */
@Composable @Composable
private fun ContinueCard(info: ResumeInfo, onClick: () -> Unit) { private fun ContinueCard(info: ResumeInfo, modifier: Modifier = Modifier, onClick: () -> Unit) {
val turn = stringResource(if (info.myTurn) R.string.home_your_move else R.string.home_ai_move) val turn = stringResource(if (info.myTurn) R.string.home_your_move else R.string.home_ai_move)
val clock = info.myMillis?.let { ms -> val clock = info.myMillis?.let { ms ->
val s = ms.coerceAtLeast(0) / 1000 val s = ms.coerceAtLeast(0) / 1000
"%d:%02d".format(s / 60, s % 60) "%d:%02d".format(s / 60, s % 60)
} }
val details = stringResource(R.string.home_continue_details, info.moveNumber, turn) + (clock?.let { " · $it" } ?: "") val details = stringResource(R.string.home_continue_details, info.moveNumber, turn) + (clock?.let { " · $it" } ?: "")
Row( Column(
modifier = Modifier modifier = modifier
.fillMaxWidth() .clip(GlassShape)
.glass() .background(Lime)
.border(1.dp, ChessGreen.copy(alpha = 0.6f), GlassShape)
.clickable(onClick = onClick) .clickable(onClick = onClick)
.padding(16.dp), .padding(14.dp)
verticalAlignment = Alignment.CenterVertically
) { ) {
Column(modifier = Modifier.weight(1f)) { Row(verticalAlignment = Alignment.CenterVertically) {
Text(stringResource(R.string.continue_game_title), color = ink, style = MaterialTheme.typography.titleMedium)
Text(details, color = ink.copy(alpha = 0.7f), style = MaterialTheme.typography.bodySmall)
}
Box( Box(
modifier = Modifier.size(44.dp).clip(CircleShape).background(ChessGreen), modifier = Modifier.size(34.dp).clip(CircleShape).background(OnAccent.copy(alpha = 0.1f)),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
cc.skysparkle.matewave.ui.components.AppIcon(R.drawable.ic_arrow_forward, size = 20.dp, tint = Color.White) AppIcon(R.drawable.ic_play, size = 18.dp, tint = OnAccent)
} }
Spacer(Modifier.weight(1f))
ArrowBubble(fill = OnAccent, tint = Lime)
}
Spacer(Modifier.weight(1f))
Text(
stringResource(R.string.continue_game_title),
color = OnAccent,
style = MaterialTheme.typography.titleMedium,
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
Text(details, color = OnAccent.copy(alpha = 0.7f), style = MaterialTheme.typography.bodySmall, maxLines = 1, overflow = TextOverflow.Ellipsis)
} }
} }
/** One of the two equal ways to start a game. */
@Composable @Composable
private fun ModeTile(iconRes: Int, title: String, subtitle: String, modifier: Modifier = Modifier, onClick: () -> Unit) { private fun ArrowBubble(fill: Color, tint: Color) {
Box(
modifier = Modifier.size(30.dp).clip(CircleShape).background(fill),
contentAlignment = Alignment.Center
) {
AppIcon(R.drawable.ic_arrow_forward, size = 16.dp, tint = tint)
}
}
@Composable
private fun LearnCard(
iconRes: Int,
title: String,
subtitle: String,
highlighted: Boolean,
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
Column( Column(
modifier = modifier modifier = modifier
.glass() .height(148.dp)
.clip(GlassShape)
.background(Surface1)
.border(1.dp, if (highlighted) ChessGreen.copy(alpha = 0.7f) else PanelBorder, GlassShape)
.clickable(onClick = onClick) .clickable(onClick = onClick)
.padding(14.dp), .padding(14.dp)
verticalArrangement = Arrangement.spacedBy(4.dp)
) { ) {
Image( Box(
painter = painterResource(iconRes), modifier = Modifier
contentDescription = null, .size(40.dp)
colorFilter = ColorFilter.tint(ink), .clip(RoundedCornerShape(14.dp))
modifier = Modifier.size(24.dp) .background(if (highlighted) ChessGreen else Surface2),
contentAlignment = Alignment.Center
) {
AppIcon(iconRes, size = 22.dp, tint = if (highlighted) OnAccent else ChessGreen)
}
Spacer(Modifier.weight(1f))
Text(title, color = ink, style = MaterialTheme.typography.titleSmall, maxLines = 2, overflow = TextOverflow.Ellipsis)
Spacer(Modifier.height(2.dp))
Text(subtitle, color = ink.copy(alpha = 0.55f), style = MaterialTheme.typography.bodySmall, maxLines = 2, overflow = TextOverflow.Ellipsis)
}
}
/** Rating with its trend and the three numbers players look at; opens the statistics. */
@Composable
private fun ProgressPanel(elo: Int, onClick: () -> Unit) {
val curve = remember(elo) { Stats.ratingCurve(elo) }
Column(
modifier = Modifier
.fillMaxWidth()
.clip(GlassShape)
.background(Surface1)
.border(1.dp, PanelBorder, GlassShape)
.clickable(onClick = onClick)
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Row(verticalAlignment = Alignment.CenterVertically) {
Column(modifier = Modifier.weight(1f)) {
Text(
stringResource(R.string.account_progress).uppercase(),
color = ink.copy(alpha = 0.5f),
style = MaterialTheme.typography.labelMedium
) )
Text(title, color = ink, style = MaterialTheme.typography.titleMedium) Text("$elo", color = ink, style = MaterialTheme.typography.headlineMedium)
Text(subtitle, color = ink.copy(alpha = 0.65f), style = MaterialTheme.typography.bodySmall) }
MiniRatingGraph(points = curve, modifier = Modifier.width(132.dp).height(44.dp), showDots = false, showGrid = false)
}
StatTiles()
}
}
/** Games, wins and streak, as three equal tiles. */
@Composable
internal fun StatTiles() {
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
StatTile(R.drawable.ic_play, stringResource(R.string.stat_games), "${Stats.gamesPlayed()}", Modifier.weight(1f))
StatTile(R.drawable.ic_trophy, stringResource(R.string.stat_wins), "${Stats.wins()}", Modifier.weight(1f))
StatTile(R.drawable.ic_speed, stringResource(R.string.stat_streak), "${Stats.streak()}", Modifier.weight(1f))
}
}
@Composable
private fun StatTile(iconRes: Int, label: String, value: String, modifier: Modifier = Modifier) {
Column(
modifier = modifier
.clip(RoundedCornerShape(16.dp))
.background(Surface2)
.padding(vertical = 12.dp, horizontal = 8.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
AppIcon(iconRes, size = 18.dp, tint = ChessGreen)
Spacer(Modifier.height(6.dp))
Text(label, color = ink.copy(alpha = 0.6f), style = MaterialTheme.typography.labelSmall, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(value, color = ink, style = MaterialTheme.typography.titleMedium, maxLines = 1)
} }
} }
@@ -326,7 +516,7 @@ internal fun StatsDialog(onDismiss: () -> Unit) {
} }
@Composable @Composable
internal fun MiniRatingGraph(points: List<Int>, modifier: Modifier = Modifier) { internal fun MiniRatingGraph(points: List<Int>, modifier: Modifier = Modifier, showDots: Boolean = true, showGrid: Boolean = true) {
val lineInk = ink val lineInk = ink
// Paths, gradient and stroke are built once per size and reused by every redraw. // Paths, gradient and stroke are built once per size and reused by every redraw.
Spacer( Spacer(
@@ -352,24 +542,31 @@ internal fun MiniRatingGraph(points: List<Int>, modifier: Modifier = Modifier) {
close() close()
} }
val fillBrush = Brush.verticalGradient(listOf(ChessGreen.copy(alpha = 0.35f), ChessGreen.copy(alpha = 0f))) val fillBrush = Brush.verticalGradient(listOf(ChessGreen.copy(alpha = 0.35f), ChessGreen.copy(alpha = 0f)))
val lineStroke = Stroke(width = 4f, cap = StrokeCap.Round) val lineBrush = Brush.horizontalGradient(listOf(ChessGreen, Lime))
val lineStroke = Stroke(width = 2.5.dp.toPx(), cap = StrokeCap.Round)
onDrawBehind { onDrawBehind {
if (showGrid) {
val gridLines = 4 val gridLines = 4
for (i in 0..gridLines) { for (i in 0..gridLines) {
val y = size.height / gridLines * i val y = size.height / gridLines * i
drawLine(lineInk.copy(alpha = 0.08f), Offset(0f, y), Offset(size.width, y), strokeWidth = 1f) drawLine(lineInk.copy(alpha = 0.06f), Offset(0f, y), Offset(size.width, y), strokeWidth = 1f)
}
drawLine(lineInk.copy(alpha = 0.25f), Offset(0f, zeroY), Offset(size.width, zeroY), strokeWidth = 1.5f)
} }
drawLine(lineInk.copy(alpha = 0.3f), Offset(0f, zeroY), Offset(size.width, zeroY), strokeWidth = 1.5f)
drawPath(fill, brush = fillBrush) drawPath(fill, brush = fillBrush)
drawPath(line, color = ChessGreen, style = lineStroke) drawPath(line, brush = lineBrush, style = lineStroke)
if (showDots) {
points.forEachIndexed { i, v -> points.forEachIndexed { i, v ->
val center = Offset(i * stepX, yOf(v)) val center = Offset(i * stepX, yOf(v))
drawCircle(color = lineInk, radius = 5f, center = center) drawCircle(color = Surface1, radius = 5f, center = center)
drawCircle(color = ChessGreen, radius = 3f, center = center) drawCircle(color = ChessGreen, radius = 3f, center = center)
} }
} else {
drawCircle(color = Lime, radius = 4.dp.toPx(), center = Offset(size.width, yOf(points.last())))
}
} }
} }
) )
@@ -180,7 +180,7 @@ private fun ActionCard(icon: Int, title: String, subtitle: String?, button: Stri
Spacer(Modifier.width(12.dp)) Spacer(Modifier.width(12.dp))
GlassButton(onClick = onClick) { GlassButton(onClick = onClick) {
ButtonIcon(R.drawable.ic_play) ButtonIcon(R.drawable.ic_play)
Text(button, color = ink, maxLines = 1) Text(button, maxLines = 1)
} }
} }
} }
@@ -147,7 +147,7 @@ fun OpeningTrainerScreen(viewModel: OpeningStudyViewModel, onBack: () -> Unit) {
} }
GlassButton(onClick = { if (!viewModel.continueStudy()) onBack() }, modifier = Modifier.weight(1f)) { GlassButton(onClick = { if (!viewModel.continueStudy()) onBack() }, modifier = Modifier.weight(1f)) {
ButtonIcon(R.drawable.ic_next) ButtonIcon(R.drawable.ic_next)
Text(stringResource(R.string.study_next), color = ink, maxLines = 1) Text(stringResource(R.string.study_next), maxLines = 1)
} }
} }
} }
@@ -12,7 +12,6 @@ import androidx.compose.material3.SwitchDefaults
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
@@ -26,10 +25,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import cc.skysparkle.matewave.R import cc.skysparkle.matewave.R
import cc.skysparkle.matewave.settings.FeedbackSettings
import cc.skysparkle.matewave.network.AppPermissions import cc.skysparkle.matewave.network.AppPermissions
import cc.skysparkle.matewave.network.DisconnectReason
import cc.skysparkle.matewave.network.NetworkLog
import cc.skysparkle.matewave.network.NetworkRequirements import cc.skysparkle.matewave.network.NetworkRequirements
import cc.skysparkle.matewave.ui.components.GlassCard import cc.skysparkle.matewave.ui.components.GlassCard
import cc.skysparkle.matewave.ui.components.GlassOutlinedButton import cc.skysparkle.matewave.ui.components.GlassOutlinedButton
@@ -88,39 +84,8 @@ fun PermissionsScreen(onBack: () -> Unit) {
cc.skysparkle.matewave.network.Transports.applyAnnounceSetting() cc.skysparkle.matewave.network.Transports.applyAnnounceSetting()
}, },
colors = SwitchDefaults.colors( colors = SwitchDefaults.colors(
checkedThumbColor = Color.White, checkedThumbColor = cc.skysparkle.matewave.ui.theme.OnAccent,
checkedTrackColor = Color(0xFF4F8A5B) checkedTrackColor = cc.skysparkle.matewave.ui.theme.ChessGreen
)
)
}
}
val feedbackSettings = remember { FeedbackSettings(context) }
var vibration by remember { mutableStateOf(feedbackSettings.vibrationEnabled) }
GlassCard(modifier = Modifier.fillMaxWidth()) {
Row(verticalAlignment = Alignment.CenterVertically) {
cc.skysparkle.matewave.ui.components.ButtonIcon(R.drawable.ic_vibration, size = 24.dp)
Column(modifier = Modifier.weight(1f)) {
Text(
stringResource(R.string.perm_vibration_title),
color = ink,
style = MaterialTheme.typography.titleMedium
)
Text(
stringResource(R.string.perm_vibration_text),
color = ink.copy(alpha = 0.7f),
style = MaterialTheme.typography.bodySmall
)
}
Switch(
checked = vibration,
onCheckedChange = {
vibration = it
feedbackSettings.vibrationEnabled = it
},
colors = SwitchDefaults.colors(
checkedThumbColor = Color.White,
checkedTrackColor = Color(0xFF4F8A5B)
) )
) )
} }
@@ -177,8 +142,8 @@ fun PermissionsScreen(onBack: () -> Unit) {
} }
}, },
colors = SwitchDefaults.colors( colors = SwitchDefaults.colors(
checkedThumbColor = Color.White, checkedThumbColor = cc.skysparkle.matewave.ui.theme.OnAccent,
checkedTrackColor = Color(0xFF4F8A5B) checkedTrackColor = cc.skysparkle.matewave.ui.theme.ChessGreen
) )
) )
} }
@@ -214,53 +179,6 @@ fun PermissionsScreen(onBack: () -> Unit) {
} }
} }
} }
val lastReason by NetworkLog.lastReason.collectAsState()
if (lastReason != DisconnectReason.NONE) {
Row(verticalAlignment = Alignment.CenterVertically) {
cc.skysparkle.matewave.ui.components.ButtonIcon(
R.drawable.ic_error, tint = Color(0xFFFFC46B), size = 16.dp
)
Text(
stringResource(R.string.diag_last_reason, stringResource(lastReason.textRes)),
color = Color(0xFFFFC46B),
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.weight(1f)
)
}
}
val metricsTick by cc.skysparkle.matewave.network.NetworkMetrics.updated.collectAsState()
val metricsText = remember(metricsTick) {
cc.skysparkle.matewave.network.NetworkMetrics.asText(context.resources)
}
Text(
metricsText.trim(),
color = ink.copy(alpha = 0.7f),
style = MaterialTheme.typography.bodySmall
)
GlassOutlinedButton(
onClick = {
val clipboard = context.getSystemService(android.content.Context.CLIPBOARD_SERVICE)
as android.content.ClipboardManager
val report = buildString {
appendLine(context.getString(R.string.diag_report_counters))
append(cc.skysparkle.matewave.network.NetworkMetrics.asText(context.resources))
appendLine()
appendLine(context.getString(R.string.diag_report_events))
append(NetworkLog.asText().ifBlank { context.getString(R.string.diag_log_empty) })
}
clipboard.setPrimaryClip(
android.content.ClipData.newPlainText("network report", report)
)
},
modifier = Modifier.fillMaxWidth()
) {
cc.skysparkle.matewave.ui.components.ButtonIcon(R.drawable.ic_copy)
Text(stringResource(R.string.diag_copy_log), color = ink)
}
} }
} }
@@ -184,7 +184,7 @@ fun PuzzleSolveScreen(viewModel: GameViewModel, onBack: () -> Unit, onNextPuzzle
if (next != null) { if (next != null) {
GlassButton(onClick = { onNextPuzzle(next) }, modifier = Modifier.fillMaxWidth()) { GlassButton(onClick = { onNextPuzzle(next) }, modifier = Modifier.fillMaxWidth()) {
ButtonIcon(R.drawable.ic_next) ButtonIcon(R.drawable.ic_next)
Text(stringResource(R.string.puzzle_next), color = ink, style = MaterialTheme.typography.titleMedium) Text(stringResource(R.string.puzzle_next), style = MaterialTheme.typography.titleMedium)
} }
} }
Text( Text(
@@ -133,7 +133,8 @@ fun SettingsScreen(
) )
ListDivider() ListDivider()
ListRow( ListRow(
title = stringResource(R.string.perm_vibration_title), title = stringResource(R.string.settings_vibration),
subtitle = stringResource(R.string.settings_vibration_subtitle),
icon = R.drawable.ic_vibration, icon = R.drawable.ic_vibration,
trailing = { SettingSwitch(vibrationOn) { vibrationOn = it; feedback.vibrationEnabled = it } } trailing = { SettingSwitch(vibrationOn) { vibrationOn = it; feedback.vibrationEnabled = it } }
) )
@@ -177,6 +178,23 @@ fun SettingsScreen(
onClick = { showAbout = true } onClick = { showAbout = true }
) )
} }
// Donation plaque with the app icon, last on the screen so it never gets in the way
ListGroup {
ListRow(
title = stringResource(R.string.support_title),
subtitle = stringResource(R.string.support_text),
leading = {
Image(
painter = painterResource(R.drawable.ic_launcher_card),
contentDescription = null,
modifier = Modifier.size(36.dp).clip(RoundedCornerShape(10.dp))
)
},
trailing = { cc.skysparkle.matewave.ui.components.AppIcon(R.drawable.ic_heart, size = 22.dp, tint = DonateRed) },
onClick = { cc.skysparkle.matewave.settings.AppLinks.open(context, cc.skysparkle.matewave.settings.AppLinks.DONATE) }
)
}
} }
if (showAbout) { if (showAbout) {
@@ -231,6 +249,12 @@ fun SettingsScreen(
onOpenLicenses() onOpenLicenses()
} }
) )
AboutRow(
iconRes = R.drawable.ic_heart,
title = stringResource(R.string.support_button),
subtitle = cc.skysparkle.matewave.settings.AppLinks.DONATE_LABEL,
onClick = { cc.skysparkle.matewave.settings.AppLinks.open(context, cc.skysparkle.matewave.settings.AppLinks.DONATE) }
)
AboutRow( AboutRow(
iconRes = R.drawable.ic_repo, iconRes = R.drawable.ic_repo,
title = stringResource(R.string.settings_repo_title), title = stringResource(R.string.settings_repo_title),
@@ -241,6 +265,8 @@ fun SettingsScreen(
} }
} }
private val DonateRed = Color(0xFFFF6B8A)
@Composable @Composable
private fun AboutRow(iconRes: Int, title: String, subtitle: String, onClick: () -> Unit) { private fun AboutRow(iconRes: Int, title: String, subtitle: String, onClick: () -> Unit) {
val rowShape = RoundedCornerShape(12.dp) val rowShape = RoundedCornerShape(12.dp)
@@ -272,7 +298,7 @@ private fun SettingSwitch(checked: Boolean, onCheckedChange: (Boolean) -> Unit)
onCheckedChange = onCheckedChange, onCheckedChange = onCheckedChange,
colors = SwitchDefaults.colors( colors = SwitchDefaults.colors(
checkedTrackColor = ChessGreen, checkedTrackColor = ChessGreen,
checkedThumbColor = Color.White, checkedThumbColor = cc.skysparkle.matewave.ui.theme.OnAccent,
uncheckedTrackColor = ink.copy(alpha = 0.15f), uncheckedTrackColor = ink.copy(alpha = 0.15f),
uncheckedThumbColor = Color.White.copy(alpha = 0.7f) uncheckedThumbColor = Color.White.copy(alpha = 0.7f)
) )
@@ -1,6 +1,8 @@
package cc.skysparkle.matewave.ui.screens package cc.skysparkle.matewave.ui.screens
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@@ -182,10 +184,6 @@ fun SpectatorScreen(target: SpectateTarget, onBackToFriends: () -> Unit) {
private fun failureTexts(failure: SpectatorClient.Failure?, max: Int): Pair<String, String> = when (failure) { private fun failureTexts(failure: SpectatorClient.Failure?, max: Int): Pair<String, String> = when (failure) {
SpectatorClient.Failure.FULL -> SpectatorClient.Failure.FULL ->
stringResource(R.string.spectate_full_title) to stringResource(R.string.spectate_full_text, max) stringResource(R.string.spectate_full_title) to stringResource(R.string.spectate_full_text, max)
SpectatorClient.Failure.UPDATE_THIS_APP ->
stringResource(R.string.spectate_update_title) to stringResource(R.string.spectate_update_this)
SpectatorClient.Failure.UPDATE_HOST_APP ->
stringResource(R.string.spectate_update_title) to stringResource(R.string.spectate_update_host)
SpectatorClient.Failure.NO_GAME -> SpectatorClient.Failure.NO_GAME ->
stringResource(R.string.spectate_failed_title) to stringResource(R.string.spectate_no_game) stringResource(R.string.spectate_failed_title) to stringResource(R.string.spectate_no_game)
SpectatorClient.Failure.UNREACHABLE, null -> SpectatorClient.Failure.UNREACHABLE, null ->
@@ -227,15 +225,25 @@ private fun SpectatorPlayerRow(
val avatar = remember(player.id) { val avatar = remember(player.id) {
if (player.id.isEmpty()) null else FriendsStore.list().firstOrNull { it.userId == player.id }?.avatarBase64 if (player.id.isEmpty()) null else FriendsStore.list().firstOrNull { it.userId == player.id }?.avatarBase64
} }
Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) { val cardShape = androidx.compose.foundation.shape.RoundedCornerShape(18.dp)
Row(
modifier = Modifier
.fillMaxWidth()
.clip(cardShape)
.background(cc.skysparkle.matewave.ui.theme.Surface1)
.border(1.dp, if (active) ChessGreen.copy(alpha = 0.7f) else cc.skysparkle.matewave.ui.theme.PanelBorder, cardShape)
.padding(horizontal = 10.dp, vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Box( Box(
modifier = Modifier modifier = Modifier
.size(8.dp) .size(40.dp)
.clip(CircleShape) .clip(CircleShape)
.background(if (active) ChessGreen else ink.copy(alpha = 0.15f)) .background(if (active) ChessGreen else androidx.compose.ui.graphics.Color.Transparent),
) contentAlignment = Alignment.Center
Spacer(Modifier.width(10.dp)) ) {
AvatarCircle(base64 = avatar, size = 34.dp) AvatarCircle(base64 = avatar, size = 36.dp)
}
Spacer(Modifier.width(10.dp)) Spacer(Modifier.width(10.dp))
Column(modifier = Modifier.weight(1f)) { Column(modifier = Modifier.weight(1f)) {
Text( Text(
@@ -80,7 +80,6 @@ fun VsAiSetupScreen(
ButtonIcon(R.drawable.ic_play) ButtonIcon(R.drawable.ic_play)
Text( Text(
stringResource(R.string.vsai_play_summary, difficultyLabel(difficulty), timeControl.displayName()), stringResource(R.string.vsai_play_summary, difficultyLabel(difficulty), timeControl.displayName()),
color = ink,
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
maxLines = 1 maxLines = 1
) )
@@ -0,0 +1,144 @@
package cc.skysparkle.matewave.ui.theme
import android.content.Context
import android.os.Build
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
import cc.skysparkle.matewave.R
/** The colours every screen is drawn with. The app stays dark in every style. */
data class AppPalette(
/** Highlights, selected states, progress. */
val accent: Color,
/** The one main action on a screen. */
val action: Color,
/** Text and icons on top of [accent] or [action]. */
val onAccent: Color,
val background: Color,
val surface1: Color,
val surface2: Color,
/** The forest backdrop keeps its green cast only with the original colours. */
val greenBackdrop: Boolean = false
)
enum class AppStyle(val titleRes: Int) {
MATEWAVE(R.string.app_style_matewave),
LAVENDER(R.string.app_style_lavender),
PEACH(R.string.app_style_peach),
MINT(R.string.app_style_mint),
SKY(R.string.app_style_sky),
DEVICE(R.string.app_style_device);
companion object {
/** Wallpaper colours exist from Android 12. */
val deviceSupported: Boolean get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
val available: List<AppStyle> get() = entries.filter { it != DEVICE || deviceSupported }
}
}
private val MatewavePalette = AppPalette(
accent = Color(0xFF35E07E),
action = Color(0xFFE3F84B),
onAccent = Color(0xFF0B1610),
background = Color(0xFF0C0F0E),
surface1 = Color(0xFF161B19),
surface2 = Color(0xFF1F2623),
greenBackdrop = true
)
private val LavenderPalette = AppPalette(
accent = Color(0xFFC8B6FF),
action = Color(0xFFFFC6E5),
onAccent = Color(0xFF1E1630),
background = Color(0xFF0F0E14),
surface1 = Color(0xFF1A1822),
surface2 = Color(0xFF25222F)
)
private val PeachPalette = AppPalette(
accent = Color(0xFFFFB59E),
action = Color(0xFFFFE08A),
onAccent = Color(0xFF2A1710),
background = Color(0xFF12100E),
surface1 = Color(0xFF1D1A17),
surface2 = Color(0xFF28231F)
)
private val MintPalette = AppPalette(
accent = Color(0xFF9EE7C8),
action = Color(0xFFD8F5A8),
onAccent = Color(0xFF0F231B),
background = Color(0xFF0D110F),
surface1 = Color(0xFF171C1A),
surface2 = Color(0xFF202724)
)
private val SkyPalette = AppPalette(
accent = Color(0xFFA5CBFF),
action = Color(0xFFB8F1EE),
onAccent = Color(0xFF0F1A2A),
background = Color(0xFF0D1014),
surface1 = Color(0xFF171B21),
surface2 = Color(0xFF20252D)
)
/** The selected style, kept in compose state so every screen recolours at once. */
object AppThemeState {
private const val PREFS = "app_theme"
private const val KEY_STYLE = "style"
var style by mutableStateOf(AppStyle.MATEWAVE)
private set
var palette by mutableStateOf(MatewavePalette)
private set
/** Reads the saved style; call once before the first frame. */
fun load(context: Context) {
val saved = context.applicationContext
.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
.getString(KEY_STYLE, null)
val style = AppStyle.entries.firstOrNull { it.name == saved } ?: AppStyle.MATEWAVE
applyStyle(context, style)
}
fun select(context: Context, style: AppStyle) {
context.applicationContext
.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
.edit().putString(KEY_STYLE, style.name).apply()
applyStyle(context, style)
}
private fun applyStyle(context: Context, requested: AppStyle) {
val style = if (requested == AppStyle.DEVICE && !AppStyle.deviceSupported) AppStyle.MATEWAVE else requested
this.style = style
palette = paletteFor(context, style)
}
/** Preview colours for the style picker. */
fun paletteFor(context: Context, style: AppStyle): AppPalette = when (style) {
AppStyle.MATEWAVE -> MatewavePalette
AppStyle.LAVENDER -> LavenderPalette
AppStyle.PEACH -> PeachPalette
AppStyle.MINT -> MintPalette
AppStyle.SKY -> SkyPalette
AppStyle.DEVICE -> devicePalette(context)
}
private fun devicePalette(context: Context): AppPalette {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return MatewavePalette
val scheme = dynamicDarkColorScheme(context)
return AppPalette(
accent = scheme.primary,
action = scheme.tertiary,
onAccent = scheme.onPrimary,
background = scheme.background,
surface1 = scheme.surfaceContainer,
surface2 = scheme.surfaceContainerHigh
)
}
}
@@ -4,15 +4,14 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
val PanelFill = Color(0xFF14171C).copy(alpha = 0.86f) val PanelFill: Color get() = Surface1
val PanelBorder = Color.White.copy(alpha = 0.10f) val PanelBorder = Color.White.copy(alpha = 0.06f)
val UiCornerRadius = 8.dp val UiCornerRadius = 22.dp
val GlassShape: Shape = RoundedCornerShape(UiCornerRadius) val GlassShape: Shape = RoundedCornerShape(UiCornerRadius)
val TabletMaxContentWidth = 600.dp val TabletMaxContentWidth = 600.dp
@@ -21,17 +20,6 @@ fun Modifier.glass(): Modifier = this
.clip(GlassShape) .clip(GlassShape)
.background(PanelFill) .background(PanelFill)
val PhotoScrim = Brush.verticalGradient( val DialogScrimColor = Color.Black.copy(alpha = 0.70f)
0.00f to Color.Black.copy(alpha = 0.84f),
0.10f to Color.Black.copy(alpha = 0.72f),
0.22f to Color.Black.copy(alpha = 0.58f),
0.38f to Color.Black.copy(alpha = 0.48f),
0.55f to Color.Black.copy(alpha = 0.47f),
0.72f to Color.Black.copy(alpha = 0.55f),
0.88f to Color.Black.copy(alpha = 0.68f),
1.00f to Color.Black.copy(alpha = 0.80f)
)
val DialogScrimColor = Color.Black.copy(alpha = 0.62f) val FloatingBarFill: Color get() = Surface2
val FloatingBarFill = Color.Black.copy(alpha = 0.25f)
@@ -3,29 +3,100 @@ package cc.skysparkle.matewave.ui.theme
import androidx.compose.material3.LocalContentColor import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextFieldDefaults import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.material3.Typography
import androidx.compose.material3.darkColorScheme import androidx.compose.material3.darkColorScheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import cc.skysparkle.matewave.R
import androidx.compose.ui.unit.sp
// The interface colours follow the selected style (see AppPalette); reading them in
// composition subscribes the screen, so a new style recolours everything at once.
/** Accent: highlights, selected states and progress. Neon green in the original style. */
val ChessGreen: Color get() = AppThemeState.palette.accent
/** The one colour for the main action on a screen. Lime in the original style. */
val Lime: Color get() = AppThemeState.palette.action
/** Text and icons on top of [ChessGreen] or [Lime]. */
val OnAccent: Color get() = AppThemeState.palette.onAccent
val AppBackground: Color get() = AppThemeState.palette.background
val Surface1: Color get() = AppThemeState.palette.surface1
val Surface2: Color get() = AppThemeState.palette.surface2
val ChessGreen = Color(0xFF3E7C4A)
val ChessGreenDark = Color(0xFF1B4D2E)
val HighlightMove = Color(0x8858A6FF) val HighlightMove = Color(0x8858A6FF)
val HighlightCheck = Color(0x88E53935) val HighlightCheck = Color(0x88E53935)
val HighlightLastMove = Color(0x664FC3F7) val HighlightLastMove = Color(0x664FC3F7)
val HighlightHint = Color(0x88FFC107) val HighlightHint = Color(0x88FFC107)
private val DarkScheme = darkColorScheme( /** Wide display face for the big headings: the brand voice of the app. */
primary = ChessGreen, val DisplayFont = FontFamily(
secondary = ChessGreenDark, Font(R.font.unbounded_semibold, FontWeight.SemiBold),
background = Color(0xFF121212), Font(R.font.unbounded_extrabold, FontWeight.ExtraBold)
surface = Color(0xFF1E1E1E) )
/** Text face for everything else. Characters it lacks (CJK, symbols) fall back to the system font. */
val TextFont = FontFamily(
Font(R.font.manrope_regular, FontWeight.Normal),
Font(R.font.manrope_medium, FontWeight.Medium),
Font(R.font.manrope_semibold, FontWeight.SemiBold),
Font(R.font.manrope_bold, FontWeight.Bold)
)
private val base = Typography()
private fun TextStyle.display(weight: FontWeight, tracking: Double) =
copy(fontFamily = DisplayFont, fontWeight = weight, letterSpacing = tracking.sp)
private fun TextStyle.text(weight: FontWeight) = copy(fontFamily = TextFont, fontWeight = weight)
private val AppTypography = Typography(
displayLarge = base.displayLarge.display(FontWeight.ExtraBold, -1.5),
displayMedium = base.displayMedium.display(FontWeight.ExtraBold, -1.2),
displaySmall = base.displaySmall.display(FontWeight.ExtraBold, -0.8),
headlineLarge = base.headlineLarge.display(FontWeight.ExtraBold, -0.8),
headlineMedium = base.headlineMedium.display(FontWeight.ExtraBold, -0.6),
headlineSmall = base.headlineSmall.copy(fontSize = 21.sp, lineHeight = 28.sp).display(FontWeight.SemiBold, -0.4),
titleLarge = base.titleLarge.text(FontWeight.Bold),
titleMedium = base.titleMedium.text(FontWeight.Bold),
titleSmall = base.titleSmall.text(FontWeight.Bold),
bodyLarge = base.bodyLarge.text(FontWeight.Medium),
bodyMedium = base.bodyMedium.text(FontWeight.Medium),
bodySmall = base.bodySmall.text(FontWeight.Medium),
labelLarge = base.labelLarge.text(FontWeight.Bold),
labelMedium = base.labelMedium.text(FontWeight.Bold).copy(letterSpacing = 1.sp),
labelSmall = base.labelSmall.text(FontWeight.SemiBold)
)
/** Large hero heading on the home screen. */
val HeroTextStyle = TextStyle(
fontFamily = DisplayFont,
fontSize = 46.sp,
lineHeight = 50.sp,
fontWeight = FontWeight.ExtraBold,
letterSpacing = (-1.5).sp
) )
/** The app has a single dark theme; system bars are set up in MainActivity. */ /** The app has a single dark theme; system bars are set up in MainActivity. */
@Composable @Composable
fun MatewaveTheme(content: @Composable () -> Unit) { fun MatewaveTheme(content: @Composable () -> Unit) {
MaterialTheme(colorScheme = DarkScheme) { val scheme = darkColorScheme(
primary = ChessGreen,
onPrimary = OnAccent,
secondary = Lime,
onSecondary = OnAccent,
background = AppBackground,
surface = Surface1,
surfaceVariant = Surface2
)
MaterialTheme(colorScheme = scheme, typography = AppTypography) {
// Text and icons without their own colour are light, so nothing turns black on the dark background // Text and icons without their own colour are light, so nothing turns black on the dark background
CompositionLocalProvider(LocalContentColor provides Color.White, content = content) CompositionLocalProvider(LocalContentColor provides Color.White, content = content)
} }
@@ -35,9 +106,9 @@ fun MatewaveTheme(content: @Composable () -> Unit) {
fun whiteOutlinedTextFieldColors() = OutlinedTextFieldDefaults.colors( fun whiteOutlinedTextFieldColors() = OutlinedTextFieldDefaults.colors(
focusedTextColor = ink, focusedTextColor = ink,
unfocusedTextColor = ink, unfocusedTextColor = ink,
focusedBorderColor = ink.copy(alpha = 0.6f), focusedBorderColor = ChessGreen,
unfocusedBorderColor = ink.copy(alpha = 0.3f), unfocusedBorderColor = ink.copy(alpha = 0.2f),
focusedLabelColor = ink.copy(alpha = 0.8f), focusedLabelColor = ChessGreen,
unfocusedLabelColor = ink.copy(alpha = 0.6f), unfocusedLabelColor = ink.copy(alpha = 0.6f),
cursorColor = ink cursorColor = ChessGreen
) )
@@ -26,6 +26,7 @@ import cc.skysparkle.matewave.network.ConnectionTransport
import cc.skysparkle.matewave.network.GameMessage import cc.skysparkle.matewave.network.GameMessage
import cc.skysparkle.matewave.network.NetworkLog import cc.skysparkle.matewave.network.NetworkLog
import cc.skysparkle.matewave.network.NetworkMetrics import cc.skysparkle.matewave.network.NetworkMetrics
import cc.skysparkle.matewave.network.PeerLimits
import cc.skysparkle.matewave.network.TransportType import cc.skysparkle.matewave.network.TransportType
import cc.skysparkle.matewave.puzzles.Puzzle import cc.skysparkle.matewave.puzzles.Puzzle
import cc.skysparkle.matewave.security.DeviceKeys import cc.skysparkle.matewave.security.DeviceKeys
@@ -43,6 +44,7 @@ import cc.skysparkle.matewave.spectate.SpectatorResult
import cc.skysparkle.matewave.spectate.SpectatorResults import cc.skysparkle.matewave.spectate.SpectatorResults
import cc.skysparkle.matewave.spectate.SpectatorSnapshot import cc.skysparkle.matewave.spectate.SpectatorSnapshot
import cc.skysparkle.matewave.stats.Stats import cc.skysparkle.matewave.stats.Stats
import cc.skysparkle.matewave.ui.components.isAcceptableIncomingImage
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
@@ -84,7 +86,6 @@ data class GameUiState(
val opponentUntrusted: Boolean = false, val opponentUntrusted: Boolean = false,
val opponentUnverified: Boolean = false, val opponentUnverified: Boolean = false,
val opponentOutdated: Boolean = false,
val handshake: HandshakeState = HandshakeState.DISCONNECTED, val handshake: HandshakeState = HandshakeState.DISCONNECTED,
val newPeerFingerprint: String? = null, val newPeerFingerprint: String? = null,
@@ -186,8 +187,10 @@ class GameViewModel : ViewModel() {
private var sessionGeneration = 0 private var sessionGeneration = 0
private var networkGameId: String = "" private var networkGameId: String = ""
private var pendingOpponentImages: Pair<String?, String?>? = null private var pendingOpponentImages: Pair<String?, String?>? = null
// The player picked in the nearby list; whoever answers must be that player.
private var expectedOpponentUserId: String? = null
private var currentPly: Int = 0 private var currentPly: Int = 0
private var lastOpponentRemaining: Long = Long.MAX_VALUE
// Spectating: the host serves spectators, both players announce the game's tag. // Spectating: the host serves spectators, both players announce the game's tag.
private var spectators: SpectatorBroadcaster? = null private var spectators: SpectatorBroadcaster? = null
@@ -712,7 +715,8 @@ class GameViewModel : ViewModel() {
myColor: PieceColor, myColor: PieceColor,
timeControl: TimeControl, timeControl: TimeControl,
isHost: Boolean, isHost: Boolean,
targetId: String? = null targetId: String? = null,
expectedUserId: String? = null
) { ) {
pendingLeave?.let { (job, oldTransport) -> pendingLeave?.let { (job, oldTransport) ->
job.cancel() job.cancel()
@@ -731,6 +735,7 @@ class GameViewModel : ViewModel() {
this.transport = transport this.transport = transport
lastNetworkTimeControl = timeControl lastNetworkTimeControl = timeControl
isNetworkHost = isHost isNetworkHost = isHost
expectedOpponentUserId = expectedUserId?.takeIf { it.isNotBlank() }
ephemeralKeys = DeviceKeys.generateEphemeral() ephemeralKeys = DeviceKeys.generateEphemeral()
@@ -740,7 +745,6 @@ class GameViewModel : ViewModel() {
opponentFlagJob = null opponentFlagJob = null
networkGameId = if (isHost) java.util.UUID.randomUUID().toString() else "" networkGameId = if (isHost) java.util.UUID.randomUUID().toString() else ""
currentPly = 0 currentPly = 0
lastOpponentRemaining = Long.MAX_VALUE
_clockState.value = null _clockState.value = null
_uiState.value = GameUiState( _uiState.value = GameUiState(
@@ -849,6 +853,13 @@ class GameViewModel : ViewModel() {
) )
} }
/** The image if it may be shown and stored, otherwise null (and a log line). */
private fun acceptedIncomingImage(base64: String): String? {
if (base64.length <= MAX_CHAT_IMAGE_CHARS && isAcceptableIncomingImage(base64)) return base64
NetworkLog.log("GAME", "Unreadable or oversized profile image rejected")
return null
}
private fun belongsToCurrentGame(gameId: String): Boolean = private fun belongsToCurrentGame(gameId: String): Boolean =
gameId.isEmpty() || networkGameId.isEmpty() || gameId == networkGameId gameId.isEmpty() || networkGameId.isEmpty() || gameId == networkGameId
@@ -902,9 +913,14 @@ class GameViewModel : ViewModel() {
NetworkLog.log("GAME", "Oversized chat message rejected") NetworkLog.log("GAME", "Oversized chat message rejected")
return return
} }
if (msg.imageBase64 != null && !isAcceptableIncomingImage(msg.imageBase64)) {
NetworkLog.log("GAME", "Unreadable or oversized chat image rejected")
return
}
val state = _uiState.value val state = _uiState.value
_uiState.value = state.copy( _uiState.value = state.copy(
chatMessages = state.chatMessages + ChatEntry(msg.text, msg.imageBase64, fromMe = false), chatMessages = (state.chatMessages + ChatEntry(msg.text, msg.imageBase64, fromMe = false))
.takeLast(MAX_CHAT_ENTRIES),
unreadChatCount = state.unreadChatCount + 1 unreadChatCount = state.unreadChatCount + 1
) )
} }
@@ -977,8 +993,8 @@ class GameViewModel : ViewModel() {
} }
is GameMessage.ProfileImagesMsg -> { is GameMessage.ProfileImagesMsg -> {
if (!belongsToCurrentGame(msg.gameId)) return if (!belongsToCurrentGame(msg.gameId)) return
val avatar = msg.avatarBase64?.takeIf { it.length <= MAX_CHAT_IMAGE_CHARS } val avatar = msg.avatarBase64?.let(::acceptedIncomingImage)
val background = msg.backgroundBase64?.takeIf { it.length <= MAX_CHAT_IMAGE_CHARS } val background = msg.backgroundBase64?.let(::acceptedIncomingImage)
if (avatar == null && background == null) return if (avatar == null && background == null) return
val current = _uiState.value.opponentProfile val current = _uiState.value.opponentProfile
if (current == null) { if (current == null) {
@@ -1052,17 +1068,17 @@ class GameViewModel : ViewModel() {
val limit = lastNetworkTimeControl?.let { it.initialSeconds * 1000L + 60_000L } val limit = lastNetworkTimeControl?.let { it.initialSeconds * 1000L + 60_000L }
val increment = lastNetworkTimeControl?.let { it.incrementSeconds * 1000L } ?: 0L val increment = lastNetworkTimeControl?.let { it.incrementSeconds * 1000L } ?: 0L
val allowedMax = if (lastOpponentRemaining == Long.MAX_VALUE) { // Our own clock has been running the opponent's time while they thought, so their claim
limit ?: Long.MAX_VALUE // may not exceed it by more than the increment and network slack.
} else { val allowedMax = clock?.remainingMillis(opponentColor)
lastOpponentRemaining + increment + CLOCK_TOLERANCE_MS ?.let { PeerLimits.maxOpponentClockAfterMove(it, increment, CLOCK_TOLERANCE_MS) }
} ?: limit ?: Long.MAX_VALUE
if (msg.remainingMillisSelf >= 0 && if (msg.remainingMillisSelf >= 0 &&
(limit == null || msg.remainingMillisSelf <= limit) && (limit == null || msg.remainingMillisSelf <= limit) &&
msg.remainingMillisSelf <= allowedMax msg.remainingMillisSelf <= allowedMax
) { ) {
lastOpponentRemaining = msg.remainingMillisSelf // The reported time already includes the increment; makeMove below adds it again.
clock?.applyRemoteTime(opponentColor, msg.remainingMillisSelf) clock?.applyRemoteTime(opponentColor, (msg.remainingMillisSelf - increment).coerceAtLeast(0))
} else if (msg.remainingMillisSelf > 0) { } else if (msg.remainingMillisSelf > 0) {
NetworkLog.log("GAME", "Invalid clock value from opponent rejected: ${msg.remainingMillisSelf}") NetworkLog.log("GAME", "Invalid clock value from opponent rejected: ${msg.remainingMillisSelf}")
} }
@@ -1078,11 +1094,10 @@ class GameViewModel : ViewModel() {
NetworkLog.log("GAME", "Repeated profile in current session ignored") NetworkLog.log("GAME", "Repeated profile in current session ignored")
return return
} }
if (msg.protocolVersion < GameMessage.PROTOCOL_VERSION) { if (!PeerLimits.isPlausibleProfile(msg)) {
NetworkLog.log( // Nothing of it is stored: no key, no friend entry. The connection is closed.
"GAME", "Opponent protocol version ${msg.protocolVersion} < ${GameMessage.PROTOCOL_VERSION}, incompatible" NetworkLog.log("GAME", "Profile with out-of-range fields rejected, disconnecting")
) transport?.disconnect()
_uiState.value = _uiState.value.copy(opponentOutdated = true)
return return
} }
val peers = knownPeers val peers = knownPeers
@@ -1133,7 +1148,11 @@ class GameViewModel : ViewModel() {
} }
markReadyIfPossible() markReadyIfPossible()
_uiState.value = _uiState.value.copy(opponentUnverified = trust == TrustResult.UNSIGNED) val unexpected = expectedOpponentUserId?.let { it != msg.userId } == true
if (unexpected) {
NetworkLog.log("GAME", "Opponent is not the player picked in the nearby list")
}
_uiState.value = _uiState.value.copy(opponentUnverified = trust == TrustResult.UNSIGNED || unexpected)
val pending = pendingOpponentImages val pending = pendingOpponentImages
pendingOpponentImages = null pendingOpponentImages = null
@@ -1141,8 +1160,8 @@ class GameViewModel : ViewModel() {
userId = msg.userId, userId = msg.userId,
name = msg.name, name = msg.name,
elo = msg.elo, elo = msg.elo,
avatarBase64 = msg.avatarBase64 ?: pending?.first, avatarBase64 = msg.avatarBase64?.let(::acceptedIncomingImage) ?: pending?.first,
backgroundBase64 = msg.backgroundBase64 ?: pending?.second backgroundBase64 = msg.backgroundBase64?.let(::acceptedIncomingImage) ?: pending?.second
) )
_uiState.value = _uiState.value.copy( _uiState.value = _uiState.value.copy(
opponentProfile = Profile( opponentProfile = Profile(
@@ -1248,7 +1267,6 @@ class GameViewModel : ViewModel() {
opponentFlagJob?.cancel() opponentFlagJob?.cancel()
opponentFlagJob = null opponentFlagJob = null
currentPly = 0 currentPly = 0
lastOpponentRemaining = Long.MAX_VALUE
val start = Board.startPosition() val start = Board.startPosition()
resetHistory(start) resetHistory(start)
@@ -1357,7 +1375,8 @@ class GameViewModel : ViewModel() {
val trimmed = text.trim().take(MAX_CHAT_TEXT_CHARS) val trimmed = text.trim().take(MAX_CHAT_TEXT_CHARS)
if (!sendGameMessage(GameMessage.ChatMsg(text = trimmed, gameId = networkGameId))) return if (!sendGameMessage(GameMessage.ChatMsg(text = trimmed, gameId = networkGameId))) return
_uiState.value = _uiState.value.copy( _uiState.value = _uiState.value.copy(
chatMessages = _uiState.value.chatMessages + ChatEntry(trimmed, null, fromMe = true) chatMessages = (_uiState.value.chatMessages + ChatEntry(trimmed, null, fromMe = true))
.takeLast(MAX_CHAT_ENTRIES)
) )
} }
@@ -1370,7 +1389,8 @@ class GameViewModel : ViewModel() {
} }
if (!sendGameMessage(GameMessage.ChatMsg(imageBase64 = base64, gameId = networkGameId))) return if (!sendGameMessage(GameMessage.ChatMsg(imageBase64 = base64, gameId = networkGameId))) return
_uiState.value = _uiState.value.copy( _uiState.value = _uiState.value.copy(
chatMessages = _uiState.value.chatMessages + ChatEntry(null, base64, fromMe = true) chatMessages = (_uiState.value.chatMessages + ChatEntry(null, base64, fromMe = true))
.takeLast(MAX_CHAT_ENTRIES)
) )
} }
@@ -1408,7 +1428,10 @@ class GameViewModel : ViewModel() {
viewModelScope.launch { viewModelScope.launch {
var serving = false var serving = false
try { try {
val port = withContext(Dispatchers.IO) { runCatching { hub.start() }.getOrNull() } // Spectators come over Wi-Fi; other interfaces (mobile data) are not listened on.
val port = withContext(Dispatchers.IO) {
runCatching { hub.start(cc.skysparkle.matewave.share.LocalNetwork.wifiInet4()) }.getOrNull()
}
if (port == null) NetworkLog.log("SPECTATE", "Could not open the spectator port") if (port == null) NetworkLog.log("SPECTATE", "Could not open the spectator port")
// The game may have ended while the port was opening. // The game may have ended while the port was opening.
if (port == null || generation != sessionGeneration || !spectatingDecided || spectateTag.isEmpty()) return@launch if (port == null || generation != sessionGeneration || !spectatingDecided || spectateTag.isEmpty()) return@launch
@@ -1597,6 +1620,7 @@ class GameViewModel : ViewModel() {
const val MAX_CHAT_TEXT_CHARS = 8_000 const val MAX_CHAT_TEXT_CHARS = 8_000
const val MAX_CHAT_IMAGE_CHARS = 400_000 const val MAX_CHAT_IMAGE_CHARS = 400_000
const val CLOCK_TOLERANCE_MS = 2_000L const val CLOCK_TOLERANCE_MS = 2_000L
const val MAX_CHAT_ENTRIES = 200
const val HANDSHAKE_TIMEOUT_MS = 20_000L const val HANDSHAKE_TIMEOUT_MS = 20_000L
const val OPPONENT_FLAG_GRACE_MS = 4_000L const val OPPONENT_FLAG_GRACE_MS = 4_000L
const val LEAVE_FLUSH_MS = 700L const val LEAVE_FLUSH_MS = 700L
@@ -0,0 +1,10 @@
<!-- Material Symbols "crisis-alert" 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="M8.1 21.213q-1.825-.788-3.175-2.138T2.788 15.9T2 12q0-2.85 1.488-5.262T7.525 3.05q.025.475.1.963t.25 1.137q-1.8 1.1-2.838 2.913T4 12q0 3.35 2.325 5.675T12 20t5.675-2.325T20 12q0-2.125-1.037-3.95T16.1 5.125q.175-.65.25-1.137t.125-.938q2.55 1.275 4.038 3.675T22 12q0 2.075-.788 3.9t-2.137 3.175t-3.175 2.138T12 22t-3.9-.788m-.35-4.962Q6 14.5 6 12q0-1.45.638-2.725T8.45 7.15q.125.375.275.863t.4 1.212q-.55.575-.837 1.275T8 12q0 1.65 1.175 2.825T12 16t2.825-1.175T16 12q0-.8-.288-1.5t-.837-1.275q.2-.6.363-1.112t.287-.963Q16.7 8 17.35 9.275T18 12q0 2.5-1.75 4.25T12 18t-4.25-1.75M11 8.5q-.925-2.8-1.213-3.937T9.5 2.5q0-1.05.725-1.775T12 0t1.775.725T14.5 2.5q0 .925-.288 2.063T13 8.5zm-.413 4.913Q10 12.825 10 12t.588-1.412T12 10t1.413.588T14 12t-.587 1.413T12 14t-1.412-.587" />
</vector>
@@ -0,0 +1,10 @@
<!-- Material Symbols "grid-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="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M5 21h2.675v-4.675H3V19q0 .825.588 1.413T5 21m4.675 0h4.65v-4.675h-4.65zm6.65 0H19q.825 0 1.413-.587T21 19v-2.675h-4.675zM3 14.325h4.675v-4.65H3zm6.675 0h4.65v-4.65h-4.65zm6.65 0H21v-4.65h-4.675zM3 7.675h4.675V3H5q-.825 0-1.412.588T3 5zm6.675 0h4.65V3h-4.65zm6.65 0H21V5q0-.825-.587-1.412T19 3h-2.675z" />
</vector>
+10
View File
@@ -0,0 +1,10 @@
<!-- Material Icons "favorite" 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="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z" />
</vector>
@@ -0,0 +1,10 @@
<!-- Material Symbols "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="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M5 21q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h14q.825 0 1.413.588T21 5v14q0 .825-.587 1.413T19 21zm1-4h12l-3.75-5l-3 4L9 13z" />
</vector>
@@ -0,0 +1,10 @@
<!-- Material Symbols "moving" 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="M3.4 18L2 16.6l5.3-5.3q.875-.875 2.125-.875t2.125.875l1.15 1.15q.3.3.713.3t.712-.3L18.575 8H16V6h6v6h-2V9.425l-4.475 4.45q-.875.875-2.125.875t-2.125-.875L10.1 12.7q-.275-.275-.7-.275t-.7.275z" />
</vector>
@@ -0,0 +1,10 @@
<!-- Material Symbols "format-list-numbered" 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="M3 22v-1.5h2.5v-.75H4v-1.5h1.5v-.75H3V16h3q.425 0 .713.288T7 17v1q0 .425-.288.713T6 19q.425 0 .713.288T7 20v1q0 .425-.288.713T6 22zm0-7v-2.75q0-.425.288-.712T4 11.25h1.5v-.75H3V9h3q.425 0 .713.288T7 10v1.75q0 .425-.288.713T6 12.75H4.5v.75H7V15zm1.5-7V3.5H3V2h3v6zM9 19v-2h12v2zm0-6v-2h12v2zm0-6V5h12v2z" />
</vector>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+94
View File
@@ -0,0 +1,94 @@
Copyright 2018 The Manrope Project Authors (https://github.com/googlefonts/manrope)
Copyright 2022 The Unbounded Project Authors (https://github.com/googlefonts/unbounded)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
+22 -24
View File
@@ -7,13 +7,11 @@
<string name="greeting_night">Gute Nacht</string> <string name="greeting_night">Gute Nacht</string>
<string name="continue_game_title">Partie fortsetzen</string> <string name="continue_game_title">Partie fortsetzen</string>
<string name="quick_game_title">Schnelles Spiel</string> <string name="quick_game_title">Schnelles Spiel</string>
<string name="quick_game_subtitle">Wie beim letzten Mal: %1$s · %2$s</string>
<string name="mode_ai_title">Gegen die KI</string> <string name="mode_ai_title">Gegen die KI</string>
<string name="mode_ai_subtitle">Schwierigkeit wählen</string> <string name="mode_ai_subtitle">Schwierigkeit wählen</string>
<string name="mode_online_title">Mit einem Freund</string> <string name="mode_online_title">Mit einem Freund</string>
<string name="mode_online_subtitle">Per Bluetooth oder WLAN in der Nähe</string> <string name="mode_online_subtitle">Per Bluetooth oder WLAN in der Nähe</string>
<string name="puzzles_title">Schachaufgaben</string> <string name="puzzles_title">Schachaufgaben</string>
<string name="puzzles_subtitle">Aufgaben passend zu deiner Wertung</string>
<string name="stats_dialog_title">Statistik</string> <string name="stats_dialog_title">Statistik</string>
<string name="stats_dialog_summary">%1$d Siege · %2$d%% · Serie: %3$d</string> <string name="stats_dialog_summary">%1$d Siege · %2$d%% · Serie: %3$d</string>
<string name="stats_min">Min.: %1$d</string> <string name="stats_min">Min.: %1$d</string>
@@ -104,11 +102,8 @@
<string name="mesh_permission_title">Berechtigungen für Spiele in der Nähe</string> <string name="mesh_permission_title">Berechtigungen für Spiele in der Nähe</string>
<string name="mesh_permission_text">Um Spieler in der Nähe zu finden und ohne Internet mit ihnen zu spielen, braucht die App Zugriff auf Bluetooth. Die Suche läuft nur, solange der Bildschirm „Spiel in der Nähe“ geöffnet ist.</string> <string name="mesh_permission_text">Um Spieler in der Nähe zu finden und ohne Internet mit ihnen zu spielen, braucht die App Zugriff auf Bluetooth. Die Suche läuft nur, solange der Bildschirm „Spiel in der Nähe“ geöffnet ist.</string>
<string name="permissions_card_title">Berechtigungen</string> <string name="permissions_card_title">Berechtigungen</string>
<string name="diag_last_reason">Letzter Verbindungsfehler: %1$s</string>
<string name="diag_copy_log">Verbindungsprotokoll kopieren</string>
<string name="trust_impersonation">Dieser Spieler gibt sich als jemand anderes aus – Daten abgelehnt</string> <string name="trust_impersonation">Dieser Spieler gibt sich als jemand anderes aus – Daten abgelehnt</string>
<string name="trust_unverified">Die Identität des Gegners ist nicht bestätigt (er hat eine alte App-Version)</string> <string name="trust_unverified">Die Identität des Gegners ist nicht bestätigt</string>
<string name="trust_outdated">Die App des Gegners ist veraltet – sicheres Spielen ist nicht möglich. Beide sollten die App aktualisieren.</string>
<string name="perm_grant">Erlauben</string> <string name="perm_grant">Erlauben</string>
<string name="perm_nearby_title">Verbindung zu Geräten in der Nähe</string> <string name="perm_nearby_title">Verbindung zu Geräten in der Nähe</string>
<string name="perm_nearby_text">Nötig, um Spieler in der Nähe zu finden und ohne Internet zu spielen.</string> <string name="perm_nearby_text">Nötig, um Spieler in der Nähe zu finden und ohne Internet zu spielen.</string>
@@ -116,8 +111,16 @@
<string name="rating_gate_text">Die Wertung wird gebraucht, um einen passenden Gegner zu wählen und dich anderen Spielern zu zeigen. Es dauert nur ein paar Sekunden.</string> <string name="rating_gate_text">Die Wertung wird gebraucht, um einen passenden Gegner zu wählen und dich anderen Spielern zu zeigen. Es dauert nur ein paar Sekunden.</string>
<string name="rating_gate_open">Niveau angeben</string> <string name="rating_gate_open">Niveau angeben</string>
<string name="about_section">Über die App</string> <string name="about_section">Über die App</string>
<string name="appearance_title">Aussehen des Bretts</string> <string name="appearance_title">Darstellung</string>
<string name="appearance_subtitle">Brettfarben, Koordinaten, Figurenstil</string> <string name="appearance_subtitle">App-Farben, Brett, Figuren</string>
<string name="app_style_title">App-Farben</string>
<string name="app_style_matewave">Matewave</string>
<string name="app_style_lavender">Lavendel</string>
<string name="app_style_peach">Pfirsich</string>
<string name="app_style_mint">Minze</string>
<string name="app_style_sky">Himmel</string>
<string name="app_style_device">Gerät</string>
<string name="app_style_device_hint">Die Farben kommen aus deinem Hintergrundbild (Material You) und ändern sich mit ihm.</string>
<string name="appearance_board_theme">Brettfarben</string> <string name="appearance_board_theme">Brettfarben</string>
<string name="appearance_coordinates">Buchstaben und Zahlen auf dem Brett</string> <string name="appearance_coordinates">Buchstaben und Zahlen auf dem Brett</string>
<string name="appearance_coordinates_hint">Feldbeschriftung an den Rändern: a–h und 1–8</string> <string name="appearance_coordinates_hint">Feldbeschriftung an den Rändern: a–h und 1–8</string>
@@ -131,7 +134,6 @@
<string name="account_forget_keys_confirm">Du kannst einen bekannten Gegner dann nicht mehr von jemandem unterscheiden, der seinen Namen benutzt, bis ihr euch erneut trefft. Nötig, wenn der Gegner die App neu installiert hat.</string> <string name="account_forget_keys_confirm">Du kannst einen bekannten Gegner dann nicht mehr von jemandem unterscheiden, der seinen Namen benutzt, bis ihr euch erneut trefft. Nötig, wenn der Gegner die App neu installiert hat.</string>
<string name="account_confirm">Vergessen</string> <string name="account_confirm">Vergessen</string>
<string name="account_cancel">Abbrechen</string> <string name="account_cancel">Abbrechen</string>
<string name="greeting_ready">Bereit für eine neue Partie?</string>
<string name="account_trusted_keys_hint">Werden beim ersten Treffen mit einem neuen Spieler automatisch gespeichert</string> <string name="account_trusted_keys_hint">Werden beim ersten Treffen mit einem neuen Spieler automatisch gespeichert</string>
<string name="account_fingerprint_explain">Eindeutiger Fingerabdruck des Schlüssels dieses Geräts. Dein Gegner kann ihn beim ersten Treffen mit deinem vergleichen.</string> <string name="account_fingerprint_explain">Eindeutiger Fingerabdruck des Schlüssels dieses Geräts. Dein Gegner kann ihn beim ersten Treffen mit deinem vergleichen.</string>
<string name="friends_online">Online</string> <string name="friends_online">Online</string>
@@ -174,6 +176,8 @@
<string name="licenses_group_data">Daten</string> <string name="licenses_group_data">Daten</string>
<string name="licenses_group_radio">Radio</string> <string name="licenses_group_radio">Radio</string>
<string name="licenses_apache_full">Vollständiger Text der Apache License 2.0</string> <string name="licenses_apache_full">Vollständiger Text der Apache License 2.0</string>
<string name="licenses_ofl_full">Vollständiger Text der SIL Open Font License 1.1</string>
<string name="licenses_note_fonts">Schriften der Oberfläche: Unbounded für Überschriften, Manrope für Text.</string>
<string name="licenses_note_puzzles">Die Aufgaben stammen aus der offenen Lichess-Puzzle-Datenbank. Die CC0-Lizenz verlangt keine Namensnennung – wir danken dem Lichess-Team.</string> <string name="licenses_note_puzzles">Die Aufgaben stammen aus der offenen Lichess-Puzzle-Datenbank. Die CC0-Lizenz verlangt keine Namensnennung – wir danken dem Lichess-Team.</string>
<string name="licenses_note_swissjazz">Öffentlich zugänglicher Internet-Stream der SRG SSR: ohne Werbung und ohne Moderation, durch Gebühren finanziert. Die Musik gehört dem Sender und den Rechteinhabern; die App spielt den Stream nur ab und speichert nichts.</string> <string name="licenses_note_swissjazz">Öffentlich zugänglicher Internet-Stream der SRG SSR: ohne Werbung und ohne Moderation, durch Gebühren finanziert. Die Musik gehört dem Sender und den Rechteinhabern; die App spielt den Stream nur ab und speichert nichts.</string>
<string name="licenses_radio_hint">Das Jazzradio in den Einstellungen spielt nur Radio Swiss Jazz; ist einer der offiziellen Stream-Links nicht erreichbar, nutzt die App einen anderen.</string> <string name="licenses_radio_hint">Das Jazzradio in den Einstellungen spielt nur Radio Swiss Jazz; ist einer der offiziellen Stream-Links nicht erreichbar, nutzt die App einen anderen.</string>
@@ -197,8 +201,8 @@
<string name="share_no_wifi">Kein WLAN gefunden. Verbinde dich mit einem WLAN oder schalte einen Hotspot ein und öffne diese Seite erneut.</string> <string name="share_no_wifi">Kein WLAN gefunden. Verbinde dich mit einem WLAN oder schalte einen Hotspot ein und öffne diese Seite erneut.</string>
<string name="share_split_warning">Diese App wurde als Paket aus mehreren Teilen installiert (z. B. über Google Play). Die geteilte Datei lässt sich deshalb eventuell auf einem anderen Handy nicht installieren.</string> <string name="share_split_warning">Diese App wurde als Paket aus mehreren Teilen installiert (z. B. über Google Play). Die geteilte Datei lässt sich deshalb eventuell auf einem anderen Handy nicht installieren.</string>
<string name="share_failed">Die Datei konnte nicht zum Teilen vorbereitet werden.</string> <string name="share_failed">Die Datei konnte nicht zum Teilen vorbereitet werden.</string>
<string name="perm_vibration_title">Vibration</string> <string name="settings_vibration">Vibration</string>
<string name="perm_vibration_text">Ein kurzes Vibrieren beim Wählen einer Figur, beim Ziehen und Schlagen, ein doppeltes bei Schach und am Ende der Partie. Schalte es aus, wenn du es nicht möchtest.</string> <string name="settings_vibration_subtitle">Zug, Schlagen und Schach</string>
<string name="appearance_last_move">Letzten Zug hervorheben</string> <string name="appearance_last_move">Letzten Zug hervorheben</string>
<string name="appearance_last_move_hint">Färbt die Felder, von und auf die der letzte Zug ging</string> <string name="appearance_last_move_hint">Färbt die Felder, von und auf die der letzte Zug ging</string>
<string name="appearance_check">Schach hervorheben</string> <string name="appearance_check">Schach hervorheben</string>
@@ -215,15 +219,6 @@
<string name="reason_remote_disconnected">Der Gegner hat die Verbindung getrennt</string> <string name="reason_remote_disconnected">Der Gegner hat die Verbindung getrennt</string>
<string name="reason_port_busy">Port konnte nicht geöffnet werden</string> <string name="reason_port_busy">Port konnte nicht geöffnet werden</string>
<string name="reason_unknown">Unbekannter Verbindungsfehler</string> <string name="reason_unknown">Unbekannter Verbindungsfehler</string>
<string name="metrics_connect_attempts">Verbindungsversuche: %1$d, erfolgreich: %2$d</string>
<string name="metrics_last_connect">Letzte Verbindung dauerte: %1$d ms</string>
<string name="metrics_chunks">Teile gesendet: %1$d, erneut: %2$d (%3$d%%)</string>
<string name="metrics_duplicates">Doppelte Teile empfangen: %1$d</string>
<string name="metrics_corrupted">Beschädigte Nachrichten: %1$d</string>
<string name="metrics_dropped">Verlorene Nachrichten: %1$d</string>
<string name="diag_report_counters">=== Netzwerkzähler ===</string>
<string name="diag_report_events">=== Ereignisse ===</string>
<string name="diag_log_empty">Protokoll ist leer</string>
<string name="nearby_player_default">Spieler in der Nähe</string> <string name="nearby_player_default">Spieler in der Nähe</string>
<string name="player_default_name">Spieler</string> <string name="player_default_name">Spieler</string>
<string name="time_no_limit">Ohne Zeitkontrolle</string> <string name="time_no_limit">Ohne Zeitkontrolle</string>
@@ -319,6 +314,10 @@
<string name="study_start_button">Start</string> <string name="study_start_button">Start</string>
<string name="study_locked_short">Gesperrt</string> <string name="study_locked_short">Gesperrt</string>
<string name="home_today">Heute</string> <string name="home_today">Heute</string>
<string name="home_hero">Spiel los</string>
<string name="stat_games">Partien</string>
<string name="stat_wins">Siege</string>
<string name="stat_streak">Serie</string>
<string name="home_continue_details">Zug %1$d · %2$s</string> <string name="home_continue_details">Zug %1$d · %2$s</string>
<string name="home_your_move">du bist am Zug</string> <string name="home_your_move">du bist am Zug</string>
<string name="home_ai_move">KI am Zug</string> <string name="home_ai_move">KI am Zug</string>
@@ -329,7 +328,6 @@
<string name="settings_section_system">System</string> <string name="settings_section_system">System</string>
<string name="permissions_card_ok_short">Alles bereit</string> <string name="permissions_card_ok_short">Alles bereit</string>
<string name="permissions_card_blocked_short">Aktion nötig</string> <string name="permissions_card_blocked_short">Aktion nötig</string>
<string name="account_header_summary">Wertung %1$d · Partien: %2$d</string>
<string name="account_progress">Fortschritt</string> <string name="account_progress">Fortschritt</string>
<string name="account_rating_row">Wertung</string> <string name="account_rating_row">Wertung</string>
<string name="account_device_key">Geräteschlüssel</string> <string name="account_device_key">Geräteschlüssel</string>
@@ -372,12 +370,12 @@
<string name="spectate_lost_text">Das Gerät, auf dem die Partie läuft, ist nicht mehr erreichbar.</string> <string name="spectate_lost_text">Das Gerät, auf dem die Partie läuft, ist nicht mehr erreichbar.</string>
<string name="spectate_full_title">Partie ist voll</string> <string name="spectate_full_title">Partie ist voll</string>
<string name="spectate_full_text">Diese Partie hat bereits die maximale Zahl von %1$d Zuschauern. Versuch es später noch einmal.</string> <string name="spectate_full_text">Diese Partie hat bereits die maximale Zahl von %1$d Zuschauern. Versuch es später noch einmal.</string>
<string name="spectate_update_title">Update erforderlich</string>
<string name="spectate_update_this">Aktualisiere Matewave, um diese Partie anzusehen.</string>
<string name="spectate_update_host">Der Spieler, der diese Partie ausrichtet, muss Matewave aktualisieren, bevor man zuschauen kann.</string>
<string name="spectate_failed_title">Zuschauen nicht möglich</string> <string name="spectate_failed_title">Zuschauen nicht möglich</string>
<string name="spectate_no_game">Diese Partie ist nicht mehr verfügbar.</string> <string name="spectate_no_game">Diese Partie ist nicht mehr verfügbar.</string>
<string name="spectate_unreachable">Das Gerät, auf dem die Partie läuft, ist nicht erreichbar. Achte darauf, dass du im selben WLAN bist.</string> <string name="spectate_unreachable">Das Gerät, auf dem die Partie läuft, ist nicht erreichbar. Achte darauf, dass du im selben WLAN bist.</string>
<string name="spectate_left_win">%1$s hat die Partie verlassen. %2$s gewinnt.</string> <string name="spectate_left_win">%1$s hat die Partie verlassen. %2$s gewinnt.</string>
<string name="spectate_interrupted">Partie unterbrochen: Die Spieler haben die Verbindung verloren.</string> <string name="spectate_interrupted">Partie unterbrochen: Die Spieler haben die Verbindung verloren.</string>
<string name="support_title">Matewave unterstützen</string>
<string name="support_text">Kostenlos, quelloffen und werbefrei. Eine kleine Spende hilft, das Projekt weiterzuführen.</string>
<string name="support_button">Auf Ko-fi spenden</string>
</resources> </resources>
+22 -24
View File
@@ -7,13 +7,11 @@
<string name="greeting_night">おやすみなさい</string> <string name="greeting_night">おやすみなさい</string>
<string name="continue_game_title">対局を続ける</string> <string name="continue_game_title">対局を続ける</string>
<string name="quick_game_title">クイックゲーム</string> <string name="quick_game_title">クイックゲーム</string>
<string name="quick_game_subtitle">前回と同じ:%1$s・%2$s</string>
<string name="mode_ai_title">AIと対戦</string> <string name="mode_ai_title">AIと対戦</string>
<string name="mode_ai_subtitle">難易度を選択</string> <string name="mode_ai_subtitle">難易度を選択</string>
<string name="mode_online_title">友達と対戦</string> <string name="mode_online_title">友達と対戦</string>
<string name="mode_online_subtitle">近くでBluetoothまたはWi-Fiで</string> <string name="mode_online_subtitle">近くでBluetoothまたはWi-Fiで</string>
<string name="puzzles_title">チェスパズル</string> <string name="puzzles_title">チェスパズル</string>
<string name="puzzles_subtitle">あなたのレーティングに合った問題</string>
<string name="stats_dialog_title">成績</string> <string name="stats_dialog_title">成績</string>
<string name="stats_dialog_summary">%1$d勝 · %2$d%% · 連勝: %3$d</string> <string name="stats_dialog_summary">%1$d勝 · %2$d%% · 連勝: %3$d</string>
<string name="stats_min">最小: %1$d</string> <string name="stats_min">最小: %1$d</string>
@@ -104,11 +102,8 @@
<string name="mesh_permission_title">近くで対戦するための権限</string> <string name="mesh_permission_title">近くで対戦するための権限</string>
<string name="mesh_permission_text">近くのプレイヤーを見つけてインターネットなしで対戦するには、Bluetoothへのアクセスが必要です。検索は「近くで対戦」画面を開いている間だけ行われます。</string> <string name="mesh_permission_text">近くのプレイヤーを見つけてインターネットなしで対戦するには、Bluetoothへのアクセスが必要です。検索は「近くで対戦」画面を開いている間だけ行われます。</string>
<string name="permissions_card_title">権限</string> <string name="permissions_card_title">権限</string>
<string name="diag_last_reason">直近の通信エラー: %1$s</string>
<string name="diag_copy_log">通信ログをコピー</string>
<string name="trust_impersonation">このプレイヤーは他人になりすましています — データを拒否しました</string> <string name="trust_impersonation">このプレイヤーは他人になりすましています — データを拒否しました</string>
<string name="trust_unverified">相手の本人確認ができていません(古いバージョンのアプリです)</string> <string name="trust_unverified">相手の本人確認ができていません</string>
<string name="trust_outdated">相手のアプリが古いため、安全に対局できません。両方のアプリを更新してください。</string>
<string name="perm_grant">許可</string> <string name="perm_grant">許可</string>
<string name="perm_nearby_title">近くのデバイスとの通信</string> <string name="perm_nearby_title">近くのデバイスとの通信</string>
<string name="perm_nearby_text">近くのプレイヤーを見つけ、インターネットなしで対戦するために必要です。</string> <string name="perm_nearby_text">近くのプレイヤーを見つけ、インターネットなしで対戦するために必要です。</string>
@@ -116,8 +111,16 @@
<string name="rating_gate_text">レーティングは、適切な相手の選択と他のプレイヤーへの表示に必要です。数秒で完了します。</string> <string name="rating_gate_text">レーティングは、適切な相手の選択と他のプレイヤーへの表示に必要です。数秒で完了します。</string>
<string name="rating_gate_open">レベルを指定</string> <string name="rating_gate_open">レベルを指定</string>
<string name="about_section">このアプリについて</string> <string name="about_section">このアプリについて</string>
<string name="appearance_title">盤の見た目</string> <string name="appearance_title">外観</string>
<string name="appearance_subtitle">盤の色、座標、駒のスタイル</string> <string name="appearance_subtitle">アプリの色、盤、駒</string>
<string name="app_style_title">アプリの色</string>
<string name="app_style_matewave">Matewave</string>
<string name="app_style_lavender">ラベンダー</string>
<string name="app_style_peach">ピーチ</string>
<string name="app_style_mint">ミント</string>
<string name="app_style_sky">スカイ</string>
<string name="app_style_device">端末</string>
<string name="app_style_device_hint">色は壁紙から取得され(Material You)、壁紙に合わせて変わります。</string>
<string name="appearance_board_theme">盤の色</string> <string name="appearance_board_theme">盤の色</string>
<string name="appearance_coordinates">盤上の文字と数字</string> <string name="appearance_coordinates">盤上の文字と数字</string>
<string name="appearance_coordinates_hint">盤の端のマス目ラベル: a〜h と 1〜8</string> <string name="appearance_coordinates_hint">盤の端のマス目ラベル: a〜h と 1〜8</string>
@@ -131,7 +134,6 @@
<string name="account_forget_keys_confirm">再び会うまで、知っている相手とその名前を名乗る人を区別できなくなります。相手がアプリを再インストールした場合に必要です。</string> <string name="account_forget_keys_confirm">再び会うまで、知っている相手とその名前を名乗る人を区別できなくなります。相手がアプリを再インストールした場合に必要です。</string>
<string name="account_confirm">忘れる</string> <string name="account_confirm">忘れる</string>
<string name="account_cancel">キャンセル</string> <string name="account_cancel">キャンセル</string>
<string name="greeting_ready">新しい対局の準備はできましたか?</string>
<string name="account_trusted_keys_hint">新しいプレイヤーと初めて会ったときに自動で保存されます</string> <string name="account_trusted_keys_hint">新しいプレイヤーと初めて会ったときに自動で保存されます</string>
<string name="account_fingerprint_explain">この端末の鍵の固有のフィンガープリントです。初めて会ったとき、相手があなたのものと照合できます。</string> <string name="account_fingerprint_explain">この端末の鍵の固有のフィンガープリントです。初めて会ったとき、相手があなたのものと照合できます。</string>
<string name="friends_online">オンライン</string> <string name="friends_online">オンライン</string>
@@ -174,6 +176,8 @@
<string name="licenses_group_data">データ</string> <string name="licenses_group_data">データ</string>
<string name="licenses_group_radio">ラジオ</string> <string name="licenses_group_radio">ラジオ</string>
<string name="licenses_apache_full">Apache License 2.0 の全文</string> <string name="licenses_apache_full">Apache License 2.0 の全文</string>
<string name="licenses_ofl_full">SIL Open Font License 1.1 の全文</string>
<string name="licenses_note_fonts">インターフェースのフォント:見出しは Unbounded、本文は Manrope。</string>
<string name="licenses_note_puzzles">パズルは Lichess のオープンなパズルデータベースから選んでいます。CC0 ライセンスでは表示義務はありませんが、Lichess チームに感謝します。</string> <string name="licenses_note_puzzles">パズルは Lichess のオープンなパズルデータベースから選んでいます。CC0 ライセンスでは表示義務はありませんが、Lichess チームに感謝します。</string>
<string name="licenses_note_swissjazz">SRG SSR が公開しているインターネットストリームです。広告もナビゲーターもなく、受信料で運営されています。音楽の権利は放送局と権利者に帰属し、アプリは再生するだけで何も保存しません。</string> <string name="licenses_note_swissjazz">SRG SSR が公開しているインターネットストリームです。広告もナビゲーターもなく、受信料で運営されています。音楽の権利は放送局と権利者に帰属し、アプリは再生するだけで何も保存しません。</string>
<string name="licenses_radio_hint">設定のジャズラジオは Radio Swiss Jazz だけを再生します。公式リンクのひとつがつながらないときは、別のリンクに切り替わります。</string> <string name="licenses_radio_hint">設定のジャズラジオは Radio Swiss Jazz だけを再生します。公式リンクのひとつがつながらないときは、別のリンクに切り替わります。</string>
@@ -197,8 +201,8 @@
<string name="share_no_wifi">Wi-Fiネットワークが見つかりません。Wi-Fiに接続するかテザリングをオンにして、この画面を開き直してください。</string> <string name="share_no_wifi">Wi-Fiネットワークが見つかりません。Wi-Fiに接続するかテザリングをオンにして、この画面を開き直してください。</string>
<string name="share_split_warning">このアプリは分割パッケージ(例: Google Play)としてインストールされているため、共有したファイルは別のスマホにインストールできない場合があります。</string> <string name="share_split_warning">このアプリは分割パッケージ(例: Google Play)としてインストールされているため、共有したファイルは別のスマホにインストールできない場合があります。</string>
<string name="share_failed">共有用のファイルを準備できませんでした。</string> <string name="share_failed">共有用のファイルを準備できませんでした。</string>
<string name="perm_vibration_title">バイブレーション</string> <string name="settings_vibration">バイブレーション</string>
<string name="perm_vibration_text">駒の選択、移動、駒を取ったときに短く振動し、チェックや対局終了時には2回振動します。不要ならオフにしてください。</string> <string name="settings_vibration_subtitle">移動、駒を取る、王手</string>
<string name="appearance_last_move">直前の手をハイライト</string> <string name="appearance_last_move">直前の手をハイライト</string>
<string name="appearance_last_move_hint">直前の手の移動元と移動先のマスに色を付けます</string> <string name="appearance_last_move_hint">直前の手の移動元と移動先のマスに色を付けます</string>
<string name="appearance_check">チェックをハイライト</string> <string name="appearance_check">チェックをハイライト</string>
@@ -215,15 +219,6 @@
<string name="reason_remote_disconnected">相手が切断しました</string> <string name="reason_remote_disconnected">相手が切断しました</string>
<string name="reason_port_busy">ポートを開けませんでした</string> <string name="reason_port_busy">ポートを開けませんでした</string>
<string name="reason_unknown">不明な通信エラー</string> <string name="reason_unknown">不明な通信エラー</string>
<string name="metrics_connect_attempts">接続試行: %1$d 回、成功: %2$d 回</string>
<string name="metrics_last_connect">直近の接続時間: %1$d ms</string>
<string name="metrics_chunks">送信パート: %1$d、再送: %2$d (%3$d%%)</string>
<string name="metrics_duplicates">重複受信パート: %1$d</string>
<string name="metrics_corrupted">破損したメッセージ: %1$d</string>
<string name="metrics_dropped">失われたメッセージ: %1$d</string>
<string name="diag_report_counters">=== ネットワークカウンター ===</string>
<string name="diag_report_events">=== イベント ===</string>
<string name="diag_log_empty">ログは空です</string>
<string name="nearby_player_default">近くのプレイヤー</string> <string name="nearby_player_default">近くのプレイヤー</string>
<string name="player_default_name">プレイヤー</string> <string name="player_default_name">プレイヤー</string>
<string name="time_no_limit">時間制限なし</string> <string name="time_no_limit">時間制限なし</string>
@@ -318,6 +313,10 @@
<string name="study_start_button">始める</string> <string name="study_start_button">始める</string>
<string name="study_locked_short">ロック中</string> <string name="study_locked_short">ロック中</string>
<string name="home_today">今日</string> <string name="home_today">今日</string>
<string name="home_hero">さあ、対局</string>
<string name="stat_games">対局数</string>
<string name="stat_wins">勝利</string>
<string name="stat_streak">連勝</string>
<string name="home_continue_details">%1$d手目 · %2$s</string> <string name="home_continue_details">%1$d手目 · %2$s</string>
<string name="home_your_move">あなたの番</string> <string name="home_your_move">あなたの番</string>
<string name="home_ai_move">AIの番</string> <string name="home_ai_move">AIの番</string>
@@ -328,7 +327,6 @@
<string name="settings_section_system">システム</string> <string name="settings_section_system">システム</string>
<string name="permissions_card_ok_short">準備完了</string> <string name="permissions_card_ok_short">準備完了</string>
<string name="permissions_card_blocked_short">要対応</string> <string name="permissions_card_blocked_short">要対応</string>
<string name="account_header_summary">レーティング %1$d · 対局: %2$d</string>
<string name="account_progress">進捗</string> <string name="account_progress">進捗</string>
<string name="account_rating_row">レーティング</string> <string name="account_rating_row">レーティング</string>
<string name="account_device_key">端末の鍵</string> <string name="account_device_key">端末の鍵</string>
@@ -371,12 +369,12 @@
<string name="spectate_lost_text">対局をホストしている端末に接続できなくなりました。</string> <string name="spectate_lost_text">対局をホストしている端末に接続できなくなりました。</string>
<string name="spectate_full_title">満員です</string> <string name="spectate_full_title">満員です</string>
<string name="spectate_full_text">この対局の観戦者はすでに上限の%1$d人です。しばらくしてからもう一度お試しください。</string> <string name="spectate_full_text">この対局の観戦者はすでに上限の%1$d人です。しばらくしてからもう一度お試しください。</string>
<string name="spectate_update_title">アップデートが必要です</string>
<string name="spectate_update_this">この対局を観戦するには Matewave をアップデートしてください。</string>
<string name="spectate_update_host">この対局を観戦するには、対局をホストしているプレイヤーが Matewave をアップデートする必要があります。</string>
<string name="spectate_failed_title">観戦できません</string> <string name="spectate_failed_title">観戦できません</string>
<string name="spectate_no_game">この対局はもう観戦できません。</string> <string name="spectate_no_game">この対局はもう観戦できません。</string>
<string name="spectate_unreachable">対局をホストしている端末に接続できません。同じWi-Fiネットワークに接続しているか確認してください。</string> <string name="spectate_unreachable">対局をホストしている端末に接続できません。同じWi-Fiネットワークに接続しているか確認してください。</string>
<string name="spectate_left_win">%1$sが対局から退出しました。%2$sの勝ち</string> <string name="spectate_left_win">%1$sが対局から退出しました。%2$sの勝ち</string>
<string name="spectate_interrupted">対局が中断されました。プレイヤー間の接続が切れました。</string> <string name="spectate_interrupted">対局が中断されました。プレイヤー間の接続が切れました。</string>
<string name="support_title">Matewave を応援する</string>
<string name="support_text">無料・オープンソースで広告なし。少額の寄付が開発の継続を支えます。</string>
<string name="support_button">Ko-fi で寄付する</string>
</resources> </resources>
+22 -24
View File
@@ -7,13 +7,11 @@
<string name="greeting_night">Labos nakties</string> <string name="greeting_night">Labos nakties</string>
<string name="continue_game_title">Tęsti partiją</string> <string name="continue_game_title">Tęsti partiją</string>
<string name="quick_game_title">Greitas žaidimas</string> <string name="quick_game_title">Greitas žaidimas</string>
<string name="quick_game_subtitle">Kaip praėjusį kartą: %1$s · %2$s</string>
<string name="mode_ai_title">Prieš DI</string> <string name="mode_ai_title">Prieš DI</string>
<string name="mode_ai_subtitle">Pasirinkite sudėtingumą</string> <string name="mode_ai_subtitle">Pasirinkite sudėtingumą</string>
<string name="mode_online_title">Su draugu</string> <string name="mode_online_title">Su draugu</string>
<string name="mode_online_subtitle">Per „Bluetooth“ arba „Wi-Fi“ netoliese</string> <string name="mode_online_subtitle">Per „Bluetooth“ arba „Wi-Fi“ netoliese</string>
<string name="puzzles_title">Šachmatų galvosūkiai</string> <string name="puzzles_title">Šachmatų galvosūkiai</string>
<string name="puzzles_subtitle">Užduotys pagal jūsų reitingą</string>
<string name="stats_dialog_title">Statistika</string> <string name="stats_dialog_title">Statistika</string>
<string name="stats_dialog_summary">%1$d pergalių · %2$d%% · serija: %3$d</string> <string name="stats_dialog_summary">%1$d pergalių · %2$d%% · serija: %3$d</string>
<string name="stats_min">Min.: %1$d</string> <string name="stats_min">Min.: %1$d</string>
@@ -104,11 +102,8 @@
<string name="mesh_permission_title">Leidimai žaidimui netoliese</string> <string name="mesh_permission_title">Leidimai žaidimui netoliese</string>
<string name="mesh_permission_text">Kad rastų netoliese esančius žaidėjus ir galėtų su jais žaisti be interneto, programai reikia prieigos prie „Bluetooth“. Paieška vyksta tik kol atidarytas ekranas „Žaidimas netoliese“.</string> <string name="mesh_permission_text">Kad rastų netoliese esančius žaidėjus ir galėtų su jais žaisti be interneto, programai reikia prieigos prie „Bluetooth“. Paieška vyksta tik kol atidarytas ekranas „Žaidimas netoliese“.</string>
<string name="permissions_card_title">Leidimai</string> <string name="permissions_card_title">Leidimai</string>
<string name="diag_last_reason">Paskutinė ryšio klaida: %1$s</string>
<string name="diag_copy_log">Kopijuoti ryšio žurnalą</string>
<string name="trust_impersonation">Šis žaidėjas apsimeta kitu — duomenys atmesti</string> <string name="trust_impersonation">Šis žaidėjas apsimeta kitu — duomenys atmesti</string>
<string name="trust_unverified">Varžovo tapatybė nepatvirtinta (jis turi seną programos versiją)</string> <string name="trust_unverified">Varžovo tapatybė nepatvirtinta</string>
<string name="trust_outdated">Varžovo programa pasenusi – saugus žaidimas neįmanomas. Atnaujinkite programą abiem.</string>
<string name="perm_grant">Leisti</string> <string name="perm_grant">Leisti</string>
<string name="perm_nearby_title">Ryšys su netoliese esančiais įrenginiais</string> <string name="perm_nearby_title">Ryšys su netoliese esančiais įrenginiais</string>
<string name="perm_nearby_text">Reikalinga, kad rastumėte žaidėjų netoliese ir žaistumėte be interneto.</string> <string name="perm_nearby_text">Reikalinga, kad rastumėte žaidėjų netoliese ir žaistumėte be interneto.</string>
@@ -116,8 +111,16 @@
<string name="rating_gate_text">Reitingas reikalingas tinkamam varžovui parinkti ir kitiems žaidėjams jus parodyti. Tai užtrunka porą sekundžių.</string> <string name="rating_gate_text">Reitingas reikalingas tinkamam varžovui parinkti ir kitiems žaidėjams jus parodyti. Tai užtrunka porą sekundžių.</string>
<string name="rating_gate_open">Nurodyti lygį</string> <string name="rating_gate_open">Nurodyti lygį</string>
<string name="about_section">Apie programą</string> <string name="about_section">Apie programą</string>
<string name="appearance_title">Lentos išvaizda</string> <string name="appearance_title">Išvaizda</string>
<string name="appearance_subtitle">Lentos spalvos, koordinatės, figūrų stilius</string> <string name="appearance_subtitle">Programėlės spalvos, lenta, figūros</string>
<string name="app_style_title">Programėlės spalvos</string>
<string name="app_style_matewave">Matewave</string>
<string name="app_style_lavender">Levanda</string>
<string name="app_style_peach">Persikas</string>
<string name="app_style_mint">Mėta</string>
<string name="app_style_sky">Dangus</string>
<string name="app_style_device">Įrenginys</string>
<string name="app_style_device_hint">Spalvos paimamos iš ekrano fono („Material You“) ir keičiasi kartu su juo.</string>
<string name="appearance_board_theme">Lentos spalvos</string> <string name="appearance_board_theme">Lentos spalvos</string>
<string name="appearance_coordinates">Raidės ir skaičiai ant lentos</string> <string name="appearance_coordinates">Raidės ir skaičiai ant lentos</string>
<string name="appearance_coordinates_hint">Langelių žymos pakraščiuose: a–h ir 1–8</string> <string name="appearance_coordinates_hint">Langelių žymos pakraščiuose: a–h ir 1–8</string>
@@ -131,7 +134,6 @@
<string name="account_forget_keys_confirm">Nebegalėsite atskirti pažįstamo varžovo nuo to, kas naudoja jo vardą, kol vėl nesusitiksite. Reikia, jei varžovas iš naujo įdiegė programą.</string> <string name="account_forget_keys_confirm">Nebegalėsite atskirti pažįstamo varžovo nuo to, kas naudoja jo vardą, kol vėl nesusitiksite. Reikia, jei varžovas iš naujo įdiegė programą.</string>
<string name="account_confirm">Pamiršti</string> <string name="account_confirm">Pamiršti</string>
<string name="account_cancel">Atšaukti</string> <string name="account_cancel">Atšaukti</string>
<string name="greeting_ready">Pasiruošę naujai partijai?</string>
<string name="account_trusted_keys_hint">Išsaugomi automatiškai pirmą kartą sutikus naują žaidėją</string> <string name="account_trusted_keys_hint">Išsaugomi automatiškai pirmą kartą sutikus naują žaidėją</string>
<string name="account_fingerprint_explain">Unikalus šio įrenginio rakto kontrolinis kodas. Pirmą kartą susitikęs varžovas gali jį palyginti su jūsų.</string> <string name="account_fingerprint_explain">Unikalus šio įrenginio rakto kontrolinis kodas. Pirmą kartą susitikęs varžovas gali jį palyginti su jūsų.</string>
<string name="friends_online">Prisijungęs</string> <string name="friends_online">Prisijungęs</string>
@@ -174,6 +176,8 @@
<string name="licenses_group_data">Duomenys</string> <string name="licenses_group_data">Duomenys</string>
<string name="licenses_group_radio">Radijas</string> <string name="licenses_group_radio">Radijas</string>
<string name="licenses_apache_full">Pilnas Apache License 2.0 tekstas</string> <string name="licenses_apache_full">Pilnas Apache License 2.0 tekstas</string>
<string name="licenses_ofl_full">Pilnas SIL Open Font License 1.1 tekstas</string>
<string name="licenses_note_fonts">Sąsajos šriftai: „Unbounded“ antraštėms, „Manrope“ tekstui.</string>
<string name="licenses_note_puzzles">Užduotys atrinktos iš atviros „Lichess“ galvosūkių duomenų bazės. CC0 licencija nereikalauja nurodyti autorystės – dėkojame „Lichess“ komandai.</string> <string name="licenses_note_puzzles">Užduotys atrinktos iš atviros „Lichess“ galvosūkių duomenų bazės. CC0 licencija nereikalauja nurodyti autorystės – dėkojame „Lichess“ komandai.</string>
<string name="licenses_note_swissjazz">Viešai prieinama SRG SSR interneto transliacija: be reklamos ir be vedėjų, finansuojama iš licencijos mokesčių. Muzikos teisės priklauso transliuotojui ir teisių turėtojams; programa srautą tik groja ir nieko neišsaugo.</string> <string name="licenses_note_swissjazz">Viešai prieinama SRG SSR interneto transliacija: be reklamos ir be vedėjų, finansuojama iš licencijos mokesčių. Muzikos teisės priklauso transliuotojui ir teisių turėtojams; programa srautą tik groja ir nieko neišsaugo.</string>
<string name="licenses_radio_hint">Nustatymuose esantis džiazo radijas groja tik „Radio Swiss Jazz“; jei viena oficiali nuoroda nepasiekiama, programa naudoja kitą.</string> <string name="licenses_radio_hint">Nustatymuose esantis džiazo radijas groja tik „Radio Swiss Jazz“; jei viena oficiali nuoroda nepasiekiama, programa naudoja kitą.</string>
@@ -197,8 +201,8 @@
<string name="share_no_wifi">Wi-Fi tinklo nerasta. Prisijunkite prie Wi-Fi arba įjunkite viešosios prieigos tašką ir vėl atidarykite šį ekraną.</string> <string name="share_no_wifi">Wi-Fi tinklo nerasta. Prisijunkite prie Wi-Fi arba įjunkite viešosios prieigos tašką ir vėl atidarykite šį ekraną.</string>
<string name="share_split_warning">Ši programa įdiegta kaip dalių rinkinys (pavyzdžiui, iš „Google Play“), todėl bendrinamas failas gali neįsidiegti kitame telefone.</string> <string name="share_split_warning">Ši programa įdiegta kaip dalių rinkinys (pavyzdžiui, iš „Google Play“), todėl bendrinamas failas gali neįsidiegti kitame telefone.</string>
<string name="share_failed">Nepavyko paruošti failo dalijimuisi.</string> <string name="share_failed">Nepavyko paruošti failo dalijimuisi.</string>
<string name="perm_vibration_title">Vibracija</string> <string name="settings_vibration">Vibracija</string>
<string name="perm_vibration_text">Trumpas virptelėjimas pasirinkus figūrą, einant ir kertant, dvigubas – esant šachui ir pasibaigus partijai. Išjunkite, jei jo nenorite.</string> <string name="settings_vibration_subtitle">Ėjimas, paėmimas ir šachas</string>
<string name="appearance_last_move">Paryškinti paskutinį ėjimą</string> <string name="appearance_last_move">Paryškinti paskutinį ėjimą</string>
<string name="appearance_last_move_hint">Nuspalvina langelius, iš kurio ir į kurį padarytas paskutinis ėjimas</string> <string name="appearance_last_move_hint">Nuspalvina langelius, iš kurio ir į kurį padarytas paskutinis ėjimas</string>
<string name="appearance_check">Paryškinti šachą</string> <string name="appearance_check">Paryškinti šachą</string>
@@ -215,15 +219,6 @@
<string name="reason_remote_disconnected">Varžovas atsijungė</string> <string name="reason_remote_disconnected">Varžovas atsijungė</string>
<string name="reason_port_busy">Nepavyko atidaryti prievado</string> <string name="reason_port_busy">Nepavyko atidaryti prievado</string>
<string name="reason_unknown">Nežinoma ryšio klaida</string> <string name="reason_unknown">Nežinoma ryšio klaida</string>
<string name="metrics_connect_attempts">Bandymų prisijungti: %1$d, sėkmingų: %2$d</string>
<string name="metrics_last_connect">Paskutinis prisijungimas užtruko: %1$d ms</string>
<string name="metrics_chunks">Išsiųsta dalių: %1$d, pakartotinai: %2$d (%3$d%%)</string>
<string name="metrics_duplicates">Gauta pasikartojančių dalių: %1$d</string>
<string name="metrics_corrupted">Sugadintų pranešimų: %1$d</string>
<string name="metrics_dropped">Prarastų pranešimų: %1$d</string>
<string name="diag_report_counters">=== Tinklo skaitikliai ===</string>
<string name="diag_report_events">=== Įvykiai ===</string>
<string name="diag_log_empty">žurnalas tuščias</string>
<string name="nearby_player_default">Netoliese esantis žaidėjas</string> <string name="nearby_player_default">Netoliese esantis žaidėjas</string>
<string name="player_default_name">Žaidėjas</string> <string name="player_default_name">Žaidėjas</string>
<string name="time_no_limit">Be laiko kontrolės</string> <string name="time_no_limit">Be laiko kontrolės</string>
@@ -321,6 +316,10 @@
<string name="study_start_button">Pradėti</string> <string name="study_start_button">Pradėti</string>
<string name="study_locked_short">Užrakinta</string> <string name="study_locked_short">Užrakinta</string>
<string name="home_today">Šiandien</string> <string name="home_today">Šiandien</string>
<string name="home_hero">Žaisk</string>
<string name="stat_games">Partijos</string>
<string name="stat_wins">Pergalės</string>
<string name="stat_streak">Serija</string>
<string name="home_continue_details">Ėjimas %1$d · %2$s</string> <string name="home_continue_details">Ėjimas %1$d · %2$s</string>
<string name="home_your_move">jūsų ėjimas</string> <string name="home_your_move">jūsų ėjimas</string>
<string name="home_ai_move">DI ėjimas</string> <string name="home_ai_move">DI ėjimas</string>
@@ -331,7 +330,6 @@
<string name="settings_section_system">Sistema</string> <string name="settings_section_system">Sistema</string>
<string name="permissions_card_ok_short">Viskas paruošta</string> <string name="permissions_card_ok_short">Viskas paruošta</string>
<string name="permissions_card_blocked_short">Reikia veiksmo</string> <string name="permissions_card_blocked_short">Reikia veiksmo</string>
<string name="account_header_summary">Reitingas %1$d · Partijų: %2$d</string>
<string name="account_progress">Pažanga</string> <string name="account_progress">Pažanga</string>
<string name="account_rating_row">Reitingas</string> <string name="account_rating_row">Reitingas</string>
<string name="account_device_key">Įrenginio raktas</string> <string name="account_device_key">Įrenginio raktas</string>
@@ -374,12 +372,12 @@
<string name="spectate_lost_text">Įrenginio, kuriame vyksta partija, nebepavyksta pasiekti.</string> <string name="spectate_lost_text">Įrenginio, kuriame vyksta partija, nebepavyksta pasiekti.</string>
<string name="spectate_full_title">Vietų nebėra</string> <string name="spectate_full_title">Vietų nebėra</string>
<string name="spectate_full_text">Šią partiją jau stebi didžiausias leidžiamas žiūrovų skaičius (%1$d). Pabandykite vėliau.</string> <string name="spectate_full_text">Šią partiją jau stebi didžiausias leidžiamas žiūrovų skaičius (%1$d). Pabandykite vėliau.</string>
<string name="spectate_update_title">Reikia atnaujinti</string>
<string name="spectate_update_this">Atnaujinkite Matewave, kad galėtumėte stebėti šią partiją.</string>
<string name="spectate_update_host">Partiją rengiantis žaidėjas turi atnaujinti Matewave, kad ją būtų galima stebėti.</string>
<string name="spectate_failed_title">Šios partijos stebėti negalima</string> <string name="spectate_failed_title">Šios partijos stebėti negalima</string>
<string name="spectate_no_game">Ši partija nebepasiekiama.</string> <string name="spectate_no_game">Ši partija nebepasiekiama.</string>
<string name="spectate_unreachable">Nepavyksta pasiekti įrenginio, kuriame vyksta partija. Įsitikinkite, kad esate prisijungę prie to paties „Wi-Fi“ tinklo.</string> <string name="spectate_unreachable">Nepavyksta pasiekti įrenginio, kuriame vyksta partija. Įsitikinkite, kad esate prisijungę prie to paties „Wi-Fi“ tinklo.</string>
<string name="spectate_left_win">%1$s paliko partiją. Laimėjo %2$s.</string> <string name="spectate_left_win">%1$s paliko partiją. Laimėjo %2$s.</string>
<string name="spectate_interrupted">Partija nutraukta: žaidėjų ryšys nutrūko.</string> <string name="spectate_interrupted">Partija nutraukta: žaidėjų ryšys nutrūko.</string>
<string name="support_title">Paremti Matewave</string>
<string name="support_text">Nemokama, atvirojo kodo ir be reklamų. Nedidelė auka padeda projektui gyvuoti.</string>
<string name="support_button">Paaukoti per Ko-fi</string>
</resources> </resources>
+22 -24
View File
@@ -9,14 +9,12 @@
<string name="continue_game_title">Продолжить партию</string> <string name="continue_game_title">Продолжить партию</string>
<string name="quick_game_title">Быстрая игра</string> <string name="quick_game_title">Быстрая игра</string>
<string name="quick_game_subtitle">Как в прошлый раз: %1$s · %2$s</string>
<string name="mode_ai_title">Против ИИ</string> <string name="mode_ai_title">Против ИИ</string>
<string name="mode_ai_subtitle">Выберите сложность</string> <string name="mode_ai_subtitle">Выберите сложность</string>
<string name="mode_online_title">С другом</string> <string name="mode_online_title">С другом</string>
<string name="mode_online_subtitle">По Bluetooth или Wi-Fi рядом</string> <string name="mode_online_subtitle">По Bluetooth или Wi-Fi рядом</string>
<string name="puzzles_title">Шахматные задачи</string> <string name="puzzles_title">Шахматные задачи</string>
<string name="puzzles_subtitle">Задачи под ваш рейтинг</string>
<string name="stats_dialog_title">Статистика</string> <string name="stats_dialog_title">Статистика</string>
<string name="stats_dialog_summary">%1$d побед · %2$d%% · серия: %3$d</string> <string name="stats_dialog_summary">%1$d побед · %2$d%% · серия: %3$d</string>
<string name="stats_min">Мин: %1$d</string> <string name="stats_min">Мин: %1$d</string>
@@ -109,11 +107,8 @@
<string name="mesh_permission_title">Разрешения для связи поблизости</string> <string name="mesh_permission_title">Разрешения для связи поблизости</string>
<string name="mesh_permission_text">Чтобы находить игроков рядом и играть с ними без интернета, приложению нужен доступ к Bluetooth. Поиск идёт, только пока открыт экран «Игра рядом».</string> <string name="mesh_permission_text">Чтобы находить игроков рядом и играть с ними без интернета, приложению нужен доступ к Bluetooth. Поиск идёт, только пока открыт экран «Игра рядом».</string>
<string name="permissions_card_title">Разрешения</string> <string name="permissions_card_title">Разрешения</string>
<string name="diag_last_reason">Последняя ошибка связи: %1$s</string>
<string name="diag_copy_log">Скопировать журнал связи</string>
<string name="trust_impersonation">Этот игрок выдаёт себя за другого — данные не приняты</string> <string name="trust_impersonation">Этот игрок выдаёт себя за другого — данные не приняты</string>
<string name="trust_unverified">Личность соперника не подтверждена (у него старая версия приложения)</string> <string name="trust_unverified">Личность соперника не подтверждена</string>
<string name="trust_outdated">У соперника устаревшая версия приложения — безопасная игра невозможна. Обновите приложение у обоих.</string>
<string name="perm_grant">Разрешить</string> <string name="perm_grant">Разрешить</string>
<string name="perm_nearby_title">Связь с устройствами рядом</string> <string name="perm_nearby_title">Связь с устройствами рядом</string>
<string name="perm_nearby_text">Нужна, чтобы находить игроков поблизости и играть без интернета.</string> <string name="perm_nearby_text">Нужна, чтобы находить игроков поблизости и играть без интернета.</string>
@@ -121,8 +116,16 @@
<string name="rating_gate_text">Рейтинг нужен, чтобы подобрать сложность соперника и показать вас другим игрокам. Это займёт пару секунд.</string> <string name="rating_gate_text">Рейтинг нужен, чтобы подобрать сложность соперника и показать вас другим игрокам. Это займёт пару секунд.</string>
<string name="rating_gate_open">Указать уровень</string> <string name="rating_gate_open">Указать уровень</string>
<string name="about_section">О программе</string> <string name="about_section">О программе</string>
<string name="appearance_title">Внешний вид доски</string> <string name="appearance_title">Оформление</string>
<string name="appearance_subtitle">Цвета доски, координаты, вид фигур</string> <string name="appearance_subtitle">Цвета приложения, доска, фигуры</string>
<string name="app_style_title">Цвета приложения</string>
<string name="app_style_matewave">Matewave</string>
<string name="app_style_lavender">Лаванда</string>
<string name="app_style_peach">Персик</string>
<string name="app_style_mint">Мята</string>
<string name="app_style_sky">Небо</string>
<string name="app_style_device">Устройство</string>
<string name="app_style_device_hint">Цвета берутся из обоев (Material You) и меняются вместе с ними.</string>
<string name="appearance_board_theme">Цвета доски</string> <string name="appearance_board_theme">Цвета доски</string>
<string name="appearance_coordinates">Буквы и цифры на доске</string> <string name="appearance_coordinates">Буквы и цифры на доске</string>
<string name="appearance_coordinates_hint">Подписи полей по краям: a–h и 1–8</string> <string name="appearance_coordinates_hint">Подписи полей по краям: a–h и 1–8</string>
@@ -136,7 +139,6 @@
<string name="account_forget_keys_confirm">Вы перестанете отличать знакомого соперника от того, кто назвался его именем, пока не встретитесь с ним заново. Нужно, если соперник переустановил приложение.</string> <string name="account_forget_keys_confirm">Вы перестанете отличать знакомого соперника от того, кто назвался его именем, пока не встретитесь с ним заново. Нужно, если соперник переустановил приложение.</string>
<string name="account_confirm">Забыть</string> <string name="account_confirm">Забыть</string>
<string name="account_cancel">Отмена</string> <string name="account_cancel">Отмена</string>
<string name="greeting_ready">Готовы к новой партии?</string>
<string name="account_trusted_keys_hint">Запоминаются автоматически при первой встрече с новым игроком</string> <string name="account_trusted_keys_hint">Запоминаются автоматически при первой встрече с новым игроком</string>
<string name="account_fingerprint_explain">Уникальный отпечаток ключа этого устройства. Соперник может сверить его с вашим при первой встрече.</string> <string name="account_fingerprint_explain">Уникальный отпечаток ключа этого устройства. Соперник может сверить его с вашим при первой встрече.</string>
<string name="friends_online">В сети</string> <string name="friends_online">В сети</string>
@@ -180,6 +182,8 @@
<string name="licenses_group_data">Данные</string> <string name="licenses_group_data">Данные</string>
<string name="licenses_group_radio">Радио</string> <string name="licenses_group_radio">Радио</string>
<string name="licenses_apache_full">Полный текст Apache License 2.0</string> <string name="licenses_apache_full">Полный текст Apache License 2.0</string>
<string name="licenses_ofl_full">Полный текст SIL Open Font License 1.1</string>
<string name="licenses_note_fonts">Шрифты интерфейса: Unbounded для заголовков, Manrope для текста.</string>
<string name="licenses_note_puzzles">Тактические задачи отобраны из открытой базы Lichess. Лицензия CC0 не требует указания авторства — мы благодарим команду Lichess.</string> <string name="licenses_note_puzzles">Тактические задачи отобраны из открытой базы Lichess. Лицензия CC0 не требует указания авторства — мы благодарим команду Lichess.</string>
<string name="licenses_note_swissjazz">Общедоступный интернет-поток SRG SSR: без рекламы и без ведущих, финансируется лицензионными сборами. Права на музыку принадлежат вещателю и правообладателям; приложение только воспроизводит поток и ничего не сохраняет.</string> <string name="licenses_note_swissjazz">Общедоступный интернет-поток SRG SSR: без рекламы и без ведущих, финансируется лицензионными сборами. Права на музыку принадлежат вещателю и правообладателям; приложение только воспроизводит поток и ничего не сохраняет.</string>
<string name="licenses_radio_hint">Джаз-радио в настройках играет только Radio Swiss Jazz; если одна из его официальных ссылок недоступна, приложение берёт другую.</string> <string name="licenses_radio_hint">Джаз-радио в настройках играет только Radio Swiss Jazz; если одна из его официальных ссылок недоступна, приложение берёт другую.</string>
@@ -203,8 +207,8 @@
<string name="share_no_wifi">Сеть Wi-Fi не найдена. Подключитесь к Wi-Fi или включите точку доступа и откройте экран заново.</string> <string name="share_no_wifi">Сеть Wi-Fi не найдена. Подключитесь к Wi-Fi или включите точку доступа и откройте экран заново.</string>
<string name="share_split_warning">Это приложение установлено как набор частей (например, из Google Play), поэтому переданный файл может не установиться на другой телефон.</string> <string name="share_split_warning">Это приложение установлено как набор частей (например, из Google Play), поэтому переданный файл может не установиться на другой телефон.</string>
<string name="share_failed">Не удалось подготовить файл для передачи.</string> <string name="share_failed">Не удалось подготовить файл для передачи.</string>
<string name="perm_vibration_title">Вибрация</string> <string name="settings_vibration">Вибрация</string>
<string name="perm_vibration_text">Короткая вибрация при выборе фигуры, ходе и взятии, двойная — при шахе и в конце партии. Выключите, если она не нужна.</string> <string name="settings_vibration_subtitle">Ход, взятие и шах</string>
<string name="appearance_last_move">Подсвечивать последний ход</string> <string name="appearance_last_move">Подсвечивать последний ход</string>
<string name="appearance_last_move_hint">Закрашивает клетки, с которой и на которую сделан последний ход</string> <string name="appearance_last_move_hint">Закрашивает клетки, с которой и на которую сделан последний ход</string>
<string name="appearance_check">Подсвечивать шах</string> <string name="appearance_check">Подсвечивать шах</string>
@@ -221,15 +225,6 @@
<string name="reason_remote_disconnected">Соперник отключился</string> <string name="reason_remote_disconnected">Соперник отключился</string>
<string name="reason_port_busy">Не удалось открыть порт</string> <string name="reason_port_busy">Не удалось открыть порт</string>
<string name="reason_unknown">Неизвестная ошибка связи</string> <string name="reason_unknown">Неизвестная ошибка связи</string>
<string name="metrics_connect_attempts">Попыток подключения: %1$d, успешных: %2$d</string>
<string name="metrics_last_connect">Последнее подключение заняло: %1$d мс</string>
<string name="metrics_chunks">Частей отправлено: %1$d, повторно: %2$d (%3$d%%)</string>
<string name="metrics_duplicates">Повторных частей принято: %1$d</string>
<string name="metrics_corrupted">Повреждённых сообщений: %1$d</string>
<string name="metrics_dropped">Сообщений потеряно: %1$d</string>
<string name="diag_report_counters">=== Счётчики сети ===</string>
<string name="diag_report_events">=== События ===</string>
<string name="diag_log_empty">журнал пуст</string>
<string name="nearby_player_default">Игрок поблизости</string> <string name="nearby_player_default">Игрок поблизости</string>
<string name="player_default_name">Игрок</string> <string name="player_default_name">Игрок</string>
<string name="time_no_limit">Без контроля времени</string> <string name="time_no_limit">Без контроля времени</string>
@@ -327,6 +322,10 @@
<string name="study_start_button">Начать</string> <string name="study_start_button">Начать</string>
<string name="study_locked_short">Закрыт</string> <string name="study_locked_short">Закрыт</string>
<string name="home_today">Сегодня</string> <string name="home_today">Сегодня</string>
<string name="home_hero">Играй</string>
<string name="stat_games">Партии</string>
<string name="stat_wins">Победы</string>
<string name="stat_streak">Серия</string>
<string name="home_continue_details">Ход %1$d · %2$s</string> <string name="home_continue_details">Ход %1$d · %2$s</string>
<string name="home_your_move">ваш ход</string> <string name="home_your_move">ваш ход</string>
<string name="home_ai_move">ход ИИ</string> <string name="home_ai_move">ход ИИ</string>
@@ -337,7 +336,6 @@
<string name="settings_section_system">Система</string> <string name="settings_section_system">Система</string>
<string name="permissions_card_ok_short">Всё готово</string> <string name="permissions_card_ok_short">Всё готово</string>
<string name="permissions_card_blocked_short">Нужно действие</string> <string name="permissions_card_blocked_short">Нужно действие</string>
<string name="account_header_summary">Рейтинг %1$d · Партий: %2$d</string>
<string name="account_progress">Прогресс</string> <string name="account_progress">Прогресс</string>
<string name="account_rating_row">Рейтинг</string> <string name="account_rating_row">Рейтинг</string>
<string name="account_device_key">Ключ устройства</string> <string name="account_device_key">Ключ устройства</string>
@@ -380,12 +378,12 @@
<string name="spectate_lost_text">Устройство, на котором идёт партия, больше недоступно.</string> <string name="spectate_lost_text">Устройство, на котором идёт партия, больше недоступно.</string>
<string name="spectate_full_title">Мест нет</string> <string name="spectate_full_title">Мест нет</string>
<string name="spectate_full_text">У этой партии уже максимум зрителей (%1$d). Попробуйте позже.</string> <string name="spectate_full_text">У этой партии уже максимум зрителей (%1$d). Попробуйте позже.</string>
<string name="spectate_update_title">Требуется обновление</string>
<string name="spectate_update_this">Обновите Matewave, чтобы смотреть эту партию.</string>
<string name="spectate_update_host">Игроку, который проводит эту партию, нужно обновить Matewave, чтобы её можно было смотреть.</string>
<string name="spectate_failed_title">Не удаётся посмотреть партию</string> <string name="spectate_failed_title">Не удаётся посмотреть партию</string>
<string name="spectate_no_game">Эта партия больше недоступна.</string> <string name="spectate_no_game">Эта партия больше недоступна.</string>
<string name="spectate_unreachable">Устройство, на котором идёт партия, недоступно. Убедитесь, что вы подключены к той же сети Wi-Fi.</string> <string name="spectate_unreachable">Устройство, на котором идёт партия, недоступно. Убедитесь, что вы подключены к той же сети Wi-Fi.</string>
<string name="spectate_left_win">%1$s покинули партию. Победили %2$s.</string> <string name="spectate_left_win">%1$s покинули партию. Победили %2$s.</string>
<string name="spectate_interrupted">Партия прервана: игроки потеряли связь.</string> <string name="spectate_interrupted">Партия прервана: игроки потеряли связь.</string>
<string name="support_title">Поддержать Matewave</string>
<string name="support_text">Бесплатно, с открытым кодом и без рекламы. Небольшое пожертвование помогает проекту развиваться.</string>
<string name="support_button">Пожертвовать через Ko-fi</string>
</resources> </resources>
+22 -24
View File
@@ -7,13 +7,11 @@
<string name="greeting_night">晚安</string> <string name="greeting_night">晚安</string>
<string name="continue_game_title">继续对局</string> <string name="continue_game_title">继续对局</string>
<string name="quick_game_title">快速对局</string> <string name="quick_game_title">快速对局</string>
<string name="quick_game_subtitle">与上次相同:%1$s · %2$s</string>
<string name="mode_ai_title">对战 AI</string> <string name="mode_ai_title">对战 AI</string>
<string name="mode_ai_subtitle">选择难度</string> <string name="mode_ai_subtitle">选择难度</string>
<string name="mode_online_title">好友对战</string> <string name="mode_online_title">好友对战</string>
<string name="mode_online_subtitle">通过蓝牙或附近的 Wi-Fi</string> <string name="mode_online_subtitle">通过蓝牙或附近的 Wi-Fi</string>
<string name="puzzles_title">国际象棋谜题</string> <string name="puzzles_title">国际象棋谜题</string>
<string name="puzzles_subtitle">按你的等级分挑选的谜题</string>
<string name="stats_dialog_title">统计</string> <string name="stats_dialog_title">统计</string>
<string name="stats_dialog_summary">%1$d 胜 · %2$d%% · 连胜:%3$d</string> <string name="stats_dialog_summary">%1$d 胜 · %2$d%% · 连胜:%3$d</string>
<string name="stats_min">最低:%1$d</string> <string name="stats_min">最低:%1$d</string>
@@ -104,11 +102,8 @@
<string name="mesh_permission_title">附近对战所需的权限</string> <string name="mesh_permission_title">附近对战所需的权限</string>
<string name="mesh_permission_text">要查找附近的玩家并在无网络时与他们对战,应用需要蓝牙权限。仅在“附近对战”页面打开时进行搜索。</string> <string name="mesh_permission_text">要查找附近的玩家并在无网络时与他们对战,应用需要蓝牙权限。仅在“附近对战”页面打开时进行搜索。</string>
<string name="permissions_card_title">权限</string> <string name="permissions_card_title">权限</string>
<string name="diag_last_reason">最近一次连接错误:%1$s</string>
<string name="diag_copy_log">复制连接日志</string>
<string name="trust_impersonation">该玩家冒充他人 — 数据已拒绝</string> <string name="trust_impersonation">该玩家冒充他人 — 数据已拒绝</string>
<string name="trust_unverified">对手身份未验证(对方使用的是旧版应用)</string> <string name="trust_unverified">对手身份未验证</string>
<string name="trust_outdated">对手的应用版本过旧,无法安全对局。请双方都更新应用。</string>
<string name="perm_grant">允许</string> <string name="perm_grant">允许</string>
<string name="perm_nearby_title">与附近设备通信</string> <string name="perm_nearby_title">与附近设备通信</string>
<string name="perm_nearby_text">用于发现附近的玩家并在无网络时对战。</string> <string name="perm_nearby_text">用于发现附近的玩家并在无网络时对战。</string>
@@ -116,8 +111,16 @@
<string name="rating_gate_text">需要等级分来匹配合适的对手,并向其他玩家展示你。只需几秒钟。</string> <string name="rating_gate_text">需要等级分来匹配合适的对手,并向其他玩家展示你。只需几秒钟。</string>
<string name="rating_gate_open">设置水平</string> <string name="rating_gate_open">设置水平</string>
<string name="about_section">关于</string> <string name="about_section">关于</string>
<string name="appearance_title">棋盘外观</string> <string name="appearance_title">外观</string>
<string name="appearance_subtitle">棋盘颜色、坐标、棋子样式</string> <string name="appearance_subtitle">应用配色、棋盘、棋子</string>
<string name="app_style_title">应用配色</string>
<string name="app_style_matewave">Matewave</string>
<string name="app_style_lavender">薰衣草</string>
<string name="app_style_peach">蜜桃</string>
<string name="app_style_mint">薄荷</string>
<string name="app_style_sky">天空</string>
<string name="app_style_device">设备</string>
<string name="app_style_device_hint">颜色取自壁纸(Material You),并随壁纸变化。</string>
<string name="appearance_board_theme">棋盘颜色</string> <string name="appearance_board_theme">棋盘颜色</string>
<string name="appearance_coordinates">棋盘上的字母和数字</string> <string name="appearance_coordinates">棋盘上的字母和数字</string>
<string name="appearance_coordinates_hint">边缘的格子标注:a–h 和 1–8</string> <string name="appearance_coordinates_hint">边缘的格子标注:a–h 和 1–8</string>
@@ -131,7 +134,6 @@
<string name="account_forget_keys_confirm">在再次见面之前,你将无法区分熟悉的对手和冒用其名字的人。如果对手重装了应用,则需要这样做。</string> <string name="account_forget_keys_confirm">在再次见面之前,你将无法区分熟悉的对手和冒用其名字的人。如果对手重装了应用,则需要这样做。</string>
<string name="account_confirm">忘记</string> <string name="account_confirm">忘记</string>
<string name="account_cancel">取消</string> <string name="account_cancel">取消</string>
<string name="greeting_ready">准备好开始新对局了吗?</string>
<string name="account_trusted_keys_hint">首次遇到新玩家时自动保存</string> <string name="account_trusted_keys_hint">首次遇到新玩家时自动保存</string>
<string name="account_fingerprint_explain">此设备密钥的唯一指纹。首次见面时,对手可以将其与你的核对。</string> <string name="account_fingerprint_explain">此设备密钥的唯一指纹。首次见面时,对手可以将其与你的核对。</string>
<string name="friends_online">在线</string> <string name="friends_online">在线</string>
@@ -174,6 +176,8 @@
<string name="licenses_group_data">数据</string> <string name="licenses_group_data">数据</string>
<string name="licenses_group_radio">电台</string> <string name="licenses_group_radio">电台</string>
<string name="licenses_apache_full">Apache License 2.0 全文</string> <string name="licenses_apache_full">Apache License 2.0 全文</string>
<string name="licenses_ofl_full">SIL Open Font License 1.1 全文</string>
<string name="licenses_note_fonts">界面字体:标题使用 Unbounded,正文使用 Manrope。</string>
<string name="licenses_note_puzzles">题目选自 Lichess 开放的谜题数据库。CC0 许可证无需署名,在此感谢 Lichess 团队。</string> <string name="licenses_note_puzzles">题目选自 Lichess 开放的谜题数据库。CC0 许可证无需署名,在此感谢 Lichess 团队。</string>
<string name="licenses_note_swissjazz">SRG SSR 公开提供的网络电台流:无广告、无主持人,由收视费资助。音乐版权归电台和权利人所有,应用只播放,不保存任何内容。</string> <string name="licenses_note_swissjazz">SRG SSR 公开提供的网络电台流:无广告、无主持人,由收视费资助。音乐版权归电台和权利人所有,应用只播放,不保存任何内容。</string>
<string name="licenses_radio_hint">设置中的爵士电台只播放 Radio Swiss Jazz;其中一个官方地址不可用时,应用会改用另一个。</string> <string name="licenses_radio_hint">设置中的爵士电台只播放 Radio Swiss Jazz;其中一个官方地址不可用时,应用会改用另一个。</string>
@@ -197,8 +201,8 @@
<string name="share_no_wifi">未找到 Wi-Fi 网络。请连接 Wi-Fi 或开启热点,然后重新打开此页面。</string> <string name="share_no_wifi">未找到 Wi-Fi 网络。请连接 Wi-Fi 或开启热点,然后重新打开此页面。</string>
<string name="share_split_warning">此应用是以拆分包形式安装的(例如来自 Google Play),因此分享的文件可能无法在另一部手机上安装。</string> <string name="share_split_warning">此应用是以拆分包形式安装的(例如来自 Google Play),因此分享的文件可能无法在另一部手机上安装。</string>
<string name="share_failed">无法准备要分享的文件。</string> <string name="share_failed">无法准备要分享的文件。</string>
<string name="perm_vibration_title">振动</string> <string name="settings_vibration">振动</string>
<string name="perm_vibration_text">选子、走子和吃子时短振一下,将军或对局结束时振动两下。如不需要,可以关闭。</string> <string name="settings_vibration_subtitle">走子、吃子和将军</string>
<string name="appearance_last_move">高亮上一步</string> <string name="appearance_last_move">高亮上一步</string>
<string name="appearance_last_move_hint">为上一步走出和落下的格子上色</string> <string name="appearance_last_move_hint">为上一步走出和落下的格子上色</string>
<string name="appearance_check">高亮将军</string> <string name="appearance_check">高亮将军</string>
@@ -215,15 +219,6 @@
<string name="reason_remote_disconnected">对手已断开连接</string> <string name="reason_remote_disconnected">对手已断开连接</string>
<string name="reason_port_busy">无法打开端口</string> <string name="reason_port_busy">无法打开端口</string>
<string name="reason_unknown">未知连接错误</string> <string name="reason_unknown">未知连接错误</string>
<string name="metrics_connect_attempts">连接尝试:%1$d 次,成功:%2$d 次</string>
<string name="metrics_last_connect">上次连接用时:%1$d 毫秒</string>
<string name="metrics_chunks">已发送分片:%1$d,重发:%2$d(%3$d%%)</string>
<string name="metrics_duplicates">收到重复分片:%1$d</string>
<string name="metrics_corrupted">损坏的消息:%1$d</string>
<string name="metrics_dropped">丢失的消息:%1$d</string>
<string name="diag_report_counters">=== 网络计数 ===</string>
<string name="diag_report_events">=== 事件 ===</string>
<string name="diag_log_empty">日志为空</string>
<string name="nearby_player_default">附近的玩家</string> <string name="nearby_player_default">附近的玩家</string>
<string name="player_default_name">玩家</string> <string name="player_default_name">玩家</string>
<string name="time_no_limit">无时间限制</string> <string name="time_no_limit">无时间限制</string>
@@ -318,6 +313,10 @@
<string name="study_start_button">开始</string> <string name="study_start_button">开始</string>
<string name="study_locked_short">已锁定</string> <string name="study_locked_short">已锁定</string>
<string name="home_today">今日</string> <string name="home_today">今日</string>
<string name="home_hero">开局吧</string>
<string name="stat_games">对局</string>
<string name="stat_wins">胜局</string>
<string name="stat_streak">连胜</string>
<string name="home_continue_details">第 %1$d 步 · %2$s</string> <string name="home_continue_details">第 %1$d 步 · %2$s</string>
<string name="home_your_move">轮到你</string> <string name="home_your_move">轮到你</string>
<string name="home_ai_move">AI 走棋</string> <string name="home_ai_move">AI 走棋</string>
@@ -328,7 +327,6 @@
<string name="settings_section_system">系统</string> <string name="settings_section_system">系统</string>
<string name="permissions_card_ok_short">已就绪</string> <string name="permissions_card_ok_short">已就绪</string>
<string name="permissions_card_blocked_short">需要处理</string> <string name="permissions_card_blocked_short">需要处理</string>
<string name="account_header_summary">等级分 %1$d · 对局:%2$d</string>
<string name="account_progress">进度</string> <string name="account_progress">进度</string>
<string name="account_rating_row">等级分</string> <string name="account_rating_row">等级分</string>
<string name="account_device_key">设备密钥</string> <string name="account_device_key">设备密钥</string>
@@ -371,12 +369,12 @@
<string name="spectate_lost_text">无法再连接到主持对局的设备。</string> <string name="spectate_lost_text">无法再连接到主持对局的设备。</string>
<string name="spectate_full_title">观战人数已满</string> <string name="spectate_full_title">观战人数已满</string>
<string name="spectate_full_text">此对局的观战人数已达上限(%1$d 人),请稍后再试。</string> <string name="spectate_full_text">此对局的观战人数已达上限(%1$d 人),请稍后再试。</string>
<string name="spectate_update_title">需要更新</string>
<string name="spectate_update_this">请更新 Matewave 以观看此对局。</string>
<string name="spectate_update_host">主持此对局的玩家需要更新 Matewave 后才能观战。</string>
<string name="spectate_failed_title">无法观看此对局</string> <string name="spectate_failed_title">无法观看此对局</string>
<string name="spectate_no_game">此对局已不可观看。</string> <string name="spectate_no_game">此对局已不可观看。</string>
<string name="spectate_unreachable">无法连接到主持对局的设备。请确认你们连接的是同一个 Wi-Fi 网络。</string> <string name="spectate_unreachable">无法连接到主持对局的设备。请确认你们连接的是同一个 Wi-Fi 网络。</string>
<string name="spectate_left_win">%1$s离开了对局,%2$s获胜。</string> <string name="spectate_left_win">%1$s离开了对局,%2$s获胜。</string>
<string name="spectate_interrupted">对局中断:玩家之间的连接已断开。</string> <string name="spectate_interrupted">对局中断:玩家之间的连接已断开。</string>
<string name="support_title">支持 Matewave</string>
<string name="support_text">免费、开源、无广告。一笔小小的捐助能让项目持续下去。</string>
<string name="support_button">通过 Ko-fi 捐助</string>
</resources> </resources>
+22 -24
View File
@@ -7,13 +7,11 @@
<string name="greeting_night">Good night</string> <string name="greeting_night">Good night</string>
<string name="continue_game_title">Continue game</string> <string name="continue_game_title">Continue game</string>
<string name="quick_game_title">Quick game</string> <string name="quick_game_title">Quick game</string>
<string name="quick_game_subtitle">Same as last time: %1$s · %2$s</string>
<string name="mode_ai_title">Vs AI</string> <string name="mode_ai_title">Vs AI</string>
<string name="mode_ai_subtitle">Choose difficulty</string> <string name="mode_ai_subtitle">Choose difficulty</string>
<string name="mode_online_title">Vs a friend</string> <string name="mode_online_title">Vs a friend</string>
<string name="mode_online_subtitle">Over Bluetooth or Wi-Fi nearby</string> <string name="mode_online_subtitle">Over Bluetooth or Wi-Fi nearby</string>
<string name="puzzles_title">Chess puzzles</string> <string name="puzzles_title">Chess puzzles</string>
<string name="puzzles_subtitle">Puzzles picked for your rating</string>
<string name="stats_dialog_title">Statistics</string> <string name="stats_dialog_title">Statistics</string>
<string name="stats_dialog_summary">%1$d wins · %2$d%% · streak: %3$d</string> <string name="stats_dialog_summary">%1$d wins · %2$d%% · streak: %3$d</string>
<string name="stats_min">Min: %1$d</string> <string name="stats_min">Min: %1$d</string>
@@ -104,11 +102,8 @@
<string name="mesh_permission_title">Permissions for nearby play</string> <string name="mesh_permission_title">Permissions for nearby play</string>
<string name="mesh_permission_text">To find players nearby and play with them without the internet, the app needs Bluetooth access. Searching runs only while the nearby play screen is open.</string> <string name="mesh_permission_text">To find players nearby and play with them without the internet, the app needs Bluetooth access. Searching runs only while the nearby play screen is open.</string>
<string name="permissions_card_title">Permissions</string> <string name="permissions_card_title">Permissions</string>
<string name="diag_last_reason">Last connection error: %1$s</string>
<string name="diag_copy_log">Copy connection log</string>
<string name="trust_impersonation">This player is impersonating someone else — data rejected</string> <string name="trust_impersonation">This player is impersonating someone else — data rejected</string>
<string name="trust_unverified">The opponent\'s identity isn\'t verified (they have an old version of the app)</string> <string name="trust_unverified">The opponent\'s identity isn\'t verified</string>
<string name="trust_outdated">The opponent\'s app is outdated and can\'t play securely with yours. Both players need to update.</string>
<string name="perm_grant">Allow</string> <string name="perm_grant">Allow</string>
<string name="perm_nearby_title">Nearby device connection</string> <string name="perm_nearby_title">Nearby device connection</string>
<string name="perm_nearby_text">Needed to find players nearby and play without the internet.</string> <string name="perm_nearby_text">Needed to find players nearby and play without the internet.</string>
@@ -116,8 +111,16 @@
<string name="rating_gate_text">Your rating is needed to pick a suitable opponent and to show you to other players. It takes a couple of seconds.</string> <string name="rating_gate_text">Your rating is needed to pick a suitable opponent and to show you to other players. It takes a couple of seconds.</string>
<string name="rating_gate_open">Set level</string> <string name="rating_gate_open">Set level</string>
<string name="about_section">About</string> <string name="about_section">About</string>
<string name="appearance_title">Board appearance</string> <string name="appearance_title">Appearance</string>
<string name="appearance_subtitle">Board colors, coordinates, piece style</string> <string name="appearance_subtitle">App colors, board, pieces</string>
<string name="app_style_title">App colors</string>
<string name="app_style_matewave">Matewave</string>
<string name="app_style_lavender">Lavender</string>
<string name="app_style_peach">Peach</string>
<string name="app_style_mint">Mint</string>
<string name="app_style_sky">Sky</string>
<string name="app_style_device">Device</string>
<string name="app_style_device_hint">Colors are taken from your wallpaper (Material You) and change with it.</string>
<string name="appearance_board_theme">Board colors</string> <string name="appearance_board_theme">Board colors</string>
<string name="appearance_coordinates">Letters and numbers on the board</string> <string name="appearance_coordinates">Letters and numbers on the board</string>
<string name="appearance_coordinates_hint">Square labels along the edges: a–h and 1–8</string> <string name="appearance_coordinates_hint">Square labels along the edges: a–h and 1–8</string>
@@ -131,7 +134,6 @@
<string name="account_forget_keys_confirm">You will no longer be able to tell a familiar opponent from someone using their name until you meet again. Needed if the opponent reinstalled the app.</string> <string name="account_forget_keys_confirm">You will no longer be able to tell a familiar opponent from someone using their name until you meet again. Needed if the opponent reinstalled the app.</string>
<string name="account_confirm">Forget</string> <string name="account_confirm">Forget</string>
<string name="account_cancel">Cancel</string> <string name="account_cancel">Cancel</string>
<string name="greeting_ready">Ready for a new game?</string>
<string name="account_trusted_keys_hint">Saved automatically the first time you meet a new player</string> <string name="account_trusted_keys_hint">Saved automatically the first time you meet a new player</string>
<string name="account_fingerprint_explain">The unique fingerprint of this device\'s key. Your opponent can compare it with yours when you first meet.</string> <string name="account_fingerprint_explain">The unique fingerprint of this device\'s key. Your opponent can compare it with yours when you first meet.</string>
<string name="friends_online">Online</string> <string name="friends_online">Online</string>
@@ -174,6 +176,8 @@
<string name="licenses_group_data">Data</string> <string name="licenses_group_data">Data</string>
<string name="licenses_group_radio">Radio</string> <string name="licenses_group_radio">Radio</string>
<string name="licenses_apache_full">Full text of the Apache License 2.0</string> <string name="licenses_apache_full">Full text of the Apache License 2.0</string>
<string name="licenses_ofl_full">Full text of the SIL Open Font License 1.1</string>
<string name="licenses_note_fonts">Typeface of the interface: Unbounded for headings, Manrope for text.</string>
<string name="licenses_note_puzzles">Puzzles are selected from the open Lichess puzzle database. The CC0 license does not require attribution — we thank the Lichess team.</string> <string name="licenses_note_puzzles">Puzzles are selected from the open Lichess puzzle database. The CC0 license does not require attribution — we thank the Lichess team.</string>
<string name="licenses_note_swissjazz">Publicly available internet stream from SRG SSR: no advertising and no presenters, funded by license fees. The music belongs to the broadcaster and rights holders; the app only plays the stream and stores nothing.</string> <string name="licenses_note_swissjazz">Publicly available internet stream from SRG SSR: no advertising and no presenters, funded by license fees. The music belongs to the broadcaster and rights holders; the app only plays the stream and stores nothing.</string>
<string name="licenses_radio_hint">The jazz radio in Settings plays only Radio Swiss Jazz; if one of its official stream links is unavailable, the app uses another.</string> <string name="licenses_radio_hint">The jazz radio in Settings plays only Radio Swiss Jazz; if one of its official stream links is unavailable, the app uses another.</string>
@@ -197,8 +201,8 @@
<string name="share_no_wifi">No Wi-Fi network found. Connect to Wi-Fi or turn on a hotspot, then reopen this screen.</string> <string name="share_no_wifi">No Wi-Fi network found. Connect to Wi-Fi or turn on a hotspot, then reopen this screen.</string>
<string name="share_split_warning">This copy was installed as a split bundle (for example, from Google Play), so the shared file may not install on another phone.</string> <string name="share_split_warning">This copy was installed as a split bundle (for example, from Google Play), so the shared file may not install on another phone.</string>
<string name="share_failed">Couldn\'t prepare the file for sharing.</string> <string name="share_failed">Couldn\'t prepare the file for sharing.</string>
<string name="perm_vibration_title">Vibration</string> <string name="settings_vibration">Vibration</string>
<string name="perm_vibration_text">A short vibration when you select a piece, move or capture, and a double one on check or when the game ends. Turn it off if you don\'t want it.</string> <string name="settings_vibration_subtitle">Moves, captures and check</string>
<string name="appearance_last_move">Highlight the last move</string> <string name="appearance_last_move">Highlight the last move</string>
<string name="appearance_last_move_hint">Colors the squares the last move was played from and to</string> <string name="appearance_last_move_hint">Colors the squares the last move was played from and to</string>
<string name="appearance_check">Highlight check</string> <string name="appearance_check">Highlight check</string>
@@ -215,15 +219,6 @@
<string name="reason_remote_disconnected">The opponent disconnected</string> <string name="reason_remote_disconnected">The opponent disconnected</string>
<string name="reason_port_busy">Couldn\'t open a port</string> <string name="reason_port_busy">Couldn\'t open a port</string>
<string name="reason_unknown">Unknown connection error</string> <string name="reason_unknown">Unknown connection error</string>
<string name="metrics_connect_attempts">Connection attempts: %1$d, successful: %2$d</string>
<string name="metrics_last_connect">Last connection took: %1$d ms</string>
<string name="metrics_chunks">Parts sent: %1$d, resent: %2$d (%3$d%%)</string>
<string name="metrics_duplicates">Duplicate parts received: %1$d</string>
<string name="metrics_corrupted">Corrupted messages: %1$d</string>
<string name="metrics_dropped">Messages lost: %1$d</string>
<string name="diag_report_counters">=== Network counters ===</string>
<string name="diag_report_events">=== Events ===</string>
<string name="diag_log_empty">log is empty</string>
<string name="nearby_player_default">Nearby player</string> <string name="nearby_player_default">Nearby player</string>
<string name="player_default_name">Player</string> <string name="player_default_name">Player</string>
<string name="time_no_limit">No time limit</string> <string name="time_no_limit">No time limit</string>
@@ -319,6 +314,10 @@
<string name="study_start_button">Start</string> <string name="study_start_button">Start</string>
<string name="study_locked_short">Locked</string> <string name="study_locked_short">Locked</string>
<string name="home_today">Today</string> <string name="home_today">Today</string>
<string name="home_hero">Play it</string>
<string name="stat_games">Games</string>
<string name="stat_wins">Wins</string>
<string name="stat_streak">Streak</string>
<string name="home_continue_details">Move %1$d · %2$s</string> <string name="home_continue_details">Move %1$d · %2$s</string>
<string name="home_your_move">your move</string> <string name="home_your_move">your move</string>
<string name="home_ai_move">AI to move</string> <string name="home_ai_move">AI to move</string>
@@ -329,7 +328,6 @@
<string name="settings_section_system">System</string> <string name="settings_section_system">System</string>
<string name="permissions_card_ok_short">All set</string> <string name="permissions_card_ok_short">All set</string>
<string name="permissions_card_blocked_short">Action needed</string> <string name="permissions_card_blocked_short">Action needed</string>
<string name="account_header_summary">Rating %1$d · Games: %2$d</string>
<string name="account_progress">Progress</string> <string name="account_progress">Progress</string>
<string name="account_rating_row">Rating</string> <string name="account_rating_row">Rating</string>
<string name="account_device_key">Device key</string> <string name="account_device_key">Device key</string>
@@ -372,12 +370,12 @@
<string name="spectate_lost_text">The host\'s device can no longer be reached.</string> <string name="spectate_lost_text">The host\'s device can no longer be reached.</string>
<string name="spectate_full_title">Game is full</string> <string name="spectate_full_title">Game is full</string>
<string name="spectate_full_text">This game already has the maximum of %1$d spectators. Try again later.</string> <string name="spectate_full_text">This game already has the maximum of %1$d spectators. Try again later.</string>
<string name="spectate_update_title">Update required</string>
<string name="spectate_update_this">Update Matewave to watch this game.</string>
<string name="spectate_update_host">The player hosting this game needs to update Matewave before it can be watched.</string>
<string name="spectate_failed_title">Can\'t watch this game</string> <string name="spectate_failed_title">Can\'t watch this game</string>
<string name="spectate_no_game">This game is no longer available.</string> <string name="spectate_no_game">This game is no longer available.</string>
<string name="spectate_unreachable">The host\'s device can\'t be reached. Make sure you\'re on the same Wi-Fi network.</string> <string name="spectate_unreachable">The host\'s device can\'t be reached. Make sure you\'re on the same Wi-Fi network.</string>
<string name="spectate_left_win">%1$s left the game. %2$s wins.</string> <string name="spectate_left_win">%1$s left the game. %2$s wins.</string>
<string name="spectate_interrupted">Game interrupted: the players lost their connection.</string> <string name="spectate_interrupted">Game interrupted: the players lost their connection.</string>
<string name="support_title">Support Matewave</string>
<string name="support_text">Free, open source and no ads. A small donation helps keep it going.</string>
<string name="support_button">Donate on Ko-fi</string>
</resources> </resources>
+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>
@@ -0,0 +1,55 @@
package cc.skysparkle.matewave
import cc.skysparkle.matewave.network.GameMessage
import cc.skysparkle.matewave.network.PeerLimits
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class PeerLimitsTest {
private fun profile(
userId: String = "6f1c2a9e-0b3d-4c5e-8f70-1a2b3c4d5e6f",
name: String = "Vladimir",
elo: Int = 1350,
initialSeconds: Int = 300,
incrementSeconds: Int = 3
) = GameMessage.ProfileMsg(
userId = userId, name = name, avatarBase64 = null, backgroundBase64 = null, elo = elo,
initialSeconds = initialSeconds, incrementSeconds = incrementSeconds
)
@Test fun ordinaryProfileIsAccepted() = assertTrue(PeerLimits.isPlausibleProfile(profile()))
@Test fun joiningPlayerWithoutTimeControlIsAccepted() =
assertTrue(PeerLimits.isPlausibleProfile(profile(initialSeconds = 0, incrementSeconds = 0)))
@Test fun unlimitedGameIsAccepted() =
assertTrue(PeerLimits.isPlausibleProfile(profile(initialSeconds = Int.MAX_VALUE, incrementSeconds = 0)))
@Test
fun oversizedOrEmptyFieldsAreRefused() {
assertFalse(PeerLimits.isPlausibleProfile(profile(name = "x".repeat(PeerLimits.MAX_NAME_CHARS + 1))))
assertFalse(PeerLimits.isPlausibleProfile(profile(name = " ")))
assertFalse(PeerLimits.isPlausibleProfile(profile(name = "a\u0000b")))
assertFalse(PeerLimits.isPlausibleProfile(profile(userId = "u".repeat(PeerLimits.MAX_USER_ID_CHARS + 1))))
assertFalse(PeerLimits.isPlausibleProfile(profile(userId = "")))
}
@Test
fun ratingAndTimeControlMustBeInRange() {
assertFalse(PeerLimits.isPlausibleProfile(profile(elo = 99)))
assertFalse(PeerLimits.isPlausibleProfile(profile(elo = 3001)))
assertFalse(PeerLimits.isPlausibleProfile(profile(initialSeconds = -1)))
assertFalse(PeerLimits.isPlausibleProfile(profile(initialSeconds = PeerLimits.MAX_INITIAL_SECONDS + 1)))
assertFalse(PeerLimits.isPlausibleProfile(profile(incrementSeconds = PeerLimits.MAX_INCREMENT_SECONDS + 1)))
}
@Test
fun opponentClockMayNotGrowBeyondIncrementAndSlack() {
assertEquals(47_000L, PeerLimits.maxOpponentClockAfterMove(42_000, 3_000, 2_000))
// A flagged opponent (0 ms locally) may still have had a little time on their side.
assertEquals(5_000L, PeerLimits.maxOpponentClockAfterMove(0, 3_000, 2_000))
assertEquals(2_000L, PeerLimits.maxOpponentClockAfterMove(-50, 0, 2_000))
}
}
@@ -0,0 +1,31 @@
package cc.skysparkle.matewave
import cc.skysparkle.matewave.network.LanTransport
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertTrue
import org.junit.Test
class PresenceSignatureTest {
private val now = 1_800_000_000_000L
private val nowSeconds = now / 1000
@Test fun recentAnnouncementIsFresh() =
assertTrue(LanTransport.isFreshPresence(nowSeconds - 4 * 60, now))
@Test fun slightlyFastClockIsTolerated() =
assertTrue(LanTransport.isFreshPresence(nowSeconds + 5 * 60, now))
@Test
fun oldMissingOrFarFutureAnnouncementsAreRejected() {
assertFalse(LanTransport.isFreshPresence(nowSeconds - 16 * 60, now))
assertFalse(LanTransport.isFreshPresence(nowSeconds + 16 * 60, now))
assertFalse(LanTransport.isFreshPresence(0, now))
}
@Test
fun signingTimeIsPartOfTheSignedText() = assertNotEquals(
LanTransport.presencePayload("u1", "Vladimir", 1350, nowSeconds),
LanTransport.presencePayload("u1", "Vladimir", 1350, nowSeconds - 60)
)
}
@@ -2,7 +2,6 @@ package cc.skysparkle.matewave
import cc.skysparkle.matewave.engine.PieceColor import cc.skysparkle.matewave.engine.PieceColor
import cc.skysparkle.matewave.spectate.MAX_SPECTATORS import cc.skysparkle.matewave.spectate.MAX_SPECTATORS
import cc.skysparkle.matewave.spectate.RejectReason
import cc.skysparkle.matewave.spectate.SpectatorBroadcaster import cc.skysparkle.matewave.spectate.SpectatorBroadcaster
import cc.skysparkle.matewave.spectate.SpectatorClient import cc.skysparkle.matewave.spectate.SpectatorClient
import cc.skysparkle.matewave.spectate.SpectatorClient.Event import cc.skysparkle.matewave.spectate.SpectatorClient.Event
@@ -24,10 +23,8 @@ import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Assert.fail import org.junit.Assert.fail
import org.junit.Test import org.junit.Test
import java.io.BufferedReader
import java.io.Closeable import java.io.Closeable
import java.io.IOException import java.io.IOException
import java.io.InputStreamReader
import java.net.InetAddress import java.net.InetAddress
import java.net.ServerSocket import java.net.ServerSocket
import java.net.Socket import java.net.Socket
@@ -271,35 +268,6 @@ class SpectatorHubTest {
assertTrue("publish took $elapsedMs ms", elapsedMs < 1_000) assertTrue("publish took $elapsedMs ms", elapsedMs < 1_000)
} }
@Test
fun outdatedSpectatorIsToldToUpdate() {
val hub = hub()
val (_, recorder) = watch(hub.port, version = 0, minVersion = 0)
assertEquals(Event.JoinFailed(Failure.UPDATE_THIS_APP), recorder.next())
assertEquals(0, hub.count.value)
}
@Test
fun outdatedHostIsReported() {
val hub = hub()
val newer = SpectatorProtocol.VERSION + 1
val (_, recorder) = watch(hub.port, version = newer, minVersion = newer)
assertEquals(Event.JoinFailed(Failure.UPDATE_HOST_APP), recorder.next())
}
@Test
fun rawOldClientGetsAClearRejectInsteadOfACrash() {
val hub = hub()
Socket(loopback, hub.port).use { s ->
s.soTimeout = 2_000
s.getOutputStream().write("{\"type\":\"hello\",\"sv\":0}\n".toByteArray())
val reply = BufferedReader(InputStreamReader(s.getInputStream())).readLine()
val reject = SpectatorProtocol.decode(reply)!!.message as SpectatorMessage.Reject
assertEquals(RejectReason.UPDATE_REQUIRED, reject.reason)
assertEquals(SpectatorProtocol.MIN_COMPATIBLE_VERSION, reject.minVersion)
}
}
@Test @Test
fun garbageAndOversizedInputCloseOnlyThatConnection() { fun garbageAndOversizedInputCloseOnlyThatConnection() {
val hub = hub() val hub = hub()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 756 KiB

After

Width:  |  Height:  |  Size: 565 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 783 KiB

After

Width:  |  Height:  |  Size: 872 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 KiB

After

Width:  |  Height:  |  Size: 948 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 KiB

After

Width:  |  Height:  |  Size: 773 KiB

+2 -2
View File
@@ -1,4 +1,4 @@
plugins { plugins {
id("com.android.application") version "9.2.0" apply false alias(libs.plugins.android.application) apply false
id("org.jetbrains.kotlin.plugin.compose") version "2.4.20" apply false alias(libs.plugins.kotlin.compose) apply false
} }
@@ -0,0 +1,3 @@
• Darstellung: App-Farben wählbar — Matewave, die Pastelltöne Lavendel, Pfirsich, Minze und Himmel oder Gerätefarben aus dem Hintergrundbild (Material You, Android 12+)
• Die Wertung auf dem Startbildschirm öffnet keine Statistik mehr
• Die Beschriftungen von Remis- und Aufgabe-Schaltfläche werden nicht mehr abgeschnitten
@@ -0,0 +1,6 @@
• Bilder des Gegners werden geprüft: zu große Avatare, Hintergründe oder Chatbilder bringen die App nicht mehr zum Absturz
• Der Gegner kann verbrauchte Zeit nicht verbergen; sein Inkrement zählt nicht mehr doppelt
• Warnung, wenn nicht der gewählte Spieler in der Nähe antwortet
• App-Sprache in den Android-Einstellungen wählbar (Android 13+)
• Schnellerer Start mit vielen Freunden, weniger Akku für Bluetooth
• WLAN-Präsenz ist nicht mit 1.0.50 kompatibel: beide Handys aktualisieren
@@ -0,0 +1,5 @@
• Vibration wird jetzt nur noch an einer Stelle geschaltet: Einstellungen → Ton
• Verbindungsprotokoll und Netzwerkzähler aus dem Bildschirm „Berechtigungen“ entfernt
• Keine Prüfung und Warnungen mehr wegen veralteter App beim Verbinden mit dem Gegner oder Zuschauen bei Freunden
• Symbole für alle Optionen unter „Aussehen des Bretts“
• Matewave gibt es auch auf meinem eigenen Gitea: https://git.skysparkle.cc/kalarina/Matewave
@@ -0,0 +1,6 @@
• Neues Aussehen: dunkles Design mit Neongrün und Limette als Akzente
• Neuer Startbildschirm: große Modus-Karten, „Partie fortsetzen“ direkt daneben, Fortschrittsanzeige mit Wertung, Partien, Siegen und Serie
• Neues Profil: großer Name und Avatar, Statistik-Kacheln und Wertungsdiagramm
• Neue schwebende Navigationsleiste
• Neue Schriften: Unbounded für Überschriften, Manrope für Text
• Spielerkarten und eine Uhr in Limette im Partiebildschirm
@@ -0,0 +1,3 @@
• Appearance: choose the app colors — Matewave, pastel Lavender, Peach, Mint and Sky, or Device colors from your wallpaper (Material You, Android 12+)
• The rating on the home screen no longer opens statistics
• Labels on the draw and resign buttons are no longer cut off
@@ -0,0 +1,6 @@
• Pictures from the opponent are checked first: an oversized avatar, background or chat image no longer crashes the app
• The opponent's clock can't hide time spent; their increment is no longer counted twice
• A warning if someone other than the chosen nearby player answers
• App language can be set in Android settings (Android 13+)
• Faster start with many friends, less battery for Bluetooth presence
• Wi-Fi presence is not compatible with 1.0.50: update both phones
@@ -0,0 +1,5 @@
• Vibration is now switched on and off in one place only: Settings → Sound
• Removed the connection log and network counters from the Permissions screen
• No more outdated-app check and warnings when connecting to an opponent or watching a friend's game
• Icons for every option in Board appearance
• Matewave is also on my own Gitea: https://git.skysparkle.cc/kalarina/Matewave
@@ -0,0 +1,6 @@
• New look: dark theme with neon green and lime accents
• Redesigned home screen: big mode cards, Continue game right next to them, progress panel with rating, games, wins and streak
• Redesigned profile: large name and avatar, stat tiles and rating chart
• New floating bottom bar
• New fonts: Unbounded for headings, Manrope for text
• Player cards and a lime clock on the game screen
Binary file not shown.

After

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 756 KiB

After

Width:  |  Height:  |  Size: 565 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 783 KiB

After

Width:  |  Height:  |  Size: 872 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 KiB

After

Width:  |  Height:  |  Size: 948 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 KiB

After

Width:  |  Height:  |  Size: 773 KiB

@@ -0,0 +1,3 @@
• 外観:アプリの色を選択可能に — Matewave、パステルのラベンダー・ピーチ・ミント・スカイ、または壁紙から取得する端末の色(Material You、Android 12 以降)
• ホーム画面のレーティングをタップしても統計が開かなくなりました
• 引き分け・投了ボタンの文字が切れにくくなりました
@@ -0,0 +1,6 @@
• 相手の画像を事前に確認:巨大なアバター、背景、チャット画像でアプリが落ちなくなりました
• 相手が消費時間を隠せなくなり、相手の加算時間が二重に数えられなくなりました
• 近くで選んだ相手以外が応答したときに警告
• Android の設定でアプリの言語を選択可能に(Android 13 以降)
• 友達が多くても起動が速く、Bluetooth の電池消費も減少
• Wi-Fi の在席表示は 1.0.50 と互換性がありません:両方の端末を更新してください
@@ -0,0 +1,5 @@
• バイブレーションの設定は「設定 → サウンド」の一か所だけになりました
• 「権限」画面から接続ログとネットワークカウンターを削除
• 対戦相手への接続時や友達の対局観戦時の、アプリが古いかどうかのチェックと警告を削除
• 「盤の見た目」のすべての項目にアイコンを追加
• Matewave は私の Gitea でも公開しています: https://git.skysparkle.cc/kalarina/Matewave
@@ -0,0 +1,6 @@
• 新しいデザイン:ネオングリーンとライムを差し色にしたダークテーマ
• ホーム画面を刷新:大きなモードカード、そのすぐ横に「対局を再開」、レーティング・対局数・勝利・連勝を表示する進捗パネル
• プロフィールを刷新:大きな名前とアバター、統計タイル、レーティンググラフ
• 新しいフローティングナビゲーションバー
• 新しいフォント:見出しは Unbounded、本文は Manrope
• 対局画面にプレイヤーカードとライム色の時計
@@ -0,0 +1,3 @@
• Išvaizda: galima pasirinkti programėlės spalvas — Matewave, pastelines Levandą, Persiką, Mėtą ir Dangų arba įrenginio spalvas iš ekrano fono („Material You“, Android 12+)
• Reitingas pagrindiniame ekrane nebeatidaro statistikos
• Lygiųjų ir pasidavimo mygtukų užrašai nebenukerpami

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