From 3596336cfe2f32a5d6ae65b1e6dd596e73d67445 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Mon, 26 Oct 2026 00:54:16 +0300 Subject: [PATCH] Android: new game, own databases (create, rename, export, delete), save and leave questions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Databases screen: «New game», «My databases» first, then «Files». A game being changed lives in a ViewModel (the phone may turn). Save puts an own game back in its place; a new game or a copy goes into an own database chosen once (or made there), later saves replace it. Leaving with changes asks only for own and new games. Co-Authored-By: Claude Opus 5.5 --- .../vrubelroman/chesspenguin/Navigation.kt | 8 + .../vrubelroman/chesspenguin/data/Library.kt | 49 +++- .../chesspenguin/ui/DatabasesScreen.kt | 211 +++++++++++++++++- .../vrubelroman/chesspenguin/ui/GameScreen.kt | 166 ++++++++++++-- .../vrubelroman/chesspenguin/ui/SaveGame.kt | 122 ++++++++++ .../app/src/main/res/values-de/strings.xml | 32 +++ .../app/src/main/res/values-es/strings.xml | 33 +++ .../app/src/main/res/values-fr/strings.xml | 33 +++ .../app/src/main/res/values-it/strings.xml | 33 +++ .../app/src/main/res/values-kk/strings.xml | 32 +++ .../app/src/main/res/values-pt/strings.xml | 33 +++ .../app/src/main/res/values-ru/strings.xml | 34 +++ .../app/src/main/res/values-uz/strings.xml | 32 +++ .../app/src/main/res/values/strings.xml | 32 +++ 14 files changed, 821 insertions(+), 29 deletions(-) create mode 100644 androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/SaveGame.kt diff --git a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/Navigation.kt b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/Navigation.kt index fcb12a2..e7b208c 100644 --- a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/Navigation.kt +++ b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/Navigation.kt @@ -39,6 +39,7 @@ import io.github.vrubelroman.chesspenguin.ui.BoardStyleScreen import io.github.vrubelroman.chesspenguin.ui.DatabasesScreen import io.github.vrubelroman.chesspenguin.ui.SettingsScreen import io.github.vrubelroman.chesspenguin.ui.GameScreen +import io.github.vrubelroman.chesspenguin.ui.NEW_GAME import io.github.vrubelroman.chesspenguin.ui.GamesScreen import io.github.vrubelroman.chesspenguin.ui.OnlineScreen import kotlinx.serialization.Serializable @@ -51,6 +52,9 @@ import kotlinx.serialization.Serializable /// the same game comes back after Android restarts the app). @Serializable data class GameAt(val db: String, val place: Int, val query: String = "") : NavKey +/// A new game from the start position (android-play.md §30.4). +@Serializable data object NewGameKey : NavKey + @Serializable data object SettingsKey : NavKey @Serializable data object AboutKey : NavKey @@ -114,8 +118,12 @@ fun MainNavigation() { onAdded = ::show, onSettings = { backStack.add(SettingsKey) }, onOnline = { backStack.add(OnlineKey) }, + onNewGame = { backStack.add(NewGameKey) }, ) } + entry { + GameScreen(NEW_GAME, 0, "", onBack = { backStack.removeLastOrNull() }, onSettings = { backStack.add(SettingsKey) }) + } entry { key -> GamesScreen(key.db, onBack = { backStack.removeLastOrNull() }, onGame = { place, query -> backStack.add(GameAt(key.db, place, query)) }) } diff --git a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/data/Library.kt b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/data/Library.kt index 9d2f866..b9d11cf 100644 --- a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/data/Library.kt +++ b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/data/Library.kt @@ -20,6 +20,10 @@ import uniffi.mobile_api.FolderFile import uniffi.mobile_api.openBytes import uniffi.mobile_api.openChessbase import uniffi.mobile_api.openFile +import uniffi.mobile_api.openPath +import uniffi.mobile_api.ownCreate +import uniffi.mobile_api.ownRemove +import uniffi.mobile_api.ownSave import java.io.File import java.util.UUID @@ -43,9 +47,13 @@ enum class Source { /// A player's games downloaded from Lichess and Chess.com (`files/online/`, with the /// state of the download beside it, android-ui.md §23). Online, + + /// The user's own database (`files/own/`, android-play.md §30): the only file the app + /// writes, and only on "Save". + Own, } -/// A database on the list. The file itself is never changed. +/// A database on the list. Its file is never changed, except an own database's. @Serializable data class DbEntry( val id: String, @@ -119,6 +127,8 @@ class Library(private val context: Context) { private val copies = File(context.filesDir, "copies") /// Downloaded databases (android-ui.md §23). val onlineDir = File(context.filesDir, "online") + /// The user's own databases (android-play.md §30). + val ownDir = File(context.filesDir, "own") private val json = Json { ignoreUnknownKeys = true } private val _entries = MutableStateFlow(load()) val entries: StateFlow> = _entries.asStateFlow() @@ -291,6 +301,36 @@ class Library(private val context: Context) { /// The file of a downloaded database. fun onlineFile(e: DbEntry): File = File(onlineDir, e.location) + /// The file of an own database. + fun ownFile(e: DbEntry): File = File(ownDir, e.location) + + /// A new empty own database named `name`, first among the own ones. + suspend fun createOwn(name: String): DbEntry = withContext(Dispatchers.IO) { + val id = UUID.randomUUID().toString() + val entry = DbEntry(id = id, name = name, source = Source.Own, location = "$id.pgn", fileName = "$id.pgn", games = 0, format = "PGN") + ownCreate(ownFile(entry).path) + update { list -> listOf(entry) + list } + entry + } + + /// Saves the game `pgn` into the own database `id`: as game `index`, or at the end. + /// Returns its number; the database is read again when next opened. + suspend fun saveOwn(id: String, index: UInt?, pgn: String): UInt = lock.withLock { + val e = entry(id)?.takeIf { it.source == Source.Own } ?: throw IllegalArgumentException("not an own database") + val n = withContext(Dispatchers.IO) { ownSave(ownFile(e).path, index, pgn) } + open.remove(id) + update { list -> list.map { if (it.id == id) it.copy(games = if (index == null) (it.games ?: 0) + 1 else it.games) else it } } + n + } + + /// Takes game `index` out of the own database `id`. + suspend fun removeOwnGame(id: String, index: UInt) = lock.withLock { + val e = entry(id)?.takeIf { it.source == Source.Own } ?: return@withLock + withContext(Dispatchers.IO) { ownRemove(ownFile(e).path, index) } + open.remove(id) + update { list -> list.map { if (it.id == id) it.copy(games = ((it.games ?: 1) - 1).coerceAtLeast(0)) else it } } + } + /// Puts a downloaded database (a file of [onlineDir]) on the list, or gives its entry. fun addOnline(file: File): DbEntry = synchronized(this) { _entries.value.firstOrNull { it.source == Source.Online && it.location == file.name }?.let { return it } @@ -351,6 +391,12 @@ class Library(private val context: Context) { uniffi.mobile_api.deleteOnlineDatabase(onlineFile(entry).path) return } + // The only copy of the user's games: gone once "Undo" is (asked before when not + // empty, android-play.md §30.3). + if (entry.source == Source.Own) { + ownFile(entry).delete() + return + } // The permission of a folder is given back with the last of its databases, also // counting those whose "Undo" is still offered. val granted = entry.tree ?: entry.location @@ -544,6 +590,7 @@ class Library(private val context: Context) { e.fileName, android.os.ParcelFileDescriptor.open(onlineFile(e), android.os.ParcelFileDescriptor.MODE_READ_ONLY).detachFd(), ) + Source.Own -> openPath(ownFile(e).path) } } } diff --git a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/DatabasesScreen.kt b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/DatabasesScreen.kt index 8594dfa..cdfb7d2 100644 --- a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/DatabasesScreen.kt +++ b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/DatabasesScreen.kt @@ -22,12 +22,19 @@ import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.foundation.background +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.ui.draw.clip +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext import androidx.compose.material.icons.Icons import androidx.compose.material.icons.rounded.Add +import androidx.compose.material.icons.rounded.EditNote import androidx.compose.material.icons.rounded.MoreVert import androidx.compose.material.icons.rounded.Settings import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button +import androidx.compose.material3.FilledTonalButton import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.ExperimentalMaterial3Api @@ -82,7 +89,7 @@ import kotlinx.coroutines.launch /// The first screen: the databases on the list (android-ui.md §3). @OptIn(ExperimentalMaterial3Api::class) @Composable -fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSettings: () -> Unit, onOnline: () -> Unit) { +fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSettings: () -> Unit, onOnline: () -> Unit, onNewGame: () -> Unit) { val library = app().library val downloads = app().downloads val views by downloads.views.collectAsState() @@ -91,6 +98,7 @@ fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSett val scope = rememberCoroutineScope() val removedText = stringResource(R.string.removed) val removedCopyText = stringResource(R.string.removed_copy) + val removedOwnText = stringResource(R.string.own_removed) val update = shownUpdate() val offersOffText = stringResource(R.string.upd_offers_off_snack) val offersUndoText = stringResource(R.string.undo) @@ -141,6 +149,29 @@ fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSett } val add = { choosing = true } var renaming by remember { mutableStateOf(null) } + // Own databases (android-play.md §30): a new one asked for, one to delete asked about. + var creating by remember { mutableStateOf(false) } + var deleting by remember { mutableStateOf(null) } + var exporting by remember { mutableStateOf(null) } + val context = androidx.compose.ui.platform.LocalContext.current + val exportedText = stringResource(R.string.own_exported) + val exportFailedText = stringResource(R.string.own_export_failed) + val export = rememberLauncherForActivityResult(ActivityResultContracts.CreateDocument("application/x-chess-pgn")) { uri -> + val e = exporting + exporting = null + if (uri == null || e == null) return@rememberLauncherForActivityResult + scope.launch { + val ok = withContext(Dispatchers.IO) { + runCatching { + context.contentResolver.openOutputStream(uri, "wt")!!.use { out -> library.ownFile(e).inputStream().use { it.copyTo(out) } } + }.isSuccess + } + snackbar.currentSnackbarData?.dismiss() + snackbar.showSnackbar(if (ok) exportedText else exportFailedText) + } + } + val own = entries.filter { it.source == Source.Own } + val files = entries.filter { it.source != Source.Own } val list = rememberLazyListState() // The card comes when GitHub answers, after the list is drawn: a list at its top then // keeps its first database in place and the card lands above the screen. It is @@ -198,7 +229,71 @@ fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSett ) { // A newer version of the app (android-ui.md §25.2): the first item of the list. update?.let { u -> item(key = "update") { UpdateCard(u, onDismissed = onUpdateDismissed, modifier = Modifier.animateItem()) } } - items(entries, key = { it.id }) { e -> + item(key = "actions") { + Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { + FilledTonalButton(onClick = onNewGame, modifier = Modifier.height(48.dp)) { + Icon(Icons.Rounded.Add, null) + Spacer(Modifier.size(8.dp)) + Text(stringResource(R.string.new_game)) + } + } + } + item(key = "own-head") { + Row(Modifier.fillMaxWidth().height(48.dp).padding(start = 16.dp, end = 4.dp), verticalAlignment = Alignment.CenterVertically) { + Text(stringResource(R.string.own_databases), Modifier.weight(1f), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary) + TextButton(onClick = { creating = true }) { Text(stringResource(R.string.own_new)) } + } + } + if (own.isEmpty()) { + item(key = "own-empty") { + Text( + stringResource(R.string.own_empty), + Modifier.padding(start = 16.dp, end = 16.dp, bottom = 8.dp), + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + } + items(own, key = { it.id }) { e -> + OwnRow( + e, + onOpen = { onOpen(e.id) }, + onRename = { renaming = e }, + onExport = { + exporting = e + export.launch(e.name + ".pgn") + }, + onDelete = { + if ((e.games ?: 0) == 0) { + val removed = library.remove(e.id) ?: return@OwnRow + scope.launch { + snackbar.currentSnackbarData?.dismiss() + var restored = false + try { + if (snackbar.showSnackbar(removedOwnText, undoText, withDismissAction = false, duration = SnackbarDuration.Long) == SnackbarResult.ActionPerformed) { + library.restore(removed.first, removed.second) + restored = true + } + } finally { + if (!restored) library.forget(removed.second) + } + } + } else { + deleting = e + } + }, + modifier = Modifier.animateItem(), + ) + } + item(key = "files-head") { + Text( + stringResource(R.string.files), + Modifier.fillMaxWidth().padding(start = 16.dp, top = 16.dp, bottom = 8.dp), + style = MaterialTheme.typography.titleSmall, + color = MaterialTheme.colorScheme.primary, + ) + } + items(files, key = { it.id }) { e -> DatabaseRow( e, download = views[e.id], @@ -237,7 +332,6 @@ fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSett } } } - val context = androidx.compose.ui.platform.LocalContext.current val pasteNone = stringResource(R.string.paste_none) val resources = LocalResources.current if (choosing) { @@ -304,11 +398,115 @@ fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSett ) } renaming?.let { e -> - RenameDialog(displayName(e), onDismiss = { renaming = null }, onSave = { + RenameDialog(displayName(e), own = e.source == Source.Own, onDismiss = { renaming = null }, onSave = { library.rename(e.id, it) renaming = null }) } + if (creating) { + NewOwnDialog( + suggested = freeName(stringResource(R.string.own_default_name), own.map { it.name }), + onDismiss = { creating = false }, + onCreate = { name -> + creating = false + scope.launch { runCatching { library.createOwn(name) } } + }, + ) + } + deleting?.let { e -> + val n = e.games ?: 0 + AlertDialog( + onDismissRequest = { deleting = null }, + title = { Text(stringResource(R.string.own_delete_title, displayName(e))) }, + text = { Text(pluralStringResource(R.plurals.own_delete_text, n, groupDigits(n))) }, + confirmButton = { + TextButton(onClick = { + deleting = null + library.remove(e.id)?.let { library.forget(it.second) } + }) { Text(stringResource(R.string.delete), color = MaterialTheme.colorScheme.error) } + }, + dismissButton = { TextButton(onClick = { deleting = null }) { Text(stringResource(R.string.cancel)) } }, + ) + } +} + +/// "My games", or "My games 2" when that one is taken. +private fun freeName(base: String, taken: List): String { + if (base !in taken) return base + var i = 2 + while ("$base $i" in taken) i++ + return "$base $i" +} + +@Composable +private fun NewOwnDialog(suggested: String, onDismiss: () -> Unit, onCreate: (String) -> Unit) { + var value by remember { mutableStateOf(TextFieldValue(suggested, TextRange(0, suggested.length))) } + val trimmed = value.text.trim() + AlertDialog( + onDismissRequest = onDismiss, + title = { Text(stringResource(R.string.own_new_title)) }, + text = { + OutlinedTextField( + value = value, + onValueChange = { value = it }, + singleLine = true, + label = { Text(stringResource(R.string.own_name)) }, + supportingText = { Text(stringResource(R.string.own_new_hint)) }, + ) + }, + confirmButton = { TextButton(onClick = { onCreate(trimmed) }, enabled = trimmed.isNotEmpty()) { Text(stringResource(R.string.create)) } }, + dismissButton = { TextButton(onClick = onDismiss) { Text(stringResource(R.string.cancel)) } }, + ) +} + +/// An own database: its games are the user's, kept on the phone (android-play.md §30.2). +@OptIn(ExperimentalFoundationApi::class) +@Composable +private fun OwnRow(e: DbEntry, onOpen: () -> Unit, onRename: () -> Unit, onExport: () -> Unit, onDelete: () -> Unit, modifier: Modifier) { + var menu by remember { mutableStateOf(false) } + val n = e.games ?: 0 + Box(modifier) { + Row( + Modifier + .fillMaxWidth() + .height(72.dp) + .combinedClickable(onClick = onOpen, onLongClick = { menu = true }) + .padding(start = 16.dp, end = 4.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Box( + Modifier.size(40.dp).clip(RoundedCornerShape(8.dp)).background(MaterialTheme.colorScheme.primaryContainer), + contentAlignment = Alignment.Center, + ) { Icon(Icons.Rounded.EditNote, null, tint = MaterialTheme.colorScheme.onPrimaryContainer) } + Column(Modifier.weight(1f).padding(start = 16.dp)) { + Text(displayName(e), style = MaterialTheme.typography.bodyLarge, maxLines = 1, overflow = TextOverflow.Ellipsis) + Text( + pluralStringResource(R.plurals.games_count, n, groupDigits(n)) + " · " + stringResource(R.string.own_on_phone), + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onSurfaceVariant, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + } + 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.rename)) }, onClick = { + menu = false + onRename() + }) + DropdownMenuItem(text = { Text(stringResource(R.string.own_export)) }, onClick = { + menu = false + onExport() + }) + DropdownMenuItem(text = { Text(stringResource(R.string.own_delete)) }, onClick = { + menu = false + onDelete() + }) + } + } + } + } } @Composable @@ -425,7 +623,7 @@ private fun DatabaseRow( } @Composable -private fun RenameDialog(name: String, onDismiss: () -> Unit, onSave: (String) -> Unit) { +private fun RenameDialog(name: String, own: Boolean = false, onDismiss: () -> Unit, onSave: (String) -> Unit) { var value by remember { mutableStateOf(TextFieldValue(name, TextRange(0, name.length))) } val trimmed = value.text.trim() AlertDialog( @@ -436,7 +634,8 @@ private fun RenameDialog(name: String, onDismiss: () -> Unit, onSave: (String) - value = value, onValueChange = { value = it }, singleLine = true, - supportingText = { Text(stringResource(R.string.rename_hint)) }, + // An own database's file is ours: no "the file does not change". + supportingText = if (own) null else { { Text(stringResource(R.string.rename_hint)) } }, ) }, confirmButton = { TextButton(onClick = { onSave(trimmed) }, enabled = trimmed.isNotEmpty()) { Text(stringResource(R.string.save)) } }, diff --git a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/GameScreen.kt b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/GameScreen.kt index 65bc561..32c4d1e 100644 --- a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/GameScreen.kt +++ b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/GameScreen.kt @@ -38,6 +38,7 @@ import androidx.compose.material.icons.automirrored.rounded.ArrowBack import androidx.compose.material.icons.outlined.Memory import androidx.compose.material.icons.rounded.ChevronLeft import androidx.compose.material.icons.rounded.Close +import androidx.compose.material.icons.rounded.Save import androidx.compose.material.icons.rounded.VerticalAlignTop import androidx.compose.material.icons.rounded.ChevronRight import androidx.compose.material.icons.rounded.Download @@ -103,6 +104,8 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.lifecycle.viewmodel.compose.viewModel +import io.github.vrubelroman.chesspenguin.data.Source import io.github.vrubelroman.chesspenguin.R import io.github.vrubelroman.chesspenguin.data.EngineSession import io.github.vrubelroman.chesspenguin.data.NetState @@ -139,12 +142,12 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o val dbEntry = libraryEntries.firstOrNull { it.id == db } var games by remember { mutableStateOf(app.shown[db]) } var place by rememberSaveable { mutableIntStateOf(startPlace) } - var game by remember { mutableStateOf(null) } - // The game as changed on the board (android-play.md §29): moves for analysis; a game - // of someone else's file is not saved (owner's decision), its file never changes. - var edit by remember { mutableStateOf(null) } - // What reading the game noticed: kept when the game is changed. - var notes by remember { mutableStateOf>(emptyList()) } + // The game as changed on the board (android-play.md §29), kept while the phone turns: + // a game of someone else's file is changed for analysis and never written there. + val held: GameEdit = viewModel() + var game by held.data + var edit by held.session + val newGame = db == NEW_GAME var failed by remember { mutableStateOf(false) } var current by rememberSaveable(place) { mutableIntStateOf(0) } var flipped by rememberSaveable { mutableStateOf(false) } @@ -153,6 +156,14 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o val review = remember { ReviewSession(java.io.File(context.cacheDir, "analysis").path, app.scope) } LaunchedEffect(db, place) { preview = null + if (newGame) { + if (held.key != NEW_GAME) { + held.key = NEW_GAME + edit = GameSession.newGame(java.text.SimpleDateFormat("yyyy.MM.dd", java.util.Locale.ROOT).format(java.util.Date())) + game = edit?.data() + } + return@LaunchedEffect + } val database = app.library.database(db).getOrNull() if (database == null) { failed = true @@ -164,13 +175,19 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o app.shown[db] = it } val index = list.getOrNull(place) ?: return@LaunchedEffect - game = null - edit = null - val loaded = withContext(Dispatchers.Default) { runCatching { database.game(index) to database.session(index) } } - failed = loaded.isFailure - game = loaded.getOrNull()?.first - edit = loaded.getOrNull()?.second - notes = game?.notes ?: emptyList() + val key = "$db/$index" + // The phone turned: the game as it was changed is still there. + if (held.key != key || edit == null) { + game = null + edit = null + held.savedTo = null + val loaded = withContext(Dispatchers.Default) { runCatching { database.game(index) to database.session(index) } } + failed = loaded.isFailure + game = loaded.getOrNull()?.first + edit = loaded.getOrNull()?.second + held.notes = game?.notes ?: emptyList() + held.key = key + } if (game != null) review.open(db, database, index) } val pieces = remember { Pieces(context) } @@ -359,7 +376,7 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o // A change of the game: shown at once, the cursor where the change says. fun apply(e: Edited) { preview = null - game = e.data.copy(notes = notes) + game = e.data.copy(notes = held.notes) current = e.cursor.toInt() } // The move sheet of a long press on a move (§29.6): which move. @@ -369,6 +386,53 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o fun undo() { edit?.undo()?.let { apply(it) } } + + // Saving (android-play.md §30.4): an own database's game in its place; a new game or + // a copy of someone else's into an own database chosen once, then in its place there. + val ownGame = dbEntry?.source == Source.Own && !newGame + var saves by remember { mutableIntStateOf(0) } + @Suppress("UNUSED_EXPRESSION") saves + val modified = g != null && edit?.isModified() == true + var saving by remember { mutableStateOf(false) } + var leaving by remember { mutableStateOf(false) } + var afterSave by remember { mutableStateOf<(() -> Unit)?>(null) } + val ownEntries = libraryEntries.filter { it.source == Source.Own } + val savedText = stringResource(R.string.saved_to) + val saveFailedText = stringResource(R.string.save_failed) + val lastOwn = remember { context.getSharedPreferences("own", Context.MODE_PRIVATE) } + fun saveInto(id: String, index: UInt?) { + val e = edit ?: return + val then = afterSave + afterSave = null + scope.launch { + val pgn = withContext(Dispatchers.Default) { e.pgn() } + val done = runCatching { app.library.saveOwn(id, index, pgn) } + snackbar.currentSnackbarData?.dismiss() + done.onSuccess { n -> + e.markSaved() + saves++ + if (!ownGame) held.savedTo = id to n + lastOwn.edit().putString("last", id).apply() + val name = app.library.entry(id)?.name ?: "" // own databases: their own names + then?.invoke() ?: snackbar.showSnackbar(String.format(savedText, name, (n + 1u).toString())) + }.onFailure { snackbar.showSnackbar(saveFailedText) } + } + } + fun save(then: (() -> Unit)? = null) { + afterSave = then + val to = held.savedTo + when { + ownGame -> games?.getOrNull(place)?.let { saveInto(db, it) } + to != null -> saveInto(to.first, to.second) + else -> saving = true + } + } + // Leaving with changes asks only where they are the user's to keep (an own game, a + // new one); moves in someone else's game are for trying out (owner's decision). + val asksOnLeave = modified && (ownGame || newGame) + fun leave() { + if (asksOnLeave) leaving = true else onBack() + } fun go(to: Int) { preview = null if (nodes == null || to == current || to !in nodes.indices) return @@ -420,6 +484,7 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o } } BackHandler(preview != null) { preview = null } + BackHandler(preview == null && asksOnLeave) { leaving = true } val landscape = LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE val controls: @Composable (Modifier) -> Unit = { modifier -> @@ -588,14 +653,18 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o topBar = { TopAppBar( navigationIcon = { - IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Rounded.ArrowBack, stringResource(R.string.back)) } + IconButton(onClick = ::leave) { Icon(Icons.AutoMirrored.Rounded.ArrowBack, stringResource(R.string.back)) } }, title = { // The event and year (else the site); the game's place and round. A tap // shows the game's details. // No event and no site: the database's name. - val event = joinKnown(tag("Event"), year(tag("Date"))).ifEmpty { joinKnown(tag("Site")) } - .ifEmpty { dbEntry?.let { displayName(it) } ?: "" } + val event = if (newGame && held.savedTo == null) { + stringResource(R.string.new_game) + } else { + joinKnown(tag("Event"), year(tag("Date"))).ifEmpty { joinKnown(tag("Site")) } + .ifEmpty { dbEntry?.let { displayName(it) } ?: "" } + } val round = tag("Round").trim().takeIf { it.isNotEmpty() && it != "?" && it != "-" } val placeLine = joinKnown( if (total > 0) stringResource(R.string.game_of, place + 1, total) else "", @@ -626,11 +695,20 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o } }, actions = { - IconButton(onClick = { place -= 1 }, enabled = place > 0) { - Icon(Icons.Rounded.ChevronLeft, stringResource(R.string.previous_game)) - } - IconButton(onClick = { place += 1 }, enabled = place + 1 < total) { - Icon(Icons.Rounded.ChevronRight, stringResource(R.string.next_game)) + // Changes not saved: "Save" in place of ‹ › (they would need a decision). + if (modified) { + val where = when { + ownGame -> dbEntry?.let { stringResource(R.string.save_in, displayName(it)) } + else -> held.savedTo?.first?.let { app.library.entry(it) }?.let { stringResource(R.string.save_in, displayName(it)) } + } ?: stringResource(R.string.save_to_mine) + IconButton(onClick = { save() }) { Icon(Icons.Rounded.Save, where) } + } else if (!newGame) { + IconButton(onClick = { place -= 1 }, enabled = place > 0) { + Icon(Icons.Rounded.ChevronLeft, stringResource(R.string.previous_game)) + } + IconButton(onClick = { place += 1 }, enabled = place + 1 < total) { + Icon(Icons.Rounded.ChevronRight, stringResource(R.string.next_game)) + } } Box { IconButton(onClick = { menu = true }) { Icon(Icons.Rounded.MoreVert, stringResource(R.string.menu)) } @@ -754,6 +832,50 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o confirmButton = { TextButton(onClick = { info = false }) { Text(stringResource(R.string.close)) } }, ) } + if (saving) { + SaveSheet( + own = ownEntries, + last = lastOwn.getString("last", null), + onSave = { e -> + saving = false + saveInto(e.id, null) + }, + onCreate = { name -> + saving = false + scope.launch { runCatching { app.library.createOwn(name) }.onSuccess { saveInto(it.id, null) } } + }, + onDismiss = { + saving = false + afterSave = null + }, + ) + } + if (leaving) { + AlertDialog( + onDismissRequest = { leaving = false }, + title = { + Text( + if (ownGame) stringResource(R.string.save_changes_in, dbEntry?.let { displayName(it) } ?: "") + else stringResource(R.string.save_game_question), + ) + }, + confirmButton = { + TextButton(onClick = { + leaving = false + save(then = onBack) + }) { Text(stringResource(if (ownGame || held.savedTo != null) R.string.save else R.string.save_to_db_ellipsis)) } + }, + dismissButton = { + Row { + TextButton(onClick = { + leaving = false + onBack() + }) { Text(stringResource(R.string.dont_save)) } + TextButton(onClick = { leaving = false }) { Text(stringResource(R.string.cancel)) } + } + }, + ) + } val sheetMove = moveSheet if (sheetMove != null && g != null && edit != null) { val n = g.nodes.getOrNull(sheetMove) diff --git a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/SaveGame.kt b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/SaveGame.kt new file mode 100644 index 0000000..14dcce4 --- /dev/null +++ b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/SaveGame.kt @@ -0,0 +1,122 @@ +package io.github.vrubelroman.chesspenguin.ui + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.selection.selectable +import androidx.compose.foundation.selection.selectableGroup +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.rounded.Add +import androidx.compose.material3.Button +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ModalBottomSheet +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.RadioButton +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.pluralStringResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.lifecycle.ViewModel +import io.github.vrubelroman.chesspenguin.R +import io.github.vrubelroman.chesspenguin.data.DbEntry +import uniffi.mobile_api.GameData +import uniffi.mobile_api.GameSession + +/// The game of a game screen as it is being changed (android-play.md §29–30), kept while +/// the phone turns: the screen is made again, the moves stay. +class GameEdit : ViewModel() { + /// Which game: "database/index", or [NEW_GAME]. + var key: String? = null + val session = mutableStateOf(null) + val data = mutableStateOf(null) + /// What reading the game noticed: kept when the game is changed. + var notes: List = emptyList() + /// Where a new game or a copy was saved: saving again replaces it there. + var savedTo: Pair? = null + + override fun onCleared() { + session.value?.close() + } +} + +/// The key of a new game (a game screen without a database). +const val NEW_GAME = "new" + +/// «Save to a database» (android-play.md §30.6): the own databases to choose from (the +/// last one used first), or a new one named here. +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun SaveSheet(own: List, last: String?, onSave: (DbEntry) -> Unit, onCreate: (String) -> Unit, onDismiss: () -> Unit) { + var chosen by remember { mutableStateOf(own.firstOrNull { it.id == last }?.id ?: own.firstOrNull()?.id) } + var creating by remember { mutableStateOf(own.isEmpty()) } + val defaultName = stringResource(R.string.own_default_name) + var name by remember { mutableStateOf(defaultName) } + ModalBottomSheet(onDismissRequest = onDismiss) { + Column(Modifier.fillMaxWidth().padding(bottom = 24.dp)) { + Text(stringResource(R.string.save_to_db), style = MaterialTheme.typography.titleLarge, modifier = Modifier.padding(horizontal = 24.dp, vertical = 8.dp)) + Column(Modifier.selectableGroup()) { + for (e in own) { + val n = e.games ?: 0 + Row( + Modifier + .fillMaxWidth() + .height(56.dp) + .selectable(selected = !creating && chosen == e.id, role = Role.RadioButton) { + creating = false + chosen = e.id + } + .padding(horizontal = 16.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + RadioButton(selected = !creating && chosen == e.id, onClick = null) + Text(displayName(e), Modifier.weight(1f).padding(start = 16.dp), maxLines = 1, overflow = TextOverflow.Ellipsis) + Text(pluralStringResource(R.plurals.games_count, n, groupDigits(n)), color = MaterialTheme.colorScheme.onSurfaceVariant, style = MaterialTheme.typography.bodyMedium) + } + } + } + if (own.isNotEmpty() && !creating) { + Row( + Modifier.fillMaxWidth().height(56.dp).clickable { creating = true }.padding(horizontal = 24.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Icon(Icons.Rounded.Add, null, tint = MaterialTheme.colorScheme.onSurfaceVariant) + Text(stringResource(R.string.own_new_ellipsis), Modifier.padding(start = 16.dp)) + } + } + if (creating) { + OutlinedTextField( + value = name, + onValueChange = { name = it }, + singleLine = true, + label = { Text(stringResource(R.string.own_name)) }, + modifier = Modifier.fillMaxWidth().padding(horizontal = 24.dp, vertical = 8.dp), + ) + } + Spacer(Modifier.size(8.dp)) + Row(Modifier.fillMaxWidth().padding(horizontal = 24.dp), horizontalArrangement = Arrangement.End) { + if (creating) { + Button(onClick = { onCreate(name.trim()) }, enabled = name.isNotBlank()) { Text(stringResource(R.string.create_and_save)) } + } else { + Button(onClick = { own.firstOrNull { it.id == chosen }?.let(onSave) }, enabled = chosen != null) { Text(stringResource(R.string.save)) } + } + } + } + } +} diff --git a/androidApp/app/src/main/res/values-de/strings.xml b/androidApp/app/src/main/res/values-de/strings.xml index c8081a1..33fc619 100644 --- a/androidApp/app/src/main/res/values-de/strings.xml +++ b/androidApp/app/src/main/res/values-de/strings.xml @@ -393,4 +393,36 @@ Zur Hauptvariante machen Zug und Fortsetzung löschen Aktionen zum Zug + Neue Partie + Meine Datenbanken + + Neue Datenbank + Hier stehen die Partien, die Sie eingeben oder gegen Maia spielen + Dateien + Meine Partien + Neue Datenbank + Name + Wird auf dem Telefon in ChessPenguin gespeichert. Die Datei lässt sich im Menü der Datenbank exportieren. + Erstellen + auf dem Telefon + Datei exportieren… + Datenbank löschen + Datei gespeichert + Die Datei konnte nicht gespeichert werden + Datenbank gelöscht + „%1$s“ löschen? + + %1$s Partie wird vom Telefon gelöscht. Wenn Sie sie brauchen, exportieren Sie zuerst die Datei. + %1$s Partien werden vom Telefon gelöscht. Wenn Sie sie brauchen, exportieren Sie zuerst die Datei. + + In „%1$s“ gespeichert, Nr. %2$s + Die Partie konnte nicht gespeichert werden + In „%1$s“ speichern + In meiner Datenbank speichern… + In einer Datenbank speichern + In einer Datenbank speichern… + Neue Datenbank… + Erstellen und speichern + Änderungen in „%1$s“ speichern? + Partie speichern? + Nicht speichern diff --git a/androidApp/app/src/main/res/values-es/strings.xml b/androidApp/app/src/main/res/values-es/strings.xml index 2b9b2c1..138b305 100644 --- a/androidApp/app/src/main/res/values-es/strings.xml +++ b/androidApp/app/src/main/res/values-es/strings.xml @@ -399,4 +399,37 @@ Convertir en línea principal Eliminar la jugada y lo que sigue Acciones de la jugada + Nueva partida + Mis bases + + Nueva base + Aquí estarán las partidas que introduzcas o juegues contra Maia + Archivos + Mis partidas + Nueva base + Nombre + Se guarda en el teléfono, en ChessPenguin. El archivo se exporta desde el menú de la base. + Crear + en el teléfono + Exportar el archivo… + Eliminar la base + Archivo guardado + No se pudo guardar el archivo + Base eliminada + ¿Eliminar «%1$s»? + + Se eliminará %1$s partida del teléfono. Si la necesitas, exporta antes el archivo. + Se eliminarán %1$s partidas del teléfono. Si las necesitas, exporta antes el archivo. + Se eliminarán %1$s partidas del teléfono. Si las necesitas, exporta antes el archivo. + + Guardada en «%1$s», n.º %2$s + No se pudo guardar la partida + Guardar en «%1$s» + Guardar en mi base… + Guardar en una base + Guardar en una base… + Nueva base… + Crear y guardar + ¿Guardar los cambios en «%1$s»? + ¿Guardar la partida? + No guardar diff --git a/androidApp/app/src/main/res/values-fr/strings.xml b/androidApp/app/src/main/res/values-fr/strings.xml index 37cb7da..d014e0a 100644 --- a/androidApp/app/src/main/res/values-fr/strings.xml +++ b/androidApp/app/src/main/res/values-fr/strings.xml @@ -399,4 +399,37 @@ En faire la ligne principale Supprimer le coup et la suite Actions sur le coup + Nouvelle partie + Mes bases + + Nouvelle base + Ici seront les parties que vous saisirez ou jouerez contre Maia + Fichiers + Mes parties + Nouvelle base + Nom + Conservée sur le téléphone, dans ChessPenguin. Le fichier s’exporte depuis le menu de la base. + Créer + sur le téléphone + Exporter le fichier… + Supprimer la base + Fichier enregistré + Impossible d’enregistrer le fichier + Base supprimée + Supprimer « %1$s » ? + + %1$s partie sera supprimée du téléphone. Si vous en avez besoin, exportez d’abord le fichier. + %1$s parties seront supprimées du téléphone. Si vous en avez besoin, exportez d’abord le fichier. + %1$s parties seront supprimées du téléphone. Si vous en avez besoin, exportez d’abord le fichier. + + Enregistrée dans « %1$s », n° %2$s + Impossible d’enregistrer la partie + Enregistrer dans « %1$s » + Enregistrer dans ma base… + Enregistrer dans une base + Enregistrer dans une base… + Nouvelle base… + Créer et enregistrer + Enregistrer les modifications dans « %1$s » ? + Enregistrer la partie ? + Ne pas enregistrer diff --git a/androidApp/app/src/main/res/values-it/strings.xml b/androidApp/app/src/main/res/values-it/strings.xml index 27356d6..1f24454 100644 --- a/androidApp/app/src/main/res/values-it/strings.xml +++ b/androidApp/app/src/main/res/values-it/strings.xml @@ -399,4 +399,37 @@ Rendi linea principale Elimina la mossa e il seguito Azioni sulla mossa + Nuova partita + I miei database + + Nuovo database + Qui ci saranno le partite che inserisci o giochi contro Maia + File + Le mie partite + Nuovo database + Nome + Conservato sul telefono, in ChessPenguin. Il file si esporta dal menu del database. + Crea + sul telefono + Esporta il file… + Elimina il database + File salvato + Impossibile salvare il file + Database eliminato + Eliminare «%1$s»? + + %1$s partita sarà eliminata dal telefono. Se ti serve, esporta prima il file. + %1$s partite saranno eliminate dal telefono. Se ti servono, esporta prima il file. + %1$s partite saranno eliminate dal telefono. Se ti servono, esporta prima il file. + + Salvata in «%1$s», n. %2$s + Impossibile salvare la partita + Salva in «%1$s» + Salva nel mio database… + Salva in un database + Salva in un database… + Nuovo database… + Crea e salva + Salvare le modifiche in «%1$s»? + Salvare la partita? + Non salvare diff --git a/androidApp/app/src/main/res/values-kk/strings.xml b/androidApp/app/src/main/res/values-kk/strings.xml index c508c60..72defcb 100644 --- a/androidApp/app/src/main/res/values-kk/strings.xml +++ b/androidApp/app/src/main/res/values-kk/strings.xml @@ -394,4 +394,36 @@ Негізгі ету Жүрісті және жалғасын жою Жүріспен әрекеттер + Жаңа ойын + Менің базаларым + + Жаңа база + Мұнда сіз енгізген немесе Maia-мен ойнаған ойындар болады + Файлдар + Менің ойындарым + Жаңа база + Атауы + Телефонда, ChessPenguin ішінде сақталады. Файлды база мәзірінен экспорттауға болады. + Құру + телефонда + Файлды экспорттау… + Базаны жою + Файл сақталды + Файлды сақтау мүмкін болмады + База жойылды + «%1$s» жойылсын ба? + + Телефоннан %1$s ойын жойылады. Керек болса, алдымен файлды экспорттаңыз. + Телефоннан %1$s ойын жойылады. Керек болса, алдымен файлды экспорттаңыз. + + «%1$s» ішіне сақталды, № %2$s + Ойынды сақтау мүмкін болмады + «%1$s» ішіне сақтау + Менің базама сақтау… + Базаға сақтау + Базаға сақтау… + Жаңа база… + Құру және сақтау + Өзгерістер «%1$s» ішіне сақталсын ба? + Ойын сақталсын ба? + Сақтамау diff --git a/androidApp/app/src/main/res/values-pt/strings.xml b/androidApp/app/src/main/res/values-pt/strings.xml index 304f884..e018cc2 100644 --- a/androidApp/app/src/main/res/values-pt/strings.xml +++ b/androidApp/app/src/main/res/values-pt/strings.xml @@ -400,4 +400,37 @@ Tornar linha principal Excluir o lance e a continuação Ações do lance + Nova partida + Minhas bases + + Nova base + Aqui ficarão as partidas que você inserir ou jogar contra a Maia + Arquivos + Minhas partidas + Nova base + Nome + Fica no telefone, no ChessPenguin. O arquivo pode ser exportado no menu da base. + Criar + no telefone + Exportar o arquivo… + Excluir a base + Arquivo salvo + Não foi possível salvar o arquivo + Base excluída + Excluir “%1$s”? + + %1$s partida será excluída do telefone. Se precisar dela, exporte o arquivo antes. + %1$s partidas serão excluídas do telefone. Se precisar delas, exporte o arquivo antes. + %1$s partidas serão excluídas do telefone. Se precisar delas, exporte o arquivo antes. + + Salva em “%1$s”, nº %2$s + Não foi possível salvar a partida + Salvar em “%1$s” + Salvar na minha base… + Salvar numa base + Salvar numa base… + Nova base… + Criar e salvar + Salvar as alterações em “%1$s”? + Salvar a partida? + Não salvar diff --git a/androidApp/app/src/main/res/values-ru/strings.xml b/androidApp/app/src/main/res/values-ru/strings.xml index 6b9119b..8362473 100644 --- a/androidApp/app/src/main/res/values-ru/strings.xml +++ b/androidApp/app/src/main/res/values-ru/strings.xml @@ -405,4 +405,38 @@ Сделать основным Удалить ход и продолжение Действия с ходом + Новая партия + Мои базы + + Новая база + Здесь будут партии, которые вы введёте или сыграете с Maia + Файлы + Мои партии + Новая база + Название + Хранится на телефоне, в ChessPenguin. Выгрузить файл можно в меню базы. + Создать + на телефоне + Выгрузить файл… + Удалить базу + Файл сохранён + Не удалось сохранить файл + База удалена + Удалить «%1$s»? + + %1$s партия будет удалена с телефона. Если она нужна, сначала выгрузите файл. + %1$s партии будут удалены с телефона. Если они нужны, сначала выгрузите файл. + %1$s партий будут удалены с телефона. Если они нужны, сначала выгрузите файл. + %1$s партии будут удалены с телефона. Если они нужны, сначала выгрузите файл. + + Сохранено в «%1$s», № %2$s + Не удалось сохранить партию + Сохранить в «%1$s» + Сохранить в мою базу… + Сохранить в базу + Сохранить в базу… + Новая база… + Создать и сохранить + Сохранить изменения в «%1$s»? + Сохранить партию? + Не сохранять diff --git a/androidApp/app/src/main/res/values-uz/strings.xml b/androidApp/app/src/main/res/values-uz/strings.xml index 0d84079..1014160 100644 --- a/androidApp/app/src/main/res/values-uz/strings.xml +++ b/androidApp/app/src/main/res/values-uz/strings.xml @@ -392,4 +392,36 @@ Asosiy qilish Yurish va davomini o‘chirish Yurish amallari + Yangi o‘yin + Mening bazalarim + + Yangi baza + Bu yerda siz kiritgan yoki Maia bilan o‘ynagan o‘yinlar bo‘ladi + Fayllar + Mening o‘yinlarim + Yangi baza + Nomi + Telefonda, ChessPenguin ichida saqlanadi. Faylni baza menyusidan eksport qilish mumkin. + Yaratish + telefonda + Faylni eksport qilish… + Bazani o‘chirish + Fayl saqlandi + Faylni saqlab bo‘lmadi + Baza o‘chirildi + “%1$s” o‘chirilsinmi? + + Telefondan %1$s ta o‘yin o‘chiriladi. Agar kerak bo‘lsa, avval faylni eksport qiling. + Telefondan %1$s ta o‘yin o‘chiriladi. Agar kerak bo‘lsa, avval faylni eksport qiling. + + “%1$s” ga saqlandi, № %2$s + O‘yinni saqlab bo‘lmadi + “%1$s” ga saqlash + Mening bazamga saqlash… + Bazaga saqlash + Bazaga saqlash… + Yangi baza… + Yaratish va saqlash + O‘zgarishlar “%1$s” ga saqlansinmi? + O‘yin saqlansinmi? + Saqlamaslik diff --git a/androidApp/app/src/main/res/values/strings.xml b/androidApp/app/src/main/res/values/strings.xml index 3a28de3..15ef69c 100644 --- a/androidApp/app/src/main/res/values/strings.xml +++ b/androidApp/app/src/main/res/values/strings.xml @@ -397,4 +397,36 @@ Make it the main line Delete the move and what follows Move actions + New game + My databases + + New database + Games you enter or play against Maia will be here + Files + My games + New database + Name + Kept on the phone, in ChessPenguin. You can export the file from the database\'s menu. + Create + on the phone + Export the file… + Delete the database + File saved + Could not save the file + Database deleted + Delete “%1$s”? + + %1$s game will be deleted from the phone. If you need it, export the file first. + %1$s games will be deleted from the phone. If you need them, export the file first. + + Saved to “%1$s”, No. %2$s + Could not save the game + Save to “%1$s” + Save to my database… + Save to a database + Save to a database… + New database… + Create and save + Save the changes to “%1$s”? + Save the game? + Don’t save