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
Liquid glass colour beads in Edit Shape; one haptic per tap on every glass button (app-wide de-dup)
Chethan6164eb0877c801c
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.ktindex 10a0d92..c9b354b 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt@@ -259,6 +259,8 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu// Floating glass (dropdown menus, contextual bars) from any depth renders here, above every// screen, refracting the live screen — see GlassOverlayHost.val overlayHost = remember { GlassOverlayHost() }+ val platformHaptics = androidx.compose.ui.platform.LocalHapticFeedback.current+ val haptics = remember(platformHaptics) { com.chethan616.clearpdf.ui.utils.ThrottledHaptics(platformHaptics) }CompositionLocalProvider(LocalResources provides localizedContext.resources,@@ -266,7 +268,8 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nuLocalReducedGlassMotion provides reduceGlassMotion,LocalBackToLibraryAction provides backToLibrary,com.chethan616.clearpdf.ui.components.LocalFlatBackdrop provides flatBackdrop,- LocalGlassOverlayHost provides overlayHost+ LocalGlassOverlayHost provides overlayHost,+ androidx.compose.ui.platform.LocalHapticFeedback provides haptics) {Box(Modifier.fillMaxSize()) {// Captured layer = wallpaper + the live screen. The floating tab bardiff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidButton.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidButton.ktindex ab9070d..7c1d774 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidButton.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidButton.kt@@ -159,7 +159,7 @@ fun LiquidButton(interactionSource = null,indication = if (isInteractive) null else LocalIndication.current,role = Role.Button,- onClick = onClick+ onClick = { if (interactiveHighlight.expandProgress < 0.5f) haptics.performHapticFeedback(HapticFeedbackType.ContextClick); onClick() }).then(if (isInteractive) {diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.ktindex 9f80df1..95b9c0f 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.kt@@ -142,7 +142,7 @@ fun LiquidIconButton(interactionSource = pressSource,indication = null,role = Role.Button,- onClick = onClick,+ onClick = { haptics.performHapticFeedback(HapticFeedbackType.ContextClick); onClick() },onLongClickLabel = onLongClickLabel,onLongClick = { longArmed[0] = true })@@ -151,7 +151,7 @@ fun LiquidIconButton(interactionSource = null,indication = null,role = Role.Button,- onClick = onClick+ onClick = { if (interactiveHighlight.expandProgress < 0.5f) haptics.performHapticFeedback(HapticFeedbackType.ContextClick); onClick() })).then(diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerDialogs.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerDialogs.ktindex 8e11fe1..a924119 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerDialogs.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerDialogs.kt@@ -98,6 +98,7 @@ import com.chethan616.clearpdf.Rimport com.chethan616.clearpdf.ui.components.DestructiveGlassButtonimport com.chethan616.clearpdf.ui.components.GlassMotionimport com.chethan616.clearpdf.ui.components.LiquidButton+import com.chethan616.clearpdf.ui.components.LiquidIconButtonimport com.chethan616.clearpdf.ui.components.liquidGlassPanelimport com.chethan616.clearpdf.ui.components.viewerGlassimport com.chethan616.clearpdf.ui.theme.LiquidGlassColors@@ -429,21 +430,17 @@ internal fun AnnotationColorRow() {editorPalette.forEach { c ->val isSel = c.value == selected.value- val s by animateFloatAsState(if (isSel) 1.15f else 1f, GlassMotion.pop(), label = "swatch")+ val s by animateFloatAsState(if (isSel) 1.12f else 1f, GlassMotion.pop(), label = "swatch")Box(Modifier.weight(1f), contentAlignment = Alignment.Center) {- Box(- Modifier- .size(26.dp)- .graphicsLayer { scaleX = s; scaleY = s }- .clip(CircleShape)- .background(c)- .border(- width = if (isSel) 2.5.dp else 1.dp,- color = if (isSel) Color.White else fgSoft.copy(alpha = 0.3f),- shape = CircleShape- )- .clickable(interactionSource = remember { MutableInteractionSource() }, indication = null) { onPick(c) }- )+ // Tinted liquid glass bead, same as the draw tools' colour buttons.+ LiquidIconButton(+ onClick = { onPick(c) },+ backdrop = backdrop,+ tint = c,+ modifier = Modifier.size(32.dp).graphicsLayer { scaleX = s; scaleY = s }+ ) {+ if (isSel) Icon(Icons.Rounded.Check, null, Modifier.size(16.dp), Color.White)+ }}}}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/utils/ThrottledHaptics.kt b/app/src/main/java/com/chethan616/clearpdf/ui/utils/ThrottledHaptics.ktnew file mode 100644index 0000000..6e54629--- /dev/null+++ b/app/src/main/java/com/chethan616/clearpdf/ui/utils/ThrottledHaptics.kt@@ -0,0 +1,20 @@+package com.chethan616.clearpdf.ui.utils++import android.os.SystemClock+import androidx.compose.ui.hapticfeedback.HapticFeedback+import androidx.compose.ui.hapticfeedback.HapticFeedbackType++/**+ * App-wide haptic de-duplication. Glass buttons tick on every tap, and many callers also buzz in+ * their own onClick; anything within [windowMs] of the last haptic is dropped, so one tap is always+ * exactly one pulse — never a double buzz.+ */+class ThrottledHaptics(private val delegate: HapticFeedback, private val windowMs: Long = 90L) : HapticFeedback {+ private var last = 0L+ override fun performHapticFeedback(hapticFeedbackType: HapticFeedbackType) {+ val now = SystemClock.uptimeMillis()+ if (now - last < windowMs) return+ last = now+ delegate.performHapticFeedback(hapticFeedbackType)+ }+}