From fd1af60dbb26912460100c62d82fbc4c8da256fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Wed, 28 Oct 2026 04:31:07 +0000 Subject: [PATCH] Android 1.0 for server 2.0: the file viewer, and older servers refused The show card. A tool call may now carry `show` (event["show"], harness spec 3.0.0): a file's name, path, kind, line and which copy -- node and version in the chat's tree, or the copy a linked device sent (shown_id). The transcript draws it as a card with Open; the viewer is a full-screen, read-only dialog that fetches the text and opens at the named line. Markdown goes through the same Markwon setup as a reply (rule 4); code, text and Markdown over 200 000 characters are numbered lines in a lazy list, the number column measured from the file's longest number. HTML is never rendered: no WebView exists in the app, so it is shown as source, and "Open in the browser" opens the web UI's viewer, which renders it in its sealed frame. Copy takes the whole file. The text comes from GET /api/v2/chats/{chat}/show?node=&version= (or ?shown=), plain text, at most 1 MB. That route is the app's half of a contract the server does not have yet: /api/v2 neither publishes `show` on a tool call nor serves the file to a token. Until it does, the card does not appear, and a viewer that meets a missing route says so and offers the browser. Older servers are refused: the discovery document's device-link protocol must be 3 (LLeMbas 2.0), at sign-in and, for an instance signed in to before, when the chat list opens. The protocol and not the version string, because the server's dev still says 1.7.x before its first beta. Also: gen-strings.py takes a server ref like the other two generators, so the strings come from the same commit as the contract and the tokens rather than from a shared working tree; the Reports notification channel goes (2.0 has no reports) and is deleted on first start. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 26 ++ README.md | 8 +- .../main/java/eu/llembas/android/LembasApp.kt | 5 +- .../java/eu/llembas/android/api/ApiClient.kt | 35 +++ .../java/eu/llembas/android/api/Compat.kt | 26 ++ .../java/eu/llembas/android/api/Models.kt | 39 +++ .../main/java/eu/llembas/android/push/Push.kt | 1 - .../java/eu/llembas/android/ui/chat/Blocks.kt | 63 ++++- .../eu/llembas/android/ui/chat/ChatScreen.kt | 11 +- .../llembas/android/ui/chats/ChatsScreen.kt | 20 ++ .../llembas/android/ui/signin/SignInScreen.kt | 18 +- .../llembas/android/ui/viewer/FileViewer.kt | 261 ++++++++++++++++++ app/src/main/res/values-cs/strings.xml | 11 +- app/src/main/res/values-de/strings.xml | 11 +- app/src/main/res/values-es/strings.xml | 11 +- app/src/main/res/values-fr/strings.xml | 11 +- app/src/main/res/values-hu/strings.xml | 11 +- app/src/main/res/values-it/strings.xml | 11 +- app/src/main/res/values-pl/strings.xml | 11 +- app/src/main/res/values-sk/strings.xml | 11 +- app/src/main/res/values/strings.xml | 11 +- .../eu/llembas/android/ShowAndServerTest.kt | 77 ++++++ scripts/gen-strings.py | 35 ++- scripts/strings.py | 12 +- scripts/strings_own.json | 80 ++++-- 25 files changed, 754 insertions(+), 62 deletions(-) create mode 100644 app/src/main/java/eu/llembas/android/api/Compat.kt create mode 100644 app/src/main/java/eu/llembas/android/ui/viewer/FileViewer.kt create mode 100644 app/src/test/java/eu/llembas/android/ShowAndServerTest.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index c2572f2..de38ba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,32 @@ is in alpha and releases come off `main`. ## [Unreleased] +For LLeMbas server 2.0, and only for it. + +### Added + +- **The file viewer.** When the model shows a file (the `show` tool, in a chat or from a linked + device), the reply carries a card with the file's name and path; Open shows it full screen, + read-only, at the line it named. Markdown is rendered with the same limits as a reply (no + images, no HTML, links open in the browser for http, https and mailto only); code and text are + numbered lines; a long Markdown file is shown as text. **HTML is never rendered in the app**: + it is shown as its source, and "Open in the browser" opens the web viewer, which draws it in + its sealed frame. Copy takes the whole file. +- **A server older than 2.0 is refused** with a sentence, at sign-in and for an instance signed + in to before: the device-link protocol must be 3 or newer. + +### Changed + +- **The server's contract is pinned to LLeMbas 2.0** (`dev`): no canvas, chats without knowledge + bases. Theme and strings are generated from the same commit; `gen-strings.py` takes a server + ref, as the other two scripts do. Selected text uses the web UI's `--selection` tint. +- CI also runs on pushes to `dev`. + +### Removed + +- **The Reports notification channel**: LLeMbas 2.0 has no reports. The channel is deleted on + first start. + ## [0.1.0] — unreleased The first version: a native client for a LLeMbas instance (server 1.7.0 or newer), and the diff --git a/README.md b/README.md index ecdc815..276083d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ digital assistant -- hold the power button and ask. Download the APK from the [latest release](https://github.com/LLeMbas/LLeMbas-Android/releases/latest) and check it against `SHA256SUMS`. The `full` APK updates itself from llembas.eu; the `-fdroid` -one does not. Android 10 or newer; the instance must run LLeMbas server 1.7.0 or newer. +one does not. Android 10 or newer; the instance must run LLeMbas server 2.0 or newer (an older +one is refused at sign-in, with a sentence saying so). If your instance uses a certificate from your own certificate authority, install that CA on the phone first (Settings › Security › Encryption & credentials › Install a certificate › CA @@ -40,13 +41,14 @@ preinstalled assistant; no app from outside can use it. Builds run on GitHub Actions (`.github/workflows/ci.yml`); locally it is the usual `./gradlew assembleFullDebug` with JDK 17 and the Android SDK. -Three things are generated from the server and pinned, each with a lock file CI checks: +Three things are generated from the server at one ref; the first two are pinned with a lock +file CI checks, and CI checks the strings against the code: | What | Script | From the server | |---|---|---| | `ui/theme/Tokens.kt` | `scripts/fetch-tokens.py ` | `tokens.css` | | `contract/*.json` | `scripts/fetch-contract.py ` | `tests/fixtures/api_v2/` | -| `res/values*/strings.xml` | `scripts/gen-strings.py` | the translation catalogues | +| `res/values*/strings.xml` | `scripts/gen-strings.py ` | the translation catalogues | The icons come from the server's pixel leaf (`scripts/gen-icons.py`). diff --git a/app/src/main/java/eu/llembas/android/LembasApp.kt b/app/src/main/java/eu/llembas/android/LembasApp.kt index f935cb5..5f5a5fc 100644 --- a/app/src/main/java/eu/llembas/android/LembasApp.kt +++ b/app/src/main/java/eu/llembas/android/LembasApp.kt @@ -18,15 +18,16 @@ class LembasApp : Application() { listOf( NotificationChannel(CHANNEL_REPLIES, getString(R.string.channel_replies), NotificationManager.IMPORTANCE_DEFAULT), NotificationChannel(CHANNEL_ASKS, getString(R.string.channel_asks), NotificationManager.IMPORTANCE_HIGH), - NotificationChannel(CHANNEL_REPORTS, getString(R.string.channel_reports), NotificationManager.IMPORTANCE_LOW), ), ) + // LLeMbas 2.0 has no reports, so 0.1's channel for them goes rather than sit empty in + // the system's settings. + manager.deleteNotificationChannel("reports") } companion object { const val CHANNEL_REPLIES = "replies" const val CHANNEL_ASKS = "asks" - const val CHANNEL_REPORTS = "reports" } } diff --git a/app/src/main/java/eu/llembas/android/api/ApiClient.kt b/app/src/main/java/eu/llembas/android/api/ApiClient.kt index c3e64d6..c2fc990 100644 --- a/app/src/main/java/eu/llembas/android/api/ApiClient.kt +++ b/app/src/main/java/eu/llembas/android/api/ApiClient.kt @@ -227,6 +227,38 @@ class ApiClient(val base: String, private val token: String, val http: OkHttpCli } } + // --- What a `show` card opens ------------------------------------------------------------- + + /** + * The text of a file a `show` card named, as the chat sees it now: the server rebuilds the + * chat's view and checks the path again, so a grant taken away since takes the file away too. + * Always plain text -- the app never asks for a page to render. + */ + suspend fun shownText(chatId: String, show: ShowCard): String = withContext(Dispatchers.IO) { + val url = "$v2/chats/$chatId/show".toHttpUrl().newBuilder() + .apply { show.query.forEach { (k, v) -> addQueryParameter(k, v) } } + .build() + http.newCall(authed(url.toString()).header("Accept", "text/plain").get().build()).await().use { + if (!it.isSuccessful) throw ApiException(it.code, detail(it)) + val body = it.body!! + // The server shows at most 1 MB; anything much larger is not a file it meant. + if (body.contentLength() > SHOWN_MAX_BYTES) throw ApiException(413, "") + val bytes = body.source().use { source -> + source.request(SHOWN_MAX_BYTES + 1) + source.buffer.readByteArray(minOf(source.buffer.size, SHOWN_MAX_BYTES + 1)) + } + if (bytes.size > SHOWN_MAX_BYTES) throw ApiException(413, "") + bytes.toString(Charsets.UTF_8) + } + } + + /** The same file in the web UI's viewer, which renders HTML in its sealed frame. */ + fun webViewer(chatId: String, show: ShowCard): String = "$base/chat/$chatId/show".toHttpUrl().newBuilder() + .apply { show.query.forEach { (k, v) -> addQueryParameter(k, v) } } + .apply { if (show.line > 0) addQueryParameter("line", show.line.toString()) } + .build() + .toString() + // --- Push -------------------------------------------------------------------------------- suspend fun pushKey(): PushKey = get("/push") @@ -265,6 +297,9 @@ class ApiClient(val base: String, private val token: String, val http: OkHttpCli authed("$v2/chats/$chatId/messages/$messageId/stream").header("Accept", "text/event-stream").build() companion object { + /** 1 MB, the server's own limit on a shown file, with room for a little more. */ + const val SHOWN_MAX_BYTES = 1_100_000L + fun emptyBody(): RequestBody = ByteArray(0).toRequestBody(null) } } diff --git a/app/src/main/java/eu/llembas/android/api/Compat.kt b/app/src/main/java/eu/llembas/android/api/Compat.kt new file mode 100644 index 0000000..53836e4 --- /dev/null +++ b/app/src/main/java/eu/llembas/android/api/Compat.kt @@ -0,0 +1,26 @@ +package eu.llembas.android.api + +/** The newest app API this app reads. A server with a newer one is told about, not guessed at. */ +const val APP_API = 1 + +/** + * The device-link protocol of LLeMbas 2.0. This app is built for 2.0 -- the file tree, the + * access levels, the `show` card -- and a 1.x server (protocol 1 or 2) is refused with a + * sentence rather than half-working. The protocol, not the version string, is the test: a + * server's `dev` branch says 1.7.x until its first beta, and the protocol is what 2.0 raised on + * purpose so that old clients can tell. + */ +const val MIN_PROTOCOL = 3 + +/** Whether this app can work with a server, from its discovery document. */ +enum class ServerFit { FITS, NOT_LEMBAS, TOO_OLD, TOO_NEW } + +fun fit(found: Discovery): ServerFit { + val protocol = maxOf(found.protocol, found.protocols.maxOrNull() ?: 0) + return when { + found.service != "lembas" -> ServerFit.NOT_LEMBAS + protocol < MIN_PROTOCOL || found.appApi < 1 || "app" !in found.scopes -> ServerFit.TOO_OLD + found.appApi > APP_API -> ServerFit.TOO_NEW + else -> ServerFit.FITS + } +} diff --git a/app/src/main/java/eu/llembas/android/api/Models.kt b/app/src/main/java/eu/llembas/android/api/Models.kt index d3680bc..db41207 100644 --- a/app/src/main/java/eu/llembas/android/api/Models.kt +++ b/app/src/main/java/eu/llembas/android/api/Models.kt @@ -27,6 +27,9 @@ data class Discovery( val version: String = "", val name: String = "", @SerialName("base_url") val baseUrl: String = "", + /** The device link's protocol: 3 from LLeMbas 2.0 on, which is what this app needs. */ + val protocol: Int = 0, + val protocols: List = emptyList(), @SerialName("app_api") val appApi: Int = 0, val login: Login = Login(), val scopes: List = emptyList(), @@ -191,9 +194,45 @@ data class ToolCall( val truncated: Boolean = false, val job: JsonElement? = null, val children: List? = null, + /** The `show` tool's card: a file put in front of the person. Never its text. */ + val show: ShowCard? = null, val block: ToolBlock = ToolBlock(), ) +/** + * What a `show` call put in front of the person (`event["show"]`, harness spec 3.0.0): the + * file's name and where it is, never its contents -- the viewer fetches those. A file from the + * chat's own tree names its node and version; a file a linked device sent names the copy the + * server kept (`shown_id`), with the tree's two ids empty. + */ +@Serializable +data class ShowCard( + val path: String = "", + val name: String = "", + /** `markdown`, `code`, `text` or `html`; anything else is read as `text`. */ + val kind: String = "text", + val language: String = "", + val line: Int = 0, + @SerialName("node_id") val nodeId: String = "", + @SerialName("version_id") val versionId: String = "", + val sha: String = "", + val size: Long = 0, + val mime: String = "", + val source: String = "", + @SerialName("shown_id") val shownId: String = "", +) { + /** The kind the viewer draws: an unknown one is plain text, never something richer. */ + val viewKind: String get() = if (kind in VIEW_KINDS) kind else "text" + + /** Which file, as the server's viewer routes take it: the device's copy, or node and version. */ + val query: List> + get() = if (shownId.isNotEmpty()) listOf("shown" to shownId) else listOf("node" to nodeId, "version" to versionId) + + companion object { + val VIEW_KINDS = setOf("markdown", "code", "text", "html") + } +} + @Serializable data class SteerNote(val id: String = "", val text: String = "") diff --git a/app/src/main/java/eu/llembas/android/push/Push.kt b/app/src/main/java/eu/llembas/android/push/Push.kt index 969a15e..36a4e53 100644 --- a/app/src/main/java/eu/llembas/android/push/Push.kt +++ b/app/src/main/java/eu/llembas/android/push/Push.kt @@ -113,7 +113,6 @@ object Notifications { ) val channel = when (payload.kind) { "ask" -> LembasApp.CHANNEL_ASKS - "report" -> LembasApp.CHANNEL_REPORTS else -> LembasApp.CHANNEL_REPLIES } val builder = NotificationCompat.Builder(context, channel) diff --git a/app/src/main/java/eu/llembas/android/ui/chat/Blocks.kt b/app/src/main/java/eu/llembas/android/ui/chat/Blocks.kt index 0a832fd..adbd1ab 100644 --- a/app/src/main/java/eu/llembas/android/ui/chat/Blocks.kt +++ b/app/src/main/java/eu/llembas/android/ui/chat/Blocks.kt @@ -28,9 +28,11 @@ import androidx.compose.material.icons.filled.Language import androidx.compose.material.icons.filled.Psychology import androidx.compose.material.icons.filled.Search import androidx.compose.material.icons.filled.Terminal +import androidx.compose.material.icons.filled.Visibility import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -46,6 +48,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import eu.llembas.android.R import eu.llembas.android.api.Message +import eu.llembas.android.api.ShowCard import eu.llembas.android.api.Step import eu.llembas.android.api.ToolCall import eu.llembas.android.ui.MarkdownText @@ -79,15 +82,18 @@ fun UserBubble(message: Message, modifier: Modifier = Modifier) { } } -/** A reply's steps, in the order they happened: the same table of contents the web page draws. */ +/** + * A reply's steps, in the order they happened: the same table of contents the web page draws. + * [onShow] opens a `show` card's file; without it (the assistant's sheet) the card only names it. + */ @Composable -fun Steps(steps: List, modifier: Modifier = Modifier) { +fun Steps(steps: List, modifier: Modifier = Modifier, onShow: ((ShowCard) -> Unit)? = null) { Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) { steps.forEach { step -> when (step.kind) { "thinking" -> Thinking(step) "text" -> MarkdownText(step.markdown.orEmpty(), modifier = Modifier.fillMaxWidth()) - "tools" -> step.calls.forEach { ToolCallBlock(it) } + "tools" -> step.calls.forEach { ToolCallBlock(it, onShow = onShow) } "steer" -> step.messages.forEach { Steered(it.text) } } } @@ -140,10 +146,15 @@ private fun iconFor(kind: String): ImageVector = when (kind) { * scroller, so a megabyte of output never becomes the page. */ @Composable -fun ToolCallBlock(call: ToolCall, depth: Int = 0) { +fun ToolCallBlock(call: ToolCall, depth: Int = 0, onShow: ((ShowCard) -> Unit)? = null) { val palette = LocalPalette.current var open by rememberSaveable(call.id ?: call.block.title) { mutableStateOf(call.block.kind == "edit") } val failed = call.status == "error" || !call.error.isNullOrEmpty() + val shown = call.show + if (shown != null && !failed) { + ShowCardRow(shown, depth, onShow) + return + } Column( Modifier .fillMaxWidth() @@ -192,7 +203,49 @@ fun ToolCallBlock(call: ToolCall, depth: Int = 0) { if (call.truncated) { Text(stringResource(R.string.output_cut), style = MaterialTheme.typography.labelSmall, color = palette.inkFaint) } - call.children?.forEach { ToolCallBlock(it, depth + 1) } + call.children?.forEach { ToolCallBlock(it, depth + 1, onShow) } + } + } + } +} + +/** + * A `show` card: the file's name and path, and Open. Nothing of its contents -- the words here + * are a path a model chose, drawn as text like everything else. The web page opens a card that + * arrives while it is open by itself, beside the conversation, when the screen is wide enough; + * a phone's screen is not, so here it waits for a tap. + */ +@Composable +private fun ShowCardRow(show: ShowCard, depth: Int, onShow: ((ShowCard) -> Unit)?) { + val palette = LocalPalette.current + Row( + Modifier + .fillMaxWidth() + .padding(start = (depth * 16).dp) + .background(palette.surfaceRaised, Rounded) + .border(1.dp, palette.border, Rounded) + .then(if (onShow != null) Modifier.clickable { onShow(show) } else Modifier) + .padding(start = 12.dp, end = 4.dp, top = 4.dp, bottom = 4.dp) + .heightIn(min = 48.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Icon(Icons.Filled.Visibility, contentDescription = stringResource(R.string.shown), modifier = Modifier.size(18.dp), tint = palette.leaf) + Spacer(Modifier.width(10.dp)) + // The one part that gives: a long path shortens, the button keeps its size. + Column(Modifier.weight(1f)) { + Text(show.name.ifBlank { show.path }, style = MaterialTheme.typography.bodyMedium, maxLines = 1, overflow = TextOverflow.Ellipsis) + Text( + show.path + if (show.line > 0) ":${show.line}" else "", + fontFamily = FontFamily.Monospace, + style = MaterialTheme.typography.labelSmall, + color = palette.inkFaint, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + } + if (onShow != null) { + TextButton(onClick = { onShow(show) }, modifier = Modifier.heightIn(min = 48.dp)) { + Text(stringResource(R.string.viewer_open)) } } } diff --git a/app/src/main/java/eu/llembas/android/ui/chat/ChatScreen.kt b/app/src/main/java/eu/llembas/android/ui/chat/ChatScreen.kt index e95947e..5d13323 100644 --- a/app/src/main/java/eu/llembas/android/ui/chat/ChatScreen.kt +++ b/app/src/main/java/eu/llembas/android/ui/chat/ChatScreen.kt @@ -74,9 +74,11 @@ import androidx.lifecycle.viewmodel.compose.viewModel import eu.llembas.android.R import eu.llembas.android.api.Message import eu.llembas.android.api.ModelInfo +import eu.llembas.android.api.ShowCard import eu.llembas.android.assist.Recorder import eu.llembas.android.lembas import eu.llembas.android.ui.theme.LocalPalette +import eu.llembas.android.ui.viewer.FileViewer import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) @@ -88,6 +90,7 @@ fun ChatScreen(chatId: String?, onBack: () -> Unit, onOpened: (String) -> Unit = val snackbar = remember { SnackbarHostState() } var menu by remember { mutableStateOf(false) } var editing by remember { mutableStateOf(null) } + var showing by remember { mutableStateOf(null) } LaunchedEffect(chatId) { model.open(chatId) } // A new chat gets its id from its first message; the route follows, so Back and a @@ -202,13 +205,13 @@ fun ChatScreen(chatId: String?, onBack: () -> Unit, onOpened: (String) -> Unit = } live != null && live.messageId == message.id && live.finished == null -> Column { - Steps(live.shown) + Steps(live.shown, onShow = { showing = it }) if (live.shown.isEmpty()) Text(stringResource(R.string.loading_line), color = palette.inkFaint) live.metrics?.let { m -> ReplyFoot(message.copy(metrics = m)) } } else -> Column { - Steps(message.steps) + Steps(message.steps, onShow = { showing = it }) ReplyFoot(message) if (live == null && message == rows.lastOrNull()) { Row { @@ -236,6 +239,10 @@ fun ChatScreen(chatId: String?, onBack: () -> Unit, onOpened: (String) -> Unit = } } + showing?.let { file -> + state.chat?.id?.let { id -> FileViewer(id, file, onClose = { showing = null }) } + } + editing?.let { message -> var text by remember(message.id) { mutableStateOf(message.text.orEmpty()) } AlertDialog( diff --git a/app/src/main/java/eu/llembas/android/ui/chats/ChatsScreen.kt b/app/src/main/java/eu/llembas/android/ui/chats/ChatsScreen.kt index 0670c3d..0fc8742 100644 --- a/app/src/main/java/eu/llembas/android/ui/chats/ChatsScreen.kt +++ b/app/src/main/java/eu/llembas/android/ui/chats/ChatsScreen.kt @@ -53,7 +53,10 @@ import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewmodel.compose.viewModel import eu.llembas.android.R import eu.llembas.android.api.Chat +import eu.llembas.android.api.Doorstep +import eu.llembas.android.api.fit import eu.llembas.android.lembas +import eu.llembas.android.ui.signin.refusal import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update @@ -68,12 +71,29 @@ class ChatsViewModel(app: Application) : AndroidViewModel(app) { val state = _state.asStateFlow() private var kind = "chat" + /** Why this instance is refused, once it was asked what it is; null while it fits. */ + private var refused: Int? = null + private var checked = false + fun load(kind: String) { this.kind = kind viewModelScope.launch { _state.update { it.copy(loading = true, error = null) } try { val api = getApplication().lembas.instances.client() ?: return@launch + // An instance signed in to before it was downgraded, or by 0.1 against a 1.x + // server, is refused here as at sign-in. Unreachable is not refused: the chat + // list's own error says that better. + if (!checked) { + runCatching { Doorstep().discover(api.base) }.onSuccess { + checked = true + refused = refusal(fit(it)) + } + } + refused?.let { said -> + _state.value = ChatsState(error = getApplication().getString(said)) + return@launch + } val page = api.chats(kind = kind) _state.value = ChatsState(chats = page.chats, more = page.more) } catch (e: Exception) { diff --git a/app/src/main/java/eu/llembas/android/ui/signin/SignInScreen.kt b/app/src/main/java/eu/llembas/android/ui/signin/SignInScreen.kt index 604a500..71dd6bb 100644 --- a/app/src/main/java/eu/llembas/android/ui/signin/SignInScreen.kt +++ b/app/src/main/java/eu/llembas/android/ui/signin/SignInScreen.kt @@ -43,6 +43,8 @@ import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewmodel.compose.viewModel import eu.llembas.android.R import eu.llembas.android.api.Doorstep +import eu.llembas.android.api.ServerFit +import eu.llembas.android.api.fit import eu.llembas.android.api.normaliseBase import eu.llembas.android.lembas import kotlinx.coroutines.Job @@ -60,8 +62,12 @@ sealed interface SignInState { data object Done : SignInState } -/** The newest API this app reads. A server with a newer one is told about, not guessed at. */ -const val APP_API = 1 +/** The sentence for a server this app will not work with, or null when it fits. */ +fun refusal(fit: ServerFit): Int? = when (fit) { + ServerFit.FITS -> null + ServerFit.NOT_LEMBAS, ServerFit.TOO_OLD -> R.string.signin_too_old + ServerFit.TOO_NEW -> R.string.signin_too_new +} class SignInViewModel(app: Application) : AndroidViewModel(app) { private val _state = MutableStateFlow(SignInState.Address) @@ -76,12 +82,8 @@ class SignInViewModel(app: Application) : AndroidViewModel(app) { try { val base = normaliseBase(typed) val found = doorstep.discover(base) - if (found.service != "lembas" || found.appApi < 1 || "app" !in found.scopes) { - _state.value = SignInState.Failed(getApplication().getString(R.string.signin_too_old)) - return@launch - } - if (found.appApi > APP_API) { - _state.value = SignInState.Failed(getApplication().getString(R.string.signin_too_new)) + refusal(fit(found))?.let { said -> + _state.value = SignInState.Failed(getApplication().getString(said)) return@launch } val device = getApplication().getString(R.string.device_name) diff --git a/app/src/main/java/eu/llembas/android/ui/viewer/FileViewer.kt b/app/src/main/java/eu/llembas/android/ui/viewer/FileViewer.kt new file mode 100644 index 0000000..9da41ab --- /dev/null +++ b/app/src/main/java/eu/llembas/android/ui/viewer/FileViewer.kt @@ -0,0 +1,261 @@ +@file:OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class) + +package eu.llembas.android.ui.viewer + +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context +import android.net.Uri +import androidx.browser.customtabs.CustomTabsIntent +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.OpenInNew +import androidx.compose.material.icons.filled.Close +import androidx.compose.material.icons.filled.ContentCopy +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.rememberTextMeasurer +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.DialogProperties +import eu.llembas.android.R +import eu.llembas.android.api.ApiException +import eu.llembas.android.api.ShowCard +import eu.llembas.android.lembas +import eu.llembas.android.ui.MarkdownText +import eu.llembas.android.ui.theme.LocalPalette +import java.io.IOException + +/** + * Markdown longer than this is shown as its lines instead. A TextView holding a whole megabyte + * of rendered Markdown stalls the phone; the same text as a lazy list of lines does not. + */ +private const val MARKDOWN_MAX_CHARS = 200_000 + +/** Where a file is on its way into the viewer. */ +private sealed interface Loaded { + data object Loading : Loaded + + data class Text(val text: String) : Loaded + + /** [unavailable]: this server has no door for the app to read a shown file through. */ + data class Failed(val message: String, val unavailable: Boolean = false) : Loaded +} + +/** + * What a `show` card opens: the file, full screen, read-only, as the chat sees it now. + * + * Everything in it came from a model and is untrusted, as on the web page, so the rules are the + * same ones the transcript keeps: Markdown goes through [MarkdownText] (no images, no HTML, links + * outside for http, https and mailto only); code and text are drawn as lines, never interpreted. + * **HTML is shown as its source, never rendered** -- the app has no WebView, and a page a model + * wrote does not get one here. The web UI renders it in its sealed frame (an opaque origin with + * no network), and "Open in the browser" goes there. + */ +@Composable +fun FileViewer(chatId: String, show: ShowCard, onClose: () -> Unit) { + val context = LocalContext.current + val palette = LocalPalette.current + var loaded by remember(chatId, show) { mutableStateOf(Loaded.Loading) } + var web by remember(chatId, show) { mutableStateOf(null) } + + LaunchedEffect(chatId, show) { + val api = context.lembas.instances.client() + if (api == null) { + loaded = Loaded.Failed(context.getString(R.string.assist_signed_out)) + return@LaunchedEffect + } + web = api.webViewer(chatId, show) + loaded = try { + Loaded.Text(api.shownText(chatId, show)) + } catch (e: ApiException) { + when { + e.status == 413 -> Loaded.Failed(context.getString(R.string.viewer_too_large)) + + // No such route at all (FastAPI's own "Not Found", or the wrong method): a + // server without the app's door to shown files. Its own 404 has a sentence. + e.status == 405 || (e.status == 404 && e.message == "Not Found") -> + Loaded.Failed(context.getString(R.string.viewer_unavailable), unavailable = true) + + else -> Loaded.Failed(e.message ?: context.getString(R.string.viewer_unavailable)) + } + } catch (e: IOException) { + Loaded.Failed(e.message ?: e.javaClass.simpleName) + } + } + + Dialog(onDismissRequest = onClose, properties = DialogProperties(usePlatformDefaultWidth = false)) { + Scaffold( + topBar = { + TopAppBar( + navigationIcon = { + IconButton(onClick = onClose) { + Icon(Icons.Filled.Close, contentDescription = stringResource(R.string.close)) + } + }, + title = { + Column { + Text(show.name.ifBlank { show.path }, maxLines = 1, overflow = TextOverflow.Ellipsis) + Text( + show.path + if (show.line > 0) ":${show.line}" else "", + style = MaterialTheme.typography.labelSmall, + fontFamily = FontFamily.Monospace, + color = palette.inkFaint, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + } + }, + actions = { + (loaded as? Loaded.Text)?.let { done -> + IconButton(onClick = { copy(context, show.name, done.text) }) { + Icon(Icons.Filled.ContentCopy, contentDescription = stringResource(R.string.viewer_copy)) + } + } + web?.let { url -> + IconButton(onClick = { openOutside(context, url) }) { + Icon(Icons.AutoMirrored.Filled.OpenInNew, contentDescription = stringResource(R.string.viewer_open_browser)) + } + } + }, + ) + }, + ) { padding -> + Box(Modifier.padding(padding).fillMaxSize()) { + when (val now = loaded) { + Loaded.Loading -> CircularProgressIndicator(Modifier.align(Alignment.Center)) + + is Loaded.Failed -> Column( + Modifier.align(Alignment.Center).padding(32.dp), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text(now.message, color = palette.inkMuted, textAlign = TextAlign.Center) + web?.let { url -> + OutlinedButton(onClick = { openOutside(context, url) }, modifier = Modifier.padding(top = 16.dp)) { + Text(stringResource(R.string.viewer_open_browser)) + } + } + } + + is Loaded.Text -> Body(show, now.text) + } + } + } + } +} + +@Composable +private fun Body(show: ShowCard, text: String) { + val palette = LocalPalette.current + val kind = show.viewKind + if (kind == "markdown" && text.length <= MARKDOWN_MAX_CHARS) { + Column(Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(16.dp)) { + MarkdownText(text, modifier = Modifier.fillMaxWidth()) + } + return + } + val note = when (kind) { + "html" -> R.string.viewer_html_source + "markdown" -> R.string.viewer_long_markdown + else -> null + } + Column(Modifier.fillMaxSize()) { + note?.let { + Text( + stringResource(it), + style = MaterialTheme.typography.bodySmall, + color = palette.inkMuted, + modifier = Modifier.fillMaxWidth().background(palette.bgSunken).padding(horizontal = 16.dp, vertical = 10.dp), + ) + } + Lines(text, show.line) + } +} + +/** + * A file as numbered lines, opened at the line the card named. The number column's width is + * measured, not guessed: it is the width of the longest number in this file, so every line's + * text starts at the same x whatever its number, and a wrapped line continues under its own + * text rather than under the numbers. + */ +@Composable +private fun Lines(text: String, line: Int) { + val palette = LocalPalette.current + val rows = remember(text) { + val split = text.split('\n') + if (split.size > 1 && split.last().isEmpty()) split.dropLast(1) else split + } + val style = TextStyle(fontFamily = FontFamily.Monospace, fontSize = 13.sp, lineHeight = 18.sp, color = palette.ink) + val measurer = rememberTextMeasurer() + val density = LocalDensity.current + val gutter = remember(rows.size, density) { + with(density) { measurer.measure("9".repeat(rows.size.toString().length), style).size.width.toDp() } + } + val state = rememberLazyListState(initialFirstVisibleItemIndex = (line - 1).coerceIn(0, (rows.size - 1).coerceAtLeast(0))) + LazyColumn( + state = state, + modifier = Modifier.fillMaxSize().background(palette.codeBg), + contentPadding = PaddingValues(vertical = 8.dp), + ) { + itemsIndexed(rows) { i, row -> + val here = line > 0 && i == line - 1 + Row( + Modifier + .fillMaxWidth() + .then(if (here) Modifier.background(palette.accentSoft) else Modifier) + .padding(horizontal = 12.dp), + ) { + Text((i + 1).toString(), style = style.copy(color = palette.inkFaint), textAlign = TextAlign.End, modifier = Modifier.width(gutter)) + Spacer(Modifier.width(12.dp)) + Text(row.ifEmpty { " " }, style = style, modifier = Modifier.weight(1f)) + } + } + } +} + +private fun copy(context: Context, label: String, text: String) { + context.getSystemService(ClipboardManager::class.java)?.setPrimaryClip(ClipData.newPlainText(label, text)) +} + +/** The web UI's viewer, in the browser (a Custom Tab), where the person's own session is. */ +private fun openOutside(context: Context, url: String) { + val uri = Uri.parse(url) + if (uri.scheme?.lowercase() !in setOf("http", "https")) return + runCatching { CustomTabsIntent.Builder().build().launchUrl(context, uri) } +} diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 18068fc..e66495c 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -11,7 +11,7 @@ Otevřít v prohlížeči Přihlášení bylo odmítnuto. Kód vypršel, než byl schválen. Zkuste to znovu. - Tato instance ještě nemá rozhraní API pro aplikace. Potřebuje LLeMbas 1.7.0 nebo novější. + Tato instance používá starší LLeMbas. Tato aplikace potřebuje LLeMbas 2.0 nebo novější. Tato instance používá novější rozhraní API pro aplikace než tato aplikace. Aktualizujte aplikaci. Nová konverzace Konverzace @@ -58,6 +58,14 @@ Přepracovat Co by se mělo změnit? Provést plán + Zobrazeno + Otevřít + Otevřít v prohlížeči + Kopírovat + Toto je zdrojový kód stránky. Samotnou stránku uvidíte po otevření v prohlížeči. + Dlouhý soubor, proto je zobrazen jako prostý text. + Tento server zatím aplikaci soubor předat neumí. Otevřete ho v prohlížeči. + Tento soubor je příliš velký na zobrazení; zobrazit lze nejvýše 1 MB. Nastavení Instance Odhlásit se @@ -74,7 +82,6 @@ Nebyl zvolen žádný distributor, takže upozornění jsou stále vypnutá. Odpovědi Otázky a schválení - Zprávy Asistent Nastavte LLeMbas jako digitálního asistenta telefonu: zvolte ho v Výchozí aplikace › Digitální asistent. Podržení tlačítka napájení, gesto asistenta nebo zkratka na zamykací obrazovce ho pak otevře přes to, co je právě na obrazovce. Otevřít nastavení asistenta diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 48a8a41..138afee 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -11,7 +11,7 @@ Im Browser öffnen Die Anmeldung wurde abgelehnt. Der Code ist abgelaufen, bevor er bestätigt wurde. Versuchen Sie es erneut. - Diese Instanz hat noch keine App-API. Sie braucht LLeMbas 1.7.0 oder neuer. + Auf dieser Instanz läuft ein älteres LLeMbas. Diese App braucht LLeMbas 2.0 oder neuer. Diese Instanz spricht eine neuere App-API als diese App. Aktualisieren Sie die App. Neuer Chat Chats @@ -58,6 +58,14 @@ Überarbeiten Was soll sich ändern? Plan ausführen + Angezeigt + Öffnen + Im Browser öffnen + Kopieren + Das ist der Quelltext der Seite. Die Seite selbst sehen Sie im Browser. + Eine lange Datei, daher wird sie als reiner Text angezeigt. + Dieser Server kann die Datei der App noch nicht übergeben. Öffnen Sie sie stattdessen im Browser. + Diese Datei ist zu groß zum Anzeigen; höchstens 1 MB kann angezeigt werden. Einstellungen Instanzen Abmelden @@ -74,7 +82,6 @@ Es wurde kein Distributor gewählt, daher sind die Benachrichtigungen noch ausgeschaltet. Antworten Fragen und Bestätigungen - Berichte Assistent Machen Sie LLeMbas zum digitalen Assistenten des Telefons: Wählen Sie ihn unter Standard-Apps › Digitaler Assistent. Das Halten der Einschalttaste, die Assistenzgeste oder die Verknüpfung auf dem Sperrbildschirm öffnet ihn dann über allem, was gerade angezeigt wird. Assistenten-Einstellungen öffnen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 1cec32c..045c0f0 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -11,7 +11,7 @@ Abrir en el navegador El inicio de sesión fue rechazado. El código caducó antes de ser aprobado. Inténtelo de nuevo. - Esta instancia aún no tiene API para aplicaciones. Necesita LLeMbas 1.7.0 o una versión posterior. + Esta instancia usa una versión anterior de LLeMbas. Esta aplicación necesita LLeMbas 2.0 o posterior. Esta instancia habla una API de aplicaciones más reciente que esta aplicación. Actualice la aplicación. Nuevo chat Chats @@ -58,6 +58,14 @@ Revisar ¿Qué debería cambiar? Llevar a cabo el plan + Mostrado + Abrir + Abrir en el navegador + Copiar + Este es el código fuente de la página. Ábrala en el navegador para ver la página. + Un archivo largo, por eso se muestra como texto sin formato. + Este servidor todavía no puede entregar el archivo a la aplicación. Ábralo en el navegador. + Este archivo es demasiado grande para mostrarlo; se puede mostrar como máximo 1 MB. Ajustes Instancias Cerrar sesión @@ -74,7 +82,6 @@ No se eligió ningún distribuidor, así que las notificaciones siguen desactivadas. Respuestas Preguntas y aprobaciones - Informes Asistente Convierta LLeMbas en el asistente digital del teléfono: elíjalo en Aplicaciones predeterminadas › App de asistencia digital. Mantener pulsado el botón de encendido, el gesto de asistencia o el acceso directo de la pantalla de bloqueo lo abrirá entonces sobre lo que haya en pantalla. Abrir los ajustes del asistente diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 1749689..6d2296f 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -11,7 +11,7 @@ Ouvrir dans le navigateur La connexion a été refusée. Le code a expiré avant d\'être approuvé. Réessayez. - Cette instance n\'a pas encore d\'API pour l\'application. Elle nécessite LLeMbas 1.7.0 ou une version plus récente. + Cette instance utilise une version plus ancienne de LLeMbas. Cette application nécessite LLeMbas 2.0 ou plus récent. Cette instance utilise une API d\'application plus récente que cette application. Mettez à jour l\'application. Nouvelle conversation Conversations @@ -58,6 +58,14 @@ Réviser Qu\'est-ce qui doit changer ? Exécuter le plan + Affiché + Ouvrir + Ouvrir dans le navigateur + Copier + Ceci est le code source de la page. Ouvrez-la dans le navigateur pour voir la page elle-même. + Un fichier long, il est donc affiché en texte brut. + Ce serveur ne peut pas encore transmettre le fichier à l\'application. Ouvrez-le plutôt dans le navigateur. + Ce fichier est trop volumineux pour être affiché ; 1 Mo au plus peut être affiché. Paramètres Instances Se déconnecter @@ -74,7 +82,6 @@ Aucun distributeur n\'a été choisi, les notifications sont donc toujours désactivées. Réponses Questions et approbations - Rapports Assistant Faites de LLeMbas l\'assistant numérique du téléphone : choisissez-le dans Applications par défaut › Application d\'assistance numérique. Maintenir le bouton d\'alimentation, le geste d\'assistance ou le raccourci de l\'écran de verrouillage l\'ouvrira alors par-dessus ce qui est affiché. Ouvrir les paramètres de l\'assistant diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 37c8c33..5aacf8f 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -11,7 +11,7 @@ Megnyitás a böngészőben A bejelentkezést elutasították. A kód lejárt, mielőtt jóváhagyták volna. Próbálja újra. - Ennek a példánynak még nincs alkalmazás-API-ja. LLeMbas 1.7.0 vagy újabb verzió szükséges hozzá. + Ezen a példányon régebbi LLeMbas fut. Ehhez az alkalmazáshoz LLeMbas 2.0 vagy újabb kell. Ez a példány újabb alkalmazás-API-t használ, mint ez az alkalmazás. Frissítse az alkalmazást. Új csevegés Csevegések @@ -58,6 +58,14 @@ Átdolgozás Mi változzon? Terv végrehajtása + Megjelenítve + Megnyitás + Megnyitás a böngészőben + Másolás + Ez az oldal forráskódja. Magát az oldalt a böngészőben megnyitva láthatja. + Hosszú fájl, ezért egyszerű szövegként jelenik meg. + Ez a szerver még nem tudja átadni a fájlt az alkalmazásnak. Nyissa meg inkább a böngészőben. + Ez a fájl túl nagy a megjelenítéshez; legfeljebb 1 MB jeleníthető meg. Beállítások Példányok Kijelentkezés @@ -74,7 +82,6 @@ Nem választottak elosztót, így az értesítések továbbra is ki vannak kapcsolva. Válaszok Kérdések és jóváhagyások - Jelentések Asszisztens Tegye az LLeMbas-t a telefon digitális asszisztensévé: válassza ki az Alapértelmezett alkalmazások › Digitális asszisztens alkalmazás alatt. A bekapcsológomb lenyomva tartása, az asszisztens-gesztus vagy a lezárási képernyő parancsikonja ezután a képernyőn lévő tartalom felett nyitja meg. Asszisztens beállításainak megnyitása diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 1d77e26..7d0ddec 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -11,7 +11,7 @@ Apri nel browser L\'accesso è stato rifiutato. Il codice è scaduto prima di essere approvato. Riprova. - Questa istanza non ha ancora un\'API per l\'app. Richiede LLeMbas 1.7.0 o una versione più recente. + Questa istanza usa una versione precedente di LLeMbas. Questa app richiede LLeMbas 2.0 o successivo. Questa istanza usa un\'API per l\'app più recente di questa app. Aggiorna l\'app. Nuova chat Chat @@ -58,6 +58,14 @@ Rivedi Cosa dovrebbe cambiare? Esegui il piano + Mostrato + Apri + Apri nel browser + Copia + Questo è il sorgente della pagina. Aprila nel browser per vedere la pagina. + Un file lungo, quindi è mostrato come testo semplice. + Questo server non può ancora passare il file all\'app. Aprilo invece nel browser. + Questo file è troppo grande da mostrare; si può mostrare al massimo 1 MB. Impostazioni Istanze Esci @@ -74,7 +82,6 @@ Non è stato scelto nessun distributore, quindi le notifiche sono ancora disattivate. Risposte Domande e approvazioni - Report Assistente Rendi LLeMbas l\'assistente digitale del telefono: selezionalo in App predefinite › App di assistenza digitale. Tenendo premuto il tasto di accensione, il gesto di assistenza o la scorciatoia della schermata di blocco lo apre quindi sopra qualsiasi cosa sia a schermo. Apri le impostazioni dell\'assistente diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index ea7a56e..6e3ce59 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -11,7 +11,7 @@ Otwórz w przeglądarce Logowanie zostało odrzucone. Kod wygasł, zanim został zatwierdzony. Spróbuj ponownie. - Ta instancja nie ma jeszcze API aplikacji. Wymaga LLeMbas 1.7.0 lub nowszego. + Ta instancja działa na starszym LLeMbas. Ta aplikacja wymaga LLeMbas 2.0 lub nowszego. Ta instancja używa nowszego API aplikacji niż ta aplikacja. Zaktualizuj aplikację. Nowy czat Czaty @@ -58,6 +58,14 @@ Popraw Co powinno się zmienić? Wykonaj plan + Pokazano + Otwórz + Otwórz w przeglądarce + Kopiuj + To jest źródło strony. Otwórz ją w przeglądarce, aby zobaczyć samą stronę. + Długi plik, dlatego jest pokazany jako zwykły tekst. + Ten serwer nie potrafi jeszcze przekazać pliku aplikacji. Otwórz go w przeglądarce. + Ten plik jest za duży, by go pokazać; można pokazać najwyżej 1 MB. Ustawienia Instancje Wyloguj się @@ -74,7 +82,6 @@ Nie wybrano dystrybutora, więc powiadomienia są wciąż wyłączone. Odpowiedzi Pytania i zatwierdzenia - Raporty Asystent Ustaw LLeMbas jako cyfrowego asystenta telefonu: wybierz go w Domyślne aplikacje › Aplikacja asystenta cyfrowego. Przytrzymanie przycisku zasilania, gest asystenta lub skrót z ekranu blokady otwiera go wtedy nad tym, co jest na ekranie. Otwórz ustawienia asystenta diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 95ba657..1332871 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -11,7 +11,7 @@ Otvoriť v prehliadači Prihlásenie bolo odmietnuté. Kód vypršal skôr, než bol schválený. Skúste to znova. - Táto inštancia ešte nemá API pre aplikácie. Potrebuje LLeMbas 1.7.0 alebo novší. + Táto inštancia beží na staršom LLeMbas. Táto aplikácia potrebuje LLeMbas 2.0 alebo novší. Táto inštancia používa novšie API pre aplikácie než táto aplikácia. Aktualizujte aplikáciu. Nová konverzácia Konverzácie @@ -58,6 +58,14 @@ Prepracovať Čo by sa malo zmeniť? Vykonať plán + Zobrazené + Otvoriť + Otvoriť v prehliadači + Kopírovať + Toto je zdrojový kód stránky. Samotnú stránku uvidíte po otvorení v prehliadači. + Dlhý súbor, preto je zobrazený ako obyčajný text. + Tento server zatiaľ nevie aplikácii súbor odovzdať. Otvorte ho v prehliadači. + Tento súbor je príliš veľký na zobrazenie; zobraziť možno najviac 1 MB. Nastavenia Inštancie Odhlásiť sa @@ -74,7 +82,6 @@ Nebol zvolený žiadny distributor, takže upozornenia sú stále vypnuté. Odpovede Otázky a schválenia - Správy Asistent Nastavte LLeMbas ako digitálneho asistenta telefónu: zvoľte ho v Predvolené aplikácie › Digitálny asistent. Podržanie tlačidla napájania, gesto asistenta alebo skratka na uzamknutej obrazovke ho potom otvorí nad tým, čo je práve na obrazovke. Otvoriť nastavenia asistenta diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f7d014c..70fe2ee 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -12,7 +12,7 @@ Open in the browser The sign-in was refused. The code expired before it was approved. Try again. - This instance has no app API yet. It needs LLeMbas 1.7.0 or newer. + This instance runs an older LLeMbas. This app needs LLeMbas 2.0 or newer. This instance speaks a newer app API than this app. Update the app. New chat Chats @@ -59,6 +59,14 @@ Revise What should change? Carry out the plan + Shown + Open + Open in the browser + Copy + This is the page\'s source. Open it in the browser to see the page itself. + A long file, so it is shown as plain text. + This server cannot hand the file to the app yet. Open it in the browser instead. + This file is too large to show here; at most 1 MB can be shown. Settings Instances Sign out @@ -75,7 +83,6 @@ No distributor was chosen, so notifications are still off. Replies Questions and approvals - Reports Assistant Make LLeMbas the phone\'s digital assistant: choose it under Default apps › Digital assistant app. Then holding the power button, the assist gesture or the lock screen\'s shortcut opens it over whatever is on screen. Open the assistant settings diff --git a/app/src/test/java/eu/llembas/android/ShowAndServerTest.kt b/app/src/test/java/eu/llembas/android/ShowAndServerTest.kt new file mode 100644 index 0000000..b03697e --- /dev/null +++ b/app/src/test/java/eu/llembas/android/ShowAndServerTest.kt @@ -0,0 +1,77 @@ +package eu.llembas.android + +import eu.llembas.android.api.Discovery +import eu.llembas.android.api.LembasJson +import eu.llembas.android.api.ServerFit +import eu.llembas.android.api.ToolCall +import eu.llembas.android.api.fit +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Test + +/** + * The `show` card and the server gate. The card's shape is the server's own payload + * (`services/tools/files.py` `_run_show` for a tree file, `services/shown.py` `payload` for a + * device's) -- written out here because the server's contract fixtures do not carry a `show` + * call yet. When they do, this moves into `ContractTest`. + */ +class ShowAndServerTest { + private fun call(json: String) = LembasJson.decodeFromString(ToolCall.serializer(), json) + + @Test + fun aTreeFileShowCard() { + val c = call( + """ + {"id": "call3", "name": "show", "status": "ok", "path": "/home/frodo/notes/road.md", + "show": {"path": "/home/frodo/notes/road.md", "name": "road.md", "kind": "markdown", + "language": "", "line": 12, "node_id": "n1", "version_id": "v7", + "sha": "ab12", "size": 2048, "mime": "text/markdown"}, + "block": {"kind": "show", "title": "/home/frodo/notes/road.md"}} + """, + ) + val show = c.show!! + assertEquals("road.md", show.name) + assertEquals("markdown", show.viewKind) + assertEquals(12, show.line) + assertEquals(listOf("node" to "n1", "version" to "v7"), show.query) + } + + @Test + fun aDeviceFileShowCardNamesTheKeptCopy() { + val c = call( + """ + {"name": "show", "show": {"path": "src/main.rs", "name": "main.rs", "kind": "code", + "language": "rust", "line": 0, "node_id": "", "version_id": "", "sha": "cd34", + "size": 10, "mime": "text/plain", "source": "device", "shown_id": "s9", + "url": "/api/chats/chat1/shown/s9"}} + """, + ) + assertEquals("device", c.show!!.source) + assertEquals(listOf("shown" to "s9"), c.show!!.query) + assertEquals("rust", c.show!!.language) + } + + @Test + fun anUnknownKindIsPlainText() { + val c = call("""{"name": "show", "show": {"path": "x.svg", "kind": "svg"}}""") + assertEquals("text", c.show!!.viewKind) + assertNull(call("""{"name": "bash"}""").show) + } + + private fun discovery(json: String) = LembasJson.decodeFromString(Discovery.serializer(), json) + + @Test + fun onlyAServerOnTheTwoPointOhProtocolFits() { + val two = """{"service": "lembas", "version": "2.0.0-beta.1", "protocol": 3, "protocols": [3], + "app_api": 1, "scopes": ["app", "models"]}""" + assertEquals(ServerFit.FITS, fit(discovery(two))) + // 1.7: protocol 2, the app API already there -- and still refused. + val old = """{"service": "lembas", "version": "1.7.3", "protocol": 2, "protocols": [1, 2], + "app_api": 1, "scopes": ["app", "models"]}""" + assertEquals(ServerFit.TOO_OLD, fit(discovery(old))) + // A server with no protocol at all is older still. + assertEquals(ServerFit.TOO_OLD, fit(discovery("""{"service": "lembas", "app_api": 1, "scopes": ["app"]}"""))) + assertEquals(ServerFit.TOO_NEW, fit(discovery(two.replace("\"app_api\": 1", "\"app_api\": 2")))) + assertEquals(ServerFit.NOT_LEMBAS, fit(discovery("""{"service": "other", "protocol": 3}"""))) + } +} diff --git a/scripts/gen-strings.py b/scripts/gen-strings.py index 3e0888b..5bf705d 100755 --- a/scripts/gen-strings.py +++ b/scripts/gen-strings.py @@ -2,8 +2,15 @@ """Write the app's string resources: English from `strings.py`, the eight translations from the server's catalogues and `strings_own.json`. See `strings.py` for the rule. - scripts/gen-strings.py (server at ../LLeMbas, or LEMBAS_SERVER) - scripts/gen-strings.py --check fail if a key the code uses has no English, or the other way round + scripts/gen-strings.py the catalogues at that ref of the server's git checkout + (../LLeMbas, or LEMBAS_SERVER) -- the same ref the + contract and the tokens are pinned to + scripts/gen-strings.py the server's working tree as it is + scripts/gen-strings.py --check fail if a key the code uses has no English, or the other + way round + +A ref, not the working tree, is the way to regenerate: the server's checkout is shared, and +whatever is uncommitted in it is not what a released server says. """ from __future__ import annotations @@ -12,6 +19,7 @@ import importlib.util import json import os import re +import subprocess import sys from pathlib import Path from xml.sax.saxutils import escape @@ -31,8 +39,18 @@ def android(text: str) -> str: return escape(text).replace("'", "\\'").replace('"', '\\"') -def server_catalogue(code: str) -> dict[str, str]: +def server_catalogue(code: str, ref: str | None = None) -> dict[str, str]: path = SERVER / "src/lembas/web/i18n" / f"{code}.py" + if ref: + shown = subprocess.run( + ["git", "-C", str(SERVER), "show", f"{ref}:src/lembas/web/i18n/{code}.py"], + capture_output=True, text=True, + ) + if shown.returncode != 0: + return {} + scope: dict = {"__name__": f"catalogue_{code}"} + exec(compile(shown.stdout, f"{ref}:{code}.py", "exec"), scope) # the server's own file + return dict(scope.get("MESSAGES", {})) if not path.exists(): return {} spec = importlib.util.spec_from_file_location(f"catalogue_{code}", path) @@ -71,10 +89,17 @@ def main() -> None: if "--check" in sys.argv: print(f"gen-strings: {len(STRINGS)} strings, all used") return + args = [a for a in sys.argv[1:] if not a.startswith("--")] + ref = None + if args: + ref = subprocess.run( + ["git", "-C", str(SERVER), "rev-parse", "--verify", f"{args[0]}^{{commit}}"], + capture_output=True, text=True, check=True, + ).stdout.strip() own = json.loads((Path(__file__).parent / "strings_own.json").read_text(encoding="utf-8")) write(RES / "values", STRINGS) for code in LANGS: - catalogue = server_catalogue(code) + catalogue = server_catalogue(code, ref) mine = own.get(code, {}) out = {} for key, english in STRINGS.items(): @@ -84,7 +109,7 @@ def main() -> None: if text and text.count("%1$s") == english.count("%1$s"): out[key] = text write(RES / f"values-{code}", out) - print(f"gen-strings: {code}: {len(out)}/{len(STRINGS) - 1}") + print(f"gen-strings: {code}: {len(out)}/{len(STRINGS) - 1}" + (f" (server {ref[:12]})" if ref else "")) if __name__ == "__main__": diff --git a/scripts/strings.py b/scripts/strings.py index 95e0c85..62ddce4 100755 --- a/scripts/strings.py +++ b/scripts/strings.py @@ -23,7 +23,7 @@ STRINGS: dict[str, str] = { "signin_open_browser": "Open in the browser", "signin_denied": "The sign-in was refused.", "signin_expired": "The code expired before it was approved. Try again.", - "signin_too_old": "This instance has no app API yet. It needs LLeMbas 1.7.0 or newer.", + "signin_too_old": "This instance runs an older LLeMbas. This app needs LLeMbas 2.0 or newer.", "signin_too_new": "This instance speaks a newer app API than this app. Update the app.", # Chats "new_chat": "New chat", @@ -72,6 +72,15 @@ STRINGS: dict[str, str] = { "plan_revise": "Revise", "plan_what_to_change": "What should change?", "plan_carry_out": "Carry out the plan", + # The file viewer (a `show` card) + "shown": "Shown", + "viewer_open": "Open", + "viewer_open_browser": "Open in the browser", + "viewer_copy": "Copy", + "viewer_html_source": "This is the page's source. Open it in the browser to see the page itself.", + "viewer_long_markdown": "A long file, so it is shown as plain text.", + "viewer_unavailable": "This server cannot hand the file to the app yet. Open it in the browser instead.", + "viewer_too_large": "This file is too large to show here; at most 1 MB can be shown.", # Settings "settings": "Settings", "settings_instances": "Instances", @@ -89,7 +98,6 @@ STRINGS: dict[str, str] = { "push_failed": "No distributor was chosen, so notifications are still off.", "channel_replies": "Replies", "channel_asks": "Questions and approvals", - "channel_reports": "Reports", "settings_assistant": "Assistant", "assistant_explained": "Make LLeMbas the phone's digital assistant: choose it under Default apps › Digital assistant app. Then holding the power button, the assist gesture or the lock screen's shortcut opens it over whatever is on screen.", "assistant_open_settings": "Open the assistant settings", diff --git a/scripts/strings_own.json b/scripts/strings_own.json index af78047..bba7172 100644 --- a/scripts/strings_own.json +++ b/scripts/strings_own.json @@ -45,6 +45,7 @@ "share_default_prompt": "Podívejte se na tohle.", "share_label": "Zeptat se LLeMbas", "share_sending": "Odesílá se do LLeMbas…", + "shown": "Zobrazeno", "signin_address": "Adresa instance", "signin_code_intro": "Otevřete instanci v prohlížeči, přihlaste se a schvalte tento kód:", "signin_denied": "Přihlášení bylo odmítnuto.", @@ -52,7 +53,7 @@ "signin_intro": "Přihlaste se k instanci LLeMbas. Tento telefon schválíte v prohlížeči, stejně jako u CLI.", "signin_open_browser": "Otevřít v prohlížeči", "signin_too_new": "Tato instance používá novější rozhraní API pro aplikace než tato aplikace. Aktualizujte aplikaci.", - "signin_too_old": "Tato instance ještě nemá rozhraní API pro aplikace. Potřebuje LLeMbas 1.7.0 nebo novější.", + "signin_too_old": "Tato instance používá starší LLeMbas. Tato aplikace potřebuje LLeMbas 2.0 nebo novější.", "theme_moria": "Moria (temná)", "theme_shire": "Shire (světlý)", "theme_system": "Podle systému", @@ -62,7 +63,12 @@ "update_check": "Zkontrolovat aktualizaci", "update_installing": "Instaluje se %1$s…", "update_none": "Toto je nejnovější verze.", - "update_unreachable": "Aktualizaci se nepodařilo stáhnout." + "update_unreachable": "Aktualizaci se nepodařilo stáhnout.", + "viewer_html_source": "Toto je zdrojový kód stránky. Samotnou stránku uvidíte po otevření v prohlížeči.", + "viewer_long_markdown": "Dlouhý soubor, proto je zobrazen jako prostý text.", + "viewer_open_browser": "Otevřít v prohlížeči", + "viewer_too_large": "Tento soubor je příliš velký na zobrazení; zobrazit lze nejvýše 1 MB.", + "viewer_unavailable": "Tento server zatím aplikaci soubor předat neumí. Otevřete ho v prohlížeči." }, "de": { "about_version": "LLeMbas für Android %1$s", @@ -110,6 +116,7 @@ "share_default_prompt": "Schauen Sie sich das an.", "share_label": "LLeMbas fragen", "share_sending": "Wird an LLeMbas gesendet…", + "shown": "Angezeigt", "signin_address": "Adresse der Instanz", "signin_code_intro": "Öffnen Sie die Instanz im Browser, melden Sie sich an und bestätigen Sie diesen Code:", "signin_denied": "Die Anmeldung wurde abgelehnt.", @@ -117,7 +124,7 @@ "signin_intro": "Melden Sie sich bei einer LLeMbas-Instanz an. Sie bestätigen dieses Telefon im Browser, genau wie bei der CLI.", "signin_open_browser": "Im Browser öffnen", "signin_too_new": "Diese Instanz spricht eine neuere App-API als diese App. Aktualisieren Sie die App.", - "signin_too_old": "Diese Instanz hat noch keine App-API. Sie braucht LLeMbas 1.7.0 oder neuer.", + "signin_too_old": "Auf dieser Instanz läuft ein älteres LLeMbas. Diese App braucht LLeMbas 2.0 oder neuer.", "theme_moria": "Moria (dunkel)", "theme_shire": "Shire (hell)", "theme_system": "Wie das System", @@ -127,7 +134,12 @@ "update_check": "Nach einem Update suchen", "update_installing": "%1$s wird installiert…", "update_none": "Dies ist die neueste Version.", - "update_unreachable": "Das Update konnte nicht abgerufen werden." + "update_unreachable": "Das Update konnte nicht abgerufen werden.", + "viewer_html_source": "Das ist der Quelltext der Seite. Die Seite selbst sehen Sie im Browser.", + "viewer_long_markdown": "Eine lange Datei, daher wird sie als reiner Text angezeigt.", + "viewer_open_browser": "Im Browser öffnen", + "viewer_too_large": "Diese Datei ist zu groß zum Anzeigen; höchstens 1 MB kann angezeigt werden.", + "viewer_unavailable": "Dieser Server kann die Datei der App noch nicht übergeben. Öffnen Sie sie stattdessen im Browser." }, "es": { "about_version": "LLeMbas para Android %1$s", @@ -175,6 +187,7 @@ "share_default_prompt": "Échele un vistazo a esto.", "share_label": "Preguntar a LLeMbas", "share_sending": "Enviando a LLeMbas…", + "shown": "Mostrado", "signin_address": "Dirección de la instancia", "signin_code_intro": "Abra la instancia en el navegador, inicie sesión y apruebe este código:", "signin_denied": "El inicio de sesión fue rechazado.", @@ -182,7 +195,7 @@ "signin_intro": "Inicie sesión en una instancia de LLeMbas. Aprobará este teléfono en el navegador, igual que haría con la CLI.", "signin_open_browser": "Abrir en el navegador", "signin_too_new": "Esta instancia habla una API de aplicaciones más reciente que esta aplicación. Actualice la aplicación.", - "signin_too_old": "Esta instancia aún no tiene API para aplicaciones. Necesita LLeMbas 1.7.0 o una versión posterior.", + "signin_too_old": "Esta instancia usa una versión anterior de LLeMbas. Esta aplicación necesita LLeMbas 2.0 o posterior.", "theme_moria": "Moria (oscuro)", "theme_shire": "Shire (claro)", "theme_system": "Como el sistema", @@ -192,7 +205,12 @@ "update_check": "Buscar una actualización", "update_installing": "Instalando %1$s…", "update_none": "Esta es la versión más reciente.", - "update_unreachable": "No se pudo obtener la actualización." + "update_unreachable": "No se pudo obtener la actualización.", + "viewer_html_source": "Este es el código fuente de la página. Ábrala en el navegador para ver la página.", + "viewer_long_markdown": "Un archivo largo, por eso se muestra como texto sin formato.", + "viewer_open_browser": "Abrir en el navegador", + "viewer_too_large": "Este archivo es demasiado grande para mostrarlo; se puede mostrar como máximo 1 MB.", + "viewer_unavailable": "Este servidor todavía no puede entregar el archivo a la aplicación. Ábralo en el navegador." }, "fr": { "about_version": "LLeMbas pour Android %1$s", @@ -240,6 +258,7 @@ "share_default_prompt": "Jetez un œil à ceci.", "share_label": "Demander à LLeMbas", "share_sending": "Envoi à LLeMbas…", + "shown": "Affiché", "signin_address": "Adresse de l'instance", "signin_code_intro": "Ouvrez l'instance dans le navigateur, connectez-vous et approuvez ce code :", "signin_denied": "La connexion a été refusée.", @@ -247,7 +266,7 @@ "signin_intro": "Connectez-vous à une instance LLeMbas. Vous approuvez ce téléphone dans le navigateur, comme vous le feriez pour la CLI.", "signin_open_browser": "Ouvrir dans le navigateur", "signin_too_new": "Cette instance utilise une API d'application plus récente que cette application. Mettez à jour l'application.", - "signin_too_old": "Cette instance n'a pas encore d'API pour l'application. Elle nécessite LLeMbas 1.7.0 ou une version plus récente.", + "signin_too_old": "Cette instance utilise une version plus ancienne de LLeMbas. Cette application nécessite LLeMbas 2.0 ou plus récent.", "theme_moria": "Moria (sombre)", "theme_shire": "Shire (clair)", "theme_system": "Comme le système", @@ -257,7 +276,12 @@ "update_check": "Rechercher une mise à jour", "update_installing": "Installation de %1$s…", "update_none": "C'est la version la plus récente.", - "update_unreachable": "La mise à jour n'a pas pu être récupérée." + "update_unreachable": "La mise à jour n'a pas pu être récupérée.", + "viewer_html_source": "Ceci est le code source de la page. Ouvrez-la dans le navigateur pour voir la page elle-même.", + "viewer_long_markdown": "Un fichier long, il est donc affiché en texte brut.", + "viewer_open_browser": "Ouvrir dans le navigateur", + "viewer_too_large": "Ce fichier est trop volumineux pour être affiché ; 1 Mo au plus peut être affiché.", + "viewer_unavailable": "Ce serveur ne peut pas encore transmettre le fichier à l'application. Ouvrez-le plutôt dans le navigateur." }, "hu": { "about_version": "LLeMbas Androidra %1$s", @@ -305,6 +329,7 @@ "share_default_prompt": "Nézze meg ezt.", "share_label": "Kérdés az LLeMbas-tól", "share_sending": "Küldés az LLeMbas-nak…", + "shown": "Megjelenítve", "signin_address": "A példány címe", "signin_code_intro": "Nyissa meg a példányt a böngészőben, jelentkezzen be, és hagyja jóvá ezt a kódot:", "signin_denied": "A bejelentkezést elutasították.", @@ -312,7 +337,7 @@ "signin_intro": "Jelentkezzen be egy LLeMbas példányba. Ezt a telefont a böngészőben hagyja jóvá, ahogyan a CLI-t is tenné.", "signin_open_browser": "Megnyitás a böngészőben", "signin_too_new": "Ez a példány újabb alkalmazás-API-t használ, mint ez az alkalmazás. Frissítse az alkalmazást.", - "signin_too_old": "Ennek a példánynak még nincs alkalmazás-API-ja. LLeMbas 1.7.0 vagy újabb verzió szükséges hozzá.", + "signin_too_old": "Ezen a példányon régebbi LLeMbas fut. Ehhez az alkalmazáshoz LLeMbas 2.0 vagy újabb kell.", "theme_moria": "Moria (sötét)", "theme_shire": "Shire (világos)", "theme_system": "A rendszer szerint", @@ -322,7 +347,12 @@ "update_check": "Frissítés keresése", "update_installing": "%1$s telepítése…", "update_none": "Ez a legújabb verzió.", - "update_unreachable": "A frissítést nem sikerült letölteni." + "update_unreachable": "A frissítést nem sikerült letölteni.", + "viewer_html_source": "Ez az oldal forráskódja. Magát az oldalt a böngészőben megnyitva láthatja.", + "viewer_long_markdown": "Hosszú fájl, ezért egyszerű szövegként jelenik meg.", + "viewer_open_browser": "Megnyitás a böngészőben", + "viewer_too_large": "Ez a fájl túl nagy a megjelenítéshez; legfeljebb 1 MB jeleníthető meg.", + "viewer_unavailable": "Ez a szerver még nem tudja átadni a fájlt az alkalmazásnak. Nyissa meg inkább a böngészőben." }, "it": { "about_version": "LLeMbas per Android %1$s", @@ -370,6 +400,7 @@ "share_default_prompt": "Dai un'occhiata a questo.", "share_label": "Chiedi a LLeMbas", "share_sending": "Invio a LLeMbas…", + "shown": "Mostrato", "signin_address": "Indirizzo dell'istanza", "signin_code_intro": "Apri l'istanza nel browser, accedi e approva questo codice:", "signin_denied": "L'accesso è stato rifiutato.", @@ -377,7 +408,7 @@ "signin_intro": "Accedi a un'istanza LLeMbas. Approvi questo telefono nel browser, come faresti con la CLI.", "signin_open_browser": "Apri nel browser", "signin_too_new": "Questa istanza usa un'API per l'app più recente di questa app. Aggiorna l'app.", - "signin_too_old": "Questa istanza non ha ancora un'API per l'app. Richiede LLeMbas 1.7.0 o una versione più recente.", + "signin_too_old": "Questa istanza usa una versione precedente di LLeMbas. Questa app richiede LLeMbas 2.0 o successivo.", "theme_moria": "Moria (scuro)", "theme_shire": "Shire (chiaro)", "theme_system": "Come il sistema", @@ -387,7 +418,12 @@ "update_check": "Controlla aggiornamenti", "update_installing": "Installazione di %1$s…", "update_none": "Questa è la versione più recente.", - "update_unreachable": "Non è stato possibile scaricare l'aggiornamento." + "update_unreachable": "Non è stato possibile scaricare l'aggiornamento.", + "viewer_html_source": "Questo è il sorgente della pagina. Aprila nel browser per vedere la pagina.", + "viewer_long_markdown": "Un file lungo, quindi è mostrato come testo semplice.", + "viewer_open_browser": "Apri nel browser", + "viewer_too_large": "Questo file è troppo grande da mostrare; si può mostrare al massimo 1 MB.", + "viewer_unavailable": "Questo server non può ancora passare il file all'app. Aprilo invece nel browser." }, "pl": { "about_version": "LLeMbas na Androida %1$s", @@ -435,6 +471,7 @@ "share_default_prompt": "Zobacz to.", "share_label": "Zapytaj LLeMbas", "share_sending": "Wysyłanie do LLeMbas…", + "shown": "Pokazano", "signin_address": "Adres instancji", "signin_code_intro": "Otwórz instancję w przeglądarce, zaloguj się i zatwierdź ten kod:", "signin_denied": "Logowanie zostało odrzucone.", @@ -442,7 +479,7 @@ "signin_intro": "Zaloguj się do instancji LLeMbas. Ten telefon zatwierdza się w przeglądarce, tak jak CLI.", "signin_open_browser": "Otwórz w przeglądarce", "signin_too_new": "Ta instancja używa nowszego API aplikacji niż ta aplikacja. Zaktualizuj aplikację.", - "signin_too_old": "Ta instancja nie ma jeszcze API aplikacji. Wymaga LLeMbas 1.7.0 lub nowszego.", + "signin_too_old": "Ta instancja działa na starszym LLeMbas. Ta aplikacja wymaga LLeMbas 2.0 lub nowszego.", "theme_moria": "Moria (ciemny)", "theme_shire": "Shire (jasny)", "theme_system": "Jak system", @@ -452,7 +489,12 @@ "update_check": "Sprawdź aktualizację", "update_installing": "Instalowanie %1$s…", "update_none": "To jest najnowsza wersja.", - "update_unreachable": "Nie udało się pobrać aktualizacji." + "update_unreachable": "Nie udało się pobrać aktualizacji.", + "viewer_html_source": "To jest źródło strony. Otwórz ją w przeglądarce, aby zobaczyć samą stronę.", + "viewer_long_markdown": "Długi plik, dlatego jest pokazany jako zwykły tekst.", + "viewer_open_browser": "Otwórz w przeglądarce", + "viewer_too_large": "Ten plik jest za duży, by go pokazać; można pokazać najwyżej 1 MB.", + "viewer_unavailable": "Ten serwer nie potrafi jeszcze przekazać pliku aplikacji. Otwórz go w przeglądarce." }, "sk": { "about_version": "LLeMbas pre Android %1$s", @@ -500,6 +542,7 @@ "share_default_prompt": "Pozrite sa na toto.", "share_label": "Spýtať sa LLeMbas", "share_sending": "Odosiela sa do LLeMbas…", + "shown": "Zobrazené", "signin_address": "Adresa inštancie", "signin_code_intro": "Otvorte inštanciu v prehliadači, prihláste sa a schváľte tento kód:", "signin_denied": "Prihlásenie bolo odmietnuté.", @@ -507,7 +550,7 @@ "signin_intro": "Prihláste sa do inštancie LLeMbas. Tento telefón schválite v prehliadači, tak ako by ste schválili CLI.", "signin_open_browser": "Otvoriť v prehliadači", "signin_too_new": "Táto inštancia používa novšie API pre aplikácie než táto aplikácia. Aktualizujte aplikáciu.", - "signin_too_old": "Táto inštancia ešte nemá API pre aplikácie. Potrebuje LLeMbas 1.7.0 alebo novší.", + "signin_too_old": "Táto inštancia beží na staršom LLeMbas. Táto aplikácia potrebuje LLeMbas 2.0 alebo novší.", "theme_moria": "Moria (tmavá)", "theme_shire": "Shire (svetlá)", "theme_system": "Podľa systému", @@ -517,6 +560,11 @@ "update_check": "Skontrolovať aktualizáciu", "update_installing": "Inštaluje sa %1$s…", "update_none": "Toto je najnovšia verzia.", - "update_unreachable": "Aktualizáciu sa nepodarilo stiahnuť." + "update_unreachable": "Aktualizáciu sa nepodarilo stiahnuť.", + "viewer_html_source": "Toto je zdrojový kód stránky. Samotnú stránku uvidíte po otvorení v prehliadači.", + "viewer_long_markdown": "Dlhý súbor, preto je zobrazený ako obyčajný text.", + "viewer_open_browser": "Otvoriť v prehliadači", + "viewer_too_large": "Tento súbor je príliš veľký na zobrazenie; zobraziť možno najviac 1 MB.", + "viewer_unavailable": "Tento server zatiaľ nevie aplikácii súbor odovzdať. Otvorte ho v prehliadači." } }