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.

Improve UI performance and community readiness

Chethan616bfc1458c98cf
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
new file mode 100644
index 0000000..22588a4
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,47 @@
+name: Bug report
+description: Report a reproducible problem in ClearPDF.
+title: "[Bug]: "
+labels: [bug]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Thanks for helping improve ClearPDF. Please remove private PDF content and personal data from logs or screenshots.
+ - type: input
+ id: version
+ attributes:
+ label: ClearPDF version
+ placeholder: "1.1.0"
+ validations:
+ required: true
+ - type: input
+ id: device
+ attributes:
+ label: Device and Android version
+ placeholder: "Pixel 7, Android 15"
+ validations:
+ required: true
+ - type: textarea
+ id: steps
+ attributes:
+ label: Steps to reproduce
+ placeholder: "1. Open... 2. Tap... 3. ..."
+ validations:
+ required: true
+ - type: textarea
+ id: expected
+ attributes:
+ label: Expected behavior
+ validations:
+ required: true
+ - type: textarea
+ id: actual
+ attributes:
+ label: Actual behavior
+ validations:
+ required: true
+ - type: textarea
+ id: extra
+ attributes:
+ label: Logs or screenshots
+ description: Remove private document content, names, paths, and tokens.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
new file mode 100644
index 0000000..081ed50
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -0,0 +1,31 @@
+name: Feature request
+description: Suggest an improvement that fits ClearPDF's offline-first mission.
+title: "[Feature]: "
+labels: [enhancement]
+body:
+ - type: textarea
+ id: problem
+ attributes:
+ label: Problem to solve
+ description: What user workflow is difficult or missing today?
+ validations:
+ required: true
+ - type: textarea
+ id: proposal
+ attributes:
+ label: Proposed solution
+ validations:
+ required: true
+ - type: textarea
+ id: alternatives
+ attributes:
+ label: Alternatives considered
+ - type: checkboxes
+ id: principles
+ attributes:
+ label: Project principles
+ options:
+ - label: This can work offline and does not require ads, accounts, or cloud processing.
+ required: true
+ - label: I have checked for existing issues or pull requests.
+ required: true
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 0000000..898f289
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,22 @@
+## What changed?
+
+<!-- Describe the user problem and the solution. -->
+
+## How was it tested?
+
+- [ ] `./gradlew assembleDebug`
+- [ ] `./gradlew assembleRelease` (if applicable)
+- [ ] Manual testing on Android API/device:
+
+## UI changes
+
+<!-- Add screenshots or a short recording when the UI changes. -->
+
+## Checklist
+
+- [ ] No ads, analytics, accounts, cloud processing, or hidden network calls added.
+- [ ] Offline behavior remains usable.
+- [ ] Light and dark themes were checked.
+- [ ] Accessibility/content descriptions were considered.
+- [ ] No secrets, private documents, build outputs, or generated IDE files are included.
+- [ ] Dependency/license changes are documented.
diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml
new file mode 100644
index 0000000..2b0dd6a
--- /dev/null
+++ b/.github/workflows/android.yml
@@ -0,0 +1,26 @@
+name: Android build
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+
+permissions:
+ contents: read
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v4
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ distribution: temurin
+ java-version: '17'
+ cache: gradle
+ - name: Set up Gradle
+ uses: gradle/actions/setup-gradle@v4
+ - name: Build release variant
+ run: ./gradlew assembleRelease --stacktrace
diff --git a/.gitignore b/.gitignore
index 0f686c8..3b23ed2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,4 +56,7 @@ app/src/main/assets/adi-registration.properties
/ClearPDF-main/
# Local Claude Code config
-.claude/
\ No newline at end of file
+.claude/
+
+# Local graphify knowledge graph
+/graphify-out/
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..6e7b97c
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,26 @@
+# Code of Conduct
+
+## Our commitment
+
+ClearPDF is a small, welcoming open-source project. We want every contributor to feel safe, respected, and able to participate regardless of experience, background, identity, or device.
+
+## Expected behavior
+
+- Be respectful, constructive, and specific.
+- Assume good intent and ask questions before making judgments.
+- Share context when reporting bugs or proposing changes.
+- Give credit to other contributors and upstream projects.
+- Keep discussions focused on improving ClearPDF for users.
+
+## Unacceptable behavior
+
+- Harassment, discrimination, threats, personal attacks, or targeted hostility.
+- Publishing private information without permission.
+- Trolling, deliberate disruption, or repeated bad-faith behavior.
+- Submitting code or assets without the right to redistribute them.
+
+## Enforcement
+
+Please report a concern privately to the maintainers through the security contact described in [SECURITY.md](SECURITY.md). Reports will be reviewed promptly and handled confidentially where possible.
+
+This policy is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..6ddd247
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,59 @@
+# Contributing to ClearPDF
+
+Thanks for helping make ClearPDF a fast, private, offline-first PDF app.
+
+## Project principles
+
+- PDF data stays on the device. Do not add cloud processing, telemetry, ads, or account requirements.
+- Keep core PDF editing usable without an internet connection.
+- Prefer small, focused pull requests with clear user value.
+- Preserve accessibility, light/dark themes, and low-end device performance.
+- Respect the licenses and notices of every dependency and asset.
+
+## Before you start
+
+1. Search existing issues and pull requests.
+2. For larger changes, open an issue describing the problem and proposed direction.
+3. Do not include private documents, signing keys, `key.properties`, APKs, build outputs, or generated IDE files.
+
+## Local setup
+
+Requirements:
+
+- Android Studio with JDK 17 or newer.
+- Android SDK 36.
+- An Android device or emulator for UI changes.
+
+```bash
+git clone https://github.com/Chethan616/ClearPDF.git
+cd ClearPDF
+./gradlew assembleDebug
+```
+
+For a release-like build without signing credentials:
+
+```bash
+./gradlew assembleRelease
+```
+
+Release signing is intentionally local-only. Copy `key.properties.example` to `key.properties` only when you have your own signing credentials; never commit it.
+
+## Pull requests
+
+Please include:
+
+- What changed and why.
+- Screenshots or a short recording for UI changes.
+- Device/API level used for testing.
+- Manual test steps and any known limitations.
+- Updated documentation, notices, or tests when relevant.
+
+Keep commits focused and use an imperative subject, for example `Improve recent-file actions`.
+
+## Reporting bugs
+
+Use the bug report form and include the app version, Android version, device, reproduction steps, expected behavior, actual behavior, and logs with personal data removed.
+
+## Code style
+
+Use official Kotlin formatting, descriptive names, and existing project patterns. Avoid unrelated formatting churn. New dependencies need a clear justification, license compatibility, and an offline behavior review.
diff --git a/PRIVACY.md b/PRIVACY.md
new file mode 100644
index 0000000..5c58ac4
--- /dev/null
+++ b/PRIVACY.md
@@ -0,0 +1,23 @@
+# ClearPDF Privacy
+
+ClearPDF is designed to be an offline-first PDF utility for Android.
+
+## What ClearPDF does not do
+
+- It does not require an account.
+- It does not show ads.
+- It does not include analytics, telemetry, or crash-reporting services.
+- It does not intentionally upload PDFs or extracted content to a server.
+- The app does not request Android's `INTERNET` permission.
+
+## Files and permissions
+
+Files are opened or saved only when you choose them through Android's document picker or the app's export flow. Recent-file entries are stored locally on the device and can be removed from the home screen.
+
+## On-device scanning and text selection
+
+Scanning and text-selection features use the on-device Google ML Kit components listed in [`NOTICE`](NOTICE). ClearPDF does not intentionally send their input to a ClearPDF server. This dependency is disclosed so contributors can make informed decisions about builds and distribution.
+
+## Reporting a concern
+
+Please do not attach private PDFs or personal information to public issues. For a suspected security or privacy vulnerability, follow [`SECURITY.md`](SECURITY.md).
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000..de9d848
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,22 @@
+# Security Policy
+
+## Supported versions
+
+Security fixes are applied to the latest `main` branch and the newest published release.
+
+## Reporting a vulnerability
+
+Please do not open a public issue for a security vulnerability. Contact the maintainers privately through the GitHub security advisory flow for this repository.
+
+Include:
+
+- A short description and impact.
+- Affected version or commit.
+- Reproduction steps or a minimal proof of concept.
+- Any suggested mitigation.
+
+Please allow reasonable time for verification and a fix before public disclosure. Do not include personal documents, access tokens, private keys, or other sensitive data in a report.
+
+## Privacy expectations
+
+ClearPDF is designed to process PDFs locally. The app does not include ads, accounts, analytics, or cloud PDF processing. Scanner and text-selection features use the disclosed on-device ML Kit components; contributors must not add hidden data collection or network upload behavior.
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 9af8821..7c26184 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -61,8 +61,9 @@ android {
buildTypes {
release {
- signingConfig = signingConfigs.getByName("release")
- if (!hasReleaseSigning) {
+ if (hasReleaseSigning) {
+ signingConfig = signingConfigs.getByName("release")
+ } else {
logger.warn("Release signing key is not configured. Add key.properties or signing env vars before running release tasks.")
}
isMinifyEnabled = true
@@ -108,7 +109,7 @@ android {
}
kotlin {
- jvmToolchain(21)
+ jvmToolchain(17)
compilerOptions {
freeCompilerArgs.addAll(
"-Xlambdas=class"
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 7f84822..29e2296 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
@@ -55,6 +55,17 @@ object RecentFilesManager {
fun clearRecents(context: Context) {
prefs(context).edit().remove(KEY_RECENTS).apply()
}
+
+ fun removeRecent(context: Context, uri: Uri) {
+ val remaining = getRecents(context).filterNot { it.uriString == uri.toString() }
+ prefs(context).edit().apply {
+ if (remaining.isEmpty()) {
+ remove(KEY_RECENTS)
+ } else {
+ putString(KEY_RECENTS, json.encodeToString(remaining))
+ }
+ }.apply()
+ }
}
/**
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt
index d2d3196..fe01a06 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt
@@ -1,8 +1,5 @@
package com.chethan616.clearpdf.ui.components
-import androidx.compose.animation.core.Animatable
-import androidx.compose.animation.core.EaseOut
-import androidx.compose.animation.core.spring
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Row
@@ -11,23 +8,18 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.draw.alpha
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLayoutDirection
-import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastCoerceIn
@@ -37,9 +29,6 @@ import com.chethan616.clearpdf.ui.theme.LocalIsDarkMode
import com.chethan616.clearpdf.ui.utils.DampedDragAnimation
import com.chethan616.clearpdf.ui.utils.InteractiveHighlight
import com.kyant.backdrop.Backdrop
-import com.kyant.backdrop.backdrops.layerBackdrop
-import com.kyant.backdrop.backdrops.rememberCombinedBackdrop
-import com.kyant.backdrop.backdrops.rememberLayerBackdrop
import com.kyant.backdrop.drawBackdrop
import com.kyant.backdrop.effects.blur
import com.kyant.backdrop.effects.lens
@@ -48,9 +37,6 @@ import com.kyant.backdrop.highlight.Highlight
import com.kyant.backdrop.shadow.InnerShadow
import com.kyant.backdrop.shadow.Shadow
import com.kyant.shapes.Capsule
-import kotlinx.coroutines.launch
-import kotlin.math.abs
-import kotlin.math.sign
@Composable
fun LiquidBottomTabs(
@@ -66,9 +52,6 @@ fun LiquidBottomTabs(
val accentColor = if (isLightTheme) Color(0xFF0088FF) else Color(0xFF0091FF)
val containerColor = if (isLightTheme) Color(0xFFFAFAFA).copy(0.4f) else Color(0xFF121212).copy(0.4f)
- val tabsBackdrop = rememberLayerBackdrop()
- val combinedBackdrop = rememberCombinedBackdrop(backdrop, tabsBackdrop)
-
BoxWithConstraints(
modifier,
contentAlignment = Alignment.CenterStart
@@ -90,15 +73,6 @@ fun LiquidBottomTabs(
(constraints.maxWidth.toFloat() - horizontalInsetPx * 2f) / tabsCount
}
- val offsetAnimation = remember { Animatable(0f) }
- val panelOffset by remember(horizontalInsetPx, constraints.maxWidth) {
- derivedStateOf {
- val width = constraints.maxWidth.coerceAtLeast(1)
- val fraction = (offsetAnimation.value / width).fastCoerceIn(-1f, 1f)
- horizontalInsetPx * fraction.sign * EaseOut.transform(abs(fraction))
- }
- }
-
val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
val animationScope = rememberCoroutineScope()
val dampedDragAnimation = remember(animationScope, isLtr, tabWidth, tabsCount) {
@@ -116,21 +90,12 @@ fun LiquidBottomTabs(
if (targetIndex != selectedIndexState.value) {
onTabSelectedState.value(targetIndex)
}
- animationScope.launch {
- offsetAnimation.animateTo(
- 0f,
- spring(1f, 300f, 0.5f)
- )
- }
},
onDrag = { _, dragAmount ->
updateValue(
(targetValue + dragAmount.x / tabWidth * if (isLtr) 1f else -1f)
.fastCoerceIn(0f, (tabsCount - 1).toFloat())
)
- animationScope.launch {
- offsetAnimation.snapTo(offsetAnimation.value + dragAmount.x)
- }
}
)
}
@@ -144,8 +109,8 @@ fun LiquidBottomTabs(
animationScope = animationScope,
position = { size, _ ->
Offset(
- if (isLtr) (dampedDragAnimation.value + 0.5f) * tabWidth + panelOffset
- else size.width - (dampedDragAnimation.value + 0.5f) * tabWidth + panelOffset,
+ if (isLtr) (dampedDragAnimation.value + 0.5f) * tabWidth
+ else size.width - (dampedDragAnimation.value + 0.5f) * tabWidth,
size.height / 2f
)
}
@@ -155,7 +120,6 @@ fun LiquidBottomTabs(
// Container row
Row(
Modifier
- .graphicsLayer { translationX = panelOffset }
.drawBackdrop(
backdrop = backdrop,
shape = { Capsule },
@@ -180,59 +144,19 @@ fun LiquidBottomTabs(
content = content
)
- // Hidden tinted row
- CompositionLocalProvider(
- LocalLiquidBottomTabScale provides {
- lerp(1f, 1.2f, dampedDragAnimation.pressProgress)
- }
- ) {
- Row(
- Modifier
- .clearAndSetSemantics {}
- .alpha(0f)
- .layerBackdrop(tabsBackdrop)
- .graphicsLayer { translationX = panelOffset }
- .drawBackdrop(
- backdrop = backdrop,
- shape = { Capsule },
- effects = {
- val progress = dampedDragAnimation.pressProgress
- vibrancy()
- blur(blurRadiusPx)
- lens(
- containerLensRadiusPx * progress,
- containerLensRadiusPx * progress
- )
- },
- highlight = {
- val progress = dampedDragAnimation.pressProgress
- Highlight.Default.copy(alpha = progress)
- },
- onDrawSurface = { drawRect(containerColor) }
- )
- .then(interactiveHighlight.modifier)
- .height(56f.dp)
- .fillMaxWidth()
- .padding(horizontal = 4f.dp)
- .graphicsLayer(colorFilter = ColorFilter.tint(accentColor)),
- verticalAlignment = Alignment.CenterVertically,
- content = content
- )
- }
-
// Indicator
Box(
Modifier
.padding(horizontal = 4f.dp)
.graphicsLayer {
translationX =
- if (isLtr) dampedDragAnimation.value * tabWidth + panelOffset
- else size.width - (dampedDragAnimation.value + 1f) * tabWidth + panelOffset
+ if (isLtr) dampedDragAnimation.value * tabWidth
+ else size.width - (dampedDragAnimation.value + 1f) * tabWidth
}
.then(interactiveHighlight.gestureModifier)
.then(dampedDragAnimation.modifier)
.drawBackdrop(
- backdrop = combinedBackdrop,
+ backdrop = backdrop,
shape = { Capsule },
effects = {
val progress = dampedDragAnimation.pressProgress
@@ -266,6 +190,7 @@ fun LiquidBottomTabs(
},
onDrawSurface = {
val progress = dampedDragAnimation.pressProgress
+ drawRect(accentColor.copy(alpha = if (isLightTheme) 0.12f else 0.2f))
drawRect(
if (isLightTheme) Color.Black.copy(0.1f) else Color.White.copy(0.1f),
alpha = 1f - progress
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/CompressPdfScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/CompressPdfScreen.kt
index b447585..1d5c576 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/CompressPdfScreen.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/CompressPdfScreen.kt
@@ -132,7 +132,7 @@ fun CompressPdfScreen(
BasicText("Size: ${state.originalSizeBytes / 1024} KB", style = TextStyle(sub, 13.sp))
}
- // Quality presets
+ // One focused control surface: preset first, fine-tuning second.
Column(
Modifier
.fillMaxWidth()
@@ -141,6 +141,10 @@ fun CompressPdfScreen(
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
BasicText("Compression Level", style = TextStyle(text, 15.sp, fontWeight = FontWeight.Medium))
+ BasicText(
+ "Start with a preset, then fine-tune the size and quality balance.",
+ style = TextStyle(sub, 12.sp)
+ )
val qualities = listOf(
Triple(CompressionQuality.LOW, "Maximum Compression", "Smallest file, lower quality"),
@@ -184,43 +188,27 @@ fun CompressPdfScreen(
}
}
}
- }
-
- if (state.estimatedSizeBytes > 0) {
- Column(
- Modifier
- .fillMaxWidth()
- .liquidGlassPanel(backdrop, uiSensor)
- .padding(14.dp),
- verticalArrangement = Arrangement.spacedBy(4.dp)
- ) {
- val currentKb = state.originalSizeBytes / 1024
- val estimateKb = state.estimatedSizeBytes / 1024
- BasicText("Estimated output", style = TextStyle(text, 14.sp, fontWeight = FontWeight.SemiBold))
- BasicText("$currentKb KB -> about $estimateKb KB", style = TextStyle(sub, 13.sp))
- }
- }
-
- // Quality slider for fine-tuning
- Column(
- Modifier
- .fillMaxWidth()
- .liquidGlassPanel(backdrop, uiSensor)
- .padding(20.dp),
- verticalArrangement = Arrangement.spacedBy(12.dp)
- ) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Icon(Icons.Rounded.HighQuality, null, Modifier.size(22.dp), accent)
- BasicText("Fine-tune Quality", style = TextStyle(text, 15.sp, fontWeight = FontWeight.Medium))
- }
- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
- BasicText("Smaller file", style = TextStyle(sub, 13.sp))
+ BasicText("Fine-tune quality", style = TextStyle(text, 14.sp, fontWeight = FontWeight.Medium))
val qualityLabel = when (state.selectedQuality) {
CompressionQuality.LOW -> "Low"
- CompressionQuality.MEDIUM -> "Medium"
+ CompressionQuality.MEDIUM -> "Balanced"
CompressionQuality.HIGH -> "High"
}
- BasicText(qualityLabel, style = TextStyle(text, 13.sp, fontWeight = FontWeight.SemiBold))
+ BasicText(
+ qualityLabel,
+ style = TextStyle(accent, 12.sp, fontWeight = FontWeight.SemiBold),
+ modifier = Modifier.weight(1f),
+ maxLines = 1
+ )
+ BasicText(
+ "${(state.qualitySlider * 100).toInt()}%",
+ style = TextStyle(text, 13.sp, fontWeight = FontWeight.SemiBold)
+ )
+ }
+ Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
+ BasicText("Smaller file", style = TextStyle(sub, 13.sp))
BasicText("Better quality", style = TextStyle(sub, 13.sp))
}
LiquidSlider(
@@ -233,6 +221,14 @@ fun CompressPdfScreen(
backdrop = backdrop,
modifier = Modifier.fillMaxWidth()
)
+ if (state.estimatedSizeBytes > 0) {
+ val currentKb = state.originalSizeBytes / 1024
+ val estimateKb = state.estimatedSizeBytes / 1024
+ BasicText(
+ "Estimated output $currentKb KB -> about $estimateKb KB",
+ style = TextStyle(sub, 12.sp, fontWeight = FontWeight.Medium)
+ )
+ }
}
// Compress button
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 67bef43..e678e43 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
@@ -1,8 +1,11 @@
package com.chethan616.clearpdf.ui.screen
import android.net.Uri
+import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
+import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
@@ -12,6 +15,7 @@ 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.shape.RoundedCornerShape
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.verticalScroll
@@ -23,10 +27,14 @@ import androidx.compose.material.icons.rounded.PictureAsPdf
import androidx.compose.material.icons.rounded.Scanner
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.runtime.getValue
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.platform.LocalContext
import androidx.compose.ui.text.TextStyle
@@ -34,6 +42,9 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.LifecycleEventObserver
+import androidx.lifecycle.compose.LocalLifecycleOwner
import com.chethan616.clearpdf.data.repository.RecentFilesManager
import com.chethan616.clearpdf.ui.components.LiquidButton
import com.chethan616.clearpdf.ui.components.LiquidGlassTopBar
@@ -52,6 +63,7 @@ fun HomeScreen(
onNavigateToScan: () -> Unit,
onRecentFileSelected: (Uri) -> Unit
) {
+ val homeRecentLimit = 5
val isDarkMode = LocalIsDarkMode.current
val isLight = !isDarkMode
val text = if (isLight) Color(0xFF1A1A1A) else Color(0xFFF0F0F0)
@@ -60,16 +72,30 @@ fun HomeScreen(
val uiSensor = rememberUISensor()
val context = LocalContext.current
- val recentsState = remember { mutableStateOf(RecentFilesManager.getRecents(context)) }
+ var recents by remember { mutableStateOf(RecentFilesManager.getRecents(context)) }
+ var showAllRecents by remember { mutableStateOf(false) }
+ var selectedRecent by remember { mutableStateOf<com.chethan616.clearpdf.data.repository.RecentFile?>(null) }
+ val lifecycleOwner = LocalLifecycleOwner.current
- Column(
- Modifier
- .fillMaxSize()
- .statusBarsPadding()
- .padding(16.dp)
- .verticalScroll(rememberScrollState()),
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
+ DisposableEffect(lifecycleOwner, context) {
+ val observer = LifecycleEventObserver { _, event ->
+ if (event == Lifecycle.Event.ON_RESUME) {
+ recents = RecentFilesManager.getRecents(context)
+ }
+ }
+ lifecycleOwner.lifecycle.addObserver(observer)
+ onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
+ }
+
+ Box(Modifier.fillMaxSize()) {
+ Column(
+ Modifier
+ .fillMaxSize()
+ .statusBarsPadding()
+ .padding(16.dp)
+ .verticalScroll(rememberScrollState()),
+ verticalArrangement = Arrangement.spacedBy(16.dp)
+ ) {
LiquidGlassTopBar(title = "ClearPDF", backdrop = backdrop, uiSensor = uiSensor)
// Welcome card
@@ -134,14 +160,22 @@ fun HomeScreen(
horizontalArrangement = Arrangement.SpaceBetween
) {
BasicText("Recent Files", style = TextStyle(text, 16.sp, FontWeight.Bold))
- if (recentsState.value.isNotEmpty()) {
+ if (recents.isNotEmpty()) {
+ if (recents.size > homeRecentLimit) {
+ BasicText(
+ if (showAllRecents) "Show less" else "See all (${recents.size})",
+ style = TextStyle(accent, 12.sp, FontWeight.SemiBold),
+ modifier = Modifier.clickable { showAllRecents = !showAllRecents }
+ )
+ }
Icon(
Icons.Rounded.DeleteOutline, "Clear recents",
Modifier
.size(20.dp)
.clickable {
RecentFilesManager.clearRecents(context)
- recentsState.value = emptyList()
+ recents = emptyList()
+ showAllRecents = false
},
sub
)
@@ -149,22 +183,33 @@ fun HomeScreen(
}
Spacer(Modifier.height(12.dp))
- if (recentsState.value.isEmpty()) {
- BasicText("No recent files", style = TextStyle(sub, 14.sp))
+ if (recents.isEmpty()) {
+ BasicText("Your opened and exported PDFs will show up here.", style = TextStyle(sub, 14.sp))
} else {
- recentsState.value.forEach { recent ->
+ val visibleRecents = if (showAllRecents) recents else recents.take(homeRecentLimit)
+ visibleRecents.forEach { recent ->
Row(
Modifier
.fillMaxWidth()
- .clickable { onRecentFileSelected(recent.uri) }
- .padding(vertical = 8.dp),
+ .clip(RoundedCornerShape(16.dp))
+ .background(if (isLight) Color.White.copy(0.18f) else Color.White.copy(0.06f))
+ .combinedClickable(
+ onClick = { onRecentFileSelected(recent.uri) },
+ onLongClick = { selectedRecent = recent }
+ )
+ .padding(horizontal = 10.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp)
) {
- Icon(
- Icons.Rounded.PictureAsPdf, null,
- Modifier.size(28.dp), Color(0xFFE53935)
- )
+ Box(
+ Modifier
+ .size(40.dp)
+ .clip(RoundedCornerShape(12.dp))
+ .background(Color(0xFFE53935).copy(alpha = if (isLight) 0.14f else 0.25f)),
+ contentAlignment = Alignment.Center
+ ) {
+ Icon(Icons.Rounded.PictureAsPdf, null, Modifier.size(24.dp), Color(0xFFE53935))
+ }
Column(Modifier.weight(1f)) {
BasicText(recent.name, style = TextStyle(text, 14.sp, FontWeight.Medium))
val timeStr = formatTimestamp(recent.timestamp)
@@ -172,12 +217,79 @@ fun HomeScreen(
val pageStr = if (recent.pageCount > 0) " Β· ${recent.pageCount} pages" else ""
BasicText("$timeStr$sizeStr$pageStr", style = TextStyle(sub, 11.sp))
}
+ BasicText("PDF", style = TextStyle(accent, 10.sp, FontWeight.Bold))
}
}
+ if (!showAllRecents && recents.size > homeRecentLimit) {
+ BasicText(
+ "Hold a file for quick actions",
+ style = TextStyle(sub, 11.sp),
+ modifier = Modifier.padding(top = 2.dp)
+ )
+ }
}
}
Spacer(Modifier.height(80.dp))
+ }
+
+ selectedRecent?.let { recent ->
+ Box(
+ Modifier
+ .fillMaxSize()
+ .background(Color.Black.copy(alpha = 0.28f))
+ .clickable { selectedRecent = null },
+ contentAlignment = Alignment.BottomCenter
+ ) {
+ Column(
+ Modifier
+ .fillMaxWidth()
+ .padding(16.dp)
+ .liquidGlassPanel(backdrop, uiSensor)
+ .clickable { /* Consume taps inside the action sheet. */ }
+ .padding(22.dp),
+ verticalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ BasicText("Quick actions", style = TextStyle(text, 18.sp, FontWeight.Bold))
+ BasicText(
+ recent.name,
+ style = TextStyle(sub, 13.sp),
+ modifier = Modifier.padding(bottom = 4.dp)
+ )
+ LiquidButton(
+ onClick = {
+ selectedRecent = null
+ onRecentFileSelected(recent.uri)
+ },
+ backdrop = backdrop,
+ tint = accent,
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ BasicText("Open PDF", style = TextStyle(Color.White, 14.sp, FontWeight.SemiBold))
+ }
+ LiquidButton(
+ onClick = {
+ RecentFilesManager.removeRecent(context, recent.uri)
+ recents = recents.filterNot { it.uriString == recent.uri.toString() }
+ selectedRecent = null
+ },
+ backdrop = backdrop,
+ surfaceColor = Color.White.copy(alpha = 0.08f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ BasicText("Remove from Recents", style = TextStyle(text, 14.sp, FontWeight.Medium))
+ }
+ BasicText(
+ "Cancel",
+ style = TextStyle(accent, 13.sp, FontWeight.SemiBold, textAlign = TextAlign.Center),
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable { selectedRecent = null }
+ .padding(vertical = 8.dp)
+ )
+ }
+ }
+ }
}
}
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/utils/DampedDragAnimation.kt b/app/src/main/java/com/chethan616/clearpdf/ui/utils/DampedDragAnimation.kt
index 11c9798..d9d8ab2 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/utils/DampedDragAnimation.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/utils/DampedDragAnimation.kt
@@ -11,6 +11,7 @@ import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.input.pointer.util.VelocityTracker
import androidx.compose.ui.unit.IntSize
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Job
import kotlinx.coroutines.android.awaitFrame
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.first
@@ -49,10 +50,15 @@ class DampedDragAnimation(
private val mutatorMutex = MutatorMutex()
private val velocityTracker = VelocityTracker()
private var lastVelocityTarget = 0f
+ private var valueUpdateJob: Job? = null
+ private var velocityUpdateJob: Job? = null
+ private var inputTargetValue = initialValue
val value: Float get() = valueAnimation.value
val progress: Float get() = (value - valueRange.start) / (valueRange.endInclusive - valueRange.start)
- val targetValue: Float get() = valueAnimation.targetValue
+ // Keep the touch target synchronous even though Animatable updates on the
+ // animation scope. This prevents a fast drag from reading a stale target.
+ val targetValue: Float get() = inputTargetValue
val pressProgress: Float get() = pressProgressAnimation.value
val scaleX: Float get() = scaleXAnimation.value
val scaleY: Float get() = scaleYAnimation.value
@@ -93,7 +99,7 @@ class DampedDragAnimation(
if (value != targetValue) {
val threshold = (valueRange.endInclusive - valueRange.start) * 0.025f
snapshotFlow { valueAnimation.value }
- .filter { abs(it - valueAnimation.targetValue) < threshold }
+ .filter { abs(it - targetValue) < threshold }
.first()
}
launch { pressProgressAnimation.animateTo(0f, pressProgressAnimationSpec) }
@@ -104,17 +110,25 @@ class DampedDragAnimation(
fun updateValue(value: Float) {
val targetValue = value.coerceIn(valueRange)
- animationScope.launch {
- launch { valueAnimation.animateTo(targetValue, valueAnimationSpec) { updateVelocity() } }
+ inputTargetValue = targetValue
+ valueUpdateJob?.cancel()
+ valueUpdateJob = animationScope.launch {
+ // A drag is already a continuous gesture. Animating every sample
+ // creates a queue of spring jobs and makes the thumb trail behind.
+ valueAnimation.snapTo(targetValue)
+ updateVelocity()
}
}
fun animateToValue(value: Float) {
+ val target = value.coerceIn(valueRange)
+ inputTargetValue = target
+ valueUpdateJob?.cancel()
+ velocityUpdateJob?.cancel()
animationScope.launch {
mutatorMutex.mutate {
press()
- val targetValue = value.coerceIn(valueRange)
- launch { valueAnimation.animateTo(targetValue, valueAnimationSpec) }
+ launch { valueAnimation.animateTo(target, valueAnimationSpec) }
if (velocity != 0f) {
launch { velocityAnimation.animateTo(0f, velocityAnimationSpec) }
}
@@ -129,6 +143,11 @@ class DampedDragAnimation(
val targetVelocity = velocityTracker.calculateVelocity().x / range
if (abs(targetVelocity - lastVelocityTarget) < VELOCITY_DELTA_EPSILON) return
lastVelocityTarget = targetVelocity
- animationScope.launch { velocityAnimation.animateTo(targetVelocity, velocityAnimationSpec) }
+ velocityUpdateJob?.cancel()
+ velocityUpdateJob = animationScope.launch {
+ // Velocity is visual feedback during a gesture; snapping to the
+ // newest sample is smoother than stacking spring animations.
+ velocityAnimation.snapTo(targetVelocity)
+ }
}
}
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/utils/InteractiveHighlight.kt b/app/src/main/java/com/chethan616/clearpdf/ui/utils/InteractiveHighlight.kt
index b99c6d5..e298cc8 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/utils/InteractiveHighlight.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/utils/InteractiveHighlight.kt
@@ -17,6 +17,7 @@ import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.util.fastCoerceIn
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
class InteractiveHighlight(
@@ -30,6 +31,7 @@ class InteractiveHighlight(
private val positionAnimation = Animatable(Offset.Zero, Offset.VectorConverter, Offset.VisibilityThreshold)
private var startPosition = Offset.Zero
+ private var positionUpdateJob: Job? = null
val pressProgress: Float get() = pressProgressAnimation.value
val offset: Offset get() = positionAnimation.value - startPosition
@@ -82,25 +84,33 @@ half4 main(float2 coord) {
inspectDragGestures(
onDragStart = { down ->
startPosition = down.position
+ positionUpdateJob?.cancel()
animationScope.launch {
launch { pressProgressAnimation.animateTo(1f, pressProgressAnimationSpec) }
launch { positionAnimation.snapTo(startPosition) }
}
},
onDragEnd = {
+ positionUpdateJob?.cancel()
animationScope.launch {
launch { pressProgressAnimation.animateTo(0f, pressProgressAnimationSpec) }
launch { positionAnimation.animateTo(startPosition, positionAnimationSpec) }
}
},
onDragCancel = {
+ positionUpdateJob?.cancel()
animationScope.launch {
launch { pressProgressAnimation.animateTo(0f, pressProgressAnimationSpec) }
launch { positionAnimation.animateTo(startPosition, positionAnimationSpec) }
}
}
) { change, _ ->
- animationScope.launch { positionAnimation.snapTo(change.position) }
+ // Pointer events can arrive faster than a frame. Keep only the
+ // newest position instead of queuing one coroutine per sample.
+ positionUpdateJob?.cancel()
+ positionUpdateJob = animationScope.launch {
+ positionAnimation.snapTo(change.position)
+ }
}
}
}
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/viewmodel/CompressPdfViewModel.kt b/app/src/main/java/com/chethan616/clearpdf/ui/viewmodel/CompressPdfViewModel.kt
index 111d902..01db589 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/viewmodel/CompressPdfViewModel.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/viewmodel/CompressPdfViewModel.kt
@@ -105,25 +105,26 @@ class CompressPdfViewModel(private val compressPdfUseCase: CompressPdfUseCase) :
}
fun onQualitySliderChanged(value: Float) {
+ val current = _uiState.value
val quality = when {
value < 0.33f -> CompressionQuality.LOW
value < 0.66f -> CompressionQuality.MEDIUM
else -> CompressionQuality.HIGH
}
- val sourceUri = _uiState.value.sourceUri
- val estimate = if (sourceUri != null) {
+ val sourceUri = current.sourceUri
+ val estimate = if (quality != current.selectedQuality && sourceUri != null) {
compressPdfUseCase.estimateSize(
source = PdfDocument(
uri = sourceUri,
- name = _uiState.value.sourceFileName,
- sizeBytes = _uiState.value.originalSizeBytes
+ name = current.sourceFileName,
+ sizeBytes = current.originalSizeBytes
),
quality = quality
)
} else {
- -1
+ current.estimatedSizeBytes
}
- _uiState.value = _uiState.value.copy(
+ _uiState.value = current.copy(
qualitySlider = value,
selectedQuality = quality,
estimatedSizeBytes = estimate
diff --git a/gradle/gradle-daemon-jvm.properties b/gradle/gradle-daemon-jvm.properties
deleted file mode 100644
index d0f0b91..0000000
--- a/gradle/gradle-daemon-jvm.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-#This file is generated by updateDaemonJvm
-toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ff1d4fc92bcfc9d3799beabb4e70cfa3/redirect
-toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/08ce182188ada0b93565cd9ca4a4ab32/redirect
-toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c5760d82d08e6c26884debb23736ea57/redirect
-toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/879378f84c64b2c76003b97a32968399/redirect
-toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/021e528cbed860c875a9016f29ee13c1/redirect
-toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/ee5178090598fb4291558827b9f00e0d/redirect
-toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ff1d4fc92bcfc9d3799beabb4e70cfa3/redirect
-toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/879378f84c64b2c76003b97a32968399/redirect
-toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9b6bab41c3ef2acea6116b7821b8dc11/redirect
-toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/a6eb06d81d82a782734ef3b616ba2684/redirect
-toolchainVendor=JETBRAINS
-toolchainVersion=21
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 19a6bde..321d68d 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-bin.zip
-networkTimeout=10000
+networkTimeout=120000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradle/wrapper/wrapper/gradle-wrapper.jar b/gradle/wrapper/wrapper/gradle-wrapper.jar
deleted file mode 100644
index f8e1ee3..0000000
Binary files a/gradle/wrapper/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/wrapper/gradle-wrapper.properties b/gradle/wrapper/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 19a6bde..0000000
--- a/gradle/wrapper/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/readme.md b/readme.md
index a97e5a0..c718281 100644
--- a/readme.md
+++ b/readme.md
@@ -30,7 +30,8 @@
- πŸ“· Document scanner with edge detection (Google ML Kit)
- πŸŒ— Beautiful liquid glass UI for light & dark mode
- ⚑ Smooth performance built with Jetpack Compose
-- πŸ”’ Fully offline & privacy friendly β€” no cloud, no accounts
+- πŸ”’ Offline-first & privacy friendly β€” no cloud PDF processing, accounts, ads, or analytics
+- πŸ›‘οΈ No hidden uploads β€” PDF work stays on-device; scanner/text-selection ML components are disclosed in `NOTICE`
---
@@ -88,6 +89,14 @@ Open the project in Android Studio and run:
2. Build the project
3. Run on a real device or emulator
+The project uses JDK 17 or newer and Android SDK 36. Build the release variant locally with:
+
+```bash
+./gradlew assembleRelease
+```
+
+The release build is intentionally unsigned for contributors unless local signing credentials are configured. Never commit `key.properties`, keystores, APKs, or private documents.
+
---
# ❀️ Open Source
@@ -101,6 +110,8 @@ If you like the project:
- πŸ›  Contribute improvements
- πŸ“’ Share it with others
+See [CONTRIBUTING.md](CONTRIBUTING.md) for the offline-first contribution principles and release workflow. See [PRIVACY.md](PRIVACY.md) for the app's privacy and offline behavior. Please use the issue templates for bugs and feature requests.
+
---
# πŸ™Œ Credits
@@ -144,4 +155,4 @@ If you find ClearPDF useful, consider supporting development:
Repository funding metadata lives in:
-`.github/FUNDING.yml`
\ No newline at end of file
+`.github/FUNDING.yml`