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
Clean up dead code and temp files; recents menu follows Liquid Glass settings
chethan616eca33095a22a
diff --git a/app/src/main/java/com/chethan616/clearpdf/domain/usecase/SplitPdfUseCase.kt b/app/src/main/java/com/chethan616/clearpdf/domain/usecase/SplitPdfUseCase.ktdeleted file mode 100644index 16a4ccb..0000000--- a/app/src/main/java/com/chethan616/clearpdf/domain/usecase/SplitPdfUseCase.kt+++ /dev/null@@ -1,7 +0,0 @@-package com.chethan616.clearpdf.domain.usecase--class SplitPdfUseCase {- fun split(sourceFilePath: String, splitAfterPages: List<Int>): List<String> {- TODO("Implement split by delegating to PdfSplitter from pdf-core")- }-}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassEffects.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassEffects.ktindex 2da278a..f341c3e 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassEffects.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassEffects.kt@@ -46,45 +46,6 @@ private const val ProgressiveBlurShader = """return mix(content.eval(coord) * a, tint * a, tintIntensity);}"""-/**- * Alpha-masked progressive blur (catalog ProgressiveBlurContent): the backdrop behind this element is- * blurred and tinted, fully opaque on the [edge] side and fading to nothing across the far half.- * Size the element yourself (e.g. `fillMaxWidth().height(statusBar + 72.dp)` behind a top bar).- *- * Needs API 33 (RuntimeShader). Below that it falls back to a plain tint gradient, since an unmasked- * blur would leave a hard edge.- */-@Composable-fun Modifier.progressiveBlurEdge(- backdrop: Backdrop,- edge: GlassEdge = GlassEdge.Top,- blurRadius: Dp = 4.dp,- tint: Color = if (LocalIsDarkMode.current) Color(0xFF101114) else Color.White,- tintIntensity: Float = 0.6f-): Modifier {- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {- return this.drawBehind {- val stops = arrayOf(0f to tint.copy(alpha = tintIntensity), 0.5f to tint.copy(alpha = tintIntensity), 1f to Color.Transparent)- drawRect(- if (edge == GlassEdge.Top) Brush.verticalGradient(*stops)- else Brush.verticalGradient(*stops, startY = size.height, endY = 0f)- )- }- }- return this.drawPlainBackdrop(- backdrop = backdrop,- shape = { RectangleShape },- effects = {- blur(blurRadius.toPx())- runtimeShaderEffect("ClearPdfProgressiveBlur", ProgressiveBlurShader, "content") {- setFloatUniform("size", size.width, size.height)- setFloatUniform("fromBottom", if (edge == GlassEdge.Bottom) 1f else 0f)- setColorUniform("tint", tint.toArgb())- setFloatUniform("tintIntensity", tintIntensity)- }- }- )-}/*** Adaptive-luminance content colour (catalog AdaptiveLuminanceGlassContent). Pass [backdrop] (the@@ -102,50 +63,4 @@ class AdaptiveGlassContent internal constructor(val luminance: Float get() = lumAnim.value}-@Composable-fun rememberAdaptiveGlassContentColor(- backdrop: Backdrop,- sampleIntervalMs: Long = 500L-): AdaptiveGlassContent {- val isDark = LocalIsDarkMode.current- val layer: GraphicsLayer = rememberGraphicsLayer()- val colorAnim = remember(isDark) { Animatable(if (isDark) Color.White else Color.Black) }- val lumAnim = remember(isDark) { Animatable(if (isDark) 0f else 1f) }- val onDraw: androidx.compose.ui.graphics.drawscope.DrawScope.(androidx.compose.ui.graphics.drawscope.DrawScope.() -> Unit) -> Unit =- remember(layer) {- { drawBackdrop ->- drawBackdrop()- layer.record { drawBackdrop() }- }- }- val wrapped = rememberBackdrop(backdrop, onDraw)- LaunchedEffect(layer, colorAnim, lumAnim) {- val buffer = IntArray(25)- while (isActive) {- delay(sampleIntervalMs)- val avg = try {- if (layer.size.width <= 0 || layer.size.height <= 0) continue- val src = layer.toImageBitmap().asAndroidBitmap()- val isHw = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && src.config == Bitmap.Config.HARDWARE- val soft = if (isHw) src.copy(Bitmap.Config.ARGB_8888, false) else src- val thumb = Bitmap.createScaledBitmap(soft, 5, 5, true)- thumb.getPixels(buffer, 0, 5, 0, 0, 5, 5)- if (thumb !== soft) thumb.recycle()- if (soft !== src) soft.recycle()- buffer.sumOf { argb ->- val r = (argb shr 16 and 0xFF) / 255.0- val g = (argb shr 8 and 0xFF) / 255.0- val b = (argb and 0xFF) / 255.0- 0.2126 * r + 0.7152 * g + 0.0722 * b- }.toFloat() / buffer.size- } catch (e: CancellationException) {- throw e- } catch (_: Throwable) {- continue- }- launch { colorAnim.animateTo(if (avg > 0.5f) Color.Black else Color.White, tween(600)) }- launch { lumAnim.animateTo(avg, tween(600)) }- }- }- return remember(wrapped, colorAnim, lumAnim) { AdaptiveGlassContent(wrapped, colorAnim, lumAnim) }-}+diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassPrimitives.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassPrimitives.ktindex 3663204..d07154c 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassPrimitives.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassPrimitives.kt@@ -96,16 +96,6 @@ object GlassDimens {val TitleSize: TextUnit = 16.sp}-/** Solid (non-refractive) glass section card. Used for settings-style grouped rows- * where a translucent panel would hurt text legibility. */-fun Modifier.glassSection(isLight: Boolean, radius: Dp = GlassDimens.SectionRadius): Modifier {- val container = if (isLight) Color.White.copy(0.68f) else Color(0xFF161820).copy(0.72f)- val borderCol = if (isLight) Color.White.copy(0.80f) else Color.White.copy(0.12f)- return this- .clip(RoundedCornerShape(radius))- .background(container)- .border(1.dp, borderCol, RoundedCornerShape(radius))-}/** Standard section header: M3 rounded icon tile + title, with an optional trailing slot. */@Composablediff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassTitlePill.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassTitlePill.ktindex 7600838..37e99c0 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassTitlePill.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassTitlePill.kt@@ -29,22 +29,6 @@ import com.chethan616.clearpdf.ui.theme.LiquidGlassColorsimport com.chethan616.clearpdf.ui.theme.LocalIsDarkModeimport com.kyant.backdrop.Backdrop-/**- * Drop-in replacement for a `LiquidGlassTopBar` sitting in a header [Row]: it takes the remaining- * width, centres a [GlassTitlePill] in it, and adds a 40 dp balancer so the pill is optically- * centred against the leading back button. Every tool screen's header is this shape.- */-@Composable-fun RowScope.GlassScreenTitle(- title: String,- backdrop: Backdrop,- fontFamily: FontFamily? = null-) {- Box(Modifier.weight(1f), contentAlignment = Alignment.Center) {- GlassTitlePill(text = title, backdrop = backdrop, fontFamily = fontFamily)- }- Spacer(Modifier.size(40.dp))-}/*** The title pill used across the app — the *same* widget as the PDF viewer's "Page 1 / 12" and thediff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassCard.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassCard.ktindex 874652c..112e612 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassCard.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassCard.kt@@ -54,102 +54,6 @@ import androidx.compose.foundation.layout.aspectRatioimport androidx.compose.material.icons.automirrored.rounded.ArrowForwardimport androidx.compose.ui.text.style.TextOverflow-@Composable-fun LiquidGlassCard(- title: String,- subtitle: String,- accentColor: Color,- backdrop: Backdrop,- uiSensor: UISensor,- onClick: () -> Unit,- modifier: Modifier = Modifier,- icon: @Composable () -> Unit-) {- val isDarkMode = LocalIsDarkMode.current- val isLight = !isDarkMode- val container = if (isLight) Color.White.copy(0.36f) else Color(0xFF13151B).copy(0.52f)- val titleColor = LiquidGlassColors.text(!isLight)- val subtitleColor = LiquidGlassColors.secondary(!isLight)-- val animationScope = rememberCoroutineScope()- val interactiveHighlight = remember(animationScope) {- InteractiveHighlight(animationScope = animationScope)- }-- Column(- modifier- .fillMaxWidth()- .aspectRatio(1f)- .drawBackdrop(- backdrop = backdrop,- shape = { RoundedRectangle(28f.dp) },- effects = {- vibrancy()- blur(7f.dp.toPx())- lens(20f.dp.toPx(), 38f.dp.toPx(), depthEffect = true)- },- highlight = {- Highlight(style = HighlightStyle.Default(angle = uiSensor.gravityAngle, falloff = 2f))- },- shadow = null,- innerShadow = null,- layerBlock = {- val progress = interactiveHighlight.pressProgress- val scale = lerp(1f, 1f + 4f.dp.toPx() / size.height, progress)- val maxOffset = size.minDimension- val offset = interactiveHighlight.offset- translationX = maxOffset * tanh(0.04f * offset.x / maxOffset)- translationY = maxOffset * tanh(0.04f * offset.y / maxOffset)- val maxDragScale = 3f.dp.toPx() / size.height- val offsetAngle = atan2(offset.y, offset.x)- scaleX = scale + maxDragScale * abs(cos(offsetAngle) * offset.x / size.maxDimension)- scaleY = scale + maxDragScale * abs(sin(offsetAngle) * offset.y / size.maxDimension)- },- onDrawSurface = { drawRect(container) }- )- .clickable(interactionSource = null, indication = null, role = Role.Button, onClick = onClick)- .then(interactiveHighlight.modifier)- .then(interactiveHighlight.gestureModifier)- .padding(18.dp),- verticalArrangement = Arrangement.SpaceBetween- ) {- // Icon pill- Box(- Modifier- .size(52.dp)- .clip(RoundedCornerShape(16.dp))- .background(accentColor.copy(alpha = if (isLight) 0.14f else 0.22f)),- contentAlignment = Alignment.Center- ) {- icon()- }-- // Bottom text content- Column(verticalArrangement = Arrangement.spacedBy(3.dp)) {- BasicText(- title,- style = TextStyle(- color = titleColor,- fontSize = 16.5.sp,- fontWeight = FontWeight.SemiBold,- letterSpacing = (-0.3).sp- ),- maxLines = 1,- overflow = TextOverflow.Ellipsis- )- BasicText(- subtitle,- style = TextStyle(- color = subtitleColor,- fontSize = 12.sp,- fontWeight = FontWeight.Normal- ),- maxLines = 1,- overflow = TextOverflow.Ellipsis- )- }- }-}@Composablefun LiquidGlassErrorCard(diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassDropdown.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassDropdown.ktindex 9e0cc2e..3bcfcec 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassDropdown.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassDropdown.kt@@ -89,9 +89,8 @@ fun Modifier.glassMenu(highlight = { glassHighlight(GlassSettings.style) },shadow = null,onDrawSurface = {- // Menus carry text: the user's Tint can make them denser, never clearer than legible.- val a = maxOf(surfaceAlpha, (surfaceAlpha * GlassSettings.style.tint)).coerceAtMost(1f)- drawRect(if (dark) Color(0xFF1E1E1E).copy(a) else Color(0xFFFAFAFA).copy(a))+ // Follows Settings -> Liquid Glass like every other surface (Tint included).+ drawRect((if (dark) Color(0xFF1E1E1E).copy(surfaceAlpha) else Color(0xFFFAFAFA).copy(surfaceAlpha)).glassTint(GlassSettings.style))})diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/ToolKit.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/ToolKit.ktindex 0122f3d..c3b5623 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/ToolKit.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/ToolKit.kt@@ -114,93 +114,7 @@ fun AccentIconTile(icon: ImageVector, accent: Color, size: Int = 60, iconSize: I}}-/**- * The intro card at the top of every tool: accent icon tile, title, centred description, then the- * primary action(s) in [actions].- */-@Composable-fun ToolHeroCard(- icon: ImageVector,- title: String,- subtitle: String,- accent: Color,- backdrop: Backdrop,- uiSensor: UISensor,- modifier: Modifier = Modifier,- actions: (@Composable ColumnScope.() -> Unit)? = null-) {- Column(- modifier- .fillMaxWidth()- .liquidGlassPanel(backdrop, uiSensor)- .padding(horizontal = 24.dp, vertical = 24.dp),- horizontalAlignment = Alignment.CenterHorizontally- ) {- AccentIconTile(icon, accent)- Spacer(Modifier.height(14.dp))- BasicText(- title,- style = TextStyle(ToolInk.text(), 20.sp, FontWeight.SemiBold, textAlign = TextAlign.Center)- )- Spacer(Modifier.height(6.dp))- BasicText(- subtitle,- style = TextStyle(ToolInk.secondary(), 14.sp, lineHeight = 19.sp, textAlign = TextAlign.Center)- )- if (actions != null) {- Spacer(Modifier.height(20.dp))- Column(- Modifier.fillMaxWidth(),- horizontalAlignment = Alignment.CenterHorizontally,- verticalArrangement = Arrangement.spacedBy(10.dp),- content = actions- )- }- }-}-/**- * The selected file, as one compact glass row: accent document tile, name, one line of detail.- */-@Composable-fun ToolFileCard(- name: String,- detail: String?,- accent: Color,- backdrop: Backdrop,- uiSensor: UISensor,- modifier: Modifier = Modifier,- icon: ImageVector = Icons.Rounded.PictureAsPdf,- trailing: (@Composable () -> Unit)? = null-) {- Row(- modifier- .fillMaxWidth()- .liquidGlassPanel(backdrop, uiSensor)- .padding(horizontal = 16.dp, vertical = 14.dp),- verticalAlignment = Alignment.CenterVertically,- horizontalArrangement = Arrangement.spacedBy(12.dp)- ) {- AccentIconTile(icon, accent, size = 42, iconSize = 22)- Column(Modifier.weight(1f)) {- BasicText(- name,- style = TextStyle(ToolInk.text(), 15.sp, FontWeight.SemiBold),- maxLines = 1,- overflow = TextOverflow.Ellipsis- )- if (!detail.isNullOrBlank()) {- BasicText(- detail,- style = TextStyle(ToolInk.secondary(), 13.sp),- maxLines = 1,- overflow = TextOverflow.Ellipsis- )- }- }- trailing?.invoke()- }-}/*** Primary action: the vivid "Get it" pill in the screen's [accent], white label. [busy] swaps the@@ -241,42 +155,6 @@ fun ToolPrimaryButton(}}-/**- * Secondary action: clear glass in the title pill's own surface, ink label, optional accent icon.- */-@Composable-fun ToolSecondaryButton(- text: String,- onClick: () -> Unit,- backdrop: Backdrop,- modifier: Modifier = Modifier,- icon: ImageVector? = null,- iconTint: Color = Color.Unspecified,- enabled: Boolean = true-) {- val isDark = LocalIsDarkMode.current- val ink = LiquidGlassColors.text(isDark)- LiquidButton(- onClick = { if (enabled) onClick() },- backdrop = backdrop,- surfaceColor = LiquidGlassColors.neutralSurface(isDark),- isInteractive = enabled,- modifier = modifier.graphicsLayer { alpha = if (enabled) 1f else 0.45f }- ) {- if (icon != null) {- Icon(icon, null, Modifier.size(18.dp), if (iconTint == Color.Unspecified) ink else iconTint)- }- BasicText(- text,- style = TextStyle(ink, 15.sp, FontWeight.Medium),- maxLines = 1,- // Last child of the capsule's Row, so it is measured against whatever width is left- // and ellipsizes instead of clipping (long pt / es labels). No weight: these pills- // also live in horizontally scrolling rows, where a weight would collapse to zero.- overflow = TextOverflow.Ellipsis- )- }-}/*** One option in a small set (format, position, mode). Selected = vivid accent pill with a white@@ -315,68 +193,5 @@ fun GlassChoiceChip(}}-/**- * Inline result / error message on glass, with the theme-correct status ink and an optional- * trailing action (e.g. "Open"). One component instead of the per-screen red/green text panels.- */-@Composable-fun ToolStatusCard(- message: String,- isError: Boolean,- backdrop: Backdrop,- uiSensor: UISensor,- modifier: Modifier = Modifier,- onDismiss: (() -> Unit)? = null,- action: (@Composable () -> Unit)? = null-) {- val isDark = LocalIsDarkMode.current- val tone = if (isError) LiquidGlassColors.danger(isDark) else LiquidGlassColors.success(isDark)- Row(- modifier- .fillMaxWidth()- .liquidGlassPanel(backdrop, uiSensor)- .padding(horizontal = 14.dp, vertical = 12.dp),- verticalAlignment = Alignment.CenterVertically,- horizontalArrangement = Arrangement.spacedBy(12.dp)- ) {- Box(- Modifier- .size(34.dp)- .clip(CircleShape)- .background(tone.copy(alpha = if (isDark) 0.22f else 0.13f)),- contentAlignment = Alignment.Center- ) {- Icon(- if (isError) Icons.Rounded.ErrorOutline else Icons.Rounded.CheckCircle,- null,- Modifier.size(19.dp),- tone- )- }- BasicText(- message,- style = TextStyle(LiquidGlassColors.text(isDark), 13.sp, FontWeight.Medium, lineHeight = 18.sp),- modifier = Modifier.weight(1f)- )- action?.invoke()- if (onDismiss != null) {- LiquidIconButton(- onClick = onDismiss,- backdrop = backdrop,- modifier = Modifier.size(32.dp)- ) {- CloseCrossIcon(Modifier.size(12.dp), LiquidGlassColors.text(isDark))- }- }- }-}-/** The recessed surface behind text inputs on glass (password, page range, watermark text…). */-@Composable-fun Modifier.glassFieldSurface(): Modifier {- val isDark = LocalIsDarkMode.current- return this- .clip(RoundedCornerShape(14.dp))- .background(if (isDark) Color.White.copy(0.09f) else Color.Black.copy(0.05f))- .padding(horizontal = 14.dp, vertical = 13.dp)-}+diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerInternals.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerInternals.ktindex 90b902e..df157fb 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerInternals.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerInternals.kt@@ -418,32 +418,7 @@ internal fun fitBitmapRect(canvasSize: Size, bitmapW: Float, bitmapH: Float): Rereturn Rect(left, top, left + w, top + h)}-internal fun screenToContent(- screen: Offset,- zoomScale: Float,- panOffset: Offset,- boxCenter: Offset-): Offset {- val unpanned = screen - panOffset- val rel = unpanned - boxCenter- return (rel / zoomScale) + boxCenter-}-internal fun clampPanOffset(- pan: Offset,- scale: Float,- canvasSize: Size,- bitmapSize: Size-): Offset {- if (scale <= 1.01f || canvasSize.width <= 0f || canvasSize.height <= 0f) return Offset.Zero- val frame = fitBitmapRect(canvasSize, bitmapSize.width, bitmapSize.height)- val maxPanX = (frame.width * (scale - 1f) / 2f).coerceAtLeast(0f)- val maxPanY = (frame.height * (scale - 1f) / 2f).coerceAtLeast(0f)- return Offset(- pan.x.coerceIn(-maxPanX, maxPanX),- pan.y.coerceIn(-maxPanY, maxPanY)- )-}internal fun ocrBlockToRect(block: OcrTextBlock, frame: Rect): Rect = Rect(frame.left + block.left * frame.width,diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/RecentContextMenu.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/RecentContextMenu.ktindex 8a137ca..770cc4d 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/RecentContextMenu.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/RecentContextMenu.kt@@ -243,7 +243,7 @@ private fun MenuPanel(Column(Modifier.width(MenuWidth)- .glassMenu(backdrop, dark = com.chethan616.clearpdf.ui.theme.LocalIsDarkMode.current, shape = { RoundedRectangle(22.dp) }, surfaceAlpha = 0.88f)+ .glassMenu(backdrop, dark = com.chethan616.clearpdf.ui.theme.LocalIsDarkMode.current, shape = { RoundedRectangle(22.dp * com.chethan616.clearpdf.ui.components.GlassSettings.style.corners) }, surfaceAlpha = 0.88f)// Swallow taps on the panel's padding so they don't fall through to the scrim..clickable(interactionSource = remember { MutableInteractionSource() }, indication = null) {}.semantics { contentDescription = title }diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/viewmodel/HomeViewModel.kt b/app/src/main/java/com/chethan616/clearpdf/ui/viewmodel/HomeViewModel.ktdeleted file mode 100644index b3f9765..0000000--- a/app/src/main/java/com/chethan616/clearpdf/ui/viewmodel/HomeViewModel.kt+++ /dev/null@@ -1,29 +0,0 @@-package com.chethan616.clearpdf.ui.viewmodel--import androidx.lifecycle.ViewModel-import com.chethan616.clearpdf.domain.model.ToolItem-import kotlinx.coroutines.flow.MutableStateFlow-import kotlinx.coroutines.flow.StateFlow-import kotlinx.coroutines.flow.asStateFlow--data class HomeUiState(- val tools: List<ToolItem> = emptyList(),- val recentFiles: List<String> = emptyList(),- val isLoading: Boolean = false-)--class HomeViewModel : ViewModel() {- private val _uiState = MutableStateFlow(- HomeUiState(- tools = listOf(- ToolItem("open", "Open PDF", "View and read PDF documents"),- ToolItem("merge", "Merge PDFs", "Combine multiple PDFs into one"),- ToolItem("split", "Split PDF", "Extract pages or split documents"),- ToolItem("compress", "Compress PDF", "Reduce PDF file size"),- ToolItem("create", "Create PDF", "Create a new PDF from scratch")- ),- recentFiles = listOf("Annual Report 2025.pdf", "Contract Draft.pdf", "Invoice_0042.pdf")- )- )- val uiState: StateFlow<HomeUiState> = _uiState.asStateFlow()-}diff --git a/plan.txt b/plan.txtdeleted file mode 100644index 165d23a..0000000--- a/plan.txt+++ /dev/null@@ -1,197 +0,0 @@-# ClearPDF — UI/UX + Feature Completion Plan (temporary)-# Work through these ONE BY ONE, patiently, verifying each compiles + doesn't break existing flows.-# Mark [x] when done. Keep the PDF/document content readable and dominant. Liquid-glass ONLY for floating UI.--=====================================================================-ITEM 1 — SAVE DOCUMENT → REAL IN-WINDOW GLASS [x] DONE (viewer). Tool screens keep solid Dialog.------------------------------------------------------------------------ LiquidSaveDialog is currently a SOLID themed card in a Dialog window (can't sample the page).-- Convert to an IN-WINDOW overlay (like LiquidPageJumpPopup) rendered inside the viewer's- BoxWithConstraints so liquidGlassPanel samples the real content backdrop (contentBackdrop).-- Real glass: translucent + blur + subtle border/highlight/shadow. NO png, NO solid slab.-- Keep: filename field, folder picker launcher, save location display. imePadding for keyboard.-- Redesign the save-location section: current location obvious, compact rows, rounded cards,- M3 rounded icons (Downloads / Documents / custom folder / create-new-folder).-- Also used by the tool screens (Merge/Split/etc.) → those stay as-is (over wallpaper) OR- give a solid card fallback when no contentBackdrop. Decide cleanly, don't break them.--=====================================================================-ITEM 2 — TEXT SELECTION + FIND OVERHAUL [x] DONE- [x] FIND now highlights the exact matched WORD (not the whole sentence/line). Studied Pdf_Tools- (PDFTextStripper per-char TextPosition). We already captured char TextPositions in- PdfTextService but collapsed to line blocks; now carry per-char normalized x-bounds- (charLefts/charRights) up: PdfTextBlock + OcrTextBlock, and FindMatch is now a normalized- WORD rect (was blockId). Search (searchText + searchTextInDocument + PdfTextService.searchAll)- computes tight per-occurrence rects; PdfContinuousPage/PdfPageCanvas draw the word rect- (rounded, padded). Multiple matches per line supported.- [x] Contextual selection bubble added in PdfContinuousPage: when text is selected (SelectText),- a compact glass bubble (Copy | Highlight) appears just above the selection's bounding rect,- flipping BELOW when near the page top and clamped to page bounds. Wired onCopySelection /- onHighlightSelection callbacks from PdfViewerScreen (copy selected OCR text to clipboard;- add TextBlockHighlightMarkup for selected ids). NOTE: bubble lives inside the page's zoom- layer so it scales with zoom — fine for text-selection (done at ~1x); could counter-scale later.- (Kept Search/Share/Annotate out for now to stay compact; can add if wanted.)------------------------------------------------------------------------ Study Pdf_Tools text selection/search approach (char-position based selection, handles).-- Selection: clear handles, subtle highlight, contextual action bubble near selection- (Copy / Select All / Search / Share / Highlight / Annotate), smart-positioned so it never- goes off-screen (flip above/below near edges).-- Find: compact floating search toolbar, "n / total", prev/next, scroll-to-match, smooth- transitions between matches, clean close, never obscures a large part of the doc.-- Feature-rich + quality-rich. Keep our OCR-block model; adapt Pdf_Tools ideas, don't copy code.--=====================================================================-ITEM 3 — SETTINGS FULL REDESIGN [x] DONE- → SettingsScreen.kt rewritten around 3 reusable primitives + centralized tokens:- - SettingsSection(title, icon, iconTint, titleColor, contentSpacing, trailing, content):- glass card + M3 rounded-icon TILE header (was a bare icon) + optional trailing slot- (used by the quality % badge). Replaces 7 hand-built headers.- - SegmentedSelector(options, selectedId, onSelect): one equal-weight glass segmented- control shared by Theme / Language / Save-location — replaces 3 copy-pasted blocks,- guarantees consistent overflow (maxLines=1 + ellipsis). SegOption carries optional icon.- - reveal(index, visible, density): one staggered fade+rise entrance modifier, replaces- 12 hand-written animateFloatAsState + graphicsLayer blocks AND fixes a real bug where- Quality + Language both reused panel4's animation. SettingsDivider extracted too.- - Tokens: SectionRadius/InnerRadius/SectionGap/SectionPadding/TitleSize/AccentBlue/Green.- - Overflow: section titles + save path now maxLines+ellipsis; dark-mode palette preserved.- → Preserved EVERY backing call (AppSettingsManager auto-compress/keep-original/notifications/- quality, SaveLocationManager + folder picker, onThemeModeChanged, onLocaleChanged, star CTA,- licenses). Function signature unchanged. No fake settings added (no privacy link target). BUILD OK.--ITEM 3 — (original spec below) [x]------------------------------------------------------------------------ Rebuild hierarchy (only real settings, no fake ones):- Appearance: Theme, (Accent/Dynamic if they exist),- Files: Default save location, File naming (if exists), Recent files (if exists)- Editor: selection/drawing/highlight defaults (only if they exist)- About: Version, Licenses (AndroidLiquidGlass + Pdf_Tools credit), Open source, Privacy-- Preserve ALL existing functionality/toggles/pickers.-- Fix every typography/overflow/dark-mode issue (audit each row: long text, pt, small screens,- font scaling, multiline, icon collisions). Use constraints, not hardcoded widths.-- M3 rounded icons, consistent spacing/corner-radii/typography tokens.--=====================================================================-ITEM 4 — LIQUID GLASS DESIGN SYSTEM EXTRACTION [x] DONE (core + 2 adopters)- → New components/GlassPrimitives.kt centralizes the design system:- - GlassDimens tokens (ScreenPadding/SectionGap/SectionRadius/InnerRadius/- SectionPadding/TitleSize) — single source of truth for spacing/radii/type.- - Modifier.glassSection(isLight, radius): the solid section card (was a private- copy in SettingsScreen).- - GlassSectionHeader(title, icon, iconTint, titleColor, trailing): M3 rounded- icon-tile header, reusable.- - GlassChip(text, color): the tinted value pill (e.g. quality %).- - ToolScaffold(title, backdrop, onBack, headerTrailing, content): the shared- animated back-header + staggered reveal + scroll body that every tool screen- hand-rolled (~45 lines each).- → Adopted in SettingsScreen (removed its private liquidGlassSection + inlined header- + badge → shared primitives) and CompressPdfScreen (now ToolScaffold + GlassChip).- Both BUILD OK.- → NOT force-migrated: PageOrganizer (reorderable list), ImagesToPdf (grid),- Encrypt/Decrypt (no reveal), Scan (no back) — their body structure differs from the- simple verticalScroll ToolScaffold assumes; migrating blind (no device eyes) risks- layout regressions for zero user-visible gain. They can adopt ToolScaffold incrementally- during a device-verified pass. Primitives are ready for them.--ITEM 4 — (original spec below) [x]------------------------------------------------------------------------ One consistent set of reusable primitives (reuse existing LiquidButton/LiquidIconButton/- liquidGlassPanel; add GlassCard/GlassSection/GlassSheet/GlassChip as thin wrappers).-- Centralize spacing / corner radii / typography / glass tint tokens.-- Do NOT make everything glass. Document/page stays solid + readable.-- De-duplicate copy-pasted glass styling across screens.--=====================================================================-ITEM 5 — PDF_TOOLS FEATURE-GAP PORTING [~] WATERMARK DONE (first gap closed this pass)- → Gap audit (from memory): MISSING = watermark, image tools, extract-pages-to-new-PDF,- HTML->PDF, form fill/flatten, OCR. Watermark chosen first: highest value, most- self-contained, maps directly onto the existing PDFBox text-stamp export path.- → Implemented END-TO-END (original code, no third-party paste):- - pdf-core/watermark/PdfWatermarker.apply(ctx, src, dest, text, opacity, diagonal, color):- stamps a page-centered text watermark on every page via PDDocument + PDPageContentStream- (APPEND) + PDExtendedGraphicsState.nonStrokingAlphaConstant for opacity +- PDType1Font.HELVETICA_BOLD; diagonal = 45° via Matrix.getRotateInstance about page centre;- font scales to the page short edge; Latin-1 glyph sanitize; source URI never modified.- - WatermarkPdfViewModel (self-contained, viewModel(), no usecase): text/opacity/diagonal- state + apply() writes via SaveLocationManager createOutputUri (custom folder or Downloads)- + RecentFilesManager, same as Compress/PdfToImages.- - WatermarkPdfScreen: built on the NEW ToolScaffold primitive (Item 4) — pick card, text- field, opacity slider + GlassChip %, diagonal LiquidToggle, Apply, open-output.- - Wired: DocsNavGraph ROUTE_WATERMARK + composable; ToolsScreen param + ToolSpec- (BrandingWatermark icon, #AD1457); strings tool_watermark(_sub)/watermark_* in en+pt+pt-rBR.- BUILD SUCCESSFUL. Not device-verified.- → EXTRACT PAGES DONE (2nd gap): `ExtractPagesViewModel` (self-contained) reuses- `PdfSplitterImpl.extractPages` with a 1-based range parser ("1-3, 5, 8-10" → 0-based- indices, clamped/deduped/sorted); saves via SaveLocationManager + RecentFilesManager.- `ExtractPagesScreen` on ToolScaffold (numeric range field, page-count trailing, apply,- open-output). Wired: DocsNavGraph ROUTE_EXTRACT_PAGES, ToolsScreen ToolSpec- (ContentCut icon, #00897B), strings en+pt+pt-rBR. assembleDebug OK.- → PAGE NUMBERS DONE (3rd tool this pass): `pdf-core/pagenumber/PdfPageNumberer.apply(ctx,- src, dest, position CENTER/RIGHT, includeTotal, startAt)` stamps a page number in the- bottom margin of every page (same PDFBox HELVETICA text-stamp path as watermark).- `PageNumbersViewModel` + `PageNumbersScreen` (ToolScaffold, position selector, show-total- toggle) + nav ROUTE_PAGE_NUMBERS + ToolsScreen ToolSpec (Icons.Rounded.Numbers, #3949AB)- + strings en+pt+pt-rBR. assembleDebug OK.- → FLATTEN DONE: pdf-core/flatten/PdfFlattener (PDAcroForm.flatten(), returns field count)- + FlattenPdfViewModel + FlattenPdfScreen (ToolScaffold) + nav ROUTE_FLATTEN + ToolSpec- (Layers #6D4C41) + strings.- → IMAGE TOOLS DONE: pdf-core/image/ImageProcessor (inspect/process/saveToGallery) — decode- (inSampleSize downscale) → scale by % → re-encode JPG/PNG/WebP at quality; re-encode strips- EXIF/GPS by construction; JPEG flattens alpha onto white. Reuses PdfRasterizer.ImageFormat.- ImageToolsViewModel + ImageToolsScreen (ToolScaffold: format selector, quality slider [lossy- only], resize slider, before/after size, Save-to-gallery + Share) + nav ROUTE_IMAGE_TOOLS- + ToolSpec (PhotoSizeSelectLarge #F4511E) + strings en+pt+pt-rBR. assembleDebug OK.- → HTML->PDF DONE: util/HtmlToPdfConverter (offscreen WebView @A4 → PdfDocument page slices,- main-thread async; JS off + null base = offline-only local HTML) + HtmlToPdfViewModel- (suspendCancellableCoroutine on Dispatchers.Main) + HtmlToPdfScreen + nav + ToolSpec (Code #E65100).- → FILL FORMS DONE: pdf-core/form/PdfFormService (readFields → text/checkbox/choice terminal- fields; fill(values, flatten) via PDField.setValue/check/unCheck) + FillFormViewModel (editable- field list) + FillFormScreen (dynamic typed inputs + flatten toggle) + nav + ToolSpec (EditNote #00695C).- → ALL Pdf_Tools feature-list gaps now CLOSED (Flatten, Image Tools, HTML→PDF, Fill Forms this pass;- Watermark/Extract-Pages/Page-Numbers earlier). Tools grid = 17 cards. assembleDebug OK.- NONE device-verified — WebView HTML→PDF timing + form appearance generation especially want it.--ITEM 5 — (original spec below) [~]------------------------------------------------------------------------ Feature-gap analysis first: what exists / missing / portable / conflicts-with-architecture.-- Implement highest-value MISSING features (candidates: form fill/flatten, watermark,- page extract-to-new-pdf, image tools, HTML->PDF, better OCR) — adapt to our PDFBox/PdfRenderer- + PdfMarkup/ExportOverlay model. No unnecessary deps. No blind code copy. Credit already given.--=====================================================================-BUGS TO FIX (from user) — do alongside the items above [ ]-----------------------------------------------------------------------BUG A — UNDO first-attempt failure [x] DONE:- "sometimes on first attempt the undo doesnt work at all for anything any modification unless i- come back to homescreen and reopen the pdf."- → ROOT CAUSE: the bottom toolbar's undo + all page-scoped OCR/highlight actions targeted- getPageMarks(state.currentPage), where state.currentPage is an ASYNC mirror updated via- snapshotFlow{ firstVisibleItemIndex }.collect{ onPageChanged }. Drawing/placement inside the- LazyColumn item targets getPageMarks(page) with the SYNCHRONOUS item index. Right after- open/scroll (before the flow settles) the two diverge, so undo removed from the wrong (empty)- page list = no-op; reopening resynced them.- → FIX: switched currentPageMarks + selectedTextCount/currentSelectedIds + onSelectAllText/- onCopyText/onHighlight/onUnderline/onStrike/onClearTextSelection + onSetActiveTool's- clearOcrSelection + the "Page X / Y" pill from state.currentPage to the synchronous- currentPageIndex (= listState.firstVisibleItemIndex, same source the drawing uses).- state.currentPage is kept only for the async OCR-extraction trigger. BUILD SUCCESSFUL.--BUG B — Signature resize [x] DONE: PdfContinuousPage image selection redesigned — rounded- accent frame, 3 passive corner dots, and a large (22px) bottom-right resize handle with a- diagonal glyph; grab radius 40f→64f. (Apple-style: touch target >> visual handle.)--BUG B (original text) — Signature resize is fiddly:- "difficult to resize the signature by dragging that small thing/line — improve it, follow Apple HIG,- unique sweet UI, best approach."- → The image/signature resize handle is a tiny corner dot with a 36-40px hit slop. Redesign:- larger, clearer Apple-style corner handles (visible rounded handles at corners), bigger touch- target (44dp+), maybe a bounding frame with grab handles, smooth. Keep aspect for signatures.- Consider a dedicated resize affordance + move handle. Touch target >= visual size.--=====================================================================-GLOBAL RULES------------------------------------------------------------------------ Compile (:app:compileDebugKotlin) after each item; don't break opening/render/nav/zoom/scroll/- select/search/annotate/draw/highlight/sign/saved-sigs/save/export/file-picker/settings/darkmode.-- Apple-quality: hierarchy, spacing, typography, restraint, depth, contextual controls, subtle motion.-- pt labels ~1.3x longer than EN → width-constrained buttons need maxLines=1.-- Keep memory (session-work-status.md) updated per item.