Skip to content

Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.

Liquid Glass settings page (blur, refraction height/amount, depth, chromatic aberration, vibrancy, brightness, tint, highlight, corners + presets) wired into every glass primitive; haptics switch; dark-reader chrome tint; no panel shadows

Chethan6161250e4afab82
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt
index c9b354b..2355530 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,7 @@ 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() }
+ remember(context) { com.chethan616.clearpdf.ui.components.GlassSettings.load(context); true }
val platformHaptics = androidx.compose.ui.platform.LocalHapticFeedback.current
val haptics = remember(platformHaptics) { com.chethan616.clearpdf.ui.utils.ThrottledHaptics(platformHaptics) }
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/FlatBackdrop.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/FlatBackdrop.kt
index 777a71c..ad0a3d2 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/FlatBackdrop.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/FlatBackdrop.kt
@@ -80,21 +80,21 @@ fun Modifier.chipGlassSurface(
surface: Color
): Modifier {
val flat = flatColorOf(backdrop)
+ val style = GlassSettings.style
return drawBackdrop(
backdrop = backdrop,
shape = shape,
effects = if (flat != null) ({}) else ({
- vibrancy()
- blur(2f.dp.toPx())
- lens(12f.dp.toPx(), 24f.dp.toPx())
+ glassEffects(style, 2f.dp.toPx(), 12f.dp.toPx(), 24f.dp.toPx())
}),
- highlight = { Highlight.Default },
+ highlight = { glassHighlight(style) },
shadow = null,
onDrawBackdrop = if (flat != null) ({ _ -> drawFlatVibrantBackdrop(flat) }) else ({ it() }),
- onDrawSurface = { drawRect(surface) }
+ onDrawSurface = { drawRect(surface.glassTint(style)) }
)
}
+/** The colour stack (user's vibrancy/brightness) over a flat [color]; blur and lens are no-ops there. */
fun DrawScope.drawFlatVibrantBackdrop(color: Color) {
- drawRect(color, colorFilter = VibrancyColorFilter)
+ drawRect(color, colorFilter = glassColorFilter(GlassSettings.style))
}
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassDialog.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassDialog.kt
index 3629ab2..a092bbe 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassDialog.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassDialog.kt
@@ -176,12 +176,18 @@ fun GlassDialog(
shape = { RoundedRectangle(48f.dp) },
effects = {
val p = progress.value.fastCoerceIn(0f, 1f)
+ val s = GlassSettings.style
colorControls(
- brightness = if (isLight) 0.2f else 0f,
- saturation = 1.5f
+ brightness = (if (isLight) 0.2f else 0f) + s.brightness,
+ saturation = s.saturation
+ )
+ blur(blurDp.toPx() * s.blur)
+ lens(
+ 24f.dp.toPx() * p * s.refractionHeight,
+ 48f.dp.toPx() * p * s.refractionAmount,
+ depthEffect = true,
+ chromaticAberration = true
)
- blur(blurDp.toPx())
- lens(24f.dp.toPx() * p, 48f.dp.toPx() * p, depthEffect = true, chromaticAberration = true)
},
highlight = { Highlight.Plain },
shadow = { Shadow(radius = 24f.dp, color = Color.Black.copy(alpha = 0.12f)) },
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassSearchHeader.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassSearchHeader.kt
index a281b32..1d80df9 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassSearchHeader.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassSearchHeader.kt
@@ -335,9 +335,7 @@ fun GlassSearchPill(
backdrop = backdrop,
shape = { Capsule },
effects = {
- vibrancy()
- blur(8f.dp.toPx())
- lens(16f.dp.toPx(), 32f.dp.toPx())
+ glassEffects(GlassSettings.style, 8f.dp.toPx(), 16f.dp.toPx(), 32f.dp.toPx())
},
highlight = {
Highlight(style = HighlightStyle.Default(angle = uiSensor.gravityAngle, falloff = 2f))
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassStyle.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassStyle.kt
new file mode 100644
index 0000000..9fcec0e
--- /dev/null
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassStyle.kt
@@ -0,0 +1,156 @@
+package com.chethan616.clearpdf.ui.components
+
+import android.content.Context
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.ColorFilter
+import androidx.compose.ui.graphics.ColorMatrix
+import com.kyant.backdrop.BackdropEffectScope
+import com.kyant.backdrop.effects.blur
+import com.kyant.backdrop.effects.colorControls
+import com.kyant.backdrop.effects.lens
+import com.kyant.backdrop.effects.vibrancy
+import com.kyant.backdrop.highlight.Highlight
+import com.kyant.backdrop.highlight.HighlightStyle
+
+/**
+ * The user's liquid-glass tuning — the same knobs kyant's Glass Playground exposes (blur, refraction
+ * height + amount, depth, chromatic aberration, corner radius) plus the colour stack (vibrancy,
+ * brightness, tint) and the specular rim. Every value is a MULTIPLIER on each component's own design
+ * value (except saturation/brightness, which are absolute), so a panel keeps its heavier frost
+ * relative to a chip whatever the user picks. 1 = the designed look.
+ */
+@Immutable
+data class GlassStyle(
+ val blur: Float = 1f,
+ val refractionHeight: Float = 1f,
+ val refractionAmount: Float = 1f,
+ val depthEffect: Boolean = false,
+ val chromaticAberration: Boolean = false,
+ val saturation: Float = 1.5f,
+ val brightness: Float = 0f,
+ val tint: Float = 1f,
+ val highlight: Float = 1f,
+ val corners: Float = 1f
+) {
+ companion object {
+ val Default = GlassStyle()
+ /** Heavier frost + denser tint: text stays legible over white PDFs. */
+ val Readable = GlassStyle(blur = 2.4f, tint = 1.8f, refractionAmount = 0.7f, saturation = 1.3f)
+ /** Clear, strongly bent glass with a prismatic edge — the showpiece. */
+ val Crystal = GlassStyle(blur = 0.3f, refractionHeight = 1.5f, refractionAmount = 1.6f, depthEffect = true, chromaticAberration = true, tint = 0.6f, saturation = 1.7f)
+ /** No blur or lens passes at all — the cheapest glass, for slower phones. */
+ val Performance = GlassStyle(blur = 0f, refractionHeight = 0f, refractionAmount = 0f, tint = 1.4f)
+ }
+}
+
+/**
+ * App-wide glass settings, held in snapshot state so a change re-draws every glass surface live, and
+ * persisted. Also hosts the haptics switch (same "how the UI feels" family).
+ */
+object GlassSettings {
+ private const val PREFS = "ui_prefs"
+
+ var style: GlassStyle by mutableStateOf(GlassStyle.Default)
+ var hapticsEnabled: Boolean by mutableStateOf(true)
+
+ private var loaded = false
+
+ fun load(context: Context) {
+ if (loaded) return
+ loaded = true
+ val p = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
+ val d = GlassStyle.Default
+ style = GlassStyle(
+ blur = p.getFloat("blur", d.blur),
+ refractionHeight = p.getFloat("refractionHeight", d.refractionHeight),
+ refractionAmount = p.getFloat("refractionAmount", d.refractionAmount),
+ depthEffect = p.getBoolean("depthEffect", d.depthEffect),
+ chromaticAberration = p.getBoolean("chromaticAberration", d.chromaticAberration),
+ saturation = p.getFloat("saturation", d.saturation),
+ brightness = p.getFloat("brightness", d.brightness),
+ tint = p.getFloat("tint", d.tint),
+ highlight = p.getFloat("highlight", d.highlight),
+ corners = p.getFloat("corners", d.corners)
+ )
+ hapticsEnabled = p.getBoolean("haptics", true)
+ }
+
+ fun update(context: Context, s: GlassStyle) {
+ style = s
+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit()
+ .putFloat("blur", s.blur)
+ .putFloat("refractionHeight", s.refractionHeight)
+ .putFloat("refractionAmount", s.refractionAmount)
+ .putBoolean("depthEffect", s.depthEffect)
+ .putBoolean("chromaticAberration", s.chromaticAberration)
+ .putFloat("saturation", s.saturation)
+ .putFloat("brightness", s.brightness)
+ .putFloat("tint", s.tint)
+ .putFloat("highlight", s.highlight)
+ .putFloat("corners", s.corners)
+ .apply()
+ }
+
+ fun setHaptics(context: Context, enabled: Boolean) {
+ hapticsEnabled = enabled
+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean("haptics", enabled).apply()
+ }
+}
+
+/**
+ * The shared glass effect stack, scaled by [style]: colour (vibrancy or the user's saturation /
+ * brightness), frost, then the lens. Components pass their DESIGNED pixel values.
+ */
+fun BackdropEffectScope.glassEffects(
+ style: GlassStyle,
+ blurPx: Float,
+ refractionHeightPx: Float,
+ refractionAmountPx: Float,
+ depthEffect: Boolean = false
+) {
+ if (style.saturation == 1.5f && style.brightness == 0f) vibrancy()
+ else colorControls(brightness = style.brightness, saturation = style.saturation)
+ blur(blurPx * style.blur)
+ lens(
+ refractionHeightPx * style.refractionHeight,
+ refractionAmountPx * style.refractionAmount,
+ depthEffect = depthEffect || style.depthEffect,
+ chromaticAberration = style.chromaticAberration
+ )
+}
+
+/** A component's surface wash, scaled by the user's tint. */
+fun Color.glassTint(style: GlassStyle): Color =
+ if (style.tint == 1f) this else copy(alpha = (alpha * style.tint).coerceIn(0f, 1f))
+
+/** The default specular rim at the user's strength. */
+fun glassHighlight(style: GlassStyle, base: Highlight = Highlight.Default): Highlight? =
+ if (style.highlight <= 0f) null else base.copy(alpha = style.highlight.coerceIn(0f, 1f))
+
+/** As [glassHighlight] for the tilt-following rim panels use. */
+fun glassHighlight(style: GlassStyle, angle: Float): Highlight? =
+ glassHighlight(style, Highlight(style = HighlightStyle.Default(angle = angle)))
+
+/** The colour stack alone, for the flat-wallpaper fast path (see FlatBackdrop). */
+internal fun glassColorFilter(style: GlassStyle): ColorFilter {
+ if (style.saturation == 1.5f && style.brightness == 0f) return VibrancyColorFilter
+ val s = style.saturation
+ val r = 0.213f * (1f - s)
+ val g = 0.715f * (1f - s)
+ val b = 0.072f * (1f - s)
+ val o = style.brightness * 255f
+ return ColorFilter.colorMatrix(
+ ColorMatrix(
+ floatArrayOf(
+ r + s, g, b, 0f, o,
+ r, g + s, b, 0f, o,
+ r, g, b + s, 0f, o,
+ 0f, 0f, 0f, 1f, 0f
+ )
+ )
+ )
+}
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.kt
index 933410c..92dcf9d 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
@@ -172,22 +172,18 @@ fun LiquidBottomTabs(
backdrop = backdrop,
shape = { Capsule },
effects = {
- vibrancy()
- // Half the original 8 dp. This is the tab bar's own surface only — the
- // selection capsule below draws through `tabsBackdrop`, which keeps its
- // own blur, so softening the bar does not soften the slider riding on it.
- // The lens is untouched: at 24x24 it is what gives the bar its edge, and
- // dropping the blur without it would flatten the whole capsule.
- blur(4f.dp.toPx())
- lens(24f.dp.toPx(), 24f.dp.toPx())
+ // Half the original 8 dp blur; the 24x24 lens gives the bar its edge. Both
+ // scale with Settings -> Liquid Glass (identical at the defaults).
+ glassEffects(GlassSettings.style, 4f.dp.toPx(), 24f.dp.toPx(), 24f.dp.toPx())
},
+ highlight = { glassHighlight(GlassSettings.style) },
layerBlock = {
val progress = dampedDragAnimation.pressProgress
val scale = lerp(1f, 1f + 16f.dp.toPx() / size.width, progress)
scaleX = scale
scaleY = scale
},
- onDrawSurface = { drawRect(containerColor) }
+ onDrawSurface = { drawRect(containerColor.glassTint(GlassSettings.style)) }
)
.then(interactiveHighlight.modifier)
.height(barHeight)
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidButton.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidButton.kt
index 7c1d774..7b371ba 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
@@ -96,6 +96,7 @@ fun LiquidButton(
}
// Flat wallpaper: same pixels, none of the blur/lens/offscreen work — see FlatBackdrop.
val flat = flatColorOf(backdrop)
+ val style = GlassSettings.style
Row(
modifier
@@ -103,10 +104,9 @@ fun LiquidButton(
backdrop = backdrop,
shape = { Capsule },
effects = if (flat != null) ({}) else ({
- vibrancy()
- blur(blurRadius.toPx())
- lens(12f.dp.toPx(), 24f.dp.toPx())
+ glassEffects(style, blurRadius.toPx(), 12f.dp.toPx(), 24f.dp.toPx())
}),
+ highlight = { glassHighlight(style) },
onDrawBackdrop = if (flat != null) ({ _ -> drawFlatVibrantBackdrop(flat) }) else ({ it() }),
layerBlock = if (isInteractive) {
{
@@ -151,7 +151,7 @@ fun LiquidButton(
drawRect(tint.copy(alpha = 0.8f))
}
if (surfaceColor.isSpecified) {
- drawRect(surfaceColor)
+ drawRect(surfaceColor.glassTint(style))
}
}
)
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.kt
index 66d1bc6..3ff2432 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
@@ -82,13 +82,13 @@ fun Modifier.glassMenu(
backdrop = backdrop,
shape = shape,
effects = {
- vibrancy()
- blur(10f.dp.toPx())
- lens(14f.dp.toPx(), 28f.dp.toPx())
+ glassEffects(GlassSettings.style, 10f.dp.toPx(), 14f.dp.toPx(), 28f.dp.toPx())
},
- highlight = { Highlight.Default },
- shadow = { Shadow(radius = 12.dp, color = Color.Black.copy(alpha = if (dark) 0.3f else 0.12f)) },
- onDrawSurface = { drawRect(if (dark) Color(0xFF1E1E1E).copy(0.62f) else Color(0xFFFAFAFA).copy(0.62f)) }
+ highlight = { glassHighlight(GlassSettings.style) },
+ shadow = null,
+ onDrawSurface = {
+ drawRect((if (dark) Color(0xFF1E1E1E).copy(0.62f) else Color(0xFFFAFAFA).copy(0.62f)).glassTint(GlassSettings.style))
+ }
)
/** One choice in a [LiquidGlassDropdown]. [supporting] is an optional second line (e.g. a native name). */
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.kt
index 81e8f11..c9dda8f 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.kt
@@ -28,7 +28,7 @@ fun Modifier.liquidGlassPanel(
// renders white text over a backdrop that may be a bright page — it needs a dark,
// mostly-opaque base so text stays readable while the glass refraction is kept.
containerColorOverride: Color? = null,
- withShadow: Boolean = true
+ withShadow: Boolean = false
): Modifier {
val isDarkMode = LocalIsDarkMode.current
val isLightTheme = !isDarkMode
@@ -38,22 +38,21 @@ fun Modifier.liquidGlassPanel(
?: if (isLightTheme) Color(0xFFFAFAFA).copy(0.35f) else Color(0xFF1E1E1E).copy(0.35f)
// Flat wallpaper: same pixels, none of the blur/lens/offscreen work — see FlatBackdrop.
val flat = flatColorOf(backdrop)
+ val style = GlassSettings.style
return this.drawBackdrop(
backdrop = backdrop,
- shape = { RoundedRectangle(28f.dp) },
+ shape = { RoundedRectangle(28f.dp * style.corners) },
// Heavier frost than a chip on purpose: panels carry paragraphs of text, which a 2 dp blur
// over a busy custom wallpaper would leave unreadable.
effects = if (flat != null) ({}) else ({
- vibrancy()
- blur(8f.dp.toPx())
- lens(20f.dp.toPx(), 40f.dp.toPx(), depthEffect = true)
+ glassEffects(style, 8f.dp.toPx(), 20f.dp.toPx(), 40f.dp.toPx(), depthEffect = true)
}),
// The chips' bright specular rim (falloff 1, LiquidButton's default) instead of the old narrow
// falloff-2 sheen plus a dark 3 dp inner shadow — that inset edge was what made panels read as
// tinted cards next to the glassy title chips. Still turns with the device tilt.
- highlight = { Highlight(style = HighlightStyle.Default(angle = uiSensor.gravityAngle)) },
+ highlight = { glassHighlight(style, uiSensor.gravityAngle) },
shadow = if (withShadow) ({ Shadow(radius = 8f.dp, color = Color.Black.copy(alpha = 0.1f)) }) else null,
onDrawBackdrop = if (flat != null) ({ _ -> drawFlatVibrantBackdrop(flat) }) else ({ it() }),
- onDrawSurface = { drawRect(containerColor) }
+ onDrawSurface = { drawRect(containerColor.glassTint(style)) }
)
}
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.kt
index 95b9c0f..e02c9e5 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
@@ -69,6 +69,7 @@ fun LiquidIconButton(
}
// Flat wallpaper: same pixels, none of the blur/lens/offscreen work — see FlatBackdrop.
val flat = flatColorOf(backdrop)
+ val style = GlassSettings.style
// 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() }
@@ -90,10 +91,9 @@ fun LiquidIconButton(
backdrop = backdrop,
shape = { CircleShape },
effects = if (flat != null) ({}) else ({
- vibrancy()
- blur(2f.dp.toPx())
- lens(12f.dp.toPx(), 24f.dp.toPx())
+ glassEffects(style, 2f.dp.toPx(), 12f.dp.toPx(), 24f.dp.toPx())
}),
+ highlight = { glassHighlight(style) },
onDrawBackdrop = if (flat != null) ({ _ -> drawFlatVibrantBackdrop(flat) }) else ({ it() }),
layerBlock = if (isInteractive) {
{
@@ -132,7 +132,7 @@ fun LiquidIconButton(
drawRect(tint.copy(alpha = 0.75f))
}
if (surfaceColor.isSpecified) {
- drawRect(surfaceColor)
+ drawRect(surfaceColor.glassTint(style))
}
}
)
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.kt
index e45245c..a4ea9af 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.kt
@@ -49,17 +49,18 @@ fun Modifier.viewerGlass(
shape: () -> Shape = { ViewerGlassShape },
// Off for surfaces that must NOT cast a drop shadow — e.g. the onboarding page-1 book, whose
// shadow otherwise snapped in the moment the assembled book reached full opacity.
- withShadow: Boolean = true
+ withShadow: Boolean = false
): Modifier = drawBackdrop(
backdrop = backdrop,
shape = shape,
+ // GlassSettings.style is snapshot state read inside these draw-time lambdas, so a change in
+ // Settings re-draws every viewer surface live without recomposing anything.
effects = {
- vibrancy()
- blur(2f.dp.toPx())
- lens(12f.dp.toPx(), 24f.dp.toPx())
+ glassEffects(GlassSettings.style, 2f.dp.toPx(), 12f.dp.toPx(), 24f.dp.toPx())
},
+ highlight = { glassHighlight(GlassSettings.style) },
shadow = if (withShadow) ({ com.kyant.backdrop.shadow.Shadow.Default }) else null,
- onDrawSurface = { drawRect(color) }
+ onDrawSurface = { drawRect(color.glassTint(GlassSettings.style)) }
)
/**
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt
index 93d595c..89e7a4e 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt
@@ -121,7 +121,7 @@ private fun ViewerGlassOverflowSurface(
content: @Composable BoxScope.() -> Unit
) {
Box(modifier) {
- Box(Modifier.matchParentSize().viewerGlass(backdrop, color))
+ Box(Modifier.matchParentSize().viewerGlass(backdrop, color, withShadow = false))
Box(Modifier.fillMaxWidth().zIndex(1f), content = content)
}
}
@@ -474,7 +474,7 @@ internal fun PdfViewerBottomToolbar(
// ── Export feedback row ────────────────────────────────────────────
if (exportError != null || exportMessage != null || isExporting) {
Row(
- Modifier.fillMaxWidth().viewerGlass(backdrop, glass).padding(12.dp),
+ Modifier.fillMaxWidth().viewerGlass(backdrop, glass, withShadow = false).padding(12.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt
index 056bf93..ad90b99 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt
@@ -760,8 +760,12 @@ fun PdfViewerScreen(
// the icons dynamic per-region, kills the "doesn't flip until you scroll deep into page 3" lag,
// and tracks the zoomed region on a single page. The old single-page white-pin is gone with it —
// band sampling reads the dark letterbox as dark (→ white ink) on its own.
- val isLightChrome = remember(currentPageBitmap) {
- currentPageBitmap?.let { averageLuminance(it) > 0.60f } ?: false
+ val isLightChrome = remember(currentPageBitmap, darkPageAppearance) {
+ // Dark reader draws the page inverted, so what is on screen is 1 - bitmap.
+ currentPageBitmap?.let {
+ val l = averageLuminance(it)
+ (if (darkPageAppearance) 1f - l else l) > 0.60f
+ } ?: false
}
// Home's tint, verbatim — the same expression GlassTitlePill and GlassSearchPill resolve — but
// picked off the *page's* luminance instead of the theme, so a white scan in dark mode still gets
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.kt
index 743f78a..8adbfb1 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
@@ -115,6 +115,8 @@ import com.chethan616.clearpdf.ui.theme.LiquidGlassColors
import com.chethan616.clearpdf.ui.theme.ToolAccents
import com.chethan616.clearpdf.ui.utils.rememberUISensor
import com.kyant.backdrop.Backdrop
+import com.kyant.backdrop.backdrops.layerBackdrop
+import androidx.compose.material.icons.rounded.Layers
import com.kyant.backdrop.backdrops.LayerBackdrop
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
@@ -211,6 +213,7 @@ fun SettingsScreen(
PageAbout -> stringResource(R.string.settings_about)
PageLicenses -> stringResource(R.string.settings_licenses)
PageOffice -> stringResource(R.string.office_engine_title)
+ PageGlass -> stringResource(R.string.settings_glass)
else -> stringResource(R.string.settings_title)
}
Box(Modifier.fillMaxSize()) {
@@ -252,6 +255,8 @@ fun SettingsScreen(
SettingsSection(backdrop, uiSensor, entrance.sectionFade(1), padding = 8.dp, gap = 0.dp) {
SettingsNavRow(Icons.Rounded.Tune, LiquidGlassColors.Orange, stringResource(R.string.settings_appearance), themeLabel, ink, sub) { page = PageAppearance }
SettingsDivider(isLight)
+ SettingsNavRow(Icons.Rounded.AutoAwesome, LiquidGlassColors.Teal, stringResource(R.string.settings_glass), null, ink, sub) { page = PageGlass }
+ SettingsDivider(isLight)
SettingsNavRow(Icons.Rounded.Language, LiquidGlassColors.Blue, stringResource(R.string.settings_language), langLabel, ink, sub) { page = PageLanguage }
SettingsDivider(isLight)
SettingsNavRow(Icons.Rounded.Wallpaper, LiquidGlassColors.Indigo, stringResource(R.string.settings_personalization), null, ink, sub) { page = PagePersonal }
@@ -308,6 +313,7 @@ fun SettingsScreen(
)
}
+ if (p == PageGlass) GlassTuningPage(backdrop, uiSensor, ink, sub)
// ── Language ──
if (p == PageLanguage) SettingsSection(backdrop, uiSensor, Modifier) {
SettingsSectionHeader(Icons.Rounded.Language, stringResource(R.string.settings_language), ink)
@@ -431,6 +437,15 @@ fun SettingsScreen(
// ── Personalization ──
if (p == PagePersonal) SettingsSection(backdrop, uiSensor, Modifier, gap = 4.dp) {
SettingsSectionHeader(Icons.Rounded.Wallpaper, stringResource(R.string.settings_personalization), ink, bottomPad = 8.dp)
+ SettingsToggleRow(
+ icon = Icons.Rounded.Vibration,
+ title = stringResource(R.string.settings_haptics),
+ desc = stringResource(R.string.settings_haptics_desc),
+ checked = com.chethan616.clearpdf.ui.components.GlassSettings.hapticsEnabled,
+ onCheckedChange = { com.chethan616.clearpdf.ui.components.GlassSettings.setHaptics(context, it) },
+ backdrop = backdrop
+ )
+ SettingsDivider(isLight)
SettingsToggleRow(
icon = Icons.Rounded.Wallpaper,
title = stringResource(R.string.settings_background),
@@ -558,6 +573,123 @@ private const val PagePersonal = 4
private const val PageAbout = 5
private const val PageLicenses = 6
private const val PageOffice = 7
+private const val PageGlass = 8
+
+/**
+ * Settings -> Liquid Glass: kyant's Glass Playground knobs, app-wide. A live preview chip sits over a
+ * busy swatch (the wallpaper is usually flat, which would hide blur and refraction), presets on top,
+ * then every parameter. Changes apply to every glass surface instantly and persist.
+ */
+@Composable
+private fun GlassTuningPage(
+ backdrop: Backdrop,
+ uiSensor: com.chethan616.clearpdf.ui.utils.UISensor,
+ ink: Color,
+ sub: Color
+) {
+ val context = LocalContext.current
+ val style = com.chethan616.clearpdf.ui.components.GlassSettings.style
+ fun set(s: com.chethan616.clearpdf.ui.components.GlassStyle) =
+ com.chethan616.clearpdf.ui.components.GlassSettings.update(context, s)
+ val isLight = !com.chethan616.clearpdf.ui.theme.LocalIsDarkMode.current
+
+ // Preview: a glass chip over a vivid, detailed strip so every knob is visible.
+ val previewBackdrop = com.kyant.backdrop.backdrops.rememberLayerBackdrop()
+ Box(
+ Modifier
+ .fillMaxWidth()
+ .height(150.dp)
+ .clip(RoundedCornerShape(28.dp)),
+ contentAlignment = Alignment.Center
+ ) {
+ Box(
+ Modifier
+ .matchParentSize()
+ .layerBackdrop(previewBackdrop)
+ .background(
+ androidx.compose.ui.graphics.Brush.linearGradient(
+ listOf(Color(0xFF0A84FF), Color(0xFFBF5AF2), Color(0xFFFF375F), Color(0xFFFF9F0A), Color(0xFF30D158))
+ )
+ )
+ ) {
+ Column(Modifier.matchParentSize().padding(14.dp), verticalArrangement = Arrangement.SpaceBetween) {
+ repeat(4) {
+ BasicText("ClearPDF • Aa Bb Cc • 0123456789", style = TextStyle(Color.White.copy(0.9f), 13.sp, FontWeight.Bold), maxLines = 1)
+ }
+ }
+ }
+ LiquidButton(onClick = {}, backdrop = previewBackdrop, surfaceColor = if (isLight) Color(0xFFFAFAFA).copy(0.35f) else Color(0xFF1E1E1E).copy(0.35f)) {
+ BasicText(stringResource(R.string.glass_preview), style = TextStyle(ink, 16.sp, FontWeight.SemiBold))
+ }
+ }
+
+ SettingsSection(backdrop, uiSensor, Modifier, gap = 12.dp) {
+ val presets = listOf(
+ com.chethan616.clearpdf.ui.components.GlassStyle.Default to stringResource(R.string.glass_preset_default),
+ com.chethan616.clearpdf.ui.components.GlassStyle.Readable to stringResource(R.string.glass_preset_readable),
+ com.chethan616.clearpdf.ui.components.GlassStyle.Crystal to stringResource(R.string.glass_preset_crystal),
+ com.chethan616.clearpdf.ui.components.GlassStyle.Performance to stringResource(R.string.glass_preset_performance)
+ )
+ Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ presets.forEach { (p, label) ->
+ GlassChoiceChip(label = label, selected = style == p, onClick = { set(p) }, backdrop = backdrop, accent = LiquidGlassColors.Blue)
+ }
+ }
+ }
+
+ SettingsSection(backdrop, uiSensor, Modifier, gap = 6.dp) {
+ @Composable
+ fun knob(label: String, value: Float, range: ClosedFloatingPointRange<Float>, onChange: (Float) -> Unit) {
+ Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
+ BasicText(label, style = TextStyle(ink, 14.sp, FontWeight.Medium))
+ BasicText("%.2f".format(value), style = TextStyle(sub, 13.sp))
+ }
+ LiquidSlider(
+ value = { value },
+ onValueChange = onChange,
+ valueRange = range,
+ visibilityThreshold = 0.005f,
+ backdrop = backdrop,
+ modifier = Modifier.fillMaxWidth()
+ )
+ }
+ knob(stringResource(R.string.glass_blur), style.blur, 0f..3f) { set(style.copy(blur = it)) }
+ knob(stringResource(R.string.glass_refraction_height), style.refractionHeight, 0f..2f) { set(style.copy(refractionHeight = it)) }
+ knob(stringResource(R.string.glass_refraction_amount), style.refractionAmount, 0f..2f) { set(style.copy(refractionAmount = it)) }
+ knob(stringResource(R.string.glass_tint), style.tint, 0f..2.5f) { set(style.copy(tint = it)) }
+ knob(stringResource(R.string.glass_vibrancy), style.saturation, 0.5f..2.5f) { set(style.copy(saturation = it)) }
+ knob(stringResource(R.string.glass_brightness), style.brightness, -0.3f..0.3f) { set(style.copy(brightness = it)) }
+ knob(stringResource(R.string.glass_highlight), style.highlight, 0f..1f) { set(style.copy(highlight = it)) }
+ knob(stringResource(R.string.glass_corners), style.corners, 0.4f..1.4f) { set(style.copy(corners = it)) }
+ SettingsDivider(isLight)
+ SettingsToggleRow(
+ icon = Icons.Rounded.Layers,
+ title = stringResource(R.string.glass_depth),
+ desc = stringResource(R.string.glass_depth_desc),
+ checked = style.depthEffect,
+ onCheckedChange = { set(style.copy(depthEffect = it)) },
+ backdrop = backdrop
+ )
+ SettingsDivider(isLight)
+ SettingsToggleRow(
+ icon = Icons.Rounded.AutoAwesome,
+ title = stringResource(R.string.glass_chromatic),
+ desc = stringResource(R.string.glass_chromatic_desc),
+ checked = style.chromaticAberration,
+ onCheckedChange = { set(style.copy(chromaticAberration = it)) },
+ backdrop = backdrop
+ )
+ Spacer(Modifier.height(8.dp))
+ ToolPrimaryButton(
+ text = stringResource(R.string.glass_reset),
+ onClick = { set(com.chethan616.clearpdf.ui.components.GlassStyle.Default) },
+ backdrop = backdrop,
+ accent = LiquidGlassColors.Blue,
+ icon = Icons.Rounded.Refresh,
+ modifier = Modifier.fillMaxWidth()
+ )
+ }
+}
/** One row of the Settings index: tinted icon tile, title, current value, chevron — iOS Settings. */
@Composable
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.kt
index 6e54629..fabe43a 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/utils/ThrottledHaptics.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/utils/ThrottledHaptics.kt
@@ -12,6 +12,8 @@ import androidx.compose.ui.hapticfeedback.HapticFeedbackType
class ThrottledHaptics(private val delegate: HapticFeedback, private val windowMs: Long = 90L) : HapticFeedback {
private var last = 0L
override fun performHapticFeedback(hapticFeedbackType: HapticFeedbackType) {
+ // Settings -> Personalization -> Haptic feedback.
+ if (!com.chethan616.clearpdf.ui.components.GlassSettings.hapticsEnabled) return
val now = SystemClock.uptimeMillis()
if (now - last < windowMs) return
last = now
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 33af1ff..cd56ad2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -745,4 +745,26 @@
<string name="tour_sheet_message">Tap the pencil to reveal cell formatting, color, and layout controls.</string>
<string name="back_to_library">Return to library</string>
<string name="home_works_with">Works with</string>
+ <string name="settings_glass">Liquid Glass</string>
+ <string name="glass_preview">Liquid Glass</string>
+ <string name="glass_preset_default">Default</string>
+ <string name="glass_preset_readable">Readable</string>
+ <string name="glass_preset_crystal">Crystal</string>
+ <string name="glass_preset_performance">Performance</string>
+ <string name="glass_preset_custom">Custom</string>
+ <string name="glass_blur">Blur</string>
+ <string name="glass_refraction_height">Refraction height</string>
+ <string name="glass_refraction_amount">Refraction amount</string>
+ <string name="glass_tint">Tint</string>
+ <string name="glass_vibrancy">Vibrancy</string>
+ <string name="glass_brightness">Brightness</string>
+ <string name="glass_highlight">Specular highlight</string>
+ <string name="glass_corners">Corner radius</string>
+ <string name="glass_depth">Depth effect</string>
+ <string name="glass_depth_desc">Thicker-looking glass that bends more toward the centre</string>
+ <string name="glass_chromatic">Chromatic aberration</string>
+ <string name="glass_chromatic_desc">Prism-coloured fringes on the glass edges</string>
+ <string name="glass_reset">Reset to default</string>
+ <string name="settings_haptics">Haptic feedback</string>
+ <string name="settings_haptics_desc">A light tick when you tap buttons and pick options</string>
</resources>