From dec2225a9c3f53df96e943300bb663af5d1bbc99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Wed, 18 Nov 2026 21:37:15 +0000 Subject: [PATCH] A notebook's prose is prose on the page; the file copies go when the instance changes A markdown cell had the code's box without its padding. A PDF's page line is read through a derived state, so a scroll redraws it when the page changes and not at every pixel. Switching to another instance clears the cached copies of the first one's files, as signing out does. Co-Authored-By: Claude Fable 5.2 --- .../java/eu/llembas/android/ui/settings/SettingsScreen.kt | 6 +++++- app/src/main/java/eu/llembas/android/ui/viewer/Bodies.kt | 6 ++---- app/src/main/java/eu/llembas/android/ui/viewer/Media.kt | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/llembas/android/ui/settings/SettingsScreen.kt b/app/src/main/java/eu/llembas/android/ui/settings/SettingsScreen.kt index a2d5af7..d15c79e 100644 --- a/app/src/main/java/eu/llembas/android/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/eu/llembas/android/ui/settings/SettingsScreen.kt @@ -256,7 +256,11 @@ fun SettingsScreen(onBack: () -> Unit, onAddInstance: () -> Unit) { val actions = remember { object : SettingsActions { override fun use(instance: Instance) { - scope.launch { store.use(instance.id) } + scope.launch { + store.use(instance.id) + // Copies of one instance's files are not kept around while another is in use. + FileCache.clear(context) + } } override fun add() = onAddInstance() diff --git a/app/src/main/java/eu/llembas/android/ui/viewer/Bodies.kt b/app/src/main/java/eu/llembas/android/ui/viewer/Bodies.kt index 54a81b2..6755900 100644 --- a/app/src/main/java/eu/llembas/android/ui/viewer/Bodies.kt +++ b/app/src/main/java/eu/llembas/android/ui/viewer/Bodies.kt @@ -189,10 +189,8 @@ fun NotebookBody(notebook: Notebook) { Text( cell.source.ifEmpty { " " }, style = if (code) mono else MaterialTheme.typography.bodyMedium.copy(color = palette.ink), - modifier = Modifier - .fillMaxWidth() - .background(if (code) palette.codeBg else palette.bg, RoundedCornerShape(8.dp)) - .padding(if (code) 10.dp else 0.dp), + // Code sits on the code's ground; a cell of prose is prose on the page. + modifier = Modifier.fillMaxWidth().then(if (code) Modifier.background(palette.codeBg, RoundedCornerShape(8.dp)).padding(10.dp) else Modifier), ) if (cell.output.isNotEmpty()) { Text(cell.output, style = mono.copy(color = palette.inkMuted), modifier = Modifier.fillMaxWidth().padding(start = 10.dp, top = 6.dp)) diff --git a/app/src/main/java/eu/llembas/android/ui/viewer/Media.kt b/app/src/main/java/eu/llembas/android/ui/viewer/Media.kt index acb6f82..8542c30 100644 --- a/app/src/main/java/eu/llembas/android/ui/viewer/Media.kt +++ b/app/src/main/java/eu/llembas/android/ui/viewer/Media.kt @@ -32,6 +32,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.produceState @@ -233,6 +234,8 @@ fun PdfBody(path: String, name: String, size: Long, fallback: @Composable (Strin private fun PdfPagesList(pages: PdfPages) { val palette = LocalPalette.current val list = rememberLazyListState() + // Read through a derived state: the line is drawn again when the page changes, not at every pixel of a scroll. + val first by remember { derivedStateOf { list.firstVisibleItemIndex + 1 } } Column(Modifier.fillMaxSize().background(palette.bgSunken)) { BoxWithConstraints(Modifier.weight(1f).fillMaxWidth()) { val width = with(LocalDensity.current) { maxWidth.toPx() }.toInt().coerceIn(1, 1600) @@ -257,7 +260,7 @@ private fun PdfPagesList(pages: PdfPages) { } } Text( - stringResource(R.string.viewer_page, (list.firstVisibleItemIndex + 1).toString(), pages.count.toString()), + stringResource(R.string.viewer_page, first.toString(), pages.count.toString()), style = MaterialTheme.typography.labelMedium, color = palette.inkMuted, modifier = Modifier.fillMaxWidth().background(palette.bg).padding(horizontal = 16.dp, vertical = 8.dp),