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
Customize toolbar in More tools' look, a solid highlighter, a steady morph over titles
chethan616949afea1e0c5
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/AppIcons.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/AppIcons.ktindex 20bdb9f..4bb64f5 100644--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/AppIcons.kt+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/AppIcons.kt@@ -163,22 +163,16 @@ object LucideIcons {}private val HighlighterGlyph: ImageVector by lazy {+ // a solid marker laid at a slant, its nib down-left, over a bar of its ink: the same weight as the+ // filled Material glyphs it sits among, its ink spanning 3 … 21 so it centres on the row as they doImageVector.Builder("Highlighter", 24.dp, 24.dp, 24f, 24f).apply {- // the pen's body and nib (Lucide's highlighter, ISC), then the ink line under itaddPath(- androidx.compose.ui.graphics.vector.PathParser().parsePathString("M9.5,10.5L4.5,15.5V18.5H11.5L14.5,15.5M20.5,10.6L16.6,14.5A1.8,1.8 0,0 1,14.1 14.5L9.6,10A1.8,1.8 0,0 1,9.6 7.5L13.5,3.6").toNodes(),- fill = null,- stroke = androidx.compose.ui.graphics.SolidColor(androidx.compose.ui.graphics.Color.Black),- strokeLineWidth = 2.1f,- strokeLineCap = androidx.compose.ui.graphics.StrokeCap.Round,- strokeLineJoin = androidx.compose.ui.graphics.StrokeJoin.Round,- )- addPath(- androidx.compose.ui.graphics.vector.PathParser().parsePathString("M14,21.5H21").toNodes(),- fill = null,- stroke = androidx.compose.ui.graphics.SolidColor(androidx.compose.ui.graphics.Color.Black),- strokeLineWidth = 2.1f,- strokeLineCap = androidx.compose.ui.graphics.StrokeCap.Round,+ androidx.compose.ui.graphics.vector.PathParser().parsePathString(+ "M14.1,3.6 Q14.8,2.9 15.5,3.6 L19.4,7.5 Q20.1,8.2 19.4,8.9 L11.6,16.7 L6.3,11.4 Z " ++ "M5.6,12.2 L10.8,17.4 L9.3,18.9 L5.2,18.9 L3.9,17.6 L3.9,13.9 Z " ++ "M12.2,19.4 L20.2,19.4 Q21.2,19.4 21.2,20.4 Q21.2,21.4 20.2,21.4 L12.2,21.4 Z",+ ).toNodes(),+ fill = androidx.compose.ui.graphics.SolidColor(androidx.compose.ui.graphics.Color.Black),)}.build()}diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/QuickTools.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/QuickTools.ktindex b08b1f2..7abd045 100644--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/QuickTools.kt+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/QuickTools.kt@@ -8,6 +8,9 @@ import androidx.compose.animation.core.infiniteRepeatableimport androidx.compose.animation.core.rememberInfiniteTransitionimport androidx.compose.animation.core.tweenimport androidx.compose.foundation.background+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.borderimport androidx.compose.foundation.clickableimport androidx.compose.foundation.gestures.detectDragGesturesimport androidx.compose.foundation.layout.Box@@ -267,47 +270,70 @@ fun CustomizeToolbar(vm: AppViewModel, onDone: () -> Unit) {Box(Modifier.fillMaxWidth().onGloballyPositioned { origin = it.boundsInRoot().topLeft }) {Column {- Row(Modifier.fillMaxWidth().padding(start = 20.dp, end = 8.dp), verticalAlignment = Alignment.CenterVertically) {- Text(stringResource(R.string.toolbar_customize), color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))- com.chethan616.clearpdf.ui.glass.GlassCircle(onDone, label = stringResource(R.string.common_cancel)) {+ // as More tools' header: its title, a glass close, and the blue tick that keeps the arrangement+ val ink = menuInk()+ Spacer(Modifier.height(6.dp))+ Row(Modifier.fillMaxWidth().padding(start = 18.dp, end = 14.dp), verticalAlignment = Alignment.CenterVertically) {+ Text(stringResource(R.string.toolbar_customize), style = com.chethan616.clearpdf.ui.theme.ClearType.Title.copy(fontSize = 18.sp), color = ink, modifier = Modifier.weight(1f))+ com.chethan616.clearpdf.ui.glass.GlassCircle(onDone, size = 36.dp, label = stringResource(R.string.common_cancel)) {com.chethan616.clearpdf.ui.glass.GlassIcon(LucideIcons.X, null, Modifier.size(18.dp))}Spacer(Modifier.width(8.dp))com.chethan616.clearpdf.ui.glass.GlassCircle({prefs.save(bar.toList(), grid.toList())onDone()- }, tint = com.chethan616.clearpdf.ui.theme.Candy.Sky, label = stringResource(R.string.toolbar_save)) {+ }, size = 36.dp, tint = com.chethan616.clearpdf.ui.theme.Candy.Sky, label = stringResource(R.string.toolbar_save)) {com.chethan616.clearpdf.ui.glass.GlassIcon(LucideIcons.Check, null, Modifier.size(18.dp))}}Text(pluralStringResource(R.plurals.toolbar_customize_hint, slots, slots),- color = c.textSecondary, fontSize = 14.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 4.dp),+ style = com.chethan616.clearpdf.ui.theme.ClearType.Label, color = ink.copy(alpha = 0.62f),+ modifier = Modifier.padding(start = 18.dp, end = 18.dp, top = 6.dp),)- Text(stringResource(R.string.toolbar_section_toolbar), color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 12.dp, bottom = 6.dp))- BoxWithConstraints(- Modifier.fillMaxWidth().padding(horizontal = 8.dp).clip(RoundedCornerShape(8.dp)).background(c.pressed)- .onGloballyPositioned { barRect = it.boundsInRoot() },+ Text(+ stringResource(R.string.toolbar_section_toolbar).uppercase(), style = com.chethan616.clearpdf.ui.theme.ClearType.Eyebrow, color = ink.copy(alpha = 0.55f),+ modifier = Modifier.padding(start = 20.dp, top = 18.dp, bottom = 8.dp),+ )+ // the toolbar as it looks on the page: a capsule of its glyphs, the blue More tools circle at its end+ Row(+ Modifier.fillMaxWidth().padding(horizontal = 12.dp).height(60.dp),+ verticalAlignment = Alignment.CenterVertically,) {- val itemW = minOf(72.dp, (maxWidth - 8.dp) / (slots + 1))- Row(Modifier.fillMaxWidth().heightIn(min = BottomBarHeight), verticalAlignment = Alignment.CenterVertically) {- for (t in bar) Draggable(t) { BarTool(t, itemW) }- Spacer(Modifier.weight(1f))- // More tools always ends the bar- Box(Modifier.alpha(0.5f)) { BarTool(null, itemW) }+ Row(+ Modifier.weight(1f).height(56.dp).clip(com.chethan616.clearpdf.ui.glass.Capsule)+ .background(if (c.dark) Color.White.copy(alpha = 0.08f) else Color.White.copy(alpha = 0.6f))+ .border(1.dp, Color.White.copy(alpha = if (c.dark) 0.18f else 0.8f), com.chethan616.clearpdf.ui.glass.Capsule)+ .onGloballyPositioned { barRect = it.boundsInRoot() }+ .padding(horizontal = 6.dp),+ verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.SpaceEvenly,+ ) {+ for (t in bar) Draggable(t) { BarGlyph(t.icon, ink) }+ // room left on the bar: faint places to drop a tool+ repeat(slots - bar.size) { Box(Modifier.size(44.dp), contentAlignment = Alignment.Center) { Box(Modifier.size(8.dp).clip(androidx.compose.foundation.shape.CircleShape).background(ink.copy(alpha = 0.18f))) } }+ }+ Spacer(Modifier.width(10.dp))+ // More tools always ends the bar+ Box(Modifier.size(52.dp).clip(androidx.compose.foundation.shape.CircleShape).background(com.chethan616.clearpdf.ui.theme.Candy.Sky), contentAlignment = Alignment.Center) {+ Icon(LucideIcons.LayoutGrid, null, tint = Color.White, modifier = Modifier.size(24.dp))}}- Text(stringResource(R.string.common_tool_more_tools), color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 16.dp, bottom = 6.dp))- Column(Modifier.fillMaxWidth().padding(horizontal = 8.dp).heightIn(min = 96.dp).onGloballyPositioned { gridRect = it.boundsInRoot() }) {+ Text(+ stringResource(R.string.common_tool_more_tools).uppercase(), style = com.chethan616.clearpdf.ui.theme.ClearType.Eyebrow, color = ink.copy(alpha = 0.55f),+ modifier = Modifier.padding(start = 20.dp, top = 18.dp, bottom = 4.dp),+ )+ // More tools' own tiles, four to a row+ Column(Modifier.fillMaxWidth().padding(horizontal = 10.dp).heightIn(min = 96.dp).onGloballyPositioned { gridRect = it.boundsInRoot() }) {grid.chunked(4).forEach { row ->- Row(Modifier.fillMaxWidth()) {- row.forEach { t -> Box(Modifier.weight(1f), contentAlignment = Alignment.Center) { Draggable(t) { GridTool(t) } } }+ Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.Top) {+ row.forEach { t -> Box(Modifier.weight(1f), contentAlignment = Alignment.TopCenter) { Draggable(t) { ToolTileFace(t.icon, stringResource(t.title), t.hue) } } }repeat(4 - row.size) { Spacer(Modifier.weight(1f)) }}- Spacer(Modifier.height(8.dp))+ Spacer(Modifier.height(6.dp))}}- Spacer(Modifier.height(16.dp))+ Spacer(Modifier.height(14.dp))}// the tool under the fingerval t = dragging@@ -315,36 +341,14 @@ fun CustomizeToolbar(vm: AppViewModel, onDone: () -> Unit) {val half = with(LocalDensity.current) { 36.dp.toPx() }Box(Modifier.offset { IntOffset((dragPos.x - origin.x - half).roundToInt(), (dragPos.y - origin.y - half).roundToInt()) }- .shadow(6.dp, RoundedCornerShape(8.dp)).background(c.surface, RoundedCornerShape(8.dp)),- ) { BarTool(t, 72.dp) }+ .graphicsLayer { scaleX = 1.08f; scaleY = 1.08f },+ ) { ToolTileFace(t.icon, stringResource(t.title), t.hue, Modifier.width(72.dp)) }}}}-/** A tool as the bar shows it: icon over its short label ([tool] null: More tools). */+/** A tool on the toolbar's capsule: its glyph alone, as the bar on the page shows it. */@Composable-private fun BarTool(tool: QuickTool?, width: androidx.compose.ui.unit.Dp) {- val c = pdfColors- // grows with a large font setting, as the bar does- Column(Modifier.width(width).heightIn(min = BottomBarHeight), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = androidx.compose.foundation.layout.Arrangement.Center) {- Icon(tool?.icon ?: LucideIcons.LayoutGrid, null, tint = c.icon, modifier = Modifier.size(24.dp))- Spacer(Modifier.height(6.dp))- Text(- stringResource(tool?.label ?: R.string.common_tool_more_tools), color = c.text, fontSize = 12.sp, lineHeight = 14.sp, maxLines = 2,- overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis, textAlign = TextAlign.Center,- )- }-}--/** A tool as More tools shows it: a tinted tile over its name. */-@Composable-private fun GridTool(tool: QuickTool) {- val c = pdfColors- Column(Modifier.width(80.dp).padding(vertical = 6.dp), horizontalAlignment = Alignment.CenterHorizontally) {- Box(Modifier.size(48.dp).clip(RoundedCornerShape(4.dp)).background(tileBackground(tool.hue, c.dark)), contentAlignment = Alignment.Center) {- Icon(tool.icon, null, tint = tool.hue, modifier = Modifier.size(26.dp))- }- Spacer(Modifier.height(8.dp))- Text(stringResource(tool.title), color = c.text, fontSize = 13.sp, textAlign = TextAlign.Center, maxLines = 2, lineHeight = 16.sp)- }+private fun BarGlyph(icon: ImageVector, ink: Color) {+ Box(Modifier.size(44.dp), contentAlignment = Alignment.Center) { Icon(icon, null, tint = ink, modifier = Modifier.size(24.dp)) }}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.ktindex 5dd55bb..8161452 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@@ -485,8 +485,14 @@ fun pdfDateMillis(s: String?): Long? {*/@Composableprivate fun ToolTile(icon: ImageVector, label: String, tint: Color, modifier: Modifier = Modifier, onClick: () -> Unit) {+ ToolTileFace(icon, label, tint, modifier.pressable(onClick, pressedScale = 0.92f).semantics { contentDescription = label })+}++/** A tool's tile as More tools draws it: its hue's rounded square with the glyph in white, its name under it. */+@Composable+internal fun ToolTileFace(icon: ImageVector, label: String, tint: Color, modifier: Modifier = Modifier) {Column(- modifier.pressable(onClick, pressedScale = 0.92f).padding(vertical = 6.dp).semantics { contentDescription = label },+ modifier.padding(vertical = 6.dp),horizontalAlignment = Alignment.CenterHorizontally,) {Box(