Android: design review fixes, icon, signed releases, the site's Android downloads
- The design review (docs/design/android-ui.md §17): the move buttons in the bottom bar (snackbars above them), ripple on press, larger ◀ ▶, coordinates over the pieces, readable NAG colors in the light theme, 16 dp edges, the ⋮ menu (game details, copy PGN/FEN, share), "Deeper" next to ▾, TalkBack states, no "*" for unfinished games, "Found N of M", texts. - The penguin as the adaptive icon and on the splash screen; dark window. - Release builds: R8, signing from the environment, androidApp/scripts/release.sh (two APKs, apksigner and 16 KB alignment checks); the release workflow builds them from the repository secrets. - Website: the Android tab with both APKs, "Download for Android" on phones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2
androidApp/.gitignore
vendored
|
|
@ -13,3 +13,5 @@
|
|||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
/dist
|
||||
.env
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@ val bundled = layout.buildDirectory.dir("generated/assets")
|
|||
val ndkHome = System.getenv("ANDROID_NDK_HOME")
|
||||
?: "${System.getenv("ANDROID_HOME") ?: "${System.getProperty("user.home")}/Android/Sdk"}/ndk/30.0.16248370"
|
||||
|
||||
/// The version of the workspace (Cargo.toml): the phone and the desktop are one release.
|
||||
val version: String = Regex("""(?m)^version = "([^"]+)"""")
|
||||
.find(File(repo, "Cargo.toml").readText())!!.groupValues[1]
|
||||
val versionNumber: Int = version.split('.').map { it.takeWhile(Char::isDigit).toInt() }
|
||||
.let { (major, minor, patch) -> major * 10000 + minor * 100 + patch }
|
||||
|
||||
/// The core for the phones (arm64) and the emulator (x86_64).
|
||||
val cargoBuild = tasks.register<Exec>("cargoBuild") {
|
||||
workingDir = repo
|
||||
|
|
@ -99,8 +105,8 @@ android {
|
|||
applicationId = "io.github.vrubelroman.chesspenguin"
|
||||
minSdk = 31
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "0.1.0"
|
||||
versionCode = versionNumber
|
||||
versionName = version
|
||||
ndk {
|
||||
abiFilters += listOf("arm64-v8a", "x86_64")
|
||||
}
|
||||
|
|
@ -115,12 +121,32 @@ android {
|
|||
)
|
||||
}
|
||||
|
||||
// The release key is never in the repository: CP_KEYSTORE, CP_KEYSTORE_PASSWORD,
|
||||
// CP_KEY_ALIAS, CP_KEY_PASSWORD come from the environment (scripts/release.sh, CI).
|
||||
val keystore = System.getenv("CP_KEYSTORE")
|
||||
signingConfigs {
|
||||
if (keystore != null) {
|
||||
create("release") {
|
||||
storeFile = File(keystore)
|
||||
storePassword = System.getenv("CP_KEYSTORE_PASSWORD")
|
||||
keyAlias = System.getenv("CP_KEY_ALIAS")
|
||||
keyPassword = System.getenv("CP_KEY_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
signingConfig = signingConfigs.findByName("release")
|
||||
}
|
||||
}
|
||||
// The languages of the interface; the libraries' other translations stay out.
|
||||
androidResources {
|
||||
localeFilters += listOf("en", "ru")
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
|
|
|
|||
6
androidApp/app/proguard-rules.pro
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# The Rust core is reached through JNA (UniFFI): JNA finds the native functions and
|
||||
# the structures by reflection, so neither may be renamed or removed.
|
||||
-keep class com.sun.jna.** { *; }
|
||||
-keep class * implements com.sun.jna.** { *; }
|
||||
-keep class uniffi.mobile_api.** { *; }
|
||||
-dontwarn java.awt.**
|
||||
|
|
@ -9,7 +9,9 @@
|
|||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.ChessPenguin">
|
||||
android:theme="@style/Theme.ChessPenguin"
|
||||
android:localeConfig="@xml/locales_config"
|
||||
android:enableOnBackInvokedCallback="true">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ val DarkErrorContainer = Color(0xFF5C1A14)
|
|||
|
||||
/// Colors of the notation and the board that stay ours whatever the theme.
|
||||
data class ChessColors(
|
||||
val dark: Boolean,
|
||||
val currentMove: Color,
|
||||
val comment: Color,
|
||||
val lightSquare: Color,
|
||||
|
|
@ -42,6 +43,7 @@ data class ChessColors(
|
|||
)
|
||||
|
||||
val LightChess = ChessColors(
|
||||
dark = false,
|
||||
currentMove = Color(0xFF90D1FF),
|
||||
comment = Color(0xFF2A5B8A),
|
||||
lightSquare = Color(0xFFFFFFDD),
|
||||
|
|
@ -50,17 +52,31 @@ val LightChess = ChessColors(
|
|||
)
|
||||
|
||||
val DarkChess = LightChess.copy(
|
||||
dark = true,
|
||||
currentMove = Color(0xFF005C80),
|
||||
comment = Color(0xFF9EC4E0),
|
||||
)
|
||||
|
||||
/// Move assessments, as on the desktop (Lichess colors), the same in both themes.
|
||||
fun nagColor(nag: Int): Color? = when (nag) {
|
||||
1 -> Color(0xFF629C2E) // !
|
||||
2 -> Color(0xFFE68F00) // ?
|
||||
3 -> Color(0xFF22AC9A) // !!
|
||||
4 -> Color(0xFFDF5353) // ??
|
||||
5 -> Color(0xFFEA45D8) // !?
|
||||
6 -> Color(0xFF56B4E9) // ?!
|
||||
else -> null
|
||||
/// Move assessments in the colors of Lichess (as on the desktop). On a light background
|
||||
/// they are darkened to stay readable (contrast at least 4.5:1).
|
||||
fun nagColor(nag: Int, dark: Boolean): Color? = if (dark) {
|
||||
when (nag) {
|
||||
1 -> Color(0xFF629C2E) // !
|
||||
2 -> Color(0xFFE68F00) // ?
|
||||
3 -> Color(0xFF22AC9A) // !!
|
||||
4 -> Color(0xFFDF5353) // ??
|
||||
5 -> Color(0xFFEA45D8) // !?
|
||||
6 -> Color(0xFF56B4E9) // ?!
|
||||
else -> null
|
||||
}
|
||||
} else {
|
||||
when (nag) {
|
||||
1 -> Color(0xFF4E7F22)
|
||||
2 -> Color(0xFFA35F00)
|
||||
3 -> Color(0xFF12806F)
|
||||
4 -> Color(0xFFC23B3B)
|
||||
5 -> Color(0xFFB0259F)
|
||||
6 -> Color(0xFF1F72A8)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,17 +180,6 @@ fun Board(
|
|||
)
|
||||
}
|
||||
}
|
||||
// Coordinates: files along the bottom edge, ranks along the left edge.
|
||||
for (k in 0 until 8) {
|
||||
val fileIndex = if (flipped) 7 - k else k
|
||||
val rankIndex = if (flipped) k else 7 - k
|
||||
val bottomLight = (7 + k) % 2 == 0
|
||||
val leftLight = k % 2 == 0
|
||||
drawCoord(measurer, ('a' + fileIndex).toString(), coordStyle.copy(color = if (bottomLight) colors.darkSquare else colors.lightSquare),
|
||||
Offset((k + 1) * sq - with(density) { 8.sp.toPx() }, 8 * sq - with(density) { 13.sp.toPx() }))
|
||||
drawCoord(measurer, ('1' + rankIndex).toString(), coordStyle.copy(color = if (leftLight) colors.darkSquare else colors.lightSquare),
|
||||
Offset(with(density) { 2.sp.toPx() }, k * sq + with(density) { 1.sp.toPx() }))
|
||||
}
|
||||
for (i in 0 until 64) {
|
||||
val p = squares[i]
|
||||
if (p == ' ') continue
|
||||
|
|
@ -202,6 +191,18 @@ fun Board(
|
|||
}
|
||||
drawImage(bmp, dstOffset = IntOffset(at.x.toInt(), at.y.toInt()), dstSize = IntSize(px, px))
|
||||
}
|
||||
// Over the pieces, so that b, c, f, g stay readable (as on Lichess).
|
||||
// Coordinates: files along the bottom edge, ranks along the left edge.
|
||||
for (k in 0 until 8) {
|
||||
val fileIndex = if (flipped) 7 - k else k
|
||||
val rankIndex = if (flipped) k else 7 - k
|
||||
val bottomLight = (7 + k) % 2 == 0
|
||||
val leftLight = k % 2 == 0
|
||||
drawCoord(measurer, ('a' + fileIndex).toString(), coordStyle.copy(color = if (bottomLight) colors.darkSquare else colors.lightSquare),
|
||||
Offset((k + 1) * sq - with(density) { 8.sp.toPx() }, 8 * sq - with(density) { 13.sp.toPx() }))
|
||||
drawCoord(measurer, ('1' + rankIndex).toString(), coordStyle.copy(color = if (leftLight) colors.darkSquare else colors.lightSquare),
|
||||
Offset(with(density) { 2.sp.toPx() }, k * sq + with(density) { 1.sp.toPx() }))
|
||||
}
|
||||
for (a in arrows) {
|
||||
val f = squareIndex(a.from) ?: continue
|
||||
val t = squareIndex(a.to) ?: continue
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ private fun LineRow(
|
|||
.fillMaxWidth()
|
||||
.height(if (first) 48.dp else 40.dp)
|
||||
.then(if (line != null) Modifier.clickable { onLine(line) } else Modifier)
|
||||
.padding(start = 8.dp, end = if (first) 0.dp else 16.dp),
|
||||
.padding(start = 16.dp, end = if (first) 0.dp else 16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
EvalPlaque(line)
|
||||
|
|
@ -155,7 +155,8 @@ private fun LineRow(
|
|||
)
|
||||
if (first && status == EngineStatus.Paused) {
|
||||
TextButton(onClick = onDeeper) { Text(stringResource(R.string.deeper)) }
|
||||
} else if (first && canExpand) {
|
||||
}
|
||||
if (first && canExpand) {
|
||||
IconButton(onClick = onExpand) {
|
||||
Icon(
|
||||
if (expanded) Icons.Rounded.ExpandLess else Icons.Rounded.ExpandMore,
|
||||
|
|
@ -178,7 +179,7 @@ private fun EvalPlaque(line: EngineLine?) {
|
|||
.height(28.dp)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.background(bg)
|
||||
.border(1.dp, MaterialTheme.colorScheme.outlineVariant, RoundedCornerShape(8.dp)),
|
||||
.border(1.dp, MaterialTheme.colorScheme.outline, RoundedCornerShape(8.dp)),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text(
|
||||
|
|
@ -204,7 +205,7 @@ fun PreviewBar(step: Int, total: Int, onClose: () -> Unit) {
|
|||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.height(40.dp)
|
||||
.height(48.dp)
|
||||
.background(MaterialTheme.colorScheme.primaryContainer)
|
||||
.padding(start = 16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
|
@ -259,7 +260,7 @@ fun EngineSheet(state: NetState, metered: Boolean, onDownload: () -> Unit, onCan
|
|||
Text(text, color = MaterialTheme.colorScheme.error, style = MaterialTheme.typography.bodyMedium)
|
||||
Spacer(Modifier.height(24.dp))
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End)) {
|
||||
TextButton(onClick = onDismiss) { Text(stringResource(R.string.not_now)) }
|
||||
if (state.problem != NetProblem.NoSpace) TextButton(onClick = onDismiss) { Text(stringResource(R.string.not_now)) }
|
||||
when (state.problem) {
|
||||
NetProblem.NoSpace -> Button(onClick = onDismiss) { Text(stringResource(R.string.ok)) }
|
||||
NetProblem.NoInternet -> Button(onClick = onDownload) { Text(stringResource(R.string.retry)) }
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
package io.github.vrubelroman.chesspenguin.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.HapticFeedbackConstants
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.indication
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.interaction.PressInteraction
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.foundation.gestures.detectTapGestures
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
|
|
@ -22,8 +28,6 @@ import androidx.compose.foundation.lazy.rememberLazyListState
|
|||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.rounded.ArrowBack
|
||||
import androidx.compose.material.icons.automirrored.rounded.ArrowLeft
|
||||
import androidx.compose.material.icons.automirrored.rounded.ArrowRight
|
||||
import androidx.compose.material.icons.outlined.Memory
|
||||
import androidx.compose.material.icons.rounded.ChevronLeft
|
||||
import androidx.compose.material.icons.rounded.ChevronRight
|
||||
|
|
@ -31,9 +35,13 @@ import androidx.compose.material.icons.rounded.Download
|
|||
import androidx.compose.material.icons.rounded.FirstPage
|
||||
import androidx.compose.material.icons.rounded.LastPage
|
||||
import androidx.compose.material.icons.rounded.Memory
|
||||
import androidx.compose.material.icons.rounded.Settings
|
||||
import androidx.compose.material.icons.rounded.MoreVert
|
||||
import androidx.compose.material.icons.rounded.PlayArrow
|
||||
import androidx.compose.material.icons.rounded.SwapVert
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
|
|
@ -46,7 +54,9 @@ import androidx.compose.material3.SnackbarHost
|
|||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.ripple
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
|
|
@ -61,6 +71,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
|
|
@ -152,6 +163,16 @@ fun GameScreen(db: String, startPlace: Int, onBack: () -> Unit, onSettings: () -
|
|||
var sheet by remember { mutableStateOf(false) }
|
||||
var wantEngine by remember { mutableStateOf(false) }
|
||||
var expanded by rememberSaveable { mutableStateOf(false) }
|
||||
var menu by remember { mutableStateOf(false) }
|
||||
var info by remember { mutableStateOf(false) }
|
||||
@Suppress("DEPRECATION")
|
||||
val clipboard = androidx.compose.ui.platform.LocalClipboardManager.current
|
||||
val copiedText = stringResource(R.string.copied)
|
||||
suspend fun pgnText(): String? {
|
||||
val index = games?.getOrNull(place) ?: return null
|
||||
val database = app.library.database(db).getOrNull() ?: return null
|
||||
return withContext(Dispatchers.Default) { database.pgn(index) }
|
||||
}
|
||||
val lifecycle = LocalLifecycleOwner.current.lifecycle
|
||||
DisposableEffect(lifecycle) {
|
||||
val observer = LifecycleEventObserver { _, e ->
|
||||
|
|
@ -267,7 +288,7 @@ fun GameScreen(db: String, startPlace: Int, onBack: () -> Unit, onSettings: () -
|
|||
)
|
||||
if (total > 0) {
|
||||
Text(
|
||||
joinKnown(stringResource(R.string.game_of, place + 1, total), g?.let { shortResult(it.result) } ?: ""),
|
||||
joinKnown(stringResource(R.string.game_of, place + 1, total), g?.let { shortResult(it.result) }?.takeIf { it != "*" } ?: ""),
|
||||
style = MaterialTheme.typography.bodyMedium.merge(Tabular),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
|
@ -281,13 +302,81 @@ fun GameScreen(db: String, startPlace: Int, onBack: () -> Unit, onSettings: () -
|
|||
IconButton(onClick = { place += 1 }, enabled = place + 1 < total) {
|
||||
Icon(Icons.Rounded.ChevronRight, stringResource(R.string.next_game))
|
||||
}
|
||||
IconButton(onClick = onSettings) { Icon(Icons.Rounded.Settings, stringResource(R.string.settings)) }
|
||||
Box {
|
||||
IconButton(onClick = { menu = true }) { Icon(Icons.Rounded.MoreVert, stringResource(R.string.menu)) }
|
||||
DropdownMenu(expanded = menu, onDismissRequest = { menu = false }) {
|
||||
DropdownMenuItem(text = { Text(stringResource(R.string.game_info)) }, enabled = g != null, onClick = {
|
||||
menu = false
|
||||
info = true
|
||||
})
|
||||
DropdownMenuItem(text = { Text(stringResource(R.string.copy_pgn)) }, enabled = g != null, onClick = {
|
||||
menu = false
|
||||
scope.launch {
|
||||
pgnText()?.let {
|
||||
clipboard.setText(AnnotatedString(it))
|
||||
snackbar.showSnackbar(copiedText)
|
||||
}
|
||||
}
|
||||
})
|
||||
DropdownMenuItem(text = { Text(stringResource(R.string.copy_fen)) }, enabled = node != null, onClick = {
|
||||
menu = false
|
||||
(preview?.let { it.line.steps[it.step].fen } ?: node?.fen)?.let {
|
||||
clipboard.setText(AnnotatedString(it))
|
||||
scope.launch { snackbar.showSnackbar(copiedText) }
|
||||
}
|
||||
})
|
||||
DropdownMenuItem(text = { Text(stringResource(R.string.share_game)) }, enabled = g != null, onClick = {
|
||||
menu = false
|
||||
scope.launch {
|
||||
pgnText()?.let { text ->
|
||||
val send = Intent(Intent.ACTION_SEND).setType("text/plain").putExtra(Intent.EXTRA_TEXT, text)
|
||||
context.startActivity(Intent.createChooser(send, null))
|
||||
}
|
||||
}
|
||||
})
|
||||
DropdownMenuItem(text = { Text(stringResource(R.string.settings)) }, onClick = {
|
||||
menu = false
|
||||
onSettings()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
snackbarHost = { SnackbarHost(snackbar) },
|
||||
// In the bottom bar, so that snackbars stand above the move buttons.
|
||||
bottomBar = {
|
||||
Column {
|
||||
val p = preview
|
||||
if (p == null && node != null && nodes != null && node.children.size > 1) {
|
||||
Forks(node.children.map { nodes[it.toInt()] }, san, onMove = ::go)
|
||||
}
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
Surface(color = MaterialTheme.colorScheme.surfaceContainer) {
|
||||
Row(
|
||||
Modifier.fillMaxWidth().navigationBarsPadding().height(72.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
EngineButton(
|
||||
on = engineOn,
|
||||
needsDownload = !engineReady && !files.builtIn,
|
||||
loading = netState as? NetState.Loading,
|
||||
modifier = Modifier.weight(1.2f),
|
||||
onClick = ::toggleEngine,
|
||||
)
|
||||
BarButton(Icons.Rounded.SwapVert, stringResource(R.string.flip), true, Modifier.weight(1f)) { flipped = !flipped }
|
||||
BarButton(Icons.Rounded.FirstPage, stringResource(R.string.to_start), canBack, Modifier.weight(1f)) {
|
||||
if (preview != null) preview = null else go(0)
|
||||
}
|
||||
BarButton(Icons.Rounded.PlayArrow, stringResource(R.string.move_back), canBack, Modifier.weight(1.5f), 32, repeat = true, mirrored = true) { back() }
|
||||
BarButton(Icons.Rounded.PlayArrow, stringResource(R.string.move_forward), canForward, Modifier.weight(1.5f), 32, repeat = true) { forward() }
|
||||
BarButton(Icons.Rounded.LastPage, stringResource(R.string.to_end), canForward, Modifier.weight(1f)) { end() }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
) { padding ->
|
||||
Column(Modifier.fillMaxSize().padding(top = padding.calculateTopPadding())) {
|
||||
Column(Modifier.fillMaxSize().padding(top = padding.calculateTopPadding(), bottom = padding.calculateBottomPadding())) {
|
||||
val p = preview
|
||||
val step = p?.let { it.line.steps[it.step] }
|
||||
val fen = step?.fen ?: node?.fen ?: START
|
||||
|
|
@ -347,7 +436,7 @@ fun GameScreen(db: String, startPlace: Int, onBack: () -> Unit, onSettings: () -
|
|||
},
|
||||
notation = line,
|
||||
)
|
||||
} else if (wantEngine && netState is NetState.Loading) {
|
||||
} else if (wantEngine && files.builtIn && netState is NetState.Loading) {
|
||||
Row(Modifier.fillMaxWidth().height(48.dp).padding(horizontal = 16.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
CircularProgressIndicator(Modifier.size(20.dp), strokeWidth = 2.dp)
|
||||
Text(stringResource(R.string.preparing_engine), Modifier.padding(start = 12.dp), color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
|
|
@ -365,33 +454,29 @@ fun GameScreen(db: String, startPlace: Int, onBack: () -> Unit, onSettings: () -
|
|||
else -> CircularProgressIndicator(Modifier.align(Alignment.Center))
|
||||
}
|
||||
}
|
||||
if (p == null && node != null && nodes != null && node.children.size > 1) {
|
||||
Forks(node.children.map { nodes[it.toInt()] }, san, onMove = ::go)
|
||||
}
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
Surface(color = MaterialTheme.colorScheme.surfaceContainer) {
|
||||
Row(
|
||||
Modifier.fillMaxWidth().navigationBarsPadding().height(72.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
EngineButton(
|
||||
on = engineOn,
|
||||
needsDownload = !engineReady && !files.builtIn,
|
||||
loading = netState as? NetState.Loading,
|
||||
modifier = Modifier.weight(1.2f),
|
||||
onClick = ::toggleEngine,
|
||||
)
|
||||
BarButton(Icons.Rounded.SwapVert, stringResource(R.string.flip), true, Modifier.weight(1f)) { flipped = !flipped }
|
||||
BarButton(Icons.Rounded.FirstPage, stringResource(R.string.to_start), canBack, Modifier.weight(1f)) {
|
||||
if (preview != null) preview = null else go(0)
|
||||
}
|
||||
BarButton(Icons.AutoMirrored.Rounded.ArrowLeft, stringResource(R.string.move_back), canBack, Modifier.weight(1.5f), 44, repeat = true) { back() }
|
||||
BarButton(Icons.AutoMirrored.Rounded.ArrowRight, stringResource(R.string.move_forward), canForward, Modifier.weight(1.5f), 44, repeat = true) { forward() }
|
||||
BarButton(Icons.Rounded.LastPage, stringResource(R.string.to_end), canForward, Modifier.weight(1f)) { end() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (info && g != null) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { info = false },
|
||||
title = { Text(stringResource(R.string.game_info)) },
|
||||
text = {
|
||||
Column(Modifier.verticalScroll(rememberScrollState())) {
|
||||
g.tags.filter { it.value.isNotBlank() && it.value != "?" }.forEach { t ->
|
||||
Row(Modifier.padding(vertical = 4.dp)) {
|
||||
Text(t.name, Modifier.width(96.dp), color = MaterialTheme.colorScheme.onSurfaceVariant, style = MaterialTheme.typography.bodyMedium)
|
||||
Text(t.value, style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
}
|
||||
if (g.notes.isNotEmpty()) {
|
||||
Text(stringResource(R.string.notes), Modifier.padding(top = 12.dp), style = MaterialTheme.typography.labelLarge)
|
||||
g.notes.forEach { Text(it, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant) }
|
||||
}
|
||||
}
|
||||
},
|
||||
confirmButton = { TextButton(onClick = { info = false }) { Text(stringResource(R.string.close)) } },
|
||||
)
|
||||
}
|
||||
if (sheet) {
|
||||
EngineSheet(
|
||||
state = netState,
|
||||
|
|
@ -418,6 +503,13 @@ private const val START = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -
|
|||
@Composable
|
||||
private fun EngineButton(on: Boolean, needsDownload: Boolean, loading: NetState.Loading?, modifier: Modifier, onClick: () -> Unit) {
|
||||
val label = stringResource(R.string.engine)
|
||||
val state = stringResource(
|
||||
when {
|
||||
needsDownload -> R.string.engine_state_missing
|
||||
on -> R.string.engine_state_on
|
||||
else -> R.string.engine_state_off
|
||||
},
|
||||
)
|
||||
val action by rememberUpdatedState(onClick)
|
||||
val color = if (on) MaterialTheme.colorScheme.primary else LocalContentColor.current
|
||||
Column(
|
||||
|
|
@ -426,10 +518,10 @@ private fun EngineButton(on: Boolean, needsDownload: Boolean, loading: NetState.
|
|||
.semantics {
|
||||
contentDescription = label
|
||||
role = Role.Switch
|
||||
stateDescription = if (on) "on" else "off"
|
||||
stateDescription = state
|
||||
onClick { action(); true }
|
||||
}
|
||||
.pointerInput(Unit) { detectTapGestures { action() } },
|
||||
.clickable(onClick = action),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
|
|
@ -484,10 +576,12 @@ private fun BarButton(
|
|||
modifier: Modifier,
|
||||
iconSize: Int = 24,
|
||||
repeat: Boolean = false,
|
||||
mirrored: Boolean = false,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
val action by rememberUpdatedState(onClick)
|
||||
val on by rememberUpdatedState(enabled)
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
val color = if (enabled) LocalContentColor.current else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)
|
||||
Box(
|
||||
modifier
|
||||
|
|
@ -498,27 +592,34 @@ private fun BarButton(
|
|||
if (!enabled) disabled()
|
||||
onClick { action(); true }
|
||||
}
|
||||
.indication(interaction, ripple(bounded = false, radius = 32.dp))
|
||||
.pointerInput(repeat) {
|
||||
detectTapGestures(onPress = {
|
||||
detectTapGestures(onPress = { at ->
|
||||
if (!on) return@detectTapGestures
|
||||
val press = PressInteraction.Press(at)
|
||||
interaction.emit(press)
|
||||
action()
|
||||
if (!repeat) return@detectTapGestures
|
||||
coroutineScope {
|
||||
val job = launch {
|
||||
delay(400)
|
||||
while (on) {
|
||||
action()
|
||||
delay(120)
|
||||
val job = if (repeat) {
|
||||
launch {
|
||||
delay(400)
|
||||
while (on) {
|
||||
action()
|
||||
delay(120)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
tryAwaitRelease()
|
||||
job.cancel()
|
||||
job?.cancel()
|
||||
}
|
||||
interaction.emit(PressInteraction.Release(press))
|
||||
})
|
||||
},
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(icon, null, tint = color, modifier = Modifier.size(iconSize.dp))
|
||||
Icon(icon, null, tint = color, modifier = Modifier.size(iconSize.dp).then(if (mirrored) Modifier.scale(-1f, 1f) else Modifier))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,8 +126,13 @@ fun GamesScreen(db: String, onBack: () -> Unit, onGame: (Int) -> Unit) {
|
|||
Text(entry?.name ?: "", maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
database?.let { d ->
|
||||
val n = d.len().toInt()
|
||||
val found = shown?.size
|
||||
Text(
|
||||
pluralStringResource(R.plurals.games_count, n, groupDigits(n)),
|
||||
if (query.isNotEmpty() && found != null) {
|
||||
stringResource(R.string.found_of, groupDigits(found), groupDigits(n))
|
||||
} else {
|
||||
pluralStringResource(R.plurals.games_count, n, groupDigits(n))
|
||||
},
|
||||
style = MaterialTheme.typography.bodyMedium.merge(Tabular),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
|
@ -188,20 +193,21 @@ private fun Message(title: String, detail: String) {
|
|||
}
|
||||
}
|
||||
|
||||
/// One game: "White – Black" and the result, then event · year · ECO (§6.2).
|
||||
/// One game: "White – Black" and the result, then event · year · ECO (§6.2). An
|
||||
/// unfinished game ("*", most book positions) shows no result.
|
||||
@Composable
|
||||
private fun GameRowView(row: GameRow?, onClick: () -> Unit) {
|
||||
Row(
|
||||
Column(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.height(64.dp)
|
||||
.clickable(enabled = row != null, onClick = onClick)
|
||||
.padding(horizontal = 16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
if (row == null) return@Column
|
||||
Row {
|
||||
if (row == null) return@Column
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Row(Modifier.weight(1f)) {
|
||||
Text(
|
||||
shortName(row.white),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
|
|
@ -221,22 +227,25 @@ private fun GameRowView(row: GameRow?, onClick: () -> Unit) {
|
|||
)
|
||||
}
|
||||
}
|
||||
val details = joinKnown(row.event, year(row.date), row.eco)
|
||||
if (details.isNotEmpty()) {
|
||||
val result = shortResult(row.result)
|
||||
if (result != "*") {
|
||||
Text(
|
||||
details,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
result,
|
||||
style = MaterialTheme.typography.bodyLarge.merge(Tabular),
|
||||
textAlign = TextAlign.End,
|
||||
modifier = Modifier.width(48.dp).padding(start = 8.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
row?.let { shortResult(it.result) } ?: "",
|
||||
style = MaterialTheme.typography.bodyLarge.merge(Tabular),
|
||||
textAlign = TextAlign.End,
|
||||
modifier = Modifier.width(48.dp).padding(start = 8.dp),
|
||||
)
|
||||
val details = joinKnown(row.event, year(row.date), row.eco)
|
||||
if (details.isNotEmpty()) {
|
||||
Text(
|
||||
details,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,8 @@ private fun variationText(
|
|||
append(label(n, number, san))
|
||||
}
|
||||
if (n.nagSymbols.isNotEmpty()) {
|
||||
val c = n.nags.firstOrNull()?.let { nagColor(it.toInt()) } ?: onSurface
|
||||
// On the highlighted move the sign takes the text color.
|
||||
val c = if (id == current) onSurface else n.nags.firstOrNull()?.let { nagColor(it.toInt(), chess.dark) } ?: onSurface
|
||||
withStyle(SpanStyle(color = c)) { append(n.nagSymbols) }
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +223,7 @@ fun Notation(
|
|||
lineHeight = 22.sp,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 8.dp, vertical = 4.dp)
|
||||
.padding(horizontal = 16.dp, vertical = 4.dp)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.background(MaterialTheme.colorScheme.surfaceContainerLow)
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
|
|
@ -231,7 +232,7 @@ fun Notation(
|
|||
is Item.Variation -> Box(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = (8 + 16 * (item.depth - 1)).dp, end = 8.dp, top = 2.dp, bottom = 2.dp),
|
||||
.padding(start = (16 + 16 * (item.depth - 1)).dp, end = 16.dp, top = 2.dp, bottom = 2.dp),
|
||||
) {
|
||||
Row(Modifier.height(androidx.compose.foundation.layout.IntrinsicSize.Min)) {
|
||||
Box(Modifier.width(2.dp).fillMaxHeight().background(MaterialTheme.colorScheme.outlineVariant))
|
||||
|
|
@ -275,8 +276,8 @@ private fun MovesRow(
|
|||
modifier = Modifier.width(40.dp).padding(end = 8.dp),
|
||||
textAlign = androidx.compose.ui.text.style.TextAlign.End,
|
||||
)
|
||||
MoveCell(game, row.white, current, chess, san, onMove, Modifier.weight(1f))
|
||||
MoveCell(game, row.black, current, chess, san, onMove, Modifier.weight(1f))
|
||||
MoveCell(game, row.white, true, current, chess, san, onMove, Modifier.weight(1f))
|
||||
MoveCell(game, row.black, false, current, chess, san, onMove, Modifier.weight(1f))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -284,6 +285,7 @@ private fun MovesRow(
|
|||
private fun MoveCell(
|
||||
game: GameData,
|
||||
id: Int?,
|
||||
white: Boolean,
|
||||
current: Int,
|
||||
chess: ChessColors,
|
||||
san: (String) -> AnnotatedString,
|
||||
|
|
@ -300,7 +302,8 @@ private fun MoveCell(
|
|||
contentAlignment = Alignment.CenterStart,
|
||||
) {
|
||||
if (id == null) {
|
||||
Text("…", color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 17.sp, modifier = Modifier.padding(horizontal = 8.dp))
|
||||
// "4. … Nf6": only White's empty cell says that a move is there.
|
||||
if (white) Text("…", color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 17.sp, modifier = Modifier.padding(horizontal = 8.dp))
|
||||
} else {
|
||||
val n = game.nodes[id]
|
||||
Row(
|
||||
|
|
@ -316,7 +319,11 @@ private fun MoveCell(
|
|||
n.nagSymbols,
|
||||
fontSize = 17.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = n.nags.firstOrNull()?.let { nagColor(it.toInt()) } ?: MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
color = if (selected) {
|
||||
MaterialTheme.colorScheme.onSurface
|
||||
} else {
|
||||
n.nags.firstOrNull()?.let { nagColor(it.toInt(), chess.dark) } ?: MaterialTheme.colorScheme.onSurfaceVariant
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import androidx.compose.material3.TextButton
|
|||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
|
|
@ -56,6 +57,7 @@ fun SettingsScreen(onBack: () -> Unit, onAbout: () -> Unit) {
|
|||
val set = app.settings::update
|
||||
var choice by remember { mutableStateOf<Choice?>(null) }
|
||||
var deleting by remember { mutableStateOf(false) }
|
||||
var sheet by remember { mutableStateOf(false) }
|
||||
val lang = uiLanguage()
|
||||
val scroll = TopAppBarDefaults.pinnedScrollBehavior()
|
||||
val size = (BuildConfig.NET_SIZE / 1_000_000).toInt()
|
||||
|
|
@ -92,12 +94,7 @@ fun SettingsScreen(onBack: () -> Unit, onAbout: () -> Unit) {
|
|||
},
|
||||
) { padding ->
|
||||
Column(Modifier.fillMaxSize().padding(padding).verticalScroll(rememberScrollState()).padding(bottom = 24.dp)) {
|
||||
Group(stringResource(R.string.group_look))
|
||||
Item(stringResource(R.string.theme), themeNames.first { it.first == prefs.theme }.second) {
|
||||
choice = Choice(R.string.theme, themeNames.map { it.second }, themeNames.indexOfFirst { it.first == prefs.theme }) { i ->
|
||||
set { it.copy(theme = themeNames[i].first) }
|
||||
}
|
||||
}
|
||||
Group(stringResource(R.string.group_game))
|
||||
val notationNow = notationNames.firstOrNull { it.first == prefs.notation } ?: notationNames.first()
|
||||
Item(stringResource(R.string.notation), notationNow.second) {
|
||||
choice = Choice(
|
||||
|
|
@ -108,23 +105,30 @@ fun SettingsScreen(onBack: () -> Unit, onAbout: () -> Unit) {
|
|||
) { i -> set { it.copy(notation = notationNames[i].first) } }
|
||||
}
|
||||
|
||||
Group(stringResource(R.string.group_board))
|
||||
Toggle(stringResource(R.string.animation), prefs.animation) { v -> set { it.copy(animation = v) } }
|
||||
Toggle(stringResource(R.string.best_arrow), prefs.bestArrow) { v -> set { it.copy(bestArrow = v) } }
|
||||
Toggle(stringResource(R.string.vibration), prefs.vibration) { v -> set { it.copy(vibration = v) } }
|
||||
|
||||
Group(stringResource(R.string.group_look))
|
||||
Item(stringResource(R.string.theme), themeNames.first { it.first == prefs.theme }.second) {
|
||||
choice = Choice(R.string.theme, themeNames.map { it.second }, themeNames.indexOfFirst { it.first == prefs.theme }) { i ->
|
||||
set { it.copy(theme = themeNames[i].first) }
|
||||
}
|
||||
}
|
||||
|
||||
Group(stringResource(R.string.group_engine))
|
||||
when {
|
||||
files.builtIn -> Item(stringResource(R.string.engine_built_in), null, null)
|
||||
files.builtIn -> Status(stringResource(R.string.engine_built_in))
|
||||
net == NetState.Ready -> {
|
||||
Item(stringResource(R.string.engine_downloaded), null, null)
|
||||
Status(stringResource(R.string.engine_downloaded))
|
||||
Item(stringResource(R.string.engine_delete, size), null) { deleting = true }
|
||||
}
|
||||
net is NetState.Loading -> {
|
||||
val l = net as NetState.Loading
|
||||
Item(stringResource(R.string.engine_downloading, (l.done / 1_000_000).toInt(), (l.total / 1_000_000).toInt()), null, null)
|
||||
Item(stringResource(R.string.engine_downloading, (l.done / 1_000_000).toInt(), (l.total / 1_000_000).toInt()), null) { sheet = true }
|
||||
}
|
||||
else -> Item(stringResource(R.string.engine_missing, size), null) { files.prepare() }
|
||||
// The same sheet as in a game: the size, mobile data, cancel (§9).
|
||||
else -> Item(stringResource(R.string.engine_missing, size), null) { sheet = true }
|
||||
}
|
||||
Item(stringResource(R.string.lines), "${prefs.engineLines}") {
|
||||
choice = Choice(R.string.lines, listOf("1", "2", "3"), prefs.engineLines - 1) { i -> set { it.copy(engineLines = i + 1) } }
|
||||
|
|
@ -183,6 +187,19 @@ fun SettingsScreen(onBack: () -> Unit, onAbout: () -> Unit) {
|
|||
confirmButton = { TextButton(onClick = { choice = null }) { Text(stringResource(R.string.cancel)) } },
|
||||
)
|
||||
}
|
||||
if (sheet) {
|
||||
EngineSheet(
|
||||
state = net,
|
||||
metered = remember(sheet) { files.metered() },
|
||||
onDownload = { files.prepare() },
|
||||
onCancel = {
|
||||
files.cancel()
|
||||
sheet = false
|
||||
},
|
||||
onDismiss = { sheet = false },
|
||||
)
|
||||
}
|
||||
LaunchedEffect(net) { if (net == NetState.Ready) sheet = false }
|
||||
if (deleting) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { deleting = false },
|
||||
|
|
@ -225,6 +242,17 @@ private fun Item(title: String, value: String?, onClick: (() -> Unit)?) {
|
|||
}
|
||||
}
|
||||
|
||||
/// A line that tells, not a button.
|
||||
@Composable
|
||||
private fun Status(text: String) {
|
||||
Text(
|
||||
text,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Toggle(title: String, value: Boolean, onChange: (Boolean) -> Unit) {
|
||||
Row(
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 70 KiB |
|
|
@ -1,170 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 7 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 982 B |
|
After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 7.6 KiB |
8
androidApp/app/src/main/res/values-night/themes.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.ChessPenguin" parent="android:Theme.Material.NoActionBar">
|
||||
<item name="android:windowBackground">#161718</item>
|
||||
<item name="android:windowSplashScreenBackground">#161718</item>
|
||||
<item name="android:windowSplashScreenIconBackgroundColor">@color/ic_launcher_background</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -35,11 +35,11 @@
|
|||
<string name="game_of">%1$d из %2$d</string>
|
||||
<string name="previous_game">Предыдущая партия</string>
|
||||
<string name="next_game">Следующая партия</string>
|
||||
<string name="flip">Перевернуть</string>
|
||||
<string name="flip">Перевернуть доску</string>
|
||||
<string name="to_start">В начало</string>
|
||||
<string name="move_back">Ход назад</string>
|
||||
<string name="move_forward">Ход вперёд</string>
|
||||
<string name="to_end">В конец</string>
|
||||
<string name="to_end">В конец линии</string>
|
||||
<string name="next_moves">Дальше:</string>
|
||||
<string name="board_hint">Это просмотр партии. Ходы листаются кнопками ◀ ▶ внизу.</string>
|
||||
<string name="board_description">Доска, позиция после %1$s</string>
|
||||
|
|
@ -83,7 +83,6 @@
|
|||
|
||||
<string name="settings">Настройки</string>
|
||||
<string name="group_look">Внешний вид</string>
|
||||
<string name="group_board">Доска</string>
|
||||
<string name="group_engine">Движок</string>
|
||||
<string name="theme">Тема</string>
|
||||
<string name="theme_system">Как в системе</string>
|
||||
|
|
@ -114,9 +113,21 @@
|
|||
<string name="megabytes">%1$d МБ</string>
|
||||
<string name="engine_battery">Движок расходует заряд. Он сам останавливается, когда гаснет экран.</string>
|
||||
<string name="about">О программе</string>
|
||||
<string name="build_full">Stockfish внутри</string>
|
||||
<string name="build_light">Stockfish скачивается</string>
|
||||
<string name="build_full">Stockfish уже внутри</string>
|
||||
<string name="build_light">Stockfish скачивается в приложении</string>
|
||||
<string name="about_text">Просмотр шахматных баз: PGN, ChessBase, архивы. Файлы только читаются и никогда не меняются.</string>
|
||||
<string name="licenses">Лицензии</string>
|
||||
<string name="licenses">Лицензии и авторы</string>
|
||||
<string name="website">Сайт и исходный код</string>
|
||||
|
||||
<string name="game_info">Сведения о партии</string>
|
||||
<string name="copy_pgn">Копировать PGN</string>
|
||||
<string name="copy_fen">Копировать FEN</string>
|
||||
<string name="share_game">Поделиться партией</string>
|
||||
<string name="copied">Скопировано</string>
|
||||
<string name="notes">Замечания</string>
|
||||
<string name="engine_state_on">включён</string>
|
||||
<string name="engine_state_off">выключен</string>
|
||||
<string name="engine_state_missing">не скачан</string>
|
||||
<string name="found_of">Найдено %1$s из %2$s</string>
|
||||
<string name="group_game">Партия</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- The background of the adaptive icon (android-ui.md §10.7). -->
|
||||
<color name="ic_launcher_background">#EAF2F9</color>
|
||||
</resources>
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
<string name="sample_classics">Classic games</string>
|
||||
<string name="sample_alekhine">Alekhine</string>
|
||||
|
||||
<string name="empty_title">Your databases will be here</string>
|
||||
<string name="empty_text">Add a PGN file or an archive .zip/.7z — from the phone or a cloud.</string>
|
||||
<string name="empty_title">Your databases will appear here</string>
|
||||
<string name="empty_text">Add a PGN file or a .zip/.7z archive — from your phone or the cloud.</string>
|
||||
<string name="add_database">Add database</string>
|
||||
<string name="open_samples">Open sample games</string>
|
||||
<string name="not_opened">not opened yet · %1$s</string>
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
<string name="games_with_format">%1$s · %2$s</string>
|
||||
<string name="menu">Menu</string>
|
||||
<string name="rename">Rename</string>
|
||||
<string name="remove">Remove from the list</string>
|
||||
<string name="rename_hint">The name on the list. The file does not change.</string>
|
||||
<string name="remove">Remove from list</string>
|
||||
<string name="rename_hint">The name in the list. The file is not changed.</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="removed">Database removed from the list</string>
|
||||
|
|
@ -34,13 +34,13 @@
|
|||
<string name="game_of">%1$d of %2$d</string>
|
||||
<string name="previous_game">Previous game</string>
|
||||
<string name="next_game">Next game</string>
|
||||
<string name="flip">Flip</string>
|
||||
<string name="flip">Flip board</string>
|
||||
<string name="to_start">To the start</string>
|
||||
<string name="move_back">Move back</string>
|
||||
<string name="move_forward">Move forward</string>
|
||||
<string name="to_end">To the end</string>
|
||||
<string name="to_end">To the end of the line</string>
|
||||
<string name="next_moves">Next:</string>
|
||||
<string name="board_hint">This is a game viewer. Moves are stepped with the ◀ ▶ buttons below.</string>
|
||||
<string name="board_hint">This is a game viewer. Step through the moves with ◀ ▶ below.</string>
|
||||
<string name="board_description">Board, position after %1$s</string>
|
||||
<string name="board_start">Board, starting position</string>
|
||||
<string name="white_won">White won</string>
|
||||
|
|
@ -50,12 +50,12 @@
|
|||
|
||||
<string name="engine">Engine</string>
|
||||
<string name="thinking">Thinking…</string>
|
||||
<string name="depth">d. %1$d</string>
|
||||
<string name="depth">depth %1$d</string>
|
||||
<string name="paused">paused</string>
|
||||
<string name="deeper">Deeper</string>
|
||||
<string name="more_lines">More lines</string>
|
||||
<string name="fewer_lines">Fewer lines</string>
|
||||
<string name="engine_not_answering">The engine is not answering</string>
|
||||
<string name="engine_not_answering">The engine is not responding</string>
|
||||
<string name="engine_not_starting">The engine does not start on this phone</string>
|
||||
<string name="restart">Restart</string>
|
||||
<string name="engine_line_preview">Engine line · move %1$d of %2$d</string>
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
<string name="engine_sheet_title">Stockfish engine</string>
|
||||
<string name="engine_sheet_text">Evaluates the position and shows the best moves. Works offline — it only has to be downloaded once.</string>
|
||||
<string name="engine_size">Size: %1$d MB</string>
|
||||
<string name="engine_metered">No Wi-Fi now: the download will go over mobile data.</string>
|
||||
<string name="engine_metered">No Wi-Fi now: the download will use mobile data.</string>
|
||||
<string name="not_now">Not now</string>
|
||||
<string name="download">Download</string>
|
||||
<string name="downloaded_of">Downloaded %1$d of %2$d MB</string>
|
||||
|
|
@ -71,9 +71,9 @@
|
|||
<string name="download_cancelled">Download cancelled</string>
|
||||
<string name="engine_ready">The engine is ready</string>
|
||||
<string name="no_internet">No internet. Connect to a network and try again.</string>
|
||||
<string name="interrupted">The download was interrupted. What came is kept.</string>
|
||||
<string name="interrupted">The download was interrupted. The downloaded part is kept.</string>
|
||||
<string name="no_space">Not enough space: %1$d MB needed.</string>
|
||||
<string name="corrupt">The engine file was damaged in the download. Download it again.</string>
|
||||
<string name="corrupt">The engine file was damaged during the download. Download it again.</string>
|
||||
<string name="retry">Try again</string>
|
||||
<string name="resume">Continue</string>
|
||||
<string name="download_again">Download again</string>
|
||||
|
|
@ -81,18 +81,17 @@
|
|||
<string name="preparing_engine">Preparing the engine…</string>
|
||||
|
||||
<string name="settings">Settings</string>
|
||||
<string name="group_look">Look</string>
|
||||
<string name="group_board">Board</string>
|
||||
<string name="group_look">Appearance</string>
|
||||
<string name="group_engine">Engine</string>
|
||||
<string name="theme">Theme</string>
|
||||
<string name="theme_system">As in the system</string>
|
||||
<string name="theme_system">System default</string>
|
||||
<string name="theme_light">Light</string>
|
||||
<string name="theme_dark">Dark</string>
|
||||
<string name="notation">Move notation</string>
|
||||
<string name="notation_latin">Latin letters (K Q R B N)</string>
|
||||
<string name="notation_figurines">Figurines</string>
|
||||
<string name="notation_local">Letters of the language</string>
|
||||
<string name="notation_hint">Only how moves look on the screen. PGN always keeps K Q R B N.</string>
|
||||
<string name="notation_hint">Display only. PGN always uses K Q R B N.</string>
|
||||
<string name="animation">Piece animation</string>
|
||||
<string name="best_arrow">Best-move arrow</string>
|
||||
<string name="vibration">Vibration</string>
|
||||
|
|
@ -101,7 +100,7 @@
|
|||
<string name="engine_missing">Not downloaded · Download (%1$d MB)</string>
|
||||
<string name="engine_downloading">Downloading… %1$d of %2$d MB</string>
|
||||
<string name="engine_delete">Delete the engine (frees %1$d MB)</string>
|
||||
<string name="engine_delete_question">Delete the engine? It can be downloaded again.</string>
|
||||
<string name="engine_delete_question">Delete the engine? You can download it again.</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="lines">Lines</string>
|
||||
<string name="time_per_position">Time per position</string>
|
||||
|
|
@ -111,11 +110,23 @@
|
|||
<string name="threads">Threads</string>
|
||||
<string name="memory">Memory</string>
|
||||
<string name="megabytes">%1$d MB</string>
|
||||
<string name="engine_battery">The engine uses the battery. It stops by itself when the screen goes dark.</string>
|
||||
<string name="engine_battery">The engine uses the battery. It stops by itself when the screen turns off.</string>
|
||||
<string name="about">About</string>
|
||||
<string name="build_full">Stockfish built in</string>
|
||||
<string name="build_light">Stockfish downloaded in the app</string>
|
||||
<string name="about_text">A viewer of chess databases: PGN, ChessBase, archives. Files are only read, never changed.</string>
|
||||
<string name="licenses">Licenses</string>
|
||||
<string name="licenses">Licenses and authors</string>
|
||||
<string name="website">Website and source code</string>
|
||||
|
||||
<string name="game_info">Game details</string>
|
||||
<string name="copy_pgn">Copy PGN</string>
|
||||
<string name="copy_fen">Copy FEN</string>
|
||||
<string name="share_game">Share game</string>
|
||||
<string name="copied">Copied</string>
|
||||
<string name="notes">Notes</string>
|
||||
<string name="engine_state_on">on</string>
|
||||
<string name="engine_state_off">off</string>
|
||||
<string name="engine_state_missing">not downloaded</string>
|
||||
<string name="found_of">Found %1$s of %2$s</string>
|
||||
<string name="group_game">Game</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="Theme.ChessPenguin" parent="android:Theme.Material.Light.NoActionBar" />
|
||||
</resources>
|
||||
<!-- The window before Compose draws, and the Android 12 splash screen (§10.7). -->
|
||||
<style name="Theme.ChessPenguin" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="android:windowBackground">#FFFFFF</item>
|
||||
<item name="android:windowSplashScreenBackground">#FFFFFF</item>
|
||||
<item name="android:windowSplashScreenIconBackgroundColor">@color/ic_launcher_background</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
|||
6
androidApp/app/src/main/res/xml/locales_config.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- The languages of the interface, for the per-app language in the system settings. -->
|
||||
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<locale android:name="en" />
|
||||
<locale android:name="ru" />
|
||||
</locale-config>
|
||||
27
androidApp/scripts/release.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
# Builds the two signed release APKs into androidApp/dist:
|
||||
# ChessPenguin-<version>-android.apk Stockfish built in ("full")
|
||||
# ChessPenguin-<version>-android-noengine.apk Stockfish downloaded in the app ("light")
|
||||
# The key comes from the environment or from ~/.config/chesspenguin/android/.env.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
env_file="${CP_SIGNING_ENV:-$HOME/.config/chesspenguin/android/.env}"
|
||||
if [[ -z "${CP_KEYSTORE:-}" && -f "${env_file}" ]]; then
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
source "${env_file}"
|
||||
set +a
|
||||
fi
|
||||
: "${CP_KEYSTORE:?no release key: set CP_KEYSTORE and the passwords, or CP_SIGNING_ENV}"
|
||||
./gradlew --console=plain assembleFullRelease assembleLightRelease
|
||||
version="$(sed -n 's/^version = "\(.*\)"/\1/p' ../Cargo.toml | head -n1)"
|
||||
mkdir -p dist
|
||||
cp app/build/outputs/apk/full/release/app-full-release.apk "dist/ChessPenguin-${version}-android.apk"
|
||||
cp app/build/outputs/apk/light/release/app-light-release.apk "dist/ChessPenguin-${version}-android-noengine.apk"
|
||||
build_tools="$(ls -d "${ANDROID_HOME:-$HOME/Android/Sdk}"/build-tools/* | sort -V | tail -n1)"
|
||||
for apk in dist/ChessPenguin-"${version}"-android*.apk; do
|
||||
"${build_tools}/apksigner" verify "${apk}"
|
||||
"${build_tools}/zipalign" -c -P 16 4 "${apk}"
|
||||
done
|
||||
(cd dist && sha256sum ChessPenguin-"${version}"-android*.apk > ChessPenguin-"${version}"-android.sha256)
|
||||
ls -l dist
|
||||