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
Bring in hide-on-scroll bars, double-tap-drag zoom and live signature trust
chethan616fa014943c55e
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.ktindex 3b6c0e0..c3185b1 100644--- a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.kt@@ -1301,6 +1301,10 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr}fun signFieldWithId(doc: OpenDocument, w: com.chethan616.clearpdf.core.WidgetInfo) {+ if (!doc.info.readOnlyReason.isNullOrEmpty()) {+ tell(text(R.string.sign_read_only_document))+ return+ }openCertSign(com.chethan616.clearpdf.ui.viewer.CertTarget(doc, w.field, w.page.toInt(), null))}@@ -1506,6 +1510,9 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andrprivate suspend fun applyTrust(eng: Engine) {val paths = withContext(Dispatchers.IO) { trustedCerts.files().map { it.absolutePath } }eng.tool("sign_trust", mapOf("clear" to true, "paths" to paths))+ // The engine redraws trusted signature appearances under a new generation; refresh the+ // document so Compose/page caches request the new pixels and signature state.+ document?.let { refresh(it) }}// ---- Edit PDF ----------------------------------------------------------------------------@@ -1828,7 +1835,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr"checkbox" -> fillField(doc, w.field, !w.on)"radio" -> w.export?.let { fillField(doc, w.field, it) }"text", "combo", "list" -> fieldEdit = com.chethan616.clearpdf.ui.viewer.FieldEdit(doc, w)- // a signed field shows its signature's details; an empty one, a drawn or a digital signature+ // a signed field shows its signature's details; an empty one offers a drawn or a digital signature"signature" -> if (doc.signatures.any { it.field == w.field && it.signed }) {doc.controller.sheet = com.chethan616.clearpdf.ui.viewer.ViewerSheet.Signatures} else {diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.ktindex 0b6c186..cd10d2e 100644--- a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt@@ -2,13 +2,14 @@ package com.chethan616.clearpdf.uiimport androidx.activity.compose.BackHandlerimport androidx.compose.animation.AnimatedVisibility-import androidx.compose.animation.core.FastOutLinearInEasing-import androidx.compose.animation.core.LinearOutSlowInEasingimport androidx.compose.animation.core.MutableTransitionStateimport androidx.compose.animation.core.animate+import androidx.compose.animation.core.springimport androidx.compose.animation.core.tweenimport androidx.compose.animation.fadeInimport androidx.compose.animation.fadeOut+import androidx.compose.animation.scaleIn+import androidx.compose.animation.scaleOutimport androidx.compose.animation.slideInVerticallyimport androidx.compose.animation.slideOutVerticallyimport androidx.compose.foundation.background@@ -16,34 +17,35 @@ import androidx.compose.foundation.clickableimport androidx.compose.foundation.gestures.detectTapGesturesimport androidx.compose.foundation.gestures.detectVerticalDragGesturesimport androidx.compose.foundation.interaction.MutableInteractionSource-import androidx.compose.foundation.layout.WindowInsets-import androidx.compose.foundation.layout.WindowInsetsSides-import androidx.compose.foundation.layout.displayCutout-import androidx.compose.foundation.layout.only-import androidx.compose.foundation.layout.statusBars-import androidx.compose.foundation.layout.union-import androidx.compose.foundation.layout.windowInsetsPadding-import androidx.compose.ui.composedimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.BoxScope+import androidx.compose.foundation.layout.BoxWithConstraintsimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.ColumnScopeimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.RowScopeimport androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.WindowInsets+import androidx.compose.foundation.layout.WindowInsetsSides+import androidx.compose.foundation.layout.displayCutoutimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.heightInimport androidx.compose.foundation.layout.navigationBarsPadding-import androidx.compose.foundation.layout.navigationBars-import androidx.compose.foundation.layout.windowInsetsBottomHeightimport androidx.compose.foundation.layout.offset+import androidx.compose.foundation.layout.onlyimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.statusBars+import androidx.compose.foundation.layout.unionimport androidx.compose.foundation.layout.width+import androidx.compose.foundation.layout.widthIn+import androidx.compose.foundation.layout.windowInsetsPaddingimport androidx.compose.foundation.shape.CircleShape-import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.foundation.text.BasicTextField+import androidx.compose.foundation.text.KeyboardActions+import androidx.compose.foundation.text.KeyboardOptionsimport androidx.compose.material3.Iconimport androidx.compose.material3.Textimport androidx.compose.runtime.Composable@@ -53,49 +55,66 @@ import androidx.compose.runtime.SideEffectimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableFloatStateOfimport androidx.compose.runtime.mutableIntStateOf+import androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.rememberimport androidx.compose.runtime.rememberCoroutineScopeimport androidx.compose.runtime.setValueimport androidx.compose.runtime.staticCompositionLocalOfimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifier-import androidx.compose.foundation.layout.PaddingValues-import androidx.compose.ui.focus.focusRequester-import androidx.compose.foundation.layout.Arrangement-import androidx.compose.runtime.mutableStateOf-import androidx.compose.ui.focus.onFocusChanged-import androidx.compose.foundation.layout.widthIn-import androidx.compose.foundation.layout.imePadding-import androidx.compose.foundation.border+import androidx.compose.ui.composedimport androidx.compose.ui.draw.clip-import androidx.compose.ui.draw.drawBehind+import androidx.compose.ui.focus.FocusRequester+import androidx.compose.ui.focus.focusRequesterimport androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.SolidColorimport androidx.compose.ui.graphics.vector.ImageVectorimport androidx.compose.ui.input.pointer.pointerInputimport androidx.compose.ui.layout.onSizeChanged-import androidx.compose.ui.platform.LocalDensityimport androidx.compose.ui.res.stringResource-import androidx.compose.ui.semantics.Roleimport androidx.compose.ui.semantics.contentDescriptionimport androidx.compose.ui.semantics.semantics-import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.input.PasswordVisualTransformation+import androidx.compose.ui.text.input.VisualTransformationimport androidx.compose.ui.text.style.TextOverflowimport androidx.compose.ui.unit.Dpimport androidx.compose.ui.unit.IntOffsetimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport com.chethan616.clearpdf.R+import com.chethan616.clearpdf.ui.glass.GlassCard+import com.chethan616.clearpdf.ui.glass.GlassCircle+import com.chethan616.clearpdf.ui.glass.GlassDialog+import com.chethan616.clearpdf.ui.glass.GlassIcon+import com.chethan616.clearpdf.ui.glass.GlassOverlay+import com.chethan616.clearpdf.ui.glass.GlassToggle+import com.chethan616.clearpdf.ui.glass.glass+import com.chethan616.clearpdf.ui.glass.pressable+import com.chethan616.clearpdf.ui.theme.Candy+import com.chethan616.clearpdf.ui.theme.ClearType+import com.chethan616.clearpdf.ui.theme.clear+import com.kyant.shapes.Capsule+import com.kyant.shapes.RoundedRectangleimport kotlin.math.roundToIntimport kotlinx.coroutines.launch-/** Motion for sheets: in rising from below, out dropping away. */+/** Motion for sheets and bars. */object PdfMotion {const val SHEET_IN_MS = 250const val SHEET_OUT_MS = 200const val BARS_MS = 300}-/** An icon button of the bars: a 46 dp target with a 24 dp icon, a pressed background when [selected]. */+/**+ * The candy an icon wears in rows and menus: chosen from the icon itself, so one action keeps one+ * colour everywhere it appears. (Lemon and lime are left out: too pale behind a glyph.)+ */+fun iconAccent(icon: ImageVector): Color {+ val palette = listOf(Candy.Tomato, Candy.Tangerine, Candy.Mint, Candy.Sky, Candy.Grape, Candy.Bubblegum)+ return palette[(icon.name.hashCode() and 0x7fffffff) % palette.size]+}++/** An icon button: a jelly press, and a soft candy disc behind it when [selected]. */@Composablefun BarIcon(icon: ImageVector,@@ -111,20 +130,20 @@ fun BarIcon(Box(modifier.size(size)- .clip(RoundedCornerShape(6.dp))- .background(if (selected) pdfColors.pressed else Color.Transparent)- .clickable(enabled = enabled, role = Role.Button, onClick = onClick)+ .pressable(onClick, enabled = enabled)+ .clip(CircleShape)+ .background(if (selected) Candy.Sky.copy(alpha = 0.18f) else Color.Transparent).semantics { contentDescription = description },contentAlignment = Alignment.Center,) {- Icon(icon, contentDescription = null, tint = if (enabled) tint else tint.copy(alpha = 0.38f), modifier = Modifier.size(iconSize))+ Icon(icon, contentDescription = null, tint = if (!enabled) tint.copy(alpha = 0.32f) else if (selected) Candy.Sky else tint, modifier = Modifier.size(iconSize))}}-/** The thin vertical line between groups of a bar. */+/** A thin upright line between groups of a bar. */@Composablefun BarDivider(height: Dp = 26.dp) {- Box(Modifier.width(1.dp).height(height).background(pdfColors.divider))+ Box(Modifier.width(1.dp).height(height).background(clear.line))}/** Whether the sheet being shown is coming in or going ([SheetHost] sets it). */@@ -149,9 +168,9 @@ fun <T : Any> SheetHost(key: T?, content: @Composable (T) -> Unit) {}/**- * A bottom sheet as the reference's viewer uses them: the page stays undimmed behind it (a tap- * there closes it, as does Back), a drag handle at the top, and it can be pulled down to close.- * [maxHeightFraction] caps its height as a fraction of the screen.+ * A sheet: a frosted glass card floating along the bottom, rising on a spring. It lives in the app's+ * overlay portal, so it refracts whatever is really behind it, wherever it's opened from. A tap+ * outside or Back closes it, as does pulling its handle down. [maxHeightFraction] caps its height.*/@Composablefun PdfSheet(@@ -159,94 +178,88 @@ fun PdfSheet(modifier: Modifier = Modifier,dim: Boolean = false,maxHeightFraction: Float = 0.9f,- /** Room kept free above the sheet however tall it grows (the viewer's top bar). */+ /** Room kept free above the sheet however tall it grows. */topReserve: Dp = 0.dp,- /** Whether the sheet paints the band behind the navigation buttons (not when it sits on a bar). */+ /** False when the sheet sits on a bar of its own (it then keeps clear of nothing below). */bottomBand: Boolean = true,- /** The sheet's colour, when not the usual surface (the comment panel's). */+ /** A wash of its own instead of the usual frost. */background: Color? = null,- /** The strip holding the drag handle (the comment panel's is shorter). */handleHeight: Dp = 24.dp,- /** Whether the sheet is [maxHeightFraction] of the screen tall above the navigation buttons' band. */aboveNavBar: Boolean = false,- /** Whether the sheet always takes its full height (its band then stays at the bottom). */+ /** Whether the sheet always takes its full height. */fill: Boolean = false,content: @Composable ColumnScope.() -> Unit,) {val own = remember { MutableTransitionState(false) }LaunchedEffect(own) { own.targetState = true }val visible = LocalSheetVisible.current ?: own- BackHandler(enabled = visible.targetState, onBack = onDismiss)- val scope = rememberCoroutineScope()- var drag by remember { mutableFloatStateOf(0f) }- var height by remember { mutableIntStateOf(0) }- val closeLabel = stringResource(R.string.ui_close_sheet)- Box(Modifier.fillMaxSize()) {- AnimatedVisibility(visible, enter = fadeIn(tween(PdfMotion.SHEET_IN_MS)), exit = fadeOut(tween(PdfMotion.SHEET_OUT_MS))) {- Box(- Modifier- .fillMaxSize()- .background(if (dim) pdfColors.scrim else Color.Transparent)- .clickable(interactionSource = remember { MutableInteractionSource() }, indication = null, onClick = onDismiss)- .semantics { contentDescription = closeLabel },- )- }- val density = LocalDensity.current- val divider = pdfColors.divider- val navBand = pdfColors.navBand- androidx.compose.foundation.layout.BoxWithConstraints(Modifier.fillMaxSize()) {- val navBar = with(density) { WindowInsets.navigationBars.getBottom(density).toDp() }- val maxH = minOf(if (aboveNavBar) maxHeight * maxHeightFraction + navBar else maxHeight * maxHeightFraction, maxHeight - topReserve)- AnimatedVisibility(- visible,- modifier = Modifier.align(Alignment.BottomCenter),- enter = slideInVertically(tween(PdfMotion.SHEET_IN_MS, easing = LinearOutSlowInEasing)) { it },- exit = slideOutVertically(tween(PdfMotion.SHEET_OUT_MS, easing = FastOutLinearInEasing)) { it },- ) {- Column(- modifier- .fillMaxWidth()- .heightIn(max = maxH)- .offset { IntOffset(0, drag.roundToInt()) }- .onSizeChanged { height = it.height }- .background(background ?: pdfColors.surface)- .drawBehind { drawRect(divider, size = androidx.compose.ui.geometry.Size(size.width, 1.dp.toPx())) }- .pointerInput(Unit) { detectTapGestures() },+ GlassOverlay {+ val c = clear+ BackHandler(enabled = visible.targetState, onBack = onDismiss)+ val scope = rememberCoroutineScope()+ var drag by remember { mutableFloatStateOf(0f) }+ var height by remember { mutableIntStateOf(0) }+ val closeLabel = stringResource(R.string.ui_close_sheet)+ Box(Modifier.fillMaxSize()) {+ AnimatedVisibility(visible, enter = fadeIn(tween(PdfMotion.SHEET_IN_MS)), exit = fadeOut(tween(PdfMotion.SHEET_OUT_MS))) {+ Box(+ Modifier.fillMaxSize()+ .background(if (dim) Color.Black.copy(alpha = if (c.dark) 0.42f else 0.22f) else Color.Transparent)+ .clickable(interactionSource = remember { MutableInteractionSource() }, indication = null, onClick = onDismiss)+ .semantics { contentDescription = closeLabel },+ )+ }+ BoxWithConstraints(Modifier.fillMaxSize()) {+ val maxH = minOf(maxHeight * maxHeightFraction, maxHeight - topReserve)+ AnimatedVisibility(+ visible,+ modifier = Modifier.align(Alignment.BottomCenter),+ enter = slideInVertically(spring(dampingRatio = 0.82f, stiffness = 420f)) { it } + fadeIn(tween(160)),+ exit = slideOutVertically(tween(PdfMotion.SHEET_OUT_MS)) { it } + fadeOut(tween(PdfMotion.SHEET_OUT_MS)),) {- // the handle: drag it (or the sheet's top) down to close- Box(- Modifier+ GlassCard(+ modifier+ .then(if (bottomBand) Modifier.navigationBarsPadding() else Modifier)+ .padding(start = 8.dp, end = 8.dp, bottom = 8.dp)+ .widthIn(max = 620.dp).fillMaxWidth()- .height(handleHeight)- .pointerInput(Unit) {+ .heightIn(max = maxH)+ .offset { IntOffset(0, drag.roundToInt()) }+ .onSizeChanged { height = it.height }+ .pointerInput(Unit) { detectTapGestures() },+ shape = RoundedRectangle(32.dp),+ wash = background?.copy(alpha = 0.9f) ?: c.frost,+ blur = 16.dp,+ ) {+ Box(+ Modifier.fillMaxWidth().height(handleHeight).pointerInput(Unit) {detectVerticalDragGestures(onDragEnd = {scope.launch {- if (drag > height / 4f) {- onDismiss()- }- animate(drag, 0f, animationSpec = tween(150)) { v, _ -> drag = v }+ if (drag > height / 4f) onDismiss()+ animate(drag, 0f, animationSpec = spring(dampingRatio = 0.7f, stiffness = 500f)) { v, _ -> drag = v }}},onVerticalDrag = { _, dy -> drag = (drag + dy).coerceAtLeast(0f) },)},- contentAlignment = if (handleHeight < 24.dp) Alignment.TopCenter else Alignment.Center,- ) {- // 8 dp down in a short strip, as the comment panel has it- Box(Modifier.padding(top = if (handleHeight < 24.dp) 8.dp else 0.dp).width(42.dp).height(4.dp).clip(CircleShape).background(pdfColors.handle))+ contentAlignment = Alignment.Center,+ ) {+ Box(Modifier.size(36.dp, 5.dp).clip(Capsule).background(c.inkFaint.copy(alpha = 0.35f)))+ }+ Column(Modifier.weight(1f, fill = fill)) { content() }+ Spacer(Modifier.height(8.dp))}- Column(Modifier.weight(1f, fill = fill)) { content() }- // the band behind the navigation buttons, in the viewer's colour- if (bottomBand) Box(Modifier.fillMaxWidth().windowInsetsBottomHeight(WindowInsets.navigationBars).background(navBand))}}- with(density) { Unit }}}}-/** A row of a sheet: icon, label, then [trailing] (a chevron for drill-in rows). 48 dp tall. */+/**+ * A row of a sheet: its icon on a soft candy blob (the icon's own colour), the label, then+ * [trailing] (a chevron for drill-in rows, a tick when [checked]).+ */@Composablefun SheetRow(icon: ImageVector?,@@ -259,112 +272,88 @@ fun SheetRow(tint: Color? = null,trailing: (@Composable RowScope.() -> Unit)? = null,) {- val c = pdfColors- val color = tint ?: if (checked) c.accent else c.text+ val c = clear+ val danger = tint != null && tint == pdfColors.red+ val accent = when {+ danger -> Candy.Tomato+ tint != null -> tint+ checked -> Candy.Sky+ icon != null -> iconAccent(icon)+ else -> Candy.Sky+ }Row(- modifier- .fillMaxWidth()- .heightIn(min = 48.dp)- .clickable(enabled = enabled, onClick = onClick)- .padding(horizontal = 16.dp),+ modifier.fillMaxWidth().heightIn(min = 52.dp).pressable(onClick, enabled = enabled).padding(horizontal = 16.dp, vertical = 6.dp),verticalAlignment = Alignment.CenterVertically,) {if (icon != null) {- Icon(icon, null, tint = if (enabled) (tint ?: if (checked) c.accent else c.icon) else c.icon.copy(alpha = 0.38f), modifier = Modifier.size(24.dp))- Spacer(Modifier.width(9.dp))+ Box(+ Modifier.size(34.dp).clip(RoundedRectangle(11.dp)).background(accent.copy(alpha = if (c.dark) 0.26f else 0.15f)),+ contentAlignment = Alignment.Center,+ ) { Icon(icon, null, tint = if (enabled) accent else accent.copy(alpha = 0.4f), modifier = Modifier.size(19.dp)) }+ Spacer(Modifier.width(14.dp))}+ val ink = if (danger) Candy.Tomato else if (checked) Candy.Sky else c.inkText(- label,- color = if (enabled) color else color.copy(alpha = 0.38f),- // the reference sets these at 17 sp in a narrower face; 16 sp of Inter matches their width- fontSize = 16.sp,- maxLines = 2,- overflow = TextOverflow.Ellipsis,- modifier = Modifier.weight(1f).padding(vertical = 12.5.dp),+ label, style = ClearType.BodyStrong, color = if (enabled) ink else ink.copy(alpha = 0.38f),+ maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f).padding(vertical = 8.dp),)if (trailing != null) trailing()- if (checked) Icon(LucideIcons.Check, null, tint = c.accent, modifier = Modifier.size(24.dp))- if (chevron) Icon(LucideIcons.ChevronRight, null, tint = c.icon, modifier = Modifier.size(24.dp))+ if (checked) Icon(LucideIcons.Check, null, tint = Candy.Sky, modifier = Modifier.size(22.dp))+ if (chevron) Icon(LucideIcons.ChevronRight, null, tint = c.inkFaint, modifier = Modifier.size(20.dp))}}-/** A sub-sheet's header: a back chevron and a bold title. */+/** A sub-sheet's header: a round glass back button and the title. */@Composablefun SheetBackHeader(title: String, onBack: () -> Unit, trailing: (@Composable RowScope.() -> Unit)? = null) {- Row(Modifier.fillMaxWidth().height(56.dp).padding(start = 4.dp, end = 8.dp), verticalAlignment = Alignment.CenterVertically) {- BarIcon(LucideIcons.ChevronLeft, stringResource(R.string.common_back), onBack)- Spacer(Modifier.width(6.dp))- Text(title, color = pdfColors.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis)+ Row(Modifier.fillMaxWidth().padding(start = 12.dp, end = 10.dp, top = 2.dp, bottom = 8.dp), verticalAlignment = Alignment.CenterVertically) {+ GlassCircle(onClick = onBack, size = 40.dp, label = stringResource(R.string.common_back)) { GlassIcon(LucideIcons.ChevronLeft, null, Modifier.size(20.dp)) }+ Spacer(Modifier.width(12.dp))+ Text(title, style = ClearType.Title, color = clear.ink, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis)if (trailing != null) trailing()}}-/** A sheet's title line. */+/** A sheet's title, in the headline face. */@Composablefun SheetTitle(title: String) {- Text(title, color = pdfColors.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 4.dp, bottom = 12.dp))+ Text(title, style = ClearType.Headline, color = clear.ink, modifier = Modifier.padding(start = 20.dp, end = 20.dp, top = 2.dp, bottom = 12.dp))}-/** A full-width divider line. */+/** A hairline between groups of rows. */@Composablefun SheetDivider(inset: Dp = 16.dp, vertical: Dp = 0.dp) {- Box(Modifier.padding(horizontal = inset, vertical = vertical).fillMaxWidth().height(1.dp).background(pdfColors.divider))+ Box(Modifier.padding(horizontal = inset + 4.dp, vertical = vertical + 4.dp).fillMaxWidth().height(1.dp).background(clear.line))}-/** A divider between groups of rows: the reference leaves 4 dp more either side than a row's own padding. */+/** A divider between groups of rows. */@Composablefun GroupDivider() = SheetDivider(vertical = 4.dp)-/** The hint the reference shows over the page when a tool starts ("Drag across the text to highlight it"). */+/** A hint over the page ("Drag across the text to highlight it"): a frosted glass capsule that pops in. */@Composable-fun BoxScope.HintToast(text: String?, modifier: Modifier = Modifier, alignment: Alignment = Alignment.Center, corner: androidx.compose.ui.unit.Dp = 4.dp) {- androidx.compose.animation.AnimatedVisibility(+fun BoxScope.HintToast(text: String?, modifier: Modifier = Modifier, alignment: Alignment = Alignment.Center, corner: Dp = 4.dp) {+ AnimatedVisibility(visible = text != null,modifier = modifier.align(alignment),- enter = fadeIn(tween(150)),- exit = fadeOut(tween(250)),+ enter = fadeIn(tween(150)) + scaleIn(spring(dampingRatio = 0.6f, stiffness = 500f), initialScale = 0.85f),+ exit = fadeOut(tween(220)) + scaleOut(tween(220), targetScale = 0.92f),) {val last = remember { Last<String>() }if (text != null) last.value = textText(last.value ?: "",- color = pdfColors.onToast,- fontSize = 15.sp,- lineHeight = 20.sp,- // the reference's box: 32 dp tall, 11 dp either side of the text- modifier = Modifier.clip(RoundedCornerShape(corner)).background(pdfColors.toast).padding(horizontal = 11.dp, vertical = 6.dp),+ style = ClearType.Label,+ color = clear.ink,+ modifier = Modifier.padding(horizontal = 24.dp).glass(Capsule, clear.frost, blur = 12.dp).padding(horizontal = 18.dp, vertical = 11.dp),)}}-/** A switch drawn as the reference's: a pill track with a round thumb. */+/** A switch: the glass toggle. */@Composablefun PdfSwitch(checked: Boolean, onChange: (Boolean) -> Unit, modifier: Modifier = Modifier) {- val c = pdfColors- val track = if (checked) c.accent else if (c.dark) Color(0xFF959595) else Color(0xFFB0B0B0)- Box(- modifier- .size(width = 36.dp, height = 18.dp)- .clip(CircleShape)- .background(if (checked) track else Color.Transparent)- .then(if (checked) Modifier else Modifier.background(Color.Transparent))- .clickable(role = Role.Switch) { onChange(!checked) },- ) {- if (!checked) {- Box(Modifier.fillMaxSize().clip(CircleShape).background(track.copy(alpha = 0.0f)))- androidx.compose.foundation.Canvas(Modifier.fillMaxSize()) {- drawRoundRect(track, cornerRadius = androidx.compose.ui.geometry.CornerRadius(size.height / 2), style = androidx.compose.ui.graphics.drawscope.Stroke(2.dp.toPx()))- }- }- Box(- Modifier- .align(if (checked) Alignment.CenterEnd else Alignment.CenterStart)- .padding(horizontal = 4.dp)- .size(10.dp)- .clip(CircleShape)- .background(if (checked) c.surface else track),- )- }+ GlassToggle(checked, onChange, modifier, accent = Candy.Sky)}/**@@ -375,11 +364,7 @@ fun Modifier.safeTopPadding(): Modifier = composed {windowInsetsPadding(WindowInsets.statusBars.union(WindowInsets.displayCutout).only(WindowInsetsSides.Top))}-/**- * A dialog as the reference draws them: a card 51 dp in from the sides with a bold title, the- * content, then an outlined pill (Cancel) and a filled blue pill (OK) at the right. The screen- * behind is veiled (lighter in dark mode, darker in light mode).- */+/** A dialog: the glass dialog, with the candy confirm (tomato when [destructive]). */@Composablefun PdfDialog(onDismiss: () -> Unit,@@ -390,55 +375,25 @@ fun PdfDialog(dismiss: String? = stringResource(R.string.common_cancel),onDismissButton: () -> Unit = onDismiss,destructive: Boolean = false,- /** A choice list's card: lighter grey, narrower, no padding of its own. */+ /** A list of choices: no buttons of its own, usually. */list: Boolean = false,content: (@Composable ColumnScope.() -> Unit)? = null,) {- val c = pdfColors- androidx.compose.ui.window.Dialog(- onDismissRequest = onDismiss,- properties = androidx.compose.ui.window.DialogProperties(usePlatformDefaultWidth = false),+ GlassDialog(+ onDismiss = onDismiss,+ title = title,+ confirm = confirm,+ onConfirm = onConfirm,+ dismiss = dismiss,+ onDismissButton = onDismissButton,+ confirmEnabled = confirmEnabled,+ destructive = destructive,) {- // the screen behind is shaded 60 % black, as the reference's dialogs leave it- val window = (androidx.compose.ui.platform.LocalView.current.parent as? androidx.compose.ui.window.DialogWindowProvider)?.window- androidx.compose.runtime.SideEffect { window?.setDimAmount(0.6f) }- Box(Modifier.fillMaxWidth().padding(horizontal = if (list) 68.dp else 51.dp), contentAlignment = Alignment.Center) {- Column(- Modifier.fillMaxWidth().clip(RoundedCornerShape(4.dp)).background(if (list) (if (c.dark) Color(0xFF424242) else Color.White) else c.surface)- .padding(if (list) PaddingValues(vertical = 8.dp) else PaddingValues(24.dp)),- ) {- if (title != null) {- Text(title, color = c.label, fontSize = 17.sp, fontWeight = FontWeight.SemiBold)- Spacer(Modifier.height(10.dp))- }- content?.invoke(this)- if (confirm != null || dismiss != null) {- Spacer(Modifier.height(20.dp))- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(18.dp, Alignment.End)) {- if (dismiss != null) DialogPill(dismiss, filled = false, enabled = true, onClick = onDismissButton)- if (confirm != null) DialogPill(confirm, filled = true, enabled = confirmEnabled, red = destructive, onClick = onConfirm)- }- }- }- }+ content?.invoke(this)}}-@Composable-private fun DialogPill(label: String, filled: Boolean, enabled: Boolean, red: Boolean = false, onClick: () -> Unit) {- val c = pdfColors- val fill = if (red) c.red else Color(0xFF1473E6)- Box(- Modifier.heightIn(min = 42.dp).widthIn(min = 88.dp).clip(RoundedCornerShape(21.dp))- .then(if (filled) Modifier.background(if (enabled) fill else c.pressed) else Modifier.border(2.dp, c.textSecondary, RoundedCornerShape(21.dp)))- .clickable(enabled = enabled, onClick = onClick).padding(horizontal = 18.dp),- contentAlignment = Alignment.Center,- ) {- Text(label, color = if (filled) (if (enabled) Color.White else c.textSecondary) else c.label, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, maxLines = 1)- }-}--/** A dialog's text field: 48 dp tall, outlined (2 dp blue while focused, red when wrong), its hint in italics. */+/** A dialog's text field: a soft frosted well, tomato when wrong, with an eye for passwords. */@Composablefun PdfField(value: String,@@ -447,41 +402,44 @@ fun PdfField(modifier: Modifier = Modifier,error: Boolean = false,password: Boolean = false,- keyboardOptions: androidx.compose.foundation.text.KeyboardOptions = androidx.compose.foundation.text.KeyboardOptions.Default,- keyboardActions: androidx.compose.foundation.text.KeyboardActions = androidx.compose.foundation.text.KeyboardActions.Default,- focus: androidx.compose.ui.focus.FocusRequester? = null,+ keyboardOptions: KeyboardOptions = KeyboardOptions.Default,+ keyboardActions: KeyboardActions = KeyboardActions.Default,+ focus: FocusRequester? = null,) {- val c = pdfColors- var focused by remember { mutableStateOf(false) }+ val c = clearvar visible by remember { mutableStateOf(false) }Row(- modifier.fillMaxWidth().height(48.dp).clip(RoundedCornerShape(4.dp))- .border(if (focused || error) 2.dp else 1.dp, if (error) c.red else if (focused) Color(0xFF378EF0) else c.textSecondary, RoundedCornerShape(4.dp))- .padding(start = 12.dp),+ modifier.fillMaxWidth().heightIn(min = 50.dp).clip(RoundedRectangle(16.dp))+ .background(if (error) Candy.Tomato.copy(alpha = 0.14f) else if (c.dark) Color.White.copy(alpha = 0.07f) else c.ink.copy(alpha = 0.05f))+ .padding(start = 16.dp),verticalAlignment = Alignment.CenterVertically,) {- Box(Modifier.weight(1f), contentAlignment = Alignment.CenterStart) {- if (value.isEmpty()) Text(placeholder, color = c.textSecondary, fontSize = 16.sp, fontStyle = androidx.compose.ui.text.font.FontStyle.Italic)- androidx.compose.foundation.text.BasicTextField(+ Box(Modifier.weight(1f).padding(vertical = 13.dp), contentAlignment = Alignment.CenterStart) {+ if (value.isEmpty()) Text(placeholder, style = ClearType.Body, color = if (error) Candy.Tomato else c.inkFaint)+ BasicTextField(value = value, onValueChange = onValue, singleLine = true,- textStyle = androidx.compose.ui.text.TextStyle(color = c.text, fontSize = 16.sp),- cursorBrush = androidx.compose.ui.graphics.SolidColor(Color(0xFF378EF0)),- visualTransformation = if (password && !visible) androidx.compose.ui.text.input.PasswordVisualTransformation() else androidx.compose.ui.text.input.VisualTransformation.None,+ textStyle = ClearType.Body.copy(color = c.ink),+ cursorBrush = SolidColor(Candy.Sky),+ visualTransformation = if (password && !visible) PasswordVisualTransformation() else VisualTransformation.None,keyboardOptions = keyboardOptions, keyboardActions = keyboardActions,- modifier = Modifier.fillMaxWidth().then(if (focus != null) Modifier.focusRequester(focus) else Modifier)- .onFocusChanged { focused = it.isFocused }.semantics { contentDescription = placeholder },+ modifier = Modifier.fillMaxWidth().then(if (focus != null) Modifier.focusRequester(focus) else Modifier).semantics { contentDescription = placeholder },+ )+ }+ if (password) {+ BarIcon(+ if (visible) LucideIcons.Eye else LucideIcons.EyeOff, stringResource(if (visible) R.string.ui_hide_password else R.string.ui_show_password),+ { visible = !visible }, size = 46.dp, iconSize = 20.dp, tint = c.inkSoft,)+ } else {+ Spacer(Modifier.width(14.dp))}- if (password) BarIcon(if (visible) LucideIcons.Eye else LucideIcons.EyeOff, stringResource(if (visible) R.string.ui_hide_password else R.string.ui_show_password), { visible = !visible }, size = 48.dp)- else Spacer(Modifier.width(12.dp))}}/*** A short label under an icon (toolbars, tool tiles), centred, on up to [maxLines] lines that* break only between words. A word too wide for the room (a large font size setting) makes the- * whole label a little smaller, down to [minSize], rather than being split: "Organize pages"- * read "Organi / ze pa…" at the largest setting.+ * whole label a little smaller, down to [minSize], rather than being split.*/@Composablefun WordWrapLabel(@@ -501,12 +459,11 @@ fun WordWrapLabel(textAlign = androidx.compose.ui.text.style.TextAlign.Center,),)- androidx.compose.foundation.layout.BoxWithConstraints(modifier, contentAlignment = Alignment.TopCenter) {+ BoxWithConstraints(modifier, contentAlignment = Alignment.TopCenter) {val room = constraints.maxWidthval scale = remember(text, style, room) {val widest = text.split(' ').filter { it.isNotBlank() }.maxOfOrNull { measurer.measure(it, style, softWrap = false, maxLines = 1).size.width } ?: 0- // a little under the exact ratio, so the narrowed word doesn't land a pixel too wideif (room == androidx.compose.ui.unit.Constraints.Infinity || widest <= room || widest == 0) 1felse (room.toFloat() / widest * 0.97f).coerceAtLeast(minSize.value / size.value)}diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Theme.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Theme.ktindex e2ae659..552a007 100644--- a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Theme.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Theme.kt@@ -152,6 +152,48 @@ val pdfColors: PdfColors @Composable get() = LocalPdfColors.current/** How the app chooses light or dark (Preferences ▸ Theme). */enum class ThemeChoice { System, Light, Dark }+/**+ * The viewer's and tool screens' roles in ClearPDF's palette: warm paper surfaces, the theme's ink,+ * candy accents. (Inside [com.chethan616.clearpdf.ui.theme.ClearTheme], so it follows the same theme.)+ */+private fun pdfColorsFrom(cc: com.chethan616.clearpdf.ui.theme.ClearColors): PdfColors {+ val candy = com.chethan616.clearpdf.ui.theme.Candy+ val dark = cc.dark+ val surface = if (dark) Color(0xFF17151E) else Color(0xFFFBF8F4)+ val raised = if (dark) Color(0xFF221F2B) else Color(0xFFF1ECE5)+ return PdfColors(+ dark = dark,+ surface = surface,+ surfaceRaised = raised,+ pressed = if (dark) Color(0xFF2C2836) else Color(0xFFE8E2DA),+ desk = cc.desk,+ pageEdge = if (dark) Color.Transparent else Color(0x1F000000),+ text = cc.ink,+ textSecondary = cc.inkSoft,+ textTertiary = cc.inkFaint,+ icon = cc.ink,+ divider = cc.line,+ handle = cc.inkFaint,+ accent = candy.Sky,+ onAccent = Color.White,+ button = candy.Sky,+ red = candy.Tomato,+ scrim = if (dark) Color(0x99000000) else Color(0x55000000),+ toast = if (dark) Color(0xFF2C2836) else Color(0xFF2A2634),+ onToast = Color.White,+ label = cc.ink,+ toolAccent = candy.Sky,+ navBand = surface,+ menu = surface,+ pageCard = raised,+ home = cc.canvas,+ navigatorText = cc.ink,+ replyBorder = cc.inkSoft,+ switchOff = raised,+ switchOn = candy.Mint,+ )+}+@Composablefun PdfcraftTheme(choice: ThemeChoice = ThemeChoice.System, content: @Composable () -> Unit) {val dark = when (choice) {@@ -159,7 +201,7 @@ fun PdfcraftTheme(choice: ThemeChoice = ThemeChoice.System, content: @ComposableThemeChoice.Light -> falseThemeChoice.Dark -> true}- val c = if (dark) DarkPdfColors else LightPdfColors+ val c = pdfColorsFrom(com.chethan616.clearpdf.ui.theme.LocalClearColors.current)val scheme: ColorScheme = if (dark) {darkColorScheme(primary = c.accent, onPrimary = c.onAccent, surface = c.surface, onSurface = c.text, background = c.surface, onBackground = c.text,surfaceVariant = c.surfaceRaised, onSurfaceVariant = c.textSecondary, outline = c.divider, error = c.red, surfaceContainer = c.surfaceRaised,diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.ktindex 4134aa0..824f27c 100644--- a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.kt@@ -39,12 +39,14 @@ import androidx.compose.ui.input.pointer.pointerInputimport androidx.compose.ui.input.pointer.positionChangedimport androidx.compose.ui.input.pointer.util.VelocityTrackerimport androidx.compose.ui.layout.onSizeChanged+import androidx.compose.ui.platform.LocalContextimport androidx.compose.ui.platform.LocalDensityimport androidx.compose.ui.unit.Dpimport androidx.compose.ui.unit.IntOffsetimport androidx.compose.ui.unit.IntSizeimport androidx.compose.ui.unit.dpimport kotlin.math.abs+import kotlin.math.expimport kotlin.math.roundToIntimport kotlinx.coroutines.CancellationExceptionimport kotlinx.coroutines.Job@@ -66,7 +68,8 @@ private const val WHEEL_TURN_MS = 800L/*** The document view: pages laid out by [state], pinch to zoom, drag and fling to scroll, double- * tap to zoom in or back out (and [onDoubleTap]), tap for [onTap] (bars), long press for [onLongPress]. [overlay]+ * tap to zoom in or back out, double tap and drag to adjust zoom (and [onDoubleTap]), tap for [onTap]+ * (bars), long press for [onLongPress]. [overlay]* draws over the pages in screen space (selection, search hits, comments being made). When* [gesturesEnabled] is false a tool above takes the touches itself. A mouse wheel scrolls (zooms* with Ctrl, then [onWheelZoom]), a mouse drag goes to [onMouseSelect] when there is one, and a@@ -92,9 +95,12 @@ fun PageCanvas(onMouseHover: (Offset) -> Unit = {},/** Ctrl and the wheel zoomed. */onWheelZoom: () -> Unit = {},+ /** The reader scrolled the pages by this many pixels vertically (a finger drag or a fling; a pinch is not). */+ onScroll: (Float) -> Unit = {},overlay: DrawScope.() -> Unit = {},) {val density = LocalDensity.current+ val doubleTapSlop = android.view.ViewConfiguration.get(LocalContext.current).scaledDoubleTapSlopval scope = rememberCoroutineScope()state.gap = with(density) { gap.toPx() }state.margin = with(density) { margin.toPx() }@@ -170,8 +176,14 @@ fun PageCanvas(.pointerInput(state, gesturesEnabled) {if (!gesturesEnabled) return@pointerInputval touchSlop = viewConfiguration.touchSlop+ var lastTapTime = -1L+ var lastTapPosition = Offset.ZeroawaitEachGesture {val down = awaitFirstDown(requireUnconsumed = false)+ val doubleTapDrag = lastTapTime >= 0 &&+ down.uptimeMillis - lastTapTime <= viewConfiguration.doubleTapTimeoutMillis &&+ (down.position - lastTapPosition).getDistance() <= doubleTapSlop+ lastTapTime = -1Lflinger[0]?.cancel()// a drag with the mouse's main button selects text instead of moving the page; the// right and middle buttons still move it@@ -199,6 +211,7 @@ fun PageCanvas(var started = falsevar pinched = falsevar centroid = down.position+ var zoomDrag = falsevar lastChange: PointerInputChange = downwhile (true) {val event = awaitPointerEvent()@@ -212,22 +225,39 @@ fun PageCanvas(if (moved.getDistance() > touchSlop || abs(1f - zoomed) * size.width / 2f > touchSlop) {started = trueonGestureStart()+ if (doubleTapDrag && pressed.size == 1) {+ zoomDrag = true+ onDoubleTap()+ }}}if (started) {- if (pressed.size > 1) {+ if (zoomDrag && pressed.size == 1) {+ state.zoomBy(exp(pan.y * 5f / size.height), down.position)+ } else if (pressed.size > 1) {pinched = trueval c = event.calculateCentroid()centroid = cif (zoomChange != 1f) state.zoomBy(zoomChange, c)}- if (pan != Offset.Zero) state.scrollBy(pan.x, pan.y)+ if (!zoomDrag && pan != Offset.Zero) {+ val left = state.scrollBy(pan.x, pan.y)+ // only what the page really moved: a drag against its end isn't a scroll+ if (pressed.size == 1) onScroll(pan.y - left.y)+ }event.changes.forEach { if (it.positionChanged()) it.consume() }}lastChange = pressed.first()tracker.addPosition(lastChange.uptimeMillis, lastChange.position)}- if (!started) return@awaitEachGesture+ if (!started) {+ if (lastChange.uptimeMillis - down.uptimeMillis < viewConfiguration.longPressTimeoutMillis) {+ lastTapTime = down.uptimeMillis+ lastTapPosition = down.position+ }+ return@awaitEachGesture+ }+ if (zoomDrag) return@awaitEachGestureval v = tracker.calculateVelocity()val velocity = if (pinched) Offset.Zero else Offset(v.x, v.y)val rest = if (pinched) state.pinchRest() else null@@ -236,7 +266,7 @@ fun PageCanvas(val anim = Animatable(state.zoom)anim.animateTo(rest, tween(DOUBLE_TAP_MS)) { state.zoomTo(value, centroid) }} else {- settle(state, velocity, density.density)+ settle(state, velocity, density.density, onScroll)}}}@@ -253,7 +283,7 @@ fun PageCanvas(}/** After a gesture: fling (with decay), or in single-page mode come to rest on a page. */-private suspend fun settle(state: ViewerState, velocity: Offset, density: Float) {+private suspend fun settle(state: ViewerState, velocity: Offset, density: Float, onScroll: (Float) -> Unit) {if (state.mode == PageMode.SinglePage && state.zoom <= 1.01f) {val target = state.snapTarget(velocity.x)val anim = Animatable(state.scrollX)@@ -267,6 +297,7 @@ private suspend fun settle(state: ViewerState, velocity: Offset, density: Float)val d = value - lastlast = valueval left = state.scrollBy(d.x, d.y)+ onScroll(d.y - left.y)// stop at the ends instead of decaying against themif (abs(left.x) > 0.5f && abs(left.y) > 0.5f) throw CancellationException("at the edge")}diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ReadingMode.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ReadingMode.ktindex 33e006a..de670b6 100644--- a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ReadingMode.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ReadingMode.kt@@ -32,6 +32,8 @@ import androidx.compose.ui.Alignmentimport androidx.compose.runtime.mutableStateMapOfimport androidx.compose.foundation.layout.Boximport androidx.compose.ui.graphics.Color+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.input.nestedscroll.nestedScrollimport androidx.compose.ui.input.pointer.pointerInputimport androidx.compose.ui.res.stringResourceimport androidx.compose.ui.text.font.FontWeight@@ -51,12 +53,13 @@ import kotlinx.coroutines.isActive* (a tap hides them). Pinch or double tap changes the text size.*/@Composable-fun ReadingModeContent(vm: AppViewModel, doc: OpenDocument, top: Dp, bottom: Dp, onTap: () -> Unit) {+fun ReadingModeContent(vm: AppViewModel, doc: OpenDocument, top: Dp, bottom: Dp, onTap: () -> Unit, onScroll: (dy: Float, atTop: Boolean) -> Unit = { _, _ -> }) {val c = pdfColorsval night = doc.controller.nightModeval paper = if (night) Color(0xFF1E1E1E) else Color.Whiteval ink = if (night) Color(0xFFE6E6E6) else Color(0xFF1B1B1B)// a file reopened in Reading Mode has its page pending (the page canvas never lays out here)+ val onScrollState = androidx.compose.runtime.rememberUpdatedState(onScroll)val list = rememberLazyListState(initialFirstVisibleItemIndex = (vm.pendingPage ?: doc.viewer.currentPage).coerceIn(0, (doc.pageCount - 1).coerceAtLeast(0)))var size by remember { mutableFloatStateOf(17f) }var hint by remember { mutableStateOf<String?>(null) }@@ -86,7 +89,16 @@ fun ReadingModeContent(vm: AppViewModel, doc: OpenDocument, top: Dp, bottom: Dp,doc.viewer.goToPage(it)}}- Box(Modifier.fillMaxSize()) {+ // what the list scrolled by under the reader's finger, for the bars to follow+ val scrollWatch = remember(list) {+ object : androidx.compose.ui.input.nestedscroll.NestedScrollConnection {+ override fun onPostScroll(consumed: Offset, available: Offset, source: androidx.compose.ui.input.nestedscroll.NestedScrollSource): Offset {+ if (consumed.y != 0f) onScrollState.value(consumed.y, list.firstVisibleItemIndex == 0 && list.firstVisibleItemScrollOffset < 24)+ return Offset.Zero+ }+ }+ }+ Box(Modifier.fillMaxSize().nestedScroll(scrollWatch)) {LazyColumn(state = list,modifier = Modifier.fillMaxSize().background(c.desk)diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.ktindex 7759389..e129386 100644--- a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt@@ -1,84 +1,105 @@package com.chethan616.clearpdf.ui.viewer+import androidx.compose.animation.animateColorAsStateimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.border-import androidx.compose.foundation.clickable-import androidx.compose.foundation.gestures.detectVerticalDragGesturesimport androidx.compose.foundation.horizontalScrollimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.BoxWithConstraintsimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.Spacerimport androidx.compose.foundation.layout.fillMaxHeightimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.height-import androidx.compose.foundation.layout.heightIn-import androidx.compose.foundation.layout.offsetimport androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.requiredSizeimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.widthimport androidx.compose.foundation.layout.widthIn+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.CircleShapeimport androidx.compose.foundation.text.BasicTextFieldimport androidx.compose.foundation.text.KeyboardActionsimport androidx.compose.foundation.text.KeyboardOptionsimport androidx.compose.material3.Iconimport androidx.compose.material3.Textimport androidx.compose.runtime.Composable-import androidx.compose.ui.draw.clip-import androidx.compose.ui.input.pointer.pointerInput-import androidx.compose.runtime.getValue-import androidx.compose.runtime.setValue+import androidx.compose.runtime.CompositionLocalProviderimport androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.runtime.snapshotFlow+import androidx.compose.runtime.staticCompositionLocalOfimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clipimport androidx.compose.ui.draw.drawBehindimport androidx.compose.ui.focus.FocusRequesterimport androidx.compose.ui.focus.focusRequesterimport androidx.compose.ui.geometry.Offset-import androidx.compose.ui.layout.onPlaced-import androidx.compose.ui.layout.onSizeChanged-import androidx.compose.ui.layout.positionInParent+import androidx.compose.ui.geometry.Rectimport androidx.compose.ui.graphics.Color-import androidx.compose.ui.graphics.Path+import androidx.compose.ui.graphics.PathEffectimport androidx.compose.ui.graphics.SolidColor+import androidx.compose.ui.graphics.drawscope.Stroke+import androidx.compose.ui.graphics.graphicsLayerimport androidx.compose.ui.graphics.vector.ImageVector+import androidx.compose.ui.layout.boundsInWindow+import androidx.compose.ui.layout.onGloballyPositioned+import androidx.compose.ui.layout.onPlaced+import androidx.compose.ui.layout.positionInParent+import androidx.compose.ui.platform.LocalConfigurationimport androidx.compose.ui.platform.LocalSoftwareKeyboardControllerimport androidx.compose.ui.res.stringResource-import androidx.compose.ui.semantics.Roleimport androidx.compose.ui.semantics.contentDescriptionimport androidx.compose.ui.semantics.semantics-import androidx.compose.ui.text.TextStyle-import androidx.compose.ui.text.font.FontStyleimport androidx.compose.ui.text.input.ImeAction-import androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.text.style.TextOverflowimport androidx.compose.ui.unit.Dpimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport com.chethan616.clearpdf.R-import com.chethan616.clearpdf.ui.BarDivider-import com.chethan616.clearpdf.ui.BarIcon-import com.chethan616.clearpdf.ui.Interimport com.chethan616.clearpdf.ui.LucideIcons-import com.chethan616.clearpdf.ui.pdfColors+import com.chethan616.clearpdf.ui.glass.GlassCircle+import com.chethan616.clearpdf.ui.glass.GlassIcon+import com.chethan616.clearpdf.ui.glass.GlassMenu+import com.chethan616.clearpdf.ui.glass.GlassMenuItem+import com.chethan616.clearpdf.ui.glass.GlassMotion+import com.chethan616.clearpdf.ui.glass.GlassPill+import com.chethan616.clearpdf.ui.glass.glass+import com.chethan616.clearpdf.ui.glass.pressable+import com.chethan616.clearpdf.ui.iconAccent+import com.chethan616.clearpdf.ui.theme.Candy+import com.chethan616.clearpdf.ui.theme.ClearType+import com.chethan616.clearpdf.ui.theme.clear+import com.kyant.shapes.Capsuleimport kotlinx.coroutines.flow.first-/** The viewer's top bar height (the reference's: 56 dp). */-val TopBarHeight = 57.dp+/** The room the floating top row takes: a 48 dp capsule and its margins. */+val TopBarHeight = 64.dp-/** The bottom quick toolbar's height (the reference's: 70 dp). */-val BottomBarHeight = 70.dp+/** The room the floating bottom dock takes: a 60 dp capsule and its margins. */+val BottomBarHeight = 76.dp++/** The dock has no handle strip of its own. */+val QuickHandleHeight = 0.dp++/** The dock's room. */+val QuickBarHeight = BottomBarHeight/**- * The top bar in plain viewing: back, a divider and the Read aloud switch, then Find, Share and- * More. With a tool active the back arrow becomes a check mark (Done), the switch goes, and Undo- * and Redo appear once there is something to undo.+ * The viewer's floating top row: a round back button, a wide glass capsule with the document's+ * name, the page it's on and Find, then Share and More. With a tool out: a candy Done, the tool's+ * name, and Undo / Redo.*/@Composablefun ViewerTopBar(+ title: String,+ subtitle: String?,+ toolTitle: String?,toolActive: Boolean,doneIsCheck: Boolean,canUndo: Boolean,@@ -86,124 +107,75 @@ fun ViewerTopBar(onBack: () -> Unit,onUndo: () -> Unit,onRedo: () -> Unit,- readingAloud: Boolean,- onReadAloud: () -> Unit,+ onTitle: () -> Unit,onSearch: (() -> Unit)?,onShare: () -> Unit,onMore: () -> Unit,- moreOpen: Boolean,- /** A tool with its own title (Edit PDF): Done, the title and Undo only. */- title: String? = null,- /** What Undo and Redo would take back or bring back, for their menu. */undoLabel: String? = null,redoLabel: String? = null,) {- val c = pdfColors+ val c = clearRow(- Modifier.fillMaxWidth().height(TopBarHeight).background(c.surface).drawBehind {- val line = 1.dp.toPx()- drawRect(c.divider, Offset(0f, size.height - line), androidx.compose.ui.geometry.Size(size.width, line))- }.padding(bottom = 1.dp),+ Modifier.fillMaxWidth().height(TopBarHeight).padding(horizontal = 12.dp),verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.spacedBy(8.dp),) {- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) {- if (toolActive && doneIsCheck) {- BarIcon(LucideIcons.Check, stringResource(R.string.common_done), onBack, tint = c.toolAccent)- } else {- BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), onBack, iconSize = 27.dp)- }- }- if (title != null) {- Spacer(Modifier.width(6.dp))- Text(title, color = c.label, fontSize = 17.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, modifier = Modifier.weight(1f))- UndoMenuButton(canUndo, canRedo, onUndo, onRedo, undoLabel, redoLabel)- Spacer(Modifier.width(10.dp))- return@Row+ if (toolActive && doneIsCheck) {+ GlassCircle(onClick = onBack, tint = Candy.Sky, label = stringResource(R.string.common_done)) { GlassIcon(LucideIcons.Check, null, Modifier.size(22.dp)) }+ } else {+ GlassCircle(onClick = onBack, label = stringResource(R.string.common_back)) { GlassIcon(LucideIcons.ArrowLeft, null, Modifier.size(21.dp)) }}- if (!toolActive) {- BarDivider(height = 24.dp)- Spacer(Modifier.width(14.dp))- // with something to undo the reference shrinks the switch to a plain speaker button- if (canUndo && !readingAloud) BarIcon(LucideIcons.Volume2, stringResource(R.string.common_tool_read_aloud), onReadAloud) else ReadAloudSwitch(readingAloud, onReadAloud)- }- Spacer(Modifier.weight(1f))- // while reading aloud the bar holds only back and the switch, as the reference's- if (readingAloud && !toolActive) {- Spacer(Modifier.width(10.dp))- return@Row+ GlassPill(onClick = onTitle, modifier = Modifier.weight(1f), height = 48.dp, horizontalPadding = 16.dp) {+ if (toolTitle != null) Box(Modifier.size(9.dp).clip(CircleShape).background(Candy.Sky))+ Column(Modifier.weight(1f)) {+ Text(toolTitle ?: title, style = ClearType.Title.copy(fontSize = 16.sp, lineHeight = 19.sp), color = c.ink, maxLines = 1, overflow = TextOverflow.Ellipsis)+ if (subtitle != null && toolTitle == null) Text(subtitle, style = ClearType.Caption, color = c.inkSoft, maxLines = 1)+ }+ if (onSearch != null && !toolActive) {+ Box(Modifier.size(36.dp).pressable(onSearch).semantics { contentDescription = "" }, contentAlignment = Alignment.Center) {+ Icon(LucideIcons.Search, stringResource(R.string.viewer_find_in_document), tint = c.ink, modifier = Modifier.size(20.dp))+ }+ }}if (toolActive) {if (canUndo || canRedo) {- BarIcon(LucideIcons.Undo2, stringResource(R.string.common_undo), onUndo, enabled = canUndo)- BarIcon(LucideIcons.Redo2, stringResource(R.string.common_redo), onRedo, enabled = canRedo)+ GlassCircle(onClick = { if (canUndo) onUndo() }, label = stringResource(R.string.common_undo)) {+ GlassIcon(LucideIcons.Undo2, null, Modifier.size(20.dp), tint = if (canUndo) Color.Unspecified else c.inkFaint)+ }+ GlassCircle(onClick = { if (canRedo) onRedo() }, label = stringResource(R.string.common_redo)) {+ GlassIcon(LucideIcons.Redo2, null, Modifier.size(20.dp), tint = if (canRedo) Color.Unspecified else c.inkFaint)+ }}- } else if (canUndo) {- UndoMenuButton(canUndo, canRedo, onUndo, onRedo, undoLabel, redoLabel)+ } else {+ if (canUndo) UndoMenuButton(canUndo, canRedo, onUndo, onRedo, undoLabel, redoLabel)+ GlassCircle(onClick = onShare, label = stringResource(R.string.common_share)) { GlassIcon(LucideIcons.Share2, null, Modifier.size(20.dp)) }+ GlassCircle(onClick = onMore, label = stringResource(R.string.common_more_options)) { GlassIcon(LucideIcons.Ellipsis, null, Modifier.size(21.dp)) }}- if (onSearch != null) BarIcon(LucideIcons.Search, stringResource(R.string.viewer_find_in_document), onSearch)- BarIcon(LucideIcons.Share2, stringResource(R.string.common_share), onShare)- BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.common_more_options), onMore, selected = moreOpen)- Spacer(Modifier.width(10.dp))}}-/** Undo with a corner mark: a tap opens Undo and Redo. */+/** Undo as a glass circle: a tap opens a menu naming what Undo and Redo would do. */@Composablefun UndoMenuButton(canUndo: Boolean, canRedo: Boolean, onUndo: () -> Unit, onRedo: () -> Unit, undoLabel: String? = null, redoLabel: String? = null) {- val c = pdfColors- var open by androidx.compose.runtime.remember { androidx.compose.runtime.mutableStateOf(false) }- val undoOrRedo = stringResource(R.string.viewer_undo_or_redo)- Box {- Box(- Modifier.size(46.dp).clickable(enabled = canUndo || canRedo, role = Role.Button) { open = true }.semantics { contentDescription = undoOrRedo },- contentAlignment = Alignment.Center,- ) {- val tint = if (canUndo || canRedo) c.icon else c.icon.copy(alpha = 0.38f)- Icon(LucideIcons.Undo2, null, tint = tint, modifier = Modifier.size(24.dp))- Box(Modifier.size(6.dp).offset(x = 12.dp, y = 10.dp).drawBehind {- val p = Path().apply { moveTo(size.width, 0f); lineTo(size.width, size.height); lineTo(0f, size.height); close() }- drawPath(p, tint)- })- }- androidx.compose.material3.DropdownMenu(expanded = open, onDismissRequest = { open = false }, containerColor = c.menu) {- androidx.compose.material3.DropdownMenuItem(- text = { Text(undoLabel?.let { stringResource(R.string.viewer_undo_named, it) } ?: stringResource(R.string.common_undo), color = c.text) }, enabled = canUndo,- leadingIcon = { Icon(LucideIcons.Undo2, null, tint = c.icon) }, onClick = { open = false; onUndo() },- )- androidx.compose.material3.DropdownMenuItem(- text = { Text(redoLabel?.let { stringResource(R.string.viewer_redo_named, it) } ?: stringResource(R.string.common_redo), color = c.text) }, enabled = canRedo,- leadingIcon = { Icon(LucideIcons.Redo2, null, tint = c.icon) }, onClick = { open = false; onRedo() },- )- }- }-}--/** Read aloud as the reference shows it: a switch whose knob carries a speaker (crossed out while off). */-@Composable-private fun ReadAloudSwitch(on: Boolean, onToggle: () -> Unit) {- val c = pdfColors- val knob by androidx.compose.animation.core.animateDpAsState(if (on) 22.dp else 2.dp, label = "knob")- val track by androidx.compose.animation.animateColorAsState(if (on) c.switchOn else c.switchOff, label = "track")- val readAloud = stringResource(R.string.common_tool_read_aloud)- Box(- Modifier.size(width = 56.dp, height = 40.dp).clickable(role = Role.Switch, onClick = onToggle).semantics { contentDescription = readAloud },- contentAlignment = Alignment.CenterStart,- ) {- Box(Modifier.size(width = 56.dp, height = 28.dp).background(track, androidx.compose.foundation.shape.RoundedCornerShape(14.dp))) {- Box(- Modifier.offset(x = knob, y = 2.dp).size(width = 32.dp, height = 24.dp).background(Color.White, androidx.compose.foundation.shape.RoundedCornerShape(12.dp)),- contentAlignment = Alignment.Center,- ) {- Icon(if (on) LucideIcons.Volume2 else LucideIcons.VolumeOff, null, tint = Color(0xFF222222), modifier = Modifier.size(16.dp))- }+ var open by remember { mutableStateOf(false) }+ var anchor by remember { mutableStateOf(Rect.Zero) }+ GlassCircle(+ onClick = { if (canUndo || canRedo) open = true },+ modifier = Modifier.onGloballyPositioned { anchor = it.boundsInWindow() },+ label = stringResource(R.string.viewer_undo_or_redo),+ ) { GlassIcon(LucideIcons.Undo2, null, Modifier.size(20.dp)) }+ if (open) {+ val items = buildList {+ if (canUndo) add(GlassMenuItem(undoLabel?.let { stringResource(R.string.viewer_undo_named, it) } ?: stringResource(R.string.common_undo), LucideIcons.Undo2, onClick = onUndo))+ if (canRedo) add(GlassMenuItem(redoLabel?.let { stringResource(R.string.viewer_redo_named, it) } ?: stringResource(R.string.common_redo), LucideIcons.Redo2, onClick = onRedo))}+ GlassMenu(anchor, { open = false }, items)}}/**- * Find in the top bar: collapse, the query field (searched on submit), then clear, Previous and- * Next, greyed until they can be used. Like the reference, it shows no hit counter, unless Extra- * Features asks for one: [count], "3 of 12", between the field and the buttons.+ * Find, floating where the top row was: a round close button, then a glass capsule holding the+ * field, the "3 of 12" count (Extra Features), clear, Previous and Next.*/@Composablefun SearchBar(@@ -217,105 +189,68 @@ fun SearchBar(onNext: () -> Unit,count: String? = null,) {- val c = pdfColors+ val c = clearval focus = remember { FocusRequester() }val keyboard = LocalSoftwareKeyboardController.currentval findLabel = stringResource(R.string.viewer_find_in_document)LaunchedEffect(Unit) { focus.requestFocus() }Row(- Modifier.fillMaxWidth().height(TopBarHeight).background(c.surface).drawBehind {- val line = 1.dp.toPx()- drawRect(c.divider, Offset(0f, size.height - line), androidx.compose.ui.geometry.Size(size.width, line))- }.padding(bottom = 1.dp),+ Modifier.fillMaxWidth().height(TopBarHeight).padding(horizontal = 12.dp),verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.spacedBy(8.dp),) {- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.viewer_collapse), onClose, iconSize = 27.dp) }- Box(- Modifier.weight(1f).padding(horizontal = 8.dp).height(40.dp).drawBehind {- drawLine(c.textSecondary, Offset(0f, size.height - 1f), Offset(size.width, size.height - 1f), 1.5f)- },- contentAlignment = Alignment.CenterStart,+ GlassCircle(onClick = onClose, label = stringResource(R.string.viewer_collapse)) { GlassIcon(LucideIcons.ArrowLeft, null, Modifier.size(21.dp)) }+ Row(+ Modifier.weight(1f).height(48.dp).glass(Capsule, blur = 6.dp).padding(start = 16.dp, end = 4.dp),+ verticalAlignment = Alignment.CenterVertically,) {+ Icon(LucideIcons.Search, null, tint = c.inkSoft, modifier = Modifier.size(18.dp))+ Spacer(Modifier.width(10.dp))BasicTextField(value = query,onValueChange = onQuery,singleLine = true,- textStyle = TextStyle(fontFamily = Inter, fontSize = 17.sp, color = c.text),- cursorBrush = SolidColor(c.accent),+ textStyle = ClearType.Body.copy(color = c.ink),+ cursorBrush = SolidColor(Candy.Tomato),keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),keyboardActions = KeyboardActions(onSearch = {keyboard?.hide()onSubmit()}),- modifier = Modifier.fillMaxWidth().focusRequester(focus).semantics { contentDescription = findLabel },+ modifier = Modifier.weight(1f).focusRequester(focus).semantics { contentDescription = findLabel },decorationBox = { inner ->Box(contentAlignment = Alignment.CenterStart) {- if (query.isEmpty()) Text(findLabel, color = c.textSecondary, fontSize = 17.sp, fontStyle = FontStyle.Italic)+ if (query.isEmpty()) Text(findLabel, style = ClearType.Body, color = c.inkFaint, maxLines = 1)inner()}},)+ if (count != null) Text(count, style = ClearType.Label, color = c.inkSoft, maxLines = 1, modifier = Modifier.padding(horizontal = 4.dp))+ if (query.isNotEmpty()) StepButton(LucideIcons.X, stringResource(R.string.common_clear), true, onClear)+ StepButton(LucideIcons.ChevronUp, stringResource(R.string.viewer_find_previous), canStep, onPrev)+ StepButton(LucideIcons.ChevronDown, stringResource(R.string.viewer_find_next), canStep, onNext)}- if (count != null) Text(count, color = c.textSecondary, fontSize = 15.sp, maxLines = 1, modifier = Modifier.padding(horizontal = 4.dp))- BarIcon(LucideIcons.X, stringResource(R.string.common_clear), onClear, size = 40.dp, enabled = query.isNotEmpty())- BarIcon(LucideIcons.ChevronLeft, stringResource(R.string.viewer_find_previous), onPrev, enabled = canStep, size = 40.dp)- BarIcon(LucideIcons.ChevronRight, stringResource(R.string.viewer_find_next), onNext, enabled = canStep, size = 40.dp)- Spacer(Modifier.width(6.dp))}}-/**- * An item of the bottom quick toolbar, laid out as the reference does: 5 dp down, the icon in a- * 44 dp box (shaded while its tool is open), the label straight under it, and a corner mark when- * the tool has sub-tools. As the reference's, the label follows the phone's font size setting: the- * item grows taller to hold it, and a long label wraps onto a second line (in a fixed height, a- * large font setting cut the labels off at the bottom).- */@Composable-private fun QuickItem(icon: ImageVector, label: String, onClick: () -> Unit, subTools: Boolean = false, selected: Boolean = false, width: Dp) {- val c = pdfColors- Column(- Modifier.width(width).heightIn(min = BottomBarHeight).clickable(role = Role.Button, onClick = onClick).semantics { contentDescription = label }- .padding(horizontal = 2.dp, vertical = 5.dp),- horizontalAlignment = Alignment.CenterHorizontally,- ) {- Box(- Modifier.size(44.dp).offset(y = 2.5.dp).background(if (selected) c.divider else Color.Transparent, androidx.compose.foundation.shape.RoundedCornerShape(4.dp)),- contentAlignment = Alignment.Center,- ) {- Icon(icon, null, tint = c.icon, modifier = Modifier.size(24.dp))- if (subTools) {- // the small corner triangle: this tool has a row of sub-tools- val tint = c.cornerMark- Box(Modifier.size(6.dp).offset(x = 16.dp, y = 13.dp).drawBehind {- val p = Path().apply { moveTo(size.width, 0f); lineTo(size.width, size.height); lineTo(0f, size.height); close() }- drawPath(p, tint)- })- }- }- // the reference's 11 sp face is narrower than Inter: a half point less gives its height, and- // tighter letters its width; lines close together, so a wrapped label stays one block, and- // a word too wide for its slot (a very large font setting) shrinks rather than splits- com.chethan616.clearpdf.ui.WordWrapLabel(- label, c.label, size = 10.5.sp, lineHeight = 13.sp, letterSpacing = (-0.5).sp,- modifier = Modifier.padding(top = 2.5.dp),- )+private fun StepButton(icon: ImageVector, label: String, enabled: Boolean, onClick: () -> Unit) {+ val c = clear+ Box(Modifier.size(38.dp).pressable(onClick, enabled = enabled).semantics { contentDescription = label }, contentAlignment = Alignment.Center) {+ Icon(icon, null, tint = if (enabled) c.ink else c.inkFaint, modifier = Modifier.size(19.dp))}}-/** The strip above the quick toolbar's tools that holds its handle. */-val QuickHandleHeight = 22.dp--/** The quick toolbar's height with its handle, the shortcuts folded away. */-val QuickBarHeight = BottomBarHeight + QuickHandleHeight--/** A shortcut in the row the quick toolbar's handle pulls up. */-class QuickChip(val label: String, val icon: ImageVector, val tint: Color, val onClick: () -> Unit)+/** How many tools fit in the dock at a screen [widthDp] wide (More tools takes its own bubble). */+private fun dockSlots(widthDp: Int): Int = when {+ widthDp >= 768 -> 8+ widthDp >= 460 -> 6+ else -> 5+}/**- * The quick toolbar: a handle, then the tools the user keeps there (the reference's six at first)- * and More tools. Pulling the handle up (or tapping it) shows a row of [chips] above the tools,- * scrolling sideways; pulling it down folds them away. No line along its top, as the reference.+ * The floating dock: the tools the reader keeps there, each glyph in its own candy, on a glass+ * capsule, and More tools as a grape bubble beside it.*/@Composablefun QuickToolbar(@@ -323,191 +258,153 @@ fun QuickToolbar(onTool: (QuickTool) -> Unit,onMoreTools: () -> Unit,moreToolsOpen: Boolean,- chips: List<QuickChip> = emptyList(),- /** How much taller than usual the tools' row is (a large font setting), in pixels. */- onExtraHeight: (Int) -> Unit = {},) {- val c = pdfColors- var open by remember { androidx.compose.runtime.mutableStateOf(false) }- val handleLabel = stringResource(if (open) R.string.viewer_hide_shortcuts else R.string.viewer_show_shortcuts)- androidx.compose.foundation.layout.BoxWithConstraints(Modifier.fillMaxWidth().background(c.surface)) {- val slots = toolbarSlots(androidx.compose.ui.platform.LocalConfiguration.current.screenWidthDp)- val shown = tools.take(slots)- val itemW = minOf(72.dp, (maxWidth - 16.dp) / maxOf(7, shown.size + 1))- Column(- Modifier.fillMaxWidth().pointerInput(chips.isNotEmpty()) {- if (chips.isEmpty()) return@pointerInput- var pulled = 0f- detectVerticalDragGestures(- onDragStart = { pulled = 0f },- onDragEnd = { if (pulled < -8f) open = true else if (pulled > 8f) open = false },- ) { _, dy -> pulled += dy }- },- ) {- Box(- Modifier.fillMaxWidth().height(QuickHandleHeight)- .clickable(enabled = chips.isNotEmpty(), role = Role.Button) { open = !open }- .semantics { contentDescription = handleLabel },- contentAlignment = Alignment.TopCenter,- ) {- // measured on the dark bar; the light bar's grey is our own match- val handle = if (c.dark) Color(0xFF6A6A6A) else Color(0xFFC4C4C4)- Box(Modifier.padding(top = 15.dp).size(40.dp, 4.dp).background(handle, androidx.compose.foundation.shape.RoundedCornerShape(2.dp)))- }- androidx.compose.animation.AnimatedVisibility(open && chips.isNotEmpty()) {- Row(- Modifier.fillMaxWidth().horizontalScroll(androidx.compose.foundation.rememberScrollState())- .padding(start = 18.dp, end = 18.dp, top = 5.dp, bottom = 10.dp),- horizontalArrangement = Arrangement.spacedBy(11.dp),- ) { for (chip in chips) QuickChipView(chip) }- }- val usual = with(androidx.compose.ui.platform.LocalDensity.current) { BottomBarHeight.roundToPx() }- Row(- Modifier.fillMaxWidth().heightIn(min = BottomBarHeight)- .onSizeChanged { onExtraHeight((it.height - usual).coerceAtLeast(0)) },- horizontalArrangement = Arrangement.Center,- ) {- for (t in shown) QuickItem(t.icon, stringResource(t.label), { onTool(t) }, subTools = t.subTools, width = itemW)- QuickItem(LucideIcons.LayoutGrid, stringResource(R.string.common_tool_more_tools), onMoreTools, selected = moreToolsOpen, width = itemW)- }- }- }-}--/** One shortcut: its coloured icon and name on a dark rounded box, 37 dp tall. */-@Composable-private fun QuickChipView(chip: QuickChip) {- val c = pdfColors- val shape = androidx.compose.foundation.shape.RoundedCornerShape(6.dp)+ val slots = dockSlots(LocalConfiguration.current.screenWidthDp)+ val shown = tools.take(slots)+ val turn by androidx.compose.animation.core.animateFloatAsState(if (moreToolsOpen) 45f else 0f, GlassMotion.morph(), label = "more")Row(- Modifier.heightIn(min = 37.dp).clip(shape).background(if (c.dark) Color(0xFF080808) else Color(0xFFEDEDED))- .clickable(role = Role.Button, onClick = chip.onClick).padding(start = 7.dp, end = 10.dp),+ Modifier.fillMaxWidth().height(BottomBarHeight).padding(horizontal = 12.dp, vertical = 8.dp),verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.spacedBy(10.dp),) {- // sized against the reference: its icon draws about 18 dp, its name 14 sp in a narrower face- Icon(chip.icon, null, tint = chip.tint, modifier = Modifier.size(21.dp))- Spacer(Modifier.width(8.dp))- Text(chip.label, color = c.text, fontSize = 14.sp, letterSpacing = (-0.65).sp, maxLines = 1)+ Row(Modifier.weight(1f).fillMaxHeight().glass(Capsule, blur = 6.dp).padding(horizontal = 6.dp), verticalAlignment = Alignment.CenterVertically) {+ for (t in shown) DockItem(t.icon, stringResource(t.label), iconAccent(t.icon)) { onTool(t) }+ }+ GlassCircle(onClick = onMoreTools, size = 60.dp, tint = Candy.Grape, label = stringResource(R.string.common_tool_more_tools)) {+ GlassIcon(LucideIcons.LayoutGrid, null, Modifier.size(24.dp).androidxRotate(turn))+ }}}-/** The 1 dp line the reference draws along the top of its bottom bars, just above them. */+private fun Modifier.androidxRotate(degrees: Float) = this.graphicsLayer { rotationZ = degrees }+@Composable-fun Modifier.barTopLine(): Modifier {- val color = pdfColors.divider- return drawBehind {- val line = 1.dp.toPx()- drawRect(color, Offset(0f, -line), androidx.compose.ui.geometry.Size(size.width, line))+private fun androidx.compose.foundation.layout.RowScope.DockItem(icon: ImageVector, label: String, accent: Color, onClick: () -> Unit) {+ val c = clear+ Column(+ Modifier.weight(1f).fillMaxHeight().pressable(onClick, pressedScale = 0.88f).semantics { contentDescription = label },+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.Center,+ ) {+ Icon(icon, null, tint = accent, modifier = Modifier.size(22.dp))+ Spacer(Modifier.height(3.dp))+ Text(label, style = ClearType.Caption.copy(fontSize = 10.5.sp, lineHeight = 12.sp), color = c.ink, maxLines = 1, overflow = TextOverflow.Ellipsis)}}+/** No line along bars any more: glass floats. Kept so the tools' own bars can call it. */+fun Modifier.barTopLine(): Modifier = this+/**- * A tool's sub-toolbar: its buttons centred on the bar, groups split by thin lines. As the reference:- * the buttons keep their size, and when they don't all fit (a narrow screen, a large display size)- * the bar scrolls sideways, sliding to a tool when it's chosen. (Squeezing the buttons together to- * fit was tried and left out; see docs/parity-mobile.md, "Tool bars on narrow screens".)+ * A tool's sub-toolbar: its buttons on a floating glass capsule, centred, sliding sideways when they+ * don't all fit (to a tool when it's chosen).*/@Composablefun SubToolbar(content: @Composable () -> Unit) {- val scroll = androidx.compose.foundation.rememberScrollState()- androidx.compose.foundation.layout.BoxWithConstraints(Modifier.fillMaxWidth().height(BottomBarHeight).barTopLine().background(pdfColors.surface)) {+ val scroll = rememberScrollState()+ BoxWithConstraints(Modifier.fillMaxWidth().height(BottomBarHeight).padding(horizontal = 12.dp, vertical = 8.dp), contentAlignment = Alignment.Center) {Row(- Modifier.fillMaxHeight().horizontalScroll(scroll).widthIn(min = maxWidth),+ Modifier.widthIn(max = maxWidth).fillMaxHeight().glass(Capsule, blur = 6.dp).horizontalScroll(scroll).padding(horizontal = 8.dp),horizontalArrangement = Arrangement.Center,verticalAlignment = Alignment.CenterVertically,- ) { androidx.compose.runtime.CompositionLocalProvider(LocalSubToolbarScroll provides scroll) { content() } }+ ) { CompositionLocalProvider(LocalSubToolbarScroll provides scroll) { content() } }}}/** The scrolling bar a sub-toolbar tool sits in (none outside one). */-private val LocalSubToolbarScroll = androidx.compose.runtime.staticCompositionLocalOf<androidx.compose.foundation.ScrollState?> { null }+private val LocalSubToolbarScroll = staticCompositionLocalOf<androidx.compose.foundation.ScrollState?> { null }/** When the tool becomes the chosen one, the bar scrolls to bring it to the start (as far as it goes). */@Composableprivate fun Modifier.slideToWhenChosen(selected: Boolean): Modifier {val scroll = LocalSubToolbarScroll.current ?: return this- var x by remember { androidx.compose.runtime.mutableStateOf<Int?>(null) }+ var x by remember { mutableStateOf<Int?>(null) }LaunchedEffect(selected) {if (!selected) return@LaunchedEffect- // once the tool has been placed on the bar- val at = androidx.compose.runtime.snapshotFlow { x }.first { it != null } ?: return@LaunchedEffect+ val at = snapshotFlow { x }.first { it != null } ?: return@LaunchedEffectscroll.animateScrollTo(at)}return onPlaced { x = it.positionInParent().x.toInt() }}-/** A sub-toolbar tool: 62 dp apart, as the reference spaces them. */+/** A sub-toolbar tool; the chosen one sits on a candy disc. */@Composablefun SubTool(icon: ImageVector, description: String, selected: Boolean, onClick: () -> Unit, enabled: Boolean = true) {- SubButton(icon, description, selected, onClick, enabled, width = 62.dp)+ SubButton(icon, description, selected, onClick, enabled, width = 54.dp)}/** Fill & Sign's text tool: an "A" in a dashed box (a field to type in). */@Composablefun SubTextField(description: String, selected: Boolean, onClick: () -> Unit) {- val tint = if (selected) pdfColors.toolAccent else pdfColors.icon- Box(- Modifier.width(62.dp).height(54.dp).slideToWhenChosen(selected).clickable(role = Role.Button, onClick = onClick).semantics { contentDescription = description },- contentAlignment = Alignment.Center,- ) {+ SubFace(description, selected, onClick, 54.dp) { tint ->Box(Modifier.size(22.dp).drawBehind {- val w = 1.5.dp.toPx()+ val w = 1.6.dp.toPx()drawRect(tint, topLeft = Offset(w / 2, w / 2), size = androidx.compose.ui.geometry.Size(size.width - w, size.height - w),- style = androidx.compose.ui.graphics.drawscope.Stroke(w, pathEffect = androidx.compose.ui.graphics.PathEffect.dashPathEffect(floatArrayOf(2.5.dp.toPx(), 2.dp.toPx()))),+ style = Stroke(w, pathEffect = PathEffect.dashPathEffect(floatArrayOf(2.5.dp.toPx(), 2.dp.toPx()))),)},contentAlignment = Alignment.Center,- ) { Text("A", color = tint, fontSize = 14.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold) }+ ) { Text("A", color = tint, fontSize = 13.sp, style = ClearType.Tile.copy(fontSize = 13.sp)) }}}/** A sub-toolbar tool drawn as a filled dot (Fill & Sign's dot mark). */@Composablefun SubDot(description: String, selected: Boolean, onClick: () -> Unit) {- val tint = if (selected) pdfColors.toolAccent else pdfColors.icon- Box(- Modifier.width(62.dp).height(54.dp).slideToWhenChosen(selected).clickable(role = Role.Button, onClick = onClick).semantics { contentDescription = description },- contentAlignment = Alignment.Center,- ) { Box(Modifier.size(8.dp).background(tint, androidx.compose.foundation.shape.CircleShape)) }+ SubFace(description, selected, onClick, 54.dp) { tint -> Box(Modifier.size(9.dp).background(tint, CircleShape)) }}-/** A sub-toolbar property (line thickness, text size): narrower than a tool, beside its colour; shaded while its picker is open. */+/** A sub-toolbar property (line thickness, text size): narrower, a soft disc while its picker is open. */@Composablefun SubProperty(icon: ImageVector, description: String, selected: Boolean, onClick: () -> Unit) {- SubButton(icon, description, selected, onClick, true, width = 36.dp, shaded = true)+ SubButton(icon, description, selected, onClick, true, width = 46.dp, shaded = true)}@Composableprivate fun SubButton(icon: ImageVector, description: String, selected: Boolean, onClick: () -> Unit, enabled: Boolean, width: Dp, shaded: Boolean = false) {- val c = pdfColors- val tint = if (selected && !shaded) c.toolAccent else c.icon+ SubFace(description, selected, onClick, width, enabled, shaded) { tint -> Icon(icon, null, tint = tint, modifier = Modifier.size(22.dp)) }+}++/** The face every sub-toolbar button shares: a jelly press and, chosen, a candy disc with white ink. */+@Composable+private fun SubFace(description: String, selected: Boolean, onClick: () -> Unit, width: Dp, enabled: Boolean = true, shaded: Boolean = false, glyph: @Composable (Color) -> Unit) {+ val c = clear+ val vivid = selected && !shaded+ val disc by animateColorAsState(+ when {+ vivid -> Candy.Sky+ selected -> c.ink.copy(alpha = 0.10f)+ else -> Color.Transparent+ },+ GlassMotion.settle(), label = "sub",+ )Box(- Modifier.width(width).height(54.dp).slideToWhenChosen(selected && !shaded).clickable(enabled = enabled, role = Role.Button, onClick = onClick).semantics { contentDescription = description },+ Modifier.width(width).fillMaxHeight().slideToWhenChosen(vivid).pressable(onClick, enabled = enabled, pressedScale = 0.86f).semantics { contentDescription = description },contentAlignment = Alignment.Center,) {- if (shaded && selected) Box(Modifier.requiredSize(40.dp).background(c.pressed, androidx.compose.foundation.shape.RoundedCornerShape(5.dp)))- Icon(icon, null, tint = if (enabled) tint else tint.copy(alpha = 0.38f), modifier = Modifier.size(24.dp))+ Box(Modifier.size(42.dp).clip(CircleShape).background(disc))+ glyph(if (!enabled) c.inkFaint else if (vivid) Color.White else c.ink)}}-/** A sub-toolbar divider with the reference's spacing. */+/** A sub-toolbar divider. */@Composablefun SubDivider() {- Box(Modifier.padding(horizontal = 4.dp)) { BarDivider(height = 30.dp) }+ Box(Modifier.padding(horizontal = 6.dp).width(1.dp).height(28.dp).background(clear.line))}-/** The colour button of a sub-toolbar: a filled dot of the tool's colour. */+/** The colour button of a sub-toolbar: a bead of the tool's colour, ringed while its picker is open. */@Composable-fun ColorDot(color: androidx.compose.ui.graphics.Color, selected: Boolean, onClick: () -> Unit) {- val c = pdfColors+fun ColorDot(color: Color, selected: Boolean, onClick: () -> Unit) {+ val c = clearval colourLabel = stringResource(R.string.viewer_colour)Box(- Modifier.width(36.dp).height(54.dp).clickable(role = Role.Button, onClick = onClick).semantics { contentDescription = colourLabel },+ Modifier.width(46.dp).fillMaxHeight().pressable(onClick, pressedScale = 0.86f).semantics { contentDescription = colourLabel },contentAlignment = Alignment.Center,) {- if (selected) Box(Modifier.requiredSize(40.dp).background(c.pressed, androidx.compose.foundation.shape.RoundedCornerShape(5.dp)))- Box(Modifier.size(20.dp).background(color, androidx.compose.foundation.shape.CircleShape))+ if (selected) Box(Modifier.size(38.dp).border(2.dp, c.ink.copy(alpha = 0.5f), CircleShape))+ Box(Modifier.size(26.dp).clip(CircleShape).background(color).border(2.dp, Color.White.copy(alpha = 0.85f), CircleShape))}}diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerController.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerController.ktindex 5b241f3..32f4e84 100644--- a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerController.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerController.kt@@ -82,6 +82,27 @@ class ViewerController {fun toggleBars() {if (!barsLocked) barsVisible = !barsVisible+ scrollTravel = 0f+ }++ /** Scroll travel (dp, signed, finger direction) since the last change of direction. */+ private var scrollTravel = 0f++ /**+ * The reader scrolled by [dy] dp (finger direction: negative moves the text up). The bars slip+ * away on a steady scroll down and come back on a scroll up, and stay while the page is at its top.+ */+ fun onUserScroll(dy: Float, atTop: Boolean) {+ if (barsLocked) return+ if (atTop) {+ barsVisible = true+ scrollTravel = 0f+ return+ }+ // a change of direction starts the count again+ if (dy * scrollTravel < 0f) scrollTravel = 0f+ scrollTravel += dy+ if (scrollTravel < -HIDE_TRAVEL_DP) barsVisible = false else if (scrollTravel > SHOW_TRAVEL_DP) barsVisible = true}/** Switch to [t]; tapping the active tool again goes back to plain viewing. */@@ -104,6 +125,9 @@ class ViewerController {companion object {/** How long the scrubber and page pill stay after the last scroll or zoom. */const val INDICATOR_MS = 2000L+ /** How far a steady scroll goes before the bars hide (down) or return (up), in dp. */+ const val HIDE_TRAVEL_DP = 36f+ const val SHOW_TRAVEL_DP = 18fconst val PREVIOUS_PAGE_MS = 30L * 60 * 1000}}diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.ktindex 9896479..414c775 100644--- a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt@@ -17,6 +17,7 @@ import androidx.compose.foundation.layout.WindowInsetsimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.navigationBars+import androidx.compose.foundation.layout.navigationBarsIgnoringVisibilityimport androidx.compose.foundation.layout.displayCutoutimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.padding@@ -81,6 +82,7 @@ import kotlinx.coroutines.launch* hides and shows them, with the system bars), the scrubber and its page pill, Find, text* selection, the active tool's layer and sub-toolbar, and the sheets.*/+@OptIn(androidx.compose.foundation.layout.ExperimentalLayoutApi::class)@Composablefun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {val c = pdfColors@@ -118,19 +120,20 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {// the bars on their own colour thereval barSides = if (statusBar) Modifier.background(c.surface).then(cutoutSides) else Modifier- // The page area starts under the top bar while it shows, and leaves room for the bottom bar.+ // The page area starts under the top bar and leaves room for the bottom bar. The room is the same+ // whether the bars show or not (they hide as the reader scrolls: the pages must not jump), and+ // the navigation bar's too, which hides with them.val statusPx = maxOf(WindowInsets.statusBars.getTop(density), WindowInsets.displayCutout.getTop(density)).toFloat()- val navPx = WindowInsets.navigationBars.getBottom(density).toFloat()+ val navPx = WindowInsets.navigationBarsIgnoringVisibility.getBottom(density).toFloat()val topPx = with(density) { TopBarHeight.toPx() }// the quick toolbar grows with a large font setting: the page area leaves room for that toovar quickExtraPx by remember { mutableIntStateOf(0) }val bottomPx = with(density) { if (ctl.tool == ViewerTool.None) QuickBarHeight.toPx() + quickExtraPx else BottomBarHeight.toPx() }// keyed on the document too: one opened over another (Create, Combine) has a fresh page view- LaunchedEffect(doc, ctl.barsVisible, statusPx, navPx, ctl.searching, ctl.tool, vm.readingMode, bottomPx, statusBar) {- val bottomShown = ctl.barsVisible && !ctl.searching && !vm.readingMode+ LaunchedEffect(doc, statusPx, navPx, ctl.searching, ctl.tool, vm.readingMode, bottomPx) {+ val bottomShown = !ctl.searching && !vm.readingModedoc.viewer.setPadding(- // with the status bar in documents, the page goes up to the top edge once the bars hide- top = if (ctl.barsVisible) statusPx + topPx else if (statusBar) 0f else statusPx,+ top = statusPx + topPx,bottom = if (bottomShown) bottomPx + navPx else navPx,)}@@ -206,6 +209,7 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {top = with(density) { (statusPx + topPx).toDp() },bottom = with(density) { doc.viewer.padBottom.toDp() },onTap = { ctl.toggleBars() },+ onScroll = { dy, atTop -> ctl.onUserScroll(dy / density.density, atTop) },) else PageCanvas(state = doc.viewer,images = doc.images,@@ -213,6 +217,8 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {look = canvasLook,gap = with(density) { (if (c.dark) 3f else 4f).toDp() },gesturesEnabled = gesturesForTool,+ // the bars slip away as the reader scrolls on, and return as they scroll back (or reach the top)+ onScroll = { dy -> ctl.onUserScroll(dy / density.density, doc.viewer.scrollY <= 8f) },onTap = { p, at ->when {selection.selection != null -> selection.clear()@@ -372,6 +378,9 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {} else {val fa = vm.fieldActionsif (fa != null) FieldTopBar(fa) else ViewerTopBar(+ title = doc.title,+ subtitle = stringResource(R.string.desk_page_of, (doc.viewer.currentPage + 1).coerceAtMost(doc.pageCount), doc.pageCount),+ toolTitle = if (ctl.tool == ViewerTool.Edit) stringResource(R.string.common_tool_edit_pdf) else null,toolActive = ctl.tool != ViewerTool.None,doneIsCheck = ctl.tool != ViewerTool.Comment,// while drawing, the strokes not yet added have their own undo and redo@@ -380,8 +389,7 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {onBack = { if (ctl.tool != ViewerTool.None) vm.leaveTool(doc) else vm.closeDocument() },onUndo = { vm.undo(doc) },onRedo = { vm.redo(doc) },- readingAloud = vm.readAloud != null,- onReadAloud = { vm.readAloud?.stop() ?: vm.startReadAloud(doc) },+ onTitle = { ctl.sheet = if (ctl.sheet == ViewerSheet.More) ViewerSheet.None else ViewerSheet.More },// Reading Mode has no search, as the reference's bar showsonSearch = if (vm.readingMode) null else ({selection.clear()@@ -390,8 +398,6 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {}),onShare = { vm.share(doc) },onMore = { ctl.sheet = if (ctl.sheet == ViewerSheet.More) ViewerSheet.None else ViewerSheet.More },- moreOpen = ctl.sheet == ViewerSheet.More,- title = if (ctl.tool == ViewerTool.Edit) stringResource(R.string.common_tool_edit_pdf) else null,undoLabel = if (doc.localUndo != null) stringResource(R.string.viewer_undo_drawing) else doc.info.undo,redoLabel = if (doc.localUndo != null) stringResource(R.string.viewer_undo_drawing) else doc.info.redo,)@@ -415,13 +421,6 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {onTool = { vm.runQuickTool(doc, it) },onMoreTools = { ctl.sheet = if (ctl.sheet == ViewerSheet.MoreTools) ViewerSheet.None else ViewerSheet.MoreTools },moreToolsOpen = ctl.sheet == ViewerSheet.MoreTools,- chips = listOf(- QuickChip(stringResource(if (vm.isStarred(doc)) R.string.viewer_unstar_file else R.string.viewer_star_file), LucideIcons.Star, ToolHues.combine) { vm.toggleStar(doc) },- QuickChip(stringResource(R.string.common_tool_read_aloud), LucideIcons.Headphones, ToolHues.read) { vm.startReadAloud(doc) },- QuickChip(stringResource(R.string.common_tool_create_pdf), QuickTool.Create.icon, ToolHues.create) { vm.runQuickTool(doc, QuickTool.Create) },- QuickChip(stringResource(R.string.common_tool_organize), QuickTool.Organize.icon, ToolHues.organize) { vm.runQuickTool(doc, QuickTool.Organize) },- ),- onExtraHeight = { quickExtraPx = it },)} else {ToolSubToolbar(vm, doc)diff --git a/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values/strings.xmlindex a3319af..6b0c2ba 100644--- a/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml+++ b/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml@@ -615,6 +615,7 @@<string name="sign_certified">Certified</string><string name="sign_add_signature">Add a digital signature</string><string name="sign_status_unsigned">Not signed yet</string>+ <string name="sign_read_only_document">This document can\'t be changed, so it can\'t be signed.</string><string name="sign_status_valid">Valid</string><string name="sign_status_invalid">Invalid</string><!-- Translator note: the signature is intact, but the signer isn't among the trusted ones -->