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.

Fix tap outside grey ripple indication and lock 120 FPS pop up spring performance

Chethan61665522d0c29a1
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.kt
index 66b96a9..9241a29 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.kt
@@ -55,6 +55,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.CompositingStrategy
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.PathParser
@@ -122,8 +123,8 @@ fun HomeScreen(
val morphProgress by androidx.compose.animation.core.animateFloatAsState(
targetValue = if (selectedRecent != null) 1f else 0f,
animationSpec = spring(
- dampingRatio = 0.58f,
- stiffness = 220f
+ dampingRatio = 0.70f,
+ stiffness = Spring.StiffnessMedium
),
label = "morphProgress"
)
@@ -466,32 +467,39 @@ fun HomeScreen(
Box(
Modifier
.fillMaxSize()
- .background(if (isLight) Color.Black.copy(alpha = 0.12f) else Color.Black.copy(alpha = 0.22f))
- .clickable { selectedRecent = null },
+ .background(Color.Transparent)
+ .clickable(
+ interactionSource = remember { androidx.compose.foundation.interaction.MutableInteractionSource() },
+ indication = null
+ ) { selectedRecent = null },
contentAlignment = Alignment.Center
) {
selectedRecent?.let { recent ->
AnimatedVisibility(
visible = true,
- enter = fadeIn(animationSpec = spring(stiffness = Spring.StiffnessMediumLow)),
- exit = fadeOut(animationSpec = spring(stiffness = Spring.StiffnessMediumLow))
+ enter = fadeIn(animationSpec = spring(stiffness = Spring.StiffnessMedium)),
+ exit = fadeOut(animationSpec = spring(stiffness = Spring.StiffnessMedium))
) {
Column(
Modifier
.padding(horizontal = 24.dp)
.graphicsLayer {
- val scaleXValue = lerp(0.35f, 1.0f, morphProgress)
- val scaleYValue = lerp(0.20f, 1.0f, morphProgress)
- val translateYValue = lerp(100f, 0f, morphProgress) * density
+ val scaleXValue = lerp(0.50f, 1.0f, morphProgress)
+ val scaleYValue = lerp(0.40f, 1.0f, morphProgress)
+ val translateYValue = lerp(40f, 0f, morphProgress) * density
scaleX = scaleXValue
scaleY = scaleYValue
translationY = translateYValue
alpha = morphProgress.coerceIn(0f, 1f)
transformOrigin = TransformOrigin(0.5f, 0.85f)
- shadowElevation = (18f * morphProgress).dp.toPx()
+ shadowElevation = (12f * morphProgress).dp.toPx()
+ compositingStrategy = CompositingStrategy.Offscreen
}
.liquidGlassPanel(backdrop, uiSensor)
- .clickable { /* Consume inner taps */ }
+ .clickable(
+ interactionSource = remember { androidx.compose.foundation.interaction.MutableInteractionSource() },
+ indication = null
+ ) { /* Consume inner taps */ }
.padding(horizontal = 18.dp, vertical = 16.dp),
verticalArrangement = Arrangement.spacedBy(14.dp),
horizontalAlignment = Alignment.CenterHorizontally
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 4d83f97..57fc2d3 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
@@ -29,8 +29,10 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.AutoFixHigh
import androidx.compose.material.icons.rounded.Code
import androidx.compose.material.icons.rounded.DarkMode
+import androidx.compose.material.icons.rounded.Download
import androidx.compose.material.icons.rounded.FileCopy
import androidx.compose.material.icons.rounded.FolderOpen
+import androidx.compose.material.icons.rounded.FolderSpecial
import androidx.compose.material.icons.rounded.HighQuality
import androidx.compose.material.icons.rounded.Info
import androidx.compose.material.icons.rounded.LightMode
@@ -255,11 +257,12 @@ fun SettingsScreen(
)
options.forEach { option ->
val isSelected = themeMode == option.idx
+ val itemContentColor = if (isSelected) Color.White else (if (isLight) Color(0xFF2C2C2E) else Color(0xFFE0E0E0))
LiquidButton(
onClick = { onThemeModeChanged(option.idx) },
backdrop = backdrop,
tint = if (isSelected) option.activeColor else Color.Transparent,
- surfaceColor = if (isSelected) option.activeColor.copy(0.18f) else (if (isLight) Color.Black.copy(0.04f) else Color.White.copy(0.06f)),
+ surfaceColor = if (isSelected) option.activeColor.copy(0.18f) else (if (isLight) Color.White.copy(0.70f) else Color.White.copy(0.10f)),
modifier = Modifier.weight(1f)
) {
Row(
@@ -269,12 +272,12 @@ fun SettingsScreen(
Icon(
option.icon, null,
Modifier.size(17.dp),
- if (isSelected) Color.White else label
+ itemContentColor
)
BasicText(
option.label,
style = TextStyle(
- if (isSelected) Color.White else label,
+ itemContentColor,
13.sp,
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium
)
@@ -310,10 +313,77 @@ fun SettingsScreen(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
- Icon(Icons.Rounded.FolderOpen, null, Modifier.size(22.dp), Color(0xFF1976D2))
+ Icon(Icons.Rounded.FolderOpen, null, Modifier.size(22.dp), Color(0xFF0088FF))
BasicText("Save Location", style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
}
+ // Liquid Glass Save Location Mode Selector
+ Row(
+ Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ val isDefault = saveUri == null
+ val activeBlue = Color(0xFF0088FF)
+ val activeGreen = Color(0xFF00C853)
+
+ // 1. Default Downloads Button
+ val defContentColor = if (isDefault) Color.White else (if (isLight) Color(0xFF2C2C2E) else Color(0xFFE0E0E0))
+ LiquidButton(
+ onClick = {
+ if (!isDefault) {
+ SaveLocationManager.clearSaveLocation(context)
+ saveUri = null
+ }
+ },
+ backdrop = backdrop,
+ tint = if (isDefault) activeBlue else Color.Transparent,
+ surfaceColor = if (isDefault) activeBlue.copy(0.18f) else (if (isLight) Color.White.copy(0.70f) else Color.White.copy(0.10f)),
+ modifier = Modifier.weight(1f)
+ ) {
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(6.dp)
+ ) {
+ Icon(Icons.Rounded.Download, null, Modifier.size(17.dp), defContentColor)
+ BasicText(
+ "Downloads",
+ style = TextStyle(
+ defContentColor,
+ 13.sp,
+ fontWeight = if (isDefault) FontWeight.Bold else FontWeight.Medium
+ )
+ )
+ }
+ }
+
+ // 2. Custom Folder Button
+ val isCustom = !isDefault
+ val customContentColor = if (isCustom) Color.White else (if (isLight) Color(0xFF2C2C2E) else Color(0xFFE0E0E0))
+ LiquidButton(
+ onClick = { folderPicker.launch(null) },
+ backdrop = backdrop,
+ tint = if (isCustom) activeGreen else Color.Transparent,
+ surfaceColor = if (isCustom) activeGreen.copy(0.18f) else (if (isLight) Color.White.copy(0.70f) else Color.White.copy(0.10f)),
+ modifier = Modifier.weight(1f)
+ ) {
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(6.dp)
+ ) {
+ Icon(Icons.Rounded.FolderSpecial, null, Modifier.size(17.dp), customContentColor)
+ BasicText(
+ "Custom Folder",
+ style = TextStyle(
+ customContentColor,
+ 13.sp,
+ fontWeight = if (isCustom) FontWeight.Bold else FontWeight.Medium
+ )
+ )
+ }
+ }
+ }
+
+ // Path Details Card
Row(
Modifier
.fillMaxWidth()
@@ -324,19 +394,25 @@ fun SettingsScreen(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp)
) {
+ val iconColor = if (saveUri != null) Color(0xFF00C853) else Color(0xFF0088FF)
Box(
Modifier
- .size(40.dp)
+ .size(38.dp)
.clip(CircleShape)
- .background(Color(0xFF1976D2).copy(0.14f)),
+ .background(iconColor.copy(0.14f)),
contentAlignment = Alignment.Center
) {
- Icon(Icons.Rounded.FolderOpen, null, Modifier.size(20.dp), Color(0xFF1976D2))
+ Icon(
+ if (saveUri != null) Icons.Rounded.FolderSpecial else Icons.Rounded.Download,
+ null,
+ Modifier.size(19.dp),
+ iconColor
+ )
}
Column(Modifier.weight(1f)) {
BasicText(
- if (saveUri != null) "Custom Output Directory" else "Default Directory",
- style = TextStyle(label, 14.sp, fontWeight = FontWeight.SemiBold)
+ if (saveUri != null) "Custom Directory" else "Default Directory",
+ style = TextStyle(label, 13.sp, fontWeight = FontWeight.SemiBold)
)
val path = if (saveUri != null) {
saveUri!!.lastPathSegment?.replace("primary:", "") ?: saveUri.toString()
@@ -344,32 +420,6 @@ fun SettingsScreen(
BasicText(path, style = TextStyle(sub, 12.sp))
}
}
-
- Row(
- Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- LiquidButton(
- onClick = { folderPicker.launch(null) },
- backdrop = backdrop,
- tint = Color(0xFF1976D2),
- modifier = Modifier.weight(1f)
- ) {
- BasicText("Change Folder", style = TextStyle(Color.White, 13.sp, fontWeight = FontWeight.SemiBold))
- }
- if (saveUri != null) {
- LiquidButton(
- onClick = {
- SaveLocationManager.clearSaveLocation(context)
- saveUri = null
- },
- backdrop = backdrop,
- surfaceColor = Color.White.copy(0.08f)
- ) {
- BasicText("Reset", style = TextStyle(text, 13.sp, fontWeight = FontWeight.SemiBold))
- }
- }
- }
}
// ── File Handling ──