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 waits a beat for its press, holding it stays in Settings, tab bar keeps up
chethan616985fcda4182f
diff --git a/DESIGN.md b/DESIGN.mdindex ebafa32..d08091b 100644--- a/DESIGN.md+++ b/DESIGN.md@@ -124,6 +124,9 @@ by hand must do the same. `settle`, `fade` and layout springs never bounce and iBack.- Long-press on a glass button blooms (grows ≤ ~14 dp, glows brighter, one LongPress haptic). Along-press **action** runs on release, never mid-press.+- A tapped back button (`GlassBackButton`) leaves after `GlassMotion.BackTapDelayMillis` (140 ms),+ so the press is seen first, as on iOS. Not longer: it must never read as lag. The system back+ gesture stays instant, and Reduce glass motion skips the wait.---@@ -152,6 +155,10 @@ by hand must do the same. `settle`, `fade` and layout springs never bounce and i---## 6. Layout and UX+- Holding a back button goes to the root of where you are: the library from a tool or document,+ the Settings index from a Settings page (never past it to Home).+- The tab bar is rebuilt whenever it reappears, so it must follow the current tab from its first+ frame; never skip the first selection change it sees.- Settings is an iOS-style index of rows. Each topic opens its own page with a back button. Keep theroot light: three small panels.- Use 16 dp screen gutters and 12–16 dp between panels. Rows are 44–48 dp tall. Text is 13–16 sp:diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassMotion.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassMotion.ktindex fe43458..0f1c835 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassMotion.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassMotion.kt@@ -63,4 +63,10 @@ object GlassMotion {/** A tap shorter than this still shows the whole press before releasing. */const val MinPressMillis = 90L++ /**+ * How long a tapped back button waits before leaving: long enough for the swell to land and start+ * springing back (the press is visible, as on iOS), short enough that it never reads as lag.+ */+ const val BackTapDelayMillis = 140L}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 d07154c..6ea59b6 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@@ -1,5 +1,6 @@package com.chethan616.clearpdf.ui.components+import kotlinx.coroutines.launchimport androidx.compose.animation.core.FastOutSlowInEasingimport androidx.compose.animation.core.animateFloatAsStateimport androidx.compose.animation.core.tween@@ -68,8 +69,29 @@ fun GlassBackButton(onLongPressBack: (() -> Unit)? = LocalBackToLibraryAction.current,longPressLabel: String? = null) {+ // A tap waits [GlassMotion.BackTapDelayMillis] so the press is seen before the screen goes; it+ // used to leave on the same frame, before the glass had moved. The system back gesture stays+ // instant (it is the screen's BackHandler, not this). Further taps while waiting are ignored, and+ // leaving the screen meanwhile cancels the wait, so Back never fires twice.+ val scope = androidx.compose.runtime.rememberCoroutineScope()+ val currentOnBack by androidx.compose.runtime.rememberUpdatedState(onBack)+ val reduced = com.chethan616.clearpdf.ui.theme.LocalReducedGlassMotion.current+ val pending = remember { booleanArrayOf(false) }LiquidIconButton(- onClick = onBack,+ onClick = {+ if (reduced) currentOnBack()+ else if (!pending[0]) {+ pending[0] = true+ scope.launch {+ try {+ kotlinx.coroutines.delay(GlassMotion.BackTapDelayMillis)+ currentOnBack()+ } finally {+ pending[0] = false+ }+ }+ }+ },onLongClick = onLongPressBack,onLongClickLabel = onLongPressBack?.let { longPressLabel ?: stringResource(R.string.back_to_library) },backdrop = backdrop,diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.ktindex 9c453c7..52b44d7 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt@@ -54,7 +54,6 @@ import com.kyant.backdrop.shadow.InnerShadowimport com.kyant.backdrop.shadow.Shadowimport com.kyant.shapes.Capsuleimport kotlinx.coroutines.flow.collectLatest-import kotlinx.coroutines.flow.dropimport kotlinx.coroutines.launchimport kotlin.math.absimport kotlin.math.sign@@ -142,11 +141,17 @@ fun LiquidBottomTabs(}}LaunchedEffect(dampedDragAnimation) {+ // No drop(1): the bar is rebuilt every time it reappears (it steps away on Settings pages+ // and tool screens), and the selection can change between its first frame and this+ // effect starting. Holding Back on a Settings page did exactly that, and drop(1) threw+ // the change away, leaving the pill on Settings over Home. Move the pill whenever it is+ // not where the index says, and report only the bar's own changes (a drag) upward.snapshotFlow { currentIndex }- .drop(1).collectLatest { index ->- dampedDragAnimation.animateToValue(index.toFloat())- onTabSelected(index)+ if (dampedDragAnimation.targetValue.fastRoundToInt() != index) {+ dampedDragAnimation.animateToValue(index.toFloat())+ }+ if (index != selectedTabIndexState.value()) onTabSelected(index)}}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.ktindex 6f22e9a..ec86be2 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt@@ -241,6 +241,10 @@ fun SettingsScreen(title = pageTitle,backdrop = headerBackdrop,onBack = if (page != PageIndex) ({ page = PageIndex }) else null,+ // Holding Back on a Settings page returns to Settings itself. The app-wide+ // default (back to the library) popped all the way Home from in here.+ onBackLongPress = if (page != PageIndex) ({ page = PageIndex }) else null,+ backLongPressLabel = stringResource(R.string.settings_title),modifier = entrance.sectionFade(0))}