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.

Calmer, more legible glass (#158)

chethan61621433fc4c18a
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt
index 7a1dd15..f4a285d 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt
@@ -530,7 +530,7 @@ fun PdfField(
verticalAlignment = Alignment.CenterVertically,
) {
Box(Modifier.weight(1f).padding(vertical = 13.dp), contentAlignment = Alignment.CenterStart) {
- if (value.isEmpty()) Text(placeholder, style = ClearType.Body, color = if (error) Candy.Tomato else c.inkFaint)
+ if (value.isEmpty()) Text(placeholder, style = ClearType.Body, color = if (error) Candy.Tomato else c.inkSoft)
BasicTextField(
value = value, onValueChange = onValue, singleLine = true,
textStyle = ClearType.Body.copy(color = c.ink),
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/Common.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/Common.kt
index b158ccf..90ce971 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/Common.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/Common.kt
@@ -233,7 +233,7 @@ fun FileListItem(vm: AppViewModel, r: FileRow, recent: Boolean, modifier: Modifi
PaperThumb(vm, r.thumbPath, 40.dp, 52.dp, corner = 6.dp, name = r.name)
Spacer(Modifier.width(14.dp))
Column(Modifier.weight(1f)) {
- Text(displayName(r.name), style = ClearType.BodyStrong, color = c.ink, maxLines = 2, overflow = TextOverflow.Ellipsis)
+ Text(displayName(r.name), style = ClearType.BodyStrong.copy(fontSize = 16.sp, lineHeight = 21.sp), color = c.ink, maxLines = 2, overflow = TextOverflow.Ellipsis)
Spacer(Modifier.height(2.dp))
Text(
listOfNotNull(whenLabel(r.date), r.size.takeIf { it > 0 }?.let { formatSize(it) }).joinToString(" · "),
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/FilesScreen.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/FilesScreen.kt
index dc88da3..b671d68 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/FilesScreen.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/FilesScreen.kt
@@ -61,7 +61,9 @@ import com.chethan616.clearpdf.ui.glass.GlassPill
import com.chethan616.clearpdf.ui.glass.GlassRow
import com.chethan616.clearpdf.ui.glass.GlassTab
import com.chethan616.clearpdf.ui.glass.GlassTabs
-import com.chethan616.clearpdf.ui.glass.WashPanel
+import com.chethan616.clearpdf.ui.glass.GlassListPanel
+import com.chethan616.clearpdf.ui.glass.glassDim
+import com.chethan616.clearpdf.ui.theme.glowing
import com.chethan616.clearpdf.ui.glass.glass
import com.chethan616.clearpdf.ui.glass.pressable
import com.chethan616.clearpdf.ui.home.FileRow
@@ -246,8 +248,12 @@ private fun LazyListScope.panels(vm: AppViewModel, key: String, title: String?,
if (title != null) {
item(key = "t-$key") {
Row(Modifier.fillMaxWidth().padding(start = 24.dp, end = 24.dp, top = 22.dp, bottom = 8.dp), verticalAlignment = Alignment.Bottom) {
- Text(title, style = ClearType.Title, color = clear.ink, modifier = Modifier.weight(1f))
- Text(rows.size.toString(), style = ClearType.Number, color = if (vm.cleanAppearance) clear.ink else clear.inkFaint)
+ // straight on the wallpaper: the theme's ink, with the hero titles' glow under it so it
+ // reads over a picture too; the count is a figure to read, in full ink (#158)
+ val c = clear
+ val glow = !vm.cleanAppearance
+ Text(title, style = if (glow) ClearType.Title.glowing(c) else ClearType.Title, color = c.ink, modifier = Modifier.weight(1f))
+ Text(rows.size.toString(), style = if (glow) ClearType.Number.glowing(c) else ClearType.Number, color = c.ink)
}
}
} else {
@@ -255,10 +261,11 @@ private fun LazyListScope.panels(vm: AppViewModel, key: String, title: String?,
}
rows.chunked(PanelRows).forEachIndexed { i, chunk ->
item(key = "p-$key-$i") {
- WashPanel(Modifier.padding(horizontal = 16.dp, vertical = 4.dp).fillMaxWidth()) {
+ GlassListPanel(Modifier.padding(horizontal = 16.dp, vertical = 4.dp).fillMaxWidth()) {
Spacer(Modifier.height(4.dp))
chunk.forEachIndexed { index, r ->
- if (vm.cleanAppearance && index > 0) HorizontalDivider(Modifier.padding(horizontal = 14.dp), color = clear.line)
+ // a hairline between rows, from the name on (past the thumbnail)
+ if (index > 0) HorizontalDivider(Modifier.padding(start = if (vm.cleanAppearance) 14.dp else 68.dp, end = 14.dp), color = clear.line)
FileListItem(vm, r, recent)
}
Spacer(Modifier.height(4.dp))
@@ -274,19 +281,21 @@ private fun SearchCapsule(query: String, onQuery: (String) -> Unit, clean: Boole
val hint = stringResource(R.string.home_search_your_files)
Row(
Modifier.padding(horizontal = 16.dp, vertical = 10.dp).fillMaxWidth().height(52.dp)
- .then(if (clean) Modifier.background(c.solidPanel, Capsule) else Modifier.glass(Capsule, blur = 4.dp))
+ // the same liquid glass as the list below it, frosted and dimmed so the words read (#158)
+ .then(if (clean) Modifier.background(c.solidPanel, Capsule) else Modifier.glass(Capsule, blur = 10.dp, dim = glassDim()))
.padding(start = 18.dp, end = 6.dp),
verticalAlignment = Alignment.CenterVertically,
) {
- Icon(LucideIcons.Search, null, tint = c.inkSoft, modifier = Modifier.size(20.dp))
+ Icon(LucideIcons.Search, null, tint = c.ink.copy(alpha = 0.85f), modifier = Modifier.size(20.dp))
Spacer(Modifier.width(12.dp))
BasicTextField(
value = query, onValueChange = onQuery, singleLine = true,
- textStyle = ClearType.Body.copy(color = c.ink), cursorBrush = SolidColor(Candy.Tomato),
+ textStyle = ClearType.Body.copy(color = c.ink, fontWeight = androidx.compose.ui.text.font.FontWeight.Medium), cursorBrush = SolidColor(Candy.Tomato),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
keyboardActions = KeyboardActions(onSearch = { onSearch() }),
modifier = Modifier.weight(1f),
- decorationBox = { inner -> Box { if (query.isEmpty()) Text(hint, style = ClearType.Body, color = if (clean) c.inkSoft else c.inkFaint); inner() } },
+ // the hint near the ink and semibold, not a grey that the wallpaper swallows
+ decorationBox = { inner -> Box { if (query.isEmpty()) Text(hint, style = ClearType.BodyStrong, color = if (clean) c.inkSoft else c.ink.copy(alpha = 0.80f)); inner() } },
)
if (query.isNotEmpty()) {
Box(Modifier.size(40.dp).pressable({ onQuery("") }), contentAlignment = Alignment.Center) {
@@ -315,8 +324,8 @@ private fun SelectionHeader(vm: AppViewModel, recent: Boolean, onDelete: () -> U
@Composable
private fun Places(vm: AppViewModel, onBrowse: () -> Unit, onDevice: () -> Unit) {
Column {
- Text(stringResource(R.string.files_places), style = ClearType.Title, color = clear.ink, modifier = Modifier.padding(start = 24.dp, top = 26.dp, bottom = 8.dp))
- WashPanel(Modifier.padding(horizontal = 16.dp).fillMaxWidth()) {
+ Text(stringResource(R.string.files_places), style = if (vm.cleanAppearance) ClearType.Title else ClearType.Title.glowing(clear), color = clear.ink, modifier = Modifier.padding(start = 24.dp, top = 26.dp, bottom = 8.dp))
+ GlassListPanel(Modifier.padding(horizontal = 16.dp).fillMaxWidth()) {
Spacer(Modifier.height(4.dp))
PlaceRow(LucideIcons.Smartphone, stringResource(R.string.home_on_this_device), Candy.Sky, onDevice)
PlaceRow(LucideIcons.Images, stringResource(R.string.home_photos), Candy.Lemon) { vm.pickPhotosToPdf() }
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/SettingsScreen.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/SettingsScreen.kt
index 61e0c96..bd0b35c 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/SettingsScreen.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/SettingsScreen.kt
@@ -156,6 +156,10 @@ private fun SettingsRoot(vm: AppViewModel, openLicences: () -> Unit, openGlass:
Panel {
ThemePicker(vm.theme) { vm.setThemeChoice(it) }
AppearancePicker(vm.cleanAppearance, vm::updateCleanAppearance)
+ if (vm.cleanAppearance) ToggleRow(
+ LucideIcons.Contrast, Candy.Sky, stringResource(R.string.settings_reduce_transparency),
+ stringResource(R.string.settings_reduce_transparency_detail), GlassSettings.reduceTransparency,
+ ) { GlassSettings.updateReduceTransparency(context, it) }
SettingRow(LucideIcons.Globe, Candy.Sky, stringResource(R.string.settings_language), openAppLanguage, value = appLanguage, chevron = true)
SettingRow(LucideIcons.Sparkles, Candy.Grape, stringResource(R.string.settings_glass_motion), openGlass, value = "$glassName · $motionName", chevron = true)
ToggleRow(LucideIcons.Smartphone, Candy.Bubblegum, stringResource(R.string.settings_haptics), null, GlassSettings.haptics) { GlassSettings.updateHaptics(context, it) }
@@ -368,7 +372,7 @@ private fun AppFooter(vm: AppViewModel) {
Spacer(Modifier.height(14.dp))
Text(stringResource(R.string.settings_credits_body), style = ClearType.Caption, color = c.inkSoft, textAlign = androidx.compose.ui.text.style.TextAlign.Center)
Spacer(Modifier.height(8.dp))
- Text(stringResource(R.string.home_legal_notice), style = ClearType.Caption, color = c.inkFaint, textAlign = androidx.compose.ui.text.style.TextAlign.Center)
+ Text(stringResource(R.string.home_legal_notice), style = ClearType.Caption, color = c.inkSoft, textAlign = androidx.compose.ui.text.style.TextAlign.Center)
}
}
@@ -714,14 +718,14 @@ private fun LicencesPage(onBack: () -> Unit) {
Icon(LucideIcons.ArrowUpRight, stringResource(R.string.licences_source, k.name), tint = c.inkSoft, modifier = Modifier.size(18.dp))
}
}
- Text(k.terms, style = ClearType.Caption.copy(fontSize = 11.5.sp), color = c.inkFaint, modifier = Modifier.padding(top = 2.dp))
+ Text(k.terms, style = ClearType.Caption, color = c.inkSoft, modifier = Modifier.padding(top = 2.dp))
if (expanded) {
val text = remember(k.text) {
k.text?.let { f -> runCatching { context.assets.open("licences/$f").bufferedReader().readText() }.getOrNull() }
}
Text(
text ?: stringResource(R.string.licences_text_at_source),
- style = ClearType.Caption.copy(fontSize = 11.sp, lineHeight = 15.sp), color = c.inkSoft,
+ style = ClearType.Caption, color = c.inkSoft,
modifier = Modifier.padding(top = 10.dp),
)
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/AdaptiveGlass.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/AdaptiveGlass.kt
index a07bd45..2dd013f 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/AdaptiveGlass.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/AdaptiveGlass.kt
@@ -14,11 +14,13 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asAndroidBitmap
+import androidx.compose.ui.graphics.drawOutline
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.drawscope.scale
import androidx.compose.ui.graphics.layer.GraphicsLayer
import androidx.compose.ui.graphics.rememberGraphicsLayer
import androidx.compose.ui.unit.IntSize
+import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.lerp
import com.chethan616.clearpdf.ui.theme.clear
import com.kyant.backdrop.BackdropEffectScope
@@ -27,6 +29,7 @@ import com.kyant.backdrop.effects.colorControls
import com.kyant.backdrop.effects.lens
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlin.math.sign
@@ -46,10 +49,21 @@ import kotlin.math.sign
class GlassLuminance internal constructor(initial: Float, internal val layer: GraphicsLayer) {
private val anim = Animatable(initial)
private var recorded = false
+ // how many times the backdrop has been recorded; the reading skips a record it has already read
+ @Volatile private var records = 0
/** 0 (black behind) … 1 (white behind). Read while drawing. */
val value: Float get() = anim.value
+ private val busyAnim = Animatable(0f)
+
+ /**
+ * 0 (calm: the wallpaper, an empty page) … 1 (busy: lines of text, a photo) behind the glass. Read
+ * while drawing: a busy backdrop takes a thicker wash and frost, so what is behind does not ghost
+ * through the words on the glass (#158), while a calm one stays as clear as it was.
+ */
+ val busy: Float get() = busyAnim.value
+
/** Whether the glass sits over something light, so its ink should be dark. */
var onLight by mutableStateOf(initial > 0.5f)
private set
@@ -67,35 +81,41 @@ class GlassLuminance internal constructor(initial: Float, internal val layer: Gr
scale(1f / DOWN, 1f / DOWN, pivot = Offset.Zero) { drawBackdrop() }
}
recorded = true
+ records++
}
- internal suspend fun run() {
+ internal suspend fun run() = kotlinx.coroutines.coroutineScope {
val px = IntArray(SAMPLES * SAMPLES)
var waited = 0
+ var read = -1
while (true) {
+ // nothing new drawn behind it since the last reading (a still page, the app in the
+ // background): nothing to read again, so no bitmap copy every 220 ms for nothing (#158)
+ if (measured && records == read) {
+ delay(SAMPLE_INTERVAL_MS)
+ continue
+ }
if (!recorded) {
// nothing drawn to read yet: don't hold the surface back for ever
if (!measured && ++waited > 12) measured = true
delay(16)
continue
}
- val lum = withContext(Dispatchers.Default) {
+ read = records
+ val stats = withContext(Dispatchers.Default) {
runCatching {
val full = layer.toImageBitmap().asAndroidBitmap()
// a hardware bitmap can't be read: a small software copy can
val small = Bitmap.createScaledBitmap(full, SAMPLES, SAMPLES, true).copy(Bitmap.Config.ARGB_8888, false)
small.getPixels(px, 0, SAMPLES, 0, 0, SAMPLES, SAMPLES)
- var sum = 0.0
- var n = 0
- for (c in px) {
- // what was not drawn (outside every layer) says nothing
- if ((c ushr 24) < 8) continue
- sum += (0.2126 * ((c shr 16) and 0xFF) + 0.7152 * ((c shr 8) and 0xFF) + 0.0722 * (c and 0xFF)) / 255.0
- n++
- }
- if (n == 0) null else (sum / n).toFloat()
+ backdropStats(px, SAMPLES)
}.getOrNull()
}
+ val lum = stats?.luminance
+ if (stats != null && kotlin.math.abs(stats.busy - busyAnim.targetValue) > 0.15f) {
+ // eased beside the luminance, not before it: neither waits for the other
+ if (!measured) busyAnim.snapTo(stats.busy) else launch { busyAnim.animateTo(stats.busy, tween(420)) }
+ }
if (lum == null && !measured && ++waited > 12) measured = true
if (lum != null) {
onLight = when {
@@ -122,11 +142,49 @@ class GlassLuminance internal constructor(initial: Float, internal val layer: Gr
private companion object {
const val DOWN = 8f
- const val SAMPLES = 6
+ // enough cells to tell lines of text from an even wash; the mean is the same as at 6 x 6
+ const val SAMPLES = 12
const val SAMPLE_INTERVAL_MS = 220L
}
}
+/** What one reading found behind a glass: how light it is, and how busy ([GlassLuminance.busy]). */
+internal class BackdropStats(val luminance: Float, val busy: Float)
+
+/**
+ * The mean luminance of [px] (a [side] x [side] sample) and how busy it is. Busy is the mean step
+ * between neighbouring cells, not the spread of the whole: a smooth gradient (the aurora) has a wide
+ * spread but tiny steps, lines of print or a photo have big ones. Cells nothing was drawn in say nothing.
+ */
+internal fun backdropStats(px: IntArray, side: Int): BackdropStats? {
+ fun drawn(c: Int) = (c ushr 24) >= 8
+ fun lum(c: Int) = (0.2126 * ((c shr 16) and 0xFF) + 0.7152 * ((c shr 8) and 0xFF) + 0.0722 * (c and 0xFF)) / 255.0
+ var sum = 0.0
+ var n = 0
+ var step = 0.0
+ var pairs = 0
+ for (y in 0 until side) for (x in 0 until side) {
+ val c = px[y * side + x]
+ if (!drawn(c)) continue
+ val l = lum(c)
+ sum += l
+ n++
+ if (x + 1 < side) px[y * side + x + 1].let { if (drawn(it)) { step += kotlin.math.abs(lum(it) - l); pairs++ } }
+ if (y + 1 < side) px[(y + 1) * side + x].let { if (drawn(it)) { step += kotlin.math.abs(lum(it) - l); pairs++ } }
+ }
+ if (n == 0) return null
+ val texture = if (pairs == 0) 0.0 else step / pairs
+ return BackdropStats((sum / n).toFloat(), ((texture - BusyFrom) / (BusyTo - BusyFrom)).toFloat().coerceIn(0f, 1f))
+}
+
+
+/**
+ * The neighbour step at which a backdrop starts to count as busy, and where it is fully so. Measured on
+ * a phone: a page of print behind a menu steps 0.14-0.18, the desk (title, chips, card edges) 0.06-0.10.
+ */
+private const val BusyFrom = 0.03
+private const val BusyTo = 0.14
+
/**
* A luminance reading for one glass surface, or null when [enabled] is false. Pass it to [glass] (or
* [GlassCard]) and take the ink from [adaptiveInk].
@@ -173,6 +231,7 @@ fun BackdropEffectScope.adaptiveGlassEffects(
blurPx: Float,
refractionHeightPx: Float,
refractionAmountPx: Float,
+ busy: Float = 0f,
) {
val l = signed(luminance.coerceIn(0f, 1f))
colorControls(
@@ -180,7 +239,7 @@ fun BackdropEffectScope.adaptiveGlassEffects(
contrast = if (l > 0f) lerp(1f, 0.25f, l) else 1f,
saturation = style.saturation,
)
- blur(blurPx * style.blur * (if (l > 0f) lerp(1f, 1.5f, l) else lerp(1f, 0.6f, -l)))
+ blur(blurPx * style.blur * (if (l > 0f) lerp(1f, 1.5f, l) else lerp(1f, 0.6f, -l)) * (1f + 0.6f * busy.coerceIn(0f, 1f)))
lens(
refractionHeightPx * style.refractionHeight,
refractionAmountPx * style.refractionAmount,
@@ -196,8 +255,42 @@ fun BackdropEffectScope.adaptiveGlassEffects(
*/
val GlassStyle.adaptiveBase: GlassStyle get() = copy(blur = 1f, saturation = 1.5f, brightness = 0f, tint = 1f)
-/** The thin wash over adaptive glass: milk over light, smoke over dark. */
-fun adaptiveWash(luminance: Float): Color {
+/**
+ * The thin wash over adaptive glass: milk over light, smoke over dark. Over a [busy] backdrop (a page
+ * of print) it thickens, so the print does not show through as ghost text behind the glass's own words.
+ */
+fun adaptiveWash(luminance: Float, busy: Float = 0f): Color {
val l = signed(luminance.coerceIn(0f, 1f))
- return if (l >= 0f) Color.White.copy(alpha = lerp(0.10f, 0.30f, l)) else Color.Black.copy(alpha = lerp(0.10f, 0.34f, -l))
+ val b = busy.coerceIn(0f, 1f)
+ return if (l >= 0f) Color.White.copy(alpha = lerp(lerp(0.10f, 0.30f, l), 0.68f, b))
+ else Color.Black.copy(alpha = lerp(lerp(0.10f, 0.34f, -l), 0.60f, b))
+}
+
+/**
+ * A dark hairline for glass over something near-white (a page): its white rim light vanishes there, so
+ * without one a light menu or bar has no edge at all on a white page (#158). None over anything darker.
+ */
+fun lightEdge(luminance: Float): Color {
+ // measured on a phone: a menu over a white page with the viewer's dark header band above reads
+ // about 0.7, so the hairline starts at 0.6 and is full from 0.85
+ val a = ((luminance - 0.6f) / 0.25f).coerceIn(0f, 1f) * 0.14f
+ return if (a <= 0.005f) Color.Unspecified else Color.Black.copy(alpha = a)
+}
+
+/**
+ * How much an open menu dims the page around it ([open] 0 … 1): over a light page a little (at most 16%
+ * black), so the white menu stands off a white page; over anything darker not at all (#158).
+ */
+fun menuScrimAlpha(luminance: Float, open: Float): Float =
+ 0.16f * open.coerceIn(0f, 1f) * ((luminance - 0.5f) / 0.25f).coerceIn(0f, 1f)
+
+/** The tallest a menu grows: its own most, or 72% of the screen, so its last row is never off-screen. */
+@Composable
+fun menuMaxHeight(designed: androidx.compose.ui.unit.Dp): androidx.compose.ui.unit.Dp =
+ minOf(designed, (androidx.compose.ui.platform.LocalConfiguration.current.screenHeightDp * 0.72f).dp)
+
+/** Draws [edge] (from [lightEdge]) along [shape]'s outline, about a dp of it showing inside. */
+fun androidx.compose.ui.graphics.drawscope.DrawScope.drawGlassEdge(shape: androidx.compose.ui.graphics.Shape, edge: Color) {
+ if (edge == Color.Unspecified || edge.alpha <= 0f) return
+ drawOutline(shape.createOutline(size, layoutDirection, this), edge, style = androidx.compose.ui.graphics.drawscope.Stroke(2.dp.toPx()))
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/AdaptiveInk.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/AdaptiveInk.kt
index 45d5a00..3b2ebea 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/AdaptiveInk.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/AdaptiveInk.kt
@@ -239,8 +239,11 @@ fun rememberSurroundLuminance(): SurroundLuminance? {
return state
}
-/** One control's ink: put [modifier] on the control (first, so it measures the resting box). */
-class InkProbe(val modifier: Modifier, val color: Color) {
+/**
+ * One control's ink: put [modifier] on the control (first, so it measures the resting box). [edge] is
+ * the hairline its glass takes over a near-white page, where its white rim light alone leaves no edge.
+ */
+class InkProbe(val modifier: Modifier, val color: Color, val edge: Color = Color.Unspecified) {
val soft: Color get() = color.copy(alpha = 0.62f)
}
@@ -258,6 +261,8 @@ fun rememberAdaptiveInk(fallback: Color): InkProbe {
val fallbackOnLight = fallback.luminance() < 0.5f
var onLight by remember { mutableStateOf(fallbackOnLight) }
var measured by remember { mutableStateOf(false) }
+ // over a page (near white), not merely over light: the light theme's aurora stays edgeless
+ var onPage by remember { mutableStateOf(false) }
val box = remember { arrayOfNulls<Rect>(1) }
val currentFallback by rememberUpdatedState(fallbackOnLight)
val inset = with(LocalDensity.current) { 5.dp.toPx() }
@@ -281,6 +286,7 @@ fun rememberAdaptiveInk(fallback: Color): InkProbe {
lum < 0.58f -> false
else -> onLight
}
+ onPage = if (onPage) lum > 0.86f else lum > 0.92f
measured = true
}
}
@@ -292,8 +298,9 @@ fun rememberAdaptiveInk(fallback: Color): InkProbe {
else -> Color.White
}
val color by animateColorAsState(target, tween(200), label = "adaptiveInk")
+ val edgeAlpha by androidx.compose.animation.core.animateFloatAsState(if (sampler != null && measured && onPage) 0.14f else 0f, tween(200), label = "adaptiveEdge")
val modifier = remember { Modifier.onGloballyPositioned { box[0] = it.boundsInWindow() } }
- return InkProbe(modifier, color)
+ return InkProbe(modifier, color, if (edgeAlpha > 0.005f) Color.Black.copy(alpha = edgeAlpha) else Color.Unspecified)
}
private tailrec fun Context.findActivity(): Activity? = when (this) {
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Buttons.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Buttons.kt
index abd43f9..7a2c9f2 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Buttons.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Buttons.kt
@@ -80,6 +80,8 @@ private fun Modifier.glassControl(
adaptWash: Boolean = true,
/** Told the control's surround reading (the morph that grows out of a round button carries it on). */
aroundOut: ((SurroundLuminance?) -> Unit)? = null,
+ /** A hairline round it ([InkProbe.edge]), read while drawing. */
+ edge: () -> Color = { Color.Unspecified },
): Modifier {
val backdrop = LocalBackdrop.current
if (clear.clean) {
@@ -151,8 +153,10 @@ private fun Modifier.glassControl(
// read here, while drawing, so a colour animating in changes pixels and recomposes nothing
val f = fill?.invoke()
if (f != null && f.alpha > 0f) drawRect(f)
+ drawGlassEdge(shape, edge())
},
)
+ .focusRing(source, corner = 100.dp)
.combinedClickable(
interactionSource = source,
indication = null,
@@ -198,7 +202,7 @@ fun rememberBeat(action: () -> Unit, millis: Long = BackBeatMillis): () -> Unit
* (Settings ▸ liquid glass), so it shows what's under it, the page in the viewer.
*/
@Composable
-fun Modifier.glassBar(shape: Shape = ChromeCapsule, surface: Color = Color.Unspecified, blur: Dp = 2.dp): Modifier {
+fun Modifier.glassBar(shape: Shape = ChromeCapsule, surface: Color = Color.Unspecified, blur: Dp = 2.dp, edge: Color = Color.Unspecified): Modifier {
if (clear.clean) {
val panel = clear.solidPanel
return clip(shape).background(if (surface.isSpecified) surface.compositeOver(panel) else panel)
@@ -207,7 +211,9 @@ fun Modifier.glassBar(shape: Shape = ChromeCapsule, surface: Color = Color.Unspe
val scope = rememberCoroutineScope()
val highlight = remember(scope) { InteractiveHighlight(scope) }
val around = rememberSurroundLuminance()
+ // the user's own glass (Settings ▸ Liquid glass), as every other surface wears it
val style = if (around != null) GlassSettings.style.adaptiveBase else GlassSettings.style
+ val currentEdge by rememberUpdatedState(edge)
return this
.then(around?.modifier ?: Modifier)
.drawBackdrop(
@@ -223,6 +229,7 @@ fun Modifier.glassBar(shape: Shape = ChromeCapsule, surface: Color = Color.Unspe
onDrawSurface = {
if (around != null) drawRect(adaptiveWash(around.value).let { it.copy(alpha = it.alpha * 0.7f) })
if (surface.isSpecified) drawRect(surface.glassTint(style))
+ drawGlassEdge(shape, currentEdge)
},
)
.then(highlight.modifier)
@@ -253,7 +260,7 @@ fun GlassPill(
Row(
modifier
.then(probe.modifier)
- .glassControl(ChromeCapsule, onClick, onLongClick, tint, if (tintAt != null) Color.Unspecified else surface, blur, label, tap = tap, bloom = true, tintAt = tintAt)
+ .glassControl(ChromeCapsule, onClick, onLongClick, tint, if (tintAt != null) Color.Unspecified else surface, blur, label, tap = tap, bloom = true, tintAt = tintAt, edge = { probe.edge })
.height(height)
.padding(horizontal = horizontalPadding),
horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),
@@ -307,6 +314,9 @@ fun GlassChip(
*/
val ChromeCapsule = com.kyant.shapes.Capsule
+/** The least a finger should have to hit (Material and WCAG: 48 dp), whatever the glyph's size. */
+val MinTouch = 48.dp
+
/** The old app's header circle: 40 dp of natural glass (no wash), so every header reads the same. */
val HeaderButtonSize = 40.dp
@@ -364,6 +374,8 @@ fun GlassCircle(
label: String? = null,
ink: Color = Color.Unspecified,
tap: Feel? = Feel.Tap,
+ /** [tint] painted solid over the glass instead of blended into it, so a white glyph keeps its contrast over a white page. */
+ solid: Boolean = false,
content: @Composable () -> Unit,
) {
// over a document the glyph takes dark or white ink from the page around it, as the old app's
@@ -390,7 +402,7 @@ fun GlassCircle(
// stepped aside while its glass is a menu: not drawn at all (a layer's alpha alone left it in
// the copy of the screen the menu's glass bends, where the lens smeared its glyph)
.drawWithContent { if (at?.let { MorphAnchors.hides(it) } != true) drawContent() }
- .size(size).glassControl(CircleShape, onClick, onLongClick, tint, surface, 2.dp, label, tap = tap, bloom = true, candyBase = false, aroundOut = { around[0] = it }),
+ .size(size).glassControl(CircleShape, onClick, onLongClick, tint, surface, 2.dp, label, fill = if (solid && tint.isSpecified) ({ tint }) else null, tap = tap, bloom = true, candyBase = false, aroundOut = { around[0] = it }, edge = { probe.edge }),
contentAlignment = Alignment.Center,
) { content() }
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/LiquidMorph.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/LiquidMorph.kt
index c05cfe1..1786c9f 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/LiquidMorph.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/LiquidMorph.kt
@@ -38,6 +38,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.isSpecified
+import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ShaderBrush
import androidx.compose.ui.graphics.graphicsLayer
@@ -360,6 +361,10 @@ internal fun LiquidMorphSurface(
fun washIn() = ((p.value - 0.08f) / 0.4f).coerceIn(0f, 1f)
// the luminance reading copies the backdrop: every few frames is plenty (its ink eases anyway)
val frame = remember { intArrayOf(0) }
+ // a breath of dim on the page around the open menu, over a light page only
+ if (luminance != null) androidx.compose.foundation.layout.Box(
+ Modifier.fillMaxSize().drawBehind { drawRect(Color.Black, alpha = menuScrimAlpha(luminance.value, washIn()) * fade.value) },
+ )
fun RuntimeShader.shapeUniforms(g: Geo) {
setFloatUniform("circle", local.center.x - stage.left, local.center.y - stage.top, g.circleR, 0f)
@@ -381,7 +386,7 @@ internal fun LiquidMorphSurface(
// adaptive blur: the button's clear glass frosts to a menu's as it opens, so rows read
// over a busy page (as MenuCard's), more over a bright page than a dark one, and a
// touch more while the glass is on the move
- morphEffects(if (adaptiveOn) style.adaptiveBase else style, luminance?.value ?: if (dark) 0.14f else 0.86f, dark, washIn(), g.motion, px(1.dp), if (adaptiveOn) aroundLum() else null)
+ morphEffects(if (adaptiveOn) style.adaptiveBase else style, luminance?.value ?: if (dark) 0.14f else 0.86f, dark, washIn(), g.motion, px(1.dp), if (adaptiveOn) aroundLum() else null, luminance?.busy ?: 0f)
runtimeShaderEffect("LiquidMorphRefraction", LiquidRefractionShader, "content") {
setFloatUniform("offset", -padding, -padding)
// the button's own lens (12 / 24 dp at the user's style), a little livelier while it moves
@@ -403,7 +408,9 @@ internal fun LiquidMorphSurface(
val w = washIn()
val lum = luminance?.value ?: if (dark) 0.14f else 0.86f
// the milk or smoke a menu wears, thicker than a button's, so its rows read
- val menuWash = adaptiveWash(lum).let { it.copy(alpha = (it.alpha * 1.7f).coerceAtMost(0.55f)) }.glassTint(style)
+ // and thicker again over a page of print, so it never shows through as ghost text
+ val busyAlpha = adaptiveWash(lum, luminance?.busy ?: 0f).alpha
+ val menuWash = adaptiveWash(lum).let { it.copy(alpha = maxOf((it.alpha * 1.7f).coerceAtMost(0.55f), busyAlpha)) }.glassTint(style)
val plain = menuWash.let { it.copy(alpha = it.alpha * w) }
val wash = when {
tint.isSpecified -> androidx.compose.ui.graphics.lerp(tint.copy(alpha = 0.75f), plain, w)
@@ -415,6 +422,15 @@ internal fun LiquidMorphSurface(
surface.setFloatUniform("rimAlpha", rimAlpha)
surface.shapeUniforms(g)
drawRect(ShaderBrush(surface))
+ // a dark hairline round the opened menu over a white page, where its rim light is lost
+ val edge = lightEdge(lum)
+ if (edge != Color.Unspecified && w > 0f) drawRoundRect(
+ edge.copy(alpha = edge.alpha * w),
+ topLeft = androidx.compose.ui.geometry.Offset(g.menu.left - stage.left, g.menu.top - stage.top),
+ size = g.menu.size,
+ cornerRadius = androidx.compose.ui.geometry.CornerRadius(g.radius),
+ style = androidx.compose.ui.graphics.drawscope.Stroke(px(1.dp)),
+ )
},
),
)
@@ -484,7 +500,7 @@ internal fun LiquidMorphSurface(
.onSizeChanged { full = it.height }
.graphicsLayer { alpha = ((p.value - 0.55f) / 0.35f).coerceIn(0f, 1f) },
) {
- Column(Modifier.heightIn(max = maxHeight).verticalScroll(rememberScrollState())) {
+ Column(Modifier.heightIn(max = maxHeight).fadingVerticalScroll()) {
Spacer(Modifier.height(6.dp))
body(shut) { action -> if (chosenAction == null) { chosenAction = action; onDismiss() } }
Spacer(Modifier.height(6.dp))
@@ -520,7 +536,7 @@ private fun signedLum(luminance: Float): Float = (luminance * 2f - 1f).let { kot
* deeper over a dark one, as [MenuCard] with Adaptive luminance). [motion] adds a little frost while
* the glass moves, so it reads as liquid rushing rather than a sharp shape sliding. [dp] is one dp.
*/
-private fun com.kyant.backdrop.BackdropEffectScope.morphEffects(style: GlassStyle, luminance: Float, dark: Boolean, open: Float, motion: Float, dp: Float, buttonLuminance: Float? = null) {
+private fun com.kyant.backdrop.BackdropEffectScope.morphEffects(style: GlassStyle, luminance: Float, dark: Boolean, open: Float, motion: Float, dp: Float, buttonLuminance: Float? = null, busy: Float = 0f) {
val l = signedLum(luminance.coerceIn(0f, 1f))
val o = open.coerceIn(0f, 1f)
val menuBrightness = if (l > 0f) lerp(0.08f, 0.3f, l) else lerp(if (dark) -0.12f else 0.04f, -0.24f, -l)
@@ -535,6 +551,6 @@ private fun com.kyant.backdrop.BackdropEffectScope.morphEffects(style: GlassStyl
saturation = lerp(style.saturation, 1.25f, o),
)
val buttonBlur = 2f * dp * style.blur * (if (b == null) 1f else if (b > 0f) lerp(1f, 1.5f, b) else lerp(1f, 0.6f, -b))
- val menuBlur = 22f * dp * (if (l > 0f) lerp(1f, 1.35f, l) else lerp(1f, 0.75f, -l))
+ val menuBlur = 22f * dp * (if (l > 0f) lerp(1f, 1.35f, l) else lerp(1f, 0.75f, -l)) * (1f + 0.4f * busy.coerceIn(0f, 1f))
blur(lerp(buttonBlur, menuBlur, o) + 5f * dp * motion.coerceIn(0f, 1f))
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/MorphButton.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/MorphButton.kt
index f122486..0159009 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/MorphButton.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/MorphButton.kt
@@ -40,6 +40,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Rect
+import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.isSpecified
import androidx.compose.ui.graphics.graphicsLayer
@@ -150,6 +151,7 @@ fun MorphButtonSurface(
onGone()
}
val glyph: @Composable () -> Unit = icon ?: MorphAnchors.glyphAt(anchor) ?: {}
+ val maxHeight = menuMaxHeight(maxHeight)
// Android 13+: the liquid version (the glass shaders it needs); before that the plain expansion
if (!com.chethan616.clearpdf.ui.theme.clear.clean && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
LiquidMorphSurface(anchor, open, onDismiss, gone, menuWidth, maxHeight, glyph, ghost, body)
@@ -319,6 +321,8 @@ private fun RectMorphSurface(
// black pages, a white document, the aurora): the glyph and rows always stand out
val luminance = rememberGlassLuminance(enabled = true)
val inkColor = adaptiveInk(luminance, clear.ink)
+ // a breath of dim on the page around the open menu, over a light page only
+ if (luminance != null) Box(Modifier.fillMaxSize().drawBehind { drawRect(Color.Black, alpha = menuScrimAlpha(luminance.value, tall.value) * fade.value) })
Layout(
content = {
CompositionLocalProvider(LocalGlassInk provides inkColor, LocalMenuInk provides inkColor) {
@@ -346,7 +350,7 @@ private fun RectMorphSurface(
.onSizeChanged { full = it.height }
.graphicsLayer { alpha = ((tall.value - 0.25f) / 0.5f).coerceIn(0f, 1f) },
) {
- Column(Modifier.heightIn(max = maxHeight).verticalScroll(rememberScrollState())) {
+ Column(Modifier.heightIn(max = maxHeight).fadingVerticalScroll()) {
Spacer(Modifier.height(6.dp))
body(shut) { action -> if (chosenAction == null) { chosenAction = action; onDismiss() } }
Spacer(Modifier.height(6.dp))
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Motion.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Motion.kt
index c4bd86e..36ebf57 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Motion.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Motion.kt
@@ -104,7 +104,9 @@ object MotionSettings {
curve = EaseCurve(it[0], it[1], it[2], it[3])
}
duration = p.getFloat("motion_duration", 1f)
- val d = MotionStyle.Default
+ // the system's "Remove animations": until the user picks a motion of their own, the calmest one
+ // (no wobble, little swell); the animations themselves already run at the system's scale
+ val d = if (!p.contains("motion_bounce") && SystemAccessibility.animationsOff(context)) MotionStyle.Calm else MotionStyle.Default
style = MotionStyle(
bounce = p.getFloat("motion_bounce", d.bounce),
speed = p.getFloat("motion_speed", d.speed),
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt
index bea1a53..1ec1061 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt
@@ -157,7 +157,7 @@ fun GlassDialog(
)
Spacer(Modifier.height(10.dp))
}
- Column(Modifier.heightIn(max = 420.dp).verticalScroll(rememberScrollState())) { content() }
+ Column(Modifier.heightIn(max = 420.dp).fadingVerticalScroll()) { content() }
if (confirm != null || dismiss != null) {
Spacer(Modifier.height(20.dp))
Row(
@@ -392,7 +392,7 @@ fun GlassMenuLayout(
maxHeight: Dp = 480.dp,
content: @Composable ColumnScope.() -> Unit,
) {
- GlassMenuLayoutContent(anchor, onDismiss, width, maxHeight) { content() }
+ GlassMenuLayoutContent(anchor, onDismiss, width, menuMaxHeight(maxHeight)) { content() }
}
@Composable
@@ -438,7 +438,7 @@ private fun GlassMenuLayoutContent(
alpha = (p * 1.6f).coerceIn(0f, 1f)
},
) {
- Column(Modifier.heightIn(max = maxHeight).verticalScroll(rememberScrollState()), content = content)
+ Column(Modifier.heightIn(max = maxHeight).fadingVerticalScroll(), content = content)
}
},
modifier = Modifier.fillMaxSize(),
@@ -501,7 +501,7 @@ fun GlassTextField(
.then(if (error) Modifier.background(Candy.Tomato.copy(alpha = 0.12f)) else Modifier)
.padding(horizontal = 16.dp, vertical = 14.dp),
) {
- if (value.isEmpty()) Text(placeholder, style = ClearType.Body, color = if (error) Candy.Tomato else c.inkFaint)
+ if (value.isEmpty()) Text(placeholder, style = ClearType.Body, color = if (error) Candy.Tomato else c.inkSoft)
inner()
}
},
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Style.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Style.kt
index 614a947..a88c212 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Style.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Style.kt
@@ -116,6 +116,19 @@ object GlassSettings {
var adaptive: Boolean by mutableStateOf(false)
private set
+ /**
+ * Reduce transparency (Settings, in the Clean appearance): the controls that float over content
+ * (the reader's toolbar, the desk's pinned filters, the bottom pill) stay solid, with no blur behind.
+ * Off by default, on by default when the system asks for high contrast.
+ */
+ var reduceTransparency: Boolean by mutableStateOf(false)
+ private set
+
+ fun updateReduceTransparency(context: Context, on: Boolean) {
+ reduceTransparency = on
+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean("reduceTransparency", on).apply()
+ }
+
fun updateAdaptive(context: Context, on: Boolean) {
adaptive = on
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean("adaptive", on).apply()
@@ -144,6 +157,7 @@ object GlassSettings {
}
haptics = p.getBoolean("haptics", true)
adaptive = p.getBoolean("adaptive", false)
+ reduceTransparency = p.getBoolean("reduceTransparency", SystemAccessibility.highContrast(context))
wallpaper = runCatching { Wallpaper.valueOf(p.getString("wallpaper", null) ?: "Aurora") }.getOrDefault(Wallpaper.Aurora)
if (wallpaper == Wallpaper.Custom) loadCustom(context)
if (wallpaper == Wallpaper.Custom && customWallpaper == null) wallpaper = Wallpaper.Aurora
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Surfaces.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Surfaces.kt
index bd423d9..221bf90 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Surfaces.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Surfaces.kt
@@ -6,9 +6,12 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.combinedClickable
+import androidx.compose.foundation.verticalScroll
import androidx.compose.ui.draw.clip
+import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.graphics.Brush
import androidx.compose.foundation.interaction.MutableInteractionSource
+import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
@@ -16,6 +19,7 @@ import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import com.kyant.backdrop.backdrops.layerBackdrop
import com.kyant.backdrop.backdrops.rememberCombinedBackdrop
@@ -39,7 +43,7 @@ import com.kyant.backdrop.drawBackdrop
@Composable
internal fun Modifier.cleanFloatingSurface(shape: Shape, strongestAtTop: Boolean = false): Modifier {
val panel = clear.solidPanel
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || GlassSettings.reduceTransparency) {
return clip(shape).background(panel)
}
val mask = remember(strongestAtTop) {
@@ -74,6 +78,11 @@ fun Modifier.glass(
lensAmount: Dp = 24.dp,
styleOverride: GlassStyle? = null,
luminance: GlassLuminance? = null,
+ /**
+ * A dimming layer ([glassDim]) over the wash, at its own strength whatever the preset's tint: what
+ * guarantees the words on this glass their contrast, so it is not the preset's to thin out (#158).
+ */
+ dim: Color = Color.Unspecified,
): Modifier {
if (clear.clean) return clip(shape).background(clear.solidPanel)
val backdrop = LocalBackdrop.current
@@ -83,10 +92,13 @@ fun Modifier.glass(
backdrop = backdrop,
shape = { shape },
shadow = null,
- effects = { adaptiveGlassEffects(style, luminance.value, blur.toPx(), lensHeight.toPx(), lensAmount.toPx()) },
+ effects = { adaptiveGlassEffects(style, luminance.value, blur.toPx(), lensHeight.toPx(), lensAmount.toPx(), busy = luminance.busy) },
highlight = { glassHighlight(style) },
onDrawBackdrop = luminance.recorder,
- onDrawSurface = { drawRect(adaptiveWash(luminance.value).glassTint(style)) },
+ onDrawSurface = {
+ drawRect(adaptiveWash(luminance.value, luminance.busy).glassTint(style))
+ drawGlassEdge(shape, lightEdge(luminance.value))
+ },
)
// Adaptive luminance on: a still surface (a bar, a panel, a sheet) takes its frost and light
// from what is around it. It keeps its own wash: what is written on it is in the theme's ink.
@@ -99,7 +111,10 @@ fun Modifier.glass(
shadow = null,
effects = { adaptiveGlassEffects(base, around.value, blur.toPx(), lensHeight.toPx(), lensAmount.toPx()) },
highlight = { glassHighlight(base) },
- onDrawSurface = { if (wash.isSpecified) drawRect(wash) },
+ onDrawSurface = {
+ if (wash.isSpecified) drawRect(wash)
+ if (dim.isSpecified) drawRect(dim)
+ },
)
}
return drawBackdrop(
@@ -108,10 +123,34 @@ fun Modifier.glass(
shadow = null,
effects = { glassEffects(style, blur.toPx(), lensHeight.toPx(), lensAmount.toPx()) },
highlight = { glassHighlight(style) },
- onDrawSurface = { if (wash.isSpecified) drawRect(wash.glassTint(style)) },
+ onDrawSurface = {
+ if (wash.isSpecified) drawRect(wash.glassTint(style))
+ if (dim.isSpecified) drawRect(dim)
+ },
)
}
+/**
+ * The dimming layer inside glass that carries words over the wallpaper (#158, after Apple's Liquid
+ * Glass: clear glass over a bright or busy backdrop needs one). Smoke in the dark theme, where the ink
+ * is white; milk in the light theme, where it is dark. [heavy] is the "regular" glass of a panel of
+ * rows (the Files list); light is a bar's (search, tabs). The blur, lens and rim stay the preset's.
+ */
+@Composable
+fun glassDim(heavy: Boolean = false): Color =
+ if (clear.dark) Color(0xFF0B0F1A).copy(alpha = if (heavy) 0.50f else 0.36f)
+ else Color.White.copy(alpha = if (heavy) 0.56f else 0.40f)
+
+/**
+ * A panel of rows on the same liquid glass as the search bar above it (#158): the wallpaper refracts
+ * and frosts through it like the bar, under a heavier dim so rows of names read over any picture. The
+ * rows lie flat on it (no glass of their own). Solid in the Clean appearance.
+ */
+@Composable
+fun GlassListPanel(modifier: Modifier = Modifier, shape: Shape = RoundedRectangle(28.dp), content: @Composable ColumnScope.() -> Unit) {
+ Column(modifier.glass(shape, blur = 20.dp, lensHeight = 14.dp, lensAmount = 20.dp, dim = glassDim(heavy = true)), content = content)
+}
+
/**
* A glass card whose children refract the card itself: its surface is a sibling layer under [content],
* so a glass button inside reads as part of the same frosted sheet, not a hole punched through it.
@@ -210,7 +249,7 @@ fun Modifier.pressable(
return graphicsLayer {
scaleX = jelly.scale
scaleY = jelly.scale
- }.combinedClickable(
+ }.focusRing(source).combinedClickable(
interactionSource = source,
indication = null,
enabled = enabled,
@@ -220,6 +259,27 @@ fun Modifier.pressable(
)
}
+/**
+ * A ring round a control while it has keyboard, D-pad or Switch Access focus (#158): with no ripple
+ * (the press is the jelly), nothing else would show which control is focused. Touch never focuses it.
+ */
+@Composable
+fun Modifier.focusRing(source: MutableInteractionSource, corner: Dp = 12.dp): Modifier {
+ val focused by source.collectIsFocusedAsState()
+ if (!focused) return this
+ val ring = com.chethan616.clearpdf.ui.theme.Candy.Sky
+ return drawWithContent {
+ drawContent()
+ val w = 2.dp.toPx()
+ drawRoundRect(
+ ring, topLeft = androidx.compose.ui.geometry.Offset(w / 2, w / 2),
+ size = androidx.compose.ui.geometry.Size(size.width - w, size.height - w),
+ cornerRadius = androidx.compose.ui.geometry.CornerRadius(minOf(corner.toPx(), size.minDimension / 2)),
+ style = androidx.compose.ui.graphics.drawscope.Stroke(w),
+ )
+ }
+}
+
/** An icon in the ink of the glass it sits on. */
@Composable
fun GlassIcon(icon: ImageVector, contentDescription: String?, modifier: Modifier = Modifier, tint: Color = Color.Unspecified) {
@@ -230,3 +290,34 @@ fun GlassIcon(icon: ImageVector, contentDescription: String?, modifier: Modifier
}
Icon(icon, contentDescription, modifier, tint = ink)
}
+
+/**
+ * A soft fade at whichever end of a scrolling menu has more to show, so a cut-off last row reads as
+ * "scroll for more" rather than a clipped word (#158). Put it before [verticalScroll], with the same
+ * [state]: it is drawn over the viewport, not the content.
+ */
+fun Modifier.scrollEdgeFade(state: androidx.compose.foundation.ScrollState, length: Dp = 24.dp): Modifier = this
+ .graphicsLayer { compositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen }
+ .drawWithContent {
+ drawContent()
+ val f = (length.toPx() / size.height).coerceIn(0f, 0.5f)
+ val top = state.canScrollBackward
+ val bottom = state.canScrollForward
+ if (f <= 0f || (!top && !bottom)) return@drawWithContent
+ drawRect(
+ Brush.verticalGradient(
+ 0f to (if (top) Color.Transparent else Color.Black),
+ f to Color.Black,
+ 1f - f to Color.Black,
+ 1f to (if (bottom) Color.Transparent else Color.Black),
+ ),
+ blendMode = BlendMode.DstIn,
+ )
+ }
+
+/** [verticalScroll] with its own state and a [scrollEdgeFade] at the ends that have more. */
+@Composable
+fun Modifier.fadingVerticalScroll(): Modifier {
+ val state = androidx.compose.foundation.rememberScrollState()
+ return scrollEdgeFade(state).then(Modifier.verticalScroll(state))
+}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/SystemAccessibility.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/SystemAccessibility.kt
new file mode 100644
index 0000000..63b2436
--- /dev/null
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/SystemAccessibility.kt
@@ -0,0 +1,28 @@
+package com.chethan616.clearpdf.ui.glass
+
+import android.app.UiModeManager
+import android.content.Context
+import android.os.Build
+import android.provider.Settings
+
+/**
+ * What the system's accessibility settings ask of the app's look. They decide only the defaults: a
+ * choice made in the app's own Settings always stands (#158).
+ */
+object SystemAccessibility {
+ /** Developer options or Accessibility ▸ "Remove animations": the animator scale is 0. */
+ fun animationsOff(context: Context): Boolean =
+ runCatching { Settings.Global.getFloat(context.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f) == 0f }.getOrDefault(false)
+
+ /** "High contrast text", or (Android 14+) the system contrast raised to medium or high. */
+ fun highContrast(context: Context): Boolean {
+ // not a public constant, but a plain readable secure setting on every Android this app runs on
+ val text = runCatching { Settings.Secure.getInt(context.contentResolver, "high_text_contrast_enabled", 0) == 1 }.getOrDefault(false)
+ if (text) return true
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ val ui = context.getSystemService(UiModeManager::class.java)
+ if (ui != null && runCatching { ui.contrast }.getOrDefault(0f) >= 0.5f) return true
+ }
+ return false
+ }
+}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Tabs.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Tabs.kt
index ef6ef1b..0190306 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Tabs.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Tabs.kt
@@ -40,7 +40,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
@@ -54,6 +53,7 @@ import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.selected
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.LayoutDirection
@@ -77,6 +77,9 @@ import kotlin.math.sign
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
+/** The chosen tab's pill: solid enough that its dark label reads whatever is behind (#158). */
+private val SelectedPill = Color.White.copy(alpha = 0.92f)
+
/** One choice of [GlassTabs]: an icon, a label, or both, and the candy it lights up in. */
data class GlassTab(val label: String, val icon: ImageVector? = null, val accent: Color)
@@ -95,6 +98,10 @@ fun GlassTabs(
textStyle: TextStyle = ClearType.Label,
) {
val c = clear
+ // at a large system font size the bar grows and a label may take two lines, never cut short
+ val fontScale = LocalDensity.current.fontScale
+ val height = height + (24f * (fontScale - 1f).coerceIn(0f, 1f)).dp
+ val labelLines = if (fontScale > 1.15f) 2 else 1
if (c.clean) {
Row(modifier.clip(Capsule).background(c.solidPanel).selectableGroup().padding(2.dp),
verticalAlignment = Alignment.CenterVertically) {
@@ -107,7 +114,8 @@ fun GlassTabs(
horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center,
) {
tab.icon?.let { Icon(it, null, Modifier.size(20.dp), tint = c.ink) }
- if (tab.label.isNotEmpty()) Text(tab.label, style = textStyle, color = c.ink, textAlign = TextAlign.Center)
+ // the chosen one is told by its weight too, not by colour alone
+ if (tab.label.isNotEmpty()) Text(tab.label, style = if (active) textStyle.copy(fontWeight = FontWeight.SemiBold) else textStyle, color = c.ink, textAlign = TextAlign.Center, maxLines = labelLines, overflow = TextOverflow.Ellipsis)
}
}
}
@@ -117,6 +125,8 @@ fun GlassTabs(
val haptics = LocalHaptics.current
val count = tabs.size
val container = c.glass
+ // the bar's dimming layer, as the search bar's: the labels read over any wallpaper (#158)
+ val dim = glassDim()
val inner = (height - 8.dp).coerceAtLeast(0.dp)
val accent by animateColorAsState(tabs.getOrNull(selected)?.accent ?: c.ink, GlassMotion.settle(), label = "tabAccent")
val tabsLayer = rememberLayerBackdrop()
@@ -184,10 +194,14 @@ fun GlassTabs(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
- val ink = c.ink
- if (t.icon != null) Icon(t.icon, null, tint = ink, modifier = Modifier.size(if (t.label.isEmpty()) 24.dp else 22.dp))
+ // Under the blob the chosen one sits on a solid light pill in dark ink, its candy only in
+ // its glyph and a breath of the pill: candy text on the blob's candy wash (Files' red
+ // Recent on pink) was the hardest thing on screen to read (#158). Every label is
+ // semibold, so none thins out over the glass.
+ val ink = if (tinted) InkOnLight else c.ink
+ if (t.icon != null) Icon(t.icon, null, tint = if (tinted) accent else ink, modifier = Modifier.size(if (t.label.isEmpty()) 24.dp else 22.dp))
if (t.icon != null && t.label.isNotEmpty()) Spacer(Modifier.height(3.dp))
- if (t.label.isNotEmpty()) Text(t.label, style = textStyle, color = ink, maxLines = 1, overflow = TextOverflow.Ellipsis)
+ if (t.label.isNotEmpty()) Text(t.label, style = textStyle.copy(fontWeight = FontWeight.SemiBold), color = ink, maxLines = labelLines, overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center)
}
}
}
@@ -206,7 +220,10 @@ fun GlassTabs(
scaleX = s
scaleY = s
},
- onDrawSurface = { drawRect(container.glassTint(GlassSettings.style)) },
+ onDrawSurface = {
+ drawRect(container.glassTint(GlassSettings.style))
+ drawRect(dim)
+ },
)
.then(highlight.modifier)
.height(height)
@@ -234,12 +251,15 @@ fun GlassTabs(
lens(24f.dp.toPx() * p * style.refractionHeight, 24f.dp.toPx() * p * style.refractionAmount)
},
highlight = { Highlight.Default.copy(alpha = drag.pressProgress * GlassSettings.style.highlight.coerceIn(0f, 1f)) },
- onDrawSurface = { drawRect(container) },
+ // the chosen pill: near-solid white with a breath of the tab's candy
+ onDrawSurface = {
+ drawRect(SelectedPill)
+ drawRect(accent.copy(alpha = 0.10f))
+ },
)
.height(inner)
.fillMaxWidth()
- .padding(horizontal = 4.dp)
- .graphicsLayer(colorFilter = ColorFilter.tint(accent)),
+ .padding(horizontal = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) { Cells(tinted = true) }
@@ -272,12 +292,8 @@ fun GlassTabs(
scaleX /= 1f - (v * 0.75f).fastCoerceIn(-0.2f, 0.2f)
scaleY *= 1f - (v * 0.25f).fastCoerceIn(-0.2f, 0.2f)
},
- onDrawSurface = {
- val p = drag.pressProgress
- drawRect(if (c.dark) Color.White.copy(0.08f) else Color.White.copy(0.14f), alpha = 1f - p)
- drawRect(accent.copy(alpha = if (c.dark) 0.20f else 0.12f), alpha = 1f - p)
- drawRect(Color.White.copy(alpha = 0.04f * p))
- },
+ // the pill under it is already solid: only the lens's own glint while it is held
+ onDrawSurface = { drawRect(Color.White.copy(alpha = 0.04f * drag.pressProgress)) },
)
.height(inner)
.fillMaxWidth(1f / count),
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/home/Cards.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/home/Cards.kt
index c06edac..d9239f1 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/home/Cards.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/home/Cards.kt
@@ -270,7 +270,7 @@ fun NoteCard(
NoteImage(name, Modifier.fillMaxWidth().height(86.dp).clip(RoundedRectangle(16.dp)))
}
Spacer(Modifier.height(12.dp).weight(1f, fill = false))
- Text(shortDate(note.updated), style = ClearType.Caption.copy(fontSize = 10.5.sp), color = tone.ink.copy(alpha = 0.55f), modifier = Modifier.align(Alignment.End))
+ Text(shortDate(note.updated), style = ClearType.Caption, color = tone.ink.copy(alpha = 0.55f), modifier = Modifier.align(Alignment.End))
}
}
@@ -295,7 +295,7 @@ fun MapCard(note: Note, onOpen: () -> Unit, onLong: () -> Unit, modifier: Modifi
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(LucideIcons.Network, null, tint = tone.ink.copy(alpha = 0.75f), modifier = Modifier.size(14.dp))
Spacer(Modifier.width(6.dp))
- Text(stringResource(R.string.mindmap_title), style = ClearType.Caption.copy(fontSize = 11.sp), color = tone.ink.copy(alpha = 0.75f))
+ Text(stringResource(R.string.mindmap_title), style = ClearType.Caption, color = tone.ink.copy(alpha = 0.75f))
}
Spacer(Modifier.height(6.dp))
WordFitText(note.title.ifBlank { stringResource(R.string.mindmap_title) }, (if (clear.clean) ClearType.Title else ClearType.CardTitle).copy(color = tone.accent), maxLines = 3)
@@ -317,7 +317,7 @@ fun MapCard(note: Note, onOpen: () -> Unit, onLong: () -> Unit, modifier: Modifi
}
}
Spacer(Modifier.height(12.dp).weight(1f, fill = false))
- Text(shortDate(note.updated), style = ClearType.Caption.copy(fontSize = 10.5.sp), color = tone.ink.copy(alpha = 0.55f), modifier = Modifier.align(Alignment.End))
+ Text(shortDate(note.updated), style = ClearType.Caption, color = tone.ink.copy(alpha = 0.55f), modifier = Modifier.align(Alignment.End))
}
}
@@ -334,7 +334,7 @@ fun ThoughtCard(onOpen: () -> Unit, modifier: Modifier = Modifier) {
Text("“$quote”", style = ClearType.Body.copy(fontSize = 14.sp, lineHeight = 19.sp, fontStyle = androidx.compose.ui.text.font.FontStyle.Italic), color = tone.ink.copy(alpha = 0.8f), maxLines = 5, overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis)
Spacer(Modifier.weight(1f))
Spacer(Modifier.height(12.dp))
- Text(shortDate(System.currentTimeMillis()), style = ClearType.Caption.copy(fontSize = 10.5.sp), color = tone.ink.copy(alpha = 0.55f), modifier = Modifier.align(Alignment.End))
+ Text(shortDate(System.currentTimeMillis()), style = ClearType.Caption, color = tone.ink.copy(alpha = 0.55f), modifier = Modifier.align(Alignment.End))
}
}
@@ -392,7 +392,7 @@ fun VoiceCard(note: Note, playing: Boolean, progress: () -> Float, onPlay: () ->
maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f),
)
if (note.durationMs > 0) {
- Text(com.chethan616.clearpdf.ui.viewer.clock(note.durationMs), style = ClearType.Caption.copy(fontSize = 10.5.sp, fontFeatureSettings = "tnum"), color = tone.ink.copy(alpha = 0.78f))
+ Text(com.chethan616.clearpdf.ui.viewer.clock(note.durationMs), style = ClearType.Caption.copy(fontFeatureSettings = "tnum"), color = tone.ink.copy(alpha = 0.78f))
}
}
val bars = remember(note.wave) { voiceBars(note.wave) }
@@ -587,7 +587,7 @@ fun StackCard(
) {
Column(Modifier.padding(start = 16.dp, top = 14.dp, end = 16.dp)) {
Text(title, style = ClearType.Title.copy(fontSize = 17.sp), color = Color.White, maxLines = 1, overflow = TextOverflow.Ellipsis)
- if (subtitle != null) Text(subtitle, style = ClearType.Caption.copy(fontSize = 10.5.sp), color = Color.White.copy(alpha = 0.85f), maxLines = 1)
+ if (subtitle != null) Text(subtitle, style = ClearType.Caption, color = Color.White.copy(alpha = 0.85f), maxLines = 1)
}
chips()
Box(Modifier.matchParentSize().border(1.dp, Color.White.copy(alpha = 0.35f), CardShape))
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/home/HomeScreen.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/home/HomeScreen.kt
index cc04d08..679dd99 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/home/HomeScreen.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/home/HomeScreen.kt
@@ -607,7 +607,7 @@ internal fun NameSheet(vm: AppViewModel, n: Note, onDismiss: () -> Unit) {
Icon(LucideIcons.Mic, null, tint = Candy.Grape, modifier = Modifier.size(19.dp))
Spacer(Modifier.width(10.dp))
Box(Modifier.weight(1f)) {
- if (name.text.isEmpty()) Text(stringResource(R.string.voice_name_hint), style = ClearType.Body.copy(fontSize = 17.sp), color = c.inkFaint)
+ if (name.text.isEmpty()) Text(stringResource(R.string.voice_name_hint), style = ClearType.Body.copy(fontSize = 17.sp), color = c.inkSoft)
inner()
}
if (name.text.isNotEmpty()) {
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/MindMap.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/MindMap.kt
index 8010077..0bd152a 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/MindMap.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/MindMap.kt
@@ -1036,7 +1036,7 @@ fun MindMapEditor(vm: AppViewModel, id: String) {
if (editing != null) finishEdit()
vm.closeNote()
}, immediate = true)
- Row(Modifier.weight(1f).height(44.dp).then(ink.modifier).glassBar().padding(horizontal = 16.dp), verticalAlignment = Alignment.CenterVertically) {
+ Row(Modifier.weight(1f).height(44.dp).then(ink.modifier).glassBar(edge = ink.edge).padding(horizontal = 16.dp), verticalAlignment = Alignment.CenterVertically) {
Icon(LucideIcons.Network, null, tint = Candy.Grape, modifier = Modifier.size(17.dp))
Spacer(Modifier.width(8.dp))
Text(
@@ -1072,7 +1072,7 @@ fun MindMapEditor(vm: AppViewModel, id: String) {
when {
typing != null -> {
Row(
- Modifier.fillMaxWidth().heightIn(min = 58.dp).then(ink.modifier).glassBar(RoundedCornerShape29).padding(start = 18.dp, end = 7.dp, top = 7.dp, bottom = 7.dp),
+ Modifier.fillMaxWidth().heightIn(min = 58.dp).then(ink.modifier).glassBar(RoundedCornerShape29, edge = ink.edge).padding(start = 18.dp, end = 7.dp, top = 7.dp, bottom = 7.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp),
) {
@@ -1135,7 +1135,7 @@ fun MindMapEditor(vm: AppViewModel, id: String) {
chosen != null -> {
AnimatedVisibility(palette && chosen !== doc.root, enter = fadeIn() + expandVertically(), exit = fadeOut() + shrinkVertically()) {
Row(
- Modifier.then(ink.modifier).glassBar().padding(horizontal = 12.dp, vertical = 10.dp),
+ Modifier.then(ink.modifier).glassBar(edge = ink.edge).padding(horizontal = 12.dp, vertical = 10.dp),
horizontalArrangement = Arrangement.spacedBy(10.dp),
verticalAlignment = Alignment.CenterVertically,
) {
@@ -1146,7 +1146,7 @@ fun MindMapEditor(vm: AppViewModel, id: String) {
}
}
Row(
- Modifier.then(ink.modifier).glassBar().padding(horizontal = 6.dp, vertical = 4.dp),
+ Modifier.then(ink.modifier).glassBar(edge = ink.edge).padding(horizontal = 6.dp, vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
CompositionLocalProvider(LocalGlassInk provides ink.color) {
@@ -1221,7 +1221,7 @@ private fun MapTool(icon: ImageVector, label: String, tint: Color = LocalGlassIn
) {
Icon(icon, null, tint = if (lit) Color.White else tint, modifier = Modifier.size(19.dp))
}
- Text(label, style = ClearType.Label.copy(fontSize = 10.sp, fontWeight = FontWeight.Medium), color = tint.copy(alpha = 0.8f), maxLines = 1, overflow = TextOverflow.Ellipsis)
+ Text(label, style = ClearType.Label.copy(fontSize = 11.sp, fontWeight = FontWeight.Medium), color = tint.copy(alpha = 0.8f), maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/PhotoEditor.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/PhotoEditor.kt
index 434a74a..ec097b7 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/PhotoEditor.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/PhotoEditor.kt
@@ -1150,7 +1150,7 @@ private fun exifFrame(file: File): PhotoFrame {
@Composable
private fun ModeSwitch(mode: Mode, modifier: Modifier, onPick: (Mode) -> Unit) {
val ink = rememberGlassInk(Color.White)
- BoxWithConstraints(modifier.height(48.dp).then(ink.modifier).glassBar().padding(4.dp)) {
+ BoxWithConstraints(modifier.height(48.dp).then(ink.modifier).glassBar(edge = ink.edge).padding(4.dp)) {
val each = maxWidth / Mode.entries.size
val x by animateDpAsState(each * mode.ordinal, spring(dampingRatio = 0.78f, stiffness = 520f), label = "modeLight")
Box(Modifier.offset(x = x).width(each).fillMaxHeight().clip(ChromeCapsule).background(Candy.Sky))
@@ -1278,7 +1278,7 @@ private fun ToolTab(icon: ImageVector, label: String, selected: Boolean, dot: Bo
}
Text(
label,
- style = ClearType.Label.copy(fontSize = 10.sp, fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Normal),
+ style = ClearType.Label.copy(fontSize = 11.sp, fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Normal),
color = if (selected) ink else ink.copy(alpha = 0.62f),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/sheets/SheetViewer.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/sheets/SheetViewer.kt
index 26ff85a..4a45fb3 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/sheets/SheetViewer.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/sheets/SheetViewer.kt
@@ -767,7 +767,7 @@ fun SheetViewer(vm: AppViewModel, doc: OpenDocument) {
Row(Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 6.dp), verticalAlignment = Alignment.CenterVertically) {
GlassCircle(onClick = { vm.closeDocument() }, label = stringResource(R.string.common_back)) { GlassIcon(LucideIcons.ChevronLeft, null, Modifier.size(22.dp)) }
Spacer(Modifier.size(10.dp))
- Column(Modifier.weight(1f).then(chrome.modifier).glassBar().padding(horizontal = 16.dp, vertical = 6.dp)) {
+ Column(Modifier.weight(1f).then(chrome.modifier).glassBar(edge = chrome.edge).padding(horizontal = 16.dp, vertical = 6.dp)) {
Text(doc.title, style = ClearType.BodyStrong, color = LocalGlassInk.current, maxLines = 1, overflow = TextOverflow.Ellipsis)
grid.sheets.getOrNull(grid.current)?.let { Text(it.name + if (doc.info.dirty) " · " + stringResource(R.string.sheet_edited) else "", style = ClearType.Caption, color = LocalGlassInk.current.copy(alpha = 0.62f), maxLines = 1) }
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/theme/ClearTheme.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/theme/ClearTheme.kt
index eb19daf..d563b9a 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/theme/ClearTheme.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/theme/ClearTheme.kt
@@ -65,6 +65,7 @@ data class ClearColors(
val heroGlow: Color,
val ink: Color,
val inkSoft: Color,
+ /** Glyphs, rings, handles and disabled states only: 2.4:1 on white, too faint for words to read ([inkSoft]). */
val inkFaint: Color,
val line: Color,
/** The wash on chrome glass (dock, bars, buttons, chips). */
@@ -271,8 +272,8 @@ object ClearType {
val DeskNotes = display(fraunces(600, 50f, 72.sp), DeskTitleSize, DeskTitleLine, (-0.8).sp)
val DeskTodo = display(Doto, DeskTitleSize, DeskTitleLine, 0.sp)
val DeskPdfs = display(Serif, DeskTitleSize, DeskTitleLine, (-0.8).sp)
- val DeskImages = display(jakarta(300, italic = true), DeskTitleSize, DeskTitleLine, (-1.4).sp).copy(fontStyle = FontStyle.Italic)
- val DeskAudio = display(bricolage(300, 100f, 72.sp), DeskTitleSize, DeskTitleLine, (-1.0).sp)
+ val DeskImages = display(jakarta(400, italic = true), DeskTitleSize, DeskTitleLine, (-1.4).sp).copy(fontStyle = FontStyle.Italic)
+ val DeskAudio = display(bricolage(400, 100f, 72.sp), DeskTitleSize, DeskTitleLine, (-1.0).sp)
/** The Tools screen's title: Fraunces at its softest and quirkiest, a face no other screen uses. */
val ToolsTitle = display(fraunces(700, 100f, 72.sp, wonk = 1f), DeskTitleSize, DeskTitleLine, (-0.8).sp)
@@ -283,22 +284,26 @@ object ClearType {
val Body = TextStyle(fontFamily = Outfit, fontWeight = FontWeight.Normal, fontSize = 15.sp, lineHeight = 22.sp)
val BodyStrong = Body.copy(fontWeight = FontWeight.SemiBold)
val Label = TextStyle(fontFamily = Outfit, fontWeight = FontWeight.Medium, fontSize = 13.sp, lineHeight = 18.sp)
- val Caption = TextStyle(fontFamily = Outfit, fontWeight = FontWeight.Normal, fontSize = 11.5.sp, lineHeight = 15.sp)
+ // 12 sp is the least for words that carry something (#158); they scale with the system font size
+ val Caption = TextStyle(fontFamily = Outfit, fontWeight = FontWeight.Normal, fontSize = 12.sp, lineHeight = 16.sp)
// The Recent card keeps its own Plus Jakarta Sans (its title, when, and chips), set exactly as
// before the interface moved to Outfit: the owner's chosen look for that card.
val RecentTitle = display(jakarta(700), 17.sp, 22.sp, (-0.2).sp)
- val RecentWhen = TextStyle(fontFamily = Jakarta, fontWeight = FontWeight.Normal, fontSize = 10.5.sp, lineHeight = 15.sp)
+ val RecentWhen = TextStyle(fontFamily = Jakarta, fontWeight = FontWeight.Normal, fontSize = 12.sp, lineHeight = 16.sp)
val RecentChip = TextStyle(fontFamily = Jakarta, fontWeight = FontWeight.SemiBold, fontSize = 13.sp, lineHeight = 18.sp)
}
/** A hero title's soft glow, so white type reads on the pale sky. */
fun TextStyle.glowing(c: ClearColors): TextStyle = copy(shadow = Shadow(c.heroGlow, Offset(0f, 2f), 22f))
-/** Also reads the Files-only choice from earlier builds. */
+/**
+ * Also reads the Files-only choice from earlier builds. Never chosen: Clean when the system asks for
+ * high contrast (#158), else Liquid Glass.
+ */
fun savedCleanAppearance(context: Context): Boolean {
val prefs = context.getSharedPreferences("app", Context.MODE_PRIVATE)
- return prefs.getBoolean("cleanAppearance", prefs.getBoolean("cleanFiles", false))
+ return prefs.getBoolean("cleanAppearance", prefs.getBoolean("cleanFiles", com.chethan616.clearpdf.ui.glass.SystemAccessibility.highContrast(context)))
}
@Composable
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentList.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentList.kt
index 5ebb4e5..719aa0c 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentList.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentList.kt
@@ -283,7 +283,7 @@ internal fun CommentRow(
cm.author?.takeIf { it.isNotBlank() } ?: stringResource(R.string.comments_guest), color = c.label, fontSize = 16.sp, fontWeight = FontWeight.SemiBold,
maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.widthIn(max = 200.dp),
)
- commentDateLabel(cm.modified, stringResource(R.string.common_today), stringResource(R.string.common_yesterday))?.let { Text(it, color = c.textTertiary, fontSize = 16.sp) }
+ commentDateLabel(cm.modified, stringResource(R.string.common_today), stringResource(R.string.common_yesterday))?.let { Text(it, color = c.textSecondary, fontSize = 16.sp) }
}
Box {
BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.comments_options), onMenu, size = 40.dp)
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt
index 53fcdeb..5e1b970 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt
@@ -72,6 +72,7 @@ import com.chethan616.clearpdf.ui.glass.GlassMenu
import com.chethan616.clearpdf.ui.glass.GlassMenuItem
import com.chethan616.clearpdf.ui.glass.GlassMotion
import com.chethan616.clearpdf.ui.glass.GlassPill
+import com.chethan616.clearpdf.ui.glass.MinTouch
import com.chethan616.clearpdf.ui.glass.RoundedRectangle
import com.chethan616.clearpdf.ui.glass.LocalGlassInk
import com.chethan616.clearpdf.ui.glass.glass
@@ -144,6 +145,8 @@ fun ViewerTopBar(
modifier = Modifier.weight(1f).onGloballyPositioned { titleAnchor = it.boundsInWindow() }
.graphicsLayer { alpha = contentAlpha.coerceIn(0f, 1f) },
height = 48.dp,
+ // frosted enough that a page heading scrolled behind the title doesn't read through it
+ blur = 10.dp,
horizontalPadding = 16.dp,
) {
val ink = LocalGlassInk.current
@@ -153,7 +156,7 @@ fun ViewerTopBar(
if (subtitle != null && toolTitle == null) Text(subtitle, style = ClearType.Caption, color = ink.copy(alpha = 0.72f), maxLines = 1)
}
if (onSearch != null && !toolActive) {
- BarGlyphButton(onSearch, stringResource(R.string.viewer_find_in_document), size = 36.dp, enabled = contentAlpha > 0.5f) {
+ BarGlyphButton(onSearch, stringResource(R.string.viewer_find_in_document), size = MinTouch, enabled = contentAlpha > 0.5f) {
Icon(LucideIcons.Search, null, tint = ink, modifier = Modifier.size(19.dp))
}
}
@@ -292,7 +295,8 @@ fun SearchBar(
layout(full, placeable.height) { placeable.place(0, 0) }
}
.then(ink.modifier)
- .glassBar().padding(start = 16.dp, end = 4.dp)
+ // frosted more than the dock: page text scrolls behind the words typed here (#158)
+ .glassBar(blur = 10.dp, edge = ink.edge).padding(start = 16.dp, end = 4.dp)
.graphicsLayer { alpha = ((progress().coerceIn(0f, 1f) - 0.35f) / 0.45f).coerceIn(0f, 1f) },
verticalAlignment = Alignment.CenterVertically,
) {
@@ -313,7 +317,7 @@ fun SearchBar(
modifier = Modifier.weight(1f).focusRequester(focus).semantics { contentDescription = findLabel },
decorationBox = { inner ->
Box(contentAlignment = Alignment.CenterStart) {
- if (query.isEmpty()) Text(findLabel, style = ClearType.Body, color = ink.color.copy(alpha = 0.48f), maxLines = 1)
+ if (query.isEmpty()) Text(findLabel, style = ClearType.Body, color = ink.color.copy(alpha = 0.62f), maxLines = 1)
inner()
}
},
@@ -329,7 +333,8 @@ fun SearchBar(
@Composable
private fun StepButton(icon: ImageVector, label: String, enabled: Boolean, onClick: () -> Unit) {
- Box(Modifier.size(38.dp).pressable(onClick, enabled = enabled).semantics { contentDescription = label }, contentAlignment = Alignment.Center) {
+ // the glyph is all that shows; the box is the 48 dp a finger needs
+ Box(Modifier.size(MinTouch).pressable(onClick, enabled = enabled).semantics { contentDescription = label }, contentAlignment = Alignment.Center) {
val ink = LocalGlassInk.current.takeIf { it != Color.Unspecified } ?: clear.ink
Icon(icon, null, tint = ink.copy(alpha = if (enabled) 0.82f else 0.30f), modifier = Modifier.size(19.dp))
}
@@ -399,7 +404,7 @@ fun QuickToolbar(
) {
val ink = rememberGlassInk(clear.ink)
Row(
- Modifier.weight(1f).fillMaxHeight().then(ink.modifier).glassBar().padding(horizontal = 6.dp),
+ Modifier.weight(1f).fillMaxHeight().then(ink.modifier).glassBar(edge = ink.edge).padding(horizontal = 6.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically,
) {
@@ -416,6 +421,8 @@ fun QuickToolbar(
onClick = { menuAt = moreRect },
size = 48.dp,
tint = Candy.Sky,
+ // solid, not blended over the page: a washed-out blue lost its white glyph on white (#158)
+ solid = true,
label = stringResource(R.string.common_tool_more_tools),
modifier = Modifier.onGloballyPositioned { moreRect = it.boundsInWindow() },
) {
@@ -448,18 +455,28 @@ private fun LabeledDockItem(icon: ImageVector, label: String, modifier: Modifier
private fun Modifier.androidxRotate(degrees: Float) = this.graphicsLayer { rotationZ = degrees }
-/** A tool of the dock: its glyph in the bar's ink; [lit], white on a blue disc. */
+/**
+ * A tool of the dock: its glyph in the bar's ink over its name, so five look-alike glyphs (edit, comment,
+ * eraser, highlighter, scribble) are told apart without trying each (#158); [lit], white on a blue pill.
+ */
@Composable
private fun DockItem(icon: ImageVector, label: String, lit: Boolean, onClick: () -> Unit) {
val disc by animateColorAsState(if (lit) Candy.Sky else Color.Transparent, GlassMotion.settle(), label = "dock")
val ink = com.chethan616.clearpdf.ui.glass.LocalGlassInk.current.takeIf { it != Color.Unspecified } ?: clear.ink
val glyph by animateColorAsState(if (lit) Color.White else ink, GlassMotion.settle(), label = "dockInk")
- Box(
+ Column(
Modifier.width(54.dp).fillMaxHeight().pressable(onClick, pressedScale = 0.86f).semantics { contentDescription = label },
- contentAlignment = Alignment.Center,
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.Center,
) {
- Box(Modifier.size(42.dp).clip(CircleShape).background(disc))
- Icon(icon, null, tint = glyph, modifier = Modifier.size(23.dp))
+ Box(Modifier.size(width = 44.dp, height = 28.dp).clip(Capsule).background(disc), contentAlignment = Alignment.Center) {
+ Icon(icon, null, tint = glyph, modifier = Modifier.size(21.dp))
+ }
+ Spacer(Modifier.height(2.dp))
+ Text(
+ label, style = ClearType.Caption.copy(fontSize = 11.sp, lineHeight = 13.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.Medium),
+ color = ink, maxLines = 1, softWrap = false, overflow = TextOverflow.Ellipsis,
+ )
}
}
@@ -476,7 +493,7 @@ fun SubToolbar(content: @Composable () -> Unit) {
BoxWithConstraints(Modifier.fillMaxWidth().height(BottomBarHeight).padding(horizontal = 12.dp, vertical = 8.dp), contentAlignment = Alignment.Center) {
val ink = rememberGlassInk(clear.ink)
Row(
- Modifier.widthIn(max = maxWidth).fillMaxHeight().then(ink.modifier).glassBar().horizontalScroll(scroll).padding(horizontal = 8.dp),
+ Modifier.widthIn(max = maxWidth).fillMaxHeight().then(ink.modifier).glassBar(edge = ink.edge).horizontalScroll(scroll).padding(horizontal = 8.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
) { CompositionLocalProvider(LocalSubToolbarScroll provides scroll, LocalGlassInk provides ink.color) { content() } }
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt
index 5edecc5..8fb2cbd 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt
@@ -274,7 +274,7 @@ internal fun menuInk(): androidx.compose.ui.graphics.Color =
internal fun MenuIcon(icon: ImageVector, label: String, enabled: Boolean, onClick: () -> Unit) {
val ink = menuInk()
Box(
- Modifier.size(44.dp).clickable(enabled = enabled, role = Role.Button, onClick = onClick).semantics { contentDescription = label },
+ Modifier.size(com.chethan616.clearpdf.ui.glass.MinTouch).clickable(enabled = enabled, role = Role.Button, onClick = onClick).semantics { contentDescription = label },
contentAlignment = Alignment.Center,
) {
Icon(icon, null, tint = if (enabled) ink else ink.copy(alpha = 0.35f), modifier = Modifier.size(24.dp))
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt
index b328ffc..b8b0e89 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt
@@ -390,6 +390,11 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {
)
}
val searchShown by remember { androidx.compose.runtime.derivedStateOf { ctl.searching || sp.value > 0.002f } }
+ // While More is its menu, the title pill, Undo and Share step out of its way: the card
+ // unfolds over them and left them cut off beside its edge (#158).
+ val besideMenu by androidx.compose.animation.core.animateFloatAsState(
+ if (moreMorphUp) 0f else 1f, androidx.compose.animation.core.tween(140), label = "besideMenu",
+ )
Box(barSides) {
Box {
val fa = vm.fieldActions
@@ -427,7 +432,7 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {
}
},
moreHidden = moreMorphUp,
- contentAlpha = 1f - sp.value,
+ contentAlpha = minOf(1f - sp.value, besideMenu),
undoLabel = if (doc.localUndo != null) stringResource(R.string.viewer_undo_drawing) else doc.info.undo,
redoLabel = if (doc.localUndo != null) stringResource(R.string.viewer_undo_drawing) else doc.info.redo,
)
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt
index 8161452..7bf7fa7 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt
@@ -169,7 +169,7 @@ private fun androidx.compose.foundation.layout.RowScope.ActionTile(icon: ImageVe
) {
Icon(icon, null, tint = accent, modifier = Modifier.size(23.dp))
Spacer(Modifier.height(6.dp))
- Text(label, style = ClearType.Caption.copy(fontSize = 11.sp, lineHeight = 13.sp), color = c.ink, maxLines = 2, textAlign = TextAlign.Center, overflow = TextOverflow.Ellipsis)
+ Text(label, style = ClearType.Caption.copy(fontSize = 11.5.sp, lineHeight = 14.sp), color = c.ink, maxLines = 2, textAlign = TextAlign.Center, overflow = TextOverflow.Ellipsis)
}
}
@@ -323,7 +323,7 @@ fun BookmarksSheet(vm: AppViewModel, doc: OpenDocument) {
verticalAlignment = Alignment.CenterVertically,
) {
Text(e.title, style = ClearType.Body.copy(fontSize = 16.sp), color = clear.ink, modifier = Modifier.weight(1f).padding(vertical = 10.dp), maxLines = 3, overflow = TextOverflow.Ellipsis)
- e.page?.let { Text((it.toInt() + 1).toString(), style = ClearType.Label, color = clear.inkFaint, modifier = Modifier.padding(horizontal = 6.dp)) }
+ e.page?.let { Text((it.toInt() + 1).toString(), style = ClearType.Label, color = clear.inkSoft, modifier = Modifier.padding(horizontal = 6.dp)) }
if (e.children > 0u) SheetCircleButton(LucideIcons.ChevronRight, stringResource(R.string.sheet_expand_entry, e.title), { parent = i }, size = 32.dp)
}
}
@@ -503,7 +503,7 @@ internal fun ToolTileFace(icon: ImageVector, label: String, tint: Color, modifie
Icon(icon, null, tint = Color.White, modifier = Modifier.size(27.dp))
}
Spacer(Modifier.height(8.dp))
- Text(label, style = ClearType.Caption.copy(fontSize = 11.sp, lineHeight = 13.sp), color = menuInk(), textAlign = TextAlign.Center, maxLines = 2, modifier = Modifier.padding(horizontal = 2.dp))
+ Text(label, style = ClearType.Caption.copy(fontSize = 11.5.sp, lineHeight = 14.sp), color = menuInk(), textAlign = TextAlign.Center, maxLines = 2, modifier = Modifier.padding(horizontal = 2.dp))
}
}
diff --git a/android/app/src/main/res/values-ar/strings.xml b/android/app/src/main/res/values-ar/strings.xml
index c226c42..42392d3 100644
--- a/android/app/src/main/res/values-ar/strings.xml
+++ b/android/app/src/main/res/values-ar/strings.xml
@@ -1287,6 +1287,8 @@
<string name="app_style_clean">بسيط</string>
<string name="app_style_glass_detail">الافتراضي · أسطح شبه شفافة</string>
<string name="app_style_clean_detail">أسطح معتمة</string>
+ <string name="settings_reduce_transparency">تقليل الشفافية</string>
+ <string name="settings_reduce_transparency_detail">تبقى أشرطة الأدوات فوق الصفحات والقوائم معتمة، دون تمويه خلفها</string>
<string name="qr_scanner">ماسح رموز QR</string>
<string name="qr_scan_prompt">وجّه الكاميرا نحو رمز QR</string>
</resources>
diff --git a/android/app/src/main/res/values-de/strings.xml b/android/app/src/main/res/values-de/strings.xml
index 5e08001..4bfe4d1 100644
--- a/android/app/src/main/res/values-de/strings.xml
+++ b/android/app/src/main/res/values-de/strings.xml
@@ -1629,6 +1629,8 @@
<string name="app_style_clean">Schlicht</string>
<string name="app_style_glass_detail">Standard · Durchscheinende Flächen</string>
<string name="app_style_clean_detail">Deckende Flächen</string>
+ <string name="settings_reduce_transparency">Transparenz reduzieren</string>
+ <string name="settings_reduce_transparency_detail">Symbolleisten über Seiten und Listen bleiben deckend, ohne Unschärfe dahinter</string>
<string name="qr_scanner">QR-Scanner</string>
<string name="qr_scan_prompt">Richte die Kamera auf einen QR-Code</string>
</resources>
diff --git a/android/app/src/main/res/values-es/strings.xml b/android/app/src/main/res/values-es/strings.xml
index 2af571d..6df10f4 100644
--- a/android/app/src/main/res/values-es/strings.xml
+++ b/android/app/src/main/res/values-es/strings.xml
@@ -1638,6 +1638,8 @@
<string name="app_style_clean">Sencillo</string>
<string name="app_style_glass_detail">Predeterminado · Superficies translúcidas</string>
<string name="app_style_clean_detail">Superficies opacas</string>
+ <string name="settings_reduce_transparency">Reducir transparencia</string>
+ <string name="settings_reduce_transparency_detail">Las barras sobre páginas y listas se mantienen opacas, sin desenfoque detrás</string>
<string name="qr_scanner">Escáner QR</string>
<string name="qr_scan_prompt">Apunta la cámara a un código QR</string>
</resources>
diff --git a/android/app/src/main/res/values-fr/strings.xml b/android/app/src/main/res/values-fr/strings.xml
index 1cb59ef..2867a4c 100644
--- a/android/app/src/main/res/values-fr/strings.xml
+++ b/android/app/src/main/res/values-fr/strings.xml
@@ -1510,6 +1510,8 @@
<string name="app_style_clean">Épuré</string>
<string name="app_style_glass_detail">Par défaut · Surfaces translucides</string>
<string name="app_style_clean_detail">Surfaces opaques</string>
+ <string name="settings_reduce_transparency">Réduire la transparence</string>
+ <string name="settings_reduce_transparency_detail">Les barres au-dessus des pages et des listes restent opaques, sans flou derrière</string>
<string name="qr_scanner">Scanner QR</string>
<string name="qr_scan_prompt">Pointez la caméra vers un code QR</string>
</resources>
diff --git a/android/app/src/main/res/values-it/strings.xml b/android/app/src/main/res/values-it/strings.xml
index d8ffc52..916eace 100644
--- a/android/app/src/main/res/values-it/strings.xml
+++ b/android/app/src/main/res/values-it/strings.xml
@@ -1620,6 +1620,8 @@
<string name="app_style_clean">Essenziale</string>
<string name="app_style_glass_detail">Predefinito · Superfici traslucide</string>
<string name="app_style_clean_detail">Superfici opache</string>
+ <string name="settings_reduce_transparency">Riduci trasparenza</string>
+ <string name="settings_reduce_transparency_detail">Le barre sopra pagine ed elenchi restano opache, senza sfocatura dietro</string>
<string name="qr_scanner">Scanner QR</string>
<string name="qr_scan_prompt">Inquadra un codice QR</string>
</resources>
diff --git a/android/app/src/main/res/values-pt-rBR/strings.xml b/android/app/src/main/res/values-pt-rBR/strings.xml
index 6ab07be..850059b 100644
--- a/android/app/src/main/res/values-pt-rBR/strings.xml
+++ b/android/app/src/main/res/values-pt-rBR/strings.xml
@@ -1215,6 +1215,8 @@
<string name="app_style_clean">Simples</string>
<string name="app_style_glass_detail">Padrão · Superfícies translúcidas</string>
<string name="app_style_clean_detail">Superfícies opacas</string>
+ <string name="settings_reduce_transparency">Reduzir transparência</string>
+ <string name="settings_reduce_transparency_detail">As barras sobre páginas e listas ficam opacas, sem desfoque por trás</string>
<string name="qr_scanner">Leitor de QR</string>
<string name="qr_scan_prompt">Aponte a câmera para um código QR</string>
</resources>
diff --git a/android/app/src/main/res/values-pt/strings.xml b/android/app/src/main/res/values-pt/strings.xml
index 6bbe536..d23ebd7 100644
--- a/android/app/src/main/res/values-pt/strings.xml
+++ b/android/app/src/main/res/values-pt/strings.xml
@@ -1215,6 +1215,8 @@
<string name="app_style_clean">Simples</string>
<string name="app_style_glass_detail">Predefinido · Superfícies translúcidas</string>
<string name="app_style_clean_detail">Superfícies opacas</string>
+ <string name="settings_reduce_transparency">Reduzir transparência</string>
+ <string name="settings_reduce_transparency_detail">As barras sobre páginas e listas ficam opacas, sem desfocagem por trás</string>
<string name="qr_scanner">Leitor de QR</string>
<string name="qr_scan_prompt">Aponte a câmara para um código QR</string>
</resources>
diff --git a/android/app/src/main/res/values-ru/strings.xml b/android/app/src/main/res/values-ru/strings.xml
index c1c8294..d73b9da 100644
--- a/android/app/src/main/res/values-ru/strings.xml
+++ b/android/app/src/main/res/values-ru/strings.xml
@@ -1248,6 +1248,8 @@
<string name="app_style_clean">Простой</string>
<string name="app_style_glass_detail">По умолчанию · Полупрозрачные панели</string>
<string name="app_style_clean_detail">Непрозрачные панели</string>
+ <string name="settings_reduce_transparency">Уменьшить прозрачность</string>
+ <string name="settings_reduce_transparency_detail">Панели над страницами и списками остаются непрозрачными, без размытия за ними</string>
<string name="qr_scanner">QR-сканер</string>
<string name="qr_scan_prompt">Наведите камеру на QR-код</string>
</resources>
diff --git a/android/app/src/main/res/values-zh-rCN/strings.xml b/android/app/src/main/res/values-zh-rCN/strings.xml
index f9650bb..946f0d4 100644
--- a/android/app/src/main/res/values-zh-rCN/strings.xml
+++ b/android/app/src/main/res/values-zh-rCN/strings.xml
@@ -1673,4 +1673,6 @@
<string name="settings_your_name">称呼</string>
<string name="settings_your_name_hint">显示在“今日”页的问候语上方</string>
<string name="thoughts_audios">音频</string>
+ <string name="settings_reduce_transparency">降低透明度</string>
+ <string name="settings_reduce_transparency_detail">页面和列表上方的工具栏保持不透明,背后不做模糊</string>
</resources>
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 9c54e34..d21a8db 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -1689,6 +1689,8 @@
<string name="app_style_clean">Clean</string>
<string name="app_style_glass_detail">Default · Translucent surfaces</string>
<string name="app_style_clean_detail">Solid surfaces</string>
+ <string name="settings_reduce_transparency">Reduce transparency</string>
+ <string name="settings_reduce_transparency_detail">Toolbars over pages and lists stay solid, with no blur behind them</string>
<string name="qr_scanner">QR Scanner</string>
<string name="qr_scan_prompt">Point the camera at a QR code</string>
</resources>
diff --git a/android/app/src/test/java/com/chethan616/clearpdf/ui/glass/BackdropStatsTest.kt b/android/app/src/test/java/com/chethan616/clearpdf/ui/glass/BackdropStatsTest.kt
new file mode 100644
index 0000000..75299b9
--- /dev/null
+++ b/android/app/src/test/java/com/chethan616/clearpdf/ui/glass/BackdropStatsTest.kt
@@ -0,0 +1,60 @@
+package com.chethan616.clearpdf.ui.glass
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class BackdropStatsTest {
+ private val side = 12
+
+ private fun grey(v: Int): Int = (0xFF shl 24) or (v shl 16) or (v shl 8) or v
+
+ private fun sample(at: (x: Int, y: Int) -> Int) = IntArray(side * side) { at(it % side, it / side) }
+
+ @Test
+ fun anEvenWashIsCalm() {
+ val s = backdropStats(sample { _, _ -> grey(240) }, side)!!
+ assertEquals(240 / 255f, s.luminance, 0.01f)
+ assertEquals(0f, s.busy, 0f)
+ }
+
+ @Test
+ fun aSmoothGradientIsCalmThoughItSpansFromDarkToLight() {
+ // the aurora: dark at one edge, light at the other, but no step between neighbours
+ val s = backdropStats(sample { x, _ -> grey(60 + x * 15) }, side)!!
+ assertEquals(0f, s.busy, 0.05f)
+ }
+
+ @Test
+ fun linesOfPrintAreBusy() {
+ // a white page with a dark line of type every other row
+ val s = backdropStats(sample { _, y -> if (y % 2 == 0) grey(250) else grey(90) }, side)!!
+ assertTrue("a page of print reads busy, was ${s.busy}", s.busy > 0.9f)
+ assertTrue("and light", s.luminance > 0.6f)
+ }
+
+ @Test
+ fun undrawnCellsSayNothing() {
+ assertNull(backdropStats(IntArray(side * side), side))
+ // half transparent, half an even grey: still calm, and the mean is the grey's alone
+ val s = backdropStats(sample { x, _ -> if (x < 6) 0 else grey(128) }, side)!!
+ assertEquals(128 / 255f, s.luminance, 0.01f)
+ assertEquals(0f, s.busy, 0f)
+ }
+
+ @Test
+ fun theEdgeIsOnlyForNearWhite() {
+ assertEquals(androidx.compose.ui.graphics.Color.Unspecified, lightEdge(0.5f))
+ assertEquals(androidx.compose.ui.graphics.Color.Unspecified, lightEdge(0.55f))
+ assertTrue(lightEdge(0.7f).alpha in 0.03f..0.08f)
+ assertTrue(lightEdge(0.98f).alpha > 0.1f)
+ }
+
+ @Test
+ fun aBusyBackdropThickensTheWash() {
+ assertTrue(adaptiveWash(0.95f, busy = 1f).alpha > adaptiveWash(0.95f).alpha + 0.3f)
+ assertTrue(adaptiveWash(0.05f, busy = 1f).alpha > adaptiveWash(0.05f).alpha + 0.2f)
+ assertEquals(adaptiveWash(0.7f).alpha, adaptiveWash(0.7f, busy = 0f).alpha, 0f)
+ }
+}