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
Back buttons: long-press action fires on release, not mid-press
Chethan616b9882c13241d
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 3a94450..9f80df1 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@@ -6,6 +6,9 @@ import androidx.compose.foundation.combinedClickableimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.sizeimport androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.foundation.interaction.MutableInteractionSource+import androidx.compose.foundation.interaction.PressInteractionimport androidx.compose.runtime.getValueimport androidx.compose.runtime.rememberimport androidx.compose.runtime.rememberCoroutineScope@@ -66,6 +69,19 @@ fun LiquidIconButton(}// Flat wallpaper: same pixels, none of the blur/lens/offscreen work — see FlatBackdrop.val flat = flatColorOf(backdrop)+ // A long-press only ARMS its action; it runs when the finger lifts (a cancelled press drops it),+ // so holding Back never yanks the screen away mid-press.+ val pressSource = remember { MutableInteractionSource() }+ val longArmed = remember { booleanArrayOf(false) }+ val currentLongClick by rememberUpdatedState(onLongClick)+ LaunchedEffect(pressSource) {+ pressSource.interactions.collect { i ->+ when (i) {+ is PressInteraction.Release -> if (longArmed[0]) { longArmed[0] = false; currentLongClick?.invoke() }+ is PressInteraction.Cancel -> longArmed[0] = false+ }+ }+ }Box(modifier@@ -123,12 +139,12 @@ fun LiquidIconButton(.then(if (onLongClick != null)Modifier.combinedClickable(- interactionSource = null,+ interactionSource = pressSource,indication = null,role = Role.Button,onClick = onClick,onLongClickLabel = onLongClickLabel,- onLongClick = onLongClick+ onLongClick = { longArmed[0] = true })elseModifier.clickable(