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
Every viewer icon picks its own ink from what is behind it
chethan616aa77fc6488d8
diff --git a/DESIGN.md b/DESIGN.mdindex 78fac67..8629eaa 100644--- a/DESIGN.md+++ b/DESIGN.md@@ -75,6 +75,10 @@ chromatic aberration, vibrancy, brightness, tint, highlight, corners, plus prese- Over documents use `chipGlass(onLight)` and `chipInk(onLight)`, picking `onLight` from the contentbehind the control (the viewer's `bandLuminance`). **In dark reader mode, invert the luminance**(`1 - l`).+- **Every viewer control picks its own ink** (PDF, PPT, Word, spreadsheet, find bar): wrap it with+ `rememberAdaptiveInk(barInk)` and put `probe.modifier` first on the control. It reads the real+ pixels at the control's corners and beside its glyph (`ProvideScreenInk`, a scaled window copy,+ Android 8+), so two circles in one bar can differ. The bar's ink is only the fallback.- Vivid actions use the per-screen accent (`ToolAccents`, `LiquidGlassColors`) via `tint`.---diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.ktindex cefb489..2998acb 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt@@ -315,6 +315,8 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nuLocalGlassOverlayHost provides overlayHost,androidx.compose.ui.platform.LocalHapticFeedback provides haptics) {+ // Per-icon ink in the document viewers (each control samples what's behind it).+ com.chethan616.clearpdf.ui.components.ProvideScreenInk {Box(Modifier.fillMaxSize()) {// Captured layer = wallpaper + the live screen. The floating tab bar// (below) samples THIS, so it reflects real content scrolling under it@@ -562,6 +564,7 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu// Last child: above the tab bar and dialogs, outside the layer it samples.GlassOverlayLayer(overlayHost, contentBackdrop)}+ }}}}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/AdaptiveInk.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/AdaptiveInk.ktnew file mode 100644index 0000000..8d3b1c5--- /dev/null+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/AdaptiveInk.kt@@ -0,0 +1,209 @@+package com.chethan616.clearpdf.ui.components++import android.app.Activity+import android.content.Context+import android.content.ContextWrapper+import android.graphics.Bitmap+import android.os.Build+import android.os.Handler+import android.os.Looper+import android.view.PixelCopy+import android.view.View+import android.view.ViewTreeObserver+import android.view.Window+import androidx.annotation.RequiresApi+import androidx.compose.animation.animateColorAsState+import androidx.compose.animation.core.tween+import androidx.compose.runtime.Composable+import androidx.compose.runtime.CompositionLocalProvider+import androidx.compose.runtime.DisposableEffect+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.Stable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableIntStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberUpdatedState+import androidx.compose.runtime.setValue+import androidx.compose.runtime.snapshotFlow+import androidx.compose.runtime.staticCompositionLocalOf+import androidx.compose.ui.Modifier+import androidx.compose.ui.geometry.Rect+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.luminance+import androidx.compose.ui.layout.boundsInWindow+import androidx.compose.ui.layout.onGloballyPositioned+import androidx.compose.ui.platform.LocalDensity+import androidx.compose.ui.platform.LocalView+import androidx.compose.ui.unit.dp+import kotlinx.coroutines.delay+import kotlinx.coroutines.flow.first+import kotlinx.coroutines.suspendCancellableCoroutine+import java.util.concurrent.atomic.AtomicBoolean+import kotlin.coroutines.resume++/**+ * Per-control ink for the document viewers. Each icon reads what is really on screen around it+ * and picks dark or white ink for itself, so two buttons in the same bar can differ (one over a+ * white page, one over the dark desk beside it, a photo, book mode's letterbox).+ *+ * How: while at least one control asks, the window is copied, scaled down, a few times a second,+ * and only after it actually drew something new. A control samples the corners of its own box,+ * which sit outside its round or capsule glass, so its own ink never feeds back into the reading.+ * Before Android 8 (no window PixelCopy) every control keeps the ink its screen gives it.+ */+@Stable+class ScreenInkSampler internal constructor() {+ internal var frame by mutableStateOf<InkFrame?>(null)+ internal var users by mutableIntStateOf(0)++ @RequiresApi(Build.VERSION_CODES.O)+ internal suspend fun run(window: Window, view: View) {+ val dirty = AtomicBoolean(true)+ val listener = ViewTreeObserver.OnDrawListener { dirty.set(true) }+ view.viewTreeObserver.addOnDrawListener(listener)+ val handler = Handler(Looper.getMainLooper())+ var bitmap: Bitmap? = null+ try {+ while (true) {+ if (users == 0) {+ snapshotFlow { users > 0 }.first { it }+ dirty.set(true)+ }+ val decor = window.decorView+ val w = decor.width+ val h = decor.height+ if (w > 0 && h > 0 && dirty.getAndSet(false)) {+ val bw = (w / SCALE_DOWN).coerceAtLeast(1)+ val bh = (h / SCALE_DOWN).coerceAtLeast(1)+ val target = bitmap?.takeIf { it.width == bw && it.height == bh && !it.isRecycled }+ ?: Bitmap.createBitmap(bw, bh, Bitmap.Config.ARGB_8888).also { bitmap = it }+ val ok = runCatching {+ suspendCancellableCoroutine { cont ->+ PixelCopy.request(window, target, { result -> if (cont.isActive) cont.resume(result) }, handler)+ } == PixelCopy.SUCCESS+ }.getOrDefault(false)+ if (ok) {+ val px = IntArray(bw * bh)+ target.getPixels(px, 0, bw, 0, 0, bw, bh)+ frame = InkFrame(px, bw, bh, bw / w.toFloat(), bh / h.toFloat())+ }+ }+ delay(SAMPLE_INTERVAL_MS)+ }+ } finally {+ if (view.viewTreeObserver.isAlive) view.viewTreeObserver.removeOnDrawListener(listener)+ bitmap?.recycle()+ }+ }++ private companion object {+ const val SCALE_DOWN = 6+ const val SAMPLE_INTERVAL_MS = 140L+ }+}++/** A scaled-down copy of the window; coordinates in and out are window pixels. */+internal class InkFrame(+ private val pixels: IntArray,+ private val width: Int,+ private val height: Int,+ private val scaleX: Float,+ private val scaleY: Float+) {+ private fun luminanceAt(x: Float, y: Float): Double {+ val px = (x * scaleX).toInt().coerceIn(0, width - 1)+ val py = (y * scaleY).toInt().coerceIn(0, height - 1)+ val c = pixels[py * width + px]+ return (0.299 * ((c shr 16) and 0xFF) + 0.587 * ((c shr 8) and 0xFF) + 0.114 * (c and 0xFF)) / 255.0+ }++ /**+ * Luminance around [box]: just inside its four corners (outside the rounded glass), plus, at+ * double weight, just outside its left and right edges level with its centre, where the icon+ * itself sits. A control straddling a page edge so follows what is beside its glyph.+ */+ fun cornerLuminance(box: Rect, inset: Float): Float {+ val d = inset.coerceAtMost(minOf(box.width, box.height) * 0.14f)+ val corners = luminanceAt(box.left + d, box.top + d) + luminanceAt(box.right - d, box.top + d) ++ luminanceAt(box.left + d, box.bottom - d) + luminanceAt(box.right - d, box.bottom - d)+ val cy = box.center.y+ val sides = luminanceAt(box.left - d * 0.6f, cy) + luminanceAt(box.right + d * 0.6f, cy)+ return ((corners + 2 * sides) / 8.0).toFloat()+ }+}++val LocalScreenInk = staticCompositionLocalOf<ScreenInkSampler?> { null }++/** Runs one [ScreenInkSampler] for this window (Android 8+); the viewers' controls read from it. */+@Composable+fun ProvideScreenInk(content: @Composable () -> Unit) {+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {+ content()+ return+ }+ val view = LocalView.current+ val window = remember(view) { view.context.findActivity()?.window }+ val sampler = remember { ScreenInkSampler() }+ if (window != null) LaunchedEffect(window, view) { sampler.run(window, view) }+ CompositionLocalProvider(LocalScreenInk provides if (window != null) sampler else null, content = content)+}++/** One control's ink: put [modifier] on the control (first, so it measures the resting box). */+class InkProbe internal constructor(val modifier: Modifier, val color: Color) {+ val soft: Color get() = color.copy(alpha = 0.62f)+}++private val InkOnLight = Color(0xFF15171C)++/**+ * Ink for one control, from the pixels around it. [fallback] is the ink the screen would use for+ * the whole bar: it applies until the first reading and on Android 7 and older, and when the+ * reading agrees with it, it is kept as is (so a screen's own dark ink stays its exact colour).+ */+@Composable+fun rememberAdaptiveInk(fallback: Color): InkProbe {+ val sampler = LocalScreenInk.current+ val fallbackOnLight = fallback.luminance() < 0.5f+ var onLight by remember { mutableStateOf(fallbackOnLight) }+ var measured by remember { mutableStateOf(false) }+ val box = remember { arrayOfNulls<Rect>(1) }+ val currentFallback by rememberUpdatedState(fallbackOnLight)+ val inset = with(LocalDensity.current) { 5.dp.toPx() }+ if (sampler != null) {+ DisposableEffect(sampler) {+ sampler.users+++ onDispose { sampler.users-- }+ }+ LaunchedEffect(sampler) {+ snapshotFlow { sampler.frame }.collect { frame ->+ val b = box[0]+ if (frame == null || b == null || b.width <= 0f || b.height <= 0f) return@collect+ val lum = frame.cornerLuminance(b, inset)+ // Hysteresis, so a control over a mid-grey picture doesn't flicker.+ onLight = when {+ !measured -> lum > 0.60f+ lum > 0.62f -> true+ lum < 0.58f -> false+ else -> onLight+ }+ measured = true+ }+ }+ }+ val useLight = if (sampler != null && measured) onLight else currentFallback+ val target = when {+ useLight == fallbackOnLight -> fallback+ useLight -> InkOnLight+ else -> Color.White+ }+ val color by animateColorAsState(target, tween(200), label = "adaptiveInk")+ val modifier = remember { Modifier.onGloballyPositioned { box[0] = it.boundsInWindow() } }+ return InkProbe(modifier, color)+}++private tailrec fun Context.findActivity(): Activity? = when (this) {+ is Activity -> this+ is ContextWrapper -> baseContext.findActivity()+ else -> null+}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/DocxEditorScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/DocxEditorScreen.ktindex a6b0684..c14526b 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/DocxEditorScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/DocxEditorScreen.kt@@ -185,6 +185,7 @@ import com.chethan616.clearpdf.docx.XNodeimport com.chethan616.clearpdf.docx.XmlScanimport com.chethan616.clearpdf.docx.findParaimport com.chethan616.clearpdf.docx.forEachPara+import com.chethan616.clearpdf.ui.components.rememberAdaptiveInkimport com.chethan616.clearpdf.ui.components.GlassBackButtonimport com.chethan616.clearpdf.ui.components.GlassColorPickerimport com.chethan616.clearpdf.ui.components.GlassDialog@@ -809,6 +810,12 @@ private fun DocxEditorContent(contentHorizontalPadding = 0.dp,headerHorizontalPadding = 12.dp,header = { headerBackdrop ->+ // Each control takes its own ink from what is behind it; the paper's ink is the fallback.+ val backInk = rememberAdaptiveInk(text)+ val titleInk = rememberAdaptiveInk(text)+ val findInk = rememberAdaptiveInk(text)+ val paperInk = rememberAdaptiveInk(text)+ val editInk = rememberAdaptiveInk(text)Row(verticalAlignment = Alignment.CenterVertically,horizontalArrangement = Arrangement.spacedBy(10.dp),@@ -817,7 +824,8 @@ private fun DocxEditorContent(GlassBackButton(onBack = { requestBack() },backdrop = headerBackdrop,- foreground = text,+ modifier = backInk.modifier,+ foreground = backInk.color,onLongPressBack = if (viewModel.dirty || editMode) ({ requestBack() }) else LocalBackToLibraryAction.current,longPressLabel = if (viewModel.dirty || editMode) stringResource(R.string.back) else null)@@ -825,8 +833,9 @@ private fun DocxEditorContent(GlassTitlePill(text = (if (viewModel.dirty) "• " else "") + meta.fileName.ifBlank { stringResource(R.string.viewer_title) },backdrop = headerBackdrop,+ modifier = titleInk.modifier,surfaceColor = chipTint,- contentColor = text+ contentColor = titleInk.color)}if (viewModel.dirty && editable) {@@ -839,14 +848,14 @@ private fun DocxEditorContent(}}if (!editMode) {- LiquidIconButton(onClick = { showSearch = true }, backdrop = headerBackdrop) {- Icon(Icons.Rounded.Search, stringResource(R.string.viewer_find), Modifier.size(20.dp), text)+ LiquidIconButton(onClick = { showSearch = true }, backdrop = headerBackdrop, modifier = findInk.modifier) {+ Icon(Icons.Rounded.Search, stringResource(R.string.viewer_find), Modifier.size(20.dp), findInk.color)}- LiquidIconButton(onClick = onTogglePaper, backdrop = headerBackdrop) {+ LiquidIconButton(onClick = onTogglePaper, backdrop = headerBackdrop, modifier = paperInk.modifier) {Icon(if (paperDark) Icons.Rounded.LightMode else Icons.Rounded.DarkMode,stringResource(if (paperDark) R.string.viewer_page_colors_original else R.string.viewer_page_dark_mode),- Modifier.size(19.dp), text+ Modifier.size(19.dp), paperInk.color)}}@@ -854,10 +863,11 @@ private fun DocxEditorContent(LiquidIconButton(onClick = { if (editMode) exitEdit() else { editMode = true; showSearch = false; searchQuery = "" } },backdrop = headerBackdrop,+ modifier = editInk.modifier,surfaceColor = if (editMode) accent.copy(0.22f) else Color.Unspecified) {if (editMode) BasicText(stringResource(R.string.sheet_done), style = TextStyle(accent, 13.sp, FontWeight.SemiBold))- else Icon(Icons.Rounded.Edit, stringResource(R.string.sheet_edit), Modifier.size(19.dp), text)+ else Icon(Icons.Rounded.Edit, stringResource(R.string.sheet_edit), Modifier.size(19.dp), editInk.color)}}}@@ -1079,9 +1089,14 @@ private fun DocxEditorContent(// ── reading chrome: page counter, print, PDF layout and share ──if (doc != null && flat != null && !editMode && !showSearch) {+ val pageInk = rememberAdaptiveInk(text)+ val printInk = rememberAdaptiveInk(text)+ val pdfInk = rememberAdaptiveInk(text)+ val shareInk = rememberAdaptiveInk(text)Row(Modifier.align(Alignment.BottomStart).navigationBarsPadding().padding(start = 12.dp, bottom = 10.dp).height(44.dp)+ .then(pageInk.modifier).viewerGlass(screenBackdrop.glass, chipTint, shape = { Capsule }).clip(Capsule).liquidRowClick(corner = 22.dp) { showGoTo = true }@@ -1091,7 +1106,7 @@ private fun DocxEditorContent(BasicText(stringResource(R.string.docx_page_of, currentPage + 1, flat.pages) +if (zoom != 1f) " · ${(zoom * 100).roundToInt()}%" else "",- style = TextStyle(text, 12.sp, FontWeight.SemiBold),+ style = TextStyle(pageInk.color, 12.sp, FontWeight.SemiBold),maxLines = 1)}@@ -1099,18 +1114,18 @@ private fun DocxEditorContent(Modifier.align(Alignment.BottomEnd).navigationBarsPadding().padding(end = 12.dp, bottom = 10.dp),horizontalArrangement = Arrangement.spacedBy(8.dp)) {- LiquidIconButton(onClick = { print() }, backdrop = screenBackdrop.glass, modifier = Modifier.size(44.dp)) {- Icon(Icons.Rounded.Print, stringResource(R.string.docx_print), Modifier.size(20.dp), text)+ LiquidIconButton(onClick = { print() }, backdrop = screenBackdrop.glass, modifier = printInk.modifier.size(44.dp)) {+ Icon(Icons.Rounded.Print, stringResource(R.string.docx_print), Modifier.size(20.dp), printInk.color)}- LiquidIconButton(onClick = { openAsPdf() }, backdrop = screenBackdrop.glass, modifier = Modifier.size(44.dp)) {- Icon(Icons.Rounded.PictureAsPdf, stringResource(R.string.docx_open_as_pdf), Modifier.size(20.dp), text)+ LiquidIconButton(onClick = { openAsPdf() }, backdrop = screenBackdrop.glass, modifier = pdfInk.modifier.size(44.dp)) {+ Icon(Icons.Rounded.PictureAsPdf, stringResource(R.string.docx_open_as_pdf), Modifier.size(20.dp), pdfInk.color)}LiquidIconButton(onClick = { viewModel.currentFile(context) { u -> u?.let { shareFile(context, it) } } },backdrop = screenBackdrop.glass,- modifier = Modifier.size(44.dp)+ modifier = shareInk.modifier.size(44.dp)) {- Icon(Icons.Rounded.IosShare, stringResource(R.string.viewer_share_document), Modifier.size(20.dp), text)+ Icon(Icons.Rounded.IosShare, stringResource(R.string.viewer_share_document), Modifier.size(20.dp), shareInk.color)}}}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfSearchBar.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfSearchBar.ktindex b6afde9..e23bc94 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfSearchBar.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfSearchBar.kt@@ -22,6 +22,7 @@ import androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport com.chethan616.clearpdf.R+import com.chethan616.clearpdf.ui.components.rememberAdaptiveInkimport com.chethan616.clearpdf.ui.components.CloseCrossIconimport com.chethan616.clearpdf.ui.components.GlassSearchPillimport com.chethan616.clearpdf.ui.components.LiquidIconButton@@ -63,6 +64,11 @@ internal fun PdfSearchBar(try { focusRequester.requestFocus() } catch (_: Exception) {}}+ // Every control takes its ink from what is behind it; [fg] is the fallback.+ val pillInk = rememberAdaptiveInk(fg)+ val prevInk = rememberAdaptiveInk(fg)+ val nextInk = rememberAdaptiveInk(fg)+ val closeInk = rememberAdaptiveInk(fg)Row(Modifier.fillMaxWidth(),verticalAlignment = Alignment.CenterVertically,@@ -74,21 +80,21 @@ internal fun PdfSearchBar(hint = stringResource(R.string.viewer_find_hint),backdrop = backdrop,uiSensor = uiSensor,- modifier = Modifier.weight(1f),+ modifier = Modifier.weight(1f).then(pillInk.modifier),focusRequester = focusRequester,// The bar's own slide-up is the entrance; a spring-in on the pill would stack on it.animateIn = false,// Same material as the top bar's title pill, not Home's heavier app chrome.viewerChrome = true,surfaceColor = surface,- contentColor = fg,- hintColor = fgSoft,+ contentColor = pillInk.color,+ hintColor = pillInk.soft,// The match count belongs with the query it counts, not out beside the buttons.trailing = {if (matchCount > 0) {BasicText("${currentMatchIndex + 1}/$matchCount",- style = TextStyle(fgSoft, 11.sp, FontWeight.SemiBold)+ style = TextStyle(pillInk.soft, 11.sp, FontWeight.SemiBold))} else if (query.isNotBlank()) {BasicText(@@ -104,22 +110,22 @@ internal fun PdfSearchBar(LiquidIconButton(onClick = onPrevMatch,backdrop = backdrop,- modifier = Modifier.size(FindBarButtonSize)+ modifier = prevInk.modifier.size(FindBarButtonSize)) {- Icon(Icons.Rounded.KeyboardArrowUp, stringResource(R.string.previous), Modifier.size(20.dp), fg)+ Icon(Icons.Rounded.KeyboardArrowUp, stringResource(R.string.previous), Modifier.size(20.dp), prevInk.color)}LiquidIconButton(onClick = onNextMatch,backdrop = backdrop,- modifier = Modifier.size(FindBarButtonSize)+ modifier = nextInk.modifier.size(FindBarButtonSize)) {- Icon(Icons.Rounded.KeyboardArrowDown, stringResource(R.string.next), Modifier.size(20.dp), fg)+ Icon(Icons.Rounded.KeyboardArrowDown, stringResource(R.string.next), Modifier.size(20.dp), nextInk.color)}- val closeTint = if (fg.luminance() > 0.5f) Color(0xFFD78A92) else Color(0xFFA84D58)+ val closeTint = if (closeInk.color.luminance() > 0.5f) Color(0xFFD78A92) else Color(0xFFA84D58)LiquidIconButton(onClick = onClose,backdrop = backdrop,- modifier = Modifier.size(FindBarButtonSize),+ modifier = closeInk.modifier.size(FindBarButtonSize),surfaceColor = closeTint.copy(alpha = 0.12f)) {CloseCrossIcon(Modifier.size(13.dp), closeTint)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.ktindex 828d8a7..1b0fb64 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@@ -88,6 +88,7 @@ import androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport com.chethan616.clearpdf.Rimport com.chethan616.clearpdf.ui.theme.LiquidGlassColors+import com.chethan616.clearpdf.ui.components.rememberAdaptiveInkimport com.chethan616.clearpdf.ui.components.CloseCrossIconimport com.chethan616.clearpdf.ui.components.GlassMotionimport com.chethan616.clearpdf.ui.components.GlassGuideCallout@@ -737,6 +738,10 @@ internal fun PdfViewerBottomToolbar(}// ── Reader actions: editor, auto-scroll, speed, and ShareMorph share one bottom row.+ // Each control takes its own ink from what is behind it; the bar's [fg] is the fallback.+ val editorInk = rememberAdaptiveInk(fg)+ val autoScrollInk = rememberAdaptiveInk(fg)+ val speedInk = rememberAdaptiveInk(fg)AnimatedVisibility(// Same `selectorGate` as the tool chips above, so the controls fade out together// before the focused sub-toolbar arrives.@@ -757,25 +762,25 @@ internal fun PdfViewerBottomToolbar(if (!editorOpen) onSetActiveTool(PdfEditTool.None)},backdrop = backdrop,- modifier = Modifier.size(ReaderControlSize),+ modifier = editorInk.modifier.size(ReaderControlSize),tint = if (editorOpen) accent else Color.Unspecified,surfaceColor = if (!editorOpen && (readerTourStep == 0 || readerTourStep == 2)) LiquidGlassColors.Blue.copy(alpha = 0.22f) else Color.Unspecified) {- Icon(Icons.Rounded.Edit, stringResource(R.string.viewer_editor_tools), Modifier.size(20.dp), if (editorOpen) Color.White else fg)+ Icon(Icons.Rounded.Edit, stringResource(R.string.viewer_editor_tools), Modifier.size(20.dp), if (editorOpen) Color.White else editorInk.color)}}Box(Modifier.size(ReaderControlSize), contentAlignment = Alignment.Center) {LiquidIconButton(onClick = onToggleAutoScroll,backdrop = backdrop,- modifier = Modifier.size(ReaderControlSize),+ modifier = autoScrollInk.modifier.size(ReaderControlSize),tint = if (autoScrollActive) LiquidGlassColors.Green else Color.Unspecified) {Icon(if (autoScrollActive) Icons.Rounded.Pause else Icons.Rounded.PlayArrow,stringResource(if (autoScrollActive) R.string.viewer_auto_scroll_pause else R.string.viewer_auto_scroll_start),Modifier.size(20.dp),- if (autoScrollActive) Color.White else fg+ if (autoScrollActive) Color.White else autoScrollInk.color)}}@@ -788,12 +793,12 @@ internal fun PdfViewerBottomToolbar(LiquidButton(onClick = onCycleAutoScrollSpeed,backdrop = backdrop,- modifier = Modifier.widthIn(min = 72.dp),+ modifier = speedInk.modifier.widthIn(min = 72.dp),surfaceColor = Color.Transparent) {BasicText(text = "${autoScrollSpeed}×",- style = TextStyle(fg, 13.sp, FontWeight.SemiBold)+ style = TextStyle(speedInk.color, 13.sp, FontWeight.SemiBold))}}@@ -805,6 +810,7 @@ internal fun PdfViewerBottomToolbar(}// Every document format uses the same ShareMorph position and open/share actions.+ val shareInk = rememberAdaptiveInk(fg)AnimatedVisibility(visible = selectorGate && !showFindBar && !showSignaturePad,enter = fadeIn(tween(180)),@@ -815,7 +821,8 @@ internal fun PdfViewerBottomToolbar(size = ReaderControlSize,backdrop = backdrop,glass = if (readerTourStep == 1) LiquidGlassColors.Blue.copy(alpha = 0.2f) else pillGlass,- fg = fg,+ fg = shareInk.color,+ modifier = shareInk.modifier,onOpen = onOpenAnotherPdf,onShare = onShareDocument,onShareModeChanged = { shareActive = it; onShareHoldChanged(it) }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.ktindex d311dc5..c7c5500 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@@ -140,6 +140,7 @@ import com.chethan616.clearpdf.data.repository.AppSettingsManagerimport com.chethan616.clearpdf.data.repository.OnboardingManagerimport com.chethan616.clearpdf.data.repository.RecentFilesManagerimport com.chethan616.clearpdf.data.repository.PdfPageBookmarksManager+import com.chethan616.clearpdf.ui.components.rememberAdaptiveInkimport com.chethan616.clearpdf.ui.components.UnsavedChangesDialogimport com.chethan616.clearpdf.ui.components.GlassBottomSheetimport com.chethan616.clearpdf.ui.components.DecryptingAnimation@@ -1649,12 +1650,19 @@ fun PdfViewerScreen(horizontalArrangement = Arrangement.spacedBy(10.dp),modifier = Modifier.fillMaxWidth()) {+ // Each control picks its own ink from what is behind it (book mode's letterbox,+ // a page edge, a photo), with the bar's band reading as the fallback.+ val backInk = rememberAdaptiveInk(topFg)+ val pillInk = rememberAdaptiveInk(topFg)+ val findInk = rememberAdaptiveInk(topFg)+ val moonInk = rememberAdaptiveInk(topFg)// No `surfaceColor`, exactly as Home calls it: the circle paints nothing of its own// and is pure refraction. Only the icon's colour adapts to the page.GlassBackButton(onBack = { requestExit() },backdrop = contentBackdrop,- foreground = topFg,+ modifier = backInk.modifier,+ foreground = backInk.color,surfaceColor = Color.Unspecified,onLongPressBack = if (hasUnsavedEdits) ({ requestExit() }) else LocalBackToLibraryAction.current,longPressLabel = if (hasUnsavedEdits) stringResource(R.string.back) else null@@ -1666,6 +1674,7 @@ fun PdfViewerScreen(GlassTitlePill(text = stringResource(R.string.viewer_page_of, currentPageIndex + 1, safePageCount),backdrop = contentBackdrop,+ modifier = pillInk.modifier,onClick = { showPageJumpDialog = true },// Transparent, not omitted: omitting falls back to the theme's 0.35 tint,// and this pill sits between two circles that paint nothing at all, so any@@ -1673,7 +1682,7 @@ fun PdfViewerScreen(// `drawRect(Color.Transparent)` is the same no-op `LiquidIconButton`// performs when it is given no `surfaceColor`.surfaceColor = Color.Transparent,- contentColor = topFg,+ contentColor = pillInk.color,// The enclosing AnimatedVisibility already slides and fades the whole bar// in every time the chrome returns; the pill's own spring would stack on// top of that and read as a stutter. Same call the find bar makes.@@ -1686,19 +1695,21 @@ fun PdfViewerScreen(if (showFindBar) viewModel.triggerOcrForAllPages(context)else { focusManager.clearFocus(); viewModel.clearSearch(); findQuery = "" }},- backdrop = contentBackdrop+ backdrop = contentBackdrop,+ modifier = findInk.modifier) {- Icon(Icons.Rounded.Search, stringResource(R.string.viewer_find), Modifier.size(20.dp), topFg)+ Icon(Icons.Rounded.Search, stringResource(R.string.viewer_find), Modifier.size(20.dp), findInk.color)}LiquidIconButton(onClick = { darkPageOverride = !darkPageAppearance },- backdrop = contentBackdrop+ backdrop = contentBackdrop,+ modifier = moonInk.modifier) {Icon(if (darkPageAppearance) Icons.Rounded.LightMode else Icons.Rounded.DarkMode,stringResource(if (darkPageAppearance) R.string.viewer_page_colors_original else R.string.viewer_page_dark_mode),Modifier.size(20.dp),- topFg+ moonInk.color)}}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SpreadsheetViewerScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SpreadsheetViewerScreen.ktindex 0e8691b..6e6522e 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SpreadsheetViewerScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SpreadsheetViewerScreen.kt@@ -133,6 +133,7 @@ import androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport kotlin.math.roundToIntimport com.chethan616.clearpdf.R+import com.chethan616.clearpdf.ui.components.rememberAdaptiveInkimport com.chethan616.clearpdf.ui.components.GlassBottomSheetimport com.chethan616.clearpdf.ui.components.GlassGuideCalloutimport com.chethan616.clearpdf.ui.components.GlassBackButton@@ -489,6 +490,12 @@ private fun SpreadsheetViewerContent(contentHorizontalPadding = 12.dp,headerHorizontalPadding = 12.dp,header = { headerBackdrop ->+ // Each control takes its own ink from what is behind it; the sheet's ink is the fallback.+ val backInk = rememberAdaptiveInk(text)+ val titleInk = rememberAdaptiveInk(text)+ val findInk = rememberAdaptiveInk(text)+ val sheetInk = rememberAdaptiveInk(text)+ val editInk = rememberAdaptiveInk(text)Row(verticalAlignment = Alignment.CenterVertically,horizontalArrangement = Arrangement.spacedBy(10.dp),@@ -497,7 +504,8 @@ private fun SpreadsheetViewerContent(GlassBackButton(onBack = { requestBack() },backdrop = headerBackdrop,- foreground = text,+ modifier = backInk.modifier,+ foreground = backInk.color,onLongPressBack = if (state.dirty || editing) ({ requestBack() }) else LocalBackToLibraryAction.current,longPressLabel = if (state.dirty || editing) stringResource(R.string.back) else null)@@ -505,8 +513,10 @@ private fun SpreadsheetViewerContent(GlassTitlePill(text = (if (state.dirty) "• " else "") + state.fileName.ifBlank { stringResource(R.string.viewer_title) },backdrop = headerBackdrop,+ modifier = titleInk.modifier,// Clear like the header circles beside it (the PDF viewer's page pill too).- surfaceColor = Color.Transparent+ surfaceColor = Color.Transparent,+ contentColor = titleInk.color)}if (state.dirty && state.editable) {@@ -524,14 +534,14 @@ private fun SpreadsheetViewerContent(}}if (!editMode) {- LiquidIconButton(onClick = { showSearch = true }, backdrop = headerBackdrop) {- Icon(Icons.Rounded.Search, stringResource(R.string.viewer_find), Modifier.size(20.dp), text)+ LiquidIconButton(onClick = { showSearch = true }, backdrop = headerBackdrop, modifier = findInk.modifier) {+ Icon(Icons.Rounded.Search, stringResource(R.string.viewer_find), Modifier.size(20.dp), findInk.color)}- LiquidIconButton(onClick = onToggleSheet, backdrop = headerBackdrop) {+ LiquidIconButton(onClick = onToggleSheet, backdrop = headerBackdrop, modifier = sheetInk.modifier) {Icon(if (sheetDark) Icons.Rounded.LightMode else Icons.Rounded.DarkMode,stringResource(if (sheetDark) R.string.viewer_page_colors_original else R.string.viewer_page_dark_mode),- Modifier.size(19.dp), text+ Modifier.size(19.dp), sheetInk.color)}}@@ -542,10 +552,11 @@ private fun SpreadsheetViewerContent(else { editMode = true; showSearch = false }},backdrop = headerBackdrop,+ modifier = editInk.modifier,surfaceColor = if (editMode || showSpreadsheetTour) accent.copy(0.22f) else Color.Unspecified) {if (editMode) BasicText(stringResource(R.string.sheet_done), style = TextStyle(accent, 13.sp, FontWeight.SemiBold))- else Icon(Icons.Rounded.Edit, stringResource(R.string.sheet_edit), Modifier.size(19.dp), if (showSpreadsheetTour) accent else text)+ else Icon(Icons.Rounded.Edit, stringResource(R.string.sheet_edit), Modifier.size(19.dp), if (showSpreadsheetTour) accent else editInk.color)}}}@@ -726,6 +737,7 @@ private fun SpreadsheetViewerContent(// one control only needs to do the one thing its icon says. No long-press: it used to open// a PDF export, which surprised people tapping-and-holding by habit.if (sheet != null && !showSearch && !editMode) {+ val shareInk = rememberAdaptiveInk(text)LiquidIconButton(onClick = { viewModel.shareableUri(context) { u -> u?.let { shareFile(context, it) } } },backdrop = screenBackdrop.glass,@@ -735,8 +747,9 @@ private fun SpreadsheetViewerContent(// asks for (that's also why the old 52dp here rendered at a full 52dp, not 40dp --// visibly oversized next to the header's unmodified 40dp icon buttons).modifier = Modifier.align(Alignment.BottomEnd).navigationBarsPadding().padding(end = 12.dp, bottom = 10.dp).size(44.dp)+ .then(shareInk.modifier)) {- Icon(Icons.Rounded.IosShare, stringResource(R.string.viewer_share_document), Modifier.size(20.dp), text)+ Icon(Icons.Rounded.IosShare, stringResource(R.string.viewer_share_document), Modifier.size(20.dp), shareInk.color)}}