Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.
Rust androiddocument-scannerdocximage-editorjetpack-composekotlinliquid-glassofflineopen-sourcepdfpdf-compressorpdf-editorpdf-mergerpdf-readerpdf-splitterpdf-toolspdf-viewerpptxspreadsheet-editorxlsx
Sheets go full screen while scrolling (#164); Quick Preview names the file's own type
chethan616a87864f94ee3
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/preview/QuickPreview.kt b/android/app/src/main/java/com/chethan616/clearpdf/preview/QuickPreview.ktindex 060f064..be845ae 100644--- a/android/app/src/main/java/com/chethan616/clearpdf/preview/QuickPreview.kt+++ b/android/app/src/main/java/com/chethan616/clearpdf/preview/QuickPreview.kt@@ -445,7 +445,13 @@ private fun Header()if (ready != null) {Text(- listOf("PDF", androidx.compose.ui.res.pluralStringResource(R.plurals.preview_pages, ready.info.pages.size, ready.info.pages.size), formatSize(ready.size)).joinToString(" · "),+ // the file's own type (a workbook said "PDF · 1 page"); a sheet's rendered pages mean nothing+ listOfNotNull(+ com.chethan616.clearpdf.ui.desk.kindBadge(ready.name).first,+ androidx.compose.ui.res.pluralStringResource(R.plurals.preview_pages, ready.info.pages.size, ready.info.pages.size)+ .takeIf { com.chethan616.clearpdf.engine.DocumentTypes.kindOf(ready.name) != com.chethan616.clearpdf.engine.DocumentTypes.Kind.Sheets },+ formatSize(ready.size),+ ).joinToString(" · "),style = ClearType.Caption, color = c.inkSoft, maxLines = 1,)}diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/sheets/SheetViewer.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/sheets/SheetViewer.ktindex a724a39..e2d3344 100644--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/sheets/SheetViewer.kt+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/sheets/SheetViewer.kt@@ -17,6 +17,7 @@ import androidx.compose.foundation.layout.navigationBarsimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.statusBars+import androidx.compose.foundation.layout.statusBarsIgnoringVisibilityimport androidx.compose.foundation.layout.windowInsetsBottomHeightimport androidx.compose.foundation.layout.windowInsetsTopHeightimport androidx.compose.foundation.rememberScrollState@@ -685,7 +686,9 @@ fun SheetViewer(vm: AppViewModel, doc: OpenDocument) {var input by remember { mutableStateOf("") }var menuAt by remember { mutableStateOf<androidx.compose.ui.geometry.Rect?>(null) }var fillMenuAt by remember { mutableStateOf<androidx.compose.ui.geometry.Rect?>(null) }- val topPx = with(density) { WindowInsets.statusBars.getTop(this) + 64.dp.toPx() } ++ // the status bar's room whether or not it shows, so the sheet doesn't jump when it hides (#164)+ @OptIn(androidx.compose.foundation.layout.ExperimentalLayoutApi::class)+ val topPx = with(density) { WindowInsets.statusBarsIgnoringVisibility.getTop(this) + 64.dp.toPx() } +with(density) { ((if (searching) 56.dp else 0.dp) + (if (grid.selected != null) 56.dp else 0.dp)).toPx() }// the chosen cell's contents, for the formula bar@@ -738,13 +741,47 @@ fun SheetViewer(vm: AppViewModel, doc: OpenDocument) {}}+ // Full screen while reading (#164), as the PDF viewer: the bars slide away as the sheet scrolls and+ // a tap brings them back. They stay while a cell is chosen, typed in or searched for.+ var barsShown by remember { mutableStateOf(true) }+ val busy = searching || editing || grid.selected != null+ LaunchedEffect(grid) {+ var last = grid.pan+ androidx.compose.runtime.snapshotFlow { grid.pan }.collect { p ->+ if ((p - last).getDistance() > 6f && !busy) barsShown = false+ last = p+ }+ }+ LaunchedEffect(busy) { if (busy) barsShown = true }+ val barsIn by androidx.compose.animation.core.animateFloatAsState(if (barsShown) 1f else 0f, com.chethan616.clearpdf.ui.glass.Fluid.quick(), label = "sheetBars")+ val view = androidx.compose.ui.platform.LocalView.current+ androidx.compose.runtime.DisposableEffect(barsShown) {+ val window = (view.context as? android.app.Activity)?.window+ if (window != null) {+ val insets = androidx.core.view.WindowCompat.getInsetsController(window, view)+ insets.systemBarsBehavior = androidx.core.view.WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE+ if (barsShown) insets.show(androidx.core.view.WindowInsetsCompat.Type.systemBars())+ else insets.hide(androidx.core.view.WindowInsetsCompat.Type.systemBars())+ }+ onDispose {+ (view.context as? android.app.Activity)?.window?.let {+ androidx.core.view.WindowCompat.getInsetsController(it, view).show(androidx.core.view.WindowInsetsCompat.Type.systemBars())+ }+ }+ }+val backdrop = rememberLayerBackdrop()val gridFocus = androidx.compose.ui.platform.LocalFocusManager.currentBox(Modifier.fillMaxSize()) {Box(Modifier.fillMaxSize().layerBackdrop(backdrop)) {SheetGrid(grid, top = topPx,- onCell = { cell ->+ onCell = onCell@{ cell ->+ // the bars away (full screen): a tap brings them back, and chooses nothing+ if (!barsShown) {+ barsShown = true+ return@onCell+ }// a tap on the sheet takes the focus from the search field (and its cursor)if (searching) gridFocus.clearFocus()// a tap chooses the cell; a tap on the chosen cell opens it for typing@@ -762,7 +799,7 @@ fun SheetViewer(vm: AppViewModel, doc: OpenDocument) {)}CompositionLocalProvider(LocalBackdrop provides backdrop, LocalGlassInk provides chrome.color) {- Column(Modifier.fillMaxWidth().align(Alignment.TopCenter)) {+ Column(Modifier.fillMaxWidth().align(Alignment.TopCenter).graphicsLayer { translationY = -(1f - barsIn) * size.height; alpha = barsIn }) {Spacer(Modifier.windowInsetsTopHeight(WindowInsets.statusBars))Row(Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 6.dp), verticalAlignment = Alignment.CenterVertically) {GlassCircle(onClick = { vm.closeDocument() }, label = stringResource(R.string.common_back)) { GlassIcon(LucideIcons.ChevronLeft, null, Modifier.size(22.dp)) }@@ -993,7 +1030,7 @@ fun SheetViewer(vm: AppViewModel, doc: OpenDocument) {}}- Column(Modifier.fillMaxWidth().align(Alignment.BottomCenter).imePadding()) {+ Column(Modifier.fillMaxWidth().align(Alignment.BottomCenter).graphicsLayer { translationY = (1f - barsIn) * size.height; alpha = barsIn }.imePadding()) {// the sheets: glass tabs for a few, else a pill with the sheet's name that lists them allval visible = grid.sheets.withIndex().filter { !it.value.hidden }if (visible.size in 2..4) {