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.

feat: star-card fix, localized Settings, grey no-bg, share morph

Chethan616812b0eaae810
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt
index c475fd7..5da6964 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt
@@ -4,7 +4,10 @@ import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
+import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.ui.draw.clip
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -180,14 +183,15 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu
contentScale = ContentScale.Crop
)
} else {
- // Wallpaper off (user experiment): fall back to a flat iOS
- // system-grouped-background so the glass surfaces still have a
- // base to sample and the app reads as a clean Apple settings look.
+ // Wallpaper off: fall back to a NEUTRAL GREY base (not pure white/black).
+ // Apple never puts glass on pure #FFF or #000 — the translucent surfaces
+ // would vanish. A light grey (#E9E9EE) / elevated dark grey (#1C1C1E) keeps
+ // the liquid-glass panels and buttons legible with real depth.
Box(
Modifier
.layerBackdrop(backdrop)
.fillMaxSize()
- .background(if (!isDarkMode) Color(0xFFF2F2F7) else Color(0xFF000000))
+ .background(if (!isDarkMode) Color(0xFFE9E9EE) else Color(0xFF1C1C1E))
)
}
DocsNavGraph(
@@ -284,9 +288,15 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu
properties = DialogProperties(usePlatformDefaultWidth = false)
) {
Column(
+ // A Dialog is a separate window and cannot sample the in-window
+ // backdrop layer — liquidGlassPanel here rendered the raw wallpaper
+ // PNG. Use a solid themed card instead (same fix as the save/signature
+ // dialogs).
Modifier
.fillMaxWidth(0.88f)
- .liquidGlassPanel(backdrop, uiSensor)
+ .clip(RoundedCornerShape(28.dp))
+ .background(if (isDarkMode) Color(0xFF1B1E25) else Color(0xFFF5F6F8))
+ .border(1.dp, if (isDarkMode) Color.White.copy(0.10f) else Color.Black.copy(0.06f), RoundedCornerShape(28.dp))
.padding(28.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.kt
index 35f47db..b70ae4d 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.kt
@@ -1,6 +1,8 @@
package com.chethan616.clearpdf.ui.components
+import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.clickable
+import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
@@ -31,6 +33,7 @@ import kotlin.math.tanh
/**
* Circular variant of LiquidButton, optimized for icons.
*/
+@OptIn(ExperimentalFoundationApi::class)
@Composable
fun LiquidIconButton(
onClick: () -> Unit,
@@ -39,6 +42,7 @@ fun LiquidIconButton(
isInteractive: Boolean = true,
tint: Color = Color.Unspecified,
surfaceColor: Color = Color.Unspecified,
+ onLongClick: (() -> Unit)? = null,
content: @Composable () -> Unit
) {
val animationScope = rememberCoroutineScope()
@@ -95,11 +99,22 @@ fun LiquidIconButton(
}
}
)
- .clickable(
- interactionSource = null,
- indication = null,
- role = Role.Button,
- onClick = onClick
+ .then(
+ if (onLongClick != null)
+ Modifier.combinedClickable(
+ interactionSource = null,
+ indication = null,
+ role = Role.Button,
+ onClick = onClick,
+ onLongClick = onLongClick
+ )
+ else
+ Modifier.clickable(
+ interactionSource = null,
+ indication = null,
+ role = Role.Button,
+ onClick = onClick
+ )
)
.then(
if (isInteractive) {
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt
index 68b0fc7..60c3b6a 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt
@@ -3,6 +3,7 @@ package com.chethan616.clearpdf.ui.screen
import android.net.Uri
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExitTransition
+import androidx.compose.animation.Crossfade
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
@@ -39,9 +40,13 @@ import androidx.compose.material.icons.rounded.Search
import androidx.compose.material.icons.rounded.SwapHoriz
import androidx.compose.material.icons.rounded.SwapVert
import androidx.compose.material.icons.rounded.Undo
+import androidx.compose.material.icons.rounded.IosShare
import androidx.compose.material.icons.rounded.UploadFile
import androidx.compose.material3.Icon
import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.ui.hapticfeedback.HapticFeedbackType
+import androidx.compose.ui.platform.LocalHapticFeedback
+import kotlinx.coroutines.delay
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -108,6 +113,7 @@ internal fun PdfViewerBottomToolbar(
onDismissExportFeedback: () -> Unit,
onOpenExportedFile: () -> Unit,
onOpenAnotherPdf: () -> Unit,
+ onShareDocument: () -> Unit,
onRecolorSignature: (Long) -> Unit,
backdrop: LayerBackdrop,
uiSensor: UISensor,
@@ -126,6 +132,10 @@ internal fun PdfViewerBottomToolbar(
// Collapsed by default (just the "Editor Tools" pill + "Open PDF" circle). Tapping
// the pill expands the tool set above it. Image selection auto-expands so its tools show.
var editorOpen by remember { mutableStateOf(false) }
+ // Long-press the "Open another PDF" circle to morph it into a Share action; auto-reverts.
+ var shareMode by remember { mutableStateOf(false) }
+ val haptics = LocalHapticFeedback.current
+ LaunchedEffect(shareMode) { if (shareMode) { delay(3500); shareMode = false } }
// Any active tool implies the editor is open (survives the chrome auto-hiding/returning).
LaunchedEffect(activeTool, activeImageId) {
if (activeTool != PdfEditTool.None || activeImageId != null) editorOpen = true
@@ -492,13 +502,31 @@ internal fun PdfViewerBottomToolbar(
)
}
}
+ // Tap = open another PDF. Long-press morphs it into a Share button (icon
+ // cross-fades, surface eases to the share-green), then a tap shares the doc.
+ val shareGreen = Color(0xFF34C759)
+ val morphSurface by animateColorAsState(
+ if (shareMode) shareGreen else glass, tween(220), label = "shareMorphSurface"
+ )
LiquidIconButton(
- onClick = onOpenAnotherPdf,
+ onClick = {
+ if (shareMode) { onShareDocument(); shareMode = false } else onOpenAnotherPdf()
+ },
+ onLongClick = {
+ shareMode = !shareMode
+ haptics.performHapticFeedback(HapticFeedbackType.LongPress)
+ },
backdrop = backdrop,
- surfaceColor = glass,
+ surfaceColor = morphSurface,
modifier = Modifier.size(52.dp)
) {
- Icon(Icons.Rounded.UploadFile, stringResource(R.string.viewer_open_another), Modifier.size(20.dp), fg)
+ Crossfade(targetState = shareMode, animationSpec = tween(200), label = "shareMorphIcon") { sharing ->
+ if (sharing) {
+ Icon(Icons.Rounded.IosShare, stringResource(R.string.viewer_share_document), Modifier.size(20.dp), Color.White)
+ } else {
+ Icon(Icons.Rounded.UploadFile, stringResource(R.string.viewer_open_another), Modifier.size(20.dp), fg)
+ }
+ }
}
}
}
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt
index 96cadcb..ce9a970 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt
@@ -817,6 +817,31 @@ fun PdfViewerScreen(
onDismissExportFeedback = { viewModel.clearExportFeedback() },
onOpenExportedFile = { state.lastExportedUri?.let { viewModel.openPdf(context, it) } },
onOpenAnotherPdf = { pdfPickerLauncher.launch(arrayOf("*/*")) },
+ onShareDocument = {
+ val uri = state.document?.uri
+ if (uri != null) {
+ // A file:// uri can't be handed to other apps directly; wrap it via
+ // the app FileProvider. content:// uris share as-is.
+ val shareUri = if (uri.scheme == "file") {
+ runCatching {
+ androidx.core.content.FileProvider.getUriForFile(
+ context, "${context.packageName}.provider", java.io.File(uri.path!!)
+ )
+ }.getOrNull() ?: uri
+ } else uri
+ val send = android.content.Intent(android.content.Intent.ACTION_SEND).apply {
+ type = "application/pdf"
+ putExtra(android.content.Intent.EXTRA_STREAM, shareUri)
+ addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION)
+ }
+ runCatching {
+ context.startActivity(
+ android.content.Intent.createChooser(send, null)
+ .addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
+ )
+ }
+ }
+ },
onRecolorSignature = { cl ->
activeImageLoc()?.let { (pg, idx, sig) ->
if (sig.isSignature) getPageMarks(pg)[idx] = sig.copy(bitmap = recolorSignatureBitmap(sig.bitmap, Color(cl).toArgb()))
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt
index 308aef7..e2b8710 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt
@@ -226,7 +226,7 @@ fun SettingsScreen(
translationY = topBarOffsetY * density
}
) {
- LiquidGlassTopBar(title = "Settings", backdrop = backdrop, uiSensor = uiSensor, modifier = Modifier.fillMaxWidth())
+ LiquidGlassTopBar(title = stringResource(R.string.settings_title), backdrop = backdrop, uiSensor = uiSensor, modifier = Modifier.fillMaxWidth())
}
// ── Theme Mode Selector ──
@@ -359,7 +359,7 @@ fun SettingsScreen(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(Icons.Rounded.FolderOpen, null, Modifier.size(22.dp), Color(0xFF1976D2))
- BasicText("Save Location", style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
+ BasicText(stringResource(R.string.settings_save_location), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
}
Row(
@@ -383,12 +383,12 @@ fun SettingsScreen(
}
Column(Modifier.weight(1f)) {
BasicText(
- if (saveUri != null) "Custom Output Directory" else "Default Directory",
+ if (saveUri != null) stringResource(R.string.settings_custom_directory) else stringResource(R.string.settings_default_directory),
style = TextStyle(label, 14.sp, fontWeight = FontWeight.SemiBold)
)
val path = if (saveUri != null) {
saveUri!!.lastPathSegment?.replace("primary:", "") ?: saveUri.toString()
- } else "Downloads / ClearPDF"
+ } else stringResource(R.string.settings_default_path)
BasicText(path, style = TextStyle(sub, 12.sp))
}
}
@@ -403,7 +403,7 @@ fun SettingsScreen(
tint = Color(0xFF1976D2),
modifier = Modifier.weight(1f)
) {
- BasicText("Change Folder", style = TextStyle(Color.White, 13.sp, fontWeight = FontWeight.SemiBold))
+ BasicText(stringResource(R.string.settings_change_folder), style = TextStyle(Color.White, 13.sp, fontWeight = FontWeight.SemiBold))
}
if (saveUri != null) {
LiquidButton(
@@ -414,7 +414,7 @@ fun SettingsScreen(
backdrop = backdrop,
surfaceColor = Color.White.copy(0.08f)
) {
- BasicText("Reset", style = TextStyle(text, 13.sp, fontWeight = FontWeight.SemiBold))
+ BasicText(stringResource(R.string.settings_reset), style = TextStyle(text, 13.sp, fontWeight = FontWeight.SemiBold))
}
}
}
@@ -438,13 +438,13 @@ fun SettingsScreen(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(Icons.Rounded.AutoFixHigh, null, Modifier.size(22.dp), label)
- BasicText("File Handling", style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
+ BasicText(stringResource(R.string.settings_file_handling), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
}
SettingsToggleRow(
icon = Icons.Rounded.AutoFixHigh,
- title = "Auto-Compress",
- desc = "Compress PDFs automatically on import",
+ title = stringResource(R.string.settings_auto_compress),
+ desc = stringResource(R.string.settings_auto_compress_desc),
checked = autoCompress,
onCheckedChange = { autoCompress = it; AppSettingsManager.setAutoCompress(context, it) },
backdrop = backdrop,
@@ -460,8 +460,8 @@ fun SettingsScreen(
SettingsToggleRow(
icon = Icons.Rounded.FileCopy,
- title = "Keep Original",
- desc = "Preserve original file after editing",
+ title = stringResource(R.string.settings_keep_original),
+ desc = stringResource(R.string.settings_keep_original_desc),
checked = keepOriginal,
onCheckedChange = { keepOriginal = it; AppSettingsManager.setKeepOriginal(context, it) },
backdrop = backdrop,
@@ -493,7 +493,7 @@ fun SettingsScreen(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(Icons.Rounded.HighQuality, null, Modifier.size(22.dp), Color(0xFF1976D2))
- BasicText("Compression Quality", style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
+ BasicText(stringResource(R.string.settings_compression_quality), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
}
Box(
Modifier
@@ -523,8 +523,8 @@ fun SettingsScreen(
)
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
- BasicText("Smaller file size", style = TextStyle(sub.copy(0.7f), 11.sp))
- BasicText("Higher image clarity", style = TextStyle(sub.copy(0.7f), 11.sp))
+ BasicText(stringResource(R.string.settings_smaller_size), style = TextStyle(sub.copy(0.7f), 11.sp))
+ BasicText(stringResource(R.string.settings_higher_quality), style = TextStyle(sub.copy(0.7f), 11.sp))
}
}
@@ -546,13 +546,13 @@ fun SettingsScreen(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(Icons.Rounded.Wallpaper, null, Modifier.size(22.dp), label)
- BasicText("Personalization", style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
+ BasicText(stringResource(R.string.settings_personalization), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
}
SettingsToggleRow(
icon = Icons.Rounded.Wallpaper,
- title = "Background",
- desc = "Show the wallpaper image behind the app",
+ title = stringResource(R.string.settings_background),
+ desc = stringResource(R.string.settings_background_desc),
checked = showWallpaper,
onCheckedChange = onShowWallpaperChanged,
backdrop = backdrop,
@@ -582,9 +582,9 @@ fun SettingsScreen(
Icon(Icons.Rounded.Info, null, Modifier.size(28.dp), Color(0xFF0088FF))
}
BasicText("ClearPDF", style = TextStyle(text, 20.sp, fontWeight = FontWeight.Bold))
- BasicText("Version 1.0.0", style = TextStyle(sub, 13.sp))
+ BasicText(stringResource(R.string.settings_version), style = TextStyle(sub, 13.sp))
BasicText(
- "Made by Chethan616 with ❤",
+ stringResource(R.string.settings_made_by),
style = TextStyle(sub, 13.sp, textAlign = TextAlign.Center)
)
@@ -602,12 +602,12 @@ fun SettingsScreen(
verticalAlignment = Alignment.CenterVertically
) {
Icon(Icons.Rounded.Star, null, Modifier.size(18.dp), Color.White)
- BasicText("Star on GitHub", style = TextStyle(Color.White, 14.sp, fontWeight = FontWeight.SemiBold))
+ BasicText(stringResource(R.string.settings_star_github), style = TextStyle(Color.White, 14.sp, fontWeight = FontWeight.SemiBold))
}
}
BasicText(
- "ClearPDF is open source",
+ stringResource(R.string.settings_open_source),
style = TextStyle(sub.copy(0.7f), 11.sp, textAlign = TextAlign.Center)
)
}
@@ -629,7 +629,7 @@ fun SettingsScreen(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(Icons.Rounded.Code, null, Modifier.size(22.dp), label)
- BasicText("Open Source Licenses", style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
+ BasicText(stringResource(R.string.settings_licenses), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
}
LicenseItem(
@@ -661,7 +661,7 @@ fun SettingsScreen(
)
BasicText(
- "Licensed under the Apache License, Version 2.0.\nYou may obtain a copy at apache.org/licenses/LICENSE-2.0",
+ stringResource(R.string.settings_license_notice),
style = TextStyle(sub.copy(0.7f), 11.sp, lineHeight = 16.sp)
)
}
@@ -743,7 +743,7 @@ private fun LicenseItem(
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
BasicText(name, style = TextStyle(labelColor, 14.sp, fontWeight = FontWeight.Medium))
- BasicText("by $author", style = TextStyle(subColor, 12.sp))
+ BasicText(stringResource(R.string.settings_license_author, author), style = TextStyle(subColor, 12.sp))
}
BasicText(license, style = TextStyle(subColor, 11.sp))
BasicText(url, style = TextStyle(Color(0xFF0088FF), 11.sp))
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
index 69617fc..1be979f 100644
--- a/app/src/main/res/values-pt-rBR/strings.xml
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -111,6 +111,7 @@
<string name="viewer_prev">Anterior</string>
<string name="viewer_next">Pr&#243;ximo</string>
<string name="viewer_open_another">Abrir outro PDF</string>
+ <string name="viewer_share_document">Compartilhar documento</string>
<string name="viewer_editor_tools">Ferramentas</string>
<string name="viewer_open_pdf_short">Abrir PDF</string>
<string name="merge_now">Mesclar Agora</string>
@@ -176,6 +177,8 @@
<string name="settings_custom_directory">Diret&#243;rio personalizado</string>
<string name="settings_default_directory">Diret&#243;rio padr&#227;o</string>
<string name="settings_default_path">Downloads / ClearPDF</string>
+ <string name="settings_change_folder">Alterar pasta</string>
+ <string name="settings_reset">Redefinir</string>
<string name="settings_license_notice">Licenciado sob a Apache License, Vers&#227;o 2.0.\nVoc&#234; pode obter uma c&#243;pia em apache.org/licenses/LICENSE-2.0</string>
<string name="settings_license_author">por %1$s</string>
<string name="language_english">Ingl&#234;s</string>
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
index 5a1fcbc..e30e982 100644
--- a/app/src/main/res/values-pt/strings.xml
+++ b/app/src/main/res/values-pt/strings.xml
@@ -111,6 +111,7 @@
<string name="viewer_prev">Anterior</string>
<string name="viewer_next">Pr&#243;ximo</string>
<string name="viewer_open_another">Abrir outro PDF</string>
+ <string name="viewer_share_document">Compartilhar documento</string>
<string name="viewer_editor_tools">Ferramentas</string>
<string name="viewer_open_pdf_short">Abrir PDF</string>
<string name="merge_now">Mesclar Agora</string>
@@ -176,6 +177,8 @@
<string name="settings_custom_directory">Diret&#243;rio personalizado</string>
<string name="settings_default_directory">Diret&#243;rio padr&#227;o</string>
<string name="settings_default_path">Downloads / ClearPDF</string>
+ <string name="settings_change_folder">Alterar pasta</string>
+ <string name="settings_reset">Redefinir</string>
<string name="settings_license_notice">Licenciado sob a Apache License, Vers&#227;o 2.0.\nVoc&#234; pode obter uma c&#243;pia em apache.org/licenses/LICENSE-2.0</string>
<string name="settings_license_author">por %1$s</string>
<string name="language_english">Ingl&#234;s</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f676072..7d1c6ba 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -184,6 +184,7 @@
<string name="viewer_prev">Previous</string>
<string name="viewer_next">Next</string>
<string name="viewer_open_another">Open Another PDF</string>
+ <string name="viewer_share_document">Share Document</string>
<string name="viewer_editor_tools">Editor Tools</string>
<string name="viewer_open_pdf_short">Open PDF</string>
<string name="viewer_pen">Pen</string>
@@ -258,6 +259,8 @@
<string name="settings_custom_directory">Custom Directory</string>
<string name="settings_default_directory">Default Directory</string>
<string name="settings_default_path">Downloads / ClearPDF</string>
+ <string name="settings_change_folder">Change Folder</string>
+ <string name="settings_reset">Reset</string>
<string name="settings_license_notice">Licensed under the Apache License, Version 2.0.\nYou may obtain a copy at apache.org/licenses/LICENSE-2.0</string>
<string name="settings_license_author">by %1$s</string>
<string name="language_english">English</string>