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
Make note text and cards legible over bright wallpapers
Hk-178f4f842ed5775
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.ktindex d9239f1..edeefd2 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@@ -93,9 +93,12 @@ import kotlinx.coroutines.withContext/** The corner every desk card shares: big and continuous, like the mock's. */val CardShape = RoundedRectangle(30.dp)-/** A desk card's paint: its tone's gradient, a soft light in one corner, a lit rim. */+/**+ * A desk card's paint: its tone's gradient, a soft light in one corner, a lit rim, and [tint] over all+ * of it (a smoked face, so pale ink and a pale accent still read on it).+ */@Composable-fun Modifier.cardPaint(tone: CardTone, glow: Offset = Offset(0.85f, 0.05f)): Modifier {+fun Modifier.cardPaint(tone: CardTone, glow: Offset = Offset(0.85f, 0.05f), tint: Color = Color.Transparent): Modifier {if (clear.clean) return clip(CardShape).background(clear.solidPanel)val dark = clear.darkreturn clip(CardShape)@@ -108,6 +111,7 @@ fun Modifier.cardPaint(tone: CardTone, glow: Offset = Offset(0.85f, 0.05f)): Mod),radius = size.maxDimension * 0.75f, center = Offset(glow.x * size.width, glow.y * size.height),)+ if (tint.alpha > 0f) drawRect(tint)}.border(1.dp, Brush.verticalGradient(listOf(Color.White.copy(alpha = if (dark) 0.18f else 0.6f), Color.White.copy(alpha = 0.05f))), CardShape)}@@ -257,20 +261,22 @@ fun NoteCard(val tone = clear.tone(Tone.Paper)val title = note.title.ifBlank { note.body.lineSequence().firstOrNull { it.isNotBlank() }?.trim()?.removePrefix("# ").orEmpty() }val body = if (note.title.isBlank()) "" else note.body.lineSequence().filter { it.isNotBlank() }.joinToString(" ") { it.trim().removePrefix("# ").replace("**", "") }+ // at night the card is smoked glass: its pale title blue sits on a dark face, not on pale glass+ val tint = if (clear.dark) Color(0xFF0B0F1A).copy(alpha = 0.34f) else Color.TransparentColumn(- modifier.heightIn(min = 156.dp).pressable(onOpen, onLong, pressedScale = 0.96f).cardPaint(tone, Offset(0.1f, 0.0f)).padding(18.dp),+ modifier.heightIn(min = 156.dp).pressable(onOpen, onLong, pressedScale = 0.96f).cardPaint(tone, Offset(0.1f, 0.0f), tint).padding(18.dp),) {WordFitText(title.ifBlank { stringResource(R.string.notes_untitled_note) }, (if (clear.clean) ClearType.Title else ClearType.CardTitle).copy(color = tone.accent), maxLines = 4)if (body.isNotBlank() && title.length < 40) {Spacer(Modifier.height(8.dp))- Text(body, style = ClearType.Label, color = tone.ink.copy(alpha = 0.62f), maxLines = 3, overflow = TextOverflow.Ellipsis, modifier = if (fitHeight) Modifier.weight(1f, fill = false) else Modifier)+ Text(body, style = ClearType.Label, color = tone.ink.copy(alpha = 0.82f), maxLines = 3, overflow = TextOverflow.Ellipsis, modifier = if (fitHeight) Modifier.weight(1f, fill = false) else Modifier)}note.images.firstOrNull()?.let { name ->Spacer(Modifier.height(12.dp))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, color = tone.ink.copy(alpha = 0.55f), modifier = Modifier.align(Alignment.End))+ Text(shortDate(note.updated), style = ClearType.Caption.copy(fontSize = 12.sp), color = tone.ink.copy(alpha = 0.75f), modifier = Modifier.align(Alignment.End))}}diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/NoteEditor.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/NoteEditor.ktindex 8899fd7..f4cda25 100644--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/NoteEditor.kt+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/NoteEditor.kt@@ -46,8 +46,11 @@ import androidx.compose.ui.draw.clipimport androidx.compose.ui.draw.drawBehindimport androidx.compose.ui.focus.FocusRequesterimport androidx.compose.ui.focus.focusRequester+import androidx.compose.ui.geometry.Offsetimport androidx.compose.ui.geometry.Rect+import androidx.compose.ui.graphics.Brushimport androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.Shadowimport androidx.compose.ui.graphics.SolidColorimport androidx.compose.ui.graphics.graphicsLayerimport androidx.compose.ui.graphics.vector.ImageVector@@ -87,6 +90,7 @@ import com.chethan616.clearpdf.ui.glass.GlassIconimport com.chethan616.clearpdf.ui.glass.GlassMenuimport com.chethan616.clearpdf.ui.glass.GlassMenuItemimport com.chethan616.clearpdf.ui.glass.GlassMotion+import com.chethan616.clearpdf.ui.glass.LocalScreenInkimport com.chethan616.clearpdf.ui.glass.glassimport com.chethan616.clearpdf.ui.glass.pressableimport com.chethan616.clearpdf.ui.home.NoteImage@@ -139,6 +143,7 @@ fun NoteEditor(vm: AppViewModel, id: String) {LaunchedEffect(id) { if (note.isEmpty) runCatching { titleFocus.requestFocus() } }Box(Modifier.fillMaxSize()) {+ ReadingVeil()LazyColumn(Modifier.fillMaxSize().imePadding(),contentPadding = PaddingValues(start = 24.dp, end = 24.dp, bottom = 140.dp),@@ -159,7 +164,7 @@ fun NoteEditor(vm: AppViewModel, id: String) {item(key = "title") {BasicTextField(title, { title = it },- textStyle = ClearType.Headline.copy(fontSize = 34.sp, lineHeight = 40.sp, fontWeight = FontWeight.ExtraBold, color = c.ink),+ textStyle = ClearType.Headline.copy(fontSize = 34.sp, lineHeight = 40.sp, fontWeight = FontWeight.ExtraBold, color = c.ink, shadow = LegibleShadow),cursorBrush = SolidColor(Candy.Sky),keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.Sentences, imeAction = ImeAction.Next),keyboardActions = KeyboardActions(onNext = {@@ -173,7 +178,8 @@ fun NoteEditor(vm: AppViewModel, id: String) {modifier = Modifier.fillMaxWidth().padding(top = 34.dp).focusRequester(titleFocus),decorationBox = { inner ->Box {- if (title.text.isEmpty()) Text(stringResource(if (isList) R.string.notes_list_title_hint else R.string.notes_title_hint), style = ClearType.Headline.copy(fontSize = 34.sp, lineHeight = 40.sp, fontWeight = FontWeight.ExtraBold), color = c.ink.copy(alpha = 0.32f))+ // told from typed text by its weight, not only by faintness+ if (title.text.isEmpty()) Text(stringResource(if (isList) R.string.notes_list_title_hint else R.string.notes_title_hint), style = ClearType.Headline.copy(fontSize = 34.sp, lineHeight = 40.sp, fontWeight = FontWeight.SemiBold, shadow = LegibleShadow), color = c.ink.copy(alpha = 0.62f))inner()}},@@ -182,7 +188,7 @@ fun NoteEditor(vm: AppViewModel, id: String) {item(key = "date") {Text(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(Date(note.updated)),- style = ClearType.Caption, color = c.ink.copy(alpha = 0.5f), modifier = Modifier.padding(top = 10.dp, bottom = 18.dp),+ style = ClearType.Caption.copy(fontSize = 13.sp, shadow = LegibleShadow), color = c.ink.copy(alpha = 0.75f), modifier = Modifier.padding(top = 10.dp, bottom = 18.dp),)}if (isList) {@@ -210,16 +216,16 @@ fun NoteEditor(vm: AppViewModel, id: String) {Modifier.fillMaxWidth().padding(top = 6.dp).pressable({ val n = checkItem(""); items = items + n; focusItem = n.id }).padding(vertical = 10.dp),verticalAlignment = Alignment.CenterVertically,) {- Icon(LucideIcons.Plus, null, tint = c.ink.copy(alpha = 0.55f), modifier = Modifier.size(24.dp))+ Icon(LucideIcons.Plus, null, tint = c.ink.copy(alpha = 0.75f), modifier = Modifier.size(24.dp))Spacer(Modifier.width(12.dp))- Text(stringResource(R.string.notes_add_item), style = ClearType.Body.copy(fontSize = 17.sp), color = c.ink.copy(alpha = 0.55f))+ Text(stringResource(R.string.notes_add_item), style = ClearType.Body.copy(fontSize = 17.sp), color = c.ink.copy(alpha = 0.75f))}}} else {item(key = "body") {BasicTextField(body, { body = it },- textStyle = ClearType.Body.copy(fontSize = 18.sp, lineHeight = 30.sp, color = c.ink.copy(alpha = 0.86f)),+ textStyle = ClearType.Body.copy(fontSize = 18.sp, lineHeight = 30.sp, color = c.ink.copy(alpha = 0.94f), shadow = LegibleShadow),cursorBrush = SolidColor(Candy.Sky),visualTransformation = MarkdownLite(c.ink),keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.Sentences),@@ -227,12 +233,12 @@ fun NoteEditor(vm: AppViewModel, id: String) {decorationBox = { inner ->Column {Box {- if (body.text.isEmpty()) Text(stringResource(R.string.notes_body_hint), style = ClearType.Body.copy(fontSize = 18.sp, lineHeight = 30.sp), color = c.ink.copy(alpha = 0.38f))+ if (body.text.isEmpty()) Text(stringResource(R.string.notes_body_hint), style = ClearType.Body.copy(fontSize = 18.sp, lineHeight = 30.sp, shadow = LegibleShadow), color = c.ink.copy(alpha = 0.66f))inner()}if (reading) {Text(- stringResource(R.string.notes_body_hint), style = ClearType.Body.copy(fontSize = 18.sp, lineHeight = 30.sp), color = c.ink.copy(alpha = 0.38f),+ stringResource(R.string.notes_body_hint), style = ClearType.Body.copy(fontSize = 18.sp, lineHeight = 30.sp, shadow = LegibleShadow), color = c.ink.copy(alpha = 0.66f),modifier = Modifier.padding(top = 30.dp).pressable({val text = body.text + "\n\n"body = TextFieldValue(text, TextRange(text.length))@@ -306,6 +312,36 @@ fun NoteEditor(vm: AppViewModel, id: String) {}}+/**+ * A soft shade under the editor's words: over a wallpaper with fine detail (the skeleton's wings and+ * chains) the veil alone can leave a letter broken up, and a shadow binds it back together.+ */+private val LegibleShadow = Shadow(Color.Black.copy(alpha = 0.35f), Offset(0f, 1.5f), 6f)++/**+ * A reading veil over the wallpaper, behind the editor's words only: the light ink sits on a calmer+ * surface without the wallpaper leaving, and the brighter the wallpaper the stronger the veil (its+ * luminance is the window's own sampler, the one the glass reads). Faded out on a dark wallpaper, in+ * the light theme (whose ink is dark) and in Clean appearance (already a solid page).+ */+@Composable+private fun ReadingVeil() {+ val c = clear+ if (c.clean || !c.dark) return+ // null while Adaptive luminance is off: then the theme's own dark backdrop is the guess+ val luminance = LocalScreenInk.current?.frame?.average() ?: 0.14f+ val top = (0.15f + 0.35f * luminance).coerceIn(0.15f, 0.50f)+ Box(+ Modifier.fillMaxSize().background(+ Brush.verticalGradient(+ 0f to Color.Black.copy(alpha = top),+ 0.6f to Color.Black.copy(alpha = top * 0.88f),+ 1f to Color.Black.copy(alpha = top * 0.45f),+ )+ )+ )+}+/** A list item being written: its round tick and its words; Enter makes the next, Backspace on nothing removes it. */@Composableprivate fun ItemRow(item: CheckItem, focus: Boolean, onChange: (String) -> Unit, onToggle: () -> Unit, onNext: () -> Unit, onRemove: () -> Unit) {