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.

Settings: full rebuild on the shared glass kit; main nav bar gets labels; wire #53 reduce-motion toggle

Chethan61615367cf71d0d
diff --git a/app/src/main/java/com/chethan616/clearpdf/data/repository/Preferences.kt b/app/src/main/java/com/chethan616/clearpdf/data/repository/Preferences.kt
index 91a4fe6..dbe1e53 100644
--- a/app/src/main/java/com/chethan616/clearpdf/data/repository/Preferences.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/data/repository/Preferences.kt
@@ -162,6 +162,7 @@ object AppSettingsManager {
private const val KEY_SHOW_WALLPAPER = "show_wallpaper"
private const val KEY_REMEMBER_RECENT_FILES = "remember_recent_files"
private const val KEY_KEEP_LOCAL_COPIES = "keep_local_document_copies"
+ private const val KEY_REDUCE_GLASS_MOTION = "reduce_glass_motion"
private fun prefs(context: Context): SharedPreferences =
context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
@@ -172,6 +173,15 @@ object AppSettingsManager {
fun setShowWallpaper(context: Context, value: Boolean) =
prefs(context).edit().putBoolean(KEY_SHOW_WALLPAPER, value).apply()
+ // Opt-in (default off: full quality). Freezes the gravity-tracked specular highlight that
+ // every liquidGlassPanel/capsule reads instead of letting it keep publishing tilt updates —
+ // see UISensor's own KDoc for why that is the dominant redraw cost on devices sensitive to it.
+ fun getReduceGlassMotion(context: Context): Boolean =
+ prefs(context).getBoolean(KEY_REDUCE_GLASS_MOTION, false)
+
+ fun setReduceGlassMotion(context: Context, value: Boolean) =
+ prefs(context).edit().putBoolean(KEY_REDUCE_GLASS_MOTION, value).apply()
+
// Optional user-picked background image (content URI). Null = use the built-in wallpaper.
fun getCustomWallpaper(context: Context): String? =
prefs(context).getString("custom_wallpaper_uri", null)
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 9d12e91..6ef0cfc 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt
@@ -64,6 +64,7 @@ import com.chethan616.clearpdf.ui.components.liquidGlassPanel
import com.chethan616.clearpdf.ui.navigation.DocsNavGraph
import com.chethan616.clearpdf.ui.navigation.ROUTE_ONBOARDING
import com.chethan616.clearpdf.ui.theme.LocalIsDarkMode
+import com.chethan616.clearpdf.ui.theme.LocalReducedGlassMotion
import com.chethan616.clearpdf.ui.utils.StarPromptEventBus
import com.chethan616.clearpdf.ui.utils.rememberUISensor
import com.chethan616.clearpdf.ui.components.GlassDialog
@@ -108,6 +109,7 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu
var themeMode by rememberSaveable { mutableIntStateOf(AppSettingsManager.getThemeMode(context)) }
var showWallpaper by rememberSaveable { mutableStateOf(AppSettingsManager.getShowWallpaper(context)) }
+ var reduceGlassMotion by rememberSaveable { mutableStateOf(AppSettingsManager.getReduceGlassMotion(context)) }
var customWallpaper by rememberSaveable { mutableStateOf(AppSettingsManager.getCustomWallpaper(context)) }
// Decode the user's chosen background off the main thread (downsampled to the screen).
var customWallpaperBitmap by remember { mutableStateOf<androidx.compose.ui.graphics.ImageBitmap?>(null) }
@@ -249,6 +251,7 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu
CompositionLocalProvider(
LocalResources provides localizedContext.resources,
LocalIsDarkMode provides isDarkMode,
+ LocalReducedGlassMotion provides reduceGlassMotion,
LocalBackToLibraryAction provides backToLibrary
) {
Box(Modifier.fillMaxSize()) {
@@ -304,6 +307,11 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu
showWallpaper = it
AppSettingsManager.setShowWallpaper(context, it)
},
+ reduceGlassMotion = reduceGlassMotion,
+ onReduceGlassMotionChanged = {
+ reduceGlassMotion = it
+ AppSettingsManager.setReduceGlassMotion(context, it)
+ },
hasCustomWallpaper = customWallpaper != null,
onCustomWallpaperChanged = { customWallpaper = it },
selectedLocale = selectedLocale,
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/DocsBottomTabs.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/DocsBottomTabs.kt
index e82f602..ee8e17c 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/DocsBottomTabs.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/DocsBottomTabs.kt
@@ -1,6 +1,7 @@
package com.chethan616.clearpdf.ui.components
import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.text.BasicText
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Home
import androidx.compose.material.icons.rounded.GridView
@@ -10,12 +11,20 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
import com.chethan616.clearpdf.ui.theme.LiquidGlassColors
import com.chethan616.clearpdf.ui.theme.LocalIsDarkMode
import com.chethan616.clearpdf.R
import com.kyant.backdrop.Backdrop
+/**
+ * Icon + label, the same richness the xlsx sheet-tab dock has (a name, not just a glyph) instead of
+ * three bare icons — the tab a visitor is actually ON used to be legible only by which capsule the
+ * slider sat under, not by anything the tab itself said.
+ */
@Composable
fun DocsBottomTabs(
selectedTab: () -> Int,
@@ -24,7 +33,14 @@ fun DocsBottomTabs(
modifier: Modifier = Modifier
) {
val isDarkMode = LocalIsDarkMode.current
- val tint = LiquidGlassColors.secondary(isDarkMode)
+ val sub = LiquidGlassColors.secondary(isDarkMode)
+ val accent = LiquidGlassColors.Blue
+
+ // The selected pill is a light sheen + a whisper of accent (see LiquidBottomTabs'
+ // onDrawSurface) in BOTH themes, not a solid fill, so its ink is the accent colour itself —
+ // the same convention the xlsx sheet tabs use for their own selected label.
+ @Composable
+ fun tabColor(index: Int): Color = if (selectedTab() == index) accent else sub
LiquidBottomTabs(
selectedTabIndex = selectedTab,
@@ -33,19 +49,28 @@ fun DocsBottomTabs(
tabsCount = 3,
modifier = modifier
) {
- LiquidBottomTab(onClick = { onTabSelected(0) }) {
- Icon(Icons.Rounded.Home, contentDescription = stringResource(R.string.nav_home), tint = tint,
- modifier = Modifier.size(22.dp))
- }
-
- LiquidBottomTab(onClick = { onTabSelected(1) }) {
- Icon(Icons.Rounded.GridView, contentDescription = stringResource(R.string.nav_tools), tint = tint,
- modifier = Modifier.size(22.dp))
- }
-
- LiquidBottomTab(onClick = { onTabSelected(2) }) {
- Icon(Icons.Rounded.Tune, contentDescription = stringResource(R.string.nav_settings), tint = tint,
- modifier = Modifier.size(22.dp))
+ val tabs = listOf(
+ Triple(Icons.Rounded.Home, R.string.nav_home, 0),
+ Triple(Icons.Rounded.GridView, R.string.nav_tools, 1),
+ Triple(Icons.Rounded.Tune, R.string.nav_settings, 2)
+ )
+ tabs.forEach { (icon, labelRes, index) ->
+ val label = stringResource(labelRes)
+ LiquidBottomTab(onClick = { onTabSelected(index) }) {
+ // Ink stays close to the selected pill's own light-sheen + accent-wash surface
+ // (see LiquidBottomTabs' onDrawSurface), so it reads against either theme without
+ // needing a per-tab recomposition when the selection moves.
+ Icon(icon, contentDescription = null, tint = tabColor(index), modifier = Modifier.size(20.dp))
+ BasicText(
+ label,
+ style = TextStyle(
+ tabColor(index),
+ 10.sp,
+ if (selectedTab() == index) FontWeight.SemiBold else FontWeight.Medium
+ ),
+ maxLines = 1
+ )
+ }
}
}
}
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/navigation/DocsNavGraph.kt b/app/src/main/java/com/chethan616/clearpdf/ui/navigation/DocsNavGraph.kt
index f655ffa..d5caa9d 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/navigation/DocsNavGraph.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/navigation/DocsNavGraph.kt
@@ -194,6 +194,8 @@ fun DocsNavGraph(
onThemeModeChanged: (Int) -> Unit,
showWallpaper: Boolean = true,
onShowWallpaperChanged: (Boolean) -> Unit = {},
+ reduceGlassMotion: Boolean = false,
+ onReduceGlassMotionChanged: (Boolean) -> Unit = {},
hasCustomWallpaper: Boolean = false,
onCustomWallpaperChanged: (String?) -> Unit = {},
selectedLocale: String,
@@ -407,6 +409,8 @@ fun DocsNavGraph(
onThemeModeChanged = onThemeModeChanged,
showWallpaper = showWallpaper,
onShowWallpaperChanged = onShowWallpaperChanged,
+ reduceGlassMotion = reduceGlassMotion,
+ onReduceGlassMotionChanged = onReduceGlassMotionChanged,
hasCustomWallpaper = hasCustomWallpaper,
onCustomWallpaperChanged = onCustomWallpaperChanged,
selectedLocale = selectedLocale,
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 1d55255..b37effe 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
@@ -5,15 +5,20 @@ import android.content.Intent
import android.net.Uri
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
+import androidx.compose.animation.core.FastOutSlowInEasing
+import androidx.compose.animation.core.Spring
+import androidx.compose.animation.core.Transition
+import androidx.compose.animation.core.animateFloat
+import androidx.compose.animation.core.tween
+import androidx.compose.animation.core.updateTransition
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
+import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
@@ -21,23 +26,20 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.relocation.BringIntoViewRequester
import androidx.compose.foundation.relocation.bringIntoViewRequester
+import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.AutoAwesome
-import androidx.compose.material.icons.rounded.AutoFixHigh
import androidx.compose.material.icons.rounded.Code
import androidx.compose.material.icons.rounded.Compress
-import androidx.compose.material.icons.rounded.Description
-import androidx.compose.material.icons.rounded.PhotoLibrary
-import androidx.compose.material.icons.rounded.Refresh
import androidx.compose.material.icons.rounded.DarkMode
+import androidx.compose.material.icons.rounded.Description
import androidx.compose.material.icons.rounded.FileCopy
import androidx.compose.material.icons.rounded.FolderOpen
import androidx.compose.material.icons.rounded.HighQuality
@@ -45,9 +47,12 @@ import androidx.compose.material.icons.rounded.Info
import androidx.compose.material.icons.rounded.Language
import androidx.compose.material.icons.rounded.LightMode
import androidx.compose.material.icons.rounded.PhoneAndroid
-import androidx.compose.material.icons.rounded.Wallpaper
+import androidx.compose.material.icons.rounded.PhotoLibrary
+import androidx.compose.material.icons.rounded.Refresh
import androidx.compose.material.icons.rounded.Star
import androidx.compose.material.icons.rounded.Tune
+import androidx.compose.material.icons.rounded.Vibration
+import androidx.compose.material.icons.rounded.Wallpaper
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@@ -59,15 +64,16 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
-import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.chethan616.clearpdf.R
@@ -75,24 +81,38 @@ import com.chethan616.clearpdf.data.repository.AppSettingsManager
import com.chethan616.clearpdf.data.repository.GitHubStarPromptManager
import com.chethan616.clearpdf.data.repository.SaveLocationManager
import com.chethan616.clearpdf.office.OfficeEngine
+import com.chethan616.clearpdf.ui.components.AccentIconTile
+import com.chethan616.clearpdf.ui.components.GlassChoiceChip
import com.chethan616.clearpdf.ui.components.GlassDialog
-import com.chethan616.clearpdf.ui.components.rememberScreenBackdrop
import com.chethan616.clearpdf.ui.components.GlassDialogAction
-import com.chethan616.clearpdf.ui.components.LiquidButton
-import com.chethan616.clearpdf.ui.components.LiquidIconButton
import com.chethan616.clearpdf.ui.components.GlassScreenHeaderRow
import com.chethan616.clearpdf.ui.components.GlassScreenScaffold
+import com.chethan616.clearpdf.ui.components.LiquidButton
+import com.chethan616.clearpdf.ui.components.LiquidIconButton
import com.chethan616.clearpdf.ui.components.LiquidSlider
import com.chethan616.clearpdf.ui.components.LiquidToggle
+import com.chethan616.clearpdf.ui.components.ToolInk
+import com.chethan616.clearpdf.ui.components.ToolPrimaryButton
import com.chethan616.clearpdf.ui.components.liquidGlassPanel
+import com.chethan616.clearpdf.ui.components.rememberScreenBackdrop
import com.chethan616.clearpdf.ui.theme.LiquidGlassColors
+import com.chethan616.clearpdf.ui.theme.ToolAccents
+import com.chethan616.clearpdf.ui.utils.rememberUISensor
+import com.kyant.backdrop.Backdrop
import com.kyant.backdrop.backdrops.LayerBackdrop
-import kotlinx.coroutines.delay
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
-import androidx.compose.ui.graphics.graphicsLayer
-
+/**
+ * Settings, rebuilt on the same kit the tool screens and Home use: [liquidGlassPanel] sections
+ * (sampling the *sensor*, so their own highlight follows device tilt like every other panel
+ * instead of the old bespoke [legacySectionBorder]-style flat card), [GlassChoiceChip] for every
+ * picker instead of three hand-rolled [LiquidButton]s per picker, and ONE staggered [updateTransition]
+ * entrance instead of twelve independent `animateFloatAsState` pairs. Every setting the old screen
+ * had is still here and still does the same thing — this only changes how it looks and how many
+ * animation clocks it costs to show it.
+ */
@Composable
fun SettingsScreen(
backdrop: LayerBackdrop,
@@ -102,6 +122,8 @@ fun SettingsScreen(
onThemeModeChanged: (Int) -> Unit = {},
showWallpaper: Boolean = true,
onShowWallpaperChanged: (Boolean) -> Unit = {},
+ reduceGlassMotion: Boolean = false,
+ onReduceGlassMotionChanged: (Boolean) -> Unit = {},
hasCustomWallpaper: Boolean = false,
onCustomWallpaperChanged: (String?) -> Unit = {},
selectedLocale: String = "en",
@@ -109,22 +131,18 @@ fun SettingsScreen(
onReplayOnboarding: () -> Unit = {}
) {
val isLight = !isDarkMode
- val text = if (isLight) Color(0xFF222222) else Color(0xFFF0F0F0)
- val sub = if (isLight) Color(0xFF888888) else Color(0xFFAAAAAA)
- val label = if (isLight) Color(0xFF444444) else Color(0xFFCCCCCC)
+ val ink = LiquidGlassColors.text(isDarkMode)
+ val sub = LiquidGlassColors.secondary(isDarkMode)
val context = LocalContext.current
+ val uiSensor = rememberUISensor()
val settingsScope = rememberCoroutineScope()
- val openRepo = remember(context) {
- { openExternalLink(context, GitHubStarPromptManager.REPO_URL) }
- }
+ val openRepo = remember(context) { { openExternalLink(context, GitHubStarPromptManager.REPO_URL) } }
var autoCompress by remember { mutableStateOf(AppSettingsManager.getAutoCompress(context)) }
var keepOriginal by remember { mutableStateOf(AppSettingsManager.getKeepOriginal(context)) }
var rememberRecentFiles by remember { mutableStateOf(AppSettingsManager.getRememberRecentFiles(context)) }
var keepLocalCopies by remember { mutableStateOf(AppSettingsManager.getKeepLocalCopies(context)) }
var defaultQuality by remember { mutableFloatStateOf(AppSettingsManager.getDefaultQuality(context)) }
-
- // Debounce quality slider persistence to prevent lag
LaunchedEffect(defaultQuality) {
delay(300L)
AppSettingsManager.setDefaultQuality(context, defaultQuality)
@@ -134,729 +152,326 @@ fun SettingsScreen(
// Non-null while the "Delete Office engine?" dialog is up; holds the size it will free.
var officeEngineDeleteSize by remember { mutableStateOf<Long?>(null) }
- val folderPicker = rememberLauncherForActivityResult(
- contract = ActivityResultContracts.OpenDocumentTree()
- ) { uri: Uri? ->
+ val folderPicker = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri: Uri? ->
if (uri != null) {
- // Take persistable permission so we can write there later
- val flags = android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION or
- android.content.Intent.FLAG_GRANT_WRITE_URI_PERMISSION
- try {
- context.contentResolver.takePersistableUriPermission(uri, flags)
- } catch (_: Exception) {
- // Some providers may reject persistable flags; fallback still stores chosen URI.
- }
+ val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
+ runCatching { context.contentResolver.takePersistableUriPermission(uri, flags) }
val displayPath = uri.lastPathSegment?.replace("primary:", "") ?: uri.toString()
SaveLocationManager.setSaveLocation(context, uri, displayPath)
saveUri = uri
}
}
-
- // Pick a custom background image from the gallery (persistable so it survives restarts).
- val wallpaperPicker = rememberLauncherForActivityResult(
- contract = ActivityResultContracts.OpenDocument()
- ) { uri: Uri? ->
+ val wallpaperPicker = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri: Uri? ->
if (uri != null) {
- try {
- context.contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
- } catch (_: Exception) {}
+ runCatching { context.contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION) }
AppSettingsManager.setCustomWallpaper(context, uri.toString())
onCustomWallpaperChanged(uri.toString())
}
}
var isVisible by remember { mutableStateOf(false) }
- LaunchedEffect(Unit) {
- isVisible = true
- }
-
- val density = androidx.compose.ui.platform.LocalDensity.current.density
-
- val topBarAlpha by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 1f else 0f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 550, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsTopBarAlpha"
- )
- val topBarOffsetY by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 0f else 18f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 550, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsTopBarOffsetY"
- )
-
- val panel1Alpha by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 1f else 0f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 600, delayMillis = 60, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel1Alpha"
- )
- val panel1OffsetY by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 0f else 20f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 600, delayMillis = 60, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel1OffsetY"
- )
-
- val panel2Alpha by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 1f else 0f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 620, delayMillis = 120, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel2Alpha"
- )
- val panel2OffsetY by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 0f else 24f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 620, delayMillis = 120, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel2OffsetY"
- )
-
- val panel3Alpha by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 1f else 0f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 640, delayMillis = 180, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel3Alpha"
- )
- val panel3OffsetY by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 0f else 28f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 640, delayMillis = 180, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel3OffsetY"
- )
-
- val panel4Alpha by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 1f else 0f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 660, delayMillis = 240, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel4Alpha"
- )
- val panel4OffsetY by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 0f else 32f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 660, delayMillis = 240, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel4OffsetY"
- )
-
- val panel5Alpha by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 1f else 0f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 680, delayMillis = 300, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel5Alpha"
- )
- val panel5OffsetY by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 0f else 36f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 680, delayMillis = 300, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel5OffsetY"
- )
-
- val panel6Alpha by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 1f else 0f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 700, delayMillis = 360, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel6Alpha"
- )
- val panel6OffsetY by androidx.compose.animation.core.animateFloatAsState(
- targetValue = if (isVisible) 0f else 40f,
- animationSpec = androidx.compose.animation.core.tween(durationMillis = 700, delayMillis = 360, easing = androidx.compose.animation.core.FastOutSlowInEasing),
- label = "settingsPanel6OffsetY"
- )
+ LaunchedEffect(Unit) { isVisible = true }
+ // One transition for every section's entrance, staggered by index — the same device ToolsScreen
+ // uses, in place of the old screen's twelve separate `animateFloatAsState` pairs (six panels,
+ // each with its own alpha *and* offsetY Animatable, all running concurrently from first frame).
+ val entrance = updateTransition(isVisible, label = "settingsEntrance")
val screenBackdrop = rememberScreenBackdrop(backdrop)
Box(Modifier.fillMaxSize()) {
- GlassScreenScaffold(
- backdrop = backdrop,
- screenBackdrop = screenBackdrop,
- contentBottomPadding = 84.dp,
- header = { headerBackdrop ->
- // No back button here, so the pill centres against the full width. Fade only — the pill
- // is glass, and translating glass re-runs its blur+lens.
- GlassScreenHeaderRow(
- title = stringResource(R.string.settings_title),
- backdrop = headerBackdrop,
- onBack = null,
- modifier = Modifier.graphicsLayer { alpha = topBarAlpha }
- )
- }
- ) { contentPadding ->
- val settingsListState = rememberLazyListState()
- val officeEngineRequester = remember { androidx.compose.foundation.relocation.BringIntoViewRequester() }
- LaunchedEffect(Unit) {
- if (com.chethan616.clearpdf.office.OfficeEngine.focusSettingsSection.value) {
- com.chethan616.clearpdf.office.OfficeEngine.focusSettingsSection.value = false
- delay(350L) // let the screen's entrance settle before scrolling
- settingsListState.animateScrollToItem(7)
- delay(120L) // let the lazy item attach its bring-into-view target
- officeEngineRequester.bringIntoView()
- }
- }
- LazyColumn(
- state = settingsListState,
- modifier = Modifier.fillMaxSize(),
- contentPadding = contentPadding,
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
- // ── Theme Mode Selector ──
- item(key = "settings-section-1") {
- Column(
- Modifier
- .fillMaxWidth()
- .graphicsLayer {
- alpha = panel1Alpha
- translationY = panel1OffsetY * density
+ GlassScreenScaffold(
+ backdrop = backdrop,
+ screenBackdrop = screenBackdrop,
+ contentBottomPadding = 84.dp,
+ header = { headerBackdrop ->
+ GlassScreenHeaderRow(
+ title = stringResource(R.string.settings_title),
+ backdrop = headerBackdrop,
+ onBack = null,
+ modifier = entrance.sectionFade(0)
+ )
+ }
+ ) { contentPadding ->
+ val scrollState = rememberScrollState()
+ val officeEngineRequester = remember { BringIntoViewRequester() }
+ LaunchedEffect(Unit) {
+ if (OfficeEngine.focusSettingsSection.value) {
+ OfficeEngine.focusSettingsSection.value = false
+ delay(350L)
+ officeEngineRequester.bringIntoView()
}
- .liquidGlassSection(isLight)
- .padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
- Row(
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- Icon(Icons.Rounded.Tune, null, Modifier.size(22.dp), label)
- BasicText(stringResource(R.string.settings_appearance), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
}
-
- // Liquid-glass refracted segmented control
- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- data class ThemeOption(val idx: Int, val label: String, val icon: ImageVector, val activeColor: Color)
- val options = listOf(
- ThemeOption(0, stringResource(R.string.settings_theme_auto), Icons.Rounded.PhoneAndroid, LiquidGlassColors.Blue),
- ThemeOption(1, stringResource(R.string.settings_theme_light), Icons.Rounded.LightMode, Color(0xFFFFA726)),
- ThemeOption(2, stringResource(R.string.settings_theme_dark), Icons.Rounded.DarkMode, Color(0xFF7C4DFF))
- )
- options.forEach { option ->
- val isSelected = themeMode == option.idx
- val cc = 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.Unspecified,
- surfaceColor = if (isSelected) Color.Unspecified else (if (isLight) Color.Black.copy(0.06f) else Color.White.copy(0.10f)),
- modifier = Modifier.weight(1f)
- ) {
- Row(
- Modifier.fillMaxWidth(),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(5.dp, Alignment.CenterHorizontally)
- ) {
- Icon(option.icon, null, Modifier.size(16.dp), cc)
- BasicText(
- option.label,
- style = TextStyle(cc, 13.sp, fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium),
- maxLines = 1, overflow = TextOverflow.Ellipsis,
- modifier = Modifier.weight(1f, fill = false)
+ Column(
+ Modifier.fillMaxSize().verticalScroll(scrollState).padding(contentPadding),
+ verticalArrangement = Arrangement.spacedBy(16.dp)
+ ) {
+ // ── Appearance ──
+ SettingsSection(backdrop, uiSensor, entrance.sectionFade(1)) {
+ SettingsSectionHeader(Icons.Rounded.Tune, stringResource(R.string.settings_appearance), ink)
+ data class ThemeOption(val idx: Int, val label: String, val icon: ImageVector, val accent: Color)
+ val options = listOf(
+ ThemeOption(0, stringResource(R.string.settings_theme_auto), Icons.Rounded.PhoneAndroid, LiquidGlassColors.Blue),
+ ThemeOption(1, stringResource(R.string.settings_theme_light), Icons.Rounded.LightMode, LiquidGlassColors.Orange),
+ ThemeOption(2, stringResource(R.string.settings_theme_dark), Icons.Rounded.DarkMode, LiquidGlassColors.Purple)
+ )
+ Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ options.forEach { option ->
+ GlassChoiceChip(
+ label = option.label,
+ selected = themeMode == option.idx,
+ onClick = { onThemeModeChanged(option.idx) },
+ backdrop = backdrop,
+ accent = option.accent,
+ icon = option.icon,
+ modifier = Modifier.weight(1f)
)
}
}
+ BasicText(
+ when (themeMode) {
+ 1 -> stringResource(R.string.settings_theme_light_desc)
+ 2 -> stringResource(R.string.settings_theme_dark_desc)
+ else -> stringResource(R.string.settings_theme_auto_desc)
+ },
+ style = TextStyle(sub, 12.sp)
+ )
+ SettingsDivider(isLight)
+ SettingsToggleRow(
+ icon = Icons.Rounded.Vibration,
+ title = stringResource(R.string.settings_reduce_glass_motion),
+ desc = stringResource(R.string.settings_reduce_glass_motion_desc),
+ checked = reduceGlassMotion,
+ onCheckedChange = onReduceGlassMotionChanged,
+ backdrop = backdrop
+ )
}
- }
- BasicText(
- when (themeMode) {
- 1 -> stringResource(R.string.settings_theme_light_desc)
- 2 -> stringResource(R.string.settings_theme_dark_desc)
- else -> stringResource(R.string.settings_theme_auto_desc)
- },
- style = TextStyle(sub, 12.sp)
- )
- }
- }
-
- // ── Language ──
- item(key = "settings-section-2") {
- Column(
- Modifier
- .fillMaxWidth()
- .graphicsLayer {
- alpha = panel1Alpha
- translationY = panel1OffsetY * density
+ // ── Language ──
+ SettingsSection(backdrop, uiSensor, entrance.sectionFade(2)) {
+ SettingsSectionHeader(Icons.Rounded.Language, stringResource(R.string.settings_language), ink)
+ data class LangOption(val code: String, val label: String)
+ val langs = listOf(
+ LangOption("en", stringResource(R.string.language_english)),
+ LangOption("pt-BR", stringResource(R.string.language_portuguese)),
+ LangOption("es", stringResource(R.string.language_spanish)),
+ LangOption("it", stringResource(R.string.language_italian)),
+ LangOption("ru", stringResource(R.string.language_russian))
+ )
+ Row(
+ Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),
+ horizontalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ langs.forEach { opt ->
+ GlassChoiceChip(
+ label = opt.label,
+ selected = selectedLocale == opt.code,
+ onClick = { onLocaleChanged(opt.code) },
+ backdrop = backdrop,
+ accent = LiquidGlassColors.Blue
+ )
+ }
+ }
}
- .liquidGlassSection(isLight)
- .padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
- Row(
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- Icon(Icons.Rounded.Language, null, Modifier.size(22.dp), label)
- BasicText(stringResource(R.string.settings_language), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
- }
- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- data class LangOption(val code: String, val label: String)
- val langs = listOf(
- LangOption("en", stringResource(R.string.language_english)),
- LangOption("pt-BR", stringResource(R.string.language_portuguese)),
- LangOption("es", stringResource(R.string.language_spanish)),
- LangOption("it", stringResource(R.string.language_italian))
- )
- val accent = LiquidGlassColors.Blue
- langs.forEach { opt ->
- val isSelected = selectedLocale == opt.code
- val cc = if (isSelected) Color.White else (if (isLight) Color(0xFF2C2C2E) else Color(0xFFE0E0E0))
- LiquidButton(
- onClick = { onLocaleChanged(opt.code) },
- backdrop = backdrop,
- tint = if (isSelected) accent else Color.Unspecified,
- surfaceColor = if (isSelected) Color.Unspecified else (if (isLight) Color.Black.copy(0.06f) else Color.White.copy(0.10f)),
- modifier = Modifier.weight(1f)
+ // ── Save Location ──
+ SettingsSection(backdrop, uiSensor, entrance.sectionFade(3)) {
+ SettingsSectionHeader(Icons.Rounded.FolderOpen, stringResource(R.string.settings_save_location), LiquidGlassColors.Blue)
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .clip(RoundedCornerShape(16.dp))
+ .background(LiquidGlassColors.neutralSurface(isDarkMode))
+ .padding(14.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(12.dp)
) {
- BasicText(
- opt.label,
- style = TextStyle(cc, 13.sp, fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium),
- maxLines = 1, overflow = TextOverflow.Ellipsis,
- modifier = Modifier.padding(vertical = 4.dp)
+ AccentIconTile(Icons.Rounded.FolderOpen, LiquidGlassColors.Blue, size = 40, iconSize = 20)
+ Column(Modifier.weight(1f)) {
+ BasicText(
+ if (saveUri != null) stringResource(R.string.settings_custom_directory) else stringResource(R.string.settings_default_directory),
+ style = TextStyle(ink, 14.sp, FontWeight.SemiBold)
+ )
+ val path = saveUri?.let { it.lastPathSegment?.replace("primary:", "") ?: it.toString() }
+ ?: stringResource(R.string.settings_default_path)
+ BasicText(path, style = TextStyle(sub, 12.sp), maxLines = 1, overflow = TextOverflow.Ellipsis)
+ }
+ }
+ Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ ToolPrimaryButton(
+ text = stringResource(R.string.settings_change_folder),
+ onClick = { folderPicker.launch(null) },
+ backdrop = backdrop,
+ accent = LiquidGlassColors.Teal,
+ modifier = Modifier.weight(1f)
)
+ if (saveUri != null) {
+ ToolPrimaryButton(
+ text = stringResource(R.string.settings_reset),
+ onClick = { SaveLocationManager.clearSaveLocation(context); saveUri = null },
+ backdrop = backdrop,
+ accent = LiquidGlassColors.Orange
+ )
+ }
}
}
- }
- }
- }
-
- // ── Save Location ──
- item(key = "settings-section-3") {
- Column(
- Modifier
- .fillMaxWidth()
- .graphicsLayer {
- alpha = panel2Alpha
- translationY = panel2OffsetY * density
- }
- .liquidGlassSection(isLight)
- .padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(14.dp)
- ) {
- Row(
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- Icon(Icons.Rounded.FolderOpen, null, Modifier.size(22.dp), LiquidGlassColors.Blue)
- BasicText(stringResource(R.string.settings_save_location), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
- }
- Row(
- Modifier
- .fillMaxWidth()
- .clip(RoundedCornerShape(16.dp))
- .background(if (isLight) Color.Black.copy(0.03f) else Color.White.copy(0.05f))
- .border(1.dp, if (isLight) Color.Black.copy(0.05f) else Color.White.copy(0.08f), RoundedCornerShape(16.dp))
- .padding(14.dp),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(12.dp)
- ) {
- Box(
- Modifier
- .size(40.dp)
- .clip(CircleShape)
- .background(LiquidGlassColors.Blue.copy(0.14f)),
- contentAlignment = Alignment.Center
- ) {
- Icon(Icons.Rounded.FolderOpen, null, Modifier.size(20.dp), LiquidGlassColors.Blue)
- }
- Column(Modifier.weight(1f)) {
- BasicText(
- if (saveUri != null) stringResource(R.string.settings_custom_directory) else stringResource(R.string.settings_default_directory),
- style = TextStyle(label, 14.sp, fontWeight = FontWeight.SemiBold)
+ // ── File Handling ──
+ SettingsSection(backdrop, uiSensor, entrance.sectionFade(4), gap = 4.dp) {
+ SettingsSectionHeader(Icons.Rounded.Description, stringResource(R.string.settings_file_handling), ink, bottomPad = 8.dp)
+ SettingsToggleRow(
+ icon = Icons.Rounded.Compress,
+ 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
)
- val path = if (saveUri != null) {
- saveUri!!.lastPathSegment?.replace("primary:", "") ?: saveUri.toString()
- } else stringResource(R.string.settings_default_path)
- BasicText(path, style = TextStyle(sub, 12.sp))
- }
- }
-
- Row(
- Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- LiquidButton(
- onClick = { folderPicker.launch(null) },
- backdrop = backdrop,
- tint = LiquidGlassColors.Teal,
- modifier = Modifier.weight(1f)
- ) {
- BasicText(stringResource(R.string.settings_change_folder), style = TextStyle(Color.White, 13.sp, fontWeight = FontWeight.SemiBold))
- }
- if (saveUri != null) {
- LiquidButton(
- onClick = {
- SaveLocationManager.clearSaveLocation(context)
- saveUri = null
+ SettingsDivider(isLight)
+ SettingsToggleRow(
+ icon = Icons.Rounded.FileCopy,
+ 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
+ )
+ SettingsDivider(isLight)
+ SettingsToggleRow(
+ icon = Icons.Rounded.Description,
+ title = stringResource(R.string.settings_remember_recent_files),
+ desc = stringResource(R.string.settings_remember_recent_files_desc),
+ checked = rememberRecentFiles,
+ onCheckedChange = { rememberRecentFiles = it; AppSettingsManager.setRememberRecentFiles(context, it) },
+ backdrop = backdrop
+ )
+ SettingsDivider(isLight)
+ SettingsToggleRow(
+ icon = Icons.Rounded.FolderOpen,
+ title = stringResource(R.string.settings_keep_local_copies),
+ desc = stringResource(R.string.settings_keep_local_copies_desc),
+ checked = keepLocalCopies,
+ onCheckedChange = {
+ keepLocalCopies = it
+ settingsScope.launch(Dispatchers.IO) { AppSettingsManager.setKeepLocalCopies(context, it) }
},
- backdrop = backdrop,
- tint = LiquidGlassColors.Orange
- ) {
- BasicText(stringResource(R.string.settings_reset), style = TextStyle(Color.White, 13.sp, fontWeight = FontWeight.SemiBold))
- }
- }
- }
- }
- }
-
- // ── File Handling ──
- item(key = "settings-section-4") {
- Column(
- Modifier
- .fillMaxWidth()
- .graphicsLayer {
- alpha = panel3Alpha
- translationY = panel3OffsetY * density
+ backdrop = backdrop
+ )
}
- .liquidGlassSection(isLight)
- .padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Row(
- Modifier.padding(bottom = 8.dp),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- Icon(Icons.Rounded.Description, null, Modifier.size(22.dp), label)
- BasicText(stringResource(R.string.settings_file_handling), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
- }
-
- SettingsToggleRow(
- icon = Icons.Rounded.Compress,
- 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,
- labelColor = label,
- subColor = sub
- )
-
- // Separator
- Box(
- Modifier.fillMaxWidth().padding(vertical = 4.dp).height(1.dp)
- .background(if (isLight) Color.Black.copy(0.04f) else Color.White.copy(0.06f))
- )
-
- SettingsToggleRow(
- icon = Icons.Rounded.FileCopy,
- 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,
- labelColor = label,
- subColor = sub
- )
-
- Box(
- Modifier.fillMaxWidth().padding(vertical = 4.dp).height(1.dp)
- .background(if (isLight) Color.Black.copy(0.04f) else Color.White.copy(0.06f))
- )
-
- SettingsToggleRow(
- icon = Icons.Rounded.Description,
- title = stringResource(R.string.settings_remember_recent_files),
- desc = stringResource(R.string.settings_remember_recent_files_desc),
- checked = rememberRecentFiles,
- onCheckedChange = {
- rememberRecentFiles = it
- AppSettingsManager.setRememberRecentFiles(context, it)
- },
- backdrop = backdrop,
- labelColor = label,
- subColor = sub
- )
- SettingsToggleRow(
- icon = Icons.Rounded.FolderOpen,
- title = stringResource(R.string.settings_keep_local_copies),
- desc = stringResource(R.string.settings_keep_local_copies_desc),
- checked = keepLocalCopies,
- onCheckedChange = {
- keepLocalCopies = it
- settingsScope.launch(Dispatchers.IO) {
- AppSettingsManager.setKeepLocalCopies(context, it)
+ // ── Default Quality ──
+ SettingsSection(backdrop, uiSensor, entrance.sectionFade(5)) {
+ Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween) {
+ SettingsSectionHeader(Icons.Rounded.HighQuality, stringResource(R.string.settings_compression_quality), LiquidGlassColors.Blue, bottomPad = 0.dp)
+ Box(
+ Modifier.clip(RoundedCornerShape(8.dp)).background(LiquidGlassColors.Blue.copy(0.14f)).padding(horizontal = 10.dp, vertical = 4.dp)
+ ) {
+ BasicText("${(defaultQuality * 100).toInt()}%", style = TextStyle(LiquidGlassColors.Blue, 13.sp, FontWeight.Bold))
+ }
}
- },
- backdrop = backdrop,
- labelColor = label,
- subColor = sub
- )
-
- }
- }
-
- // ── Default Quality ──
- item(key = "settings-section-5") {
- Column(
- Modifier
- .fillMaxWidth()
- .graphicsLayer {
- alpha = panel4Alpha
- translationY = panel4OffsetY * density
- }
- .liquidGlassSection(isLight)
- .padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(14.dp)
- ) {
- Row(
- Modifier.fillMaxWidth(),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.SpaceBetween
- ) {
- Row(
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- Icon(Icons.Rounded.HighQuality, null, Modifier.size(22.dp), LiquidGlassColors.Blue)
- BasicText(stringResource(R.string.settings_compression_quality), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
- }
- Box(
- Modifier
- .clip(RoundedCornerShape(8.dp))
- .background(LiquidGlassColors.Blue.copy(0.14f))
- .padding(horizontal = 10.dp, vertical = 4.dp)
- ) {
- BasicText(
- "${(defaultQuality * 100).toInt()}%",
- style = TextStyle(LiquidGlassColors.Blue, 13.sp, fontWeight = FontWeight.Bold)
+ LiquidSlider(
+ value = { defaultQuality },
+ onValueChange = { defaultQuality = ((it * 100f).toInt() / 100f).coerceIn(0f, 1f) },
+ valueRange = 0f..1f,
+ visibilityThreshold = 0.005f,
+ backdrop = backdrop,
+ modifier = Modifier.fillMaxWidth()
)
- }
- }
-
- LiquidSlider(
- value = { defaultQuality },
- onValueChange = {
- val snapped = ((it * 100f).toInt() / 100f).coerceIn(0f, 1f)
- if (snapped != defaultQuality) {
- defaultQuality = snapped
+ Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
+ 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))
}
- },
- valueRange = 0f..1f,
- visibilityThreshold = 0.005f,
- backdrop = backdrop,
- modifier = Modifier.fillMaxWidth()
- )
-
- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
- 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))
- }
- }
- }
-
- // ── Personalization ──
- item(key = "settings-section-6") {
- Column(
- Modifier
- .fillMaxWidth()
- .graphicsLayer {
- alpha = panel4Alpha
- translationY = panel4OffsetY * density
}
- .liquidGlassSection(isLight)
- .padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- Row(
- Modifier.padding(bottom = 8.dp),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- Icon(Icons.Rounded.Wallpaper, null, Modifier.size(22.dp), label)
- BasicText(stringResource(R.string.settings_personalization), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
- }
-
- SettingsToggleRow(
- icon = Icons.Rounded.Wallpaper,
- title = stringResource(R.string.settings_background),
- desc = stringResource(R.string.settings_background_desc),
- checked = showWallpaper,
- onCheckedChange = onShowWallpaperChanged,
- backdrop = backdrop,
- labelColor = label,
- subColor = sub
- )
- // When the background is on, let the user pick a custom image + reset to default.
- if (showWallpaper) {
- Row(
- Modifier.fillMaxWidth().padding(top = 8.dp, start = 46.dp),
- horizontalArrangement = Arrangement.spacedBy(10.dp),
- verticalAlignment = Alignment.CenterVertically
- ) {
- LiquidButton(
- onClick = { wallpaperPicker.launch(arrayOf("image/*")) },
- backdrop = backdrop,
- tint = LiquidGlassColors.Indigo,
- modifier = Modifier.weight(1f)
- ) {
+ // ── Personalization ──
+ SettingsSection(backdrop, uiSensor, entrance.sectionFade(6), gap = 4.dp) {
+ SettingsSectionHeader(Icons.Rounded.Wallpaper, stringResource(R.string.settings_personalization), ink, bottomPad = 8.dp)
+ SettingsToggleRow(
+ icon = Icons.Rounded.Wallpaper,
+ title = stringResource(R.string.settings_background),
+ desc = stringResource(R.string.settings_background_desc),
+ checked = showWallpaper,
+ onCheckedChange = onShowWallpaperChanged,
+ backdrop = backdrop
+ )
+ if (showWallpaper) {
Row(
- horizontalArrangement = Arrangement.spacedBy(6.dp, Alignment.CenterHorizontally),
- verticalAlignment = Alignment.CenterVertically,
- modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp)
+ Modifier.fillMaxWidth().padding(top = 8.dp, start = 46.dp),
+ horizontalArrangement = Arrangement.spacedBy(10.dp),
+ verticalAlignment = Alignment.CenterVertically
) {
- Icon(Icons.Rounded.PhotoLibrary, null, Modifier.size(16.dp), Color.White)
- BasicText(stringResource(R.string.settings_bg_gallery), style = TextStyle(Color.White, 13.sp, fontWeight = FontWeight.SemiBold), maxLines = 1)
+ ToolPrimaryButton(
+ text = stringResource(R.string.settings_bg_gallery),
+ onClick = { wallpaperPicker.launch(arrayOf("image/*")) },
+ backdrop = backdrop,
+ accent = LiquidGlassColors.Indigo,
+ icon = Icons.Rounded.PhotoLibrary,
+ modifier = Modifier.weight(1f)
+ )
+ LiquidIconButton(
+ onClick = { AppSettingsManager.clearCustomWallpaper(context); onCustomWallpaperChanged(null) },
+ backdrop = backdrop,
+ modifier = Modifier.size(44.dp)
+ ) {
+ Icon(Icons.Rounded.Refresh, stringResource(R.string.settings_reset), Modifier.size(18.dp), if (hasCustomWallpaper) ink else ink.copy(0.4f))
+ }
}
}
- LiquidIconButton(
- onClick = { AppSettingsManager.clearCustomWallpaper(context); onCustomWallpaperChanged(null) },
+ Spacer(Modifier.height(12.dp))
+ ToolPrimaryButton(
+ text = stringResource(R.string.settings_replay_onboarding),
+ onClick = onReplayOnboarding,
backdrop = backdrop,
- surfaceColor = if (isLight) Color.Black.copy(0.06f) else Color.White.copy(0.10f),
- modifier = Modifier.size(44.dp)
- ) {
- Icon(Icons.Rounded.Refresh, stringResource(R.string.settings_reset), Modifier.size(18.dp), if (hasCustomWallpaper) label else label.copy(0.4f))
- }
- }
- }
-
- // Replaying the tour also clears the completion flag (see the nav graph), so quitting
- // the replay early does not leave it marked as seen-but-never-finished.
- Spacer(Modifier.height(12.dp))
- LiquidButton(
- onClick = onReplayOnboarding,
- backdrop = backdrop,
- tint = LiquidGlassColors.Purple,
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- Modifier.fillMaxWidth(),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- Icon(Icons.Rounded.AutoAwesome, null, Modifier.size(18.dp), Color.White)
- Column(Modifier.weight(1f)) {
- BasicText(
- stringResource(R.string.settings_replay_onboarding),
- style = TextStyle(Color.White, 14.sp, fontWeight = FontWeight.SemiBold),
- maxLines = 1, overflow = TextOverflow.Ellipsis
- )
- BasicText(
- stringResource(R.string.settings_replay_onboarding_desc),
- style = TextStyle(Color.White.copy(0.8f), 12.sp),
- maxLines = 1, overflow = TextOverflow.Ellipsis
- )
- }
- }
- }
- }
- }
-
- // ── About & Open Source ──
- item(key = "settings-section-7") {
- Column(
- Modifier
- .fillMaxWidth()
- .graphicsLayer {
- alpha = panel5Alpha
- translationY = panel5OffsetY * density
- }
- .liquidGlassSection(isLight)
- .padding(24.dp),
- horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(12.dp)
- ) {
- Box(
- Modifier.size(56.dp).clip(CircleShape)
- .background(LiquidGlassColors.Blue.copy(0.12f)),
- contentAlignment = Alignment.Center
- ) {
- Icon(Icons.Rounded.Info, null, Modifier.size(28.dp), LiquidGlassColors.Blue)
- }
- BasicText("ClearPDF", style = TextStyle(text, 20.sp, fontWeight = FontWeight.Bold))
- BasicText(stringResource(R.string.settings_version), style = TextStyle(sub, 13.sp))
- BasicText(
- stringResource(R.string.settings_made_by),
- style = TextStyle(sub, 13.sp, textAlign = TextAlign.Center)
- )
-
- Spacer(Modifier.height(4.dp))
-
- // Star CTA
- LiquidButton(
- onClick = openRepo,
- backdrop = backdrop,
- tint = Color(0xFFFFC107),
- modifier = Modifier.fillMaxWidth()
- ) {
- Row(
- horizontalArrangement = Arrangement.spacedBy(8.dp),
- verticalAlignment = Alignment.CenterVertically
- ) {
- Icon(Icons.Rounded.Star, null, Modifier.size(18.dp), Color.White)
- BasicText(stringResource(R.string.settings_star_github), style = TextStyle(Color.White, 14.sp, fontWeight = FontWeight.SemiBold))
+ accent = LiquidGlassColors.Purple,
+ icon = Icons.Rounded.AutoAwesome,
+ modifier = Modifier.fillMaxWidth()
+ )
}
- }
-
- BasicText(
- stringResource(R.string.settings_open_source),
- style = TextStyle(sub.copy(0.7f), 11.sp, textAlign = TextAlign.Center)
- )
- }
- }
- // ── Office engine (optional, powered by LibreOffice) ──
- item(key = "settings-office-engine") {
- OfficeEngineSettingsSection(
- backdrop = backdrop,
- isLight = isLight,
- textColor = text,
- labelColor = label,
- subColor = sub,
- onRequestDelete = { officeEngineDeleteSize = it },
- modifier = Modifier
- .bringIntoViewRequester(officeEngineRequester)
- .fillMaxWidth()
- .graphicsLayer {
- alpha = panel5Alpha
- translationY = panel5OffsetY * density
+ // ── About & Open Source ──
+ SettingsSection(backdrop, uiSensor, entrance.sectionFade(7), padding = 24.dp, horizontalAlignment = Alignment.CenterHorizontally) {
+ AccentIconTile(Icons.Rounded.Info, LiquidGlassColors.Blue, size = 56, iconSize = 28)
+ BasicText("ClearPDF", style = TextStyle(ink, 20.sp, FontWeight.Bold))
+ BasicText(stringResource(R.string.settings_version), style = TextStyle(sub, 13.sp))
+ BasicText(stringResource(R.string.settings_made_by), style = TextStyle(sub, 13.sp, textAlign = TextAlign.Center))
+ Spacer(Modifier.height(4.dp))
+ ToolPrimaryButton(
+ text = stringResource(R.string.settings_star_github),
+ onClick = openRepo,
+ backdrop = backdrop,
+ accent = ToolAccents.Star,
+ icon = Icons.Rounded.Star,
+ modifier = Modifier.fillMaxWidth()
+ )
+ BasicText(stringResource(R.string.settings_open_source), style = TextStyle(sub.copy(0.7f), 11.sp, textAlign = TextAlign.Center))
}
- .liquidGlassSection(isLight)
- .padding(20.dp)
- )
- }
- // ── Licenses ──
- item(key = "settings-section-8") {
- Column(
- Modifier
- .fillMaxWidth()
- .graphicsLayer {
- alpha = panel6Alpha
- translationY = panel6OffsetY * density
- }
- .liquidGlassSection(isLight)
- .padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(12.dp)
- ) {
- Row(
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- Icon(Icons.Rounded.Code, null, Modifier.size(22.dp), label)
- BasicText(stringResource(R.string.settings_licenses), style = TextStyle(text, 17.sp, fontWeight = FontWeight.SemiBold))
- }
+ // ── Office engine (optional, powered by LibreOffice) ──
+ OfficeEngineSettingsSection(
+ backdrop = backdrop,
+ isLight = isLight,
+ textColor = ink,
+ labelColor = ink,
+ subColor = sub,
+ onRequestDelete = { officeEngineDeleteSize = it },
+ modifier = Modifier
+ .bringIntoViewRequester(officeEngineRequester)
+ .fillMaxWidth()
+ .then(entrance.sectionFade(8))
+ .liquidGlassPanel(backdrop, uiSensor)
+ .padding(20.dp)
+ )
- // Everything third-party that ships inside the app. This is the attribution the
- // Apache-2.0 and BSD notices actually require, so it has to list what the build really
- // pulls in — not just the two entries it started with. THIRD_PARTY_NOTICES.md carries
- // the full text; keep the two in step when a dependency is added or dropped.
- OpenSourceCredits.forEachIndexed { index, credit ->
- if (index > 0) {
- Box(
- Modifier.fillMaxWidth().height(1.dp)
- .background(if (isLight) Color.Black.copy(0.04f) else Color.White.copy(0.06f))
- )
+ // ── Licenses ──
+ SettingsSection(backdrop, uiSensor, entrance.sectionFade(9)) {
+ SettingsSectionHeader(Icons.Rounded.Code, stringResource(R.string.settings_licenses), ink)
+ OpenSourceCredits.forEachIndexed { index, credit ->
+ if (index > 0) SettingsDivider(isLight)
+ LicenseItem(credit.name, credit.author, credit.license, credit.url, ink, sub)
+ }
+ SettingsDivider(isLight)
+ BasicText(stringResource(R.string.settings_license_notice), style = TextStyle(sub.copy(0.7f), 11.sp, lineHeight = 16.sp))
}
- LicenseItem(
- name = credit.name,
- author = credit.author,
- license = credit.license,
- url = credit.url,
- labelColor = label,
- subColor = sub
- )
}
-
- Box(
- Modifier.fillMaxWidth().height(1.dp)
- .background(if (isLight) Color.Black.copy(0.04f) else Color.White.copy(0.06f))
- )
-
- BasicText(
- stringResource(R.string.settings_license_notice),
- style = TextStyle(sub.copy(0.7f), 11.sp, lineHeight = 16.sp)
- )
}
- }
-
- }
-
}
// Outside the scaffold's captured layer so it refracts the live screen (wallpaper + content).
GlassDialog(
@@ -865,136 +480,84 @@ fun SettingsScreen(
backdrop = screenBackdrop.glass,
title = stringResource(R.string.office_engine_delete_title),
actions = {
- GlassDialogAction(
- text = stringResource(R.string.office_engine_cancel),
- onClick = { officeEngineDeleteSize = null }
- )
+ GlassDialogAction(text = stringResource(R.string.office_engine_cancel), onClick = { officeEngineDeleteSize = null })
GlassDialogAction(
text = stringResource(R.string.office_engine_delete),
- onClick = {
- officeEngineDeleteSize = null
- OfficeEngine.installer(context).uninstall()
- },
+ onClick = { officeEngineDeleteSize = null; OfficeEngine.installer(context).uninstall() },
primary = true,
destructive = true
)
}
) {
BasicText(
- stringResource(
- R.string.office_engine_delete_message,
- android.text.format.Formatter.formatShortFileSize(context, officeEngineDeleteSize ?: 0L)
- ),
- style = TextStyle(LiquidGlassColors.text(!isLight), 14.sp, lineHeight = 20.sp)
+ stringResource(R.string.office_engine_delete_message, android.text.format.Formatter.formatShortFileSize(context, officeEngineDeleteSize ?: 0L)),
+ style = TextStyle(ink, 14.sp, lineHeight = 20.sp)
)
}
- }
}
-private class Credit(val name: String, val author: String, val license: String, val url: String)
+/** One stagger step, matching ToolsScreen's own cadence. */
+private const val SettingsStaggerStepMs = 45
-/**
- * Ordered roughly by how much of the app each one carries.
- *
- * Note what is *not* here: the .xlsx reader and the PowerPoint slide renderer are written in this
- * repo against the published OOXML layout, not borrowed. That was a size decision — the libraries
- * that read Office formats properly on Android (POI's OOXML half plus XmlBeans at ~17 MB, or
- * OpenDocument.core's 100 MB AAR) are far more than this app can carry for a viewer. POI appears
- * below only for the *legacy* binary .doc/.xls/.ppt formats, which are not XML and cannot be read
- * this way. Word layout is the one place a library won on merit: docx-preview delegates to the
- * browser engine the phone already has, so it costs ~48 KB rather than tens of megabytes.
- */
-private val OpenSourceCredits = listOf(
- Credit(
- "AndroidLiquidGlass", "Kyant",
- "Apache License 2.0",
- "https://github.com/Kyant0/AndroidLiquidGlass"
- ),
- Credit(
- "PdfBox-Android", "Tom Roush",
- "Apache License 2.0 — PDF text, forms and annotation export",
- "https://github.com/TomRoush/PdfBox-Android"
- ),
- Credit(
- "Apache POI", "The Apache Software Foundation",
- "Apache License 2.0 — legacy .doc / .xls / .ppt reading",
- "https://poi.apache.org"
- ),
- Credit(
- "ML Kit Text Recognition", "Google",
- "Apache License 2.0 — bundled on-device OCR, no network",
- "https://developers.google.com/ml-kit/vision/text-recognition"
- ),
- Credit(
- "Tesseract4Android", "Adaptech s.r.o.",
- "Apache License 2.0 — offline OCR fallback",
- "https://github.com/adaptech-cz/Tesseract4Android"
- ),
- Credit(
- "Tesseract OCR", "Google / Tesseract contributors",
- "Apache License 2.0",
- "https://github.com/tesseract-ocr/tesseract"
- ),
- Credit(
- "Leptonica", "Dan Bloomberg",
- "BSD 2-Clause — image processing behind Tesseract",
- "https://github.com/DanBloomberg/leptonica"
- ),
- Credit(
- "docx-preview", "Volodymyr Baydalka",
- "Apache License 2.0 — Word document layout",
- "https://github.com/VolodymyrBaydalka/docxjs"
- ),
- Credit(
- "JSZip", "Stuart Knightley",
- "MIT License (used under MIT of its MIT/GPLv3 dual licence)",
- "https://github.com/Stuk/jszip"
- ),
- Credit(
- "ImageToolbox", "T8RIN (Malik Mukhametzyanov)",
- "Apache License 2.0 — image editor cropper, perspective crop and draw engine (adapted)",
- "https://github.com/T8RIN/ImageToolbox"
- ),
- Credit(
- "GPUImage for Android", "CyberAgent, Inc.",
- "Apache License 2.0 — image editor adjustments and filters",
- "https://github.com/cats-oss/android-gpuimage"
- ),
- Credit(
- "ML Kit Subject Segmentation", "Google",
- "Google APIs Terms — optional background removal via Play services",
- "https://developers.google.com/ml-kit/vision/subject-segmentation"
- ),
- Credit(
- "LibreOffice", "The Document Foundation",
- "Mozilla Public License 2.0 — optional Office engine (downloaded on request, not bundled)",
- "https://www.libreoffice.org/about-us/licenses/"
- ),
- Credit(
- "Pdf_Tools", "Karna14314",
- "PDF viewer zoom/pan reference",
- "https://github.com/Karna14314/Pdf_Tools"
+/** Fade-only entrance for a glass section — translating a `liquidGlassPanel` re-samples its backdrop
+ * every frame of the slide, which is the jank this replaces (see ToolsScreen's own note). */
+@Composable
+private fun Transition<Boolean>.sectionFade(index: Int): Modifier {
+ val fadeAlpha by animateFloat(
+ transitionSpec = { tween(durationMillis = 320, delayMillis = SettingsStaggerStepMs * index, easing = FastOutSlowInEasing) },
+ label = "settingsFade$index"
+ ) { if (it) 1f else 0f }
+ return Modifier.alpha(fadeAlpha)
+}
+
+/** One glass panel, built from [liquidGlassPanel] exactly like every tool screen's own sections. */
+@Composable
+private fun SettingsSection(
+ backdrop: Backdrop,
+ uiSensor: com.chethan616.clearpdf.ui.utils.UISensor,
+ entranceModifier: Modifier,
+ padding: androidx.compose.ui.unit.Dp = 20.dp,
+ gap: androidx.compose.ui.unit.Dp = 16.dp,
+ horizontalAlignment: Alignment.Horizontal = Alignment.Start,
+ content: @Composable androidx.compose.foundation.layout.ColumnScope.() -> Unit
+) {
+ Column(
+ Modifier
+ .fillMaxWidth()
+ .then(entranceModifier)
+ .liquidGlassPanel(backdrop, uiSensor)
+ .padding(padding),
+ verticalArrangement = Arrangement.spacedBy(gap),
+ horizontalAlignment = horizontalAlignment,
+ content = content
)
-)
+}
+
+@Composable
+private fun SettingsSectionHeader(icon: ImageVector, title: String, tint: Color, bottomPad: androidx.compose.ui.unit.Dp = 0.dp) {
+ Row(
+ Modifier.padding(bottom = bottomPad),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(8.dp)
+ ) {
+ Icon(icon, null, Modifier.size(22.dp), tint)
+ BasicText(title, style = TextStyle(ToolInk.text(), 17.sp, FontWeight.SemiBold))
+ }
+}
-private fun Modifier.liquidGlassSection(isLight: Boolean): Modifier {
- val containerColor = if (isLight) Color.White.copy(0.68f) else Color(0xFF161820).copy(0.72f)
- val borderColor = if (isLight) Color.White.copy(0.80f) else Color.White.copy(0.12f)
- return this
- .clip(RoundedCornerShape(24.dp))
- .background(containerColor)
- .border(1.dp, borderColor, RoundedCornerShape(24.dp))
+@Composable
+private fun SettingsDivider(isLight: Boolean) {
+ Box(Modifier.fillMaxWidth().padding(vertical = 4.dp).height(1.dp).background(if (isLight) Color.Black.copy(0.04f) else Color.White.copy(0.06f)))
}
private fun openExternalLink(context: Context, url: String) {
runCatching {
- val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply {
- addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- }
- context.startActivity(intent)
+ context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
}
}
+/** A row's accent icon badge + title/description + [LiquidToggle] — the same icon-tile language
+ * [AccentIconTile] uses, just sized for a list row instead of a hero card. */
@Composable
private fun SettingsToggleRow(
icon: ImageVector,
@@ -1002,66 +565,71 @@ private fun SettingsToggleRow(
desc: String,
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
- backdrop: LayerBackdrop,
- labelColor: Color,
- subColor: Color
+ backdrop: Backdrop
) {
+ val ink = ToolInk.text()
+ val sub = ToolInk.secondary()
Row(
Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(12.dp))
- .clickable { onCheckedChange(!checked) }
+ .clickable(interactionSource = remember { MutableInteractionSource() }, indication = null) { onCheckedChange(!checked) }
.padding(vertical = 6.dp, horizontal = 4.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp)
) {
- Box(
- Modifier.size(34.dp).clip(CircleShape)
- .background(labelColor.copy(0.08f)),
- contentAlignment = Alignment.Center
- ) {
- Icon(icon, null, Modifier.size(18.dp), labelColor)
- }
+ AccentIconTile(icon, LiquidGlassColors.Blue, size = 34, iconSize = 17)
Column(Modifier.weight(1f)) {
- BasicText(title, style = TextStyle(labelColor, 15.sp, fontWeight = FontWeight.Medium))
- BasicText(desc, style = TextStyle(subColor, 12.sp))
+ BasicText(title, style = TextStyle(ink, 15.sp, FontWeight.Medium))
+ BasicText(desc, style = TextStyle(sub, 12.sp))
}
- LiquidToggle(
- selected = { checked },
- onSelect = onCheckedChange,
- backdrop = backdrop
- )
+ LiquidToggle(selected = { checked }, onSelect = onCheckedChange, backdrop = backdrop)
}
}
+private class Credit(val name: String, val author: String, val license: String, val url: String)
+
+/**
+ * Ordered roughly by how much of the app each one carries.
+ *
+ * Note what is *not* here: the .xlsx reader and the PowerPoint slide renderer are written in this
+ * repo against the published OOXML layout, not borrowed. That was a size decision — the libraries
+ * that read Office formats properly on Android (POI's OOXML half plus XmlBeans at ~17 MB, or
+ * OpenDocument.core's 100 MB AAR) are far more than this app can carry for a viewer. POI appears
+ * below only for the *legacy* binary .doc/.xls/.ppt formats, which are not XML and cannot be read
+ * this way. Word layout is the one place a library won on merit: docx-preview delegates to the
+ * browser engine the phone already has, so it costs ~48 KB rather than tens of megabytes.
+ */
+private val OpenSourceCredits = listOf(
+ Credit("AndroidLiquidGlass", "Kyant", "Apache License 2.0", "https://github.com/Kyant0/AndroidLiquidGlass"),
+ Credit("PdfBox-Android", "Tom Roush", "Apache License 2.0 — PDF text, forms and annotation export", "https://github.com/TomRoush/PdfBox-Android"),
+ Credit("Apache POI", "The Apache Software Foundation", "Apache License 2.0 — legacy .doc / .xls / .ppt reading", "https://poi.apache.org"),
+ Credit("ML Kit Text Recognition", "Google", "Apache License 2.0 — bundled on-device OCR, no network", "https://developers.google.com/ml-kit/vision/text-recognition"),
+ Credit("Tesseract4Android", "Adaptech s.r.o.", "Apache License 2.0 — offline OCR fallback", "https://github.com/adaptech-cz/Tesseract4Android"),
+ Credit("Tesseract OCR", "Google / Tesseract contributors", "Apache License 2.0", "https://github.com/tesseract-ocr/tesseract"),
+ Credit("Leptonica", "Dan Bloomberg", "BSD 2-Clause — image processing behind Tesseract", "https://github.com/DanBloomberg/leptonica"),
+ Credit("docx-preview", "Volodymyr Baydalka", "Apache License 2.0 — Word document layout", "https://github.com/VolodymyrBaydalka/docxjs"),
+ Credit("JSZip", "Stuart Knightley", "MIT License (used under MIT of its MIT/GPLv3 dual licence)", "https://github.com/Stuk/jszip"),
+ Credit("ImageToolbox", "T8RIN (Malik Mukhametzyanov)", "Apache License 2.0 — image editor cropper, perspective crop and draw engine (adapted)", "https://github.com/T8RIN/ImageToolbox"),
+ Credit("GPUImage for Android", "CyberAgent, Inc.", "Apache License 2.0 — image editor adjustments and filters", "https://github.com/cats-oss/android-gpuimage"),
+ Credit("ML Kit Subject Segmentation", "Google", "Google APIs Terms — optional background removal via Play services", "https://developers.google.com/ml-kit/vision/subject-segmentation"),
+ Credit("LibreOffice", "The Document Foundation", "Mozilla Public License 2.0 — optional Office engine (downloaded on request, not bundled)", "https://www.libreoffice.org/about-us/licenses/"),
+ Credit("Pdf_Tools", "Karna14314", "PDF viewer zoom/pan reference", "https://github.com/Karna14314/Pdf_Tools")
+)
+
@Composable
-private fun LicenseItem(
- name: String,
- author: String,
- license: String,
- url: String,
- labelColor: Color,
- subColor: Color
-) {
+private fun LicenseItem(name: String, author: String, license: String, url: String, labelColor: Color, subColor: Color) {
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
- Row(
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(6.dp)
- ) {
- BasicText(name, style = TextStyle(labelColor, 14.sp, fontWeight = FontWeight.Medium))
+ Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
+ BasicText(name, style = TextStyle(labelColor, 14.sp, FontWeight.Medium))
BasicText(stringResource(R.string.settings_license_author, author), style = TextStyle(subColor, 12.sp))
}
BasicText(license, style = TextStyle(subColor, 11.sp))
val context = LocalContext.current
- // Same blue URL text, now a tap target that opens the repo. No indication/ripple so the row
- // looks exactly as before — only its behaviour changes.
BasicText(
url,
style = TextStyle(LiquidGlassColors.Blue, 11.sp),
- modifier = Modifier.clickable(
- interactionSource = remember { MutableInteractionSource() },
- indication = null
- ) { openExternalLink(context, url) }
+ modifier = Modifier.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null) { openExternalLink(context, url) }
)
}
}
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/theme/ThemeState.kt b/app/src/main/java/com/chethan616/clearpdf/ui/theme/ThemeState.kt
index 5bdc85e..5bba9c7 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/theme/ThemeState.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/theme/ThemeState.kt
@@ -7,3 +7,11 @@ import androidx.compose.runtime.compositionLocalOf
* Allows all composables to access the current theme without prop drilling.
*/
val LocalIsDarkMode = compositionLocalOf { false }
+
+/**
+ * Opt-in "Reduce glass motion" (Settings → Appearance, #53). `false` by default — full glass. When
+ * `true`, [com.chethan616.clearpdf.ui.utils.rememberUISensor] freezes the gravity-tracked specular
+ * highlight that every `liquidGlassPanel` reads, instead of threading an explicit parameter through
+ * every one of its call sites across the app.
+ */
+val LocalReducedGlassMotion = compositionLocalOf { false }
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/utils/UISensor.kt b/app/src/main/java/com/chethan616/clearpdf/ui/utils/UISensor.kt
index 961cf4c..e207859 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/utils/UISensor.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/utils/UISensor.kt
@@ -35,10 +35,14 @@ fun rememberUISensor(): UISensor {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
val uiSensor = remember { UISensor(context) }
- DisposableEffect(lifecycleOwner, uiSensor) {
+ // Settings -> Appearance -> "Reduce glass motion" (#53): with it on, the sensor simply never
+ // starts, so gravityAngle holds its fixed default and every liquidGlassPanel/capsule that reads
+ // it in draw stops re-publishing (and re-running blur+lens) on tilt. Off by default -- full glass.
+ val reducedMotion = com.chethan616.clearpdf.ui.theme.LocalReducedGlassMotion.current
+ DisposableEffect(lifecycleOwner, uiSensor, reducedMotion) {
val observer = LifecycleEventObserver { _, event ->
when (event) {
- Lifecycle.Event.ON_RESUME -> uiSensor.start()
+ Lifecycle.Event.ON_RESUME -> if (!reducedMotion) uiSensor.start()
Lifecycle.Event.ON_PAUSE -> uiSensor.stop()
else -> Unit
}
@@ -46,6 +50,7 @@ fun rememberUISensor(): UISensor {
// addObserver replays the events up to the current state, so an already-resumed screen
// starts listening immediately.
lifecycleOwner.lifecycle.addObserver(observer)
+ if (reducedMotion) uiSensor.stop()
onDispose {
lifecycleOwner.lifecycle.removeObserver(observer)
uiSensor.stop()
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9e8edc8..33af1ff 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -179,6 +179,8 @@
<string name="settings_theme_auto_desc">Follow system settings</string>
<string name="settings_theme_light_desc">Always use light theme</string>
<string name="settings_theme_dark_desc">Always use dark theme</string>
+ <string name="settings_reduce_glass_motion">Reduce glass motion</string>
+ <string name="settings_reduce_glass_motion_desc">Freezes the glass highlight that tracks the phone\'s tilt, for devices that feel it</string>
<string name="settings_save_location">Save Location</string>
<string name="settings_save_downloads">Downloads</string>
<string name="settings_save_custom">Custom Folder</string>
@@ -333,6 +335,7 @@
<string name="language_portuguese">Portuguese</string>
<string name="language_spanish">Spanish</string>
<string name="language_italian">Italian</string>
+ <string name="language_russian">Russian</string>
<string name="recents_open">Open</string>
<string name="recents_share">Share</string>
<string name="recents_details">Details</string>