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.

Start ClearPDF V2 on the PdfCraft engine with a new liquid glass UI

chethan6164797273cd08d
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index f21b2f5..0e49976 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -35,7 +35,7 @@ jobs:
- id: v
name: Resolve version
run: |
- listed="$(sed -n 's/^pdfcraft\.version=//p' apps/pdfcraft-android/android/gradle.properties)"
+ listed="$(sed -n 's/^clearpdf\.version=//p' apps/pdfcraft-android/android/gradle.properties)"
if [ "$GITHUB_REF_TYPE" = tag ]; then v="${GITHUB_REF_NAME#v}"; else v="$listed"; fi
if ! printf '%s' "$v" | grep -Eq '^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'; then
echo "::error::'$v' is not a version like 1.2.3 or 1.2.3-beta"
@@ -43,7 +43,7 @@ jobs:
fi
# the tag must be the version gradle.properties names (F-Droid builds from that file)
if [ "$v" != "$listed" ]; then
- echo "::error::the tag is v$v but gradle.properties says pdfcraft.version=$listed: set it (and pdfcraft.versionCode) before tagging"
+ echo "::error::the tag is v$v but gradle.properties says clearpdf.version=$listed: set it (and clearpdf.versionCode) before tagging"
exit 1
fi
echo "version=$v" >>"$GITHUB_OUTPUT"
@@ -69,11 +69,11 @@ jobs:
- name: Release key
env:
- KEYSTORE_BASE64: ${{ secrets.PDFCRAFT_KEYSTORE_BASE64 }}
+ KEYSTORE_BASE64: ${{ secrets.CLEARPDF_UPLOAD_STORE_FILE_BASE64 }}
run: |
if [ -n "$KEYSTORE_BASE64" ]; then
- printf '%s' "$KEYSTORE_BASE64" | base64 -d >"$RUNNER_TEMP/release.p12"
- echo "PDFCRAFT_KEYSTORE=$RUNNER_TEMP/release.p12" >>"$GITHUB_ENV"
+ printf '%s' "$KEYSTORE_BASE64" | base64 -d >"$RUNNER_TEMP/clearpdf-upload-key.jks"
+ echo "CLEARPDF_UPLOAD_STORE_FILE=$RUNNER_TEMP/clearpdf-upload-key.jks" >>"$GITHUB_ENV"
elif [ "$GITHUB_REF_TYPE" = tag ]; then
echo "::error::No release key: a release is never signed with the debug key"
exit 1
@@ -82,21 +82,21 @@ jobs:
fi
# one APK per ABI (each about half the size of one holding both): 64-bit ARM for most
- # phones (pdfcraft-android-<version>.apk), 32-bit ARM for older and low-end ones
- # (pdfcraft-android-<version>-armeabi-v7a.apk)
+ # phones (ClearPDF-v<version>.apk), 32-bit ARM for older and low-end ones
+ # (ClearPDF-v<version>-armeabi-v7a.apk)
- name: Build
working-directory: apps/pdfcraft-android/android
env:
VERSION: ${{ steps.v.outputs.version }}
- PDFCRAFT_KEYSTORE_PASSWORD: ${{ secrets.PDFCRAFT_KEYSTORE_PASSWORD }}
- PDFCRAFT_KEY_ALIAS: ${{ secrets.PDFCRAFT_KEY_ALIAS }}
- PDFCRAFT_KEY_PASSWORD: ${{ secrets.PDFCRAFT_KEY_PASSWORD }}
+ CLEARPDF_UPLOAD_STORE_PASSWORD: ${{ secrets.CLEARPDF_UPLOAD_STORE_PASSWORD }}
+ CLEARPDF_UPLOAD_KEY_ALIAS: ${{ secrets.CLEARPDF_UPLOAD_KEY_ALIAS }}
+ CLEARPDF_UPLOAD_KEY_PASSWORD: ${{ secrets.CLEARPDF_UPLOAD_KEY_PASSWORD }}
run: |
mkdir -p "$GITHUB_WORKSPACE/dist"
for abi in arm64-v8a armeabi-v7a; do
- ./gradlew assembleRelease "-Ppdfcraft.abis=$abi" "-Ppdfcraft.version=$VERSION" --no-daemon
+ ./gradlew assembleRelease "-Pclearpdf.abis=$abi" "-Pclearpdf.version=$VERSION" --no-daemon
suffix=""; [ "$abi" = arm64-v8a ] || suffix="-$abi"
- cp app/build/outputs/apk/release/app-release.apk "$GITHUB_WORKSPACE/dist/pdfcraft-android-$VERSION$suffix.apk"
+ cp app/build/outputs/apk/release/app-release.apk "$GITHUB_WORKSPACE/dist/ClearPDF-v$VERSION$suffix.apk"
done
- name: APK
@@ -123,7 +123,7 @@ jobs:
- name: Remove the release key
if: always()
- run: rm -f "$RUNNER_TEMP/release.p12"
+ run: rm -f "$RUNNER_TEMP/clearpdf-upload-key.jks"
release:
name: GitHub Release
diff --git a/.gitignore b/.gitignore
index 7b0a4f5..e8e4307 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,9 @@
.claude/
# the phone parity tracker stays on this computer, out of the repo
/docs/parity-mobile.md
+# release signing (ClearPDF's upload key): never committed
+/key.properties
+*.jks
+*.keystore
+# local build logs
+/build-*.log
diff --git a/NOTICE b/NOTICE
index 8b3502a..bfa0cf0 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,3 +1,27 @@
+ClearPDF
+Copyright (c) 2026 Chethan616
+
+ClearPDF is a modified version of PdfCraft for Android
+(https://github.com/artcraft-android/pdfcraft-android) by the ArtCraft Team, which is built on the
+engine of PdfCraft (https://github.com/storytold/pdfcraft) by storytold and the PdfCraft
+contributors. ClearPDF changed the Android app (apps/pdfcraft-android/android): its package, name,
+icon, signing and release workflow, and its user interface, rewritten on ClearPDF's liquid glass
+design system. The engine crates (crates/, vendor/, apps/pdfcraft-android/src) come from PdfCraft.
+ClearPDF's changes are under the same terms: MIT OR Apache-2.0, at your option.
+
+Liquid glass: the backdrop library from AndroidLiquidGlass by Kyant0
+(https://github.com/Kyant0/AndroidLiquidGlass), Apache-2.0, adapted. The velocity squash-and-stretch
+of glass thumbs follows LiquidTracker from AndroidLiquidGlassView by Donny Yale
+(https://github.com/QmDeve/AndroidLiquidGlassView), MIT, re-implemented for Compose.
+
+Display type: Bricolage Grotesque, Copyright 2022 The Bricolage Grotesque Project Authors
+(https://github.com/ateliertriay/bricolage), SIL Open Font License 1.1
+(app/src/main/assets/licences/OFL-BricolageGrotesque.txt).
+
+The original notice of PdfCraft for Android follows.
+
+----------------------------------------------------------------------------------------------------
+
PdfCraft for Android
Copyright (c) 2026 ArtCraft Team and the PdfCraft contributors.
diff --git a/apps/pdfcraft-android/README.md b/apps/pdfcraft-android/README.md
index a686786..4413904 100644
--- a/apps/pdfcraft-android/README.md
+++ b/apps/pdfcraft-android/README.md
@@ -24,7 +24,7 @@ words are PdfCraft's own.
|---|---|
| `src/lib.rs` | The `pdfcraft-android` crate: [`MobileSession`](src/lib.rs) wraps `pdfcraft_automation::Automation` for UniFFI (Kotlin now, Swift later) |
| `src/tests.rs` | Host tests of that API (`cargo test -p pdfcraft-android`) |
-| `uniffi.toml` | Bindings config: the Kotlin package `io.github.artcraftandroid.pdfcraft.core` |
+| `uniffi.toml` | Bindings config: the Kotlin package `com.chethan616.clearpdf.core` |
| `bindgen/` | `uniffi-bindgen`, pinned to the crate's UniFFI release; the Android build runs it |
| `android/` | The Android Studio project (Gradle, Kotlin, Compose) |
diff --git a/apps/pdfcraft-android/android/app/build.gradle.kts b/apps/pdfcraft-android/android/app/build.gradle.kts
index 4ed67c5..474939d 100644
--- a/apps/pdfcraft-android/android/app/build.gradle.kts
+++ b/apps/pdfcraft-android/android/app/build.gradle.kts
@@ -1,3 +1,4 @@
+import java.util.Properties
import javax.inject.Inject
import org.gradle.process.ExecOperations
@@ -10,29 +11,29 @@ plugins {
// crate (apps/pdfcraft-android), which sits in the PdfCraft cargo workspace two folders up.
val cargoWorkspaceDir: File = rootDir.parentFile.parentFile.parentFile
val rustAbis: List<String> =
- providers.gradleProperty("pdfcraft.abis").getOrElse("arm64-v8a,x86_64").split(',').map { it.trim() }.filter { it.isNotEmpty() }
+ providers.gradleProperty("clearpdf.abis").getOrElse("arm64-v8a,x86_64").split(',').map { it.trim() }.filter { it.isNotEmpty() }
val minApi = 29
-// The app's version: gradle.properties' pdfcraft.version, or the version tag's when the release
+// The app's version: gradle.properties' clearpdf.version, or the version tag's when the release
// workflow builds a release. The version code follows from it (0.0.1-beta → 101, 0.0.1-beta.2 →
// 102, 0.0.1 → 199, 0.1.0-beta → 10001), so a pre-release comes before its release and every
// release before the next version's pre-releases; times ten plus the ABI of a one-ABI build
// (armeabi-v7a 1, arm64-v8a 2, x86_64 3; 0 for several), so each APK of a release has its own code
-// (F-Droid needs that).
-val appVersion: String = providers.gradleProperty("pdfcraft.version").get()
+// (F-Droid needs that). ClearPDF 2.x shipped codes up to 95, so 3.x codes always sort above them.
+val appVersion: String = providers.gradleProperty("clearpdf.version").get()
val appVersionCode: Int = run {
val m = requireNotNull(Regex("""(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z-]+?(\.(\d+))?)?""").matchEntire(appVersion)) {
- "pdfcraft.version $appVersion is not a version like 1.2.3, 1.2.3-beta or 1.2.3-beta.4"
+ "clearpdf.version $appVersion is not a version like 1.2.3, 1.2.3-beta or 1.2.3-beta.4"
}
val (major, minor, patch) = m.groupValues.subList(1, 4).map { it.toInt() }
val pre = if (m.groupValues[4].isEmpty()) null else m.groupValues[6].toIntOrNull() ?: 1
require(minor < 100 && patch < 100 && (pre ?: 1) in 1..98) {
- "pdfcraft.version $appVersion: minor and patch must be under 100, and a pre-release's number 1 to 98"
+ "clearpdf.version $appVersion: minor and patch must be under 100, and a pre-release's number 1 to 98"
}
val base = ((major * 100 + minor) * 100 + patch) * 100 + (pre ?: 99)
- providers.gradleProperty("pdfcraft.versionCode").orNull?.let { listed ->
+ providers.gradleProperty("clearpdf.versionCode").orNull?.let { listed ->
require(listed.trim().toIntOrNull() == base) {
- "gradle.properties: pdfcraft.versionCode=$listed, but version $appVersion's is $base (set both before tagging)"
+ "gradle.properties: clearpdf.versionCode=$listed, but version $appVersion's is $base (set both before tagging)"
}
}
val abi = when (rustAbis.singleOrNull()) {
@@ -44,12 +45,19 @@ val appVersionCode: Int = run {
base * 10 + abi
}
-// The release key, when the build is given one (the release workflow passes it from the repository's
-// secrets). Without one a release build is signed with the debug key: it installs, but it can't
-// update a published release; or, with -Ppdfcraft.unsigned=true (F-Droid's build), not signed at
-// all, so the published APK's signature can be checked against it.
-val releaseKeystore: String? = providers.environmentVariable("PDFCRAFT_KEYSTORE").orNull
-val unsignedRelease: Boolean = providers.gradleProperty("pdfcraft.unsigned").orNull == "true"
+// ClearPDF's release key: the CLEARPDF_UPLOAD_* variables (CI, from the repository's secrets), else
+// key.properties at the repository root (a local Play build). Each channel keeps the key its
+// installs were signed with, or they can't update. Without either a release build is signed with
+// the debug key; with -Pclearpdf.unsigned=true (F-Droid's build) it isn't signed at all.
+val keyProperties = Properties().apply {
+ val f = File(cargoWorkspaceDir, "key.properties")
+ if (f.isFile) f.inputStream().use(::load)
+}
+fun signingValue(property: String, env: String): String? =
+ providers.environmentVariable(env).orNull?.takeIf { it.isNotBlank() } ?: keyProperties.getProperty(property)?.takeIf { it.isNotBlank() }
+val releaseKeystore: File? = signingValue("storeFile", "CLEARPDF_UPLOAD_STORE_FILE")
+ ?.let { File(it).takeIf(File::isAbsolute) ?: File(cargoWorkspaceDir, it) }
+val unsignedRelease: Boolean = providers.gradleProperty("clearpdf.unsigned").orNull == "true"
/** rustup's `cargo` (Android Studio may not see rustup's PATH), else `cargo` from PATH; `CARGO` overrides. */
val cargoExecutable: String = run {
@@ -154,13 +162,13 @@ abstract class LucideIconsTask : DefaultTask() {
fun generate() {
val out = outputDir.get().asFile
out.deleteRecursively()
- val pkg = File(out, "io/github/artcraftandroid/pdfcraft/ui").apply { mkdirs() }
+ val pkg = File(out, "com/chethan616/clearpdf/ui").apply { mkdirs() }
val attr = Regex("""([\w-]+)="([^"]*)"""")
val element = Regex("""<(path|circle|ellipse|rect|line|polyline|polygon)\b([^>]*)/?>""")
fun n(v: Double) = if (v == Math.floor(v)) v.toLong().toString() else v.toString()
val sb = StringBuilder()
sb.appendLine("// Generated by app/build.gradle.kts (LucideIconsTask) from assets/icons: do not edit.")
- sb.appendLine("package io.github.artcraftandroid.pdfcraft.ui\n")
+ sb.appendLine("package com.chethan616.clearpdf.ui\n")
sb.appendLine("import androidx.compose.ui.graphics.vector.ImageVector\n")
sb.appendLine("/** Lucide icons (ISC, Lucide Contributors; assets/icons/LICENSE-lucide.txt). */")
sb.appendLine("object LucideIcons {")
@@ -231,12 +239,12 @@ abstract class OcrModels : DefaultTask() {
}
android {
- namespace = "io.github.artcraftandroid.pdfcraft"
+ namespace = "com.chethan616.clearpdf"
compileSdk = 37
ndkVersion = "29.0.14206865"
defaultConfig {
- applicationId = "io.github.artcraftandroid.pdfcraft"
+ applicationId = "com.chethan616.clearpdf"
minSdk = minApi
targetSdk = 36
versionCode = appVersionCode
@@ -247,10 +255,10 @@ android {
signingConfigs {
if (releaseKeystore != null) {
create("release") {
- storeFile = file(releaseKeystore)
- storePassword = providers.environmentVariable("PDFCRAFT_KEYSTORE_PASSWORD").orNull
- keyAlias = providers.environmentVariable("PDFCRAFT_KEY_ALIAS").orNull
- keyPassword = providers.environmentVariable("PDFCRAFT_KEY_PASSWORD").orNull
+ storeFile = releaseKeystore
+ storePassword = signingValue("storePassword", "CLEARPDF_UPLOAD_STORE_PASSWORD")
+ keyAlias = signingValue("keyAlias", "CLEARPDF_UPLOAD_KEY_ALIAS")
+ keyPassword = signingValue("keyPassword", "CLEARPDF_UPLOAD_KEY_PASSWORD")
}
}
}
@@ -313,7 +321,6 @@ androidComponents {
val assetsDir = File(cargoWorkspaceDir, "assets")
val res = tasks.register<PdfcraftAssets>("pdfcraftResources$name") {
val map = mapOf(
- "app-icon/hicolor/512x512/apps/ai.storyteller.pdfcraft.png" to "drawable-nodpi/ic_launcher_tile.png",
"fonts/Inter-Regular.ttf" to "font/inter_regular.ttf",
"fonts/Inter-Medium.ttf" to "font/inter_medium.ttf",
"fonts/Inter-SemiBold.ttf" to "font/inter_semibold.ttf",
@@ -363,6 +370,9 @@ dependencies {
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.graphics)
implementation(libs.androidx.compose.material3)
+ implementation(libs.androidx.compose.foundation)
+ implementation(project(":backdrop"))
+ implementation(libs.kyant.shapes)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.androidx.exifinterface)
implementation(libs.jna) { artifact { type = "aar" } }
diff --git a/apps/pdfcraft-android/android/app/proguard-rules.pro b/apps/pdfcraft-android/android/app/proguard-rules.pro
index 5254b94..1b99cc6 100644
--- a/apps/pdfcraft-android/android/app/proguard-rules.pro
+++ b/apps/pdfcraft-android/android/app/proguard-rules.pro
@@ -2,5 +2,5 @@
# functions and structures by reflection: keep both.
-keep class com.sun.jna.** { *; }
-keep class * implements com.sun.jna.** { *; }
--keep class io.github.artcraftandroid.pdfcraft.core.** { *; }
+-keep class com.chethan616.clearpdf.core.** { *; }
-dontwarn java.awt.**
diff --git a/apps/pdfcraft-android/android/app/src/main/AndroidManifest.xml b/apps/pdfcraft-android/android/app/src/main/AndroidManifest.xml
index 557f87f..037a56e 100644
--- a/apps/pdfcraft-android/android/app/src/main/AndroidManifest.xml
+++ b/apps/pdfcraft-android/android/app/src/main/AndroidManifest.xml
@@ -12,7 +12,7 @@
granting it makes Android refuse IMAGE_CAPTURE. -->
<uses-feature android:name="android.hardware.camera.any" android:required="false" />
- <!-- Read aloud keeps reading with PdfCraft in the background (a media notification) -->
+ <!-- Read aloud keeps reading with ClearPDF in the background (a media notification) -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
@@ -23,9 +23,9 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
- android:roundIcon="@mipmap/ic_launcher"
+ android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
- android:theme="@style/Theme.PdfCraft">
+ android:theme="@style/Theme.ClearPDF">
<activity
android:name=".MainActivity"
@@ -37,7 +37,7 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
- <!-- PDFs other apps open with PdfCraft -->
+ <!-- PDFs other apps open with ClearPDF -->
<intent-filter android:label="@string/open_with">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
@@ -46,7 +46,7 @@
<data android:scheme="file" />
<data android:mimeType="application/pdf" />
</intent-filter>
- <!-- PDFs shared to PdfCraft -->
+ <!-- PDFs shared to ClearPDF -->
<intent-filter android:label="@string/open_with">
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
@@ -60,7 +60,7 @@
android:exported="false"
android:foregroundServiceType="mediaPlayback" />
- <!-- Files of PdfCraft's handed to other apps (share, print, open in) -->
+ <!-- Files of ClearPDF's handed to other apps (share, print, open in) -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.files"
diff --git a/apps/pdfcraft-android/android/app/src/main/assets/licences/OFL-BricolageGrotesque.txt b/apps/pdfcraft-android/android/app/src/main/assets/licences/OFL-BricolageGrotesque.txt
new file mode 100644
index 0000000..a397658
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/assets/licences/OFL-BricolageGrotesque.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Bricolage Grotesque Project Authors (https://github.com/ateliertriay/bricolage)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/MainActivity.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/MainActivity.kt
similarity index 93%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/MainActivity.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/MainActivity.kt
index cdd1c1e..4f1982e 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/MainActivity.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/MainActivity.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft
+package com.chethan616.clearpdf
import android.content.ActivityNotFoundException
import android.content.Intent
@@ -24,10 +24,10 @@ import androidx.activity.viewModels
import androidx.core.content.FileProvider
import androidx.core.content.IntentCompat
import androidx.lifecycle.lifecycleScope
-import io.github.artcraftandroid.pdfcraft.ui.AppRoot
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.FilePickKind
-import io.github.artcraftandroid.pdfcraft.ui.PdfcraftTheme
+import com.chethan616.clearpdf.ui.ClearApp
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.FilePickKind
+import com.chethan616.clearpdf.ui.glass.GlassSettings
import java.io.File
import java.io.FileOutputStream
import kotlinx.coroutines.delay
@@ -62,14 +62,13 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
if (savedInstanceState == null) openFromIntent(intent)
collectRequests()
+ GlassSettings.load(this)
setContent {
- PdfcraftTheme {
- AppRoot(
- vm,
- onBrowse = { launchSafely { pickPdf.launch(arrayOf("application/pdf")) } },
- onPickSignatureImage = { launchSafely { pickSignature.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) } },
- )
- }
+ ClearApp(
+ vm,
+ onBrowse = { launchSafely { pickPdf.launch(arrayOf("application/pdf")) } },
+ onPickSignatureImage = { launchSafely { pickSignature.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) } },
+ )
}
}
@@ -158,7 +157,7 @@ class MainActivity : ComponentActivity() {
openFromIntent(intent)
}
- /** A PDF another app opens with PdfCraft, or shares to it, opens in the viewer. */
+ /** A PDF another app opens with ClearPDF, or shares to it, opens in the viewer. */
private fun openFromIntent(intent: Intent?) {
val uri: Uri? = when (intent?.action) {
Intent.ACTION_VIEW -> intent.data
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/PdfcraftApplication.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/PdfcraftApplication.kt
similarity index 91%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/PdfcraftApplication.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/PdfcraftApplication.kt
index c263e87..1c066af 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/PdfcraftApplication.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/PdfcraftApplication.kt
@@ -1,8 +1,8 @@
-package io.github.artcraftandroid.pdfcraft
+package com.chethan616.clearpdf
import android.app.Application
import android.content.ComponentCallbacks2
-import io.github.artcraftandroid.pdfcraft.engine.Engine
+import com.chethan616.clearpdf.engine.Engine
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ReadAloudService.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ReadAloudService.kt
similarity index 92%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ReadAloudService.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ReadAloudService.kt
index 9728659..8ae5e71 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ReadAloudService.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ReadAloudService.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft
+package com.chethan616.clearpdf
import android.app.Notification
import android.app.NotificationChannel
@@ -37,7 +37,7 @@ class ReadAloudService : Service() {
super.onCreate()
val nm = getSystemService(NotificationManager::class.java)
nm?.createNotificationChannel(NotificationChannel(CHANNEL, getString(R.string.common_tool_read_aloud), NotificationManager.IMPORTANCE_LOW).apply { setShowBadge(false) })
- session = MediaSession(this, "PdfCraft read aloud").apply {
+ session = MediaSession(this, "ClearPDF read aloud").apply {
setCallback(object : MediaSession.Callback() {
override fun onPlay() { controls?.play() }
override fun onPause() { controls?.pause() }
@@ -122,11 +122,11 @@ class ReadAloudService : Service() {
companion object {
private const val CHANNEL = "readAloud"
private const val NOTIFICATION = 7
- private const val ACTION_PLAY = "io.github.artcraftandroid.pdfcraft.readaloud.PLAY"
- private const val ACTION_PAUSE = "io.github.artcraftandroid.pdfcraft.readaloud.PAUSE"
- private const val ACTION_BACK = "io.github.artcraftandroid.pdfcraft.readaloud.BACK"
- private const val ACTION_FORWARD = "io.github.artcraftandroid.pdfcraft.readaloud.FORWARD"
- private const val ACTION_STOP = "io.github.artcraftandroid.pdfcraft.readaloud.STOP"
+ private const val ACTION_PLAY = "com.chethan616.clearpdf.readaloud.PLAY"
+ private const val ACTION_PAUSE = "com.chethan616.clearpdf.readaloud.PAUSE"
+ private const val ACTION_BACK = "com.chethan616.clearpdf.readaloud.BACK"
+ private const val ACTION_FORWARD = "com.chethan616.clearpdf.readaloud.FORWARD"
+ private const val ACTION_STOP = "com.chethan616.clearpdf.readaloud.STOP"
private const val EXTRA_TITLE = "title"
private const val EXTRA_PLAYING = "playing"
private var lastTitle = ""
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/Strings.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/Strings.kt
similarity index 95%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/Strings.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/Strings.kt
index 3e266cc..c0dcf8b 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/Strings.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/Strings.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft
+package com.chethan616.clearpdf
import android.content.Context
import androidx.annotation.PluralsRes
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/DigitalIds.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/DigitalIds.kt
similarity index 97%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/DigitalIds.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/DigitalIds.kt
index d7a8860..25bc9f8 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/DigitalIds.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/DigitalIds.kt
@@ -1,9 +1,9 @@
-package io.github.artcraftandroid.pdfcraft.engine
+package com.chethan616.clearpdf.engine
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
-import io.github.artcraftandroid.pdfcraft.core.DigitalIdInfo
+import com.chethan616.clearpdf.core.DigitalIdInfo
import java.io.File
import org.json.JSONArray
import org.json.JSONObject
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/DocumentFiles.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/DocumentFiles.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/DocumentFiles.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/DocumentFiles.kt
index eff66e1..c0f5057 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/DocumentFiles.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/DocumentFiles.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.engine
+package com.chethan616.clearpdf.engine
import android.content.ContentResolver
import android.content.Context
@@ -8,7 +8,7 @@ import android.provider.DocumentsContract
import android.provider.MediaStore
import android.provider.OpenableColumns
import androidx.core.content.FileProvider
-import io.github.artcraftandroid.pdfcraft.R
+import com.chethan616.clearpdf.R
import java.io.File
import java.io.IOException
import java.security.MessageDigest
@@ -207,12 +207,12 @@ class DocumentFiles(private val context: Context) {
return uri
}
- /** Save an image into Pictures/PdfCraft (exported pages). */
+ /** Save an image into Pictures/ClearPDF (exported pages). */
fun saveToPictures(file: File, name: String, mime: String): Uri {
val values = android.content.ContentValues().apply {
put(android.provider.MediaStore.MediaColumns.DISPLAY_NAME, name)
put(android.provider.MediaStore.MediaColumns.MIME_TYPE, mime)
- put(android.provider.MediaStore.MediaColumns.RELATIVE_PATH, android.os.Environment.DIRECTORY_PICTURES + "/PdfCraft")
+ put(android.provider.MediaStore.MediaColumns.RELATIVE_PATH, android.os.Environment.DIRECTORY_PICTURES + "/ClearPDF")
}
val uri = resolver.insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values) ?: error(context.getString(R.string.files_error_save_image))
resolver.openOutputStream(uri).use { out ->
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/Engine.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/Engine.kt
similarity index 92%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/Engine.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/Engine.kt
index 4060537..0ce643f 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/Engine.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/Engine.kt
@@ -1,12 +1,12 @@
-package io.github.artcraftandroid.pdfcraft.engine
+package com.chethan616.clearpdf.engine
import android.graphics.Bitmap
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.core.MobileException
-import io.github.artcraftandroid.pdfcraft.core.MobileSession
-import io.github.artcraftandroid.pdfcraft.core.RenderedImage
-import io.github.artcraftandroid.pdfcraft.core.initLogging
-import io.github.artcraftandroid.pdfcraft.text
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.core.MobileException
+import com.chethan616.clearpdf.core.MobileSession
+import com.chethan616.clearpdf.core.RenderedImage
+import com.chethan616.clearpdf.core.initLogging
+import com.chethan616.clearpdf.text
import java.nio.ByteBuffer
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/LocalFiles.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/LocalFiles.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/LocalFiles.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/LocalFiles.kt
index 482afd2..42d91e9 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/LocalFiles.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/LocalFiles.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.engine
+package com.chethan616.clearpdf.engine
import android.content.Context
import android.content.Intent
@@ -9,8 +9,8 @@ import android.content.ContentUris
import android.provider.DocumentsContract
import android.provider.MediaStore
import android.provider.OpenableColumns
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.core.fileThumbnail
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.core.fileThumbnail
import java.io.File
import java.security.MessageDigest
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/RecentFiles.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/RecentFiles.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/RecentFiles.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/RecentFiles.kt
index fc54c4a..6aa5b70 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/RecentFiles.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/RecentFiles.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.engine
+package com.chethan616.clearpdf.engine
import java.io.File
import org.json.JSONArray
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/UserBookmarks.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/UserBookmarks.kt
similarity index 95%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/UserBookmarks.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/UserBookmarks.kt
index 18eb00f..290571b 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/UserBookmarks.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/engine/UserBookmarks.kt
@@ -1,8 +1,8 @@
-package io.github.artcraftandroid.pdfcraft.engine
+package com.chethan616.clearpdf.engine
import androidx.compose.runtime.mutableStateMapOf
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.text
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.text
import java.io.File
import org.json.JSONArray
import org.json.JSONObject
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.kt
similarity index 87%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.kt
index 4dec64f..3b6c0e0 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.kt
@@ -1,28 +1,28 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import android.app.ActivityManager
-import io.github.artcraftandroid.pdfcraft.ui.home.FileTool
-import io.github.artcraftandroid.pdfcraft.ui.viewer.FillElement
+import com.chethan616.clearpdf.ui.home.FileTool
+import com.chethan616.clearpdf.ui.viewer.FillElement
import androidx.compose.ui.graphics.asImageBitmap
-import io.github.artcraftandroid.pdfcraft.engine.toBitmap
-import io.github.artcraftandroid.pdfcraft.engine.UserBookmark
-import io.github.artcraftandroid.pdfcraft.engine.UserBookmarks
-import io.github.artcraftandroid.pdfcraft.ui.viewer.NotePrompt
-import io.github.artcraftandroid.pdfcraft.ui.viewer.VoicePrompt
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ReplyPrompt
-import io.github.artcraftandroid.pdfcraft.ui.viewer.StyledTool
-import io.github.artcraftandroid.pdfcraft.ui.viewer.TextMarkup
-import io.github.artcraftandroid.pdfcraft.ui.viewer.TextPrompt
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ToolPrefs
-import io.github.artcraftandroid.pdfcraft.ui.viewer.engineType
-import io.github.artcraftandroid.pdfcraft.ui.viewer.hex
+import com.chethan616.clearpdf.engine.toBitmap
+import com.chethan616.clearpdf.engine.UserBookmark
+import com.chethan616.clearpdf.engine.UserBookmarks
+import com.chethan616.clearpdf.ui.viewer.NotePrompt
+import com.chethan616.clearpdf.ui.viewer.VoicePrompt
+import com.chethan616.clearpdf.ui.viewer.ReplyPrompt
+import com.chethan616.clearpdf.ui.viewer.StyledTool
+import com.chethan616.clearpdf.ui.viewer.TextMarkup
+import com.chethan616.clearpdf.ui.viewer.TextPrompt
+import com.chethan616.clearpdf.ui.viewer.ToolPrefs
+import com.chethan616.clearpdf.ui.viewer.engineType
+import com.chethan616.clearpdf.ui.viewer.hex
import android.content.ClipData
import android.content.Intent
import androidx.compose.runtime.snapshotFlow
-import io.github.artcraftandroid.pdfcraft.ui.viewer.LinkFlash
-import io.github.artcraftandroid.pdfcraft.ui.viewer.PagePoint
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ReadAloud
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerTool
+import com.chethan616.clearpdf.ui.viewer.LinkFlash
+import com.chethan616.clearpdf.ui.viewer.PagePoint
+import com.chethan616.clearpdf.ui.viewer.ReadAloud
+import com.chethan616.clearpdf.ui.viewer.ViewerTool
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.first
import org.json.JSONObject
@@ -34,17 +34,17 @@ import androidx.compose.runtime.setValue
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
-import io.github.artcraftandroid.pdfcraft.PdfcraftApplication
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.plural
-import io.github.artcraftandroid.pdfcraft.text
-import io.github.artcraftandroid.pdfcraft.core.MobileException
-import io.github.artcraftandroid.pdfcraft.engine.DocumentFiles
-import io.github.artcraftandroid.pdfcraft.engine.Engine
-import io.github.artcraftandroid.pdfcraft.engine.RecentFile
-import io.github.artcraftandroid.pdfcraft.engine.RecentFiles
-import io.github.artcraftandroid.pdfcraft.engine.userMessage
-import io.github.artcraftandroid.pdfcraft.ui.viewer.PageImages
+import com.chethan616.clearpdf.PdfcraftApplication
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.plural
+import com.chethan616.clearpdf.text
+import com.chethan616.clearpdf.core.MobileException
+import com.chethan616.clearpdf.engine.DocumentFiles
+import com.chethan616.clearpdf.engine.Engine
+import com.chethan616.clearpdf.engine.RecentFile
+import com.chethan616.clearpdf.engine.RecentFiles
+import com.chethan616.clearpdf.engine.userMessage
+import com.chethan616.clearpdf.ui.viewer.PageImages
import java.io.File
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.Channel
@@ -100,21 +100,6 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
(heapMb / 4).coerceIn(32, 192) * 1024 * 1024
}
- init {
- viewModelScope.launch {
- application.engine.await().onSuccess { engine = it }.onFailure { engineProblem = it.userMessage }
- refreshRecents()
- // the signers the reader trusts, before any signature is checked
- // (a document opened from another app meanwhile is checked again)
- engine?.let { eng ->
- if (withContext(Dispatchers.IO) { trustedCerts.files().isNotEmpty() }) {
- runCatching { applyTrust(eng) }
- document?.let { loadSignatures(eng, it) }
- }
- }
- }
- }
-
fun tell(text: String, actionLabel: String? = null, action: (() -> Unit)? = null) {
messages.trySend(Message(text, actionLabel, action))
}
@@ -311,7 +296,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
val pending = pendingPage
// the spot at the screen's top-left and the zoom, to reopen there (as the reference does)
val v = doc.viewer
- val spot = if (pending == null && v.mode == io.github.artcraftandroid.pdfcraft.ui.viewer.PageMode.Continuous) v.screenToPage(androidx.compose.ui.geometry.Offset(0f, v.padTop), nearest = true) else null
+ val spot = if (pending == null && v.mode == com.chethan616.clearpdf.ui.viewer.PageMode.Continuous) v.screenToPage(androidx.compose.ui.geometry.Offset(0f, v.padTop), nearest = true) else null
val zoom = v.zoom
withContext(Dispatchers.IO) {
// in Reading Mode the page canvas has no layout: the page read is the pending one
@@ -470,7 +455,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
commitInlineEdit(doc)
editSelection = null
editImage = null
- editMode = io.github.artcraftandroid.pdfcraft.ui.viewer.EditMode.Select
+ editMode = com.chethan616.clearpdf.ui.viewer.EditMode.Select
}
if (certPlacing === doc) certPlacing = null
doc.controller.tool = ViewerTool.None
@@ -677,16 +662,16 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
snapshotFlow { readAloud to (readAloud?.playing == true) }.collect { (ra, playing) ->
val ctx = getApplication<Application>()
if (ra == null) {
- io.github.artcraftandroid.pdfcraft.ReadAloudService.controls = null
- io.github.artcraftandroid.pdfcraft.ReadAloudService.hide(ctx)
+ com.chethan616.clearpdf.ReadAloudService.controls = null
+ com.chethan616.clearpdf.ReadAloudService.hide(ctx)
} else {
- io.github.artcraftandroid.pdfcraft.ReadAloudService.controls = object : io.github.artcraftandroid.pdfcraft.ReadAloudService.Controls {
+ com.chethan616.clearpdf.ReadAloudService.controls = object : com.chethan616.clearpdf.ReadAloudService.Controls {
override fun play() { readAloud?.play() }
override fun pause() { readAloud?.pause() }
override fun skip(forward: Boolean) { readAloud?.skip(forward) }
override fun stop() { readAloud?.stop() }
}
- io.github.artcraftandroid.pdfcraft.ReadAloudService.show(ctx, ra.title, playing)
+ com.chethan616.clearpdf.ReadAloudService.show(ctx, ra.title, playing)
}
}
}
@@ -728,7 +713,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
* While Read aloud is on, a tap on a word moves the reading there, as the reference's does. False
* when no word is under [at] (the tap then shows or hides the bars).
*/
- suspend fun readAloudAt(doc: OpenDocument, at: io.github.artcraftandroid.pdfcraft.ui.viewer.PagePoint, slopPoints: Float): Boolean {
+ suspend fun readAloudAt(doc: OpenDocument, at: com.chethan616.clearpdf.ui.viewer.PagePoint, slopPoints: Float): Boolean {
val current = readAloud ?: return false
val eng = engine ?: return false
val word = withContext(eng.commands) { eng.session.wordAt(doc.id, at.page.toUInt(), at.x, at.y, slopPoints) } ?: return false
@@ -743,7 +728,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
val toolPrefs = ToolPrefs(app)
/** The viewer's bottom toolbar as the user arranged it (More tools ▸ Customize toolbar). */
- val quickToolbar = io.github.artcraftandroid.pdfcraft.ui.viewer.QuickToolbarPrefs(app)
+ val quickToolbar = com.chethan616.clearpdf.ui.viewer.QuickToolbarPrefs(app)
private val appPrefs = app.getSharedPreferences("app", android.content.Context.MODE_PRIVATE)
private val bookmarkStore = UserBookmarks(File(app.filesDir, "bookmarks.json"))
@@ -820,18 +805,18 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
private set
/** The page mode documents open in (View settings; remembered app-wide). */
- val savedPageMode: io.github.artcraftandroid.pdfcraft.ui.viewer.PageMode
- get() = if (appPrefs.getString("pageMode", "continuous") == "single") io.github.artcraftandroid.pdfcraft.ui.viewer.PageMode.SinglePage
- else io.github.artcraftandroid.pdfcraft.ui.viewer.PageMode.Continuous
+ val savedPageMode: com.chethan616.clearpdf.ui.viewer.PageMode
+ get() = if (appPrefs.getString("pageMode", "continuous") == "single") com.chethan616.clearpdf.ui.viewer.PageMode.SinglePage
+ else com.chethan616.clearpdf.ui.viewer.PageMode.Continuous
val savedNightMode: Boolean get() = appPrefs.getBoolean("nightMode", false)
- fun setPageMode(doc: OpenDocument, mode: io.github.artcraftandroid.pdfcraft.ui.viewer.PageMode) {
+ fun setPageMode(doc: OpenDocument, mode: com.chethan616.clearpdf.ui.viewer.PageMode) {
// leaving Reading Mode: a canvas laid out already followed the page read; else it shows it on layout
if (readingMode && doc.viewer.viewW > 0f) pendingPage = null
readingMode = false
doc.viewer.switchMode(mode)
- appPrefs.edit().putString("pageMode", if (mode == io.github.artcraftandroid.pdfcraft.ui.viewer.PageMode.SinglePage) "single" else "continuous").apply()
+ appPrefs.edit().putString("pageMode", if (mode == com.chethan616.clearpdf.ui.viewer.PageMode.SinglePage) "single" else "continuous").apply()
}
fun setNightMode(doc: OpenDocument, on: Boolean) {
@@ -1057,7 +1042,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
/** Voice comment [c]'s recording as a WAV file to play, or null when it can't be read. */
- suspend fun voiceRecording(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo): File? {
+ suspend fun voiceRecording(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo): File? {
val eng = engine ?: return null
val f = File(getApplication<Application>().cacheDir, "voice-play.wav")
return withContext(eng.commands) {
@@ -1075,8 +1060,8 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
fun copyText(text: String) {
val cm = getApplication<Application>().getSystemService(android.content.ClipboardManager::class.java)
// the parameter `text` hides the text() function here: called by its full name
- cm?.setPrimaryClip(android.content.ClipData.newPlainText(io.github.artcraftandroid.pdfcraft.text(R.string.msg_clip_comment), text))
- if (android.os.Build.VERSION.SDK_INT < 33) tell(io.github.artcraftandroid.pdfcraft.text(R.string.msg_copied))
+ cm?.setPrimaryClip(android.content.ClipData.newPlainText(com.chethan616.clearpdf.text(R.string.msg_clip_comment), text))
+ if (android.os.Build.VERSION.SDK_INT < 33) tell(com.chethan616.clearpdf.text(R.string.msg_copied))
}
/** Copy the selected text (when the document allows copying). */
@@ -1088,9 +1073,9 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
viewModelScope.launch {
val text = doc.selection.text() ?: return@launch
val cm = getApplication<Application>().getSystemService(android.content.ClipboardManager::class.java)
- cm?.setPrimaryClip(android.content.ClipData.newPlainText(io.github.artcraftandroid.pdfcraft.text(R.string.msg_clip_pdf_text), text))
+ cm?.setPrimaryClip(android.content.ClipData.newPlainText(com.chethan616.clearpdf.text(R.string.msg_clip_pdf_text), text))
doc.selection.clear()
- if (android.os.Build.VERSION.SDK_INT < 33) tell(io.github.artcraftandroid.pdfcraft.text(R.string.msg_copied))
+ if (android.os.Build.VERSION.SDK_INT < 33) tell(com.chethan616.clearpdf.text(R.string.msg_copied))
}
}
@@ -1157,24 +1142,24 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
// ---- Fill & Sign -------------------------------------------------------------------------
/** The element a tap places. */
- var fillElement by mutableStateOf(io.github.artcraftandroid.pdfcraft.ui.viewer.FillElement.Text)
+ var fillElement by mutableStateOf(com.chethan616.clearpdf.ui.viewer.FillElement.Text)
/** Fill & Sign text waiting to be typed. */
var fillTextPrompt by mutableStateOf<TextPrompt?>(null)
- val signatures = io.github.artcraftandroid.pdfcraft.ui.viewer.Signatures(app.filesDir)
+ val signatures = com.chethan616.clearpdf.ui.viewer.Signatures(app.filesDir)
/** Bumped when a saved signature is cleared or replaced, so the panel redraws. */
var signaturesChanged by mutableStateOf(0)
/** A signature or initials being made. */
- var signaturePad by mutableStateOf<io.github.artcraftandroid.pdfcraft.ui.viewer.SignaturePad?>(null)
+ var signaturePad by mutableStateOf<com.chethan616.clearpdf.ui.viewer.SignaturePad?>(null)
/** A signature taken from an image (Image tab), before Done. */
var importedSignature by mutableStateOf<android.graphics.Bitmap?>(null)
/** Place [element] at [at] on its page. */
- fun placeFill(doc: OpenDocument, element: io.github.artcraftandroid.pdfcraft.ui.viewer.FillElement, at: PagePoint, text: String? = null) {
+ fun placeFill(doc: OpenDocument, element: com.chethan616.clearpdf.ui.viewer.FillElement, at: PagePoint, text: String? = null) {
if (element == FillElement.Box) {
// a rounded box around what was tapped, in the Fill & Sign colour: drawn as one ink stroke
val r = toolPrefs.fillTextSize
@@ -1215,11 +1200,11 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
fun postFillText(prompt: TextPrompt, text: String) {
fillTextPrompt = null
if (text.isBlank()) return
- placeFill(prompt.doc, io.github.artcraftandroid.pdfcraft.ui.viewer.FillElement.Text, prompt.at, text)
+ placeFill(prompt.doc, com.chethan616.clearpdf.ui.viewer.FillElement.Text, prompt.at, text)
}
/** A signature or initials was made: save it (if asked) and place it where the page was tapped. */
- fun finishSignature(pad: io.github.artcraftandroid.pdfcraft.ui.viewer.SignaturePad, bitmap: android.graphics.Bitmap, save: Boolean) {
+ fun finishSignature(pad: com.chethan616.clearpdf.ui.viewer.SignaturePad, bitmap: android.graphics.Bitmap, save: Boolean) {
signaturePad = null
importedSignature = null
viewModelScope.launch {
@@ -1270,32 +1255,32 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
// ---- Digital signatures: signing with a digital ID, and what a document's signatures say ----
/** The digital IDs the reader added or made (lazy: the engine's start may need them first). */
- val digitalIds by lazy { io.github.artcraftandroid.pdfcraft.engine.DigitalIds(app.filesDir) }
+ val digitalIds by lazy { com.chethan616.clearpdf.engine.DigitalIds(app.filesDir) }
/** The signers the reader chose to trust, given to the engine when it starts. */
- val trustedCerts by lazy { io.github.artcraftandroid.pdfcraft.engine.TrustedCertificates(app.filesDir) }
+ val trustedCerts by lazy { com.chethan616.clearpdf.engine.TrustedCertificates(app.filesDir) }
/** The document a digital signature's box is being drawn on (Sign ▸ Sign with a digital ID). */
var certPlacing by mutableStateOf<OpenDocument?>(null)
/** Sign with a digital ID, open for where the signature goes. */
- var certSign by mutableStateOf<io.github.artcraftandroid.pdfcraft.ui.viewer.CertTarget?>(null)
+ var certSign by mutableStateOf<com.chethan616.clearpdf.ui.viewer.CertTarget?>(null)
/** Why the last signing failed (a wrong password), shown on the Sign screen. */
var certSignError by mutableStateOf<String?>(null)
/** The digital ID chosen on the Sign screen. */
- var chosenId by mutableStateOf<io.github.artcraftandroid.pdfcraft.engine.DigitalId?>(null)
+ var chosenId by mutableStateOf<com.chethan616.clearpdf.engine.DigitalId?>(null)
/** A picked digital ID file, waiting for its password. */
- var idImport by mutableStateOf<io.github.artcraftandroid.pdfcraft.ui.viewer.IdImport?>(null)
+ var idImport by mutableStateOf<com.chethan616.clearpdf.ui.viewer.IdImport?>(null)
private set
/** Create a digital ID is open. */
var idCreate by mutableStateOf(false)
/** An empty signature field was tapped: draw a signature there, or sign it with a digital ID. */
- var signFieldChoice by mutableStateOf<Pair<OpenDocument, io.github.artcraftandroid.pdfcraft.core.WidgetInfo>?>(null)
+ var signFieldChoice by mutableStateOf<Pair<OpenDocument, com.chethan616.clearpdf.core.WidgetInfo>?>(null)
/** Draw the box for a new digital signature on [doc], in Fill & Sign. */
fun startCertPlacing(doc: OpenDocument) {
@@ -1312,19 +1297,19 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
/** The box was drawn: on to choosing the ID. */
fun placeCert(doc: OpenDocument, page: Int, rect: FloatArray) {
certPlacing = null
- openCertSign(io.github.artcraftandroid.pdfcraft.ui.viewer.CertTarget(doc, null, page, rect))
+ openCertSign(com.chethan616.clearpdf.ui.viewer.CertTarget(doc, null, page, rect))
}
- fun signFieldWithId(doc: OpenDocument, w: io.github.artcraftandroid.pdfcraft.core.WidgetInfo) {
- openCertSign(io.github.artcraftandroid.pdfcraft.ui.viewer.CertTarget(doc, w.field, w.page.toInt(), null))
+ fun signFieldWithId(doc: OpenDocument, w: com.chethan616.clearpdf.core.WidgetInfo) {
+ openCertSign(com.chethan616.clearpdf.ui.viewer.CertTarget(doc, w.field, w.page.toInt(), null))
}
/** A drawn (Fill & Sign) signature in signature field [w], as a tap on it did before digital IDs. */
- fun drawSignatureInField(doc: OpenDocument, w: io.github.artcraftandroid.pdfcraft.core.WidgetInfo) {
- signaturePad = io.github.artcraftandroid.pdfcraft.ui.viewer.SignaturePad(false, doc, PagePoint(w.page.toInt(), (w.rect[0] + w.rect[2]) / 2f - 40f, (w.rect[1] + w.rect[3]) / 2f - 10f))
+ fun drawSignatureInField(doc: OpenDocument, w: com.chethan616.clearpdf.core.WidgetInfo) {
+ signaturePad = com.chethan616.clearpdf.ui.viewer.SignaturePad(false, doc, PagePoint(w.page.toInt(), (w.rect[0] + w.rect[2]) / 2f - 40f, (w.rect[1] + w.rect[3]) / 2f - 10f))
}
- private fun openCertSign(t: io.github.artcraftandroid.pdfcraft.ui.viewer.CertTarget) {
+ private fun openCertSign(t: com.chethan616.clearpdf.ui.viewer.CertTarget) {
certSignError = null
val ids = digitalIds.all
if (chosenId !in ids) chosenId = ids.lastOrNull()
@@ -1343,7 +1328,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
viewModelScope.launch {
try {
- val info = withContext(Dispatchers.IO) { io.github.artcraftandroid.pdfcraft.core.digitalIdInfo(imp.file.absolutePath, password) }
+ val info = withContext(Dispatchers.IO) { com.chethan616.clearpdf.core.digitalIdInfo(imp.file.absolutePath, password) }
val problem = info.problem
if (problem != null) {
imp.file.delete()
@@ -1355,7 +1340,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
chosenId = id
tell(text(R.string.msg_id_added, id.name))
} catch (e: MobileException.WrongPassword) {
- idImport = io.github.artcraftandroid.pdfcraft.ui.viewer.IdImport(imp.file, imp.name, wrong = true)
+ idImport = com.chethan616.clearpdf.ui.viewer.IdImport(imp.file, imp.name, wrong = true)
} catch (e: MobileException) {
imp.file.delete()
tell(text(R.string.msg_id_unusable, e.userMessage))
@@ -1374,7 +1359,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
"name" to name.trim(), "email" to email.trim().ifEmpty { null }, "organization" to organization.trim().ifEmpty { null },
"password" to password, "path" to tmp.absolutePath,
))
- val info = withContext(Dispatchers.IO) { io.github.artcraftandroid.pdfcraft.core.digitalIdInfo(tmp.absolutePath, password) }
+ val info = withContext(Dispatchers.IO) { com.chethan616.clearpdf.core.digitalIdInfo(tmp.absolutePath, password) }
chosenId = withContext(Dispatchers.IO) { digitalIds.add(tmp, info) }
idCreate = false
tell(text(R.string.msg_id_created))
@@ -1387,7 +1372,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
}
- fun removeDigitalId(id: io.github.artcraftandroid.pdfcraft.engine.DigitalId) {
+ fun removeDigitalId(id: com.chethan616.clearpdf.engine.DigitalId) {
digitalIds.remove(id)
if (chosenId == id) chosenId = digitalIds.all.lastOrNull()
}
@@ -1397,10 +1382,10 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
* saved) and the signed file replaces the working copy, then goes back where it came from.
*/
fun signWithId(
- t: io.github.artcraftandroid.pdfcraft.ui.viewer.CertTarget,
- id: io.github.artcraftandroid.pdfcraft.engine.DigitalId,
+ t: com.chethan616.clearpdf.ui.viewer.CertTarget,
+ id: com.chethan616.clearpdf.engine.DigitalId,
password: String,
- look: io.github.artcraftandroid.pdfcraft.ui.viewer.CertLook,
+ look: com.chethan616.clearpdf.ui.viewer.CertLook,
reason: String,
location: String,
) {
@@ -1420,9 +1405,9 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
args["rect"] = t.rect?.map { it.toDouble() }
}
when (look) {
- io.github.artcraftandroid.pdfcraft.ui.viewer.CertLook.Name -> Unit
- io.github.artcraftandroid.pdfcraft.ui.viewer.CertLook.Typed -> args["graphic"] = mapOf("text" to id.name)
- io.github.artcraftandroid.pdfcraft.ui.viewer.CertLook.Drawn -> args["graphic"] = mapOf("image" to signatures.signature.absolutePath)
+ com.chethan616.clearpdf.ui.viewer.CertLook.Name -> Unit
+ com.chethan616.clearpdf.ui.viewer.CertLook.Typed -> args["graphic"] = mapOf("text" to id.name)
+ com.chethan616.clearpdf.ui.viewer.CertLook.Drawn -> args["graphic"] = mapOf("image" to signatures.signature.absolutePath)
}
eng.tool("sign_document", args)
certSign = null
@@ -1455,7 +1440,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
doc.signatures = emptyList()
return
}
- doc.signatures = runCatching { io.github.artcraftandroid.pdfcraft.ui.viewer.parseSignatures(eng.tool("sign_list", mapOf("doc" to doc.id))) }.getOrDefault(emptyList())
+ doc.signatures = runCatching { com.chethan616.clearpdf.ui.viewer.parseSignatures(eng.tool("sign_list", mapOf("doc" to doc.id))) }.getOrDefault(emptyList())
}
/** On opening a signed document: whether its signatures hold, with the details a tap away. */
@@ -1465,20 +1450,20 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
val one = signed.singleOrNull()
// the local `text` hides the text() function here: called by its full name
val text = when {
- signed.any { it.status == "invalid" } -> io.github.artcraftandroid.pdfcraft.text(if (one != null) R.string.msg_sig_invalid else R.string.msg_sig_some_invalid)
+ signed.any { it.status == "invalid" } -> com.chethan616.clearpdf.text(if (one != null) R.string.msg_sig_invalid else R.string.msg_sig_some_invalid)
signed.all { it.status == "valid" } -> if (one != null) {
- one.signer?.let { io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_valid, it) } ?: io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_valid_unknown)
+ one.signer?.let { com.chethan616.clearpdf.text(R.string.msg_sig_valid, it) } ?: com.chethan616.clearpdf.text(R.string.msg_sig_valid_unknown)
} else {
plural(R.plurals.msg_sig_all_valid, signed.size, signed.size)
}
- one != null -> one.signer?.let { io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_unverified, it) } ?: io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_unverified_unknown)
- else -> io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_some_unverified)
+ one != null -> one.signer?.let { com.chethan616.clearpdf.text(R.string.msg_sig_unverified, it) } ?: com.chethan616.clearpdf.text(R.string.msg_sig_unverified_unknown)
+ else -> com.chethan616.clearpdf.text(R.string.msg_sig_some_unverified)
}
- tell(text, io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_details)) { doc.controller.sheet = io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerSheet.Signatures }
+ tell(text, com.chethan616.clearpdf.text(R.string.msg_sig_details)) { doc.controller.sheet = com.chethan616.clearpdf.ui.viewer.ViewerSheet.Signatures }
}
/** Show signature [s] on its page, flashing its box. */
- fun showSignature(doc: OpenDocument, s: io.github.artcraftandroid.pdfcraft.ui.viewer.SignatureEntry) {
+ fun showSignature(doc: OpenDocument, s: com.chethan616.clearpdf.ui.viewer.SignatureEntry) {
val page = s.page ?: return
val rect = s.rect ?: return
doc.viewer.goToPage(page, (rect[1] - 60f).coerceAtLeast(0f))
@@ -1491,7 +1476,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
/** Trust the certificate that made signature [s], on this device: signatures by it then validate. */
- fun trustSigner(doc: OpenDocument, s: io.github.artcraftandroid.pdfcraft.ui.viewer.SignatureEntry) {
+ fun trustSigner(doc: OpenDocument, s: com.chethan616.clearpdf.ui.viewer.SignatureEntry) {
val eng = engine ?: return
val sha = s.cert?.sha256 ?: return
viewModelScope.launch {
@@ -1507,7 +1492,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
}
- fun untrustSigner(doc: OpenDocument, s: io.github.artcraftandroid.pdfcraft.ui.viewer.SignatureEntry) {
+ fun untrustSigner(doc: OpenDocument, s: com.chethan616.clearpdf.ui.viewer.SignatureEntry) {
val eng = engine ?: return
val sha = s.cert?.sha256 ?: return
viewModelScope.launch {
@@ -1525,15 +1510,15 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
// ---- Edit PDF ----------------------------------------------------------------------------
- var editMode by mutableStateOf(io.github.artcraftandroid.pdfcraft.ui.viewer.EditMode.Select)
+ var editMode by mutableStateOf(com.chethan616.clearpdf.ui.viewer.EditMode.Select)
/** Each page's paragraphs (0-based page), read when Edit PDF shows the page. */
- val paragraphs = androidx.compose.runtime.mutableStateMapOf<Int, List<io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph>>()
+ val paragraphs = androidx.compose.runtime.mutableStateMapOf<Int, List<com.chethan616.clearpdf.ui.viewer.Paragraph>>()
private var paragraphsGen = -1L
/** The paragraph tapped once (outlined), and the one open in the editor. */
- var editSelection by mutableStateOf<io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph?>(null)
- var editing by mutableStateOf<io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph?>(null)
+ var editSelection by mutableStateOf<com.chethan616.clearpdf.ui.viewer.Paragraph?>(null)
+ var editing by mutableStateOf<com.chethan616.clearpdf.ui.viewer.Paragraph?>(null)
suspend fun loadParagraphs(doc: OpenDocument, page: Int) {
val eng = engine ?: return
@@ -1548,7 +1533,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
val o = arr.optJSONObject(i) ?: return@mapNotNull null
val rect = o.optJSONArray("rect") ?: return@mapNotNull null
val font = o.optString("font")
- io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph(
+ com.chethan616.clearpdf.ui.viewer.Paragraph(
page = page, number = o.optInt("paragraph"), text = o.optString("text"),
box = FloatArray(4) { k -> rect.optDouble(k).toFloat() }, font = font, size = o.optDouble("size", 12.0).toFloat(),
bold = if (o.has("bold")) o.optBoolean("bold") else font.contains("Bold", true) || font.contains("Black", true) || font.contains("Heavy", true),
@@ -1568,14 +1553,14 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
editSelection = null
return
}
- if (editMode == io.github.artcraftandroid.pdfcraft.ui.viewer.EditMode.AddText) {
- editMode = io.github.artcraftandroid.pdfcraft.ui.viewer.EditMode.Select
+ if (editMode == com.chethan616.clearpdf.ui.viewer.EditMode.AddText) {
+ editMode = com.chethan616.clearpdf.ui.viewer.EditMode.Select
editSelection = null
addTextPrompt = TextPrompt(doc, at)
return
}
- if (editMode == io.github.artcraftandroid.pdfcraft.ui.viewer.EditMode.AddImage) {
- editMode = io.github.artcraftandroid.pdfcraft.ui.viewer.EditMode.Select
+ if (editMode == com.chethan616.clearpdf.ui.viewer.EditMode.AddImage) {
+ editMode = com.chethan616.clearpdf.ui.viewer.EditMode.Select
editSelection = null
addImageAt(doc, at)
return
@@ -1586,7 +1571,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
/** The picture selected in Edit PDF. */
- var editImage by mutableStateOf<io.github.artcraftandroid.pdfcraft.ui.viewer.EditImage?>(null)
+ var editImage by mutableStateOf<com.chethan616.clearpdf.ui.viewer.EditImage?>(null)
/** Formatting the engine doesn't report back, kept per paragraph (page to number) while editing. */
val editFont = androidx.compose.runtime.mutableStateMapOf<Pair<Int, Int>, String>()
@@ -1597,7 +1582,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
var editSelectAll = false
var editDraft: String? = null
- fun startInlineEdit(para: io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph, selectAll: Boolean) {
+ fun startInlineEdit(para: com.chethan616.clearpdf.ui.viewer.Paragraph, selectAll: Boolean) {
editSelectAll = selectAll
editDraft = para.text
editSelection = para
@@ -1613,48 +1598,48 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
if (text != para.text) runTool(doc, "text_edit", mapOf("page" to para.page + 1, "paragraph" to para.number, "text" to text))
}
- private fun paraArgs(para: io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph) = mapOf<String, Any?>("page" to para.page + 1, "paragraph" to para.number)
+ private fun paraArgs(para: com.chethan616.clearpdf.ui.viewer.Paragraph) = mapOf<String, Any?>("page" to para.page + 1, "paragraph" to para.number)
/** Make [para] a list of [style] (or plain again), with any typing so far. */
- fun listParagraph(doc: OpenDocument, para: io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph, style: io.github.artcraftandroid.pdfcraft.ui.viewer.ListStyle) {
+ fun listParagraph(doc: OpenDocument, para: com.chethan616.clearpdf.ui.viewer.Paragraph, style: com.chethan616.clearpdf.ui.viewer.ListStyle) {
val typing = editing != null && editing?.number == para.number && editing?.page == para.page
val base = if (typing) editDraft ?: para.text else para.text
- val text = io.github.artcraftandroid.pdfcraft.ui.viewer.ListStyle.apply(base, style)
+ val text = com.chethan616.clearpdf.ui.viewer.ListStyle.apply(base, style)
if (text == base) return
if (typing) editDraft = text
runTool(doc, "text_edit", paraArgs(para) + ("text" to text))
}
/** A formatting change to [para], applied to the page at once (with any typing so far). */
- fun styleParagraph(doc: OpenDocument, para: io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph, style: Map<String, Any?>) {
+ fun styleParagraph(doc: OpenDocument, para: com.chethan616.clearpdf.ui.viewer.Paragraph, style: Map<String, Any?>) {
val typed = editDraft?.takeIf { editing != null && it != para.text }
runTool(doc, "text_edit", paraArgs(para) + style + (if (typed != null) mapOf("text" to typed) else emptyMap()))
}
/** Move [para] by ([dx], [dy]) points (right and down on screen). */
- fun moveParagraph(doc: OpenDocument, para: io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph, dx: Float, dy: Float) {
+ fun moveParagraph(doc: OpenDocument, para: com.chethan616.clearpdf.ui.viewer.Paragraph, dx: Float, dy: Float) {
runTool(doc, "text_edit", paraArgs(para) + mapOf("dx" to dx.toDouble(), "dy" to -dy.toDouble()))
}
/** Rewrap [para] to [width] points, moving it [shift] points right first (dragged from the left). */
- fun resizeParagraph(doc: OpenDocument, para: io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph, width: Float, shift: Float) {
+ fun resizeParagraph(doc: OpenDocument, para: com.chethan616.clearpdf.ui.viewer.Paragraph, width: Float, shift: Float) {
val args = paraArgs(para) + ("width" to width.toDouble()) + (if (shift != 0f) mapOf("dx" to shift.toDouble()) else emptyMap())
runTool(doc, "text_edit", args)
}
- fun deleteParagraph(doc: OpenDocument, para: io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph) {
+ fun deleteParagraph(doc: OpenDocument, para: com.chethan616.clearpdf.ui.viewer.Paragraph) {
editSelection = null
editing = null
runTool(doc, "text_edit", paraArgs(para) + ("text" to ""))
}
/** The page's colour just outside [para], for typing over it. */
- suspend fun paperColor(doc: OpenDocument, para: io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph): androidx.compose.ui.graphics.Color? {
+ suspend fun paperColor(doc: OpenDocument, para: com.chethan616.clearpdf.ui.viewer.Paragraph): androidx.compose.ui.graphics.Color? {
val eng = engine ?: return null
val x = (para.box[0] - 4f).coerceAtLeast(0f).toInt().toUInt()
val y = (para.box[1] - 4f).coerceAtLeast(0f).toInt().toUInt()
val img = runCatching {
- withContext(eng.thumbnails) { eng.session.renderPage(doc.id, para.page.toUInt(), 1f, io.github.artcraftandroid.pdfcraft.core.TileRect(x, y, 2u, 2u)) }
+ withContext(eng.thumbnails) { eng.session.renderPage(doc.id, para.page.toUInt(), 1f, com.chethan616.clearpdf.core.TileRect(x, y, 2u, 2u)) }
}.getOrNull() ?: return null
val px = img.rgba
if (px.size < 4) return null
@@ -1666,7 +1651,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
/** The picture drawn under [at], topmost first, if any. */
- private suspend fun imageUnder(doc: OpenDocument, at: PagePoint): io.github.artcraftandroid.pdfcraft.ui.viewer.EditImage? {
+ private suspend fun imageUnder(doc: OpenDocument, at: PagePoint): com.chethan616.clearpdf.ui.viewer.EditImage? {
val eng = engine ?: return null
val r = runCatching { eng.tool("page_images", mapOf("doc" to doc.id, "page" to at.page + 1)) }.getOrNull() ?: return null
val arr = r.optJSONArray("images") ?: return null
@@ -1676,14 +1661,14 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
val box = FloatArray(4) { k -> rect.optDouble(k).toFloat() }
if (at.x in box[0]..box[2] && at.y in box[1]..box[3]) {
val full = o.optJSONArray("rect") ?: rect
- return io.github.artcraftandroid.pdfcraft.ui.viewer.EditImage(at.page, o.optInt("image"), FloatArray(4) { k -> full.optDouble(k).toFloat() })
+ return com.chethan616.clearpdf.ui.viewer.EditImage(at.page, o.optInt("image"), FloatArray(4) { k -> full.optDouble(k).toFloat() })
}
}
return null
}
/** The menu a long press on an empty part of a page opens. */
- var pageMenu by mutableStateOf<io.github.artcraftandroid.pdfcraft.ui.viewer.PageMenu?>(null)
+ var pageMenu by mutableStateOf<com.chethan616.clearpdf.ui.viewer.PageMenu?>(null)
/**
* A long press where no word is: on a picture, Edit PDF with the picture selected (the
@@ -1694,29 +1679,29 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
viewModelScope.launch {
val img = imageUnder(doc, at)
if (img != null) {
- enterTool(doc, io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerTool.Edit)
- if (doc.controller.tool == io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerTool.Edit) editImage = img
+ enterTool(doc, com.chethan616.clearpdf.ui.viewer.ViewerTool.Edit)
+ if (doc.controller.tool == com.chethan616.clearpdf.ui.viewer.ViewerTool.Edit) editImage = img
return@launch
}
val glyphs = runCatching { withContext(eng.commands) { eng.session.glyphCount(doc.id, at.page.toUInt()) } }.getOrDefault(1u)
- pageMenu = io.github.artcraftandroid.pdfcraft.ui.viewer.PageMenu(doc, at, screen, pageHasText = glyphs > 0u)
+ pageMenu = com.chethan616.clearpdf.ui.viewer.PageMenu(doc, at, screen, pageHasText = glyphs > 0u)
}
}
/** Put [img] in [rect] (points): a move or a resize. */
- fun placeImage(doc: OpenDocument, img: io.github.artcraftandroid.pdfcraft.ui.viewer.EditImage, rect: FloatArray) {
+ fun placeImage(doc: OpenDocument, img: com.chethan616.clearpdf.ui.viewer.EditImage, rect: FloatArray) {
editImage = img.copy(rect = rect)
runTool(doc, "image_edit", mapOf("page" to img.page + 1, "image" to img.number, "action" to "move", "rect" to rect.map { it.toDouble() }))
}
- fun turnImage(doc: OpenDocument, img: io.github.artcraftandroid.pdfcraft.ui.viewer.EditImage, quarters: Int) {
+ fun turnImage(doc: OpenDocument, img: com.chethan616.clearpdf.ui.viewer.EditImage, quarters: Int) {
runTool(doc, "image_edit", mapOf("page" to img.page + 1, "image" to img.number, "action" to "rotate", "quarters" to quarters)) {
// the turned picture keeps its centre; read its new box
selectImageAt(doc, PagePoint(img.page, (img.rect[0] + img.rect[2]) / 2f, (img.rect[1] + img.rect[3]) / 2f))
}
}
- fun deleteImage(doc: OpenDocument, img: io.github.artcraftandroid.pdfcraft.ui.viewer.EditImage) {
+ fun deleteImage(doc: OpenDocument, img: com.chethan616.clearpdf.ui.viewer.EditImage) {
editImage = null
runTool(doc, "image_edit", mapOf("page" to img.page + 1, "image" to img.number, "action" to "delete"))
}
@@ -1820,10 +1805,10 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
// ---- Forms -------------------------------------------------------------------------------
/** The field being filled in. */
- var fieldEdit by mutableStateOf<io.github.artcraftandroid.pdfcraft.ui.viewer.FieldEdit?>(null)
+ var fieldEdit by mutableStateOf<com.chethan616.clearpdf.ui.viewer.FieldEdit?>(null)
/** The top bar's Reset and arrows while a text field is filled. */
- var fieldActions by mutableStateOf<io.github.artcraftandroid.pdfcraft.ui.viewer.FieldActions?>(null)
+ var fieldActions by mutableStateOf<com.chethan616.clearpdf.ui.viewer.FieldActions?>(null)
/**
* A tap at [at]: fill the form field there, if any (a check box or radio button toggles at
@@ -1842,10 +1827,10 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
when (w.kind) {
"checkbox" -> fillField(doc, w.field, !w.on)
"radio" -> w.export?.let { fillField(doc, w.field, it) }
- "text", "combo", "list" -> fieldEdit = io.github.artcraftandroid.pdfcraft.ui.viewer.FieldEdit(doc, w)
+ "text", "combo", "list" -> fieldEdit = com.chethan616.clearpdf.ui.viewer.FieldEdit(doc, w)
// a signed field shows its signature's details; an empty one, a drawn or a digital signature
"signature" -> if (doc.signatures.any { it.field == w.field && it.signed }) {
- doc.controller.sheet = io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerSheet.Signatures
+ doc.controller.sheet = com.chethan616.clearpdf.ui.viewer.ViewerSheet.Signatures
} else {
signFieldChoice = doc to w
}
@@ -1860,7 +1845,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
* clear the form (or the fields it names), open a web address after asking, go to a page, or
* run its script. Sending the form online isn't done.
*/
- private fun pressButton(doc: OpenDocument, w: io.github.artcraftandroid.pdfcraft.core.WidgetInfo) {
+ private fun pressButton(doc: OpenDocument, w: com.chethan616.clearpdf.core.WidgetInfo) {
val eng = engine ?: return
viewModelScope.launch {
val r = runCatching { eng.tool("form_actions", mapOf("doc" to doc.id, "field" to w.field)) }.getOrNull() ?: return@launch
@@ -1913,7 +1898,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
*/
private fun scriptOutput(doc: OpenDocument, r: JSONObject) {
// a script that failed: kept out of sight, as the reference keeps it, but in the log
- r.optString("error").takeIf { it.isNotEmpty() && it != "null" }?.let { android.util.Log.w("PdfCraft", "form script: $it") }
+ r.optString("error").takeIf { it.isNotEmpty() && it != "null" }?.let { android.util.Log.w("ClearPDF", "form script: $it") }
r.optJSONArray("alerts")?.let { a -> for (i in 0 until a.length()) showScriptAlert(a.optString(i)) }
val requests = r.optJSONArray("requests") ?: return
for (i in 0 until requests.length()) {
@@ -1928,13 +1913,13 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
/** Move to the next (or previous) fillable text or choice field in reading order. */
- fun nextField(doc: OpenDocument, from: io.github.artcraftandroid.pdfcraft.core.WidgetInfo, forward: Boolean) {
+ fun nextField(doc: OpenDocument, from: com.chethan616.clearpdf.core.WidgetInfo, forward: Boolean) {
val fillable = doc.widgets.filter { !it.readOnly && (it.kind == "text" || it.kind == "combo" || it.kind == "list") }
val i = fillable.indexOfFirst { it.field == from.field && it.page == from.page && it.rect == from.rect }
val next = fillable.getOrNull(if (forward) i + 1 else i - 1)
fieldEdit = next?.let {
if (it.page.toInt() != doc.viewer.currentPage) doc.viewer.goToPage(it.page.toInt(), (it.rect[1] - 60f).coerceAtLeast(0f))
- io.github.artcraftandroid.pdfcraft.ui.viewer.FieldEdit(doc, it)
+ com.chethan616.clearpdf.ui.viewer.FieldEdit(doc, it)
}
}
@@ -2030,7 +2015,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
val uri = uris.first()
val picked = withContext(Dispatchers.IO) { runCatching { copyIn(uri) }.getOrNull() }
if (picked == null) tell(text(R.string.msg_that_file_unreadable))
- else idImport = io.github.artcraftandroid.pdfcraft.ui.viewer.IdImport(picked, picked.name, wrong = false)
+ else idImport = com.chethan616.clearpdf.ui.viewer.IdImport(picked, picked.name, wrong = false)
}
}
}
@@ -2070,7 +2055,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
private suspend fun deliver(file: File, name: String, mime: String = "application/pdf") {
val uri = withContext(Dispatchers.IO) { files.saveToDownloads(file, name, mime).also { file.delete() } }
val size = withContext(Dispatchers.IO) { files.size(uri) }
- val saved = size?.let { text(R.string.msg_saved_downloads_size, name, io.github.artcraftandroid.pdfcraft.ui.viewer.formatSize(it)) } ?: text(R.string.msg_saved_downloads, name)
+ val saved = size?.let { text(R.string.msg_saved_downloads_size, name, com.chethan616.clearpdf.ui.viewer.formatSize(it)) } ?: text(R.string.msg_saved_downloads, name)
if (mime == "application/pdf") tell(saved, text(R.string.common_open)) { open(uri) }
else tell(saved, text(R.string.common_open)) {
intents.trySend(Intent.createChooser(Intent(Intent.ACTION_VIEW).setDataAndType(uri, mime).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION), null))
@@ -2155,7 +2140,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
deliver(out, "${doc.title}.$ext", mime)
}
- /** Every page of [doc] as an image (200 dpi) in Pictures/PdfCraft. */
+ /** Every page of [doc] as an image (200 dpi) in Pictures/ClearPDF. */
/** Export to images: the format chosen, while its pages are being picked in the page grid. */
var imageExport by mutableStateOf<String?>(null)
@@ -2171,7 +2156,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
doc.controller.pagesOpen = true
}
- /** Pictures of [pages] (0-based) at 200 dpi, saved to Pictures/PdfCraft or handed to the share sheet. */
+ /** Pictures of [pages] (0-based) at 200 dpi, saved to Pictures/ClearPDF or handed to the share sheet. */
fun writeImages(doc: OpenDocument, ext: String, pages: List<Int>, share: Boolean) = job(text(R.string.msg_busy_exporting_images)) { eng ->
val mime = if (ext == "png") "image/png" else "image/jpeg"
val made = mutableListOf<Pair<File, String>>()
@@ -2371,11 +2356,11 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
// ---- Home, Files, Search -----------------------------------------------------------------
- var homeTab by mutableStateOf(io.github.artcraftandroid.pdfcraft.ui.home.HomeTab.Home)
+ var homeTab by mutableStateOf(com.chethan616.clearpdf.ui.home.HomeTab.Home)
var settingsOpen by mutableStateOf(false)
/** The file whose "..." sheet is open, and whether it was opened from Recent. */
- var fileSheet by mutableStateOf<Pair<io.github.artcraftandroid.pdfcraft.ui.home.FileRow, Boolean>?>(null)
+ var fileSheet by mutableStateOf<Pair<com.chethan616.clearpdf.ui.home.FileRow, Boolean>?>(null)
var showLicences by mutableStateOf(false)
var filesShowLocal by mutableStateOf(false)
@@ -2400,13 +2385,13 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
/** Bumped when a preference shown on screen changes outside Compose state. */
var prefsChanged by mutableStateOf(0)
- val thumbnails = io.github.artcraftandroid.pdfcraft.engine.Thumbnails(app)
+ val thumbnails = com.chethan616.clearpdf.engine.Thumbnails(app)
- var localFiles by mutableStateOf<List<io.github.artcraftandroid.pdfcraft.engine.LocalPdf>>(emptyList())
+ var localFiles by mutableStateOf<List<com.chethan616.clearpdf.engine.LocalPdf>>(emptyList())
private set
var scanning by mutableStateOf(false)
private set
- var hasFileAccess by mutableStateOf(io.github.artcraftandroid.pdfcraft.engine.LocalFiles.hasAccess(app))
+ var hasFileAccess by mutableStateOf(com.chethan616.clearpdf.engine.LocalFiles.hasAccess(app))
private set
private var lastScan = 0L
@@ -2415,13 +2400,13 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
/** Look for the PDFs on the phone (at most every half minute unless [force]d). */
fun scanLocal(force: Boolean = false) {
- hasFileAccess = io.github.artcraftandroid.pdfcraft.engine.LocalFiles.hasAccess(getApplication())
+ hasFileAccess = com.chethan616.clearpdf.engine.LocalFiles.hasAccess(getApplication())
val now = System.currentTimeMillis()
if (!force && now - lastScan < 30_000 && localFiles.isNotEmpty()) return
lastScan = now
viewModelScope.launch {
scanning = true
- localFiles = withContext(Dispatchers.IO) { io.github.artcraftandroid.pdfcraft.engine.LocalFiles.scan(getApplication()) }
+ localFiles = withContext(Dispatchers.IO) { com.chethan616.clearpdf.engine.LocalFiles.scan(getApplication()) }
scanning = false
}
}
@@ -2436,27 +2421,27 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
/** The folders On this device lists, with their names. */
fun localFolders(): List<Pair<Uri, String>> {
val app = getApplication<Application>()
- return io.github.artcraftandroid.pdfcraft.engine.LocalFiles.folders(app).map { it to io.github.artcraftandroid.pdfcraft.engine.LocalFiles.folderName(app, it) }
+ return com.chethan616.clearpdf.engine.LocalFiles.folders(app).map { it to com.chethan616.clearpdf.engine.LocalFiles.folderName(app, it) }
}
/** A folder chosen in the picker: list its PDFs from now on. */
fun addLocalFolder(tree: Uri) {
- io.github.artcraftandroid.pdfcraft.engine.LocalFiles.addFolder(getApplication(), tree)
- hasFileAccess = io.github.artcraftandroid.pdfcraft.engine.LocalFiles.hasAccess(getApplication())
+ com.chethan616.clearpdf.engine.LocalFiles.addFolder(getApplication(), tree)
+ hasFileAccess = com.chethan616.clearpdf.engine.LocalFiles.hasAccess(getApplication())
scanLocal(force = true)
}
/** Stop listing [tree]. */
fun removeLocalFolder(tree: Uri) {
- io.github.artcraftandroid.pdfcraft.engine.LocalFiles.removeFolder(getApplication(), tree)
- hasFileAccess = io.github.artcraftandroid.pdfcraft.engine.LocalFiles.hasAccess(getApplication())
+ com.chethan616.clearpdf.engine.LocalFiles.removeFolder(getApplication(), tree)
+ hasFileAccess = com.chethan616.clearpdf.engine.LocalFiles.hasAccess(getApplication())
scanLocal(force = true)
}
/** Back from the access page (or the app resumed): look again. */
fun onResumed() {
val had = hasFileAccess
- hasFileAccess = io.github.artcraftandroid.pdfcraft.engine.LocalFiles.hasAccess(getApplication())
+ hasFileAccess = com.chethan616.clearpdf.engine.LocalFiles.hasAccess(getApplication())
if (hasFileAccess && !had) scanLocal(force = true)
refreshRecents()
}
@@ -2470,28 +2455,28 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
}
- fun recentRows(): List<io.github.artcraftandroid.pdfcraft.ui.home.FileRow> = recentList.map { r ->
- io.github.artcraftandroid.pdfcraft.ui.home.FileRow(r.uri, r.name, thumbPathFor(r.uri), locationOf(r.uri), r.opened, r.size, r.starred) { open(Uri.parse(r.uri)) }
+ fun recentRows(): List<com.chethan616.clearpdf.ui.home.FileRow> = recentList.map { r ->
+ com.chethan616.clearpdf.ui.home.FileRow(r.uri, r.name, thumbPathFor(r.uri), locationOf(r.uri), r.opened, r.size, r.starred) { open(Uri.parse(r.uri)) }
}
- fun starredRows(): List<io.github.artcraftandroid.pdfcraft.ui.home.FileRow> = recentRows().filter { it.starred }.let { l ->
+ fun starredRows(): List<com.chethan616.clearpdf.ui.home.FileRow> = recentRows().filter { it.starred }.let { l ->
if (starSort == 1) l.sortedBy { it.name.lowercase() } else l.sortedByDescending { it.date }
}
- fun localRows(): List<io.github.artcraftandroid.pdfcraft.ui.home.FileRow> {
+ fun localRows(): List<com.chethan616.clearpdf.ui.home.FileRow> {
// a file opened from another app is known by a different address than the scan's path,
// so stars are matched by the file itself (name and size)
val stars = recentList.filter { it.starred }.flatMap { listOf(it.uri, sameFile(it.name, it.size)) }.toSet()
return localFiles.map { f ->
val key = f.uri.toString()
- io.github.artcraftandroid.pdfcraft.ui.home.FileRow(key, f.name, f.path ?: key, f.folder, f.modified, f.size, key in stars || sameFile(f.name, f.size) in stars) { open(f.uri) }
+ com.chethan616.clearpdf.ui.home.FileRow(key, f.name, f.path ?: key, f.folder, f.modified, f.size, key in stars || sameFile(f.name, f.size) in stars) { open(f.uri) }
}
}
private fun sameFile(name: String, size: Long) = "$name|$size"
/** Files whose names contain [query]: the phone's and Recent's, each file once. */
- fun searchFiles(query: String): List<io.github.artcraftandroid.pdfcraft.ui.home.FileRow> {
+ fun searchFiles(query: String): List<com.chethan616.clearpdf.ui.home.FileRow> {
val q = query.trim().lowercase()
val all = localRows() + recentRows()
return all.filter { q in it.name.lowercase() }.distinctBy { it.key }.distinctBy { sameFile(it.name, it.size) }
@@ -2519,16 +2504,16 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
/** What to do with the next PDF opened from a tool tile (Home, Tools). */
- private var pendingTool: io.github.artcraftandroid.pdfcraft.ui.home.FileTool? = null
+ private var pendingTool: com.chethan616.clearpdf.ui.home.FileTool? = null
/** A tool that starts by choosing a PDF: pick one, open it, then start the tool. */
- fun toolForFile(tool: io.github.artcraftandroid.pdfcraft.ui.home.FileTool) {
+ fun toolForFile(tool: com.chethan616.clearpdf.ui.home.FileTool) {
pendingTool = tool
pickFiles(FilePickKind.Open)
}
/** Open [row] and start [tool] on it. */
- fun openFor(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow, tool: io.github.artcraftandroid.pdfcraft.ui.home.FileTool) {
+ fun openFor(row: com.chethan616.clearpdf.ui.home.FileRow, tool: com.chethan616.clearpdf.ui.home.FileTool) {
pendingTool = tool
row.open()
}
@@ -2552,20 +2537,20 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
/** A file row's local file, for sharing and the like: the file itself, or a fresh copy. */
- private suspend fun localFileOf(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow): File? = withContext(Dispatchers.IO) {
+ private suspend fun localFileOf(row: com.chethan616.clearpdf.ui.home.FileRow): File? = withContext(Dispatchers.IO) {
val u = Uri.parse(row.key)
runCatching { if (u.scheme == "file") File(requireNotNull(u.path)) else files.workingCopy(u) }.getOrNull()
}
/** Files ticked in Home's lists (a long press starts it), keyed by where they are. */
- val selectedFiles = androidx.compose.runtime.mutableStateMapOf<String, io.github.artcraftandroid.pdfcraft.ui.home.FileRow>()
+ val selectedFiles = androidx.compose.runtime.mutableStateMapOf<String, com.chethan616.clearpdf.ui.home.FileRow>()
- fun toggleSelected(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
+ fun toggleSelected(row: com.chethan616.clearpdf.ui.home.FileRow) {
if (selectedFiles.remove(row.key) == null) selectedFiles[row.key] = row
}
/** Several PDFs to the share sheet at once. */
- fun shareFiles(rows: List<io.github.artcraftandroid.pdfcraft.ui.home.FileRow>) {
+ fun shareFiles(rows: List<com.chethan616.clearpdf.ui.home.FileRow>) {
handOut {
val local = rows.mapNotNull { r -> localFileOf(r)?.let { it to r.name } }
if (local.isEmpty()) error(text(R.string.msg_files_unreadable))
@@ -2574,34 +2559,34 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
/** Combine the ticked files, in the order shown. */
- fun combineSelected(rows: List<io.github.artcraftandroid.pdfcraft.ui.home.FileRow>) {
+ fun combineSelected(rows: List<com.chethan616.clearpdf.ui.home.FileRow>) {
combineFiles.clear()
rows.take(12).forEach { combineFiles.add(PickedFile(Uri.parse(it.key), it.name, it.size)) }
toolScreen = ToolScreen.Combine(null)
}
- fun removeRecents(rows: List<io.github.artcraftandroid.pdfcraft.ui.home.FileRow>) {
+ fun removeRecents(rows: List<com.chethan616.clearpdf.ui.home.FileRow>) {
viewModelScope.launch {
withContext(Dispatchers.IO) { recents.remove(rows.map { it.key }.toSet()) }
refreshRecents()
}
}
- fun shareFile(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
+ fun shareFile(row: com.chethan616.clearpdf.ui.home.FileRow) {
handOut {
val f = localFileOf(row) ?: error(text(R.string.common_file_unreadable))
sendIntent(listOf(withContext(Dispatchers.IO) { files.shareable(f, row.name) }))
}
}
- fun printFile(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
+ fun printFile(row: com.chethan616.clearpdf.ui.home.FileRow) {
viewModelScope.launch {
val f = localFileOf(row) ?: return@launch tell(text(R.string.common_file_unreadable))
prints.trySend(f to row.name)
}
}
- fun openWith(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
+ fun openWith(row: com.chethan616.clearpdf.ui.home.FileRow) {
handOut {
val f = localFileOf(row) ?: error(text(R.string.common_file_unreadable))
val uri = withContext(Dispatchers.IO) { files.shareable(f, row.name) }
@@ -2609,7 +2594,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
}
- fun renameFile(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow, newName: String) {
+ fun renameFile(row: com.chethan616.clearpdf.ui.home.FileRow, newName: String) {
viewModelScope.launch {
val name = DocumentFiles.safeName(newName.trim())
val u = Uri.parse(row.key)
@@ -2647,7 +2632,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
}
- fun duplicateFile(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
+ fun duplicateFile(row: com.chethan616.clearpdf.ui.home.FileRow) {
viewModelScope.launch {
val f = localFileOf(row) ?: return@launch tell(text(R.string.common_file_unreadable))
val copy = withContext(Dispatchers.IO) { File(getApplication<Application>().cacheDir, "dup-${System.nanoTime()}.pdf").also { f.copyTo(it, overwrite = true) } }
@@ -2658,9 +2643,9 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
}
}
- private var copyRow: io.github.artcraftandroid.pdfcraft.ui.home.FileRow? = null
+ private var copyRow: com.chethan616.clearpdf.ui.home.FileRow? = null
- fun saveFileCopy(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
+ fun saveFileCopy(row: com.chethan616.clearpdf.ui.home.FileRow) {
copyRow = row
saveCopyRequests.trySend(row.name)
}
@@ -2678,7 +2663,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
return true
}
- fun deleteFile(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
+ fun deleteFile(row: com.chethan616.clearpdf.ui.home.FileRow) {
viewModelScope.launch {
val u = Uri.parse(row.key)
val ok = withContext(Dispatchers.IO) {
@@ -2740,7 +2725,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
// ---- Selecting a comment ------------------------------------------------------------------
/** The comment tapped: its panel shows over the viewer. */
- var selectedComment by mutableStateOf<Pair<OpenDocument, io.github.artcraftandroid.pdfcraft.core.CommentInfo>?>(null)
+ var selectedComment by mutableStateOf<Pair<OpenDocument, com.chethan616.clearpdf.core.CommentInfo>?>(null)
/** A tap at [at]: select the comment there (the top one), if any. */
fun tapComment(doc: OpenDocument, at: PagePoint?): Boolean {
@@ -2753,59 +2738,59 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
return true
}
- private fun commentArgs(c: io.github.artcraftandroid.pdfcraft.core.CommentInfo) = mapOf("page" to c.page.toInt() + 1, "index" to c.index.toInt() + 1)
+ private fun commentArgs(c: com.chethan616.clearpdf.core.CommentInfo) = mapOf("page" to c.page.toInt() + 1, "index" to c.index.toInt() + 1)
- fun deleteComment(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo) {
+ fun deleteComment(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo) {
selectedComment = null
runTool(doc, "comment_delete", commentArgs(c))
}
- fun recolorComment(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo, color: androidx.compose.ui.graphics.Color) {
+ fun recolorComment(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo, color: androidx.compose.ui.graphics.Color) {
runTool(doc, "comment_edit", commentArgs(c) + ("color" to color.hex())) { reselect(doc, c) }
}
/** Change a comment's opacity or line width (one undo step each). */
- fun styleComment(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo, style: Map<String, Any?>) {
+ fun styleComment(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo, style: Map<String, Any?>) {
runTool(doc, "comment_edit", commentArgs(c) + style) { reselect(doc, c) }
}
- fun editCommentText(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo, text: String) {
+ fun editCommentText(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo, text: String) {
runTool(doc, "comment_edit", commentArgs(c) + ("contents" to text)) { reselect(doc, c) }
}
- fun moveComment(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo, dx: Float, dy: Float) {
+ fun moveComment(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo, dx: Float, dy: Float) {
runTool(doc, "comment_edit", commentArgs(c) + ("move" to listOf(dx.toDouble(), dy.toDouble()))) { reselect(doc, c) }
}
/** Put a comment in a new rectangle (points, top-left origin): a resize. */
- fun resizeComment(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo, rect: List<Float>) {
+ fun resizeComment(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo, rect: List<Float>) {
runTool(doc, "comment_edit", commentArgs(c) + ("rect" to rect.map { it.toDouble() })) { reselect(doc, c) }
}
/** Move or resize a Fill & Sign element, keeping it selected. */
- fun moveFill(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo, dx: Float, dy: Float) {
+ fun moveFill(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo, dx: Float, dy: Float) {
runTool(doc, "comment_edit", commentArgs(c) + ("move" to listOf(dx.toDouble(), dy.toDouble()))) {
selectedFill = doc.comments.firstOrNull { it.page == c.page && it.index == c.index }
}
}
- fun resizeFill(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo, rect: List<Float>) {
+ fun resizeFill(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo, rect: List<Float>) {
runTool(doc, "comment_edit", commentArgs(c) + ("rect" to rect.map { it.toDouble() })) {
selectedFill = doc.comments.firstOrNull { it.page == c.page && it.index == c.index }
}
}
/** After an edit the comment is read again (same page and position). */
- private fun reselect(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo) {
+ private fun reselect(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo) {
val again = doc.comments.firstOrNull { it.page == c.page && it.index == c.index }
selectedComment = again?.let { doc to it }
}
/** The Fill & Sign element tapped (its menu shows over it). */
- var selectedFill by mutableStateOf<io.github.artcraftandroid.pdfcraft.core.CommentInfo?>(null)
+ var selectedFill by mutableStateOf<com.chethan616.clearpdf.core.CommentInfo?>(null)
/** Make a Fill & Sign element [factor] times bigger, about its top-left corner. */
- fun scaleFill(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo, factor: Float) {
+ fun scaleFill(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo, factor: Float) {
if (c.rect.size < 4) return
val w = (c.rect[2] - c.rect[0]) * factor
val h = (c.rect[3] - c.rect[1]) * factor
@@ -2820,17 +2805,17 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
* Page [page]'s text reflowed into paragraphs from its text layer: lines are joined until one
* ends a sentence well short of the line width, or a heading-like short line stands alone.
*/
- suspend fun reflowParagraphs(doc: OpenDocument, page: Int): List<io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph> {
+ suspend fun reflowParagraphs(doc: OpenDocument, page: Int): List<com.chethan616.clearpdf.ui.viewer.Paragraph> {
val eng = engine ?: return emptyList()
val text = runCatching { eng.command { pagePlainText(doc.id, page.toUInt()) } }.getOrDefault("")
val lines = text.lines().map { it.trim() }
if (lines.none { it.isNotEmpty() }) return emptyList()
val longest = lines.maxOf { it.length }.coerceAtLeast(1)
- val out = mutableListOf<io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph>()
+ val out = mutableListOf<com.chethan616.clearpdf.ui.viewer.Paragraph>()
val current = StringBuilder()
fun flush() {
if (current.isNotBlank()) {
- out += io.github.artcraftandroid.pdfcraft.ui.viewer.Paragraph(page, out.size + 1, current.toString().trim(), floatArrayOf(0f, 0f, 0f, 0f), "", 12f, false, false, null)
+ out += com.chethan616.clearpdf.ui.viewer.Paragraph(page, out.size + 1, current.toString().trim(), floatArrayOf(0f, 0f, 0f, 0f), "", 12f, false, false, null)
}
current.clear()
}
@@ -2848,6 +2833,23 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
flush()
return out
}
+
+ // Last in the class: initializers and init blocks run in source order, and this coroutine can run
+ // straight away (a started engine) or on another thread, so every property must exist first.
+ init {
+ viewModelScope.launch {
+ application.engine.await().onSuccess { engine = it }.onFailure { engineProblem = it.userMessage }
+ refreshRecents()
+ // the signers the reader trusts, before any signature is checked
+ // (a document opened from another app meanwhile is checked again)
+ engine?.let { eng ->
+ if (withContext(Dispatchers.IO) { trustedCerts.files().isNotEmpty() }) {
+ runCatching { applyTrust(eng) }
+ document?.let { loadSignatures(eng, it) }
+ }
+ }
+ }
+ }
}
/** The most files Create PDF converts at once. */
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ClearApp.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ClearApp.kt
new file mode 100644
index 0000000..a9b7f0d
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ClearApp.kt
@@ -0,0 +1,386 @@
+package com.chethan616.clearpdf.ui
+
+import androidx.activity.compose.BackHandler
+import androidx.compose.animation.core.Animatable
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxScope
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.WindowInsets
+import androidx.compose.foundation.layout.WindowInsetsSides
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.navigationBars
+import androidx.compose.foundation.layout.navigationBarsPadding
+import androidx.compose.foundation.layout.only
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.safeDrawing
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.windowInsetsPadding
+import androidx.compose.foundation.text.KeyboardActions
+import androidx.compose.foundation.text.KeyboardOptions
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.SideEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.key
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.CompositingStrategy
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalView
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.SpanStyle
+import androidx.compose.ui.text.buildAnnotatedString
+import androidx.compose.ui.text.font.FontStyle
+import androidx.compose.ui.text.input.ImeAction
+import androidx.compose.ui.text.input.KeyboardType
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.text.withStyle
+import androidx.compose.ui.unit.dp
+import androidx.core.view.WindowCompat
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.desk.DeskScreen
+import com.chethan616.clearpdf.ui.desk.FileActionsSheet
+import com.chethan616.clearpdf.ui.desk.FilesScreen
+import com.chethan616.clearpdf.ui.desk.SettingsScreen
+import com.chethan616.clearpdf.ui.desk.ToolCatalog
+import com.chethan616.clearpdf.ui.desk.ToolsScreen
+import com.chethan616.clearpdf.ui.glass.Aurora
+import com.chethan616.clearpdf.ui.glass.AuroraMoods
+import com.chethan616.clearpdf.ui.glass.GlassCircle
+import com.chethan616.clearpdf.ui.glass.GlassDialog
+import com.chethan616.clearpdf.ui.glass.GlassIcon
+import com.chethan616.clearpdf.ui.glass.GlassMotion
+import com.chethan616.clearpdf.ui.glass.GlassOverlay
+import com.chethan616.clearpdf.ui.glass.GlassOverlayHost
+import com.chethan616.clearpdf.ui.glass.LocalGlassOverlayHost
+import com.chethan616.clearpdf.ui.glass.GlassSheet
+import com.chethan616.clearpdf.ui.glass.GlassStage
+import com.chethan616.clearpdf.ui.glass.GlassTab
+import com.chethan616.clearpdf.ui.glass.GlassTabs
+import com.chethan616.clearpdf.ui.glass.GlassTextField
+import com.chethan616.clearpdf.ui.glass.GlassToast
+import com.chethan616.clearpdf.ui.glass.ProvideGlassHaptics
+import com.chethan616.clearpdf.ui.glass.pressable
+import com.chethan616.clearpdf.ui.home.HomeTab
+import com.chethan616.clearpdf.ui.theme.Candy
+import com.chethan616.clearpdf.ui.theme.ClearTheme
+import com.chethan616.clearpdf.ui.theme.ClearType
+import com.chethan616.clearpdf.ui.theme.clear
+import com.chethan616.clearpdf.ui.viewer.CertSignScreen
+import com.chethan616.clearpdf.ui.viewer.CreateIdScreen
+import com.chethan616.clearpdf.ui.viewer.IdPasswordDialog
+import com.chethan616.clearpdf.ui.viewer.SignFieldChoiceDialog
+import com.chethan616.clearpdf.ui.viewer.SignaturePadScreen
+import com.chethan616.clearpdf.ui.viewer.ViewerScreen
+import com.kyant.shapes.RoundedRectangle
+import kotlinx.coroutines.delay
+
+/** The whole app: the glass stage with the tabs (or a document, or Settings), the dock, and every dialog. */
+@Composable
+fun ClearApp(vm: AppViewModel, onBrowse: () -> Unit, onPickSignatureImage: () -> Unit) {
+ val overlays = remember { GlassOverlayHost() }
+ ClearTheme(vm.theme) {
+ PdfcraftTheme(vm.theme) {
+ ProvideGlassHaptics {
+ CompositionLocalProvider(LocalGlassOverlayHost provides overlays) { Shell(vm, onBrowse, onPickSignatureImage) }
+ }
+ }
+ }
+}
+
+@Composable
+private fun Shell(vm: AppViewModel, onBrowse: () -> Unit, onPickSignatureImage: () -> Unit) {
+ val c = clear
+ val doc = vm.document
+ var toast by remember { mutableStateOf<Message?>(null) }
+ var creating by remember { mutableStateOf(false) }
+ LaunchedEffect(vm) {
+ for (m in vm.messages) {
+ toast = m
+ delay(if (m.actionLabel != null) 6_000 else 3_200)
+ toast = null
+ delay(220)
+ }
+ }
+ // outside a document the bar icons follow the app's theme (the viewer sets its own)
+ val view = LocalView.current
+ val activity = LocalContext.current as? android.app.Activity
+ SideEffect {
+ val window = activity?.window ?: return@SideEffect
+ if (doc == null) {
+ val bars = WindowCompat.getInsetsController(window, view)
+ bars.isAppearanceLightStatusBars = !c.dark
+ bars.isAppearanceLightNavigationBars = !c.dark
+ }
+ }
+ BackHandler(enabled = doc != null && vm.toolScreen == null) { vm.closeDocument() }
+ BackHandler(enabled = doc == null && !vm.settingsOpen && vm.homeTab != HomeTab.Home && vm.toolScreen == null) { vm.homeTab = HomeTab.Home }
+
+ val onTabs = doc == null && !vm.settingsOpen
+ val dockVisible = onTabs && vm.toolScreen == null && vm.signaturePad == null && vm.certSign == null && !vm.idCreate && vm.selectedFiles.isEmpty()
+ val mood = when {
+ vm.settingsOpen -> AuroraMoods.Settings
+ vm.homeTab == HomeTab.Files -> AuroraMoods.Files
+ vm.homeTab == HomeTab.Tools -> AuroraMoods.Tools
+ else -> AuroraMoods.Desk
+ }
+
+ GlassStage(
+ wallpaper = { Aurora(mood) },
+ screens = {
+ Box(Modifier.fillMaxSize().windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal))) {
+ when {
+ doc != null -> Viewer(vm, doc)
+ vm.settingsOpen -> Entrance("settings", fromSide = true) { SettingsScreen(vm) }
+ else -> Entrance(vm.homeTab) {
+ when (vm.homeTab) {
+ HomeTab.Home -> DeskScreen(vm, onBrowse)
+ HomeTab.Files -> FilesScreen(vm, onBrowse)
+ HomeTab.Tools -> ToolsScreen(vm)
+ }
+ }
+ }
+ vm.toolScreen?.let { ToolScreenHost(vm, it) }
+ vm.signaturePad?.let { SignaturePadScreen(vm, it, onPickSignatureImage) }
+ vm.certSign?.let { CertSignScreen(vm, it) }
+ if (vm.idCreate) CreateIdScreen(vm)
+ }
+ },
+ chrome = {
+ if (dockVisible) Dock(vm, creating) { creating = !creating }
+ toast?.let { m ->
+ Box(
+ Modifier.align(Alignment.BottomCenter).navigationBarsPadding()
+ .padding(start = 16.dp, end = 16.dp, bottom = if (dockVisible) 96.dp else 20.dp),
+ ) { key(m) { GlassToast(m.text, m.actionLabel, { m.action?.invoke(); toast = null }) } }
+ }
+ },
+ )
+
+ if (creating) CreateSheet(vm, onBrowse) { creating = false }
+ if (doc == null) vm.fileSheet?.let { (r, recent) -> FileActionsSheet(vm, r, recent) { vm.fileSheet = null } }
+ if (vm.opening) Spinner()
+ Dialogs(vm)
+}
+
+/** The document viewer, laid out as it expects (sideways it keeps clear of the camera and buttons). */
+@Composable
+private fun Viewer(vm: AppViewModel, doc: OpenDocument) {
+ val fullWidth = vm.statusBarInDocuments
+ Box(Modifier.fillMaxSize().background(Color.Black)) {
+ Box(
+ Modifier.fillMaxSize().windowInsetsPadding(
+ if (fullWidth) WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal) else WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal),
+ ).then(if (fullWidth) Modifier else Modifier.background(pdfColors.surface)),
+ ) { ViewerScreen(vm, doc) }
+ }
+}
+
+/**
+ * A screen arriving: it rises a little and fades in on a soft spring ([fromSide]: slides in from
+ * the end, for pushed pages). Only the arriving screen is composed.
+ */
+@Composable
+private fun Entrance(key: Any, fromSide: Boolean = false, content: @Composable () -> Unit) {
+ key(key) {
+ val p = remember { Animatable(0f) }
+ LaunchedEffect(Unit) { p.animateTo(1f, GlassMotion.rise()) }
+ Box(
+ Modifier.fillMaxSize().graphicsLayer {
+ val v = p.value
+ if (fromSide) translationX = (1f - v) * 48.dp.toPx() else translationY = (1f - v) * 22.dp.toPx()
+ alpha = v.coerceIn(0f, 1f)
+ compositingStrategy = CompositingStrategy.ModulateAlpha
+ },
+ ) { content() }
+ }
+}
+
+/** The floating dock: Desk, Files and Tools on a glass capsule, and the candy + that creates. */
+@Composable
+private fun BoxScope.Dock(vm: AppViewModel, creating: Boolean, onCreate: () -> Unit) {
+ val turn by animateFloatAsState(if (creating) 45f else 0f, GlassMotion.morph(), label = "plus")
+ Row(
+ Modifier.align(Alignment.BottomCenter).navigationBarsPadding().padding(bottom = 14.dp),
+ horizontalArrangement = Arrangement.spacedBy(10.dp), verticalAlignment = Alignment.CenterVertically,
+ ) {
+ val tabs = listOf(HomeTab.Home, HomeTab.Files, HomeTab.Tools)
+ GlassTabs(
+ tabs = listOf(
+ GlassTab(stringResource(R.string.dock_desk), LucideIcons.House, Candy.Tomato),
+ GlassTab(stringResource(R.string.dock_files), LucideIcons.Folder, Candy.Sky),
+ GlassTab(stringResource(R.string.dock_tools), LucideIcons.LayoutGrid, Candy.Grape),
+ ),
+ selected = tabs.indexOf(vm.homeTab).coerceAtLeast(0),
+ onSelect = { vm.homeTab = tabs[it] },
+ modifier = Modifier.width(252.dp),
+ height = 64.dp,
+ )
+ GlassCircle(onClick = onCreate, size = 64.dp, tint = Candy.Tomato, label = stringResource(R.string.dock_create)) {
+ GlassIcon(LucideIcons.Plus, null, Modifier.size(30.dp).graphicsLayer { rotationZ = turn })
+ }
+ }
+}
+
+/** "Start something": the ways in, as a grid of candy tiles. */
+@Composable
+private fun CreateSheet(vm: AppViewModel, onBrowse: () -> Unit, onDismiss: () -> Unit) {
+ fun go(f: () -> Unit) {
+ onDismiss()
+ f()
+ }
+ GlassSheet(onDismiss, stringResource(R.string.create_title), stringResource(R.string.create_subtitle)) {
+ val items = listOf(
+ Triple(LucideIcons.FolderOpen, stringResource(R.string.home_open_file), Candy.Sky) to onBrowse,
+ Triple(ToolCatalog.Scan.icon, stringResource(ToolCatalog.Scan.label), ToolCatalog.Scan.accent) to { ToolCatalog.Scan.go(vm) },
+ Triple(ToolCatalog.Photos.icon, stringResource(ToolCatalog.Photos.label), ToolCatalog.Photos.accent) to { ToolCatalog.Photos.go(vm) },
+ Triple(ToolCatalog.Combine.icon, stringResource(ToolCatalog.Combine.label), Candy.Grape) to { ToolCatalog.Combine.go(vm) },
+ Triple(ToolCatalog.Create.icon, stringResource(ToolCatalog.Create.label), Candy.Tangerine) to { ToolCatalog.Create.go(vm) },
+ Triple(ToolCatalog.Edit.icon, stringResource(ToolCatalog.Edit.label), ToolCatalog.Edit.accent) to { ToolCatalog.Edit.go(vm) },
+ )
+ Column(Modifier.padding(horizontal = 14.dp, vertical = 4.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ items.chunked(3).forEach { row ->
+ Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ row.forEach { (spec, action) ->
+ val (icon, label, accent) = spec
+ CreateTile(icon, label, accent, Modifier.weight(1f)) { go(action) }
+ }
+ }
+ }
+ }
+ }
+}
+
+@Composable
+private fun CreateTile(icon: ImageVector, label: String, accent: Color, modifier: Modifier, onClick: () -> Unit) {
+ Column(
+ modifier.height(112.dp).pressable(onClick, pressedScale = 0.92f).clip(RoundedRectangle(24.dp)).background(accent).padding(14.dp),
+ verticalArrangement = Arrangement.SpaceBetween,
+ ) {
+ Icon(icon, null, tint = Color.White, modifier = Modifier.size(28.dp))
+ Text(label, style = ClearType.Label, color = Color.White, maxLines = 2)
+ }
+}
+
+/** A candy spinner over everything while a document opens. */
+@Composable
+private fun Spinner() {
+ GlassOverlay {
+ Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
+ CircularProgressIndicator(Modifier.size(44.dp), color = Candy.Tomato, strokeWidth = 4.dp)
+ }
+ }
+}
+
+/** Everything the view model can ask: passwords, read-only files, links, form alerts, waits. */
+@Composable
+private fun Dialogs(vm: AppViewModel) {
+ val c = clear
+ vm.passwordRequest?.let { PasswordDialog(vm, it) }
+ vm.idImport?.let { IdPasswordDialog(vm, it) }
+ vm.signFieldChoice?.let { (d, w) -> SignFieldChoiceDialog(vm, d, w) }
+ if (vm.authorPrompt) {
+ var name by remember { mutableStateOf("") }
+ GlassDialog(
+ onDismiss = { vm.authorPrompt = false }, title = stringResource(R.string.home_author_title), icon = LucideIcons.UserRound, accent = Candy.Sky,
+ confirm = stringResource(R.string.common_save), onConfirm = { vm.toolPrefs.author = name.trim(); vm.authorPrompt = false; vm.prefsChanged++ },
+ dismiss = stringResource(R.string.root_skip),
+ ) {
+ Text(stringResource(R.string.root_author_prompt_body), style = ClearType.Body, color = c.inkSoft)
+ Spacer(Modifier.height(14.dp))
+ GlassTextField(name, { name = it }, stringResource(R.string.common_your_name))
+ }
+ }
+ vm.readOnlyPrompt?.let { d ->
+ GlassDialog(
+ onDismiss = { vm.answerReadOnly(null) }, title = stringResource(R.string.root_read_only_title), icon = LucideIcons.Lock, accent = Candy.Tangerine,
+ confirm = stringResource(R.string.common_save_copy), onConfirm = { vm.answerReadOnly(true) },
+ dismiss = stringResource(R.string.root_discard), onDismissButton = { vm.answerReadOnly(false) },
+ ) { Text(stringResource(R.string.root_read_only_body, d.name), style = ClearType.Body, color = c.inkSoft) }
+ }
+ vm.linkPrompt?.let { url ->
+ val shown = runCatching { android.net.Uri.parse(url).let { u -> "${u.scheme}://${u.host}${if (u.port > 0) ":${u.port}" else ""}" } }.getOrDefault(url)
+ GlassDialog(
+ onDismiss = { vm.answerLink(false) }, title = stringResource(R.string.root_open_link_title), icon = LucideIcons.Link, accent = Candy.Sky,
+ confirm = stringResource(R.string.common_open), onConfirm = { vm.answerLink(true) }, dismiss = stringResource(R.string.common_cancel),
+ ) { Text(stringResource(R.string.root_open_link_body, shown), style = ClearType.Body, color = c.inkSoft) }
+ }
+ vm.scriptAlerts.firstOrNull()?.let { message ->
+ GlassDialog(onDismiss = vm::dismissScriptAlert, title = null, icon = LucideIcons.Info, accent = Candy.Grape, confirm = stringResource(R.string.common_ok), onConfirm = vm::dismissScriptAlert) {
+ Text(message, style = ClearType.Body, color = c.ink)
+ }
+ }
+ vm.confirmDeleteAllBookmarks?.let { d ->
+ GlassDialog(
+ onDismiss = { vm.confirmDeleteAllBookmarks = null }, title = stringResource(R.string.root_delete_bookmarks_title), icon = LucideIcons.BookmarkMinus, destructive = true,
+ confirm = stringResource(R.string.root_delete_all), onConfirm = { vm.confirmDeleteAllBookmarks = null; vm.deleteAllBookmarks(d) }, dismiss = stringResource(R.string.common_cancel),
+ ) { Text(stringResource(R.string.root_delete_bookmarks_body), style = ClearType.Body, color = c.inkSoft) }
+ }
+ vm.readingModeBlocked?.let {
+ GlassDialog(
+ onDismiss = { vm.readingModeBlocked = null }, title = stringResource(R.string.root_reading_mode_title), icon = LucideIcons.BookOpenText, accent = Candy.Sky,
+ confirm = stringResource(R.string.common_ok), onConfirm = { vm.readingModeBlocked = null },
+ ) { Text(stringResource(R.string.root_reading_mode_body), style = ClearType.Body, color = c.inkSoft) }
+ }
+ vm.busy?.let { message ->
+ GlassDialog(onDismiss = {}, title = null, dismissible = false) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ CircularProgressIndicator(Modifier.size(30.dp), color = Candy.Tomato, strokeWidth = 3.5.dp)
+ Spacer(Modifier.width(18.dp))
+ Text(message, style = ClearType.BodyStrong, color = c.ink, textAlign = TextAlign.Start)
+ }
+ }
+ }
+}
+
+/** "Enter password": the file's name in italics, a masked field; a wrong one turns it tomato. */
+@Composable
+private fun PasswordDialog(vm: AppViewModel, req: PasswordRequest) {
+ val c = clear
+ var pw by remember(req) { mutableStateOf("") }
+ val focus = remember { FocusRequester() }
+ LaunchedEffect(req) { runCatching { focus.requestFocus() } }
+ val body = stringResource(R.string.root_password_body)
+ GlassDialog(
+ onDismiss = { vm.answerPassword(null) }, title = stringResource(R.string.root_enter_password), icon = LucideIcons.LockOpen, accent = Candy.Grape,
+ confirm = stringResource(R.string.common_ok), onConfirm = { vm.answerPassword(pw) }, dismiss = stringResource(R.string.common_cancel),
+ ) {
+ Text(
+ buildAnnotatedString {
+ val at = body.indexOf("%1\$s")
+ if (at < 0) append(body) else {
+ append(body.substring(0, at))
+ withStyle(SpanStyle(fontStyle = FontStyle.Italic)) { append(req.file.name) }
+ append(body.substring(at + "%1\$s".length))
+ }
+ },
+ style = ClearType.Body, color = c.inkSoft,
+ )
+ Spacer(Modifier.height(14.dp))
+ GlassTextField(
+ pw, { pw = it }, stringResource(R.string.common_password), password = true, error = req.wrong && pw.isEmpty(), focus = focus,
+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, imeAction = ImeAction.Done),
+ keyboardActions = KeyboardActions(onDone = { if (pw.isNotEmpty()) vm.answerPassword(pw) }),
+ )
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Components.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt
similarity index 99%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Components.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt
index 7ffc886..0b6c186 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Components.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedVisibility
@@ -84,7 +84,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
+import com.chethan616.clearpdf.R
import kotlin.math.roundToInt
import kotlinx.coroutines.launch
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/FreeTextLayout.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/FreeTextLayout.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/FreeTextLayout.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/FreeTextLayout.kt
index 1c27fce..95ab6d2 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/FreeTextLayout.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/FreeTextLayout.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
/**
* How typed text sits in a new text box, measured the way the engine draws the box (its Helvetica
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Icons.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Icons.kt
similarity index 83%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Icons.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Icons.kt
index be77a6b..787679d 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Icons.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Icons.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
@@ -9,10 +9,10 @@ import androidx.compose.ui.graphics.vector.PathParser
import androidx.compose.ui.unit.dp
/**
- * The stroke weight PdfCraft draws Lucide's 24-unit icons with on phones: a little lighter than
- * Lucide's 2, for the thin outline look of a phone's tool bars.
+ * The stroke weight ClearPDF draws Lucide's 24-unit icons with: Lucide's own 2, bold enough to sit
+ * beside the heavy display type.
*/
-const val ICON_STROKE = 1.6f
+const val ICON_STROKE = 2.0f
/** A Lucide icon from its SVG path strings (see `LucideIconsTask` in app/build.gradle.kts). */
internal fun lucide(name: String, vararg paths: String): ImageVector {
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/OpenDocument.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/OpenDocument.kt
similarity index 76%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/OpenDocument.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/OpenDocument.kt
index 4abf943..6fbd530 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/OpenDocument.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/OpenDocument.kt
@@ -1,19 +1,19 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import android.net.Uri
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
-import io.github.artcraftandroid.pdfcraft.core.DocumentInfo
-import io.github.artcraftandroid.pdfcraft.engine.Engine
-import io.github.artcraftandroid.pdfcraft.ui.viewer.LinkFlash
-import io.github.artcraftandroid.pdfcraft.ui.viewer.PageImages
-import io.github.artcraftandroid.pdfcraft.ui.viewer.PageSize
-import io.github.artcraftandroid.pdfcraft.ui.viewer.SearchState
-import io.github.artcraftandroid.pdfcraft.ui.viewer.TextSelectionState
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerController
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerState
+import com.chethan616.clearpdf.core.DocumentInfo
+import com.chethan616.clearpdf.engine.Engine
+import com.chethan616.clearpdf.ui.viewer.LinkFlash
+import com.chethan616.clearpdf.ui.viewer.PageImages
+import com.chethan616.clearpdf.ui.viewer.PageSize
+import com.chethan616.clearpdf.ui.viewer.SearchState
+import com.chethan616.clearpdf.ui.viewer.TextSelectionState
+import com.chethan616.clearpdf.ui.viewer.ViewerController
+import com.chethan616.clearpdf.ui.viewer.ViewerState
import java.io.File
import kotlinx.coroutines.CoroutineScope
@@ -56,16 +56,16 @@ class OpenDocument(
var notWrittenBack = false
/** The links of each page (0-based), refreshed when the document changes. */
- var links: Map<Int, List<io.github.artcraftandroid.pdfcraft.core.LinkInfo>> = emptyMap()
+ var links: Map<Int, List<com.chethan616.clearpdf.core.LinkInfo>> = emptyMap()
/** The comments, refreshed when the document changes (tapping one selects it). */
- var comments: List<io.github.artcraftandroid.pdfcraft.core.CommentInfo> = emptyList()
+ var comments: List<com.chethan616.clearpdf.core.CommentInfo> = emptyList()
/** Its signatures and signature fields with what validating them found, refreshed when the document changes. */
- var signatures by mutableStateOf<List<io.github.artcraftandroid.pdfcraft.ui.viewer.SignatureEntry>>(emptyList())
+ var signatures by mutableStateOf<List<com.chethan616.clearpdf.ui.viewer.SignatureEntry>>(emptyList())
/** The form fields' widgets, refreshed when the document changes. */
- var widgets: List<io.github.artcraftandroid.pdfcraft.core.WidgetInfo> = emptyList()
+ var widgets: List<com.chethan616.clearpdf.core.WidgetInfo> = emptyList()
/** What the active tool still holds (ink being drawn), to add when the tool is left. */
var commitTool: (() -> Unit)? = null
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ScanSession.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ScanSession.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ScanSession.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ScanSession.kt
index cefb6ee..ef65a08 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ScanSession.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ScanSession.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
/**
* A scan in progress as text, kept in the activity's saved state: Android often closes the app
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Theme.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Theme.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Theme.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Theme.kt
index 7252cfb..e2ae659 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Theme.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/Theme.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.ColorScheme
@@ -16,7 +16,7 @@ import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
+import com.chethan616.clearpdf.R
/** Inter (OFL, assets/fonts), PdfCraft's UI face, copied in by the build. */
val Inter = FontFamily(
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ToolScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ToolScreen.kt
similarity index 90%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ToolScreen.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ToolScreen.kt
index 9a8c5f7..1bf8c99 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ToolScreen.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ToolScreen.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
/** A full-screen tool shown over the app. */
sealed class ToolScreen {
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ToolScreens.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ToolScreens.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ToolScreens.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ToolScreens.kt
index bfef981..d840489 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ToolScreens.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/ToolScreens.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.Image
@@ -81,9 +81,9 @@ import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.annotation.StringRes
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.engine.toBitmap
-import io.github.artcraftandroid.pdfcraft.ui.viewer.formatSize
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.engine.toBitmap
+import com.chethan616.clearpdf.ui.viewer.formatSize
import kotlin.math.roundToInt
import kotlinx.coroutines.withContext
@@ -107,7 +107,7 @@ fun ToolScaffold(
.background(if (viewerBands) c.navBand else c.surface).navigationBarsPadding().background(c.surface).imePadding(),
) {
Row(
- Modifier.fillMaxWidth().height(io.github.artcraftandroid.pdfcraft.ui.viewer.TopBarHeight).then(
+ Modifier.fillMaxWidth().height(com.chethan616.clearpdf.ui.viewer.TopBarHeight).then(
if (viewerBands) Modifier.drawBehind { drawRect(c.divider, Offset(0f, size.height - 1.dp.toPx()), Size(size.width, 1.dp.toPx())) } else Modifier,
),
verticalAlignment = Alignment.CenterVertically,
@@ -175,7 +175,7 @@ fun ToolPage(
BackHandler(onBack = onBack)
// the keyboard covers the pill rather than lifting it, as the reference's does
Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().background(c.navBand).navigationBarsPadding().background(c.surface)) {
- Row(Modifier.fillMaxWidth().height(io.github.artcraftandroid.pdfcraft.ui.viewer.TopBarHeight), verticalAlignment = Alignment.CenterVertically) {
+ Row(Modifier.fillMaxWidth().height(com.chethan616.clearpdf.ui.viewer.TopBarHeight), verticalAlignment = Alignment.CenterVertically) {
Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), onBack, iconSize = 27.dp) }
Spacer(Modifier.weight(1f))
trailing?.invoke()
@@ -366,7 +366,7 @@ fun CreateSourcesScreen(vm: AppViewModel) {
val back = { vm.toolScreen = null }
BackHandler(onBack = back)
Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().background(c.navBand).navigationBarsPadding().background(c.surface)) {
- Row(Modifier.fillMaxWidth().height(io.github.artcraftandroid.pdfcraft.ui.viewer.TopBarHeight), verticalAlignment = Alignment.CenterVertically) {
+ Row(Modifier.fillMaxWidth().height(com.chethan616.clearpdf.ui.viewer.TopBarHeight), verticalAlignment = Alignment.CenterVertically) {
Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), back, iconSize = 27.dp) }
Spacer(Modifier.width(4.dp))
Text(stringResource(R.string.tools_create_title), color = c.label, fontSize = 17.sp, fontWeight = FontWeight.SemiBold)
@@ -427,7 +427,7 @@ fun CombineScreen(vm: AppViewModel) {
BackHandler(onBack = back)
Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().background(c.navBand).navigationBarsPadding().background(c.surface)) {
Row(
- Modifier.fillMaxWidth().height(io.github.artcraftandroid.pdfcraft.ui.viewer.TopBarHeight)
+ Modifier.fillMaxWidth().height(com.chethan616.clearpdf.ui.viewer.TopBarHeight)
.drawBehind { drawRect(c.divider, Offset(0f, size.height - 1.dp.toPx()), Size(size.width, 1.dp.toPx())) },
verticalAlignment = Alignment.CenterVertically,
) {
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/Common.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/Common.kt
new file mode 100644
index 0000000..3ed233a
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/Common.kt
@@ -0,0 +1,288 @@
+package com.chethan616.clearpdf.ui.desk
+
+import androidx.annotation.StringRes
+import androidx.compose.foundation.Image
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+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
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.offset
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.draw.rotate
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.ImageBitmap
+import androidx.compose.ui.graphics.asImageBitmap
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.FilePickKind
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.glass.GlassCircle
+import com.chethan616.clearpdf.ui.glass.GlassDialog
+import com.chethan616.clearpdf.ui.glass.GlassIcon
+import com.chethan616.clearpdf.ui.glass.GlassPill
+import com.chethan616.clearpdf.ui.glass.GlassRow
+import com.chethan616.clearpdf.ui.glass.GlassSheet
+import com.chethan616.clearpdf.ui.glass.GlassTextField
+import com.chethan616.clearpdf.ui.glass.pressable
+import com.chethan616.clearpdf.ui.home.FileRow
+import com.chethan616.clearpdf.ui.home.FileTool
+import com.chethan616.clearpdf.ui.home.displayName
+import com.chethan616.clearpdf.ui.home.whenLabel
+import com.chethan616.clearpdf.ui.theme.Candy
+import com.chethan616.clearpdf.ui.theme.ClearType
+import com.chethan616.clearpdf.ui.theme.clear
+import com.chethan616.clearpdf.ui.viewer.formatSize
+import com.kyant.shapes.RoundedRectangle
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+
+/** A tool as the desk and the Tools tab show it: one candy colour everywhere it appears. */
+class ToolDef(
+ val key: String,
+ val icon: ImageVector,
+ @StringRes val label: Int,
+ @StringRes val about: Int,
+ val accent: Color,
+ val categories: Set<String>,
+ val go: (AppViewModel) -> Unit,
+)
+
+object ToolCatalog {
+ val Scan = ToolDef("scan", LucideIcons.Camera, R.string.home_new_scan, R.string.home_about_scan, Candy.Tomato, setOf("Create")) { it.startScan() }
+ val Edit = ToolDef("edit", LucideIcons.FilePenLine, R.string.common_tool_edit_pdf, R.string.home_about_edit, Candy.Bubblegum, setOf("Edit")) { it.toolForFile(FileTool.Edit) }
+ val FillSign = ToolDef("sign", LucideIcons.Signature, R.string.common_tool_fill_sign, R.string.home_about_fill_sign, Candy.Grape, emptySet()) { it.toolForFile(FileTool.FillSign) }
+ val Comment = ToolDef("comment", LucideIcons.MessageSquareText, R.string.home_tool_add_comment, R.string.home_about_comment, Candy.Tangerine, emptySet()) { it.toolForFile(FileTool.Comment) }
+ val ReadAloud = ToolDef("read", LucideIcons.Volume2, R.string.common_tool_read_aloud, R.string.home_about_read_aloud, Candy.Sky, setOf("Read")) { it.toolForFile(FileTool.ReadAloud) }
+ val Create = ToolDef("create", LucideIcons.FilePlus2, R.string.common_tool_create_pdf, R.string.home_about_create, Candy.Tomato, setOf("Create")) { it.openCreate() }
+ val Combine = ToolDef("combine", LucideIcons.Combine, R.string.common_tool_combine, R.string.home_about_combine, Candy.Sky, setOf("Create", "Edit")) { it.pickFiles(FilePickKind.Combine) }
+ val Organize = ToolDef("organize", LucideIcons.LayoutGrid, R.string.common_tool_organize, R.string.home_about_organize, Candy.Lime, setOf("Edit")) { it.toolForFile(FileTool.Organize) }
+ val Crop = ToolDef("crop", LucideIcons.Crop, R.string.common_tool_crop, R.string.home_about_crop, Candy.Mint, setOf("Edit")) { it.toolForFile(FileTool.Crop) }
+ val Compress = ToolDef("compress", LucideIcons.FileArchive, R.string.common_tool_compress, R.string.home_about_compress, Candy.Mint, setOf("Convert")) { it.toolForFile(FileTool.Compress) }
+ val Export = ToolDef("export", LucideIcons.FileOutput, R.string.common_tool_export, R.string.home_about_export, Candy.Tangerine, setOf("Convert")) { it.toolForFile(FileTool.Export) }
+ val Protect = ToolDef("protect", LucideIcons.FileLock2, R.string.common_tool_set_password, R.string.home_about_protect, Candy.Grape, setOf("Edit")) { it.toolForFile(FileTool.Protect) }
+ val Photos = ToolDef("photos", LucideIcons.Images, R.string.desk_photos_to_pdf, R.string.home_about_create, Candy.Lemon, setOf("Create")) { it.pickPhotosToPdf() }
+
+ val All = listOf(Edit, FillSign, Scan, Combine, Comment, ReadAloud, Organize, Compress, Export, Crop, Protect, Create)
+}
+
+/**
+ * A document's first page on white paper (the render, or a candy placeholder while it draws),
+ * optionally tilted like a sheet dropped on a desk.
+ */
+@Composable
+fun PaperThumb(vm: AppViewModel, path: String?, width: Dp, height: Dp, modifier: Modifier = Modifier, tilt: Float = 0f, corner: Dp = 8.dp) {
+ var img by remember(path) { mutableStateOf<ImageBitmap?>(null) }
+ LaunchedEffect(path) {
+ if (path != null) img = withContext(Dispatchers.IO) { vm.thumbnails.of(path)?.asImageBitmap() }
+ }
+ val c = clear
+ val shape = RoundedRectangle(corner)
+ Box(
+ modifier.size(width, height).rotate(tilt).clip(shape).background(Color.White)
+ .border(1.dp, if (c.dark) Color.White.copy(alpha = 0.10f) else c.ink.copy(alpha = 0.10f), shape),
+ contentAlignment = Alignment.Center,
+ ) {
+ val i = img
+ if (i != null) {
+ Image(i, null, modifier = Modifier.size(width, height), contentScale = ContentScale.Crop)
+ } else {
+ // a blank page: a few grey "lines" and a red PDF corner, drawn instead of an icon
+ Column(Modifier.fillMaxWidth().padding(horizontal = width * 0.16f), verticalArrangement = Arrangement.spacedBy(height * 0.06f)) {
+ Box(Modifier.fillMaxWidth(0.62f).height(height * 0.05f).clip(CircleShape).background(Color(0xFF17141F).copy(alpha = 0.20f)))
+ repeat(4) { k -> Box(Modifier.fillMaxWidth(if (k == 3) 0.5f else 1f).height(height * 0.03f).clip(CircleShape).background(Color(0xFF17141F).copy(alpha = 0.09f))) }
+ }
+ Box(Modifier.align(Alignment.BottomEnd).padding(width * 0.08f).clip(RoundedRectangle(4.dp)).background(Candy.Tomato).padding(horizontal = 4.dp, vertical = 1.dp)) {
+ Text("PDF", color = Color.White, fontSize = (width.value * 0.11f).coerceIn(7f, 13f).sp, style = ClearType.Eyebrow.copy(letterSpacing = 0.4.sp))
+ }
+ }
+ }
+}
+
+/** The big title every tab opens with: a small caps [eyebrow], the [title] in display type, and [trailing] controls. */
+@Composable
+fun ScreenHeader(eyebrow: String?, title: String, modifier: Modifier = Modifier, trailing: @Composable () -> Unit = {}) {
+ val c = clear
+ Row(modifier.fillMaxWidth().padding(start = 22.dp, end = 16.dp), verticalAlignment = Alignment.Bottom) {
+ Column(Modifier.weight(1f)) {
+ if (eyebrow != null) {
+ Text(eyebrow.uppercase(), style = ClearType.Eyebrow, color = c.inkSoft)
+ Spacer(Modifier.height(6.dp))
+ }
+ Text(title, style = ClearType.Display, color = c.ink)
+ }
+ Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) { trailing() }
+ }
+}
+
+/** The round glass Settings button that sits in each tab's header. */
+@Composable
+fun SettingsButton(vm: AppViewModel) {
+ GlassCircle(onClick = { vm.settingsOpen = true }, label = stringResource(R.string.home_settings)) {
+ GlassIcon(LucideIcons.Settings, null, Modifier.size(21.dp))
+ }
+}
+
+/** A file in a list: its paper, its name, when and how big, a star, and its menu. */
+@Composable
+fun FileListItem(vm: AppViewModel, r: FileRow, recent: Boolean, modifier: Modifier = Modifier) {
+ val c = clear
+ val selecting = vm.selectedFiles.isNotEmpty()
+ val ticked = r.key in vm.selectedFiles
+ Row(
+ modifier.fillMaxWidth()
+ .pressable(onClick = { if (selecting) vm.toggleSelected(r) else r.open() }, onLongClick = { vm.toggleSelected(r) })
+ .background(if (ticked) Candy.Sky.copy(alpha = 0.14f) else Color.Transparent)
+ .padding(start = 14.dp, end = 6.dp, top = 10.dp, bottom = 10.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ PaperThumb(vm, r.thumbPath, 40.dp, 52.dp, corner = 6.dp)
+ Spacer(Modifier.width(14.dp))
+ Column(Modifier.weight(1f)) {
+ Text(displayName(r.name), style = ClearType.BodyStrong, color = c.ink, maxLines = 2, overflow = TextOverflow.Ellipsis)
+ Spacer(Modifier.height(2.dp))
+ Text(
+ listOfNotNull(whenLabel(r.date), r.size.takeIf { it > 0 }?.let { formatSize(it) }).joinToString(" · "),
+ style = ClearType.Caption, color = c.inkSoft, maxLines = 1,
+ )
+ }
+ if (r.starred) Icon(LucideIcons.Star, stringResource(R.string.home_starred_description), tint = Candy.Lemon, modifier = Modifier.padding(horizontal = 4.dp).size(16.dp))
+ if (selecting) {
+ Box(Modifier.size(44.dp), contentAlignment = Alignment.Center) {
+ Box(
+ Modifier.size(24.dp).clip(CircleShape).background(if (ticked) Candy.Sky else Color.Transparent)
+ .border(2.dp, if (ticked) Candy.Sky else c.inkFaint, CircleShape),
+ contentAlignment = Alignment.Center,
+ ) { if (ticked) Icon(LucideIcons.Check, null, tint = Color.White, modifier = Modifier.size(14.dp)) }
+ }
+ } else {
+ Box(Modifier.size(44.dp).pressable({ vm.fileSheet = r to recent }), contentAlignment = Alignment.Center) {
+ Icon(LucideIcons.EllipsisVertical, stringResource(R.string.home_more_options_for, r.name), tint = c.inkSoft, modifier = Modifier.size(20.dp))
+ }
+ }
+ }
+}
+
+/** A file's sheet: four big candy actions up top, then its tools and the rest. */
+@Composable
+fun FileActionsSheet(vm: AppViewModel, r: FileRow, recent: Boolean, onDismiss: () -> Unit) {
+ var renaming by remember { mutableStateOf(false) }
+ var deleting by remember { mutableStateOf(false) }
+ fun act(f: () -> Unit) {
+ onDismiss()
+ f()
+ }
+ GlassSheet(onDismiss = onDismiss, title = displayName(r.name), subtitle = listOfNotNull(whenLabel(r.date), r.size.takeIf { it > 0 }?.let { formatSize(it) }).joinToString(" · ")) {
+ Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 6.dp), horizontalArrangement = Arrangement.SpaceEvenly) {
+ BigAction(LucideIcons.Share2, stringResource(R.string.common_share), Candy.Sky) { act { vm.shareFile(r) } }
+ BigAction(LucideIcons.Star, stringResource(if (r.starred) R.string.home_unstar else R.string.home_star), Candy.Lemon) { act { vm.setStarred(r.key, !r.starred) } }
+ BigAction(LucideIcons.Pencil, stringResource(R.string.common_rename), Candy.Grape) { renaming = true }
+ BigAction(LucideIcons.Printer, stringResource(R.string.home_print), Candy.Mint) { act { vm.printFile(r) } }
+ }
+ Spacer(Modifier.height(6.dp))
+ Column(Modifier.verticalScroll(rememberScrollState())) {
+ GlassRow(stringResource(R.string.common_tool_edit_pdf), { act { vm.openFor(r, FileTool.Edit) } }, icon = LucideIcons.FilePenLine, accent = ToolCatalog.Edit.accent)
+ GlassRow(stringResource(R.string.common_tool_read_aloud), { act { vm.openFor(r, FileTool.ReadAloud) } }, icon = LucideIcons.Volume2, accent = ToolCatalog.ReadAloud.accent)
+ GlassRow(stringResource(R.string.home_export_as), { act { vm.openFor(r, FileTool.Export) } }, icon = LucideIcons.FileOutput, accent = ToolCatalog.Export.accent)
+ GlassRow(stringResource(R.string.common_tool_compress), { act { vm.openFor(r, FileTool.Compress) } }, icon = LucideIcons.FileArchive, accent = ToolCatalog.Compress.accent)
+ GlassRow(stringResource(R.string.common_tool_set_password), { act { vm.openFor(r, FileTool.Protect) } }, icon = LucideIcons.FileLock2, accent = ToolCatalog.Protect.accent)
+ GlassRow(stringResource(R.string.home_open_with), { act { vm.openWith(r) } }, icon = LucideIcons.ExternalLink, accent = Candy.Sky)
+ GlassRow(stringResource(R.string.home_duplicate), { act { vm.duplicateFile(r) } }, icon = LucideIcons.Copy, accent = Candy.Tangerine)
+ GlassRow(stringResource(R.string.common_save_copy), { act { vm.saveFileCopy(r) } }, icon = LucideIcons.FileDown, accent = Candy.Mint)
+ if (recent) GlassRow(stringResource(R.string.home_remove_from_recent), { act { vm.removeRecent(r.key) } }, icon = LucideIcons.X, accent = Candy.Grape)
+ GlassRow(stringResource(R.string.common_delete), { deleting = true }, icon = LucideIcons.Trash2, destructive = true)
+ }
+ }
+ if (renaming) {
+ var name by remember { mutableStateOf(r.name.removeSuffix(".pdf")) }
+ GlassDialog(
+ onDismiss = { renaming = false }, title = stringResource(R.string.common_rename), icon = LucideIcons.Pencil, accent = Candy.Grape,
+ confirm = stringResource(R.string.common_done), confirmEnabled = name.isNotBlank() && !name.startsWith("."),
+ onConfirm = { renaming = false; onDismiss(); vm.renameFile(r, name) },
+ dismiss = stringResource(R.string.common_cancel),
+ ) { GlassTextField(name, { name = it }, stringResource(R.string.home_enter_name)) }
+ }
+ if (deleting) {
+ GlassDialog(
+ onDismiss = { deleting = false }, title = stringResource(R.string.home_delete_file_title), icon = LucideIcons.Trash2, destructive = true,
+ confirm = stringResource(R.string.common_delete), onConfirm = { deleting = false; onDismiss(); vm.deleteFile(r) },
+ dismiss = stringResource(R.string.common_cancel),
+ ) { Text(stringResource(R.string.home_delete_file_body, r.name), style = ClearType.Body, color = clear.inkSoft) }
+ }
+}
+
+/** A big round candy action with its name under it. */
+@Composable
+private fun BigAction(icon: ImageVector, label: String, accent: Color, onClick: () -> Unit) {
+ val c = clear
+ Column(Modifier.width(76.dp), horizontalAlignment = Alignment.CenterHorizontally) {
+ GlassCircle(onClick = onClick, size = 56.dp, tint = accent, label = label) { GlassIcon(icon, null, Modifier.size(24.dp)) }
+ Spacer(Modifier.height(6.dp))
+ Text(label, style = ClearType.Caption, color = c.inkSoft, maxLines = 1, overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center)
+ }
+}
+
+/** An empty list, playfully: three tilted papers, a big line and a candy action. */
+@Composable
+fun EmptyHero(title: String, body: String, action: String? = null, accent: Color = Candy.Tomato, onAction: (() -> Unit)? = null) {
+ val c = clear
+ Column(Modifier.fillMaxWidth().padding(horizontal = 32.dp, vertical = 28.dp), horizontalAlignment = Alignment.CenterHorizontally) {
+ Box(Modifier.size(150.dp, 120.dp), contentAlignment = Alignment.Center) {
+ Paper(Modifier.offset(x = (-30).dp, y = 6.dp).rotate(-14f), Candy.Sky)
+ Paper(Modifier.offset(x = 30.dp, y = 4.dp).rotate(12f), Candy.Lemon)
+ Paper(Modifier.rotate(-2f), accent)
+ }
+ Spacer(Modifier.height(18.dp))
+ Text(title, style = ClearType.Headline, color = c.ink, textAlign = TextAlign.Center)
+ Spacer(Modifier.height(6.dp))
+ Text(body, style = ClearType.Body, color = c.inkSoft, textAlign = TextAlign.Center)
+ if (action != null && onAction != null) {
+ Spacer(Modifier.height(18.dp))
+ GlassPill(onClick = onAction, tint = accent) { Text(action, style = ClearType.BodyStrong, color = Color.White) }
+ }
+ }
+}
+
+@Composable
+private fun Paper(modifier: Modifier, accent: Color) {
+ Box(
+ modifier.size(64.dp, 84.dp).clip(RoundedRectangle(10.dp))
+ .background(Brush.verticalGradient(listOf(Color.White, Color(0xFFF4F0EA))))
+ .border(1.dp, Color(0xFF17141F).copy(alpha = 0.08f), RoundedRectangle(10.dp))
+ .padding(10.dp),
+ ) {
+ Column(verticalArrangement = Arrangement.spacedBy(5.dp)) {
+ Box(Modifier.fillMaxWidth(0.7f).height(6.dp).clip(CircleShape).background(accent))
+ repeat(3) { Box(Modifier.fillMaxWidth().height(4.dp).clip(CircleShape).background(Color(0xFF17141F).copy(alpha = 0.10f))) }
+ }
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/DeskScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/DeskScreen.kt
new file mode 100644
index 0000000..7723086
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/DeskScreen.kt
@@ -0,0 +1,269 @@
+package com.chethan616.clearpdf.ui.desk
+
+import androidx.compose.animation.core.Animatable
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.WindowInsets
+import androidx.compose.foundation.layout.aspectRatio
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.navigationBars
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.statusBars
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.windowInsetsBottomHeight
+import androidx.compose.foundation.layout.windowInsetsTopHeight
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyRow
+import androidx.compose.foundation.lazy.itemsIndexed
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.CompositingStrategy
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.SpanStyle
+import androidx.compose.ui.text.buildAnnotatedString
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.text.withStyle
+import androidx.compose.ui.unit.dp
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.engine.RecentFile
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.glass.GlassCard
+import com.chethan616.clearpdf.ui.glass.GlassIcon
+import com.chethan616.clearpdf.ui.glass.GlassMotion
+import com.chethan616.clearpdf.ui.glass.GlassPill
+import com.chethan616.clearpdf.ui.glass.pressable
+import com.chethan616.clearpdf.ui.home.FileRow
+import com.chethan616.clearpdf.ui.home.HomeTab
+import com.chethan616.clearpdf.ui.home.displayName
+import com.chethan616.clearpdf.ui.home.whenLabel
+import com.chethan616.clearpdf.ui.theme.Candy
+import com.chethan616.clearpdf.ui.theme.ClearType
+import com.chethan616.clearpdf.ui.theme.clear
+import com.kyant.shapes.Capsule
+import com.kyant.shapes.RoundedRectangle
+import java.text.SimpleDateFormat
+import java.util.Calendar
+import java.util.Date
+import java.util.Locale
+
+/** How much room the floating dock takes at the bottom of every tab. */
+val DockClearance = 112.dp
+
+/**
+ * The desk: a big greeting, the document you were reading, a bento of candy tools, and a shelf of
+ * recent papers dropped at playful angles.
+ */
+@Composable
+fun DeskScreen(vm: AppViewModel, onBrowse: () -> Unit) {
+ val recents = vm.recentRows()
+ val last = vm.recentList.firstOrNull()
+ LazyColumn(Modifier.fillMaxSize(), contentPadding = PaddingValues(bottom = DockClearance)) {
+ item { Spacer(Modifier.windowInsetsTopHeight(WindowInsets.statusBars)) }
+ item(key = "top") {
+ Row(Modifier.fillMaxWidth().padding(start = 22.dp, end = 16.dp, top = 10.dp), verticalAlignment = Alignment.CenterVertically) {
+ Text(dateLine().uppercase(), style = ClearType.Eyebrow, color = clear.inkSoft, modifier = Modifier.weight(1f))
+ SettingsButton(vm)
+ }
+ }
+ item(key = "hero") { Greeting(hasDocument = last != null) }
+ if (last != null && recents.isNotEmpty()) {
+ item(key = "continue") { ContinueCard(vm, last, recents.first()) }
+ }
+ item(key = "make") {
+ SectionTitle(stringResource(R.string.desk_make_something), action = stringResource(R.string.desk_all_tools)) { vm.homeTab = HomeTab.Tools }
+ Bento(vm)
+ }
+ item(key = "shelf") {
+ SectionTitle(stringResource(R.string.desk_on_your_desk), action = if (recents.isNotEmpty()) stringResource(R.string.desk_see_all) else null) { vm.homeTab = HomeTab.Files }
+ if (recents.isEmpty()) {
+ EmptyHero(
+ stringResource(R.string.desk_empty_title), stringResource(R.string.desk_empty_body),
+ stringResource(R.string.home_open_file), Candy.Tomato, onBrowse,
+ )
+ } else {
+ Shelf(vm, recents.drop(if (last != null) 1 else 0).take(12).ifEmpty { recents.take(1) })
+ }
+ }
+ item { Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars)) }
+ }
+}
+
+private fun dateLine(): String = SimpleDateFormat("EEEE · d MMMM", Locale.getDefault()).format(Date())
+
+/** The hero: "Good evening," in ink, the tagline in a candy gradient, rising in on a soft spring. */
+@Composable
+private fun Greeting(hasDocument: Boolean) {
+ val c = clear
+ val hour = remember { Calendar.getInstance().get(Calendar.HOUR_OF_DAY) }
+ val hello = stringResource(
+ when (hour) {
+ in 5..11 -> R.string.desk_greeting_morning
+ in 12..16 -> R.string.desk_greeting_afternoon
+ in 17..22 -> R.string.desk_greeting_evening
+ else -> R.string.desk_greeting_night
+ },
+ )
+ val tagline = stringResource(if (hasDocument) R.string.desk_tagline_reading else R.string.desk_tagline_empty)
+ val rise = remember { Animatable(0f) }
+ LaunchedEffect(Unit) { rise.animateTo(1f, GlassMotion.rise()) }
+ val gradient = Brush.linearGradient(listOf(Candy.Tomato, Candy.Bubblegum, Candy.Grape))
+ Column(
+ Modifier.fillMaxWidth().padding(start = 22.dp, end = 22.dp, top = 18.dp, bottom = 10.dp)
+ .graphicsLayer {
+ translationY = (1f - rise.value) * 28.dp.toPx()
+ alpha = rise.value.coerceIn(0f, 1f)
+ compositingStrategy = CompositingStrategy.ModulateAlpha
+ },
+ ) {
+ Text(hello, style = ClearType.Hero, color = c.ink)
+ Text(
+ buildAnnotatedString { withStyle(SpanStyle(brush = gradient)) { append(tagline) } },
+ style = ClearType.Hero,
+ )
+ }
+}
+
+@Composable
+private fun SectionTitle(title: String, action: String?, onAction: () -> Unit) {
+ val c = clear
+ Row(Modifier.fillMaxWidth().padding(start = 22.dp, end = 14.dp, top = 26.dp, bottom = 12.dp), verticalAlignment = Alignment.CenterVertically) {
+ Text(title, style = ClearType.Headline, color = c.ink, modifier = Modifier.weight(1f))
+ if (action != null) {
+ GlassPill(onClick = onAction, height = 36.dp, horizontalPadding = 14.dp) {
+ Text(action, style = ClearType.Label, color = c.ink)
+ GlassIcon(LucideIcons.ChevronRight, null, Modifier.size(16.dp))
+ }
+ }
+ }
+}
+
+/**
+ * The document you were reading: its tilted first page, its name, where you are in it, and a
+ * chunky candy progress bar.
+ */
+@Composable
+private fun ContinueCard(vm: AppViewModel, last: RecentFile, row: FileRow) {
+ val c = clear
+ val pages = last.pages.coerceAtLeast(1)
+ val page = (last.lastPage + 1).coerceIn(1, pages)
+ val progress = page / pages.toFloat()
+ GlassCard(
+ Modifier.padding(horizontal = 16.dp, vertical = 8.dp).fillMaxWidth().pressable(row.open),
+ shape = RoundedRectangle(32.dp),
+ ) {
+ Row(Modifier.padding(18.dp), verticalAlignment = Alignment.CenterVertically) {
+ Box(Modifier.size(104.dp, 132.dp), contentAlignment = Alignment.Center) {
+ Box(Modifier.size(92.dp, 120.dp).graphicsLayer { rotationZ = 6f; translationX = 8.dp.toPx() }.clip(RoundedRectangle(8.dp)).background(Candy.Lemon.copy(alpha = 0.7f)))
+ PaperThumb(vm, row.thumbPath, 92.dp, 120.dp, tilt = -4f)
+ }
+ Spacer(Modifier.width(16.dp))
+ Column(Modifier.weight(1f)) {
+ Text(stringResource(R.string.desk_continue).uppercase(), style = ClearType.Eyebrow, color = Candy.Tomato)
+ Spacer(Modifier.height(6.dp))
+ Text(displayName(row.name), style = ClearType.Title, color = c.ink, maxLines = 3, overflow = TextOverflow.Ellipsis)
+ Spacer(Modifier.height(10.dp))
+ Text(stringResource(R.string.desk_page_of, page, pages), style = ClearType.Label, color = c.inkSoft)
+ Spacer(Modifier.height(8.dp))
+ Box(Modifier.fillMaxWidth().height(10.dp).clip(Capsule).background(c.ink.copy(alpha = 0.08f))) {
+ Box(
+ Modifier.fillMaxWidth(progress.coerceIn(0.06f, 1f)).fillMaxHeight().clip(Capsule)
+ .background(Brush.horizontalGradient(listOf(Candy.Tangerine, Candy.Tomato))),
+ )
+ }
+ }
+ }
+ }
+}
+
+/** A candy tile of the bento: a big glyph up top, the tool's name at the bottom, a lighter corner. */
+@Composable
+private fun CandyTile(icon: ImageVector, label: String, accent: Color, modifier: Modifier, big: Boolean = false, onClick: () -> Unit) {
+ val shape = RoundedRectangle(if (big) 30.dp else 26.dp)
+ Box(
+ modifier.pressable(onClick, pressedScale = 0.93f).clip(shape)
+ .background(Brush.linearGradient(listOf(lighten(accent, 0.22f), accent, darken(accent, 0.08f))))
+ .padding(if (big) 18.dp else 14.dp),
+ ) {
+ // a soft bubble of light in the corner, the playful bit
+ Box(Modifier.align(Alignment.TopEnd).size(if (big) 90.dp else 56.dp).graphicsLayer { translationX = 26.dp.toPx(); translationY = (-26).dp.toPx() }.clip(CircleShape).background(Color.White.copy(alpha = 0.18f)))
+ Icon(icon, null, tint = Color.White, modifier = Modifier.size(if (big) 34.dp else 26.dp))
+ Text(label, style = if (big) ClearType.Headline else ClearType.Tile, color = Color.White, modifier = Modifier.align(Alignment.BottomStart), maxLines = 2)
+ }
+}
+
+private fun lighten(c: Color, f: Float) = Color(c.red + (1f - c.red) * f, c.green + (1f - c.green) * f, c.blue + (1f - c.blue) * f, c.alpha)
+private fun darken(c: Color, f: Float) = Color(c.red * (1f - f), c.green * (1f - f), c.blue * (1f - f), c.alpha)
+
+/**
+ * The bento: Scan as a tall hero tile, Combine and Fill & Sign beside it, then a row of three.
+ */
+@Composable
+private fun Bento(vm: AppViewModel) {
+ val gap = 12.dp
+ Column(Modifier.padding(horizontal = 16.dp), verticalArrangement = Arrangement.spacedBy(gap)) {
+ Row(Modifier.fillMaxWidth().height(232.dp), horizontalArrangement = Arrangement.spacedBy(gap)) {
+ val scan = ToolCatalog.Scan
+ CandyTile(scan.icon, stringResource(scan.label), scan.accent, Modifier.weight(1.08f).fillMaxHeight(), big = true) { scan.go(vm) }
+ Column(Modifier.weight(1f).fillMaxHeight(), verticalArrangement = Arrangement.spacedBy(gap)) {
+ for (t in listOf(ToolCatalog.Combine, ToolCatalog.FillSign)) {
+ CandyTile(t.icon, stringResource(t.label), t.accent, Modifier.weight(1f).fillMaxWidth()) { t.go(vm) }
+ }
+ }
+ }
+ Row(Modifier.fillMaxWidth().height(112.dp), horizontalArrangement = Arrangement.spacedBy(gap)) {
+ for (t in listOf(ToolCatalog.Photos, ToolCatalog.Edit, ToolCatalog.Compress)) {
+ CandyTile(t.icon, stringResource(t.label), t.accent, Modifier.weight(1f).fillMaxHeight()) { t.go(vm) }
+ }
+ }
+ }
+}
+
+private val Tilts = floatArrayOf(-4f, 3f, -2f, 4.5f, -3.5f, 2f)
+
+/** Recent papers on a shelf, each dropped at its own angle; a press straightens it. */
+@Composable
+private fun Shelf(vm: AppViewModel, rows: List<FileRow>) {
+ LazyRow(contentPadding = PaddingValues(horizontal = 20.dp), horizontalArrangement = Arrangement.spacedBy(18.dp)) {
+ itemsIndexed(rows, key = { _, r -> r.key }) { i, r -> ShelfPaper(vm, r, Tilts[i % Tilts.size]) }
+ }
+}
+
+@Composable
+private fun ShelfPaper(vm: AppViewModel, r: FileRow, tilt: Float) {
+ val c = clear
+ Column(Modifier.width(124.dp).pressable(r.open, onLongClick = { vm.fileSheet = r to true }, pressedScale = 1.04f).padding(vertical = 10.dp)) {
+ Box(Modifier.fillMaxWidth().aspectRatio(0.78f), contentAlignment = Alignment.Center) {
+ PaperThumb(vm, r.thumbPath, 112.dp, 144.dp, tilt = tilt)
+ if (r.starred) {
+ Box(
+ Modifier.align(Alignment.TopEnd).size(26.dp).clip(CircleShape).background(Candy.Lemon),
+ contentAlignment = Alignment.Center,
+ ) { Icon(LucideIcons.Star, null, tint = Color.White, modifier = Modifier.size(14.dp)) }
+ }
+ }
+ Spacer(Modifier.height(12.dp))
+ Text(displayName(r.name), style = ClearType.Label, color = c.ink, maxLines = 2, overflow = TextOverflow.Ellipsis)
+ Text(whenLabel(r.date), style = ClearType.Caption, color = c.inkSoft, maxLines = 1)
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/FilesScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/FilesScreen.kt
new file mode 100644
index 0000000..0390b3e
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/FilesScreen.kt
@@ -0,0 +1,301 @@
+package com.chethan616.clearpdf.ui.desk
+
+import androidx.activity.compose.BackHandler
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.WindowInsets
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.navigationBars
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.statusBars
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.windowInsetsBottomHeight
+import androidx.compose.foundation.layout.windowInsetsTopHeight
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.foundation.text.BasicTextField
+import androidx.compose.foundation.text.KeyboardActions
+import androidx.compose.foundation.text.KeyboardOptions
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.geometry.Rect
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.SolidColor
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.layout.boundsInWindow
+import androidx.compose.ui.layout.onGloballyPositioned
+import androidx.compose.ui.res.pluralStringResource
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.input.ImeAction
+import androidx.compose.ui.unit.dp
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.glass.GlassCircle
+import com.chethan616.clearpdf.ui.glass.GlassDialog
+import com.chethan616.clearpdf.ui.glass.GlassIcon
+import com.chethan616.clearpdf.ui.glass.GlassMenu
+import com.chethan616.clearpdf.ui.glass.GlassMenuItem
+import com.chethan616.clearpdf.ui.glass.GlassPill
+import com.chethan616.clearpdf.ui.glass.GlassRow
+import com.chethan616.clearpdf.ui.glass.GlassTab
+import com.chethan616.clearpdf.ui.glass.GlassTabs
+import com.chethan616.clearpdf.ui.glass.WashPanel
+import com.chethan616.clearpdf.ui.glass.glass
+import com.chethan616.clearpdf.ui.glass.pressable
+import com.chethan616.clearpdf.ui.home.FileRow
+import com.chethan616.clearpdf.ui.home.dayBucket
+import com.chethan616.clearpdf.ui.theme.Candy
+import com.chethan616.clearpdf.ui.theme.ClearType
+import com.chethan616.clearpdf.ui.theme.clear
+import com.kyant.shapes.Capsule
+import kotlinx.coroutines.delay
+
+/** At most this many rows share one panel, so a long folder isn't one giant item. */
+private const val PanelRows = 20
+
+/**
+ * Files: a big title with the count, a glass search capsule, Recent / Starred / On device, and the
+ * files grouped (by day, or by folder) in wash panels. A long press starts selecting.
+ */
+@Composable
+fun FilesScreen(vm: AppViewModel, onBrowse: () -> Unit) {
+ val c = clear
+ var tab by rememberSaveable { mutableIntStateOf(0) }
+ var query by rememberSaveable { mutableStateOf("") }
+ var sortByName by rememberSaveable { mutableStateOf(false) }
+ var menuAnchor by remember { mutableStateOf<Rect?>(null) }
+ var menuOpen by remember { mutableStateOf(false) }
+ var confirmClear by remember { mutableStateOf(false) }
+ var confirmDelete by remember { mutableStateOf(false) }
+ LaunchedEffect(vm.filesShowLocal) {
+ if (vm.filesShowLocal) {
+ tab = 2
+ vm.filesShowLocal = false
+ }
+ }
+ LaunchedEffect(tab) { if (tab == 2) vm.scanLocal() }
+ BackHandler(enabled = vm.selectedFiles.isNotEmpty()) { vm.selectedFiles.clear() }
+ BackHandler(enabled = vm.selectedFiles.isEmpty() && query.isNotEmpty()) { query = "" }
+
+ val rows: List<FileRow> = when {
+ query.isNotBlank() -> vm.searchFiles(query).sortedWith(compareBy<FileRow> { !it.name.lowercase().startsWith(query.trim().lowercase()) }.thenByDescending { it.date })
+ tab == 0 -> vm.recentRows()
+ tab == 1 -> vm.starredRows()
+ else -> vm.localRows()
+ }.let { if (sortByName && query.isBlank()) it.sortedBy { r -> r.name.lowercase() } else it }
+
+ // a search left alone for a moment counts as one made
+ LaunchedEffect(query) {
+ if (query.isNotBlank()) {
+ delay(2000)
+ if (rows.isNotEmpty()) vm.addRecentSearch(query)
+ }
+ }
+
+ val resultsTitle = pluralStringResource(R.plurals.home_search_results, rows.size, rows.size)
+ val bucketLabels = listOf(
+ stringResource(R.string.files_today), stringResource(R.string.common_yesterday),
+ stringResource(R.string.files_this_week), stringResource(R.string.files_earlier),
+ )
+ val internal = stringResource(R.string.home_internal_storage)
+ LazyColumn(Modifier.fillMaxSize(), contentPadding = PaddingValues(bottom = DockClearance)) {
+ item { Spacer(Modifier.windowInsetsTopHeight(WindowInsets.statusBars)) }
+ item(key = "header") {
+ Spacer(Modifier.height(16.dp))
+ if (vm.selectedFiles.isNotEmpty()) {
+ SelectionHeader(vm, recent = tab == 0) { confirmDelete = true }
+ } else {
+ ScreenHeader(pluralStringResource(R.plurals.files_count, rows.size, rows.size), stringResource(R.string.home_tab_files)) {
+ GlassCircle(
+ onClick = { menuOpen = true },
+ modifier = Modifier.onGloballyPositioned { menuAnchor = it.boundsInWindow() },
+ label = stringResource(R.string.common_more_options),
+ ) { GlassIcon(LucideIcons.Ellipsis, null, Modifier.size(21.dp)) }
+ SettingsButton(vm)
+ }
+ }
+ }
+ item(key = "search") { SearchCapsule(query, { query = it }, onSearch = { vm.addRecentSearch(query) }) }
+ if (query.isBlank()) {
+ item(key = "tabs") {
+ GlassTabs(
+ tabs = listOf(
+ GlassTab(stringResource(R.string.home_list_recent), accent = Candy.Tomato),
+ GlassTab(stringResource(R.string.home_list_starred), accent = Candy.Tangerine),
+ GlassTab(stringResource(R.string.home_list_on_device), accent = Candy.Sky),
+ ),
+ selected = tab, onSelect = { tab = it; vm.selectedFiles.clear() },
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 6.dp).fillMaxWidth(),
+ height = 48.dp,
+ )
+ }
+ }
+ when {
+ query.isNotBlank() -> {
+ if (rows.isEmpty()) item(key = "noresults") { EmptyHero(stringResource(R.string.home_no_results), stringResource(R.string.home_no_results_body), accent = Candy.Sky) }
+ else panels(vm, "results", resultsTitle, rows, recent = false)
+ }
+ tab == 0 -> {
+ if (rows.isEmpty()) {
+ item(key = "empty0") { EmptyHero(stringResource(R.string.home_no_recent_title), stringResource(R.string.home_no_recent_body), stringResource(R.string.home_open_file), Candy.Tomato, onBrowse) }
+ } else {
+ val groups = if (sortByName) mapOf(-1 to rows) else rows.groupBy { dayBucket(it.date) }.toSortedMap()
+ for ((bucket, list) in groups) {
+ panels(vm, "d$bucket", if (bucket < 0) null else bucketLabels[bucket], list, recent = true)
+ }
+ }
+ item(key = "places") { Places(vm, onBrowse) { tab = 2 } }
+ }
+ tab == 1 -> {
+ if (rows.isEmpty()) item(key = "empty1") { EmptyHero(stringResource(R.string.files_starred_empty_title), stringResource(R.string.files_starred_empty_body), accent = Candy.Tangerine) }
+ else panels(vm, "starred", null, rows, recent = true)
+ }
+ else -> {
+ when {
+ !vm.hasFileAccess && rows.isEmpty() -> item(key = "noaccess") {
+ EmptyHero(stringResource(R.string.home_device_files_title), stringResource(R.string.home_device_files_body_long), stringResource(R.string.home_add_folder), Candy.Sky) { vm.requestFileAccess() }
+ }
+ rows.isEmpty() -> item(key = "nopdfs") {
+ if (vm.scanning) EmptyHero(stringResource(R.string.home_looking_for_pdfs), "", accent = Candy.Sky)
+ else EmptyHero(stringResource(R.string.home_no_pdfs_title), stringResource(R.string.home_no_pdfs_body), stringResource(R.string.home_add_folder), Candy.Sky) { vm.requestFileAccess() }
+ }
+ else -> {
+ for ((folder, list) in rows.groupBy { it.location }) panels(vm, "f$folder", folder.ifEmpty { internal }, list, recent = false)
+ }
+ }
+ }
+ }
+ item { Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars)) }
+ }
+
+ if (menuOpen) {
+ val anchor = menuAnchor ?: Rect.Zero
+ val items = buildList {
+ add(GlassMenuItem(stringResource(if (sortByName) R.string.home_sort_by_date else R.string.home_sort_by_name), LucideIcons.ArrowUpDown) { sortByName = !sortByName })
+ if (tab == 0 && vm.recentList.isNotEmpty()) add(GlassMenuItem(stringResource(R.string.home_clear_recent), LucideIcons.BrushCleaning) { confirmClear = true })
+ if (tab == 2) {
+ add(GlassMenuItem(stringResource(R.string.home_refresh), LucideIcons.RotateCw) { vm.scanLocal(force = true) })
+ add(GlassMenuItem(stringResource(R.string.home_add_folder), LucideIcons.FolderPlus) { vm.requestFileAccess() })
+ for ((tree, name) in vm.localFolders()) add(GlassMenuItem(stringResource(R.string.home_stop_listing, name), LucideIcons.FolderOpen) { vm.removeLocalFolder(tree) })
+ }
+ }
+ GlassMenu(anchor, { menuOpen = false }, items)
+ }
+ if (confirmClear) {
+ GlassDialog(
+ onDismiss = { confirmClear = false }, title = stringResource(R.string.home_clear_recent_title), icon = LucideIcons.BrushCleaning, destructive = true,
+ confirm = stringResource(R.string.common_clear), onConfirm = { confirmClear = false; vm.clearRecents() }, dismiss = stringResource(R.string.common_cancel),
+ ) { Text(stringResource(R.string.home_clear_recent_body), style = ClearType.Body, color = c.inkSoft) }
+ }
+ if (confirmDelete) {
+ val sel = vm.selectedFiles.values.toList()
+ GlassDialog(
+ onDismiss = { confirmDelete = false }, title = pluralStringResource(R.plurals.home_delete_files_title, sel.size, sel.size), icon = LucideIcons.Trash2, destructive = true,
+ confirm = stringResource(R.string.common_delete), onConfirm = { confirmDelete = false; sel.forEach(vm::deleteFile); vm.selectedFiles.clear() },
+ dismiss = stringResource(R.string.common_cancel),
+ ) { Text(stringResource(R.string.home_delete_files_body), style = ClearType.Body, color = c.inkSoft) }
+ }
+}
+
+/** [rows] under an optional [title], in wash panels of at most [PanelRows]. */
+private fun LazyListScope.panels(vm: AppViewModel, key: String, title: String?, rows: List<FileRow>, recent: Boolean) {
+ if (title != null) {
+ item(key = "t-$key") {
+ Row(Modifier.fillMaxWidth().padding(start = 24.dp, end = 24.dp, top = 22.dp, bottom = 8.dp), verticalAlignment = Alignment.Bottom) {
+ Text(title, style = ClearType.Title, color = clear.ink, modifier = Modifier.weight(1f))
+ Text(rows.size.toString(), style = ClearType.Number, color = clear.inkFaint)
+ }
+ }
+ } else {
+ item(key = "s-$key") { Spacer(Modifier.height(12.dp)) }
+ }
+ rows.chunked(PanelRows).forEachIndexed { i, chunk ->
+ item(key = "p-$key-$i") {
+ WashPanel(Modifier.padding(horizontal = 16.dp, vertical = 4.dp).fillMaxWidth()) {
+ Spacer(Modifier.height(4.dp))
+ chunk.forEach { r -> FileListItem(vm, r, recent) }
+ Spacer(Modifier.height(4.dp))
+ }
+ }
+ }
+}
+
+/** The search capsule: glass, a candy cursor, a clear button. */
+@Composable
+private fun SearchCapsule(query: String, onQuery: (String) -> Unit, onSearch: () -> Unit) {
+ val c = clear
+ val hint = stringResource(R.string.home_search_your_files)
+ Row(
+ Modifier.padding(horizontal = 16.dp, vertical = 10.dp).fillMaxWidth().height(52.dp).glass(Capsule, blur = 4.dp).padding(start = 18.dp, end = 6.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Icon(LucideIcons.Search, null, tint = c.inkSoft, modifier = Modifier.size(20.dp))
+ Spacer(Modifier.width(12.dp))
+ BasicTextField(
+ value = query, onValueChange = onQuery, singleLine = true,
+ textStyle = ClearType.Body.copy(color = c.ink), cursorBrush = SolidColor(Candy.Tomato),
+ keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
+ keyboardActions = KeyboardActions(onSearch = { onSearch() }),
+ modifier = Modifier.weight(1f),
+ decorationBox = { inner -> Box { if (query.isEmpty()) Text(hint, style = ClearType.Body, color = c.inkFaint); inner() } },
+ )
+ if (query.isNotEmpty()) {
+ Box(Modifier.size(40.dp).pressable({ onQuery("") }), contentAlignment = Alignment.Center) {
+ Icon(LucideIcons.CircleX, stringResource(R.string.common_clear), tint = c.inkSoft, modifier = Modifier.size(20.dp))
+ }
+ }
+ }
+}
+
+/** While files are ticked: how many, and what to do with them. */
+@Composable
+private fun SelectionHeader(vm: AppViewModel, recent: Boolean, onDelete: () -> Unit) {
+ val c = clear
+ val rows = vm.selectedFiles.values.toList()
+ Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ GlassCircle(onClick = { vm.selectedFiles.clear() }, label = stringResource(R.string.home_clear_selection)) { GlassIcon(LucideIcons.X, null, Modifier.size(20.dp)) }
+ Text(pluralStringResource(R.plurals.home_files_selected, rows.size, rows.size), style = ClearType.Headline, color = c.ink, modifier = Modifier.weight(1f).padding(start = 4.dp))
+ GlassCircle(onClick = { vm.shareFiles(rows); vm.selectedFiles.clear() }, tint = Candy.Sky, label = stringResource(R.string.common_share)) { GlassIcon(LucideIcons.Share2, null, Modifier.size(20.dp)) }
+ if (rows.size >= 2) GlassCircle(onClick = { vm.combineSelected(rows); vm.selectedFiles.clear() }, tint = Candy.Grape, label = stringResource(R.string.common_tool_combine)) { GlassIcon(LucideIcons.Combine, null, Modifier.size(20.dp)) }
+ if (recent) GlassCircle(onClick = { vm.removeRecents(rows); vm.selectedFiles.clear() }, label = stringResource(R.string.home_remove_from_recent)) { GlassIcon(LucideIcons.CircleMinus, null, Modifier.size(20.dp)) }
+ GlassCircle(onClick = onDelete, tint = Candy.Tomato, label = stringResource(R.string.common_delete)) { GlassIcon(LucideIcons.Trash2, null, Modifier.size(20.dp)) }
+ }
+}
+
+/** Where else files come from. */
+@Composable
+private fun Places(vm: AppViewModel, onBrowse: () -> Unit, onDevice: () -> Unit) {
+ Column {
+ Text(stringResource(R.string.files_places), style = ClearType.Title, color = clear.ink, modifier = Modifier.padding(start = 24.dp, top = 26.dp, bottom = 8.dp))
+ WashPanel(Modifier.padding(horizontal = 16.dp).fillMaxWidth()) {
+ Spacer(Modifier.height(4.dp))
+ PlaceRow(LucideIcons.Smartphone, stringResource(R.string.home_on_this_device), Candy.Sky, onDevice)
+ PlaceRow(LucideIcons.Images, stringResource(R.string.home_photos), Candy.Lemon) { vm.pickPhotosToPdf() }
+ PlaceRow(LucideIcons.FolderOpen, stringResource(R.string.home_look_in_other_folders), Candy.Mint, onBrowse)
+ Spacer(Modifier.height(4.dp))
+ }
+ }
+}
+
+@Composable
+private fun PlaceRow(icon: ImageVector, label: String, accent: Color, onClick: () -> Unit) {
+ GlassRow(label, onClick, icon = icon, accent = accent, trailing = { Icon(LucideIcons.ChevronRight, null, tint = clear.inkFaint, modifier = Modifier.size(18.dp)) })
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/SettingsScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/SettingsScreen.kt
new file mode 100644
index 0000000..dce7add
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/SettingsScreen.kt
@@ -0,0 +1,338 @@
+package com.chethan616.clearpdf.ui.desk
+
+import androidx.activity.compose.BackHandler
+import androidx.compose.foundation.Image
+import androidx.compose.foundation.background
+import androidx.compose.foundation.gestures.detectTapGestures
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ColumnScope
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.WindowInsets
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.navigationBars
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.statusBars
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.windowInsetsBottomHeight
+import androidx.compose.foundation.layout.windowInsetsTopHeight
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.input.pointer.pointerInput
+import androidx.compose.ui.platform.LocalClipboardManager
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalUriHandler
+import androidx.compose.ui.res.painterResource
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.AnnotatedString
+import androidx.compose.ui.unit.dp
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.ThemeChoice
+import com.chethan616.clearpdf.ui.glass.GlassCard
+import com.chethan616.clearpdf.ui.glass.GlassCircle
+import com.chethan616.clearpdf.ui.glass.GlassDialog
+import com.chethan616.clearpdf.ui.glass.GlassIcon
+import com.chethan616.clearpdf.ui.glass.GlassRow
+import com.chethan616.clearpdf.ui.glass.GlassSettings
+import com.chethan616.clearpdf.ui.glass.GlassStyle
+import com.chethan616.clearpdf.ui.glass.GlassTab
+import com.chethan616.clearpdf.ui.glass.GlassTabs
+import com.chethan616.clearpdf.ui.glass.GlassTextField
+import com.chethan616.clearpdf.ui.glass.GlassToggle
+import com.chethan616.clearpdf.ui.glass.MotionSettings
+import com.chethan616.clearpdf.ui.glass.MotionStyle
+import com.chethan616.clearpdf.ui.glass.WashPanel
+import com.chethan616.clearpdf.ui.glass.pressable
+import com.chethan616.clearpdf.ui.theme.Candy
+import com.chethan616.clearpdf.ui.theme.ClearType
+import com.chethan616.clearpdf.ui.theme.clear
+import com.kyant.shapes.RoundedRectangle
+
+/** ClearPDF's repository: help, issues and source. */
+const val CLEARPDF_REPO = "https://github.com/Chethan616/ClearPDF"
+
+/** Settings, and its Licences page. */
+@Composable
+fun SettingsScreen(vm: AppViewModel) {
+ var page by remember { mutableStateOf("root") }
+ BackHandler { if (page == "root") vm.settingsOpen = false else page = "root" }
+ when (page) {
+ "licences" -> LicencesPage { page = "root" }
+ else -> SettingsRoot(vm) { page = "licences" }
+ }
+}
+
+@Composable
+private fun SettingsRoot(vm: AppViewModel, openLicences: () -> Unit) {
+ val c = clear
+ val context = LocalContext.current
+ val uri = LocalUriHandler.current
+ var leaving by remember { mutableStateOf<String?>(null) }
+ var authorDialog by remember { mutableStateOf(false) }
+ LazyColumn(Modifier.fillMaxSize(), contentPadding = PaddingValues(bottom = 32.dp)) {
+ item { Spacer(Modifier.windowInsetsTopHeight(WindowInsets.statusBars)) }
+ item(key = "back") {
+ Row(Modifier.padding(start = 14.dp, top = 10.dp)) {
+ GlassCircle(onClick = { vm.settingsOpen = false }, label = stringResource(R.string.common_back)) { GlassIcon(LucideIcons.ArrowLeft, null, Modifier.size(21.dp)) }
+ }
+ }
+ item(key = "title") {
+ Spacer(Modifier.height(14.dp))
+ ScreenHeader(null, stringResource(R.string.home_settings))
+ }
+ item(key = "hero") { AppCard(vm) }
+
+ item(key = "look") { Section(stringResource(R.string.settings_look)) }
+ item(key = "theme") {
+ Choice(stringResource(R.string.settings_theme)) {
+ val options = listOf(ThemeChoice.System, ThemeChoice.Light, ThemeChoice.Dark)
+ GlassTabs(
+ listOf(
+ GlassTab(stringResource(R.string.settings_theme_system), LucideIcons.Contrast, Candy.Grape),
+ GlassTab(stringResource(R.string.settings_theme_light), LucideIcons.Sun, Candy.Tangerine),
+ GlassTab(stringResource(R.string.settings_theme_dark), LucideIcons.Moon, Candy.Sky),
+ ),
+ selected = options.indexOf(vm.theme).coerceAtLeast(0), onSelect = { vm.setThemeChoice(options[it]) },
+ modifier = Modifier.fillMaxWidth(), height = 64.dp,
+ )
+ }
+ }
+ item(key = "glass") {
+ Choice(stringResource(R.string.settings_glass)) {
+ val presets = GlassStyle.Presets
+ GlassTabs(
+ listOf(
+ GlassTab(stringResource(R.string.settings_glass_clear), accent = Candy.Sky),
+ GlassTab(stringResource(R.string.settings_glass_frosted), accent = Candy.Mint),
+ GlassTab(stringResource(R.string.settings_glass_crystal), accent = Candy.Grape),
+ GlassTab(stringResource(R.string.settings_glass_lite), accent = Candy.Tangerine),
+ ),
+ selected = presets.indexOf(GlassSettings.style).coerceAtLeast(0), onSelect = { GlassSettings.update(context, presets[it]) },
+ modifier = Modifier.fillMaxWidth(), height = 48.dp,
+ )
+ }
+ }
+ item(key = "motion") {
+ Choice(stringResource(R.string.settings_motion)) {
+ val presets = MotionStyle.Presets
+ GlassTabs(
+ listOf(
+ GlassTab(stringResource(R.string.settings_motion_calm), accent = Candy.Mint),
+ GlassTab(stringResource(R.string.settings_motion_normal), accent = Candy.Sky),
+ GlassTab(stringResource(R.string.settings_motion_bouncy), accent = Candy.Bubblegum),
+ GlassTab(stringResource(R.string.settings_motion_jelly), accent = Candy.Tomato),
+ ),
+ selected = presets.indexOf(MotionSettings.style).coerceAtLeast(0), onSelect = { MotionSettings.update(context, presets[it]) },
+ modifier = Modifier.fillMaxWidth(), height = 48.dp,
+ )
+ }
+ }
+ item(key = "feel") {
+ Panel {
+ ToggleRow(LucideIcons.Sparkles, Candy.Bubblegum, stringResource(R.string.settings_haptics), null, GlassSettings.haptics) { GlassSettings.updateHaptics(context, it) }
+ }
+ }
+
+ item(key = "reading") { Section(stringResource(R.string.settings_reading)) }
+ item(key = "readingpanel") {
+ Panel {
+ ToggleRow(LucideIcons.Sun, Candy.Lemon, stringResource(R.string.home_keep_screen_on), stringResource(R.string.home_keep_screen_on_body), vm.keepScreenOn) { vm.updateKeepScreenOn(it) }
+ ToggleRow(LucideIcons.Smartphone, Candy.Sky, stringResource(R.string.home_status_bar_in_documents), stringResource(R.string.home_status_bar_in_documents_body), vm.statusBarInDocuments) { vm.updateStatusBarInDocuments(it) }
+ ToggleRow(LucideIcons.Hash, Candy.Mint, stringResource(R.string.home_search_count), stringResource(R.string.home_search_count_body), vm.searchCount) { vm.updateSearchCount(it) }
+ ToggleRow(LucideIcons.SquareTerminal, Candy.Grape, stringResource(R.string.home_keyboard_shortcuts), stringResource(R.string.home_keyboard_shortcuts_body), vm.keyboardShortcuts) { vm.updateKeyboardShortcuts(it) }
+ }
+ }
+
+ item(key = "forms") { Section(stringResource(R.string.settings_forms)) }
+ item(key = "formspanel") {
+ Panel {
+ ToggleRow(LucideIcons.TextCursorInput, Candy.Tangerine, stringResource(R.string.home_offer_suggestions), null, vm.formSuggestions) { vm.updateFormSuggestions(it) }
+ GlassRow(stringResource(R.string.home_clear_suggestions), { vm.clearFormSuggestions() }, icon = LucideIcons.BrushCleaning, accent = Candy.Tomato)
+ GlassRow(
+ stringResource(R.string.home_author_title), { authorDialog = true }, icon = LucideIcons.UserRound, accent = Candy.Sky,
+ value = vm.toolPrefs.author.ifBlank { stringResource(R.string.home_author_hint) },
+ )
+ }
+ }
+
+ item(key = "about") { Section(stringResource(R.string.settings_about)) }
+ item(key = "aboutpanel") {
+ Panel {
+ GlassRow(stringResource(R.string.home_report_problem), { leaving = "$CLEARPDF_REPO/issues" }, icon = LucideIcons.MessageSquare, accent = Candy.Tomato)
+ GlassRow(stringResource(R.string.home_source_code), { uri.openUri(CLEARPDF_REPO) }, icon = LucideIcons.CodeXml, accent = Candy.Grape)
+ GlassRow(stringResource(R.string.home_engine), { uri.openUri("https://github.com/storytold/pdfcraft") }, icon = LucideIcons.Wrench, accent = Candy.Tangerine)
+ GlassRow(stringResource(R.string.home_licences), openLicences, icon = LucideIcons.ScrollText, accent = Candy.Mint)
+ }
+ }
+ item(key = "credits") {
+ GlassCard(Modifier.padding(horizontal = 16.dp, vertical = 14.dp).fillMaxWidth(), shape = RoundedRectangle(28.dp)) {
+ Column(Modifier.padding(20.dp)) {
+ Text(stringResource(R.string.settings_credits_title), style = ClearType.Title, color = c.ink)
+ Spacer(Modifier.height(6.dp))
+ Text(stringResource(R.string.settings_credits_body), style = ClearType.Body, color = c.inkSoft)
+ Spacer(Modifier.height(12.dp))
+ Text(stringResource(R.string.home_legal_notice), style = ClearType.Caption, color = c.inkFaint)
+ }
+ }
+ }
+ item { Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars)) }
+ }
+ leaving?.let { url ->
+ GlassDialog(
+ onDismiss = { leaving = null }, title = stringResource(R.string.home_leaving_title), icon = LucideIcons.ExternalLink, accent = Candy.Sky,
+ confirm = stringResource(R.string.home_continue), onConfirm = { leaving = null; uri.openUri(url) }, dismiss = stringResource(R.string.common_cancel),
+ ) { Text(stringResource(R.string.home_leaving_body), style = ClearType.Body, color = c.inkSoft) }
+ }
+ if (authorDialog) {
+ var name by remember { mutableStateOf(vm.toolPrefs.author) }
+ GlassDialog(
+ onDismiss = { authorDialog = false }, title = stringResource(R.string.home_author_title), icon = LucideIcons.UserRound, accent = Candy.Sky,
+ confirm = stringResource(R.string.common_ok), onConfirm = { vm.toolPrefs.author = name.trim(); authorDialog = false; vm.prefsChanged++ },
+ dismiss = stringResource(R.string.common_cancel),
+ ) { GlassTextField(name, { name = it }, stringResource(R.string.common_your_name)) }
+ }
+}
+
+/** The app's own card: its icon, its name, the version (long-press copies it). */
+@Composable
+private fun AppCard(vm: AppViewModel) {
+ val c = clear
+ val clipboard = LocalClipboardManager.current
+ val version = stringResource(R.string.home_version, vm.appVersion, com.chethan616.clearpdf.core.engineVersion())
+ val copied = stringResource(R.string.home_version_copied)
+ GlassCard(
+ Modifier.padding(horizontal = 16.dp, vertical = 16.dp).fillMaxWidth()
+ .pointerInput(version) { detectTapGestures(onLongPress = { clipboard.setText(AnnotatedString(version)); vm.tell(copied) }) },
+ shape = RoundedRectangle(30.dp),
+ ) {
+ Row(Modifier.padding(18.dp), verticalAlignment = Alignment.CenterVertically) {
+ Image(painterResource(R.mipmap.ic_launcher), null, Modifier.size(64.dp).clip(RoundedRectangle(18.dp)))
+ Spacer(Modifier.width(16.dp))
+ Column {
+ Text(stringResource(R.string.app_name), style = ClearType.Headline, color = c.ink)
+ Spacer(Modifier.height(2.dp))
+ Text(version, style = ClearType.Caption, color = c.inkSoft)
+ }
+ }
+ }
+}
+
+@Composable
+private fun Section(title: String) {
+ Text(title, style = ClearType.Headline, color = clear.ink, modifier = Modifier.padding(start = 22.dp, end = 22.dp, top = 22.dp, bottom = 10.dp))
+}
+
+/** A setting chosen by a segmented capsule: its name above, the glass capsule below. */
+@Composable
+private fun Choice(label: String, content: @Composable () -> Unit) {
+ Column(Modifier.padding(horizontal = 16.dp, vertical = 8.dp)) {
+ Text(label.uppercase(), style = ClearType.Eyebrow, color = clear.inkSoft, modifier = Modifier.padding(start = 8.dp, bottom = 8.dp))
+ content()
+ }
+}
+
+@Composable
+private fun Panel(content: @Composable ColumnScope.() -> Unit) {
+ WashPanel(Modifier.padding(horizontal = 16.dp, vertical = 4.dp).fillMaxWidth()) {
+ Spacer(Modifier.height(6.dp))
+ content()
+ Spacer(Modifier.height(6.dp))
+ }
+}
+
+/** A switch row: a candy blob, the setting's name and what it does, and a glass toggle. */
+@Composable
+private fun ToggleRow(icon: ImageVector, accent: Color, label: String, body: String?, checked: Boolean, onChange: (Boolean) -> Unit) {
+ val c = clear
+ Row(
+ Modifier.fillMaxWidth().pressable({ onChange(!checked) }).padding(horizontal = 18.dp, vertical = 10.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Box(Modifier.size(34.dp).clip(RoundedRectangle(11.dp)).background(accent.copy(alpha = if (c.dark) 0.26f else 0.16f)), contentAlignment = Alignment.Center) {
+ Icon(icon, null, tint = accent, modifier = Modifier.size(19.dp))
+ }
+ Spacer(Modifier.width(14.dp))
+ Column(Modifier.weight(1f)) {
+ Text(label, style = ClearType.BodyStrong, color = c.ink)
+ if (body != null) Text(body, style = ClearType.Caption, color = c.inkSoft)
+ }
+ Spacer(Modifier.width(12.dp))
+ GlassToggle(checked, onChange, accent = accent)
+ }
+}
+
+/** One entry of the Licences page: what it is, and its licence and authors. */
+private class Credit(val name: String, val terms: String)
+
+/** The open-source licences of everything ClearPDF is built from, then their full texts. */
+@Composable
+private fun LicencesPage(onBack: () -> Unit) {
+ val c = clear
+ val context = LocalContext.current
+ val texts = remember {
+ listOf("LICENSE-lucide.txt", "OFL-Inter.txt", "OFL-BricolageGrotesque.txt", "OFL-DancingScript.txt", "LICENSE-foxit.txt", "LICENSE-adobe-cmaps.txt").mapNotNull { name ->
+ runCatching { context.assets.open("licences/$name").bufferedReader().readText() }.getOrNull()?.takeIf { it.isNotBlank() }
+ }
+ }
+ val credits = listOf(
+ Credit(stringResource(R.string.root_licence_pdfcraft), stringResource(R.string.root_licence_pdfcraft_terms)),
+ Credit("AndroidLiquidGlass (backdrop)", "Apache-2.0, Kyant0"),
+ Credit("AndroidLiquidGlassView (LiquidTracker)", "MIT, Donny Yale (QmDeve)"),
+ Credit("UniFFI", "MPL-2.0, Mozilla"),
+ Credit("JNA", "Apache-2.0"),
+ Credit("AndroidX, Jetpack Compose, Kotlin coroutines", "Apache-2.0"),
+ Credit(stringResource(R.string.root_licence_lucide), "ISC, Lucide Contributors"),
+ Credit("Bricolage Grotesque", "SIL Open Font License 1.1, The Bricolage Grotesque Project Authors"),
+ Credit(stringResource(R.string.root_licence_inter), "SIL Open Font License 1.1, The Inter Project Authors"),
+ Credit(stringResource(R.string.root_licence_dancing_script), "SIL Open Font License 1.1, The Dancing Script Project Authors"),
+ Credit(stringResource(R.string.root_licence_foxit), "BSD-3-Clause, Foxit Software Inc. and the PDFium Authors"),
+ Credit(stringResource(R.string.root_licence_cmaps), "BSD-3-Clause, Adobe"),
+ Credit(stringResource(R.string.root_licence_ocrs), stringResource(R.string.root_licence_ocrs_terms)),
+ Credit(stringResource(R.string.root_licence_rust), stringResource(R.string.root_licence_rust_terms)),
+ )
+ LazyColumn(Modifier.fillMaxSize(), contentPadding = PaddingValues(bottom = 32.dp)) {
+ item { Spacer(Modifier.windowInsetsTopHeight(WindowInsets.statusBars)) }
+ item {
+ Row(Modifier.padding(start = 14.dp, top = 10.dp)) {
+ GlassCircle(onClick = onBack, label = stringResource(R.string.common_back)) { GlassIcon(LucideIcons.ArrowLeft, null, Modifier.size(21.dp)) }
+ }
+ Spacer(Modifier.height(14.dp))
+ ScreenHeader(null, stringResource(R.string.home_licences))
+ Spacer(Modifier.height(16.dp))
+ }
+ item {
+ Panel {
+ credits.forEach { k ->
+ Column(Modifier.fillMaxWidth().padding(horizontal = 18.dp, vertical = 10.dp)) {
+ Text(k.name, style = ClearType.BodyStrong, color = c.ink)
+ Text(k.terms, style = ClearType.Caption, color = c.inkSoft)
+ }
+ }
+ }
+ }
+ items(texts.size) { i ->
+ WashPanel(Modifier.padding(horizontal = 16.dp, vertical = 6.dp).fillMaxWidth()) {
+ Text(texts[i], style = ClearType.Caption, color = c.inkSoft, modifier = Modifier.padding(18.dp))
+ }
+ }
+ item { Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars)) }
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/ToolsScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/ToolsScreen.kt
new file mode 100644
index 0000000..6a6b1c4
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/desk/ToolsScreen.kt
@@ -0,0 +1,153 @@
+package com.chethan616.clearpdf.ui.desk
+
+import androidx.compose.animation.animateColorAsState
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.WindowInsets
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.navigationBars
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.statusBars
+import androidx.compose.foundation.layout.windowInsetsBottomHeight
+import androidx.compose.foundation.layout.windowInsetsTopHeight
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyRow
+import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.glass.GlassMotion
+import com.chethan616.clearpdf.ui.glass.pressable
+import com.chethan616.clearpdf.ui.glass.wash
+import com.chethan616.clearpdf.ui.theme.Candy
+import com.chethan616.clearpdf.ui.theme.ClearType
+import com.chethan616.clearpdf.ui.theme.clear
+import com.kyant.shapes.Capsule
+import com.kyant.shapes.RoundedRectangle
+
+private val Categories = listOf(
+ "All" to R.string.home_category_all,
+ "Read" to R.string.home_category_read,
+ "Create" to R.string.home_category_create,
+ "Edit" to R.string.home_category_edit,
+ "Convert" to R.string.home_category_convert,
+)
+
+/**
+ * Tools: a big title, candy category chips, the featured tool as a wide hero tile, then every tool
+ * as a card with its candy blob, name and one line about it.
+ */
+@Composable
+fun ToolsScreen(vm: AppViewModel) {
+ val c = clear
+ var cat by rememberSaveable { mutableStateOf("All") }
+ val tools = ToolCatalog.All.filter { cat == "All" || cat in it.categories }
+ val featured = if (cat == "All") ToolCatalog.Edit else null
+ val grid = tools.filter { it !== featured }
+ LazyColumn(Modifier.fillMaxSize(), contentPadding = PaddingValues(bottom = DockClearance)) {
+ item { Spacer(Modifier.windowInsetsTopHeight(WindowInsets.statusBars)) }
+ item(key = "header") {
+ Spacer(Modifier.height(16.dp))
+ ScreenHeader(stringResource(R.string.tools_subtitle), stringResource(R.string.home_tab_tools)) { SettingsButton(vm) }
+ }
+ item(key = "chips") {
+ LazyRow(contentPadding = PaddingValues(horizontal = 16.dp, vertical = 16.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ items(Categories, key = { it.first }) { (k, label) -> Chip(stringResource(label), k == cat, chipAccent(k)) { cat = k } }
+ }
+ }
+ if (featured != null) item(key = "featured") { FeaturedTile(featured) { featured.go(vm) } }
+ items(grid.chunked(2), key = { row -> row.joinToString { it.key } }) { pair ->
+ Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 6.dp), horizontalArrangement = Arrangement.spacedBy(12.dp)) {
+ pair.forEach { t -> ToolCard(t, Modifier.weight(1f)) { t.go(vm) } }
+ if (pair.size == 1) Spacer(Modifier.weight(1f))
+ }
+ }
+ item { Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars)) }
+ }
+}
+
+private fun chipAccent(k: String) = when (k) {
+ "Read" -> Candy.Sky
+ "Create" -> Candy.Tomato
+ "Edit" -> Candy.Bubblegum
+ "Convert" -> Candy.Mint
+ else -> Candy.Grape
+}
+
+/** A category chip: a wash capsule, filled with its candy once chosen. */
+@Composable
+private fun Chip(label: String, chosen: Boolean, accent: Color, onClick: () -> Unit) {
+ val c = clear
+ val fill by animateColorAsState(if (chosen) accent else Color.Transparent, GlassMotion.settle(), label = "chip")
+ Box(
+ Modifier.pressable(onClick).wash(Capsule).background(fill, Capsule).padding(horizontal = 18.dp, vertical = 10.dp),
+ contentAlignment = Alignment.Center,
+ ) { Text(label, style = ClearType.BodyStrong, color = if (chosen) Color.White else c.ink) }
+}
+
+/** The featured tool: a wide candy tile with a bubble of light and a big headline. */
+@Composable
+private fun FeaturedTile(t: ToolDef, onClick: () -> Unit) {
+ val shape = RoundedRectangle(32.dp)
+ Box(
+ Modifier.padding(horizontal = 16.dp, vertical = 6.dp).fillMaxWidth().height(168.dp)
+ .pressable(onClick, pressedScale = 0.95f).clip(shape)
+ .background(Brush.linearGradient(listOf(t.accent, Candy.Grape)))
+ .padding(22.dp),
+ ) {
+ Box(Modifier.align(Alignment.TopEnd).size(150.dp).graphicsLayer { translationX = 50.dp.toPx(); translationY = (-60).dp.toPx() }.clip(CircleShape).background(Color.White.copy(alpha = 0.16f)))
+ Box(Modifier.align(Alignment.BottomEnd).size(70.dp).graphicsLayer { translationX = 10.dp.toPx(); translationY = 24.dp.toPx() }.clip(CircleShape).background(Color.White.copy(alpha = 0.12f)))
+ Column {
+ Text(stringResource(R.string.tools_featured).uppercase(), style = ClearType.Eyebrow, color = Color.White.copy(alpha = 0.85f))
+ Spacer(Modifier.height(8.dp))
+ Text(stringResource(t.label), style = ClearType.Display, color = Color.White)
+ }
+ Row(Modifier.align(Alignment.BottomStart), verticalAlignment = Alignment.CenterVertically) {
+ Text(stringResource(t.about), style = ClearType.Label, color = Color.White.copy(alpha = 0.9f), maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false).padding(end = 64.dp))
+ }
+ Box(Modifier.align(Alignment.BottomEnd).size(52.dp).clip(CircleShape).background(Color.White), contentAlignment = Alignment.Center) {
+ Icon(t.icon, null, tint = t.accent, modifier = Modifier.size(26.dp))
+ }
+ }
+}
+
+/** A tool's card: a candy blob with its glyph, its name in display type, and one line about it. */
+@Composable
+private fun ToolCard(t: ToolDef, modifier: Modifier, onClick: () -> Unit) {
+ val c = clear
+ Column(modifier.heightIn(min = 168.dp).pressable(onClick).wash(RoundedRectangle(28.dp)).padding(16.dp)) {
+ Box(
+ Modifier.size(52.dp).clip(RoundedRectangle(17.dp)).background(Brush.linearGradient(listOf(t.accent.copy(alpha = 0.85f), t.accent))),
+ contentAlignment = Alignment.Center,
+ ) { Icon(t.icon, null, tint = Color.White, modifier = Modifier.size(26.dp)) }
+ Spacer(Modifier.height(14.dp))
+ Text(stringResource(t.label), style = ClearType.Tile, color = c.ink, maxLines = 2)
+ Spacer(Modifier.height(4.dp))
+ Text(stringResource(t.about), style = ClearType.Caption, color = c.inkSoft, maxLines = 3, overflow = TextOverflow.Ellipsis)
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Backdrops.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Backdrops.kt
new file mode 100644
index 0000000..32d2a32
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Backdrops.kt
@@ -0,0 +1,191 @@
+package com.chethan616.clearpdf.ui.glass
+
+import androidx.compose.animation.core.Animatable
+import androidx.compose.animation.core.AnimationVector4D
+import androidx.compose.animation.core.TwoWayConverter
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxScope
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.DisposableEffect
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.Stable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.key
+import androidx.compose.runtime.mutableStateListOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberUpdatedState
+import androidx.compose.runtime.setValue
+import androidx.compose.runtime.staticCompositionLocalOf
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.drawBehind
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.layout.onGloballyPositioned
+import androidx.compose.ui.layout.positionInWindow
+import androidx.compose.ui.unit.IntSize
+import com.chethan616.clearpdf.ui.theme.clear
+import com.kyant.backdrop.Backdrop
+import com.kyant.backdrop.backdrops.emptyBackdrop
+import com.kyant.backdrop.backdrops.layerBackdrop
+import com.kyant.backdrop.backdrops.rememberCombinedBackdrop
+import com.kyant.backdrop.backdrops.rememberLayerBackdrop
+import kotlinx.coroutines.launch
+
+/**
+ * What a glass surface refracts: everything drawn beneath it. Provided by the layer below, never
+ * passed by hand, so no surface can sample the wallpaper when something else is actually behind it.
+ */
+val LocalBackdrop = staticCompositionLocalOf<Backdrop> { emptyBackdrop() }
+
+/**
+ * Draws [content] (recording it), then [above] over it. Glass in [above] refracts the content and
+ * everything beneath this layer; glass inside [content] refracts only what is beneath the layer.
+ *
+ * Use it wherever glass floats over something: the app over its wallpaper, the dock over the
+ * screens, a viewer's bars over its pages, a glass chip over a picture.
+ */
+@Composable
+fun GlassLayer(
+ modifier: Modifier = Modifier,
+ content: @Composable BoxScope.() -> Unit,
+ above: @Composable BoxScope.() -> Unit,
+) {
+ val below = LocalBackdrop.current
+ val layer = rememberLayerBackdrop()
+ val combined = rememberCombinedBackdrop(below, layer)
+ Box(modifier) {
+ Box(Modifier.matchParentSize().layerBackdrop(layer), content = content)
+ CompositionLocalProvider(LocalBackdrop provides combined) { Box(Modifier.matchParentSize(), content = above) }
+ }
+}
+
+/** A mood of the aurora: where its blobs sit, as fractions of the screen, and how big they are. */
+data class AuroraMood(val blobs: List<Offset>, val radius: Float = 0.75f)
+
+object AuroraMoods {
+ val Desk = AuroraMood(listOf(Offset(0.05f, 0.08f), Offset(0.95f, 0.02f), Offset(0.0f, 0.62f), Offset(1.0f, 0.78f), Offset(0.5f, 1.05f)))
+ val Files = AuroraMood(listOf(Offset(0.9f, 0.1f), Offset(0.1f, 0.0f), Offset(1.0f, 0.55f), Offset(0.0f, 0.9f), Offset(0.45f, 0.4f)), 0.7f)
+ val Tools = AuroraMood(listOf(Offset(0.5f, -0.05f), Offset(0.0f, 0.3f), Offset(0.95f, 0.45f), Offset(0.15f, 1.0f), Offset(0.9f, 1.0f)))
+ val Settings = AuroraMood(listOf(Offset(0.0f, 0.0f), Offset(1.0f, 0.15f), Offset(0.2f, 0.75f), Offset(0.85f, 1.0f), Offset(0.6f, 0.45f)), 0.65f)
+}
+
+private val OffsetPairConverter = TwoWayConverter<Pair<Offset, Offset>, AnimationVector4D>(
+ { (a, b) -> AnimationVector4D(a.x, a.y, b.x, b.y) },
+ { v -> Offset(v.v1, v.v2) to Offset(v.v3, v.v4) },
+)
+
+/**
+ * The wallpaper: the canvas colour under soft candy blobs. Static while idle (no infinite animation);
+ * a new [mood] glides the blobs to new places on one spring, so each tab has its own light.
+ */
+@Composable
+fun Aurora(mood: AuroraMood, modifier: Modifier = Modifier) {
+ val colors = clear
+ val anims = remember { List(5) { i -> Animatable(mood.blobs[i % mood.blobs.size] to Offset(mood.radius, 0f), OffsetPairConverter) } }
+ LaunchedEffect(mood) {
+ mood.blobs.forEachIndexed { i, p ->
+ val target = p to Offset(mood.radius, 0f)
+ if (anims[i].targetValue != target) launch { anims[i].animateTo(target, GlassMotion.rise()) }
+ }
+ }
+ Box(
+ modifier.fillMaxSize().drawBehind {
+ drawRect(colors.canvas)
+ val r = size.maxDimension
+ colors.aurora.forEachIndexed { i, (c, strength) ->
+ val (p, rad) = anims.getOrNull(i)?.value ?: return@forEachIndexed
+ if (!(r * rad.x > 1f)) return@forEachIndexed
+ val center = Offset(p.x * size.width, p.y * size.height)
+ drawCircle(
+ Brush.radialGradient(listOf(c.copy(alpha = strength), c.copy(alpha = strength * 0.4f), Color.Transparent), center, r * rad.x),
+ radius = r * rad.x, center = center,
+ )
+ }
+ },
+ )
+}
+
+/**
+ * An in-window portal for floating glass (menus, sheets, dialogs, toasts). Glass can't refract the
+ * layer it is drawn in, so anything that floats is composed here, above every screen and the dock,
+ * where [LocalBackdrop] is the whole live screen.
+ */
+@Stable
+class GlassOverlayHost {
+ internal val entries = mutableStateListOf<OverlayEntry>()
+ internal var originInWindow by mutableStateOf(Offset.Zero)
+ var size by mutableStateOf(IntSize.Zero)
+ internal set
+
+ internal fun register(entry: OverlayEntry) {
+ entries.removeAll { it.key === entry.key }
+ entries.add(entry)
+ }
+
+ internal fun unregister(key: Any) {
+ entries.removeAll { it.key === key }
+ }
+
+ /** A window point in the overlay's space. Read at layout or draw time. */
+ fun windowToLocal(point: Offset): Offset = point - originInWindow
+}
+
+internal class OverlayEntry(val key: Any, val content: @Composable BoxScope.() -> Unit)
+
+val LocalGlassOverlayHost = staticCompositionLocalOf<GlassOverlayHost?> { null }
+
+@Composable
+fun GlassOverlayLayer(host: GlassOverlayHost, modifier: Modifier = Modifier) {
+ Box(
+ modifier.fillMaxSize().onGloballyPositioned {
+ host.originInWindow = it.positionInWindow()
+ host.size = it.size
+ },
+ ) {
+ host.entries.forEach { entry -> key(entry.key) { entry.content(this) } }
+ }
+}
+
+/** Shows [content] in the overlay for as long as the caller is composed. Draw nothing while idle. */
+@Composable
+fun GlassOverlay(content: @Composable BoxScope.() -> Unit) {
+ val host = LocalGlassOverlayHost.current ?: return
+ val latest by rememberUpdatedState(content)
+ val key = remember { Any() }
+ DisposableEffect(host, key) {
+ host.register(OverlayEntry(key) { latest() })
+ onDispose { host.unregister(key) }
+ }
+}
+
+/**
+ * The app's glass stack, bottom to top: the [wallpaper]; the [screens]; the [chrome] that floats over
+ * them (the dock); then the overlay portal over all three. Provide [LocalGlassOverlayHost] above it
+ * so overlays composed outside the stage (app-level dialogs and sheets) land in the same portal.
+ */
+@Composable
+fun GlassStage(
+ wallpaper: @Composable BoxScope.() -> Unit,
+ screens: @Composable BoxScope.() -> Unit,
+ chrome: @Composable BoxScope.() -> Unit,
+) {
+ val provided = LocalGlassOverlayHost.current
+ val host = provided ?: remember { GlassOverlayHost() }
+ val wall = rememberLayerBackdrop()
+ CompositionLocalProvider(LocalGlassOverlayHost provides host) {
+ Box(Modifier.fillMaxSize()) {
+ Box(Modifier.fillMaxSize().layerBackdrop(wall), content = wallpaper)
+ CompositionLocalProvider(LocalBackdrop provides wall) {
+ GlassLayer(Modifier.fillMaxSize(), content = screens) {
+ GlassLayer(Modifier.fillMaxSize(), content = chrome) {
+ GlassOverlayLayer(host)
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Buttons.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Buttons.kt
new file mode 100644
index 0000000..47d5aaa
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Buttons.kt
@@ -0,0 +1,158 @@
+package com.chethan616.clearpdf.ui.glass
+
+import androidx.compose.foundation.ExperimentalFoundationApi
+import androidx.compose.foundation.combinedClickable
+import androidx.compose.foundation.interaction.MutableInteractionSource
+import androidx.compose.foundation.interaction.PressInteraction
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.RowScope
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.LaunchedEffect
+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.graphics.BlendMode
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.isSpecified
+import androidx.compose.ui.hapticfeedback.HapticFeedbackType
+import androidx.compose.ui.platform.LocalHapticFeedback
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.semantics.contentDescription
+import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.dp
+import com.chethan616.clearpdf.ui.theme.clear
+import com.kyant.backdrop.drawBackdrop
+import com.kyant.shapes.Capsule
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.ui.graphics.Shape
+
+/** The ink drawn on a glass control: white on a candy tint, else the theme's ink. */
+val LocalGlassInk = androidx.compose.runtime.compositionLocalOf { Color.Unspecified }
+
+/**
+ * The pressable glass both buttons share: refracts [LocalBackdrop], swells, leans, blooms and jiggles,
+ * ticks once. A long-press only arms [onLongClick]; it runs when the finger lifts.
+ */
+@OptIn(ExperimentalFoundationApi::class)
+@Composable
+private fun Modifier.glassControl(
+ shape: Shape,
+ onClick: () -> Unit,
+ onLongClick: (() -> Unit)?,
+ tint: Color,
+ surface: Color,
+ blur: Dp,
+ label: String?,
+): Modifier {
+ val backdrop = LocalBackdrop.current
+ val scope = rememberCoroutineScope()
+ val haptics = LocalHapticFeedback.current
+ val currentHaptics by rememberUpdatedState(haptics)
+ val hasLongClick by rememberUpdatedState(onLongClick != null)
+ val highlight = remember(scope) {
+ InteractiveHighlight(scope, longPressExpand = true, onLongPressExpand = {
+ if (!hasLongClick) currentHaptics.performHapticFeedback(HapticFeedbackType.LongPress)
+ })
+ }
+ val source = remember { MutableInteractionSource() }
+ val armed = remember { booleanArrayOf(false) }
+ val currentLongClick by rememberUpdatedState(onLongClick)
+ LaunchedEffect(source) {
+ source.interactions.collect { i ->
+ when (i) {
+ is PressInteraction.Release -> if (armed[0]) { armed[0] = false; currentLongClick?.invoke() }
+ is PressInteraction.Cancel -> armed[0] = false
+ }
+ }
+ }
+ val style = GlassSettings.style
+ return this
+ .drawBackdrop(
+ backdrop = backdrop,
+ shape = { shape },
+ shadow = null,
+ effects = { glassEffects(style, blur.toPx(), 12f.dp.toPx(), 24f.dp.toPx()) },
+ highlight = { glassHighlight(style) },
+ layerBlock = { liquidPressTransform(highlight) },
+ onDrawSurface = {
+ if (tint.isSpecified) {
+ // a soft white base first, so the candy comes out vivid over dark and light alike
+ drawRect(Color.White.copy(alpha = 0.42f))
+ drawRect(tint, blendMode = BlendMode.Hue)
+ drawRect(tint.copy(alpha = 0.82f))
+ }
+ if (surface.isSpecified) drawRect(surface.glassTint(style))
+ },
+ )
+ .combinedClickable(
+ interactionSource = source,
+ indication = null,
+ role = Role.Button,
+ onClick = { if (highlight.expandProgress < 0.5f) haptics.performHapticFeedback(HapticFeedbackType.ContextClick); onClick() },
+ onLongClick = if (onLongClick != null) ({ armed[0] = true; haptics.performHapticFeedback(HapticFeedbackType.LongPress) }) else null,
+ )
+ .then(highlight.modifier)
+ .then(highlight.gestureModifier)
+ .then(if (label != null) Modifier.semantics { contentDescription = label } else Modifier)
+}
+
+/**
+ * A glass capsule. With [tint] it's the vivid candy button (white ink); without, a neutral pill.
+ */
+@Composable
+fun GlassPill(
+ onClick: () -> Unit,
+ modifier: Modifier = Modifier,
+ tint: Color = Color.Unspecified,
+ surface: Color = if (tint.isSpecified) Color.Unspecified else clear.glass,
+ height: Dp = 48.dp,
+ blur: Dp = 2.dp,
+ horizontalPadding: Dp = 18.dp,
+ onLongClick: (() -> Unit)? = null,
+ label: String? = null,
+ content: @Composable RowScope.() -> Unit,
+) {
+ val ink = if (tint.isSpecified) Color.White else clear.ink
+ CompositionLocalProvider(LocalGlassInk provides ink) {
+ Row(
+ modifier
+ .glassControl(Capsule, onClick, onLongClick, tint, surface, blur, label)
+ .height(height)
+ .padding(horizontal = horizontalPadding),
+ horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),
+ verticalAlignment = Alignment.CenterVertically,
+ content = content,
+ )
+ }
+}
+
+/** A round glass button, usually an icon. */
+@Composable
+fun GlassCircle(
+ onClick: () -> Unit,
+ modifier: Modifier = Modifier,
+ size: Dp = 44.dp,
+ tint: Color = Color.Unspecified,
+ surface: Color = if (tint.isSpecified) Color.Unspecified else clear.glass,
+ onLongClick: (() -> Unit)? = null,
+ label: String? = null,
+ content: @Composable () -> Unit,
+) {
+ val ink = if (tint.isSpecified) Color.White else clear.ink
+ CompositionLocalProvider(LocalGlassInk provides ink) {
+ Box(
+ modifier.size(size).glassControl(CircleShape, onClick, onLongClick, tint, surface, 2.dp, label),
+ contentAlignment = Alignment.Center,
+ ) { content() }
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Controls.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Controls.kt
new file mode 100644
index 0000000..47da663
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Controls.kt
@@ -0,0 +1,233 @@
+package com.chethan616.clearpdf.ui.glass
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.gestures.detectTapGestures
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxWithConstraints
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableFloatStateOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.runtime.rememberUpdatedState
+import androidx.compose.runtime.setValue
+import androidx.compose.runtime.snapshotFlow
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.draw.drawBehind
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.drawscope.scale
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.graphics.lerp
+import androidx.compose.ui.hapticfeedback.HapticFeedbackType
+import androidx.compose.ui.input.pointer.pointerInput
+import androidx.compose.ui.layout.layout
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalHapticFeedback
+import androidx.compose.ui.platform.LocalLayoutDirection
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.semantics.onClick
+import androidx.compose.ui.semantics.role
+import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.semantics.toggleableState
+import androidx.compose.ui.state.ToggleableState
+import androidx.compose.ui.unit.LayoutDirection
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.util.fastCoerceIn
+import androidx.compose.ui.util.fastRoundToInt
+import androidx.compose.ui.util.lerp
+import com.chethan616.clearpdf.ui.theme.Candy
+import com.chethan616.clearpdf.ui.theme.clear
+import com.kyant.backdrop.backdrops.layerBackdrop
+import com.kyant.backdrop.backdrops.rememberBackdrop
+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
+import com.kyant.backdrop.highlight.Highlight
+import com.kyant.backdrop.shadow.InnerShadow
+import com.kyant.shapes.Capsule
+import kotlin.math.abs
+import kotlinx.coroutines.flow.collectLatest
+
+/** The thumb both controls share: an opaque white capsule at rest, a refracting lens while held. */
+@Composable
+private fun Modifier.thumb(drag: DampedDragAnimation, track: com.kyant.backdrop.backdrops.LayerBackdrop, lensHeight: Float, lensAmount: Float, trackScale: Float): Modifier {
+ val backdrop = LocalBackdrop.current
+ return drawBackdrop(
+ backdrop = rememberCombinedBackdrop(
+ backdrop,
+ rememberBackdrop(track) { draw ->
+ val p = drag.pressProgress
+ scale(lerp(2f / 3f, trackScale, p), lerp(0f, trackScale, p)) { draw() }
+ },
+ ),
+ shape = { Capsule },
+ effects = {
+ val p = drag.pressProgress
+ if (p > 0f) blur(8f.dp.toPx() * (1f - p))
+ lens(lensHeight.dp.toPx() * p, lensAmount.dp.toPx() * p, chromaticAberration = true)
+ },
+ highlight = {
+ val p = drag.pressProgress
+ if (p <= 0f) null else Highlight.Ambient.copy(width = Highlight.Ambient.width / 1.5f, blurRadius = Highlight.Ambient.blurRadius / 1.5f, alpha = p)
+ },
+ shadow = null,
+ innerShadow = {
+ val p = drag.pressProgress
+ if (p <= 0f) null else InnerShadow(radius = 4f.dp * p, alpha = p)
+ },
+ // covered by the white surface at rest: don't record or blur what nobody can see
+ onDrawBackdrop = { draw -> if (drag.pressProgress > 0f) draw() },
+ layerBlock = {
+ scaleX = drag.scaleX
+ scaleY = drag.scaleY
+ },
+ onDrawSurface = { drawRect(Color.White.copy(alpha = 1f - drag.pressProgress)) },
+ )
+}
+
+/** A glass switch: drag or tap, the thumb turns to glass under the finger. */
+@Composable
+fun GlassToggle(checked: Boolean, onChange: (Boolean) -> Unit, modifier: Modifier = Modifier, accent: Color = Candy.Mint) {
+ val c = clear
+ val track = if (c.dark) Color(0xFF787880).copy(0.36f) else Color(0xFF787878).copy(0.2f)
+ val density = LocalDensity.current
+ val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
+ val haptics = LocalHapticFeedback.current
+ val dragWidth = with(density) { 20f.dp.toPx() }
+ val scope = rememberCoroutineScope()
+ val current by rememberUpdatedState(checked)
+ val change by rememberUpdatedState(onChange)
+ var didDrag by remember { mutableStateOf(false) }
+ var fraction by remember { mutableFloatStateOf(if (checked) 1f else 0f) }
+ val drag = remember(scope) {
+ DampedDragAnimation(
+ scope, fraction, 0f..1f, 0.001f, 1f, 1.5f,
+ onDragStarted = {},
+ onDragStopped = {
+ fraction = if (didDrag) (if (targetValue >= 0.5f) 1f else 0f) else (if (current) 0f else 1f)
+ didDrag = false
+ if ((fraction == 1f) != current) {
+ haptics.performHapticFeedback(HapticFeedbackType.SegmentTick)
+ change(fraction == 1f)
+ }
+ },
+ onDrag = { _, d ->
+ if (!didDrag) didDrag = d.x != 0f
+ val delta = d.x / dragWidth
+ fraction = (if (isLtr) fraction + delta else fraction - delta).fastCoerceIn(0f, 1f)
+ },
+ )
+ }
+ LaunchedEffect(drag) { snapshotFlow { fraction }.collectLatest { drag.updateValue(it) } }
+ LaunchedEffect(checked) {
+ val target = if (checked) 1f else 0f
+ if (target != fraction) {
+ fraction = target
+ drag.animateToValue(target)
+ }
+ }
+ val trackLayer = rememberLayerBackdrop()
+ val stretch = rememberLiquidStretchState(stretchFactor = 0.4f, minScale = 0.85f, maxScale = 1.2f)
+ LaunchedEffect(drag, stretch) { snapshotFlow { drag.value }.collect { stretch.onPositionSample(it * dragWidth) } }
+ Box(
+ modifier.clip(Capsule).then(drag.modifier).semantics {
+ role = Role.Switch
+ toggleableState = ToggleableState(current)
+ onClick { change(!current); true }
+ },
+ contentAlignment = Alignment.CenterStart,
+ ) {
+ Box(Modifier.layerBackdrop(trackLayer).clip(Capsule).drawBehind { drawRect(lerp(track, accent, drag.value)) }.size(64.dp, 28.dp))
+ Box(
+ Modifier
+ .graphicsLayer {
+ val pad = 2f.dp.toPx()
+ translationX = if (isLtr) lerp(pad, pad + dragWidth, drag.value) else lerp(-pad, -(pad + dragWidth), drag.value)
+ }
+ .liquidStretch(stretch)
+ .thumb(drag, trackLayer, 5f, 10f, 0.75f)
+ .size(40.dp, 24.dp),
+ )
+ }
+}
+
+/** A glass slider: the candy fill follows the thumb, which turns to glass while held. */
+@Composable
+fun GlassSlider(
+ value: Float,
+ onChange: (Float) -> Unit,
+ modifier: Modifier = Modifier,
+ range: ClosedFloatingPointRange<Float> = 0f..1f,
+ accent: Color = Candy.Sky,
+) {
+ val c = clear
+ val track = if (c.dark) Color(0xFF787880).copy(0.36f) else Color(0xFF787878).copy(0.2f)
+ val trackLayer = rememberLayerBackdrop()
+ BoxWithConstraints(modifier.fillMaxWidth(), contentAlignment = Alignment.CenterStart) {
+ val width = constraints.maxWidth.coerceAtLeast(1)
+ val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
+ val scope = rememberCoroutineScope()
+ val current = value.coerceIn(range.start, range.endInclusive)
+ val change by rememberUpdatedState(onChange)
+ var dragging by remember { mutableStateOf(false) }
+ val drag = remember(scope, isLtr, width, range.start, range.endInclusive) {
+ DampedDragAnimation(
+ scope, current, range, 0.001f, 1f, 1.5f,
+ onDragStarted = { dragging = true },
+ onDragStopped = { dragging = false },
+ onDrag = { _, d ->
+ val delta = (range.endInclusive - range.start) * (d.x / width.toFloat())
+ if (delta != 0f) {
+ val next = (if (isLtr) targetValue + delta else targetValue - delta).coerceIn(range.start, range.endInclusive)
+ updateValue(next)
+ change(next)
+ }
+ },
+ )
+ }
+ val stretch = rememberLiquidStretchState(stretchFactor = 0.4f, minScale = 0.85f, maxScale = 1.2f)
+ LaunchedEffect(drag, stretch, width) { snapshotFlow { drag.progress }.collect { stretch.onPositionSample(it * width) } }
+ LaunchedEffect(current, dragging, drag) {
+ if (!dragging && abs(drag.targetValue - current) > 0.001f) drag.updateValue(current)
+ }
+ Box(Modifier.layerBackdrop(trackLayer)) {
+ Box(
+ Modifier.clip(Capsule).background(track)
+ .pointerInput(width, isLtr, range.start, range.endInclusive) {
+ detectTapGestures { p ->
+ val delta = (range.endInclusive - range.start) * (p.x / width.toFloat())
+ val target = (if (isLtr) range.start + delta else range.endInclusive - delta).coerceIn(range)
+ drag.animateToValue(target)
+ change(target)
+ }
+ }
+ .height(6.dp).fillMaxWidth(),
+ )
+ Box(
+ Modifier.clip(Capsule).background(accent).height(6.dp).layout { m, cons ->
+ val p = m.measure(cons)
+ layout((cons.maxWidth * drag.progress).fastRoundToInt(), p.height) { p.place(0, 0) }
+ },
+ )
+ }
+ Box(
+ Modifier
+ .graphicsLayer {
+ translationX = (-size.width / 2f + width * drag.progress).fastCoerceIn(-size.width / 4f, width - size.width * 3f / 4f) * if (isLtr) 1f else -1f
+ }
+ .then(drag.modifier)
+ .liquidStretch(stretch)
+ .thumb(drag, trackLayer, 10f, 14f, 1f)
+ .size(40.dp, 24.dp),
+ )
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Haptics.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Haptics.kt
new file mode 100644
index 0000000..91b4aac
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Haptics.kt
@@ -0,0 +1,28 @@
+package com.chethan616.clearpdf.ui.glass
+
+import android.os.SystemClock
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.remember
+import androidx.compose.ui.hapticfeedback.HapticFeedback
+import androidx.compose.ui.hapticfeedback.HapticFeedbackType
+import androidx.compose.ui.platform.LocalHapticFeedback
+
+/** One tap is one tick: anything within [windowMs] of the last haptic is dropped. Honours Settings. */
+class ThrottledHaptics(private val delegate: HapticFeedback, private val windowMs: Long = 90L) : HapticFeedback {
+ private var last = 0L
+ override fun performHapticFeedback(hapticFeedbackType: HapticFeedbackType) {
+ if (!GlassSettings.haptics) return
+ val now = SystemClock.uptimeMillis()
+ if (now - last < windowMs) return
+ last = now
+ delegate.performHapticFeedback(hapticFeedbackType)
+ }
+}
+
+@Composable
+fun ProvideGlassHaptics(content: @Composable () -> Unit) {
+ val system = LocalHapticFeedback.current
+ val throttled = remember(system) { ThrottledHaptics(system) }
+ CompositionLocalProvider(LocalHapticFeedback provides throttled, content = content)
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Motion.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Motion.kt
new file mode 100644
index 0000000..2b3a198
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Motion.kt
@@ -0,0 +1,113 @@
+package com.chethan616.clearpdf.ui.glass
+
+import android.content.Context
+import androidx.compose.animation.core.Spring
+import androidx.compose.animation.core.SpringSpec
+import androidx.compose.animation.core.spring
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
+
+/**
+ * How springy the glass moves: multipliers on the designed physics, so [Normal] is the design exactly.
+ * [bounce] 0.5 is the design (higher overshoots more); [speed] scales stiffness; [press] how far a
+ * control swells or dips under the finger; [wobble] the release jiggle; [stretch] the lean toward a
+ * dragging finger; [bloom] how much a long-pressed control grows.
+ */
+@Immutable
+data class MotionStyle(
+ val bounce: Float = 0.5f,
+ val speed: Float = 1f,
+ val press: Float = 1f,
+ val wobble: Float = 1f,
+ val stretch: Float = 1f,
+ val bloom: Float = 1f,
+) {
+ companion object {
+ val Normal = MotionStyle()
+ val Calm = MotionStyle(bounce = 0.2f, speed = 1.45f, press = 0.6f, wobble = 0f, stretch = 0.5f, bloom = 0.5f)
+ val Bouncy = MotionStyle(bounce = 0.75f, speed = 0.92f, press = 1.3f, wobble = 1.6f, stretch = 1.2f, bloom = 1.2f)
+ val Jelly = MotionStyle(bounce = 0.95f, speed = 0.82f, press = 1.6f, wobble = 2.2f, stretch = 1.5f, bloom = 1.5f)
+ val Presets = listOf(Calm, Normal, Bouncy, Jelly)
+ val Default = Bouncy
+ }
+}
+
+object MotionSettings {
+ private const val PREFS = "glass"
+
+ var style: MotionStyle by mutableStateOf(MotionStyle.Default)
+ private set
+
+ fun load(context: Context) {
+ val p = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
+ val d = MotionStyle.Default
+ style = MotionStyle(
+ bounce = p.getFloat("motion_bounce", d.bounce),
+ speed = p.getFloat("motion_speed", d.speed),
+ press = p.getFloat("motion_press", d.press),
+ wobble = p.getFloat("motion_wobble", d.wobble),
+ stretch = p.getFloat("motion_stretch", d.stretch),
+ bloom = p.getFloat("motion_bloom", d.bloom),
+ )
+ }
+
+ fun update(context: Context, s: MotionStyle) {
+ style = s
+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit()
+ .putFloat("motion_bounce", s.bounce)
+ .putFloat("motion_speed", s.speed)
+ .putFloat("motion_press", s.press)
+ .putFloat("motion_wobble", s.wobble)
+ .putFloat("motion_stretch", s.stretch)
+ .putFloat("motion_bloom", s.bloom)
+ .apply()
+ }
+
+ /** A designed damping ratio at the user's bounce: 1.6x calmer at 0, 0.4x springier at 1. */
+ fun damping(designed: Float): Float = (designed * (1f + (0.5f - style.bounce) * 1.2f)).coerceIn(0.12f, 0.98f)
+
+ fun stiffness(designed: Float): Float = designed * style.speed.coerceIn(0.4f, 2.5f)
+}
+
+/**
+ * The shared springs. Bounce belongs on draw-time properties (scale, translation, rotation), never on
+ * layout or alpha: a bouncing size re-runs the glass blur every overshoot frame, a bouncing alpha flickers.
+ */
+object GlassMotion {
+ /** Springs open: capsules, chevrons, thumbs. ~8 % overshoot. */
+ fun <T> morph(): SpringSpec<T> = spring(MotionSettings.damping(0.58f), MotionSettings.stiffness(420f))
+
+ /** Small things landing: icons, beads, toasts. */
+ fun <T> pop(): SpringSpec<T> = spring(MotionSettings.damping(0.45f), MotionSettings.stiffness(500f))
+
+ /** Alpha and layout. Never bounces. */
+ fun <T> settle(): SpringSpec<T> = spring(dampingRatio = 1f, stiffness = Spring.StiffnessMedium)
+
+ /** Finger down: lands in ~80 ms, barely overshoots. */
+ fun <T> pressIn(): SpringSpec<T> = spring(MotionSettings.damping(0.72f), MotionSettings.stiffness(900f))
+
+ /** Finger up: one small swing past rest. */
+ fun <T> pressOut(): SpringSpec<T> = spring(MotionSettings.damping(0.46f), MotionSettings.stiffness(420f))
+
+ /** Menus unfolding from their anchor: width first ... */
+ fun <T> unfold(): SpringSpec<T> = spring(MotionSettings.damping(0.68f), MotionSettings.stiffness(420f))
+
+ /** ... then the height a beat behind, like a drop of gel. */
+ fun <T> unfoldLag(): SpringSpec<T> = spring(MotionSettings.damping(0.6f), MotionSettings.stiffness(340f))
+
+ /** Folding away: fast and critically damped. Dismissals never bounce. */
+ fun <T> fold(): SpringSpec<T> = spring(dampingRatio = 1f, stiffness = MotionSettings.stiffness(900f))
+
+ /** Entrances of whole blocks: a soft rise with a little overshoot. */
+ fun <T> rise(): SpringSpec<T> = spring(MotionSettings.damping(0.62f), MotionSettings.stiffness(220f))
+
+ val PressedScale: Float get() = 1f - 0.06f * MotionSettings.style.press.coerceIn(0f, 2.5f)
+
+ /** A tap shorter than this still plays the whole press. */
+ const val MinPressMillis = 90L
+
+ /** A tapped back button waits this long so its press is seen first. */
+ const val BackTapDelayMillis = 280L
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt
new file mode 100644
index 0000000..a39d281
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt
@@ -0,0 +1,392 @@
+package com.chethan616.clearpdf.ui.glass
+
+import androidx.activity.compose.BackHandler
+import androidx.compose.animation.core.Animatable
+import androidx.compose.animation.core.AnimationVector1D
+import androidx.compose.foundation.background
+import androidx.compose.foundation.interaction.MutableInteractionSource
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxScope
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ColumnScope
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.imePadding
+import androidx.compose.foundation.layout.navigationBarsPadding
+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.layout.widthIn
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.text.BasicTextField
+import androidx.compose.foundation.text.KeyboardActions
+import androidx.compose.foundation.text.KeyboardOptions
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.geometry.Rect
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.CompositingStrategy
+import androidx.compose.ui.graphics.SolidColor
+import androidx.compose.ui.graphics.TransformOrigin
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.layout.Layout
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.text.input.PasswordVisualTransformation
+import androidx.compose.ui.text.input.VisualTransformation
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.Constraints
+import androidx.compose.ui.unit.IntOffset
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.util.lerp
+import com.chethan616.clearpdf.ui.theme.Candy
+import com.chethan616.clearpdf.ui.theme.ClearType
+import com.chethan616.clearpdf.ui.theme.clear
+import com.kyant.shapes.Capsule
+import com.kyant.shapes.RoundedRectangle
+import kotlin.math.roundToInt
+import kotlinx.coroutines.launch
+
+/** A 0 → 1 entrance on [spec], read in draw. */
+@Composable
+private fun rememberAppear(): Animatable<Float, AnimationVector1D> {
+ val a = remember { Animatable(0f) }
+ LaunchedEffect(Unit) { a.animateTo(1f, GlassMotion.morph()) }
+ return a
+}
+
+/** The dim behind a dialog or sheet; a tap on it dismisses. */
+@Composable
+private fun BoxScope.Scrim(appear: Animatable<Float, AnimationVector1D>, onDismiss: () -> Unit) {
+ val c = clear
+ Box(
+ Modifier.fillMaxSize()
+ .graphicsLayer { alpha = appear.value.coerceIn(0f, 1f) }
+ .background(Color.Black.copy(alpha = if (c.dark) 0.42f else 0.22f))
+ .clickable(remember { MutableInteractionSource() }, null, onClick = onDismiss),
+ )
+}
+
+/**
+ * A dialog: a frosted card that springs up from 82 %, an optional candy [icon] blob, a big title,
+ * then [content] and the buttons. [destructive] paints the confirm button tomato.
+ */
+@Composable
+fun GlassDialog(
+ onDismiss: () -> Unit,
+ title: String?,
+ confirm: String? = null,
+ onConfirm: () -> Unit = {},
+ dismiss: String? = null,
+ onDismissButton: (() -> Unit)? = null,
+ confirmEnabled: Boolean = true,
+ destructive: Boolean = false,
+ icon: ImageVector? = null,
+ accent: Color = Candy.Sky,
+ dismissible: Boolean = true,
+ content: @Composable ColumnScope.() -> Unit = {},
+) {
+ val c = clear
+ val tint = if (destructive) Candy.Tomato else accent
+ GlassOverlay {
+ BackHandler(enabled = dismissible, onBack = onDismiss)
+ val appear = rememberAppear()
+ Box(Modifier.fillMaxSize().imePadding(), contentAlignment = Alignment.Center) {
+ Scrim(appear) { if (dismissible) onDismiss() }
+ GlassCard(
+ Modifier
+ .padding(24.dp)
+ .widthIn(max = 380.dp)
+ .fillMaxWidth()
+ .graphicsLayer {
+ val s = lerp(0.82f, 1f, appear.value)
+ scaleX = s
+ scaleY = s
+ alpha = appear.value.coerceIn(0f, 1f)
+ compositingStrategy = CompositingStrategy.ModulateAlpha
+ }
+ .clickable(remember { MutableInteractionSource() }, null) {},
+ shape = RoundedRectangle(34.dp),
+ wash = c.frost,
+ blur = 16.dp,
+ ) {
+ Column(Modifier.padding(start = 22.dp, end = 22.dp, top = 22.dp, bottom = 18.dp)) {
+ if (icon != null) {
+ Box(Modifier.size(46.dp).clip(CircleShape).background(tint), contentAlignment = Alignment.Center) {
+ Icon(icon, null, tint = Color.White, modifier = Modifier.size(24.dp))
+ }
+ Spacer(Modifier.height(14.dp))
+ }
+ if (title != null) {
+ Text(title, style = ClearType.Headline, color = c.ink)
+ Spacer(Modifier.height(10.dp))
+ }
+ Column(Modifier.heightIn(max = 420.dp).verticalScroll(rememberScrollState())) { content() }
+ if (confirm != null || dismiss != null) {
+ Spacer(Modifier.height(20.dp))
+ Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.End)) {
+ if (dismiss != null) {
+ GlassPill(onClick = { (onDismissButton ?: onDismiss)() }, height = 46.dp) {
+ Text(dismiss, style = ClearType.BodyStrong, color = c.ink)
+ }
+ }
+ if (confirm != null) {
+ GlassPill(
+ onClick = { if (confirmEnabled) onConfirm() },
+ tint = if (confirmEnabled) tint else c.inkFaint,
+ height = 46.dp,
+ ) { Text(confirm, style = ClearType.BodyStrong, color = Color.White) }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+/**
+ * A sheet: a floating frosted card along the bottom, inset from the edges, that rises on a spring.
+ * [title] in the headline face, an optional [subtitle], then [content].
+ */
+@Composable
+fun GlassSheet(
+ onDismiss: () -> Unit,
+ title: String? = null,
+ subtitle: String? = null,
+ maxHeightFraction: Float = 0.86f,
+ content: @Composable ColumnScope.() -> Unit,
+) {
+ val c = clear
+ GlassOverlay {
+ BackHandler(onBack = onDismiss)
+ val appear = rememberAppear()
+ val density = LocalDensity.current
+ val overlayHeight = LocalGlassOverlayHost.current?.size?.height ?: 0
+ Box(Modifier.fillMaxSize().imePadding(), contentAlignment = Alignment.BottomCenter) {
+ Scrim(appear, onDismiss)
+ val maxH = with(density) { if (overlayHeight > 0) (overlayHeight * maxHeightFraction).toDp() else 640.dp }
+ GlassCard(
+ Modifier
+ .navigationBarsPadding()
+ .padding(horizontal = 10.dp, vertical = 10.dp)
+ .widthIn(max = 560.dp)
+ .fillMaxWidth()
+ .heightIn(max = maxH)
+ .graphicsLayer {
+ val p = appear.value
+ translationY = (1f - p) * 96.dp.toPx()
+ val s = lerp(0.94f, 1f, p)
+ scaleX = s
+ scaleY = s
+ transformOrigin = TransformOrigin(0.5f, 1f)
+ alpha = p.coerceIn(0f, 1f)
+ compositingStrategy = CompositingStrategy.ModulateAlpha
+ }
+ .clickable(remember { MutableInteractionSource() }, null) {},
+ shape = RoundedRectangle(32.dp),
+ wash = c.frost,
+ blur = 16.dp,
+ ) {
+ Box(Modifier.fillMaxWidth().padding(top = 10.dp), contentAlignment = Alignment.Center) {
+ Box(Modifier.size(36.dp, 5.dp).clip(Capsule).background(c.inkFaint.copy(alpha = 0.35f)))
+ }
+ if (title != null) {
+ Text(title, style = ClearType.Headline, color = c.ink, modifier = Modifier.padding(start = 22.dp, end = 22.dp, top = 14.dp))
+ if (subtitle != null) Text(subtitle, style = ClearType.Label, color = c.inkSoft, maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(start = 22.dp, end = 22.dp, top = 4.dp))
+ Spacer(Modifier.height(10.dp))
+ } else {
+ Spacer(Modifier.height(8.dp))
+ }
+ content()
+ Spacer(Modifier.height(12.dp))
+ }
+ }
+ }
+}
+
+/** A row of a sheet or menu: a candy icon blob, a label, an optional value. */
+@Composable
+fun GlassRow(
+ label: String,
+ onClick: () -> Unit,
+ modifier: Modifier = Modifier,
+ icon: ImageVector? = null,
+ accent: Color = Candy.Sky,
+ value: String? = null,
+ destructive: Boolean = false,
+ trailing: (@Composable () -> Unit)? = null,
+) {
+ val c = clear
+ Row(
+ modifier.fillMaxWidth().pressable(onClick).padding(horizontal = 18.dp, vertical = 9.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ if (icon != null) {
+ val blob = if (destructive) Candy.Tomato else accent
+ Box(Modifier.size(34.dp).clip(RoundedRectangle(11.dp)).background(blob.copy(alpha = if (c.dark) 0.26f else 0.16f)), contentAlignment = Alignment.Center) {
+ Icon(icon, null, tint = blob, modifier = Modifier.size(19.dp))
+ }
+ Spacer(Modifier.width(14.dp))
+ }
+ Text(label, style = ClearType.BodyStrong, color = if (destructive) Candy.Tomato else c.ink, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis)
+ if (value != null) Text(value, style = ClearType.Label, color = c.inkSoft, modifier = Modifier.padding(start = 8.dp))
+ trailing?.invoke()
+ }
+}
+
+/** An item of a [GlassMenu]. */
+data class GlassMenuItem(val label: String, val icon: ImageVector? = null, val destructive: Boolean = false, val onClick: () -> Unit)
+
+/**
+ * A popover menu anchored to [anchor] (window bounds of its trigger): unfolds from the trigger's
+ * corner, width first then height, and folds away on a tap outside or Back.
+ */
+@Composable
+fun GlassMenu(anchor: Rect, onDismiss: () -> Unit, items: List<GlassMenuItem>) {
+ val c = clear
+ GlassOverlay {
+ BackHandler(onBack = onDismiss)
+ val host = LocalGlassOverlayHost.current ?: return@GlassOverlay
+ val w = remember { Animatable(0f) }
+ val h = remember { Animatable(0f) }
+ LaunchedEffect(Unit) {
+ launch { w.animateTo(1f, GlassMotion.unfold()) }
+ launch { h.animateTo(1f, GlassMotion.unfoldLag()) }
+ }
+ Box(Modifier.fillMaxSize().clickable(remember { MutableInteractionSource() }, null, onClick = onDismiss))
+ val local = Rect(host.windowToLocal(anchor.topLeft), host.windowToLocal(anchor.bottomRight))
+ val margin = with(LocalDensity.current) { 12.dp.toPx() }
+ var fromRight by remember { mutableStateOf(true) }
+ var fromBelow by remember { mutableStateOf(true) }
+ Layout(
+ content = {
+ GlassCard(
+ Modifier
+ .width(236.dp)
+ .graphicsLayer {
+ scaleX = lerp(0.4f, 1f, w.value)
+ scaleY = lerp(0.2f, 1f, h.value)
+ transformOrigin = TransformOrigin(if (fromRight) 1f else 0f, if (fromBelow) 0f else 1f)
+ alpha = (h.value * 1.6f).coerceIn(0f, 1f)
+ compositingStrategy = CompositingStrategy.ModulateAlpha
+ },
+ shape = RoundedRectangle(24.dp),
+ wash = c.frost,
+ blur = 16.dp,
+ ) {
+ Spacer(Modifier.height(6.dp))
+ items.forEach { item ->
+ Row(
+ Modifier.fillMaxWidth().pressable({ onDismiss(); item.onClick() }).padding(horizontal = 16.dp, vertical = 11.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Text(item.label, style = ClearType.BodyStrong, color = if (item.destructive) Candy.Tomato else c.ink, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis)
+ if (item.icon != null) Icon(item.icon, null, tint = if (item.destructive) Candy.Tomato else c.inkSoft, modifier = Modifier.size(19.dp))
+ }
+ }
+ Spacer(Modifier.height(6.dp))
+ }
+ },
+ modifier = Modifier.fillMaxSize().statusBarsPadding().navigationBarsPadding(),
+ ) { measurables, constraints ->
+ val p = measurables.first().measure(Constraints(maxWidth = constraints.maxWidth, maxHeight = constraints.maxHeight))
+ layout(constraints.maxWidth, constraints.maxHeight) {
+ val right = local.center.x > constraints.maxWidth / 2f
+ fromRight = right
+ val x = if (right) (local.right - p.width) else local.left
+ val below = local.bottom + 6f + p.height < constraints.maxHeight - margin
+ fromBelow = below
+ val y = if (below) local.bottom + 6f else local.top - 6f - p.height
+ p.place(IntOffset(x.coerceIn(margin, constraints.maxWidth - p.width - margin).roundToInt(), y.coerceAtLeast(margin).roundToInt()))
+ }
+ }
+ }
+}
+
+/** A text field on glass: a rounded frosted well, a quiet [placeholder], the theme's ink. */
+@Composable
+fun GlassTextField(
+ value: String,
+ onValueChange: (String) -> Unit,
+ placeholder: String,
+ modifier: Modifier = Modifier,
+ password: Boolean = false,
+ error: Boolean = false,
+ focus: FocusRequester? = null,
+ keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
+ keyboardActions: KeyboardActions = KeyboardActions.Default,
+ singleLine: Boolean = true,
+) {
+ val c = clear
+ BasicTextField(
+ value = value,
+ onValueChange = onValueChange,
+ singleLine = singleLine,
+ textStyle = ClearType.Body.copy(color = c.ink),
+ cursorBrush = SolidColor(Candy.Sky),
+ visualTransformation = if (password) PasswordVisualTransformation() else VisualTransformation.None,
+ keyboardOptions = keyboardOptions,
+ keyboardActions = keyboardActions,
+ modifier = modifier.fillMaxWidth().then(if (focus != null) Modifier.focusRequester(focus) else Modifier),
+ decorationBox = { inner ->
+ Box(
+ Modifier.fillMaxWidth().clip(RoundedRectangle(16.dp))
+ .background(if (c.dark) Color.White.copy(alpha = 0.07f) else c.ink.copy(alpha = 0.05f))
+ .then(if (error) Modifier.background(Candy.Tomato.copy(alpha = 0.12f)) else Modifier)
+ .padding(horizontal = 16.dp, vertical = 14.dp),
+ ) {
+ if (value.isEmpty()) Text(placeholder, style = ClearType.Body, color = if (error) Candy.Tomato else c.inkFaint)
+ inner()
+ }
+ },
+ )
+}
+
+/** A toast: a glass capsule that pops in above the dock, with an optional candy action. */
+@Composable
+fun GlassToast(text: String, action: String?, onAction: () -> Unit, modifier: Modifier = Modifier) {
+ val c = clear
+ val appear = rememberAppear()
+ Row(
+ modifier
+ .graphicsLayer {
+ val p = appear.value
+ translationY = (1f - p) * 24.dp.toPx()
+ alpha = p.coerceIn(0f, 1f)
+ compositingStrategy = CompositingStrategy.ModulateAlpha
+ }
+ .widthIn(max = 520.dp)
+ .glass(Capsule, c.frost, blur = 12.dp)
+ .padding(start = 20.dp, end = if (action != null) 6.dp else 20.dp, top = 6.dp, bottom = 6.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Text(text, style = ClearType.Label, color = c.ink, modifier = Modifier.weight(1f, fill = false).padding(vertical = 8.dp), maxLines = 3)
+ if (action != null) {
+ Spacer(Modifier.width(10.dp))
+ GlassPill(onClick = onAction, tint = Candy.Sky, height = 38.dp, horizontalPadding = 14.dp) {
+ Text(action, style = ClearType.Label, color = Color.White)
+ }
+ }
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Press.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Press.kt
new file mode 100644
index 0000000..41154fd
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Press.kt
@@ -0,0 +1,490 @@
+package com.chethan616.clearpdf.ui.glass
+
+import android.graphics.RuntimeShader
+import android.graphics.Shader
+import android.os.Build
+import android.os.SystemClock
+import androidx.annotation.RequiresApi
+import androidx.compose.animation.core.Animatable
+import androidx.compose.animation.core.VectorConverter
+import androidx.compose.animation.core.VisibilityThreshold
+import androidx.compose.animation.core.spring
+import androidx.compose.foundation.MutatorMutex
+import androidx.compose.foundation.gestures.awaitEachGesture
+import androidx.compose.foundation.gestures.awaitFirstDown
+import androidx.compose.foundation.interaction.InteractionSource
+import androidx.compose.foundation.interaction.PressInteraction
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.Stable
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.runtime.snapshotFlow
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.drawWithContent
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.graphics.BlendMode
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.GraphicsLayerScope
+import androidx.compose.ui.graphics.ShaderBrush
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.graphics.toArgb
+import androidx.compose.ui.input.pointer.AwaitPointerEventScope
+import androidx.compose.ui.input.pointer.PointerEventPass
+import androidx.compose.ui.input.pointer.PointerId
+import androidx.compose.ui.input.pointer.PointerInputChange
+import androidx.compose.ui.input.pointer.PointerInputScope
+import androidx.compose.ui.input.pointer.changedToUpIgnoreConsumed
+import androidx.compose.ui.input.pointer.pointerInput
+import androidx.compose.ui.input.pointer.positionChange
+import androidx.compose.ui.input.pointer.util.VelocityTracker
+import androidx.compose.ui.unit.IntSize
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.util.fastCoerceAtMost
+import androidx.compose.ui.util.fastCoerceIn
+import androidx.compose.ui.util.fastFirstOrNull
+import androidx.compose.ui.util.lerp
+import kotlin.math.abs
+import kotlin.math.atan2
+import kotlin.math.cos
+import kotlin.math.sin
+import kotlin.math.tanh
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.android.awaitFrame
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.flow.filter
+import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.launch
+
+/** Watches a press and its drag without consuming them, so the control under it still gets the click. */
+suspend fun PointerInputScope.inspectDragGestures(
+ onDragStart: (down: PointerInputChange) -> Unit = {},
+ onDragEnd: (change: PointerInputChange) -> Unit = {},
+ onDragCancel: () -> Unit = {},
+ onDrag: (change: PointerInputChange, dragAmount: Offset) -> Unit,
+) {
+ awaitEachGesture {
+ val initialDown = awaitFirstDown(false, PointerEventPass.Initial)
+ val down = awaitFirstDown(false)
+ onDragStart(down)
+ onDrag(initialDown, Offset.Zero)
+ val up = drag(initialDown.id) { onDrag(it, it.positionChange()) }
+ if (up == null) onDragCancel() else onDragEnd(up)
+ }
+}
+
+private suspend inline fun AwaitPointerEventScope.drag(pointerId: PointerId, onDrag: (PointerInputChange) -> Unit): PointerInputChange? {
+ if (currentEvent.changes.fastFirstOrNull { it.id == pointerId }?.pressed != true) return null
+ var pointer = pointerId
+ while (true) {
+ val change = awaitDragOrUp(pointer) ?: return null
+ if (change.isConsumed) return null
+ if (change.changedToUpIgnoreConsumed()) return change
+ onDrag(change)
+ pointer = change.id
+ }
+}
+
+private suspend inline fun AwaitPointerEventScope.awaitDragOrUp(pointerId: PointerId): PointerInputChange? {
+ var pointer = pointerId
+ while (true) {
+ val event = awaitPointerEvent()
+ val change = event.changes.fastFirstOrNull { it.id == pointer } ?: return null
+ if (change.changedToUpIgnoreConsumed()) {
+ val other = event.changes.fastFirstOrNull { it.pressed } ?: return change
+ pointer = other.id
+ } else if (change.previousPosition != change.position) {
+ return change
+ }
+ }
+}
+
+// Initial velocities of the release jiggle: 34 peaks near 1, 10 near 0.3.
+private const val WobbleKick = 34f
+private const val PressKick = 10f
+
+/**
+ * The glass press: a swell under the finger, a lean toward a dragging finger, a one-swing jiggle on
+ * release, a light that follows the touch, and (with [longPressExpand]) a bloom after a long hold.
+ */
+class InteractiveHighlight(
+ val animationScope: CoroutineScope,
+ val position: (size: Size, offset: Offset) -> Offset = { _, offset -> offset },
+ private val longPressExpand: Boolean = false,
+ private val onLongPressExpand: (() -> Unit)? = null,
+) {
+ private val pressInSpec get() = spring(MotionSettings.damping(0.66f), MotionSettings.stiffness(620f), 0.001f)
+ private val pressOutSpec get() = spring(MotionSettings.damping(0.5f), MotionSettings.stiffness(380f), 0.001f)
+ private val positionSpec get() = spring(MotionSettings.damping(0.52f), MotionSettings.stiffness(360f), Offset.VisibilityThreshold)
+ private val wobbleSpec get() = spring(MotionSettings.damping(0.42f), MotionSettings.stiffness(420f), 0.001f)
+ private val expandInSpec get() = spring(MotionSettings.damping(0.52f), MotionSettings.stiffness(340f), 0.001f)
+ private val expandOutSpec get() = spring(MotionSettings.damping(0.46f), MotionSettings.stiffness(420f), 0.001f)
+ // The light never bounces: it rises with the finger and fades once it lifts, while the shape jiggles.
+ private val glowInSpec get() = spring(1f, MotionSettings.stiffness(900f), 0.001f)
+ private val glowOutSpec get() = spring(1f, MotionSettings.stiffness(380f), 0.001f)
+
+ private val pressAnim = Animatable(0f, 0.001f)
+ private val positionAnim = Animatable(Offset.Zero, Offset.VectorConverter, Offset.VisibilityThreshold)
+ private val expandAnim = Animatable(0f, 0.001f)
+ private val wobbleAnim = Animatable(0f, 0.001f)
+ private val glowAnim = Animatable(0f, 0.001f)
+ private val bloomGlowAnim = Animatable(0f, 0.001f)
+
+ private var startPosition = Offset.Zero
+ private var positionJob: Job? = null
+ private var longPressJob: Job? = null
+ private var releaseJob: Job? = null
+ private var downAt = 0L
+
+ val pressProgress: Float get() = pressAnim.value
+ val offset: Offset get() = positionAnim.value - startPosition
+ val expandProgress: Float get() = expandAnim.value
+ val wobble: Float get() = wobbleAnim.value
+
+ // Built on first press: RuntimeShader compiles on the calling thread, and most buttons are never pressed.
+ // Typed Shader so nothing names RuntimeShader below Android 13.
+ private val shader: Shader? by lazy(LazyThreadSafetyMode.NONE) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) PressGlow.create() else null
+ }
+
+ val modifier: Modifier = Modifier.drawWithContent {
+ val progress = glowAnim.value.fastCoerceIn(0f, 1f)
+ val bloom = bloomGlowAnim.value.fastCoerceIn(0f, 1f)
+ if (progress > 0f || bloom > 0f) {
+ val s = shader
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && s != null) {
+ drawRect(Color.White.copy(0.08f * progress + 0.05f * bloom), blendMode = BlendMode.Plus)
+ val p = position(size, positionAnim.value)
+ PressGlow.update(
+ s, size, Color.White.copy(0.15f * progress + 0.10f * bloom).toArgb(), size.minDimension * (1.5f + 0.5f * bloom),
+ Offset(p.x.fastCoerceIn(0f, size.width), p.y.fastCoerceIn(0f, size.height)),
+ )
+ drawRect(ShaderBrush(s), blendMode = BlendMode.Plus)
+ } else {
+ drawRect(Color.White.copy(0.25f * progress), blendMode = BlendMode.Plus)
+ }
+ }
+ drawContent()
+ }
+
+ @RequiresApi(Build.VERSION_CODES.TIRAMISU)
+ private object PressGlow {
+ fun create(): Shader = RuntimeShader(
+ """
+uniform float2 size;
+layout(color) uniform half4 color;
+uniform float radius;
+uniform float2 position;
+
+half4 main(float2 coord) {
+ float dist = distance(coord, position);
+ float intensity = smoothstep(radius, radius * 0.5, dist);
+ return color * intensity;
+}""",
+ )
+
+ fun update(shader: Shader, size: Size, color: Int, radius: Float, position: Offset) {
+ (shader as RuntimeShader).apply {
+ setFloatUniform("size", size.width, size.height)
+ setColorUniform("color", color)
+ setFloatUniform("radius", radius)
+ setFloatUniform("position", position.x, position.y)
+ }
+ }
+ }
+
+ private fun release() {
+ positionJob?.cancel()
+ longPressJob?.cancel()
+ releaseJob?.cancel()
+ releaseJob = animationScope.launch {
+ val held = SystemClock.uptimeMillis() - downAt
+ if (held < GlassMotion.MinPressMillis) delay(GlassMotion.MinPressMillis - held)
+ val kick = WobbleKick * MotionSettings.style.wobble.fastCoerceIn(0f, 3f) * pressAnim.value.fastCoerceIn(0f, 1.1f)
+ launch { wobbleAnim.animateTo(0f, wobbleSpec, initialVelocity = kick) }
+ launch { pressAnim.animateTo(0f, pressOutSpec) }
+ launch { glowAnim.animateTo(0f, glowOutSpec) }
+ launch { positionAnim.animateTo(startPosition, positionSpec) }
+ if (expandAnim.value != 0f || expandAnim.targetValue != 0f) {
+ launch { expandAnim.animateTo(0f, expandOutSpec) }
+ launch { bloomGlowAnim.animateTo(0f, glowOutSpec) }
+ }
+ }
+ }
+
+ val gestureModifier: Modifier = Modifier.pointerInput(animationScope) {
+ val longPressMs = viewConfiguration.longPressTimeoutMillis
+ val slop = viewConfiguration.touchSlop
+ inspectDragGestures(
+ onDragStart = { down ->
+ startPosition = down.position
+ downAt = SystemClock.uptimeMillis()
+ positionJob?.cancel()
+ longPressJob?.cancel()
+ releaseJob?.cancel()
+ animationScope.launch {
+ launch { pressAnim.animateTo(1f, pressInSpec) }
+ launch { glowAnim.animateTo(1f, glowInSpec) }
+ launch { positionAnim.snapTo(startPosition) }
+ launch { wobbleAnim.animateTo(0f, wobbleSpec, initialVelocity = -PressKick) }
+ }
+ if (longPressExpand) {
+ longPressJob = animationScope.launch {
+ delay(longPressMs)
+ onLongPressExpand?.invoke()
+ launch { bloomGlowAnim.animateTo(1f, glowInSpec) }
+ expandAnim.animateTo(1f, expandInSpec)
+ }
+ }
+ },
+ onDragEnd = { release() },
+ onDragCancel = { release() },
+ ) { change, _ ->
+ if (longPressJob?.isActive == true && expandAnim.targetValue == 0f && (change.position - startPosition).getDistance() > slop) {
+ longPressJob?.cancel()
+ }
+ positionJob?.cancel()
+ positionJob = animationScope.launch { positionAnim.snapTo(change.position) }
+ }
+ }
+}
+
+/**
+ * The glass press as a transform (from a drawBackdrop layerBlock): swells ~4 dp, leans toward a
+ * dragging finger, blooms on a long hold (≤ ~14 dp), and jiggles once on release, X and Y out of phase.
+ */
+fun GraphicsLayerScope.liquidPressTransform(h: InteractiveHighlight) {
+ val width = size.width
+ val height = size.height
+ if (!(width > 0f && height > 0f)) return
+ val motion = MotionSettings.style
+ val progress = h.pressProgress
+ val bloomAmount = motion.bloom.fastCoerceIn(0f, 2.5f)
+ val bloom = h.expandProgress * (14f.dp.toPx() * bloomAmount / size.maxDimension).fastCoerceAtMost(0.12f * bloomAmount)
+ val scale = lerp(1f, 1f + 4f.dp.toPx() * motion.press.fastCoerceIn(0f, 2.5f) / height, progress) + bloom
+ val maxOffset = size.minDimension
+ val stretch = motion.stretch.fastCoerceIn(0f, 2.5f)
+ val k = 0.05f * stretch
+ val offset = h.offset
+ translationX = maxOffset * tanh(k * offset.x / maxOffset)
+ translationY = maxOffset * tanh(k * offset.y / maxOffset)
+ val maxDragScale = 4f.dp.toPx() * stretch / height
+ val angle = atan2(offset.y, offset.x)
+ val w = h.wobble
+ val wobbleX = w * (2.5f.dp.toPx() / width).fastCoerceAtMost(0.045f)
+ val wobbleY = w * (2.5f.dp.toPx() / height).fastCoerceAtMost(0.045f)
+ scaleX = scale + maxDragScale * abs(cos(angle) * offset.x / size.maxDimension) * (width / height).fastCoerceAtMost(1f) + wobbleX
+ scaleY = scale + maxDragScale * abs(sin(angle) * offset.y / size.maxDimension) * (height / width).fastCoerceAtMost(1f) - wobbleY
+}
+
+/**
+ * The press jelly of flat pressables (rows, tiles, chips): dips on press, springs back past rest once,
+ * and holds a quick tap long enough to be seen. Read [scale] inside graphicsLayer.
+ */
+@Stable
+class JellyPress internal constructor(private val scope: CoroutineScope, private val pressedScale: Float) {
+ private val anim = Animatable(1f, 0.0005f)
+ private var downAt = 0L
+ private var releaseJob: Job? = null
+
+ val scale: Float get() = anim.value
+ /** 0 at rest, 1 fully pressed (past 1 on the overshoot). */
+ val progress: Float get() = ((1f - anim.value) / (1f - pressedScale)).fastCoerceIn(-0.5f, 1.5f)
+
+ fun press() {
+ releaseJob?.cancel()
+ downAt = SystemClock.uptimeMillis()
+ scope.launch { anim.animateTo(pressedScale, GlassMotion.pressIn()) }
+ }
+
+ fun release() {
+ releaseJob?.cancel()
+ releaseJob = scope.launch {
+ val held = SystemClock.uptimeMillis() - downAt
+ if (held < GlassMotion.MinPressMillis) delay(GlassMotion.MinPressMillis - held)
+ anim.animateTo(1f, GlassMotion.pressOut())
+ }
+ }
+}
+
+@Composable
+fun rememberJellyPress(interaction: InteractionSource, pressedScale: Float = GlassMotion.PressedScale): JellyPress {
+ val scope = rememberCoroutineScope()
+ val jelly = remember(scope, pressedScale) { JellyPress(scope, pressedScale) }
+ LaunchedEffect(interaction, jelly) {
+ interaction.interactions.collect { i ->
+ when (i) {
+ is PressInteraction.Press -> jelly.press()
+ is PressInteraction.Release, is PressInteraction.Cancel -> jelly.release()
+ }
+ }
+ }
+ return jelly
+}
+
+/**
+ * Velocity squash-and-stretch, after LiquidTracker in AndroidLiquidGlassView by Donny Yale (QmDeve,
+ * MIT): stretches along the direction of travel and squashes across it, then relaxes.
+ */
+@Stable
+class LiquidStretchState internal constructor(
+ private val scope: CoroutineScope,
+ private val stretchFactor: Float,
+ private val minScale: Float,
+ private val maxScale: Float,
+ private val settleDelayMs: Long,
+) {
+ private val spec = spring<Float>(dampingRatio = 0.35f, stiffness = 180f, visibilityThreshold = 0.0005f)
+ private val sx = Animatable(1f, 0.0005f)
+ private val sy = Animatable(1f, 0.0005f)
+ private var lastX = Float.NaN
+ private var lastY = 0f
+ private var lastT = 0L
+ private var settleJob: Job? = null
+
+ val scaleX: Float get() = sx.value
+ val scaleY: Float get() = sy.value
+
+ fun onPositionSample(x: Float, y: Float = 0f) {
+ val t = SystemClock.uptimeMillis()
+ if (lastX.isNaN()) {
+ lastX = x; lastY = y; lastT = t
+ return
+ }
+ val dt = t - lastT
+ if (dt <= 0L) return
+ if (dt > 100L) {
+ lastX = x; lastY = y; lastT = t
+ return
+ }
+ onVelocity((x - lastX) / dt, (y - lastY) / dt)
+ lastX = x; lastY = y; lastT = t
+ }
+
+ fun onVelocity(vx: Float, vy: Float) {
+ val ax = abs(vx)
+ val ay = abs(vy)
+ val (tx, ty) = if (ax >= ay) (1f + ax * stretchFactor) to (1f - ax * stretchFactor * 0.5f)
+ else (1f - ay * stretchFactor * 0.5f) to (1f + ay * stretchFactor)
+ animateTo(tx.coerceIn(minScale, maxScale), ty.coerceIn(minScale, maxScale))
+ settleJob?.cancel()
+ settleJob = scope.launch {
+ delay(settleDelayMs)
+ settle()
+ }
+ }
+
+ fun settle() {
+ lastX = Float.NaN
+ animateTo(1f, 1f)
+ }
+
+ private fun animateTo(x: Float, y: Float) {
+ scope.launch { sx.animateTo(x, spec) }
+ scope.launch { sy.animateTo(y, spec) }
+ }
+}
+
+@Composable
+fun rememberLiquidStretchState(stretchFactor: Float = 0.5f, minScale: Float = 0.6f, maxScale: Float = 1.4f, settleDelayMs: Long = 200L): LiquidStretchState {
+ val scope = rememberCoroutineScope()
+ return remember(scope, stretchFactor, minScale, maxScale, settleDelayMs) { LiquidStretchState(scope, stretchFactor, minScale, maxScale, settleDelayMs) }
+}
+
+fun Modifier.liquidStretch(state: LiquidStretchState): Modifier = graphicsLayer {
+ scaleX = state.scaleX
+ scaleY = state.scaleY
+}
+
+/**
+ * A value a finger drags (a thumb, a tab blob): it follows on a stiff spring, the thumb swells while
+ * held, and its velocity is tracked so it can stretch along its travel.
+ */
+class DampedDragAnimation(
+ private val animationScope: CoroutineScope,
+ initialValue: Float,
+ val valueRange: ClosedRange<Float>,
+ private val visibilityThreshold: Float,
+ private val initialScale: Float,
+ private val pressedScale: Float,
+ val onDragStarted: DampedDragAnimation.(position: Offset) -> Unit,
+ val onDragStopped: DampedDragAnimation.() -> Unit,
+ val onDrag: DampedDragAnimation.(size: IntSize, dragAmount: Offset) -> Unit,
+) {
+ private val valueSpec = spring(1f, 1000f, visibilityThreshold)
+ private val velocitySpec get() = spring(MotionSettings.damping(0.5f), MotionSettings.stiffness(300f), visibilityThreshold * 10f)
+ private val pressSpec = spring(1f, 1000f, 0.001f)
+ private val scaleXSpec get() = spring(MotionSettings.damping(0.6f), MotionSettings.stiffness(250f), 0.001f)
+ private val scaleYSpec get() = spring(MotionSettings.damping(0.7f), MotionSettings.stiffness(250f), 0.001f)
+
+ private val valueAnim = Animatable(initialValue, visibilityThreshold)
+ private val velocityAnim = Animatable(0f, 5f)
+ private val pressAnim = Animatable(0f, 0.001f)
+ private val scaleXAnim = Animatable(initialScale, 0.001f)
+ private val scaleYAnim = Animatable(initialScale, 0.001f)
+ private val mutex = MutatorMutex()
+ private val tracker = VelocityTracker()
+
+ val value: Float get() = valueAnim.value
+ val progress: Float get() = (value - valueRange.start) / (valueRange.endInclusive - valueRange.start)
+ val targetValue: Float get() = valueAnim.targetValue
+ val pressProgress: Float get() = pressAnim.value
+ val scaleX: Float get() = scaleXAnim.value
+ val scaleY: Float get() = scaleYAnim.value
+ val velocity: Float get() = velocityAnim.value
+
+ val modifier: Modifier = Modifier.pointerInput(Unit) {
+ inspectDragGestures(
+ onDragStart = { down -> onDragStarted(down.position); press() },
+ onDragEnd = { onDragStopped(); release() },
+ onDragCancel = { onDragStopped(); release() },
+ ) { _, dragAmount -> onDrag(size, dragAmount) }
+ }
+
+ fun press() {
+ tracker.resetTracking()
+ animationScope.launch {
+ launch { pressAnim.animateTo(1f, pressSpec) }
+ launch { scaleXAnim.animateTo(pressedScale, scaleXSpec) }
+ launch { scaleYAnim.animateTo(pressedScale, scaleYSpec) }
+ }
+ }
+
+ fun release() {
+ animationScope.launch {
+ awaitFrame()
+ if (value != targetValue) {
+ val threshold = (valueRange.endInclusive - valueRange.start) * 0.025f
+ snapshotFlow { valueAnim.value }.filter { abs(it - valueAnim.targetValue) < threshold }.first()
+ }
+ launch { pressAnim.animateTo(0f, pressSpec) }
+ launch { scaleXAnim.animateTo(initialScale, scaleXSpec) }
+ launch { scaleYAnim.animateTo(initialScale, scaleYSpec) }
+ }
+ }
+
+ fun updateValue(value: Float) {
+ val target = value.coerceIn(valueRange)
+ animationScope.launch { valueAnim.animateTo(target, valueSpec) { updateVelocity() } }
+ }
+
+ fun animateToValue(value: Float) {
+ animationScope.launch {
+ mutex.mutate {
+ press()
+ val target = value.coerceIn(valueRange)
+ launch { valueAnim.animateTo(target, valueSpec) }
+ if (velocity != 0f) launch { velocityAnim.animateTo(0f, velocitySpec) }
+ release()
+ }
+ }
+ }
+
+ private fun updateVelocity() {
+ tracker.addPosition(System.currentTimeMillis(), Offset(value, 0f))
+ val v = tracker.calculateVelocity().x / (valueRange.endInclusive - valueRange.start)
+ animationScope.launch { velocityAnim.animateTo(v, velocitySpec) }
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Style.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Style.kt
new file mode 100644
index 0000000..8187627
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Style.kt
@@ -0,0 +1,114 @@
+package com.chethan616.clearpdf.ui.glass
+
+import android.content.Context
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.graphics.Color
+import com.kyant.backdrop.BackdropEffectScope
+import com.kyant.backdrop.effects.blur
+import com.kyant.backdrop.effects.colorControls
+import com.kyant.backdrop.effects.lens
+import com.kyant.backdrop.effects.vibrancy
+import com.kyant.backdrop.highlight.Highlight
+
+/**
+ * The user's glass tuning. Each value multiplies a component's designed value (saturation and
+ * brightness are absolute), so a sheet keeps its heavier frost relative to a button. 1 = the design.
+ */
+@Immutable
+data class GlassStyle(
+ val blur: Float = 1f,
+ val refractionHeight: Float = 1f,
+ val refractionAmount: Float = 1f,
+ val depthEffect: Boolean = false,
+ val chromaticAberration: Boolean = false,
+ val saturation: Float = 1.5f,
+ val brightness: Float = 0f,
+ val tint: Float = 1f,
+ val highlight: Float = 1f,
+) {
+ companion object {
+ val Default = GlassStyle()
+ /** Heavier frost and wash: text stays legible over busy pages. */
+ val Frosted = GlassStyle(blur = 2.4f, tint = 1.8f, refractionAmount = 0.7f, saturation = 1.3f)
+ /** Clear, strongly bent glass with a prismatic rim. */
+ val Crystal = GlassStyle(blur = 0.3f, refractionHeight = 1.5f, refractionAmount = 1.6f, depthEffect = true, chromaticAberration = true, tint = 0.6f, saturation = 1.7f)
+ /** No blur or lens at all, for slower phones. */
+ val Lite = GlassStyle(blur = 0f, refractionHeight = 0f, refractionAmount = 0f, tint = 1.4f)
+ val Presets = listOf(Default, Frosted, Crystal, Lite)
+ }
+}
+
+object GlassSettings {
+ private const val PREFS = "glass"
+
+ var style: GlassStyle by mutableStateOf(GlassStyle.Default)
+ var haptics: Boolean by mutableStateOf(true)
+
+ fun load(context: Context) {
+ val p = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
+ val d = GlassStyle.Default
+ style = GlassStyle(
+ blur = p.getFloat("blur", d.blur),
+ refractionHeight = p.getFloat("refractionHeight", d.refractionHeight),
+ refractionAmount = p.getFloat("refractionAmount", d.refractionAmount),
+ depthEffect = p.getBoolean("depthEffect", d.depthEffect),
+ chromaticAberration = p.getBoolean("chromaticAberration", d.chromaticAberration),
+ saturation = p.getFloat("saturation", d.saturation),
+ brightness = p.getFloat("brightness", d.brightness),
+ tint = p.getFloat("tint", d.tint),
+ highlight = p.getFloat("highlight", d.highlight),
+ )
+ haptics = p.getBoolean("haptics", true)
+ MotionSettings.load(context)
+ }
+
+ fun update(context: Context, s: GlassStyle) {
+ style = s
+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit()
+ .putFloat("blur", s.blur)
+ .putFloat("refractionHeight", s.refractionHeight)
+ .putFloat("refractionAmount", s.refractionAmount)
+ .putBoolean("depthEffect", s.depthEffect)
+ .putBoolean("chromaticAberration", s.chromaticAberration)
+ .putFloat("saturation", s.saturation)
+ .putFloat("brightness", s.brightness)
+ .putFloat("tint", s.tint)
+ .putFloat("highlight", s.highlight)
+ .apply()
+ }
+
+ fun updateHaptics(context: Context, on: Boolean) {
+ haptics = on
+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean("haptics", on).apply()
+ }
+}
+
+/** The one effect stack every glass surface uses: colour (vibrancy), frost, then the lens. Pass designed px. */
+fun BackdropEffectScope.glassEffects(
+ style: GlassStyle,
+ blurPx: Float,
+ refractionHeightPx: Float,
+ refractionAmountPx: Float,
+ depthEffect: Boolean = false,
+) {
+ if (style.saturation == 1.5f && style.brightness == 0f) vibrancy()
+ else colorControls(brightness = style.brightness, saturation = style.saturation)
+ blur(blurPx * style.blur)
+ lens(
+ refractionHeightPx * style.refractionHeight,
+ refractionAmountPx * style.refractionAmount,
+ depthEffect = depthEffect || style.depthEffect,
+ chromaticAberration = style.chromaticAberration,
+ )
+}
+
+/** A surface wash at the user's tint. */
+fun Color.glassTint(style: GlassStyle): Color =
+ if (style.tint == 1f) this else copy(alpha = (alpha * style.tint).coerceIn(0f, 1f))
+
+/** The specular rim at the user's strength. */
+fun glassHighlight(style: GlassStyle, base: Highlight = Highlight.Default): Highlight? =
+ if (style.highlight <= 0f) null else base.copy(alpha = style.highlight.coerceIn(0f, 1f))
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Surfaces.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Surfaces.kt
new file mode 100644
index 0000000..31272de
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Surfaces.kt
@@ -0,0 +1,145 @@
+package com.chethan616.clearpdf.ui.glass
+
+import androidx.compose.foundation.ExperimentalFoundationApi
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.combinedClickable
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.foundation.interaction.MutableInteractionSource
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ColumnScope
+import androidx.compose.material3.Icon
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.remember
+import com.kyant.backdrop.backdrops.layerBackdrop
+import com.kyant.backdrop.backdrops.rememberCombinedBackdrop
+import com.kyant.backdrop.backdrops.rememberLayerBackdrop
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.Shape
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.graphics.isSpecified
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.hapticfeedback.HapticFeedbackType
+import androidx.compose.ui.platform.LocalHapticFeedback
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.dp
+import com.chethan616.clearpdf.ui.theme.clear
+import com.kyant.backdrop.drawBackdrop
+import com.kyant.shapes.RoundedRectangle
+
+/**
+ * A still glass surface (bars, the dock's body, panels, sheets): refracts [LocalBackdrop] through
+ * [shape], washed with [wash]. No shadow, ever.
+ */
+@Composable
+fun Modifier.glass(
+ shape: Shape,
+ wash: Color = clear.glass,
+ blur: Dp = 8.dp,
+ lensHeight: Dp = 16.dp,
+ lensAmount: Dp = 24.dp,
+): Modifier {
+ val backdrop = LocalBackdrop.current
+ val style = GlassSettings.style
+ return drawBackdrop(
+ backdrop = backdrop,
+ shape = { shape },
+ shadow = null,
+ effects = { glassEffects(style, blur.toPx(), lensHeight.toPx(), lensAmount.toPx()) },
+ highlight = { glassHighlight(style) },
+ onDrawSurface = { if (wash.isSpecified) drawRect(wash.glassTint(style)) },
+ )
+}
+
+/**
+ * A glass card whose children refract the card itself: its surface is a sibling layer under [content],
+ * so a glass button inside reads as part of the same frosted sheet, not a hole punched through it.
+ */
+@Composable
+fun GlassCard(
+ modifier: Modifier = Modifier,
+ shape: Shape = RoundedRectangle(28.dp),
+ wash: Color = clear.glass,
+ blur: Dp = 8.dp,
+ content: @Composable ColumnScope.() -> Unit,
+) {
+ val below = LocalBackdrop.current
+ val layer = rememberLayerBackdrop()
+ val combined = rememberCombinedBackdrop(below, layer)
+ Box(modifier) {
+ Box(Modifier.matchParentSize().layerBackdrop(layer).glass(shape, wash, blur))
+ CompositionLocalProvider(LocalBackdrop provides combined) { Column(content = content) }
+ }
+}
+
+/**
+ * The wash panel scrolling lists use: the glass's tint and its lit rim without the backdrop pass.
+ * Over the aurora's soft gradients a blur changes almost nothing, but re-sampling every panel on
+ * every scrolled frame costs a lot; floating chrome keeps the real glass.
+ */
+@Composable
+fun Modifier.wash(shape: Shape = RoundedRectangle(28.dp), tint: Color = clear.glass): Modifier {
+ val dark = clear.dark
+ val rimTop = Color.White.copy(alpha = if (dark) 0.16f else 0.70f)
+ val rimBottom = Color.White.copy(alpha = if (dark) 0.03f else 0.18f)
+ return clip(shape)
+ .background(tint.glassTint(GlassSettings.style))
+ .border(1.dp, Brush.verticalGradient(listOf(rimTop, rimBottom)), shape)
+}
+
+/** A [wash] panel holding rows. */
+@Composable
+fun WashPanel(modifier: Modifier = Modifier, shape: Shape = RoundedRectangle(28.dp), content: @Composable ColumnScope.() -> Unit) {
+ Column(modifier.wash(shape), content = content)
+}
+
+/** A glass panel holding rows: 28 dp continuous corners. */
+@Composable
+fun GlassPanel(modifier: Modifier = Modifier, shape: Shape = RoundedRectangle(28.dp), wash: Color = clear.glass, content: @Composable ColumnScope.() -> Unit) {
+ Column(modifier.glass(shape, wash), content = content)
+}
+
+/**
+ * A flat pressable (a row, a tile, a card): dips on press with the jelly spring, springs back past
+ * rest once, one haptic per tap. No ripple.
+ */
+@OptIn(ExperimentalFoundationApi::class)
+@Composable
+fun Modifier.pressable(
+ onClick: () -> Unit,
+ onLongClick: (() -> Unit)? = null,
+ pressedScale: Float = GlassMotion.PressedScale,
+ role: Role = Role.Button,
+ enabled: Boolean = true,
+): Modifier {
+ val source = remember { MutableInteractionSource() }
+ val jelly = rememberJellyPress(source, pressedScale)
+ val haptics = LocalHapticFeedback.current
+ return graphicsLayer {
+ scaleX = jelly.scale
+ scaleY = jelly.scale
+ }.combinedClickable(
+ interactionSource = source,
+ indication = null,
+ enabled = enabled,
+ role = role,
+ onClick = { haptics.performHapticFeedback(HapticFeedbackType.ContextClick); onClick() },
+ onLongClick = onLongClick?.let { l -> { haptics.performHapticFeedback(HapticFeedbackType.LongPress); l() } },
+ )
+}
+
+/** An icon in the ink of the glass it sits on. */
+@Composable
+fun GlassIcon(icon: ImageVector, contentDescription: String?, modifier: Modifier = Modifier, tint: Color = Color.Unspecified) {
+ val ink = when {
+ tint.isSpecified -> tint
+ LocalGlassInk.current.isSpecified -> LocalGlassInk.current
+ else -> clear.ink
+ }
+ Icon(icon, contentDescription, modifier, tint = ink)
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Tabs.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Tabs.kt
new file mode 100644
index 0000000..bd8768a
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Tabs.kt
@@ -0,0 +1,262 @@
+package com.chethan616.clearpdf.ui.glass
+
+import androidx.compose.animation.animateColorAsState
+import androidx.compose.animation.core.Animatable
+import androidx.compose.animation.core.EaseOut
+import androidx.compose.animation.core.spring
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.interaction.MutableInteractionSource
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxWithConstraints
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.RowScope
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxHeight
+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.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.derivedStateOf
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.runtime.rememberUpdatedState
+import androidx.compose.runtime.setValue
+import androidx.compose.runtime.snapshotFlow
+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.graphics.vector.ImageVector
+import androidx.compose.ui.hapticfeedback.HapticFeedbackType
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalHapticFeedback
+import androidx.compose.ui.platform.LocalLayoutDirection
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.semantics.clearAndSetSemantics
+import androidx.compose.ui.semantics.contentDescription
+import androidx.compose.ui.semantics.role
+import androidx.compose.ui.semantics.selected
+import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.LayoutDirection
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.util.fastCoerceIn
+import androidx.compose.ui.util.fastRoundToInt
+import androidx.compose.ui.util.lerp
+import com.chethan616.clearpdf.ui.theme.ClearType
+import com.chethan616.clearpdf.ui.theme.clear
+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
+import com.kyant.backdrop.effects.vibrancy
+import com.kyant.backdrop.highlight.Highlight
+import com.kyant.backdrop.shadow.InnerShadow
+import com.kyant.shapes.Capsule
+import kotlin.math.abs
+import kotlin.math.sign
+import kotlinx.coroutines.flow.collectLatest
+import kotlinx.coroutines.launch
+
+/** One choice of [GlassTabs]: an icon, a label, or both, and the candy it lights up in. */
+data class GlassTab(val label: String, val icon: ImageVector? = null, val accent: Color)
+
+/**
+ * A glass capsule of choices with a jelly blob over the chosen one. Drag the blob or tap a choice;
+ * the blob is a lens, and under it the choices are drawn in the chosen tab's candy. The dock and the
+ * segmented controls are both this.
+ */
+@Composable
+fun GlassTabs(
+ tabs: List<GlassTab>,
+ selected: Int,
+ onSelect: (Int) -> Unit,
+ modifier: Modifier = Modifier,
+ height: Dp = 64.dp,
+ textStyle: TextStyle = ClearType.Label,
+) {
+ val c = clear
+ val backdrop = LocalBackdrop.current
+ val haptics = LocalHapticFeedback.current
+ val count = tabs.size
+ val container = c.glass
+ val inner = (height - 8.dp).coerceAtLeast(0.dp)
+ val accent by animateColorAsState(tabs.getOrNull(selected)?.accent ?: c.ink, GlassMotion.settle(), label = "tab accent")
+ val tabsLayer = rememberLayerBackdrop()
+ val select by rememberUpdatedState(onSelect)
+ val selectedNow by rememberUpdatedState(selected)
+
+ BoxWithConstraints(modifier, contentAlignment = Alignment.CenterStart) {
+ val density = LocalDensity.current
+ val tabWidth = with(density) { (constraints.maxWidth.toFloat() - 8f.dp.toPx()) / count }
+ val offsetAnim = remember { Animatable(0f) }
+ val panelOffset by remember(density) {
+ derivedStateOf {
+ val f = (offsetAnim.value / constraints.maxWidth).fastCoerceIn(-1f, 1f)
+ with(density) { 4f.dp.toPx() * f.sign * EaseOut.transform(abs(f)) }
+ }
+ }
+ val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
+ val scope = rememberCoroutineScope()
+ var current by remember { mutableIntStateOf(selected) }
+ val drag = remember(scope, count) {
+ DampedDragAnimation(
+ scope, selected.toFloat(), 0f..(count - 1).toFloat(), 0.001f, 1f, 78f / 56f,
+ onDragStarted = {},
+ onDragStopped = {
+ val target = targetValue.fastRoundToInt().fastCoerceIn(0, count - 1)
+ current = target
+ animateToValue(target.toFloat())
+ scope.launch { offsetAnim.animateTo(0f, spring(1f, 300f, 0.5f)) }
+ },
+ onDrag = { _, d ->
+ updateValue((targetValue + d.x / tabWidth * if (isLtr) 1f else -1f).fastCoerceIn(0f, (count - 1).toFloat()))
+ scope.launch { offsetAnim.snapTo(offsetAnim.value + d.x) }
+ },
+ )
+ }
+ // follow the caller from the first frame (the bar may be rebuilt mid-change), report only our own changes
+ LaunchedEffect(selected) { current = selected }
+ LaunchedEffect(drag) {
+ snapshotFlow { current }.collectLatest { i ->
+ if (drag.targetValue.fastRoundToInt() != i) drag.animateToValue(i.toFloat())
+ if (i != selectedNow) {
+ haptics.performHapticFeedback(HapticFeedbackType.SegmentTick)
+ select(i)
+ }
+ }
+ }
+ val highlight = remember(scope) {
+ InteractiveHighlight(scope, position = { size, _ ->
+ Offset(
+ if (isLtr) (drag.value + 0.5f) * tabWidth + panelOffset else size.width - (drag.value + 0.5f) * tabWidth + panelOffset,
+ size.height / 2f,
+ )
+ })
+ }
+ val pressScale = { lerp(1f, 1.18f, drag.pressProgress) }
+
+ @Composable
+ fun RowScope.Cells(tinted: Boolean) {
+ tabs.forEachIndexed { i, t ->
+ Column(
+ Modifier.weight(1f).fillMaxHeight()
+ .then(if (tinted) Modifier else Modifier.clickable(remember { MutableInteractionSource() }, null, role = Role.Tab) { current = i })
+ .semantics { if (!tinted) { this.selected = i == current; contentDescription = t.label; role = Role.Tab } }
+ .graphicsLayer { val s = pressScale(); scaleX = s; scaleY = s },
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.Center,
+ ) {
+ val ink = c.ink
+ if (t.icon != null) Icon(t.icon, null, tint = ink, modifier = Modifier.size(if (t.label.isEmpty()) 24.dp else 22.dp))
+ if (t.icon != null && t.label.isNotEmpty()) Spacer(Modifier.height(3.dp))
+ if (t.label.isNotEmpty()) Text(t.label, style = textStyle, color = ink, maxLines = 1, overflow = TextOverflow.Ellipsis)
+ }
+ }
+ }
+
+ Row(
+ Modifier
+ .graphicsLayer { translationX = panelOffset }
+ .drawBackdrop(
+ backdrop = backdrop,
+ shape = { Capsule },
+ shadow = null,
+ effects = { glassEffects(GlassSettings.style, 4f.dp.toPx(), 24f.dp.toPx(), 24f.dp.toPx()) },
+ highlight = { glassHighlight(GlassSettings.style) },
+ layerBlock = {
+ val s = if (size.width <= 0f) 1f else lerp(1f, 1f + 16f.dp.toPx() / size.width, drag.pressProgress)
+ scaleX = s
+ scaleY = s
+ },
+ onDrawSurface = { drawRect(container.glassTint(GlassSettings.style)) },
+ )
+ .then(highlight.modifier)
+ .height(height)
+ .fillMaxWidth()
+ .padding(4.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) { Cells(tinted = false) }
+
+ // the same choices in the chosen candy, recorded (not shown) for the blob's lens to reveal
+ Row(
+ Modifier
+ .clearAndSetSemantics {}
+ .alpha(0f)
+ .layerBackdrop(tabsLayer)
+ .graphicsLayer { translationX = panelOffset }
+ .drawBackdrop(
+ backdrop = backdrop,
+ shape = { Capsule },
+ shadow = null,
+ effects = {
+ val p = drag.pressProgress
+ vibrancy()
+ blur(8f.dp.toPx())
+ lens(24f.dp.toPx() * p, 24f.dp.toPx() * p)
+ },
+ highlight = { Highlight.Default.copy(alpha = drag.pressProgress) },
+ onDrawSurface = { drawRect(container) },
+ )
+ .height(inner)
+ .fillMaxWidth()
+ .padding(horizontal = 4.dp)
+ .graphicsLayer(colorFilter = ColorFilter.tint(accent)),
+ verticalAlignment = Alignment.CenterVertically,
+ ) { Cells(tinted = true) }
+
+ Box(
+ Modifier
+ .padding(horizontal = 4.dp)
+ .graphicsLayer {
+ translationX = if (isLtr) drag.value * tabWidth + panelOffset else size.width - (drag.value + 1f) * tabWidth + panelOffset
+ }
+ .then(highlight.gestureModifier)
+ .then(drag.modifier)
+ .drawBackdrop(
+ backdrop = rememberCombinedBackdrop(backdrop, tabsLayer),
+ shape = { Capsule },
+ effects = {
+ val p = drag.pressProgress
+ lens(10f.dp.toPx() * p, 14f.dp.toPx() * p, chromaticAberration = true)
+ },
+ highlight = { Highlight.Default.copy(alpha = drag.pressProgress) },
+ shadow = null,
+ innerShadow = {
+ val p = drag.pressProgress
+ InnerShadow(radius = 8f.dp * p, alpha = p)
+ },
+ layerBlock = {
+ scaleX = drag.scaleX
+ scaleY = drag.scaleY
+ val v = drag.velocity / 10f
+ scaleX /= 1f - (v * 0.75f).fastCoerceIn(-0.2f, 0.2f)
+ scaleY *= 1f - (v * 0.25f).fastCoerceIn(-0.2f, 0.2f)
+ },
+ onDrawSurface = {
+ val p = drag.pressProgress
+ drawRect(if (c.dark) Color.White.copy(0.08f) else Color.White.copy(0.14f), alpha = 1f - p)
+ drawRect(accent.copy(alpha = if (c.dark) 0.20f else 0.12f), alpha = 1f - p)
+ drawRect(Color.White.copy(alpha = 0.04f * p))
+ },
+ )
+ .height(inner)
+ .fillMaxWidth(1f / count),
+ )
+ }
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/home/HomeModel.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/home/HomeModel.kt
new file mode 100644
index 0000000..29bbc0c
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/home/HomeModel.kt
@@ -0,0 +1,59 @@
+package com.chethan616.clearpdf.ui.home
+
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.text
+import java.text.DateFormat
+import java.util.Calendar
+import java.util.Date
+
+/** The places the dock goes. */
+enum class HomeTab { Home, Files, Tools }
+
+/** A file as the lists show it, wherever it comes from (recent, starred, on this device). */
+data class FileRow(
+ val key: String,
+ val name: String,
+ /** A local path to draw its thumbnail from, if there is one. */
+ val thumbPath: String?,
+ val location: String,
+ val date: Long,
+ val size: Long,
+ val starred: Boolean,
+ val open: () -> Unit,
+)
+
+/** A tool that starts by choosing a PDF. */
+enum class FileTool { Edit, ReadAloud, FillSign, Organize, Compress, Export, Protect, Comment, Crop, Ocr }
+
+/** "Just now", the time if today, "Yesterday", else a medium date. */
+fun whenLabel(t: Long): String {
+ val now = System.currentTimeMillis()
+ if (now - t < 60_000) return text(R.string.home_just_now)
+ val cal = Calendar.getInstance().apply { timeInMillis = t }
+ val today = Calendar.getInstance()
+ val sameDay = cal.get(Calendar.YEAR) == today.get(Calendar.YEAR) && cal.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)
+ if (sameDay) return DateFormat.getTimeInstance(DateFormat.SHORT).format(Date(t))
+ today.add(Calendar.DAY_OF_YEAR, -1)
+ if (cal.get(Calendar.YEAR) == today.get(Calendar.YEAR) && cal.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)) return text(R.string.common_yesterday)
+ return DateFormat.getDateInstance(DateFormat.MEDIUM).format(Date(t))
+}
+
+/** Which day bucket [t] falls in: 0 today, 1 yesterday, 2 this week, 3 earlier. */
+fun dayBucket(t: Long): Int {
+ val day = Calendar.getInstance().apply {
+ set(Calendar.HOUR_OF_DAY, 0); set(Calendar.MINUTE, 0); set(Calendar.SECOND, 0); set(Calendar.MILLISECOND, 0)
+ }.timeInMillis
+ return when {
+ t >= day -> 0
+ t >= day - 86_400_000L -> 1
+ t >= day - 6 * 86_400_000L -> 2
+ else -> 3
+ }
+}
+
+/**
+ * A file's name as the screens show it: no ".pdf", underscores as spaces, and a break allowed after
+ * each hyphen, so "report_2026-09-22.pdf" wraps between words instead of inside a number.
+ */
+fun displayName(name: String): String =
+ name.removeSuffix(".pdf").removeSuffix(".PDF").replace('_', ' ').replace("-", "-\u200B")
diff --git a/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/theme/ClearTheme.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/theme/ClearTheme.kt
new file mode 100644
index 0000000..0b75564
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/theme/ClearTheme.kt
@@ -0,0 +1,145 @@
+package com.chethan616.clearpdf.ui.theme
+
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.staticCompositionLocalOf
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.Font
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.text.font.FontVariation
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.LineHeightStyle
+import androidx.compose.ui.unit.TextUnit
+import androidx.compose.ui.unit.sp
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.Inter
+import com.chethan616.clearpdf.ui.ThemeChoice
+
+/** The candy accents: one per tool, the same hue in both themes. */
+object Candy {
+ val Tomato = Color(0xFFFF5A3C)
+ val Tangerine = Color(0xFFFF9A1F)
+ val Lemon = Color(0xFFFFC83A)
+ val Lime = Color(0xFF8CCB2E)
+ val Mint = Color(0xFF17C08F)
+ val Sky = Color(0xFF2E86FF)
+ val Grape = Color(0xFF8A4DFF)
+ val Bubblegum = Color(0xFFFF4DA6)
+
+ val All = listOf(Tomato, Tangerine, Lemon, Lime, Mint, Sky, Grape, Bubblegum)
+}
+
+@Immutable
+data class ClearColors(
+ val dark: Boolean,
+ /** Behind everything, under the aurora. */
+ val canvas: Color,
+ val ink: Color,
+ val inkSoft: Color,
+ val inkFaint: Color,
+ val line: Color,
+ /** The wash on chrome glass (dock, bars, buttons). */
+ val glass: Color,
+ /** The heavier frost menus, sheets and dialogs use so their text stays legible. */
+ val frost: Color,
+ /** The aurora's blobs: colour and strength. */
+ val aurora: List<Pair<Color, Float>>,
+ /** Behind document pages. */
+ val desk: Color,
+)
+
+private val InkLight = Color(0xFF17141F)
+private val InkDark = Color(0xFFF7F3FF)
+
+val LightClear = ClearColors(
+ dark = false,
+ canvas = Color(0xFFF6F1EA),
+ ink = InkLight,
+ inkSoft = InkLight.copy(alpha = 0.64f),
+ inkFaint = InkLight.copy(alpha = 0.40f),
+ line = InkLight.copy(alpha = 0.08f),
+ glass = Color.White.copy(alpha = 0.40f),
+ frost = Color(0xFFFBF8F4).copy(alpha = 0.78f),
+ aurora = listOf(
+ Candy.Tangerine to 0.30f,
+ Candy.Grape to 0.24f,
+ Candy.Sky to 0.20f,
+ Candy.Bubblegum to 0.18f,
+ Candy.Lemon to 0.26f,
+ ),
+ desk = Color(0xFFE6E2DC),
+)
+
+val DarkClear = ClearColors(
+ dark = true,
+ canvas = Color(0xFF0E0C13),
+ ink = InkDark,
+ inkSoft = InkDark.copy(alpha = 0.66f),
+ inkFaint = InkDark.copy(alpha = 0.42f),
+ line = InkDark.copy(alpha = 0.10f),
+ glass = Color(0xFF2A2634).copy(alpha = 0.42f),
+ frost = Color(0xFF1C1924).copy(alpha = 0.82f),
+ aurora = listOf(
+ Candy.Tangerine to 0.30f,
+ Candy.Grape to 0.42f,
+ Candy.Sky to 0.30f,
+ Candy.Bubblegum to 0.26f,
+ Candy.Mint to 0.18f,
+ ),
+ desk = Color(0xFF111015),
+)
+
+val LocalClearColors = staticCompositionLocalOf { LightClear }
+
+/** The colours in effect. */
+val clear: ClearColors @Composable get() = LocalClearColors.current
+
+/** Bricolage Grotesque at one point of its weight, width and optical-size axes. */
+private fun bricolage(weight: Int, width: Float, opticalSize: Float) = FontFamily(
+ Font(
+ R.font.bricolage,
+ FontWeight(weight),
+ variationSettings = FontVariation.Settings(
+ FontVariation.weight(weight),
+ FontVariation.width(width),
+ FontVariation.Setting("opsz", opticalSize),
+ ),
+ ),
+)
+
+private val Trim = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.Both)
+
+private fun display(family: FontFamily, size: TextUnit, line: TextUnit, tracking: TextUnit) =
+ TextStyle(fontFamily = family, fontSize = size, lineHeight = line, letterSpacing = tracking, lineHeightStyle = Trim)
+
+/**
+ * The type scale. Bricolage Grotesque (condensed, heavy, large optical size) carries the voice: heroes,
+ * titles, tile labels and numbers. Inter carries reading: body, labels and captions.
+ */
+object ClearType {
+ val Hero = display(bricolage(800, 84f, 96f), 52.sp, 54.sp, (-0.9).sp)
+ val Display = display(bricolage(760, 86f, 60f), 40.sp, 42.sp, (-0.6).sp)
+ val Headline = display(bricolage(720, 90f, 36f), 27.sp, 31.sp, (-0.3).sp)
+ val Title = display(bricolage(660, 92f, 24f), 19.sp, 23.sp, (-0.2).sp)
+ val Tile = display(bricolage(720, 86f, 20f), 18.sp, 20.sp, (-0.2).sp)
+ val Number = display(bricolage(740, 80f, 48f), 22.sp, 24.sp, 0.sp).copy(fontFeatureSettings = "tnum")
+
+ val Eyebrow = TextStyle(fontFamily = Inter, fontWeight = FontWeight.SemiBold, fontSize = 11.5.sp, lineHeight = 14.sp, letterSpacing = 1.4.sp)
+ val Body = TextStyle(fontFamily = Inter, fontWeight = FontWeight.Normal, fontSize = 15.sp, lineHeight = 21.sp)
+ val BodyStrong = Body.copy(fontWeight = FontWeight.SemiBold)
+ val Label = TextStyle(fontFamily = Inter, fontWeight = FontWeight.Medium, fontSize = 13.sp, lineHeight = 18.sp)
+ val Caption = TextStyle(fontFamily = Inter, fontWeight = FontWeight.Normal, fontSize = 12.sp, lineHeight = 16.sp)
+}
+
+@Composable
+fun ClearTheme(choice: ThemeChoice, content: @Composable () -> Unit) {
+ val dark = when (choice) {
+ ThemeChoice.System -> isSystemInDarkTheme()
+ ThemeChoice.Light -> false
+ ThemeChoice.Dark -> true
+ }
+ CompositionLocalProvider(LocalClearColors provides if (dark) DarkClear else LightClear, content = content)
+}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentDrag.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentDrag.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentDrag.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentDrag.kt
index 92e9dd9..c42a58b 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentDrag.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentDrag.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.gestures.detectDragGestures
@@ -24,9 +24,9 @@ import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.core.CommentInfo
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.core.CommentInfo
+import com.chethan616.clearpdf.ui.OpenDocument
import kotlin.math.roundToInt
/** Comments whose rectangle can be resized (the engine re-draws these to a new rectangle). */
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentList.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentList.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentList.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentList.kt
index b6e32a1..4f55cf8 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentList.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentList.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.activity.compose.BackHandler
import androidx.annotation.StringRes
@@ -58,19 +58,19 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.core.CommentInfo
-import io.github.artcraftandroid.pdfcraft.core.TileRect
-import io.github.artcraftandroid.pdfcraft.engine.toBitmap
-import io.github.artcraftandroid.pdfcraft.plural
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.SheetRow
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
-import io.github.artcraftandroid.pdfcraft.ui.safeTopPadding
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.core.CommentInfo
+import com.chethan616.clearpdf.core.TileRect
+import com.chethan616.clearpdf.engine.toBitmap
+import com.chethan616.clearpdf.plural
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.BarIcon
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.SheetRow
+import com.chethan616.clearpdf.ui.pdfColors
+import com.chethan616.clearpdf.ui.safeTopPadding
import kotlinx.coroutines.withContext
/** The comment types the list shows: the commenting kinds, not attachments, links or pop-ups. */
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentPanel.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentPanel.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentPanel.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentPanel.kt
index 408da35..5fd0d49 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentPanel.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/CommentPanel.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.foundation.background
import androidx.compose.foundation.border
@@ -42,15 +42,15 @@ 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 io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.core.CommentInfo
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.Inter
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.core.CommentInfo
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.BarIcon
+import com.chethan616.clearpdf.ui.Inter
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.pdfColors
/**
* A selected comment's panel, as the reference's: "‹ N of M ›" to step through the document's
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/DigitalSign.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/DigitalSign.kt
similarity index 97%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/DigitalSign.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/DigitalSign.kt
index 4106c44..1d23167 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/DigitalSign.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/DigitalSign.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.annotation.StringRes
import androidx.compose.foundation.Canvas
@@ -49,21 +49,21 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.engine.DigitalId
-import io.github.artcraftandroid.pdfcraft.text as appText
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfDialog
-import io.github.artcraftandroid.pdfcraft.ui.PdfField
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.SheetDivider
-import io.github.artcraftandroid.pdfcraft.ui.SheetRow
-import io.github.artcraftandroid.pdfcraft.ui.SheetTitle
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
-import io.github.artcraftandroid.pdfcraft.ui.safeTopPadding
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.engine.DigitalId
+import com.chethan616.clearpdf.text as appText
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.BarIcon
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfDialog
+import com.chethan616.clearpdf.ui.PdfField
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.SheetDivider
+import com.chethan616.clearpdf.ui.SheetRow
+import com.chethan616.clearpdf.ui.SheetTitle
+import com.chethan616.clearpdf.ui.pdfColors
+import com.chethan616.clearpdf.ui.safeTopPadding
import java.text.DateFormat
import java.util.Date
import org.json.JSONObject
@@ -458,7 +458,7 @@ fun CreateIdScreen(vm: AppViewModel) {
/** Tapping an empty signature field: draw a signature there, or sign it with a digital ID. */
@Composable
-fun SignFieldChoiceDialog(vm: AppViewModel, doc: OpenDocument, field: io.github.artcraftandroid.pdfcraft.core.WidgetInfo) {
+fun SignFieldChoiceDialog(vm: AppViewModel, doc: OpenDocument, field: com.chethan616.clearpdf.core.WidgetInfo) {
PdfDialog(onDismiss = { vm.signFieldChoice = null }, title = null, confirm = null, dismiss = null, list = true) {
SheetRow(LucideIcons.Signature, stringResource(R.string.sign_add_your_signature), { vm.signFieldChoice = null; vm.drawSignatureInField(doc, field) })
SheetRow(LucideIcons.ShieldCheck, stringResource(R.string.common_tool_sign_digital_id), { vm.signFieldChoice = null; vm.signFieldWithId(doc, field) })
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/DocLayout.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/DocLayout.kt
similarity index 99%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/DocLayout.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/DocLayout.kt
index 6db1ec7..7991877 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/DocLayout.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/DocLayout.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import kotlin.math.max
import kotlin.math.min
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Edit.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Edit.kt
similarity index 99%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Edit.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Edit.kt
index aa7a628..484c3fc 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Edit.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Edit.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
@@ -72,11 +72,11 @@ import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.res.stringResource
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.pdfColors
import kotlin.math.roundToInt
/** A paragraph Edit PDF can change: its number on the page, text, box (points) and style. */
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/EditLists.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/EditLists.kt
similarity index 95%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/EditLists.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/EditLists.kt
index 9598c1c..c535f61 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/EditLists.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/EditLists.kt
@@ -1,7 +1,7 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.text as appText
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.text as appText
/**
* Bulleted and numbered lists in Edit PDF: each line of a paragraph (its hard line breaks) becomes
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/FillSign.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/FillSign.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/FillSign.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/FillSign.kt
index 6901baa..a1754c8 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/FillSign.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/FillSign.kt
@@ -1,6 +1,6 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
-import io.github.artcraftandroid.pdfcraft.ui.safeTopPadding
+import com.chethan616.clearpdf.ui.safeTopPadding
import android.graphics.Bitmap
import androidx.annotation.StringRes
import android.graphics.BitmapFactory
@@ -55,16 +55,16 @@ import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.res.stringResource
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.SheetDivider
-import io.github.artcraftandroid.pdfcraft.ui.SheetRow
-import io.github.artcraftandroid.pdfcraft.ui.SheetTitle
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.BarIcon
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.SheetDivider
+import com.chethan616.clearpdf.ui.SheetRow
+import com.chethan616.clearpdf.ui.SheetTitle
+import com.chethan616.clearpdf.ui.pdfColors
import java.io.File
/** What a tap places in Fill & Sign. */
@@ -340,7 +340,7 @@ private fun renderStrokes(strokes: List<List<Offset>>, size: IntSize, color: Col
* reference's element menu, without its convert-to-another-element step).
*/
@Composable
-fun androidx.compose.foundation.layout.BoxScope.FillElementMenu(vm: AppViewModel, doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo) {
+fun androidx.compose.foundation.layout.BoxScope.FillElementMenu(vm: AppViewModel, doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo) {
val colors = pdfColors
if (c.rect.size < 4) return
var palette by remember { mutableStateOf(false) }
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Forms.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Forms.kt
similarity index 93%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Forms.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Forms.kt
index 6109472..85b1c27 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Forms.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Forms.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.foundation.background
import androidx.compose.foundation.border
@@ -48,16 +48,16 @@ import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.res.stringResource
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.core.WidgetInfo
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.SheetRow
-import io.github.artcraftandroid.pdfcraft.ui.SheetTitle
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.core.WidgetInfo
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.BarIcon
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.SheetRow
+import com.chethan616.clearpdf.ui.SheetTitle
+import com.chethan616.clearpdf.ui.pdfColors
import kotlin.math.roundToInt
/** A field being filled in: the widget tapped. */
@@ -75,7 +75,7 @@ fun BoxScope.FieldEditor(vm: AppViewModel, edit: FieldEdit) {
if (w.kind == "combo" || w.kind == "list") {
// as the reference: a dialog of radio choices that closes on a pick
val options = w.options.chunked(2).filter { it.size == 2 }
- io.github.artcraftandroid.pdfcraft.ui.PdfDialog(onDismiss = { vm.fieldEdit = null }, title = null, confirm = null, dismiss = null, list = true) {
+ com.chethan616.clearpdf.ui.PdfDialog(onDismiss = { vm.fieldEdit = null }, title = null, confirm = null, dismiss = null, list = true) {
LazyColumn(Modifier.heightIn(max = 420.dp)) {
items(options) { (value, label) ->
Row(
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageCanvas.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.kt
similarity index 99%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageCanvas.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.kt
index f8f4dd4..4134aa0 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageCanvas.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector2D
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageImages.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageImages.kt
similarity index 95%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageImages.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageImages.kt
index b2346e1..a05fd24 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageImages.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageImages.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import android.util.Log
import androidx.compose.runtime.getValue
@@ -6,9 +6,9 @@ import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
-import io.github.artcraftandroid.pdfcraft.core.TileRect
-import io.github.artcraftandroid.pdfcraft.engine.Engine
-import io.github.artcraftandroid.pdfcraft.engine.toBitmap
+import com.chethan616.clearpdf.core.TileRect
+import com.chethan616.clearpdf.engine.Engine
+import com.chethan616.clearpdf.engine.toBitmap
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
@@ -123,7 +123,7 @@ class PageImages(
PageImage(r.key, img.toBitmap().asImageBitmap(), r.scale, r.tile?.x?.toInt() ?: 0, r.tile?.y?.toInt() ?: 0)
}
} catch (e: Exception) {
- Log.w("PdfCraft", "render of ${r.key} failed: ${e.message}")
+ Log.w("ClearPDF", "render of ${r.key} failed: ${e.message}")
synchronized(lock) { failed.add(r.key) }
null
} finally {
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageMenu.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageMenu.kt
similarity index 94%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageMenu.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageMenu.kt
index 6ef6888..d7e8074 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageMenu.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageMenu.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@@ -39,11 +39,11 @@ import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.pdfColors
import kotlin.math.roundToInt
/** A long press on an empty part of a page: the menu of what can start there. */
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PagesScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PagesScreen.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PagesScreen.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PagesScreen.kt
index b42d76e..0277aec 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PagesScreen.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PagesScreen.kt
@@ -1,6 +1,6 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
-import io.github.artcraftandroid.pdfcraft.ui.safeTopPadding
+import com.chethan616.clearpdf.ui.safeTopPadding
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
@@ -59,16 +59,16 @@ import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.engine.toBitmap
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.SheetRow
-import io.github.artcraftandroid.pdfcraft.ui.SheetTitle
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.engine.toBitmap
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.BarIcon
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.SheetRow
+import com.chethan616.clearpdf.ui.SheetTitle
+import com.chethan616.clearpdf.ui.pdfColors
import kotlinx.coroutines.withContext
/**
@@ -312,7 +312,7 @@ fun PagesScreen(vm: AppViewModel, doc: OpenDocument, onClose: () -> Unit) {
Text(label, color = c.text, fontSize = 16.sp)
}
}
- io.github.artcraftandroid.pdfcraft.ui.SheetDivider()
+ com.chethan616.clearpdf.ui.SheetDivider()
SheetRow(LucideIcons.File, stringResource(R.string.pages_blank_page), { insertMenu = false; vm.runTool(doc, "page_insert_blank", mapOf("at" to at)) })
SheetRow(LucideIcons.FileStack, stringResource(R.string.pages_from_file), { insertMenu = false; vm.pickInsertFile(doc, at) })
SheetRow(LucideIcons.Camera, stringResource(R.string.pages_from_scan), { insertMenu = false; vm.insertScanAt = doc to at; vm.startScan() })
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/QuickTools.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/QuickTools.kt
similarity index 97%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/QuickTools.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/QuickTools.kt
index b0b9539..9030ef3 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/QuickTools.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/QuickTools.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import android.content.Context
import androidx.annotation.StringRes
@@ -59,12 +59,12 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.BarIcon
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.pdfColors
import kotlin.math.roundToInt
/**
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadAloud.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ReadAloud.kt
similarity index 95%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadAloud.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ReadAloud.kt
index d7b9c58..529204e 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadAloud.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ReadAloud.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import android.content.Context
import android.content.Intent
@@ -66,16 +66,16 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Popup
import androidx.compose.ui.window.PopupProperties
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.core.ReadingBlock
-import io.github.artcraftandroid.pdfcraft.core.TextRange
-import io.github.artcraftandroid.pdfcraft.engine.Engine
-import io.github.artcraftandroid.pdfcraft.engine.toBitmap
-import io.github.artcraftandroid.pdfcraft.text
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.core.ReadingBlock
+import com.chethan616.clearpdf.core.TextRange
+import com.chethan616.clearpdf.engine.Engine
+import com.chethan616.clearpdf.engine.toBitmap
+import com.chethan616.clearpdf.text
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.pdfColors
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -448,7 +448,7 @@ fun DrawScope.drawReadAloud(doc: OpenDocument, r: ReadAloud) {
* seconds, and the speed.
*/
@Composable
-fun BoxScope.ReadAloudBar(vm: io.github.artcraftandroid.pdfcraft.ui.AppViewModel, doc: OpenDocument, r: ReadAloud) {
+fun BoxScope.ReadAloudBar(vm: com.chethan616.clearpdf.ui.AppViewModel, doc: OpenDocument, r: ReadAloud) {
val c = pdfColors
var speeds by remember { mutableStateOf(false) }
var expanded by remember { mutableStateOf(false) }
@@ -548,7 +548,7 @@ private fun SpeedPicker(r: ReadAloud, onDismiss: () -> Unit) {
* settings) and the speed.
*/
@Composable
-private fun ReadAloudFull(vm: io.github.artcraftandroid.pdfcraft.ui.AppViewModel, doc: OpenDocument, r: ReadAloud, onClose: () -> Unit) {
+private fun ReadAloudFull(vm: com.chethan616.clearpdf.ui.AppViewModel, doc: OpenDocument, r: ReadAloud, onClose: () -> Unit) {
val c = pdfColors
val context = LocalContext.current
var thumb by remember(r.page) { mutableStateOf<ImageBitmap?>(null) }
@@ -626,15 +626,15 @@ private fun LanguageSheet(r: ReadAloud, onVoiceSettings: () -> Unit, onDismiss:
// opened at the language in use (a couple of rows above it showing)
val current = remember(langs, r.language) { languageIndex(langs, r.language) }
val list = androidx.compose.foundation.lazy.rememberLazyListState(initialFirstVisibleItemIndex = (current - 2).coerceAtLeast(0))
- io.github.artcraftandroid.pdfcraft.ui.PdfSheet(onDismiss = onDismiss, dim = true) {
- io.github.artcraftandroid.pdfcraft.ui.SheetTitle(stringResource(R.string.read_aloud_choose_language))
+ com.chethan616.clearpdf.ui.PdfSheet(onDismiss = onDismiss, dim = true) {
+ com.chethan616.clearpdf.ui.SheetTitle(stringResource(R.string.read_aloud_choose_language))
androidx.compose.foundation.lazy.LazyColumn(Modifier.heightIn(max = 420.dp), state = list) {
items(langs.size) { i ->
val l = langs[i]
- io.github.artcraftandroid.pdfcraft.ui.SheetRow(null, l.getDisplayName(Locale.getDefault()), { r.chooseLanguage(l); onDismiss() }, checked = i == current)
+ com.chethan616.clearpdf.ui.SheetRow(null, l.getDisplayName(Locale.getDefault()), { r.chooseLanguage(l); onDismiss() }, checked = i == current)
}
}
- io.github.artcraftandroid.pdfcraft.ui.SheetRow(LucideIcons.Settings, stringResource(R.string.read_aloud_voice_settings), onVoiceSettings)
+ com.chethan616.clearpdf.ui.SheetRow(LucideIcons.Settings, stringResource(R.string.read_aloud_voice_settings), onVoiceSettings)
Spacer(Modifier.height(8.dp))
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadingMode.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ReadingMode.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadingMode.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ReadingMode.kt
index 62714a3..33e006a 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadingMode.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ReadingMode.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.awaitEachGesture
@@ -27,7 +27,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Modifier
import kotlinx.coroutines.flow.first
-import io.github.artcraftandroid.pdfcraft.ui.HintToast
+import com.chethan616.clearpdf.ui.HintToast
import androidx.compose.ui.Alignment
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.foundation.layout.Box
@@ -38,10 +38,10 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.pdfColors
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Search.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Search.kt
similarity index 95%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Search.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Search.kt
index 3f1171f..0ee92e4 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Search.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Search.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
@@ -6,8 +6,8 @@ import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
-import io.github.artcraftandroid.pdfcraft.core.SearchHit
-import io.github.artcraftandroid.pdfcraft.engine.Engine
+import com.chethan616.clearpdf.core.SearchHit
+import com.chethan616.clearpdf.engine.Engine
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.isActive
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ShapeSnap.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ShapeSnap.kt
similarity index 99%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ShapeSnap.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ShapeSnap.kt
index 334010e..661c12b 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ShapeSnap.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ShapeSnap.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.ui.geometry.Offset
import kotlin.math.abs
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/SpellCheck.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/SpellCheck.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/SpellCheck.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/SpellCheck.kt
index 0cb94f2..3f73612 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/SpellCheck.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/SpellCheck.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import android.content.Context
import android.view.textservice.SentenceSuggestionsInfo
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/TextSelection.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/TextSelection.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/TextSelection.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/TextSelection.kt
index 961b739..c1e59b3 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/TextSelection.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/TextSelection.kt
@@ -1,11 +1,11 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
-import io.github.artcraftandroid.pdfcraft.core.TextRange
-import io.github.artcraftandroid.pdfcraft.engine.Engine
+import com.chethan616.clearpdf.core.TextRange
+import com.chethan616.clearpdf.engine.Engine
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ToolPrefs.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ToolPrefs.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ToolPrefs.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ToolPrefs.kt
index 05d0851..72c6f08 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ToolPrefs.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ToolPrefs.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import android.content.Context
import androidx.compose.runtime.Stable
@@ -8,7 +8,7 @@ import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
-import io.github.artcraftandroid.pdfcraft.R
+import com.chethan616.clearpdf.R
/** The comment colours: 18 swatches in three rows of six (strong, light, greys), as measured on the reference. */
val CommentPalette: List<Pair<Color, Int>> = listOf(
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Tools.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Tools.kt
similarity index 97%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Tools.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Tools.kt
index 1987c03..7fc4897 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Tools.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Tools.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
@@ -38,7 +38,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import io.github.artcraftandroid.pdfcraft.ui.LocalUndo
+import com.chethan616.clearpdf.ui.LocalUndo
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.drawscope.clipPath
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
@@ -61,15 +61,15 @@ import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.res.stringResource
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.text
-import io.github.artcraftandroid.pdfcraft.core.TextRange
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.SheetHost
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.text
+import com.chethan616.clearpdf.core.TextRange
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.SheetHost
+import com.chethan616.clearpdf.ui.pdfColors
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerBars.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerBars.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt
index 8f2cc7f..7759389 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerBars.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.foundation.background
import androidx.compose.foundation.border
@@ -58,12 +58,12 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.ui.BarDivider
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.Inter
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.BarDivider
+import com.chethan616.clearpdf.ui.BarIcon
+import com.chethan616.clearpdf.ui.Inter
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.pdfColors
import kotlinx.coroutines.flow.first
/** The viewer's top bar height (the reference's: 56 dp). */
@@ -296,7 +296,7 @@ private fun QuickItem(icon: ImageVector, label: String, onClick: () -> Unit, sub
// the reference's 11 sp face is narrower than Inter: a half point less gives its height, and
// tighter letters its width; lines close together, so a wrapped label stays one block, and
// a word too wide for its slot (a very large font setting) shrinks rather than splits
- io.github.artcraftandroid.pdfcraft.ui.WordWrapLabel(
+ com.chethan616.clearpdf.ui.WordWrapLabel(
label, c.label, size = 10.5.sp, lineHeight = 13.sp, letterSpacing = (-0.5).sp,
modifier = Modifier.padding(top = 2.5.dp),
)
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerController.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerController.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerController.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerController.kt
index 9b5f0a8..5b241f3 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerController.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerController.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerOverlays.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerOverlays.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt
index 86148f2..b2066ac 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerOverlays.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.tween
@@ -64,14 +64,14 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.core.CommentInfo
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.core.CommentInfo
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.BarIcon
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.pdfColors
import kotlin.math.roundToInt
/** A note waiting for its text: at a point (Comment tool) or on selected text (Add comment). */
@@ -154,11 +154,11 @@ fun GoToPageDialog(doc: OpenDocument, onDismiss: () -> Unit) {
doc.viewer.goToPage(n - 1)
onDismiss()
}
- io.github.artcraftandroid.pdfcraft.ui.PdfDialog(onDismiss = onDismiss, title = stringResource(R.string.viewer_go_to_page), confirm = stringResource(R.string.common_ok), onConfirm = ::go, confirmEnabled = text.isNotEmpty()) {
+ com.chethan616.clearpdf.ui.PdfDialog(onDismiss = onDismiss, title = stringResource(R.string.viewer_go_to_page), confirm = stringResource(R.string.common_ok), onConfirm = ::go, confirmEnabled = text.isNotEmpty()) {
Column {
Text(stringResource(R.string.viewer_go_to_page_range, doc.pageCount), color = c.textSecondary, fontSize = 14.sp)
Spacer(Modifier.height(10.dp))
- io.github.artcraftandroid.pdfcraft.ui.PdfField(
+ com.chethan616.clearpdf.ui.PdfField(
text, { text = it.filter(Char::isDigit).take(6); wrong = false }, stringResource(R.string.viewer_enter_page_number), error = wrong, focus = focus,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = androidx.compose.ui.text.input.ImeAction.Go),
keyboardActions = KeyboardActions(onGo = { go() }),
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt
similarity index 95%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt
index 39c2e6e..9896479 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import android.app.Activity
import android.os.SystemClock
@@ -41,8 +41,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.foundation.magnifier
import androidx.compose.ui.draw.clip
import androidx.compose.foundation.layout.imePadding
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.BarIcon
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.Spacer
@@ -65,14 +65,14 @@ import androidx.compose.ui.res.stringResource
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.text
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.HintToast
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfMotion
-import io.github.artcraftandroid.pdfcraft.ui.SheetHost
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.text
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.HintToast
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfMotion
+import com.chethan616.clearpdf.ui.SheetHost
+import com.chethan616.clearpdf.ui.pdfColors
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@@ -458,10 +458,10 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {
if (ctl.sheet == ViewerSheet.Comments) CommentListScreen(vm, doc)
vm.pageMenu?.takeIf { it.doc === doc }?.let { PageMenuView(vm, it) }
if (vm.imageSource?.first === doc) {
- io.github.artcraftandroid.pdfcraft.ui.PdfSheet(onDismiss = { vm.imageSource = null }, dim = true) {
- io.github.artcraftandroid.pdfcraft.ui.SheetTitle(stringResource(R.string.viewer_add_image))
- io.github.artcraftandroid.pdfcraft.ui.SheetRow(LucideIcons.Images, stringResource(R.string.viewer_image_from_photos), { vm.addImageFrom(camera = false) })
- io.github.artcraftandroid.pdfcraft.ui.SheetRow(LucideIcons.Camera, stringResource(R.string.viewer_image_from_camera), { vm.addImageFrom(camera = true) })
+ com.chethan616.clearpdf.ui.PdfSheet(onDismiss = { vm.imageSource = null }, dim = true) {
+ com.chethan616.clearpdf.ui.SheetTitle(stringResource(R.string.viewer_add_image))
+ com.chethan616.clearpdf.ui.SheetRow(LucideIcons.Images, stringResource(R.string.viewer_image_from_photos), { vm.addImageFrom(camera = false) })
+ com.chethan616.clearpdf.ui.SheetRow(LucideIcons.Camera, stringResource(R.string.viewer_image_from_camera), { vm.addImageFrom(camera = true) })
Spacer(Modifier.height(12.dp))
}
}
@@ -517,7 +517,7 @@ private fun closeSearch(doc: OpenDocument) {
}
/** Bring a hit into view: its page, with the hit a third of the way down the screen. */
-fun showHit(doc: OpenDocument, hit: io.github.artcraftandroid.pdfcraft.core.SearchHit) {
+fun showHit(doc: OpenDocument, hit: com.chethan616.clearpdf.core.SearchHit) {
val page = hit.range.page.toInt()
val y = hit.rects.getOrNull(1) ?: 0f
val v = doc.viewer
@@ -564,7 +564,7 @@ private fun androidx.compose.ui.graphics.drawscope.DrawScope.drawSelection(doc:
}
}
-private fun androidx.compose.ui.graphics.drawscope.DrawScope.drawCommentSelection(doc: OpenDocument, c: io.github.artcraftandroid.pdfcraft.core.CommentInfo) {
+private fun androidx.compose.ui.graphics.drawscope.DrawScope.drawCommentSelection(doc: OpenDocument, c: com.chethan616.clearpdf.core.CommentInfo) {
if (c.rect.size < 4) return
val page = c.page.toInt()
val a = doc.viewer.pageToScreen(page, c.rect[0], c.rect[1])
@@ -607,7 +607,7 @@ private const val NOTE_SELECTED_DP = 19f
* pale fill in a 2 dp outline of the note's colour, edged in white over a soft shadow; selected,
* it fills with the colour and shows two white lines of "text".
*/
-private fun androidx.compose.ui.graphics.drawscope.DrawScope.drawNotes(doc: OpenDocument, night: Boolean, selected: io.github.artcraftandroid.pdfcraft.core.CommentInfo?) {
+private fun androidx.compose.ui.graphics.drawscope.DrawScope.drawNotes(doc: OpenDocument, night: Boolean, selected: com.chethan616.clearpdf.core.CommentInfo?) {
val dp = density
val s = NOTE_ICON_DP * dp
for (n in doc.comments) {
@@ -660,7 +660,7 @@ data class LinkFlash(val page: Int, val rect: FloatArray)
/** The green banner a finished job leaves over the bar: a tick, the message, close, and Undo. */
@Composable
-private fun SuccessBannerView(b: io.github.artcraftandroid.pdfcraft.ui.SuccessBanner, onClose: () -> Unit) {
+private fun SuccessBannerView(b: com.chethan616.clearpdf.ui.SuccessBanner, onClose: () -> Unit) {
LaunchedEffect(b) {
delay(8000)
onClose()
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerSheets.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerSheets.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt
index 88d0f7c..36e97de 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerSheets.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.foundation.background
import androidx.compose.foundation.border
@@ -46,24 +46,24 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.core.AttachmentInfo
-import io.github.artcraftandroid.pdfcraft.core.CommentInfo
-import io.github.artcraftandroid.pdfcraft.core.OutlineEntry
-import io.github.artcraftandroid.pdfcraft.plural
-import io.github.artcraftandroid.pdfcraft.text
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.PdfSwitch
-import io.github.artcraftandroid.pdfcraft.ui.SheetBackHeader
-import io.github.artcraftandroid.pdfcraft.ui.GroupDivider
-import io.github.artcraftandroid.pdfcraft.ui.SheetDivider
-import io.github.artcraftandroid.pdfcraft.ui.SheetRow
-import io.github.artcraftandroid.pdfcraft.ui.SheetTitle
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.core.AttachmentInfo
+import com.chethan616.clearpdf.core.CommentInfo
+import com.chethan616.clearpdf.core.OutlineEntry
+import com.chethan616.clearpdf.plural
+import com.chethan616.clearpdf.text
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.BarIcon
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.PdfSwitch
+import com.chethan616.clearpdf.ui.SheetBackHeader
+import com.chethan616.clearpdf.ui.GroupDivider
+import com.chethan616.clearpdf.ui.SheetDivider
+import com.chethan616.clearpdf.ui.SheetRow
+import com.chethan616.clearpdf.ui.SheetTitle
+import com.chethan616.clearpdf.ui.pdfColors
import java.text.DateFormat
import java.util.Date
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerState.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerState.kt
similarity index 99%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerState.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerState.kt
index eda5461..625d614 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerState.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerState.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
@@ -7,7 +7,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
-import io.github.artcraftandroid.pdfcraft.core.TileRect
+import com.chethan616.clearpdf.core.TileRect
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.ln
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/VoiceRecorder.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/VoiceRecorder.kt
similarity index 99%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/VoiceRecorder.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/VoiceRecorder.kt
index 87780ac..4d7d443 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/VoiceRecorder.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/VoiceRecorder.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import android.annotation.SuppressLint
import android.media.AudioFormat
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/VoiceSheet.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/VoiceSheet.kt
similarity index 95%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/VoiceSheet.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/VoiceSheet.kt
index 0b62395..af254cf 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/VoiceSheet.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/VoiceSheet.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
@@ -41,14 +41,14 @@ import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.core.CommentInfo
-import io.github.artcraftandroid.pdfcraft.text
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.core.CommentInfo
+import com.chethan616.clearpdf.text
+import com.chethan616.clearpdf.ui.AppViewModel
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.OpenDocument
+import com.chethan616.clearpdf.ui.PdfSheet
+import com.chethan616.clearpdf.ui.pdfColors
import kotlinx.coroutines.launch
/** A voice comment to record at [at]. */
@@ -249,11 +249,11 @@ fun VoiceCommentPlayer(vm: AppViewModel, doc: OpenDocument, comment: CommentInfo
/** The microphone was refused before: why it is needed, and a way to the app's settings. */
@Composable
fun MicRationaleDialog(vm: AppViewModel) {
- io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
+ com.chethan616.clearpdf.ui.PdfDialog(
onDismiss = { vm.dismissMicRationale(false) }, title = stringResource(R.string.voice_mic_title),
confirm = stringResource(R.string.voice_open_settings), onConfirm = { vm.dismissMicRationale(true) },
dismiss = stringResource(R.string.voice_not_now), onDismissButton = { vm.dismissMicRationale(false) },
- ) { Text(stringResource(R.string.voice_mic_rationale), color = io.github.artcraftandroid.pdfcraft.ui.pdfColors.text, fontSize = 14.sp) }
+ ) { Text(stringResource(R.string.voice_mic_rationale), color = com.chethan616.clearpdf.ui.pdfColors.text, fontSize = 14.sp) }
}
/** A comment's type as the lists name it (a Sound comment is a voice comment here). */
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ZoomButtons.kt b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ZoomButtons.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ZoomButtons.kt
rename to apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ZoomButtons.kt
index c0edf97..17528f2 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ZoomButtons.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ZoomButtons.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui.viewer
+package com.chethan616.clearpdf.ui.viewer
import android.content.Context
import android.content.pm.PackageManager
@@ -37,9 +37,9 @@ import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
+import com.chethan616.clearpdf.R
+import com.chethan616.clearpdf.ui.LucideIcons
+import com.chethan616.clearpdf.ui.pdfColors
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppRoot.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppRoot.kt
deleted file mode 100644
index 61ff4e5..0000000
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppRoot.kt
+++ /dev/null
@@ -1,258 +0,0 @@
-package io.github.artcraftandroid.pdfcraft.ui
-
-import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.WindowInsets
-import androidx.compose.foundation.layout.WindowInsetsSides
-import androidx.compose.foundation.layout.only
-import androidx.compose.foundation.layout.safeDrawing
-import androidx.compose.foundation.layout.windowInsetsPadding
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.imePadding
-import androidx.compose.foundation.layout.navigationBars
-import androidx.compose.foundation.layout.navigationBarsPadding
-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.text.KeyboardActions
-import androidx.compose.foundation.text.KeyboardOptions
-import androidx.compose.foundation.verticalScroll
-import androidx.compose.material3.AlertDialog
-import androidx.compose.material3.CircularProgressIndicator
-import androidx.compose.material3.OutlinedTextField
-import androidx.compose.material3.OutlinedTextFieldDefaults
-import androidx.compose.material3.SnackbarDuration
-import androidx.compose.material3.SnackbarHost
-import androidx.compose.material3.SnackbarHostState
-import androidx.compose.material3.SnackbarResult
-import androidx.compose.material3.Text
-import androidx.compose.material3.TextButton
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
-import androidx.compose.runtime.setValue
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.focus.FocusRequester
-import androidx.compose.ui.focus.focusRequester
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.LocalContext
-import androidx.compose.ui.res.stringResource
-import androidx.compose.ui.text.SpanStyle
-import androidx.compose.ui.text.buildAnnotatedString
-import androidx.compose.ui.text.font.FontStyle
-import androidx.compose.ui.text.font.FontWeight
-import androidx.compose.ui.text.input.ImeAction
-import androidx.compose.ui.text.input.KeyboardType
-import androidx.compose.ui.text.input.PasswordVisualTransformation
-import androidx.compose.ui.text.input.VisualTransformation
-import androidx.compose.ui.text.withStyle
-import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.ui.home.HomeRoot
-import io.github.artcraftandroid.pdfcraft.ui.home.SettingsScreen
-import io.github.artcraftandroid.pdfcraft.ui.viewer.CertSignScreen
-import io.github.artcraftandroid.pdfcraft.ui.viewer.CreateIdScreen
-import io.github.artcraftandroid.pdfcraft.ui.viewer.IdPasswordDialog
-import io.github.artcraftandroid.pdfcraft.ui.viewer.SignFieldChoiceDialog
-import io.github.artcraftandroid.pdfcraft.ui.viewer.SignaturePadScreen
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerScreen
-
-/** Home or the viewer, and everything that can come over them: tools, settings, dialogs, snackbars. */
-@Composable
-fun AppRoot(vm: AppViewModel, onBrowse: () -> Unit, onPickSignatureImage: () -> Unit) {
- val c = pdfColors
- val snackbar = remember { SnackbarHostState() }
- LaunchedEffect(vm) {
- for (m in vm.messages) {
- val result = snackbar.showSnackbar(
- m.text, actionLabel = m.actionLabel, withDismissAction = m.actionLabel == null,
- duration = if (m.actionLabel != null) SnackbarDuration.Long else SnackbarDuration.Short,
- )
- if (result == SnackbarResult.ActionPerformed) m.action?.invoke()
- }
- }
- val doc = vm.document
- // outside the viewer (which sets its own) the bar icons follow the app's theme, not the system's
- val view = androidx.compose.ui.platform.LocalView.current
- val activity = androidx.compose.ui.platform.LocalContext.current as? android.app.Activity
- androidx.compose.runtime.SideEffect {
- val window = activity?.window ?: return@SideEffect
- if (doc == null) {
- val insets = androidx.core.view.WindowCompat.getInsetsController(window, view)
- insets.isAppearanceLightStatusBars = !c.dark
- insets.isAppearanceLightNavigationBars = !c.dark
- }
- }
- // Back in the viewer closes the document (saving it) and returns to Home
- androidx.activity.compose.BackHandler(enabled = doc != null && vm.toolScreen == null) { vm.closeDocument() }
- // sideways, the camera cutout and the navigation bar sit at the sides: content stays between
- // them, on black, as the reference's does. With Extra Features' status bar in documents the
- // page goes under the camera too, as it does upright (#45): the viewer is laid out full width
- // and keeps its bars clear of the camera itself.
- val fullWidthViewer = doc != null && vm.statusBarInDocuments
- Box(Modifier.fillMaxSize().background(Color.Black)) {
- if (fullWidthViewer && doc != null) {
- Box(Modifier.fillMaxSize().windowInsetsPadding(WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal))) { ViewerScreen(vm, doc) }
- }
- Box(
- Modifier.fillMaxSize()
- .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal))
- .then(if (fullWidthViewer) Modifier else Modifier.background(c.surface)),
- ) {
- when {
- fullWidthViewer -> Unit
- doc != null -> ViewerScreen(vm, doc)
- else -> HomeRoot(vm, onBrowse)
- }
- // here rather than in the file's row: a sheet inside a scrolling list has no height to fill
- if (doc == null) vm.fileSheet?.let { (r, recent) -> io.github.artcraftandroid.pdfcraft.ui.home.FileSheet(vm, r, recent) { vm.fileSheet = null } }
- vm.toolScreen?.let { ToolScreenHost(vm, it) }
- vm.signaturePad?.let { SignaturePadScreen(vm, it, onPickSignatureImage) }
- vm.certSign?.let { CertSignScreen(vm, it) }
- if (vm.idCreate) CreateIdScreen(vm)
- if (vm.settingsOpen) SettingsScreen(vm)
- if (vm.showLicences) LicencesScreen(vm)
-
- if (vm.opening) CircularProgressIndicator(Modifier.align(Alignment.Center), color = c.accent)
- SnackbarHost(snackbar, Modifier.align(Alignment.BottomCenter).navigationBarsPadding().padding(bottom = 72.dp, start = 8.dp, end = 8.dp))
-
- vm.passwordRequest?.let { PasswordDialog(vm, it) }
- vm.idImport?.let { IdPasswordDialog(vm, it) }
- vm.signFieldChoice?.let { (d, w) -> SignFieldChoiceDialog(vm, d, w) }
- if (vm.authorPrompt) {
- var name by remember { mutableStateOf("") }
- PdfDialog(
- onDismiss = { vm.authorPrompt = false }, title = stringResource(R.string.home_author_title),
- confirm = stringResource(R.string.common_save), onConfirm = { vm.toolPrefs.author = name.trim(); vm.authorPrompt = false; vm.prefsChanged++ },
- dismiss = stringResource(R.string.root_skip),
- ) {
- Text(stringResource(R.string.root_author_prompt_body), color = c.text, fontSize = 14.sp)
- Spacer(Modifier.height(14.dp))
- PdfField(name, { name = it }, stringResource(R.string.common_your_name))
- }
- }
- vm.readOnlyPrompt?.let { d ->
- PdfDialog(
- onDismiss = { vm.answerReadOnly(null) }, title = stringResource(R.string.root_read_only_title),
- confirm = stringResource(R.string.common_save_copy), onConfirm = { vm.answerReadOnly(true) },
- dismiss = stringResource(R.string.root_discard), onDismissButton = { vm.answerReadOnly(false) },
- ) { Text(stringResource(R.string.root_read_only_body, d.name), color = c.text, fontSize = 14.sp) }
- }
- vm.linkPrompt?.let { url ->
- val shown = runCatching { android.net.Uri.parse(url).let { u -> "${u.scheme}://${u.host}${if (u.port > 0) ":${u.port}" else ""}" } }.getOrDefault(url)
- PdfDialog(onDismiss = { vm.answerLink(false) }, title = stringResource(R.string.root_open_link_title), confirm = stringResource(R.string.common_open), onConfirm = { vm.answerLink(true) }) {
- Text(stringResource(R.string.root_open_link_body, shown), color = c.text, fontSize = 14.sp)
- }
- }
- // a form script's alert, as the form words it
- vm.scriptAlerts.firstOrNull()?.let { message ->
- PdfDialog(onDismiss = vm::dismissScriptAlert, title = null, confirm = stringResource(R.string.common_ok), onConfirm = vm::dismissScriptAlert, dismiss = null) {
- Text(message, color = c.text, fontSize = 14.sp)
- }
- }
- vm.confirmDeleteAllBookmarks?.let { d ->
- PdfDialog(
- onDismiss = { vm.confirmDeleteAllBookmarks = null }, title = stringResource(R.string.root_delete_bookmarks_title),
- confirm = stringResource(R.string.root_delete_all), onConfirm = { vm.confirmDeleteAllBookmarks = null; vm.deleteAllBookmarks(d) }, destructive = true,
- ) { Text(stringResource(R.string.root_delete_bookmarks_body), color = c.text, fontSize = 14.sp) }
- }
- vm.readingModeBlocked?.let {
- PdfDialog(onDismiss = { vm.readingModeBlocked = null }, title = stringResource(R.string.root_reading_mode_title), confirm = stringResource(R.string.common_ok), onConfirm = { vm.readingModeBlocked = null }, dismiss = null) {
- Text(stringResource(R.string.root_reading_mode_body), color = c.text, fontSize = 14.sp)
- }
- }
- vm.busy?.let { message ->
- PdfDialog(onDismiss = {}, title = null, confirm = null, dismiss = null) {
- Row(verticalAlignment = Alignment.CenterVertically) {
- CircularProgressIndicator(Modifier.size(28.dp), color = c.accent, strokeWidth = 3.dp)
- Spacer(Modifier.width(20.dp))
- Text(message, color = c.text)
- }
- }
- }
- }
- }
-}
-
-/** "Enter password": the file's name, a masked field with an eye, OK and Cancel; wrong turns it red. */
-@Composable
-private fun PasswordDialog(vm: AppViewModel, req: PasswordRequest) {
- val c = pdfColors
- var pw by remember(req) { mutableStateOf("") }
- val focus = remember { FocusRequester() }
- LaunchedEffect(req) { runCatching { focus.requestFocus() } }
- // the sentence with the file's name in italics where its %1$s is
- val body = stringResource(R.string.root_password_body)
- PdfDialog(onDismiss = { vm.answerPassword(null) }, title = stringResource(R.string.root_enter_password), confirm = stringResource(R.string.common_ok), onConfirm = { vm.answerPassword(pw) }) {
- Text(buildAnnotatedString {
- val at = body.indexOf("%1\$s")
- if (at < 0) {
- append(body)
- } else {
- append(body.substring(0, at))
- withStyle(SpanStyle(fontStyle = FontStyle.Italic)) { append(req.file.name) }
- append(body.substring(at + "%1\$s".length))
- }
- }, color = c.text, fontSize = 14.sp)
- Spacer(Modifier.height(14.dp))
- PdfField(
- pw, { pw = it }, stringResource(R.string.common_password), error = req.wrong && pw.isEmpty(), password = true, focus = focus,
- keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, imeAction = ImeAction.Done),
- keyboardActions = KeyboardActions(onDone = { if (pw.isNotEmpty()) vm.answerPassword(pw) }),
- )
- }
-}
-
-/** The open-source licences of what the app is built from. */
-@Composable
-private fun LicencesScreen(vm: AppViewModel) {
- val c = pdfColors
- val context = LocalContext.current
- androidx.activity.compose.BackHandler { vm.showLicences = false }
- // the full texts of the bundled notices, in the order of the entries below
- val texts = remember {
- listOf("LICENSE-lucide.txt", "OFL-Inter.txt", "OFL-DancingScript.txt", "LICENSE-foxit.txt", "LICENSE-adobe-cmaps.txt").map { name ->
- runCatching { context.assets.open("licences/$name").bufferedReader().readText() }.getOrDefault("")
- }
- }
- Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().navigationBarsPadding()) {
- Row(Modifier.fillMaxWidth().height(56.dp), verticalAlignment = Alignment.CenterVertically) {
- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), { vm.showLicences = false }) }
- Text(stringResource(R.string.home_licences), color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold)
- }
- Column(Modifier.verticalScroll(rememberScrollState()).padding(horizontal = 20.dp)) {
- @Composable
- fun entry(name: String, licence: String) {
- Text(name, color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(top = 14.dp))
- Text(licence, color = c.textSecondary, fontSize = 13.sp)
- }
- entry(stringResource(R.string.root_licence_pdfcraft), stringResource(R.string.root_licence_pdfcraft_terms))
- entry("UniFFI", "MPL-2.0, Mozilla")
- entry("JNA", "Apache-2.0")
- entry("AndroidX, Jetpack Compose, Kotlin coroutines", "Apache-2.0")
- entry(stringResource(R.string.root_licence_lucide), "ISC, Lucide Contributors")
- entry(stringResource(R.string.root_licence_inter), "SIL Open Font License 1.1, The Inter Project Authors")
- entry(stringResource(R.string.root_licence_dancing_script), "SIL Open Font License 1.1, The Dancing Script Project Authors")
- entry(stringResource(R.string.root_licence_foxit), "BSD-3-Clause, Foxit Software Inc. and the PDFium Authors")
- entry(stringResource(R.string.root_licence_cmaps), "BSD-3-Clause, Adobe")
- entry(stringResource(R.string.root_licence_ocrs), stringResource(R.string.root_licence_ocrs_terms))
- entry(stringResource(R.string.root_licence_rust), stringResource(R.string.root_licence_rust_terms))
- for (licence in texts.filter { it.isNotBlank() }) {
- Spacer(Modifier.height(20.dp))
- Text(licence, color = c.textSecondary, fontSize = 11.sp)
- }
- Spacer(Modifier.height(32.dp))
- }
- }
-}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/HomeScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/HomeScreen.kt
deleted file mode 100644
index 3680a6d..0000000
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/HomeScreen.kt
+++ /dev/null
@@ -1,492 +0,0 @@
-package io.github.artcraftandroid.pdfcraft.ui.home
-
-import io.github.artcraftandroid.pdfcraft.ui.safeTopPadding
-import androidx.compose.foundation.Image
-import androidx.compose.foundation.background
-import androidx.compose.foundation.border
-import androidx.compose.foundation.clickable
-import androidx.compose.foundation.horizontalScroll
-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
-import androidx.compose.foundation.layout.WindowInsets
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.heightIn
-import androidx.compose.foundation.layout.navigationBars
-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.layout.windowInsetsBottomHeight
-import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.items
-import androidx.compose.foundation.rememberScrollState
-import androidx.compose.foundation.shape.CircleShape
-import androidx.compose.foundation.verticalScroll
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material3.AlertDialog
-import androidx.compose.material3.DropdownMenu
-import androidx.compose.material3.DropdownMenuItem
-import androidx.compose.material3.FloatingActionButton
-import androidx.compose.material3.Icon
-import androidx.compose.material3.Text
-import androidx.compose.material3.TextButton
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
-import androidx.compose.runtime.setValue
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.foundation.combinedClickable
-import androidx.compose.ui.draw.clip
-import androidx.compose.ui.draw.drawBehind
-import androidx.compose.ui.geometry.Offset
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.ImageBitmap
-import androidx.compose.ui.graphics.asImageBitmap
-import androidx.compose.ui.graphics.vector.ImageVector
-import androidx.compose.ui.layout.ContentScale
-import androidx.compose.ui.res.painterResource
-import androidx.compose.ui.res.pluralStringResource
-import androidx.compose.ui.res.stringResource
-import androidx.compose.ui.semantics.Role
-import androidx.compose.ui.semantics.contentDescription
-import androidx.compose.ui.semantics.semantics
-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.unit.dp
-import androidx.compose.ui.unit.sp
-import androidx.annotation.StringRes
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.text
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.PdfBadge
-import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
-import io.github.artcraftandroid.pdfcraft.ui.SheetDivider
-import io.github.artcraftandroid.pdfcraft.ui.SheetRow
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ToolHues
-import io.github.artcraftandroid.pdfcraft.ui.viewer.formatSize
-import java.text.DateFormat
-import java.util.Calendar
-import java.util.Date
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.withContext
-
-/** The tabs along the bottom of the app. */
-enum class HomeTab(@StringRes val label: Int) { Home(R.string.home_tab_home), Files(R.string.home_tab_files), Tools(R.string.home_tab_tools), Search(R.string.home_tab_search) }
-
-/** A file as the lists show it, wherever it comes from (recent, starred, on this device). */
-data class FileRow(
- val key: String,
- val name: String,
- /** A local path to draw its thumbnail from, if there is one. */
- val thumbPath: String?,
- val location: String,
- val date: Long,
- val size: Long,
- val starred: Boolean,
- val open: () -> Unit,
-)
-
-/** The app outside the viewer: the current tab's screen over the bottom bar. */
-@Composable
-fun HomeRoot(vm: AppViewModel, onBrowse: () -> Unit) {
- val c = pdfColors
- // Home and its tabs sit on the reference's home background: white, or black in dark mode
- Column(Modifier.fillMaxSize().background(c.home)) {
- Box(Modifier.weight(1f)) {
- when (vm.homeTab) {
- HomeTab.Home -> HomeTabScreen(vm, onBrowse)
- HomeTab.Files -> FilesTab(vm, onBrowse)
- HomeTab.Tools -> ToolsTab(vm)
- HomeTab.Search -> SearchTab(vm)
- }
- }
- BottomNav(vm.homeTab) { vm.homeTab = it }
- }
-}
-
-/** The bottom bar: Home, Files, Tools, Search; the chosen one in the accent colour. */
-@Composable
-private fun BottomNav(selected: HomeTab, onSelect: (HomeTab) -> Unit) {
- val c = pdfColors
- Column(Modifier.fillMaxWidth().background(c.home).drawBehind { drawLine(c.divider, Offset(0f, 0f), Offset(size.width, 0f), 1.dp.toPx()) }) {
- Row(Modifier.fillMaxWidth().height(61.dp), horizontalArrangement = Arrangement.SpaceEvenly, verticalAlignment = Alignment.CenterVertically) {
- for (t in HomeTab.entries) {
- val icon = when (t) {
- HomeTab.Home -> LucideIcons.House
- HomeTab.Files -> LucideIcons.Folder
- HomeTab.Tools -> LucideIcons.LayoutGrid
- HomeTab.Search -> LucideIcons.Search
- }
- val tint = if (t == selected) c.toolAccent else c.icon
- val label = stringResource(t.label)
- Column(
- Modifier.weight(1f).height(61.dp).clickable(role = Role.Tab) { onSelect(t) }.semantics { contentDescription = label },
- horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.Center,
- ) {
- Icon(icon, null, tint = tint, modifier = Modifier.size(22.dp))
- Spacer(Modifier.height(5.dp))
- Text(label, color = tint, fontSize = 11.sp)
- }
- }
- }
- Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))
- }
-}
-
-/** Home: the app's name and Settings, a welcome, the tools carousel, then Recent, Starred and On device. */
-@Composable
-private fun HomeTabScreen(vm: AppViewModel, onBrowse: () -> Unit) {
- val c = pdfColors
- var tab by remember { mutableStateOf(0) }
- var fabMenu by remember { mutableStateOf(false) }
- var menu by remember { mutableStateOf(false) }
- var confirmClear by remember { mutableStateOf(false) }
- var confirmDeleteSelected by remember { mutableStateOf(false) }
- LaunchedEffect(tab) { if (tab == 2) vm.scanLocal(); vm.selectedFiles.clear() }
- androidx.activity.compose.BackHandler(enabled = vm.selectedFiles.isNotEmpty()) { vm.selectedFiles.clear() }
- if (confirmDeleteSelected) {
- val rows = vm.selectedFiles.values.toList()
- io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { confirmDeleteSelected = false },
- title = pluralStringResource(R.plurals.home_delete_files_title, rows.size, rows.size),
- confirm = stringResource(R.string.common_delete), destructive = true,
- onConfirm = { confirmDeleteSelected = false; rows.forEach(vm::deleteFile); vm.selectedFiles.clear() },
- ) { Text(stringResource(R.string.home_delete_files_body), color = c.text, fontSize = 14.sp) }
- }
- val settingsLabel = stringResource(R.string.home_settings)
- val toolsLabel = stringResource(R.string.home_tab_tools)
- Box(Modifier.fillMaxSize()) {
- Column(Modifier.fillMaxSize().safeTopPadding()) {
- if (vm.selectedFiles.isNotEmpty()) SelectionBar(vm, recent = tab == 0, onDelete = { confirmDeleteSelected = true }) else
- Row(Modifier.fillMaxWidth().height(56.dp).padding(start = 16.dp, end = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- Image(painterResource(R.drawable.ic_launcher_tile), null, modifier = Modifier.size(28.dp).clip(RoundedCornerShape(6.dp)))
- Spacer(Modifier.width(10.dp))
- Text(stringResource(R.string.app_name), color = c.text, fontSize = 20.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
- Box(
- Modifier.size(40.dp).clip(CircleShape).background(c.surfaceRaised).clickable { vm.settingsOpen = true }.semantics { contentDescription = settingsLabel },
- contentAlignment = Alignment.Center,
- ) { Icon(LucideIcons.UserRound, null, tint = c.icon, modifier = Modifier.size(22.dp)) }
- }
- LazyColumn(Modifier.weight(1f)) {
- item {
- Text(stringResource(if (vm.recentList.isEmpty()) R.string.home_welcome else R.string.home_welcome_back), color = c.text, fontSize = 24.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 16.dp, top = 8.dp, bottom = 16.dp))
- Text(stringResource(R.string.home_start_with_tool), color = c.text, fontSize = 15.sp, lineHeight = 22.sp, fontWeight = FontWeight.Medium, modifier = Modifier.padding(start = 16.dp, bottom = 8.dp))
- ToolsCarousel(vm, onBrowse)
- Spacer(Modifier.height(16.dp))
- Row(Modifier.fillMaxWidth().padding(start = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- listOf(R.string.home_list_recent, R.string.home_list_starred, R.string.home_list_on_device).forEachIndexed { i, label ->
- Column(Modifier.clickable(role = Role.Tab) { tab = i }.padding(horizontal = 10.dp), horizontalAlignment = Alignment.CenterHorizontally) {
- Text(stringResource(label), color = if (tab == i) c.text else c.textSecondary, fontSize = 15.sp, fontWeight = if (tab == i) FontWeight.SemiBold else FontWeight.Normal, modifier = Modifier.padding(vertical = 10.dp))
- Box(Modifier.width(48.dp).height(2.dp).background(if (tab == i) c.text else Color.Transparent))
- }
- }
- Spacer(Modifier.weight(1f))
- Box {
- BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.common_more_options), { menu = true })
- DropdownMenu(expanded = menu, onDismissRequest = { menu = false }, containerColor = c.surface) {
- DropdownMenuItem(text = { Text(stringResource(if (vm.gridView) R.string.home_list_view else R.string.home_grid_view)) }, onClick = { menu = false; vm.gridView = !vm.gridView })
- if (tab == 0 && vm.recentList.isNotEmpty()) DropdownMenuItem(text = { Text(stringResource(R.string.home_clear_recent)) }, onClick = { menu = false; confirmClear = true })
- if (tab == 1) {
- DropdownMenuItem(text = { Text(stringResource(R.string.home_sort_by_name)) }, onClick = { menu = false; vm.starSort = 1 })
- DropdownMenuItem(text = { Text(stringResource(R.string.home_sort_by_date)) }, onClick = { menu = false; vm.starSort = 0 })
- }
- }
- }
- }
- SheetDivider(inset = 0.dp)
- }
- val rows = when (tab) {
- 0 -> vm.recentRows()
- 1 -> vm.starredRows()
- else -> vm.localRows().take(10)
- }
- if (rows.isEmpty()) {
- item {
- when (tab) {
- 0 -> EmptyState(LucideIcons.Clock, stringResource(R.string.home_no_recent_title), stringResource(R.string.home_no_recent_body), stringResource(R.string.home_open_file), onBrowse)
- 1 -> EmptyState(LucideIcons.Star, stringResource(R.string.home_no_starred_title), stringResource(R.string.home_no_starred_body))
- else -> if (!vm.hasFileAccess) EmptyState(LucideIcons.Smartphone, stringResource(R.string.home_device_files_title), stringResource(R.string.home_device_files_body), stringResource(R.string.home_add_folder)) { vm.requestFileAccess() }
- else EmptyState(LucideIcons.Smartphone, stringResource(R.string.home_no_pdfs_title), stringResource(R.string.home_no_pdfs_body), stringResource(R.string.home_add_folder)) { vm.requestFileAccess() }
- }
- }
- } else if (vm.gridView) {
- items(rows.chunked(2)) { pair ->
- Row(Modifier.fillMaxWidth().padding(horizontal = 12.dp), horizontalArrangement = Arrangement.spacedBy(12.dp)) {
- pair.forEach { r -> FileGridCell(vm, r, Modifier.weight(1f), recent = tab == 0) }
- if (pair.size == 1) Spacer(Modifier.weight(1f))
- }
- }
- } else {
- items(rows, key = { it.key }) { r -> FileListRow(vm, r, recent = tab == 0) }
- }
- if (tab == 2 && vm.localRows().size > 10) {
- item {
- Text(stringResource(R.string.home_other_files), color = c.accent, fontWeight = FontWeight.SemiBold, modifier = Modifier.fillMaxWidth().clickable { vm.homeTab = HomeTab.Files; vm.filesShowLocal = true }.padding(16.dp))
- }
- }
- item { Spacer(Modifier.height(88.dp)) }
- }
- }
- FloatingActionButton(
- onClick = { fabMenu = true },
- containerColor = c.button,
- contentColor = Color.White,
- shape = CircleShape,
- modifier = Modifier.align(Alignment.BottomEnd).padding(16.dp).semantics { contentDescription = toolsLabel },
- ) { Icon(LucideIcons.Plus, null, modifier = Modifier.size(26.dp)) }
- }
- if (fabMenu) {
- PdfSheet(onDismiss = { fabMenu = false }, dim = true) {
- SheetRow(LucideIcons.FolderOpen, stringResource(R.string.home_open_file), { fabMenu = false; onBrowse() })
- SheetRow(LucideIcons.Camera, stringResource(R.string.home_new_scan), { fabMenu = false; vm.startScan() })
- SheetDivider()
- SheetRow(LucideIcons.FilePenLine, stringResource(R.string.common_tool_edit_pdf), { fabMenu = false; vm.toolForFile(FileTool.Edit) })
- SheetRow(LucideIcons.FilePlus2, stringResource(R.string.common_tool_create_pdf), { fabMenu = false; vm.openCreate() })
- SheetRow(LucideIcons.Combine, stringResource(R.string.common_tool_combine), { fabMenu = false; vm.pickFiles(io.github.artcraftandroid.pdfcraft.ui.FilePickKind.Combine) })
- Spacer(Modifier.height(12.dp))
- }
- }
- if (confirmClear) {
- io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { confirmClear = false }, title = stringResource(R.string.home_clear_recent_title),
- confirm = stringResource(R.string.common_clear), onConfirm = { confirmClear = false; vm.clearRecents() }, destructive = true,
- ) { Text(stringResource(R.string.home_clear_recent_body), color = c.text, fontSize = 14.sp) }
- }
-}
-
-/** A tool that starts by choosing a PDF. */
-enum class FileTool { Edit, ReadAloud, FillSign, Organize, Compress, Export, Protect, Comment, Crop, Ocr }
-
-/** The row of tools under "Start with a tool". */
-@Composable
-private fun ToolsCarousel(vm: AppViewModel, onBrowse: () -> Unit) {
- Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(16.dp)) {
- CarouselTile(LucideIcons.FolderOpen, stringResource(R.string.home_open_file), ToolHues.crop, onBrowse)
- CarouselTile(LucideIcons.FilePenLine, stringResource(R.string.common_tool_edit_pdf), ToolHues.edit) { vm.toolForFile(FileTool.Edit) }
- CarouselTile(LucideIcons.Volume2, stringResource(R.string.common_tool_read_aloud), ToolHues.read) { vm.toolForFile(FileTool.ReadAloud) }
- CarouselTile(LucideIcons.Signature, stringResource(R.string.common_tool_fill_sign), ToolHues.sign) { vm.toolForFile(FileTool.FillSign) }
- CarouselTile(LucideIcons.FilePlus2, stringResource(R.string.common_tool_create_pdf), ToolHues.create) { vm.openCreate() }
- CarouselTile(LucideIcons.LayoutGrid, stringResource(R.string.common_tool_organize), ToolHues.organize) { vm.toolForFile(FileTool.Organize) }
- CarouselTile(LucideIcons.Combine, stringResource(R.string.common_tool_combine), ToolHues.combine) { vm.pickFiles(io.github.artcraftandroid.pdfcraft.ui.FilePickKind.Combine) }
- CarouselTile(LucideIcons.FileArchive, stringResource(R.string.common_tool_compress), ToolHues.compress) { vm.toolForFile(FileTool.Compress) }
- CarouselTile(LucideIcons.FileOutput, stringResource(R.string.common_tool_export), ToolHues.export) { vm.toolForFile(FileTool.Export) }
- CarouselTile(LucideIcons.FileLock2, stringResource(R.string.common_tool_set_password), ToolHues.protect) { vm.toolForFile(FileTool.Protect) }
- }
-}
-
-@Composable
-private fun CarouselTile(icon: ImageVector, label: String, hue: Color, onClick: () -> Unit) {
- val c = pdfColors
- // 64 dp tiles 16 dp apart, the tool's hue faint behind its icon, an 11 sp name under it
- Column(Modifier.width(64.dp).clickable(role = Role.Button, onClick = onClick).padding(vertical = 8.dp).semantics { contentDescription = label }, horizontalAlignment = Alignment.CenterHorizontally) {
- Box(Modifier.size(64.dp).clip(RoundedCornerShape(5.dp)).background(tint(hue, c.dark)), contentAlignment = Alignment.Center) {
- Icon(icon, null, tint = hue, modifier = Modifier.size(32.dp))
- }
- Spacer(Modifier.height(8.dp))
- io.github.artcraftandroid.pdfcraft.ui.WordWrapLabel(label, c.text, size = 11.sp, lineHeight = 14.sp)
- }
-}
-
-fun tint(hue: Color, dark: Boolean): Color =
- if (dark) Color(hue.red * 0.22f + 0.07f, hue.green * 0.22f + 0.07f, hue.blue * 0.22f + 0.09f) else Color(hue.red * 0.12f + 0.88f, hue.green * 0.12f + 0.88f, hue.blue * 0.12f + 0.88f)
-
-/** An empty list's picture, title, line and optional action. */
-@Composable
-fun EmptyState(icon: ImageVector, title: String, body: String, action: String? = null, onAction: (() -> Unit)? = null) {
- val c = pdfColors
- Column(Modifier.fillMaxWidth().padding(horizontal = 32.dp, vertical = 40.dp), horizontalAlignment = Alignment.CenterHorizontally) {
- Box(Modifier.size(72.dp).clip(CircleShape).background(c.surfaceRaised), contentAlignment = Alignment.Center) {
- Icon(icon, null, tint = c.textSecondary, modifier = Modifier.size(34.dp))
- }
- Spacer(Modifier.height(16.dp))
- Text(title, color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, textAlign = TextAlign.Center)
- Spacer(Modifier.height(6.dp))
- Text(body, color = c.textSecondary, fontSize = 14.sp, textAlign = TextAlign.Center)
- if (action != null && onAction != null) {
- Spacer(Modifier.height(16.dp))
- Text(action, color = c.accent, fontWeight = FontWeight.SemiBold, modifier = Modifier.clickable(onClick = onAction).padding(8.dp))
- }
- }
-}
-
-/** "Just now", the time if today, "Yesterday", else a medium date. */
-fun whenLabel(t: Long): String {
- val now = System.currentTimeMillis()
- if (now - t < 60_000) return text(R.string.home_just_now)
- val cal = Calendar.getInstance().apply { timeInMillis = t }
- val today = Calendar.getInstance()
- val sameDay = cal.get(Calendar.YEAR) == today.get(Calendar.YEAR) && cal.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)
- if (sameDay) return DateFormat.getTimeInstance(DateFormat.SHORT).format(Date(t))
- today.add(Calendar.DAY_OF_YEAR, -1)
- if (cal.get(Calendar.YEAR) == today.get(Calendar.YEAR) && cal.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)) return text(R.string.common_yesterday)
- return DateFormat.getDateInstance(DateFormat.MEDIUM).format(Date(t))
-}
-
-/** A document's first page, or the PDF badge while it draws (or when it can't). */
-@Composable
-fun FileThumb(vm: AppViewModel, path: String?, width: Int, height: Int) {
- var img by remember(path) { mutableStateOf<ImageBitmap?>(null) }
- LaunchedEffect(path) {
- if (path != null) img = withContext(Dispatchers.IO) { vm.thumbnails.of(path)?.asImageBitmap() }
- }
- val c = pdfColors
- Box(Modifier.size(width.dp, height.dp).clip(RoundedCornerShape(4.dp)).background(if (img != null) Color.White else c.surfaceRaised).border(1.dp, c.divider, RoundedCornerShape(4.dp)), contentAlignment = Alignment.Center) {
- val i = img
- if (i != null) Image(i, null, modifier = Modifier.size(width.dp, height.dp), contentScale = ContentScale.Crop) else PdfBadge((width * 0.55f).toInt())
- }
-}
-
-@Composable
-@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
-fun FileListRow(vm: AppViewModel, r: FileRow, recent: Boolean = false) {
- val c = pdfColors
- val selecting = vm.selectedFiles.isNotEmpty()
- val ticked = r.key in vm.selectedFiles
- // a long press ticks the file (several can then be shared, combined or deleted together)
- Row(
- Modifier.fillMaxWidth()
- .background(if (ticked) c.toolAccent.copy(alpha = 0.12f) else Color.Transparent)
- .combinedClickable(onClick = { if (selecting) vm.toggleSelected(r) else r.open() }, onLongClick = { vm.toggleSelected(r) })
- .padding(start = 12.dp, end = 4.dp, top = 12.dp, bottom = 12.dp),
- verticalAlignment = Alignment.CenterVertically,
- ) {
- Box(Modifier.width(48.dp), contentAlignment = Alignment.Center) { FileThumb(vm, r.thumbPath, 36, 42) }
- Spacer(Modifier.width(12.dp))
- Column(Modifier.weight(1f)) {
- Row(verticalAlignment = Alignment.CenterVertically) {
- Text(r.name.removeSuffix(".pdf").removeSuffix(".PDF"), color = c.text, fontSize = 17.sp, fontWeight = FontWeight.Medium, maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
- if (r.starred) {
- Spacer(Modifier.width(6.dp))
- Icon(LucideIcons.Star, stringResource(R.string.home_starred_description), tint = Color(0xFFF5B800), modifier = Modifier.size(14.dp))
- }
- }
- Spacer(Modifier.height(2.dp))
- Row(verticalAlignment = Alignment.CenterVertically) {
- // where it is, then type, date and size: "PDF • Yesterday • 2.3 MB"
- Icon(LucideIcons.Smartphone, stringResource(R.string.home_stored_on, r.location), tint = c.textTertiary, modifier = Modifier.size(14.dp))
- Spacer(Modifier.width(6.dp))
- Text(listOfNotNull("PDF", whenLabel(r.date), r.size.takeIf { it > 0 }?.let { formatSize(it) }).joinToString(" • "), color = c.textTertiary, fontSize = 13.sp, fontWeight = FontWeight.Medium, maxLines = 1)
- }
- }
- if (selecting) {
- Box(Modifier.size(48.dp), contentAlignment = Alignment.Center) { SelectBox(ticked) }
- } else {
- BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.home_more_options_for, r.name), { vm.fileSheet = r to recent })
- }
- }
-}
-
-/** A round tick for a ticked file, an empty ring for the others. */
-@Composable
-private fun SelectBox(ticked: Boolean) {
- val c = pdfColors
- Box(
- Modifier.size(22.dp).clip(CircleShape).background(if (ticked) c.toolAccent else Color.Transparent)
- .border(2.dp, if (ticked) c.toolAccent else c.textSecondary, CircleShape),
- contentAlignment = Alignment.Center,
- ) { if (ticked) Icon(LucideIcons.Check, null, tint = Color.White, modifier = Modifier.size(14.dp)) }
-}
-
-/** Home's bar while files are ticked: how many, Share, Combine, and the rest in a menu. */
-@Composable
-private fun SelectionBar(vm: AppViewModel, recent: Boolean, onDelete: () -> Unit) {
- val c = pdfColors
- val rows = vm.selectedFiles.values.toList()
- var menu by remember { mutableStateOf(false) }
- Row(Modifier.fillMaxWidth().height(56.dp).padding(horizontal = 4.dp), verticalAlignment = Alignment.CenterVertically) {
- BarIcon(LucideIcons.X, stringResource(R.string.home_clear_selection), { vm.selectedFiles.clear() })
- Text(pluralStringResource(R.plurals.home_files_selected, rows.size, rows.size), color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f).padding(start = 8.dp))
- BarIcon(LucideIcons.Share2, stringResource(R.string.common_share), { vm.shareFiles(rows); vm.selectedFiles.clear() })
- if (rows.size >= 2) BarIcon(LucideIcons.Combine, stringResource(R.string.common_tool_combine), { vm.combineSelected(rows); vm.selectedFiles.clear() })
- Box {
- BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.common_more_options), { menu = true })
- DropdownMenu(expanded = menu, onDismissRequest = { menu = false }, containerColor = c.surface) {
- if (recent) DropdownMenuItem(text = { Text(stringResource(R.string.home_remove_from_recent)) }, onClick = { menu = false; vm.removeRecents(rows); vm.selectedFiles.clear() })
- DropdownMenuItem(text = { Text(stringResource(R.string.common_delete), color = c.red) }, onClick = { menu = false; onDelete() })
- }
- }
- }
-}
-
-@Composable
-private fun FileGridCell(vm: AppViewModel, r: FileRow, modifier: Modifier, recent: Boolean) {
- val c = pdfColors
- Column(modifier.clickable(onClick = r.open).padding(vertical = 8.dp)) {
- Box(Modifier.fillMaxWidth().heightIn(min = 160.dp), contentAlignment = Alignment.Center) { FileThumb(vm, r.thumbPath, 120, 156) }
- Row(verticalAlignment = Alignment.CenterVertically) {
- Column(Modifier.weight(1f).padding(start = 4.dp)) {
- Text(r.name.removeSuffix(".pdf"), color = c.text, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
- Text(whenLabel(r.date), color = c.textSecondary, fontSize = 12.sp)
- }
- BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.home_more_options_for, r.name), { vm.fileSheet = r to recent }, size = 40.dp)
- }
- }
-}
-
-/**
- * A file's "..." sheet: its tools, then Share, Print, Open with, Star, Rename, Duplicate, Save a
- * copy, Remove from recent (Recent) and Delete.
- */
-@Composable
-fun FileSheet(vm: AppViewModel, r: FileRow, recent: Boolean, onDismiss: () -> Unit) {
- val c = pdfColors
- var renaming by remember { mutableStateOf(false) }
- var deleting by remember { mutableStateOf(false) }
- fun act(f: () -> Unit) {
- onDismiss()
- f()
- }
- PdfSheet(onDismiss = onDismiss, maxHeightFraction = 0.85f) {
- Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- FileThumb(vm, r.thumbPath, 32, 42)
- Spacer(Modifier.width(14.dp))
- Text(r.name.removeSuffix(".pdf"), color = c.text, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, maxLines = 2, overflow = TextOverflow.Ellipsis)
- }
- SheetDivider()
- Column(Modifier.verticalScroll(rememberScrollState())) {
- SheetRow(LucideIcons.FilePenLine, stringResource(R.string.common_tool_edit_pdf), { act { vm.openFor(r, FileTool.Edit) } })
- SheetRow(LucideIcons.Volume2, stringResource(R.string.common_tool_read_aloud), { act { vm.openFor(r, FileTool.ReadAloud) } })
- SheetRow(LucideIcons.FileOutput, stringResource(R.string.home_export_as), { act { vm.openFor(r, FileTool.Export) } })
- SheetRow(LucideIcons.FileArchive, stringResource(R.string.common_tool_compress), { act { vm.openFor(r, FileTool.Compress) } })
- SheetRow(LucideIcons.FileLock2, stringResource(R.string.common_tool_set_password), { act { vm.openFor(r, FileTool.Protect) } })
- SheetDivider()
- SheetRow(LucideIcons.Share2, stringResource(R.string.common_share), { act { vm.shareFile(r) } })
- SheetRow(LucideIcons.Printer, stringResource(R.string.home_print), { act { vm.printFile(r) } })
- SheetRow(LucideIcons.ExternalLink, stringResource(R.string.home_open_with), { act { vm.openWith(r) } })
- SheetRow(LucideIcons.Star, stringResource(if (r.starred) R.string.home_unstar else R.string.home_star), { act { vm.setStarred(r.key, !r.starred) } })
- SheetRow(LucideIcons.Pencil, stringResource(R.string.common_rename), { renaming = true })
- SheetRow(LucideIcons.Copy, stringResource(R.string.home_duplicate), { act { vm.duplicateFile(r) } })
- SheetRow(LucideIcons.FileDown, stringResource(R.string.common_save_copy), { act { vm.saveFileCopy(r) } })
- if (recent) SheetRow(LucideIcons.X, stringResource(R.string.home_remove_from_recent), { act { vm.removeRecent(r.key) } })
- SheetRow(LucideIcons.Trash2, stringResource(R.string.common_delete), { deleting = true }, tint = c.red)
- Spacer(Modifier.height(8.dp))
- }
- }
- if (renaming) {
- var name by remember { mutableStateOf(r.name.removeSuffix(".pdf")) }
- io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { renaming = false }, title = stringResource(R.string.common_rename),
- confirm = stringResource(R.string.common_done), onConfirm = { renaming = false; onDismiss(); vm.renameFile(r, name) }, confirmEnabled = name.isNotBlank() && !name.startsWith("."),
- ) { io.github.artcraftandroid.pdfcraft.ui.PdfField(name, { name = it }, stringResource(R.string.home_enter_name)) }
- }
- if (deleting) {
- io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { deleting = false }, title = stringResource(R.string.home_delete_file_title),
- confirm = stringResource(R.string.common_delete), onConfirm = { deleting = false; onDismiss(); vm.deleteFile(r) }, destructive = true,
- ) { Text(stringResource(R.string.home_delete_file_body, r.name), color = c.text, fontSize = 14.sp) }
- }
-}
-
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.kt
deleted file mode 100644
index 26a2bbe..0000000
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.kt
+++ /dev/null
@@ -1,440 +0,0 @@
-package io.github.artcraftandroid.pdfcraft.ui.home
-
-import io.github.artcraftandroid.pdfcraft.ui.safeTopPadding
-import androidx.activity.compose.BackHandler
-import androidx.compose.foundation.background
-import androidx.compose.foundation.clickable
-import androidx.compose.foundation.horizontalScroll
-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
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.navigationBarsPadding
-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.lazy.LazyColumn
-import androidx.compose.foundation.lazy.grid.GridCells
-import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
-import androidx.compose.foundation.lazy.grid.items
-import androidx.compose.foundation.lazy.items
-import androidx.compose.foundation.rememberScrollState
-import androidx.compose.foundation.shape.CircleShape
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.foundation.text.BasicTextField
-import androidx.compose.foundation.verticalScroll
-import androidx.compose.material3.AlertDialog
-import androidx.compose.material3.DropdownMenu
-import androidx.compose.material3.DropdownMenuItem
-import androidx.compose.material3.HorizontalDivider
-import androidx.compose.material3.Icon
-import androidx.compose.material3.OutlinedTextField
-import androidx.compose.material3.Text
-import androidx.compose.material3.TextButton
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
-import androidx.compose.runtime.setValue
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.foundation.layout.heightIn
-import androidx.compose.foundation.border
-import androidx.compose.ui.draw.clip
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.SolidColor
-import androidx.compose.ui.graphics.vector.ImageVector
-import androidx.compose.ui.input.pointer.pointerInput
-import androidx.compose.foundation.gestures.detectTapGestures
-import androidx.compose.ui.platform.LocalClipboardManager
-import androidx.compose.ui.platform.LocalUriHandler
-import androidx.compose.ui.res.pluralStringResource
-import androidx.compose.ui.res.stringResource
-import androidx.compose.ui.semantics.Role
-import androidx.compose.ui.semantics.contentDescription
-import androidx.compose.ui.semantics.semantics
-import androidx.compose.ui.text.AnnotatedString
-import androidx.compose.ui.text.TextStyle
-import androidx.compose.ui.text.font.FontWeight
-import androidx.compose.ui.text.style.TextOverflow
-import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
-import androidx.annotation.StringRes
-import io.github.artcraftandroid.pdfcraft.R
-import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
-import io.github.artcraftandroid.pdfcraft.ui.BarIcon
-import io.github.artcraftandroid.pdfcraft.ui.Inter
-import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
-import io.github.artcraftandroid.pdfcraft.ui.PdfSwitch
-import io.github.artcraftandroid.pdfcraft.ui.SheetDivider
-import io.github.artcraftandroid.pdfcraft.ui.SheetRow
-import io.github.artcraftandroid.pdfcraft.ui.pdfColors
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ToolHues
-
-/** Files: the places files come from; On this device lists every PDF on the phone by folder. */
-@Composable
-fun FilesTab(vm: AppViewModel, onBrowse: () -> Unit) {
- val c = pdfColors
- if (vm.filesShowLocal) {
- OnThisDevice(vm)
- return
- }
- Column(Modifier.fillMaxSize().safeTopPadding()) {
- // a large title, as the expanded bar of the reference shows it
- Box(Modifier.fillMaxWidth().height(128.dp), contentAlignment = Alignment.BottomStart) {
- Text(stringResource(R.string.home_tab_files), color = c.label, fontSize = 24.sp, fontWeight = FontWeight.Bold, modifier = Modifier.padding(start = 16.dp, bottom = 40.dp))
- }
- LocationRow(LucideIcons.Smartphone, stringResource(R.string.home_on_this_device)) { vm.filesShowLocal = true }
- LocationRow(LucideIcons.Image, stringResource(R.string.home_photos)) { vm.pickPhotosToPdf() }
- LocationRow(LucideIcons.FolderOpen, stringResource(R.string.home_look_in_other_folders), onBrowse)
- }
-}
-
-@Composable
-private fun LocationRow(icon: ImageVector, label: String, onClick: () -> Unit) {
- val c = pdfColors
- Row(Modifier.fillMaxWidth().heightIn(min = 62.dp).clickable(onClick = onClick).padding(start = 16.dp, end = 16.dp), verticalAlignment = Alignment.CenterVertically) {
- Icon(icon, null, tint = c.icon, modifier = Modifier.size(22.dp))
- Spacer(Modifier.width(16.dp))
- Text(label, color = c.text, fontSize = 17.sp, modifier = Modifier.weight(1f))
- }
-}
-
-/** On this device: every PDF found on the phone, newest first, under its folder's name. */
-@Composable
-private fun OnThisDevice(vm: AppViewModel) {
- val c = pdfColors
- BackHandler { vm.filesShowLocal = false }
- LaunchedEffect(Unit) { vm.scanLocal() }
- var sort by remember { mutableStateOf(0) }
- var menu by remember { mutableStateOf(false) }
- Column(Modifier.fillMaxSize().safeTopPadding()) {
- Row(Modifier.fillMaxWidth().height(56.dp), verticalAlignment = Alignment.CenterVertically) {
- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), { vm.filesShowLocal = false }) }
- Text(stringResource(R.string.home_on_this_device), color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
- BarIcon(LucideIcons.RotateCw, stringResource(R.string.home_refresh), { vm.scanLocal(force = true) })
- Box {
- BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.common_more_options), { menu = true })
- DropdownMenu(expanded = menu, onDismissRequest = { menu = false }, containerColor = c.surface) {
- DropdownMenuItem(text = { Text(stringResource(R.string.home_sort_by_name)) }, onClick = { sort = 1; menu = false }, trailingIcon = { if (sort == 1) Icon(LucideIcons.Check, null, tint = c.accent) })
- DropdownMenuItem(text = { Text(stringResource(R.string.home_sort_by_date)) }, onClick = { sort = 0; menu = false }, trailingIcon = { if (sort == 0) Icon(LucideIcons.Check, null, tint = c.accent) })
- HorizontalDivider(color = c.divider)
- DropdownMenuItem(text = { Text(stringResource(R.string.home_add_folder)) }, onClick = { menu = false; vm.requestFileAccess() }, leadingIcon = { Icon(LucideIcons.FolderPlus, null, tint = c.icon) })
- // the folders listed here, each with a way to stop listing it
- for ((tree, name) in vm.localFolders()) {
- DropdownMenuItem(text = { Text(stringResource(R.string.home_stop_listing, name)) }, onClick = { menu = false; vm.removeLocalFolder(tree) }, leadingIcon = { Icon(LucideIcons.Folder, null, tint = c.icon) })
- }
- }
- }
- }
- val rows = vm.localRows().let { if (sort == 1) it.sortedBy { r -> r.name.lowercase() } else it }
- // what PdfCraft saved itself shows before any folder is added
- if (!vm.hasFileAccess && rows.isEmpty()) {
- EmptyState(LucideIcons.Smartphone, stringResource(R.string.home_device_files_title), stringResource(R.string.home_device_files_body_long), stringResource(R.string.home_add_folder)) { vm.requestFileAccess() }
- return@Column
- }
- if (rows.isEmpty()) {
- if (vm.scanning) EmptyState(LucideIcons.FileText, stringResource(R.string.home_looking_for_pdfs), "")
- else EmptyState(LucideIcons.FileText, stringResource(R.string.home_no_pdfs_title), stringResource(R.string.home_no_pdfs_body), stringResource(R.string.home_add_folder)) { vm.requestFileAccess() }
- return@Column
- }
- LazyColumn(Modifier.weight(1f)) {
- val groups = rows.groupBy { it.location }
- for ((folder, list) in groups) {
- item(key = "h-$folder") {
- val internalStorage = stringResource(R.string.home_internal_storage)
- Text(folder.uppercase().ifEmpty { internalStorage }, color = c.textSecondary, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 16.dp, top = 16.dp, bottom = 4.dp))
- }
- items(list, key = { it.key }) { r -> FileListRow(vm, r) }
- }
- item { Spacer(Modifier.height(24.dp)) }
- }
- }
-}
-
-/** A tool of the Tools tab: its tile, name and one line about it ([name] is its key, [label] what is shown). */
-private class HubTool(val icon: ImageVector, val name: String, @StringRes val label: Int, @StringRes val about: Int, val hue: Color, val categories: Set<String>, val go: () -> Unit)
-
-/** Where a category lists its tools in an order of its own (the rest keep the All order). */
-private val CategoryOrder = mapOf(
- "Edit" to listOf("Edit PDF", "Crop pages", "Organize pages", "Combine files", "Set password"),
- "Convert" to listOf("Export PDF", "Compress PDF"),
-)
-
-/** Tools: every tool, by category (All, Read, Create, Edit, Convert), as outlined cards. */
-@Composable
-fun ToolsTab(vm: AppViewModel) {
- val c = pdfColors
- val categories = listOf(
- "All" to R.string.home_category_all, "Read" to R.string.home_category_read, "Create" to R.string.home_category_create,
- "Edit" to R.string.home_category_edit, "Convert" to R.string.home_category_convert,
- )
- var cat by remember { mutableStateOf("All") }
- val tools = remember {
- listOf(
- HubTool(LucideIcons.Signature, "Fill & Sign", R.string.common_tool_fill_sign, R.string.home_about_fill_sign, ToolHues.sign, emptySet()) { vm.toolForFile(FileTool.FillSign) },
- HubTool(LucideIcons.MessageSquareText, "Add comment", R.string.home_tool_add_comment, R.string.home_about_comment, ToolHues.comment, emptySet()) { vm.toolForFile(FileTool.Comment) },
- HubTool(LucideIcons.Volume2, "Read aloud", R.string.common_tool_read_aloud, R.string.home_about_read_aloud, ToolHues.read, setOf("Read")) { vm.toolForFile(FileTool.ReadAloud) },
- HubTool(LucideIcons.FilePlus2, "Create PDF", R.string.common_tool_create_pdf, R.string.home_about_create, ToolHues.create, setOf("Create")) { vm.openCreate() },
- HubTool(LucideIcons.Camera, "New scan", R.string.home_new_scan, R.string.home_about_scan, ToolHues.scan, setOf("Create")) { vm.startScan() },
- HubTool(LucideIcons.Combine, "Combine files", R.string.common_tool_combine, R.string.home_about_combine, ToolHues.combine, setOf("Create", "Edit")) { vm.pickFiles(io.github.artcraftandroid.pdfcraft.ui.FilePickKind.Combine) },
- HubTool(LucideIcons.LayoutGrid, "Organize pages", R.string.common_tool_organize, R.string.home_about_organize, ToolHues.organize, setOf("Edit")) { vm.toolForFile(FileTool.Organize) },
- HubTool(LucideIcons.Crop, "Crop pages", R.string.common_tool_crop, R.string.home_about_crop, ToolHues.crop, setOf("Edit")) { vm.toolForFile(FileTool.Crop) },
- HubTool(LucideIcons.FilePenLine, "Edit PDF", R.string.common_tool_edit_pdf, R.string.home_about_edit, ToolHues.edit, setOf("Edit")) { vm.toolForFile(FileTool.Edit) },
- HubTool(LucideIcons.FileArchive, "Compress PDF", R.string.common_tool_compress, R.string.home_about_compress, ToolHues.compress, setOf("Convert")) { vm.toolForFile(FileTool.Compress) },
- HubTool(LucideIcons.FileOutput, "Export PDF", R.string.common_tool_export, R.string.home_about_export, ToolHues.export, setOf("Convert")) { vm.toolForFile(FileTool.Export) },
- HubTool(LucideIcons.FileLock2, "Set password", R.string.common_tool_set_password, R.string.home_about_protect, ToolHues.protect, setOf("Edit")) { vm.toolForFile(FileTool.Protect) },
- )
- }
- Column(Modifier.fillMaxSize().safeTopPadding()) {
- Text(stringResource(R.string.home_tab_tools), color = c.label, fontSize = 27.sp, lineHeight = 35.sp, fontWeight = FontWeight.Bold, modifier = Modifier.padding(start = 16.dp, top = 12.dp, bottom = 12.dp))
- // text tabs with a 2 dp underline under the chosen one
- Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(24.dp)) {
- for ((k, label) in categories) {
- Column(Modifier.clickable(role = Role.Tab) { cat = k }.width(androidx.compose.foundation.layout.IntrinsicSize.Max)) {
- Text(stringResource(label), color = if (k == cat) c.label else c.textTertiary, fontSize = 17.sp, lineHeight = 25.sp, fontWeight = if (k == cat) FontWeight.SemiBold else FontWeight.Normal)
- Spacer(Modifier.height(14.dp))
- Box(Modifier.fillMaxWidth().height(2.dp).background(if (k == cat) c.label else Color.Transparent))
- }
- }
- }
- Spacer(Modifier.height(16.dp))
- LazyVerticalGrid(
- GridCells.Adaptive(140.dp), modifier = Modifier.weight(1f).padding(horizontal = 16.dp),
- horizontalArrangement = Arrangement.spacedBy(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp),
- ) {
- items(tools.filter { cat == "All" || cat in it.categories }.sortedBy { t -> CategoryOrder[cat]?.indexOf(t.name)?.takeIf { it >= 0 } ?: Int.MAX_VALUE }) { t ->
- val name = stringResource(t.label)
- Column(
- Modifier.fillMaxWidth().clip(RoundedCornerShape(12.dp)).background(c.surface)
- .border(1.dp, c.divider, RoundedCornerShape(12.dp)).clickable(onClick = t.go).padding(16.dp).semantics { contentDescription = name },
- ) {
- Box(Modifier.size(64.dp).clip(RoundedCornerShape(5.dp)).background(tint(t.hue, c.dark)), contentAlignment = Alignment.Center) {
- Icon(t.icon, null, tint = t.hue, modifier = Modifier.size(32.dp))
- }
- Spacer(Modifier.height(12.dp))
- Text(name, color = c.label, fontSize = 15.sp, lineHeight = 20.sp, fontWeight = FontWeight.SemiBold)
- Text(stringResource(t.about), color = c.label, fontSize = 15.sp, lineHeight = 21.sp)
- }
- }
- item { Spacer(Modifier.height(8.dp)) }
- }
- }
-}
-
-/** Search: file names on the phone and in Recent, with the reference's sort choices. */
-@Composable
-fun SearchTab(vm: AppViewModel) {
- val c = pdfColors
- var query by remember { mutableStateOf("") }
- var sort by remember { mutableStateOf(0) }
- var menu by remember { mutableStateOf(false) }
- LaunchedEffect(Unit) { vm.scanLocal() }
- val searchHint = stringResource(R.string.home_search_your_files)
- // the orders results can be sorted in, by [sort]
- val sorts = listOf(R.string.home_sort_relevant, R.string.home_sort_name_az, R.string.home_sort_name_za, R.string.home_sort_oldest, R.string.home_sort_newest)
- Column(Modifier.fillMaxSize().safeTopPadding()) {
- Row(Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 8.dp).clip(CircleShape).background(c.surfaceRaised).padding(horizontal = 14.dp, vertical = 10.dp), verticalAlignment = Alignment.CenterVertically) {
- Icon(LucideIcons.Search, null, tint = c.textSecondary, modifier = Modifier.size(20.dp))
- Spacer(Modifier.width(10.dp))
- BasicTextField(
- value = query, onValueChange = { query = it }, singleLine = true,
- keyboardOptions = androidx.compose.foundation.text.KeyboardOptions(imeAction = androidx.compose.ui.text.input.ImeAction.Search),
- keyboardActions = androidx.compose.foundation.text.KeyboardActions(onSearch = { vm.addRecentSearch(query) }),
- textStyle = TextStyle(fontFamily = Inter, fontSize = 16.sp, color = c.text), cursorBrush = SolidColor(c.accent),
- modifier = Modifier.weight(1f).semantics { contentDescription = searchHint },
- decorationBox = { inner -> Box { if (query.isEmpty()) Text(searchHint, color = c.textSecondary, fontSize = 16.sp); inner() } },
- )
- if (query.isNotEmpty()) BarIcon(LucideIcons.X, stringResource(R.string.common_clear), { query = "" }, size = 32.dp)
- }
- if (query.isBlank()) {
- val recent = vm.recentSearches
- if (recent.isEmpty()) {
- EmptyState(LucideIcons.Search, searchHint, stringResource(R.string.home_search_empty_body))
- return@Column
- }
- // the last searches, to run again with a tap
- Row(Modifier.fillMaxWidth().padding(start = 16.dp, end = 4.dp), verticalAlignment = Alignment.CenterVertically) {
- Text(stringResource(R.string.home_recent_searches), color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
- Text(stringResource(R.string.common_clear), color = c.toolAccent, fontSize = 15.sp, modifier = Modifier.clickable { vm.clearRecentSearches() }.padding(12.dp))
- }
- LazyColumn(Modifier.weight(1f)) {
- items(recent, key = { it }) { q ->
- Row(Modifier.fillMaxWidth().height(52.dp).clickable { query = q }.padding(start = 16.dp, end = 4.dp), verticalAlignment = Alignment.CenterVertically) {
- Icon(LucideIcons.Clock, null, tint = c.icon, modifier = Modifier.size(22.dp))
- Spacer(Modifier.width(16.dp))
- Text(q, color = c.text, fontSize = 16.sp, maxLines = 1, modifier = Modifier.weight(1f))
- BarIcon(LucideIcons.X, stringResource(R.string.home_remove_search, q), { vm.removeRecentSearch(q) }, size = 40.dp)
- }
- }
- }
- return@Column
- }
- // a search left in place for a moment counts as one made
- LaunchedEffect(query) {
- kotlinx.coroutines.delay(2000)
- if (vm.searchFiles(query).isNotEmpty()) vm.addRecentSearch(query)
- }
- val results = vm.searchFiles(query).let { list ->
- when (sort) {
- 1 -> list.sortedBy { it.name.lowercase() }
- 2 -> list.sortedByDescending { it.name.lowercase() }
- 3 -> list.sortedBy { it.date }
- 4 -> list.sortedByDescending { it.date }
- // most relevant: names starting with the search first, then the newest
- else -> list.sortedWith(compareBy<FileRow> { !it.name.lowercase().startsWith(query.trim().lowercase()) }.thenByDescending { it.date })
- }
- }
- Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp), verticalAlignment = Alignment.CenterVertically) {
- Text(pluralStringResource(R.plurals.home_search_results, results.size, results.size), color = c.text, fontSize = 15.sp, modifier = Modifier.weight(1f))
- Box {
- Row(Modifier.clickable { menu = true }.padding(vertical = 10.dp), verticalAlignment = Alignment.CenterVertically) {
- Text(stringResource(sorts[sort]), color = c.label, fontSize = 15.sp)
- Spacer(Modifier.width(4.dp))
- Icon(LucideIcons.ArrowUpDown, null, tint = c.icon, modifier = Modifier.size(18.dp))
- }
- DropdownMenu(expanded = menu, onDismissRequest = { menu = false }, containerColor = c.surface) {
- sorts.forEachIndexed { i, s ->
- DropdownMenuItem(text = { Text(stringResource(s)) }, onClick = { sort = i; menu = false }, trailingIcon = { if (sort == i) Icon(LucideIcons.Check, null, tint = c.accent) })
- }
- }
- }
- }
- if (results.isEmpty()) {
- EmptyState(LucideIcons.FileSearch, stringResource(R.string.home_no_results), stringResource(R.string.home_no_results_body))
- } else {
- LazyColumn(Modifier.weight(1f)) { items(results, key = { it.key }) { r -> FileListRow(vm, r) } }
- }
- }
-}
-
-/** Settings: About, Preferences, Help & Support. */
-@Composable
-fun SettingsScreen(vm: AppViewModel) {
- val c = pdfColors
- var page by remember { mutableStateOf("root") }
- BackHandler { if (page == "root") vm.settingsOpen = false else page = "root" }
- Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().navigationBarsPadding()) {
- Row(Modifier.fillMaxWidth().height(56.dp), verticalAlignment = Alignment.CenterVertically) {
- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) {
- BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), { if (page == "root") vm.settingsOpen = false else page = "root" })
- }
- Text(stringResource(when (page) { "about" -> R.string.home_about_app; "prefs" -> R.string.home_preferences; "help" -> R.string.home_help_support; else -> R.string.home_settings }), color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold)
- }
- Column(Modifier.verticalScroll(rememberScrollState())) {
- when (page) {
- "root" -> {
- SheetRow(LucideIcons.Info, stringResource(R.string.home_about_app), { page = "about" }, chevron = true)
- SheetRow(LucideIcons.Settings, stringResource(R.string.home_preferences), { page = "prefs" }, chevron = true)
- SheetRow(LucideIcons.CircleHelp, stringResource(R.string.home_help_support), { page = "help" }, chevron = true)
- }
- "prefs" -> Preferences(vm)
- "about" -> About(vm)
- "help" -> {
- val uri = LocalUriHandler.current
- var leaving by remember { mutableStateOf<String?>(null) }
- SheetRow(LucideIcons.CircleHelp, stringResource(R.string.home_help), { leaving = "$APP_REPO#readme" })
- SheetRow(LucideIcons.MessageSquare, stringResource(R.string.home_report_problem), { leaving = "$APP_REPO/issues" })
- leaving?.let { url ->
- io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { leaving = null }, title = stringResource(R.string.home_leaving_title), confirm = stringResource(R.string.home_continue), onConfirm = { leaving = null; uri.openUri(url) },
- ) { Text(stringResource(R.string.home_leaving_body), color = c.text, fontSize = 14.sp) }
- }
- }
- }
- }
- }
-}
-
-@Composable
-private fun Preferences(vm: AppViewModel) {
- val c = pdfColors
- var authorDialog by remember { mutableStateOf(false) }
- Section(stringResource(R.string.home_section_notifications))
- Text(stringResource(R.string.home_no_notifications), color = c.textSecondary, fontSize = 14.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 6.dp))
- SheetDivider()
- Section(stringResource(R.string.home_section_suggestions))
- SheetRow(null, stringResource(R.string.home_offer_suggestions), { vm.updateFormSuggestions(!vm.formSuggestions) }) {
- PdfSwitch(vm.formSuggestions, { vm.updateFormSuggestions(it) })
- }
- SheetRow(null, stringResource(R.string.home_clear_suggestions), { vm.clearFormSuggestions() })
- SheetDivider()
- Section(stringResource(R.string.home_author_title))
- val authorHint = stringResource(R.string.home_author_hint)
- SheetRow(null, vm.toolPrefs.author.ifBlank { authorHint }, { authorDialog = true })
- SheetDivider()
- Section(stringResource(R.string.home_section_screen))
- SheetRow(null, stringResource(R.string.home_keep_screen_on), { vm.updateKeepScreenOn(!vm.keepScreenOn) }) {
- PdfSwitch(vm.keepScreenOn, { vm.updateKeepScreenOn(it) })
- }
- Text(stringResource(R.string.home_keep_screen_on_body), color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp))
- SheetDivider()
- Section(stringResource(R.string.home_section_keyboard))
- SheetRow(null, stringResource(R.string.home_keyboard_shortcuts), { vm.updateKeyboardShortcuts(!vm.keyboardShortcuts) }) {
- PdfSwitch(vm.keyboardShortcuts, { vm.updateKeyboardShortcuts(it) })
- }
- Text(
- stringResource(R.string.home_keyboard_shortcuts_body),
- color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp),
- )
- SheetDivider()
- // what PdfCraft does differently from the reference, each by choice
- Section(stringResource(R.string.home_section_extra))
- Text(stringResource(R.string.home_extra_body), color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp))
- SheetRow(null, stringResource(R.string.home_status_bar_in_documents), { vm.updateStatusBarInDocuments(!vm.statusBarInDocuments) }) {
- PdfSwitch(vm.statusBarInDocuments, { vm.updateStatusBarInDocuments(it) })
- }
- Text(stringResource(R.string.home_status_bar_in_documents_body), color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp))
- Spacer(Modifier.height(8.dp))
- SheetRow(null, stringResource(R.string.home_search_count), { vm.updateSearchCount(!vm.searchCount) }) {
- PdfSwitch(vm.searchCount, { vm.updateSearchCount(it) })
- }
- Text(stringResource(R.string.home_search_count_body), color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp))
- Spacer(Modifier.height(24.dp))
- if (authorDialog) {
- var name by remember { mutableStateOf(vm.toolPrefs.author) }
- io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { authorDialog = false }, title = stringResource(R.string.home_author_title),
- confirm = stringResource(R.string.common_ok), onConfirm = { vm.toolPrefs.author = name.trim(); authorDialog = false; vm.prefsChanged++ },
- ) { io.github.artcraftandroid.pdfcraft.ui.PdfField(name, { name = it }, stringResource(R.string.common_your_name)) }
- }
-}
-
-/** PdfCraft for Android's own repository: its help, its issues and its source. */
-private const val APP_REPO = "https://github.com/artcraft-android/pdfcraft-android"
-
-@Composable
-private fun Section(title: String) {
- Text(title, color = pdfColors.accent, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 16.dp, bottom = 4.dp))
-}
-
-@Composable
-private fun About(vm: AppViewModel) {
- val c = pdfColors
- val clipboard = LocalClipboardManager.current
- val uri = LocalUriHandler.current
- Section(stringResource(R.string.home_section_about))
- val version = stringResource(R.string.home_version, vm.appVersion, io.github.artcraftandroid.pdfcraft.core.engineVersion())
- val copied = stringResource(R.string.home_version_copied)
- Text(
- version, color = c.text, fontSize = 16.sp,
- modifier = Modifier.fillMaxWidth()
- .pointerInput(version) { detectTapGestures(onLongPress = { clipboard.setText(AnnotatedString(version)); vm.tell(copied) }) }
- .padding(horizontal = 20.dp, vertical = 12.dp),
- )
- SheetDivider()
- Section(stringResource(R.string.home_section_legal))
- SheetRow(null, stringResource(R.string.home_licences), { vm.showLicences = true })
- SheetRow(null, stringResource(R.string.home_source_code), { uri.openUri(APP_REPO) })
- SheetRow(null, stringResource(R.string.home_engine), { uri.openUri("https://github.com/storytold/pdfcraft") })
- Text(
- stringResource(R.string.home_legal_notice),
- color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(20.dp), overflow = TextOverflow.Visible,
- )
-}
diff --git a/apps/pdfcraft-android/android/app/src/main/res/font/bricolage.ttf b/apps/pdfcraft-android/android/app/src/main/res/font/bricolage.ttf
new file mode 100644
index 0000000..9a4ca27
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/font/bricolage.ttf differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/apps/pdfcraft-android/android/app/src/main/res/mipmap-anydpi/ic_launcher.xml
deleted file mode 100644
index 706e712..0000000
--- a/apps/pdfcraft-android/android/app/src/main/res/mipmap-anydpi/ic_launcher.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- PdfCraft's own icon (assets/app-icon/hicolor/512x512, copied in by the build as
- drawable/ic_launcher_tile): the tile inset to the 72 dp a launcher shows, on its crimson. -->
-<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
- <background android:drawable="@color/ic_launcher_background" />
- <foreground>
- <inset
- android:drawable="@drawable/ic_launcher_tile"
- android:inset="18dp" />
- </foreground>
-</adaptive-icon>
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/apps/pdfcraft-android/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..b4a729e
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/apps/pdfcraft-android/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..b4a729e
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/apps/pdfcraft-android/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..1f95ed0
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/apps/pdfcraft-android/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..1f95ed0
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..ca277c7
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..ca277c7
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..e09c629
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..e09c629
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..bde64ec
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..bde64ec
Binary files /dev/null and b/apps/pdfcraft-android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/apps/pdfcraft-android/android/app/src/main/res/values-ar/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values-ar/strings.xml
index 6911af9..45139c8 100644
--- a/apps/pdfcraft-android/android/app/src/main/res/values-ar/strings.xml
+++ b/apps/pdfcraft-android/android/app/src/main/res/values-ar/strings.xml
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- PdfCraft's Arabic translation. The English original is values/strings.xml.
+ ClearPDF's Arabic translation. The English original is values/strings.xml.
Resource names and format arguments follow the upstream English catalog.
Arabic plurals include zero, one, two, few, many and other.
-->
<resources>
- <string name="open_with">فتح باستخدام PdfCraft</string>
+ <string name="open_with">فتح باستخدام ClearPDF</string>
<string name="common_ok">موافق</string>
<string name="common_cancel">إلغاء</string>
<string name="common_done">تم</string>
@@ -75,7 +75,7 @@
<string name="home_no_starred_body">ميّز ملفًا من قائمته لتجده هنا بسرعة.</string>
<string name="home_device_files_title">الملفات على جهازك</string>
<string name="home_device_files_body">اختر مجلدات لعرض ملفات PDF منها، مثل المستندات أو مجلد داخل التنزيلات. ستبقى الملفات التي تفتحها من أي مكان في قائمة الأخيرة.</string>
- <string name="home_device_files_body_long">اختر مجلدات لعرض ملفات PDF منها، مثل المستندات أو مجلد داخل التنزيلات. لا يسمح Android للتطبيقات بعرض مجلد التنزيلات كاملًا. لا يصل PdfCraft إلا إلى المجلدات التي تختارها، وتبقى الملفات التي تفتحها من أي مكان في قائمة الأخيرة.</string>
+ <string name="home_device_files_body_long">اختر مجلدات لعرض ملفات PDF منها، مثل المستندات أو مجلد داخل التنزيلات. لا يسمح Android للتطبيقات بعرض مجلد التنزيلات كاملًا. لا يصل ClearPDF إلا إلى المجلدات التي تختارها، وتبقى الملفات التي تفتحها من أي مكان في قائمة الأخيرة.</string>
<string name="home_no_pdfs_title">لا توجد ملفات PDF في مجلداتك</string>
<string name="home_no_pdfs_body">ستظهر هنا ملفات PDF الموجودة في المجلدات التي أضفتها.</string>
<string name="home_add_folder">إضافة مجلد</string>
@@ -157,16 +157,16 @@
<string name="home_sort_newest">الأحدث تعديلًا</string>
<string name="home_no_results">لا توجد نتائج</string>
<string name="home_no_results_body">تحقق من الكتابة أو جرّب اسمًا أقصر.</string>
- <string name="home_about_app">حول PdfCraft</string>
+ <string name="home_about_app">حول ClearPDF</string>
<string name="home_preferences">التفضيلات</string>
<string name="home_help_support">المساعدة والدعم</string>
<string name="home_help">المساعدة</string>
<string name="home_report_problem">الإبلاغ عن مشكلة أو طلب ميزة</string>
- <string name="home_leaving_title">مغادرة PdfCraft</string>
+ <string name="home_leaving_title">مغادرة ClearPDF</string>
<string name="home_continue">متابعة</string>
<string name="home_leaving_body">سيُفتح موقع في متصفحك.</string>
<string name="home_section_notifications">الإشعارات</string>
- <string name="home_no_notifications">لا يرسل PdfCraft إشعارات.</string>
+ <string name="home_no_notifications">لا يرسل ClearPDF إشعارات.</string>
<string name="home_section_suggestions">الاقتراحات التلقائية</string>
<string name="home_offer_suggestions">اقتراح كلمات استخدمتها سابقًا عند تعبئة النماذج</string>
<string name="home_clear_suggestions">مسح الاقتراحات</string>
@@ -179,7 +179,7 @@
<string name="home_keyboard_shortcuts">اختصارات لوحة المفاتيح</string>
<string name="home_keyboard_shortcuts_body">عند توصيل لوحة مفاتيح: N أو Page Down للصفحة التالية، وP أو Page Up للسابقة، والأسهم للتمرير، وCtrl+P للطباعة، وCtrl مع + أو − للتكبير والتصغير.</string>
<string name="home_section_extra">ميزات إضافية</string>
- <string name="home_extra_body">خيارات إضافية لتخصيص مظهر PdfCraft وطريقة عمله.</string>
+ <string name="home_extra_body">خيارات إضافية لتخصيص مظهر ClearPDF وطريقة عمله.</string>
<string name="home_status_bar_in_documents">إظهار شريط الحالة داخل المستندات</string>
<string name="home_status_bar_in_documents_body">يظهر شريط الحالة مع أشرطة الأدوات. عند الضغط لإخفائها، يستخدم المستند الشاشة كاملة، بما فيها المساحة حول الكاميرا.</string>
<string name="home_search_count">إظهار عدد نتائج البحث</string>
@@ -191,7 +191,6 @@
<string name="home_licences">تراخيص المصادر المفتوحة</string>
<string name="home_source_code">الشيفرة المصدرية</string>
<string name="home_engine">محرك PdfCraft</string>
- <string name="home_legal_notice">يعتمد PdfCraft لنظام Android على محرك PdfCraft المكتوب بلغة Rust، بترخيص MIT أو Apache-2.0. لا يتبع PdfCraft شركة Adobe؛ وAcrobat علامة تجارية لشركة Adobe Inc.</string>
<string name="tools_compress_action">ضغط</string>
<string name="tools_compression_level">مستوى الضغط:</string>
<string name="tools_compress_high">ضغط عالٍ</string>
@@ -350,7 +349,7 @@
<string name="voice_play_audio">تشغيل الصوت</string>
<string name="voice_comment_kind">تعليق صوتي</string>
<string name="voice_mic_title">السماح باستخدام الميكروفون؟</string>
- <string name="voice_mic_rationale">يحتاج PdfCraft إلى الميكروفون لتسجيل التعليقات الصوتية. يمكنك السماح بذلك من إعدادات التطبيق.</string>
+ <string name="voice_mic_rationale">يحتاج ClearPDF إلى الميكروفون لتسجيل التعليقات الصوتية. يمكنك السماح بذلك من إعدادات التطبيق.</string>
<string name="voice_open_settings">فتح الإعدادات</string>
<string name="voice_not_now">ليس الآن</string>
<string name="pages_title">الصفحات</string>
@@ -404,7 +403,7 @@
<string name="sign_remove_id_description">إزالة الهوية الرقمية لـ %1$s</string>
<string name="sign_remove_id_title">إزالة الهوية الرقمية؟</string>
<string name="sign_remove">إزالة</string>
- <string name="sign_remove_id_message">ستُزال الهوية الرقمية لـ %1$s من PdfCraft. تحتفظ المستندات الموقّعة مسبقًا بتوقيعاتها.</string>
+ <string name="sign_remove_id_message">ستُزال الهوية الرقمية لـ %1$s من ClearPDF. تحتفظ المستندات الموقّعة مسبقًا بتوقيعاتها.</string>
<string name="sign_add">إضافة</string>
<string name="sign_id_password_prompt">أدخل كلمة المرور التي تحمي %1$s.</string>
<string name="sign_create_about">الهوية الرقمية المنشأة هنا موقّعة ذاتيًا: يكشف المستند الموقّع بها أي تغيير بعد التوقيع، لكن لا توجد جهة مستقلة تثبت هويتك. لإثبات الهوية، استخدم ملف هوية تصدره مؤسسة أو جهة تصديق.</string>
@@ -417,7 +416,7 @@
<string name="sign_password_again">أعد كتابة كلمة المرور</string>
<string name="sign_password_short">تحتاج كلمة المرور إلى 8 أحرف على الأقل.</string>
<string name="sign_password_mismatch">كلمتا المرور غير متطابقتين.</string>
- <string name="sign_password_note">لا يحتفظ PdfCraft بكلمة المرور ولا يمكنه استعادتها؛ أدخلها عند كل توقيع.</string>
+ <string name="sign_password_note">لا يحتفظ ClearPDF بكلمة المرور ولا يمكنه استعادتها؛ أدخلها عند كل توقيع.</string>
<string name="sign_add_your_signature">إضافة توقيعك</string>
<string name="sign_signatures">التوقيعات</string>
<string name="sign_none">لا توجد توقيعات في هذا المستند.</string>
@@ -670,10 +669,10 @@
<string name="forms_reset">إعادة ضبط</string>
<string name="forms_previous_field">الحقل السابق</string>
<string name="forms_next_field">الحقل التالي</string>
- <string name="msg_engine_not_started">تعذّر بدء PdfCraft.</string>
+ <string name="msg_engine_not_started">تعذّر بدء ClearPDF.</string>
<string name="msg_file_moved">نُقل هذا الملف أو حُذف.</string>
- <string name="msg_opened_own_copy">تم فتح نسخة PdfCraft. لتعديل الأصل، افتحه مجددًا من التطبيق الموجود فيه.</string>
- <string name="msg_file_access_lost">تعذّر على PdfCraft فتح هذا الملف. افتحه مجددًا من التطبيق الموجود فيه أو باستخدام «فتح ملف».</string>
+ <string name="msg_opened_own_copy">تم فتح نسخة ClearPDF. لتعديل الأصل، افتحه مجددًا من التطبيق الموجود فيه.</string>
+ <string name="msg_file_access_lost">تعذّر على ClearPDF فتح هذا الملف. افتحه مجددًا من التطبيق الموجود فيه أو باستخدام «فتح ملف».</string>
<string name="msg_undone">تم التراجع عن %1$s</string>
<string name="msg_redone">تمت إعادة %1$s</string>
<string name="msg_tool_blocked_security">هذه الأداة غير متاحة بسبب إعدادات أمان المستند.</string>
@@ -708,7 +707,7 @@
<string name="msg_sign_read_only">لا يمكن تعديل هذا المستند، لذلك لا يمكن توقيعه.</string>
<string name="msg_id_cannot_sign">لا يمكن لهذه الهوية الرقمية توقيع المستندات. %1$s</string>
<string name="msg_id_added">أُضيفت الهوية الرقمية الخاصة بـ %1$s</string>
- <string name="msg_id_unusable">لا يستطيع PdfCraft استخدام هذا الملف كهوية رقمية: %1$s</string>
+ <string name="msg_id_unusable">لا يستطيع ClearPDF استخدام هذا الملف كهوية رقمية: %1$s</string>
<string name="msg_busy_creating_id">جارٍ إنشاء هويتك الرقمية…</string>
<string name="msg_id_created">أُنشئت الهوية الرقمية</string>
<string name="msg_busy_signing">جارٍ التوقيع…</string>
@@ -735,7 +734,7 @@
<string name="msg_picture_unreadable">تعذّرت قراءة الصورة.</string>
<string name="msg_gif_not_supported">لا يمكن إضافة صور GIF.</string>
<string name="msg_form_cleared">تم مسح النموذج</string>
- <string name="msg_button_submit">يرسل هذا الزر النموذج عبر الإنترنت، ولا يدعم PdfCraft ذلك.</string>
+ <string name="msg_button_submit">يرسل هذا الزر النموذج عبر الإنترنت، ولا يدعم ClearPDF ذلك.</string>
<string name="msg_suggestions_cleared">تم مسح الاقتراحات</string>
<string name="msg_that_file_unreadable">تعذّرت قراءة ذلك الملف.</string>
<string name="msg_named_file_unreadable">تعذّرت قراءة %1$s.</string>
@@ -751,11 +750,11 @@
<string name="msg_busy_exporting_page">جارٍ تصدير الصفحة %1$d من %2$d…</string>
<plurals name="msg_images_saved">
<item quantity="zero">لم تُحفظ أي صورة</item>
- <item quantity="one">حُفظت صورة واحدة في Pictures/PdfCraft</item>
- <item quantity="two">حُفظت صورتان في Pictures/PdfCraft</item>
- <item quantity="few">حُفظت %1$d صور في Pictures/PdfCraft</item>
- <item quantity="many">حُفظت %1$d صورة في Pictures/PdfCraft</item>
- <item quantity="other">حُفظت %1$d صورة في Pictures/PdfCraft</item>
+ <item quantity="one">حُفظت صورة واحدة في Pictures/ClearPDF</item>
+ <item quantity="two">حُفظت صورتان في Pictures/ClearPDF</item>
+ <item quantity="few">حُفظت %1$d صور في Pictures/ClearPDF</item>
+ <item quantity="many">حُفظت %1$d صورة في Pictures/ClearPDF</item>
+ <item quantity="other">حُفظت %1$d صورة في Pictures/ClearPDF</item>
</plurals>
<string name="msg_busy_creating_pdf">جارٍ إنشاء PDF…</string>
<plurals name="msg_create_first_files">
diff --git a/apps/pdfcraft-android/android/app/src/main/res/values-de/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values-de/strings.xml
index 66bd8a4..961effb 100644
--- a/apps/pdfcraft-android/android/app/src/main/res/values-de/strings.xml
+++ b/apps/pdfcraft-android/android/app/src/main/res/values-de/strings.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- PdfCraft's text, in German. The English original is values/strings.xml.
+ ClearPDF's text, in German. The English original is values/strings.xml.
-->
<resources>
- <string name="open_with">In PdfCraft öffnen</string>
+ <string name="open_with">In ClearPDF öffnen</string>
<!-- Shared: buttons and words used on many screens -->
<string name="common_ok">OK</string>
@@ -90,7 +90,7 @@
<string name="home_device_files_title">Dateien auf deinem Gerät</string>
<string name="home_device_files_body">Wähle Ordner aus, deren PDFs angezeigt werden sollen, z. B. „Dokumente“ oder einen Ordner im Ordner „Download“. Dateien, die du von einem beliebigen Ort öffnest, bleiben unter „Zuletzt verwendet“.</string>
<!-- On this device, before any folder is added: the longer explanation -->
- <string name="home_device_files_body_long">Wähle Ordner aus, deren PDFs angezeigt werden sollen, z. B. „Dokumente“ oder einen Ordner im Ordner „Download“ (Android erlaubt Apps nicht, den gesamten Ordner „Download“ aufzulisten). PdfCraft sieht nur die Ordner, die du auswählst. Dateien, die du von einem beliebigen Ort öffnest, bleiben unter „Zuletzt verwendet“.</string>
+ <string name="home_device_files_body_long">Wähle Ordner aus, deren PDFs angezeigt werden sollen, z. B. „Dokumente“ oder einen Ordner im Ordner „Download“ (Android erlaubt Apps nicht, den gesamten Ordner „Download“ aufzulisten). ClearPDF sieht nur die Ordner, die du auswählst. Dateien, die du von einem beliebigen Ort öffnest, bleiben unter „Zuletzt verwendet“.</string>
<string name="home_no_pdfs_title">Keine PDFs in deinen Ordnern</string>
<string name="home_no_pdfs_body">PDFs in den hinzugefügten Ordnern werden hier angezeigt.</string>
<string name="home_add_folder">Ordner hinzufügen</string>
@@ -193,18 +193,18 @@
<string name="home_no_results_body">Überprüfe die Schreibweise oder versuche einen kürzeren Namen.</string>
<!-- Settings -->
- <string name="home_about_app">Über PdfCraft</string>
+ <string name="home_about_app">Über ClearPDF</string>
<string name="home_preferences">Einstellungen</string>
<string name="home_help_support">Hilfe und Support</string>
<string name="home_help">Hilfe</string>
<string name="home_report_problem">Problem melden oder Funktion vorschlagen</string>
- <string name="home_leaving_title">PdfCraft verlassen</string>
+ <string name="home_leaving_title">ClearPDF verlassen</string>
<string name="home_continue">Weiter</string>
<string name="home_leaving_body">Dadurch wird eine Webseite in deinem Browser geöffnet.</string>
<!-- Settings: Preferences -->
<string name="home_section_notifications">Benachrichtigungen</string>
- <string name="home_no_notifications">PdfCraft sendet keine Benachrichtigungen.</string>
+ <string name="home_no_notifications">ClearPDF sendet keine Benachrichtigungen.</string>
<string name="home_section_suggestions">Automatische Vorschläge</string>
<string name="home_offer_suggestions">Beim Ausfüllen von Formularen zuvor verwendete Wörter vorschlagen</string>
<string name="home_clear_suggestions">Vorschläge löschen</string>
@@ -219,13 +219,13 @@
<!-- N, P, Page Down, Page Up, Ctrl+P, Ctrl, + and − are keys on the keyboard -->
<string name="home_keyboard_shortcuts_body">Bei angeschlossener Tastatur: N oder Bild-ab für die nächste Seite, P oder Bild-auf für die vorherige Seite, Pfeiltasten zum Scrollen, Strg+P zum Drucken und Strg zusammen mit + oder − zum Zoomen.</string>
<string name="home_section_extra">Zusatzfunktionen</string>
- <string name="home_extra_body">Optionale Änderungen am Aussehen und Verhalten von PdfCraft.</string>
+ <string name="home_extra_body">Optionale Änderungen am Aussehen und Verhalten von ClearPDF.</string>
<string name="home_status_bar_in_documents">Statusleiste in Dokumenten anzeigen</string>
<string name="home_status_bar_in_documents_body">Die Statusleiste wird zusammen mit den Symbolleisten angezeigt. Wenn du sie durch Tippen ausblendest, nutzt die Seite den gesamten Bildschirm, auch den Bereich um die Kamera.</string>
<string name="home_search_count">Anzahl der Suchergebnisse anzeigen</string>
<string name="home_search_count_body">Bei der Dokumentsuche wird angezeigt, welches Ergebnis du gerade ansiehst und wie viele es insgesamt gibt, z. B. 3 von 12.</string>
- <!-- Settings: About PdfCraft -->
+ <!-- Settings: About ClearPDF -->
<string name="home_section_about">Über</string>
<!-- %1$s is the app's version, %2$s the engine's version -->
<string name="home_version">Version %1$s (Engine %2$s)</string>
@@ -236,7 +236,6 @@
<string name="home_source_code">Quellcode</string>
<string name="home_engine">PdfCraft-Engine</string>
<!-- Keep the licence names (MIT, Apache-2.0) and the trademark notice -->
- <string name="home_legal_notice">PdfCraft für Android basiert auf der Rust-Engine von PdfCraft. MIT OR Apache-2.0. PdfCraft ist nicht mit Adobe verbunden; Acrobat ist eine Marke von Adobe Inc.</string>
<!-- Tool screens: Compress PDF -->
<string name="tools_compress_action">Komprimieren</string>
@@ -490,7 +489,7 @@
<!-- Voice comments: the microphone was refused before -->
<string name="voice_mic_title">Mikrofon verwenden?</string>
- <string name="voice_mic_rationale">PdfCraft benötigt das Mikrofon, um Sprachkommentare aufzunehmen. Du kannst den Zugriff in den App-Einstellungen erlauben.</string>
+ <string name="voice_mic_rationale">ClearPDF benötigt das Mikrofon, um Sprachkommentare aufzunehmen. Du kannst den Zugriff in den App-Einstellungen erlauben.</string>
<string name="voice_open_settings">Einstellungen öffnen</string>
<string name="voice_not_now">Nicht jetzt</string>
@@ -574,7 +573,7 @@
<string name="sign_remove_id_title">Digitale ID entfernen?</string>
<string name="sign_remove">Entfernen</string>
<!-- Translator note: %1$s is the person's name on the digital ID -->
- <string name="sign_remove_id_message">Die digitale ID von %1$s wird aus PdfCraft entfernt. Dokumente, die bereits damit unterschrieben wurden, behalten ihre Unterschriften.</string>
+ <string name="sign_remove_id_message">Die digitale ID von %1$s wird aus ClearPDF entfernt. Dokumente, die bereits damit unterschrieben wurden, behalten ihre Unterschriften.</string>
<!-- Digital signatures: the password of a digital ID file being added -->
<string name="sign_add">Hinzufügen</string>
@@ -593,7 +592,7 @@
<string name="sign_password_again">Passwort erneut eingeben</string>
<string name="sign_password_short">Das Passwort muss mindestens 8 Zeichen lang sein.</string>
<string name="sign_password_mismatch">Die Passwörter stimmen nicht überein.</string>
- <string name="sign_password_note">PdfCraft speichert das Passwort nicht und kann es nicht wiederherstellen. Du musst es bei jeder Unterschrift erneut eingeben.</string>
+ <string name="sign_password_note">ClearPDF speichert das Passwort nicht und kann es nicht wiederherstellen. Du musst es bei jeder Unterschrift erneut eingeben.</string>
<!-- Digital signatures: tapping an empty signature field -->
<string name="sign_add_your_signature">Unterschrift hinzufügen</string>
@@ -966,11 +965,11 @@
<!-- Messages: notices at the bottom of the screen, progress, errors -->
<!-- ================================================================== -->
<!-- Messages: opening documents -->
- <string name="msg_engine_not_started">PdfCraft konnte nicht gestartet werden.</string>
+ <string name="msg_engine_not_started">ClearPDF konnte nicht gestartet werden.</string>
<string name="msg_file_moved">Diese Datei wurde verschoben oder gelöscht.</string>
- <string name="msg_opened_own_copy">Die Kopie von PdfCraft wurde geöffnet. Um das Original zu ändern, öffne es erneut in der App, in der es sich befindet.</string>
+ <string name="msg_opened_own_copy">Die Kopie von ClearPDF wurde geöffnet. Um das Original zu ändern, öffne es erneut in der App, in der es sich befindet.</string>
<!-- "Open file" is the name of the button on Home that picks a file. -->
- <string name="msg_file_access_lost">PdfCraft kann diese Datei nicht mehr öffnen. Öffne sie erneut in der App, in der sie sich befindet, oder über „Datei öffnen“.</string>
+ <string name="msg_file_access_lost">ClearPDF kann diese Datei nicht mehr öffnen. Öffne sie erneut in der App, in der sie sich befindet, oder über „Datei öffnen“.</string>
<!-- Messages: undo and redo. %1$s is the name of the edit, as the engine gives it (for example "Add comment"). -->
<string name="msg_undone">%1$s rückgängig gemacht</string>
@@ -1037,7 +1036,7 @@
<!-- %1$s is the name of the person the digital ID belongs to. -->
<string name="msg_id_added">Digitale ID von %1$s hinzugefügt</string>
<!-- %1$s is the reason the file was refused. -->
- <string name="msg_id_unusable">PdfCraft kann diese Datei nicht als digitale ID verwenden: %1$s</string>
+ <string name="msg_id_unusable">ClearPDF kann diese Datei nicht als digitale ID verwenden: %1$s</string>
<string name="msg_busy_creating_id">Deine digitale ID wird erstellt …</string>
<string name="msg_id_created">Digitale ID erstellt</string>
<string name="msg_busy_signing">Wird unterschrieben …</string>
@@ -1069,7 +1068,7 @@
<!-- Messages: forms -->
<string name="msg_form_cleared">Formular geleert</string>
- <string name="msg_button_submit">Diese Schaltfläche sendet das Formular online. PdfCraft führt diese Aktion nicht aus.</string>
+ <string name="msg_button_submit">Diese Schaltfläche sendet das Formular online. ClearPDF führt diese Aktion nicht aus.</string>
<!-- Words remembered from form fields, offered while typing. -->
<string name="msg_suggestions_cleared">Vorschläge gelöscht</string>
@@ -1090,10 +1089,10 @@
<string name="msg_busy_exporting_images">Bilder werden exportiert …</string>
<!-- %1$d is the page being exported, %2$d how many pages there are. -->
<string name="msg_busy_exporting_page">Seite %1$d von %2$d wird exportiert …</string>
- <!-- Pictures/PdfCraft is a folder on the phone: keep it as it is. -->
+ <!-- Pictures/ClearPDF is a folder on the phone: keep it as it is. -->
<plurals name="msg_images_saved">
- <item quantity="one">%1$d Bild wurde in Pictures/PdfCraft gespeichert</item>
- <item quantity="other">%1$d Bilder wurden in Pictures/PdfCraft gespeichert</item>
+ <item quantity="one">%1$d Bild wurde in Pictures/ClearPDF gespeichert</item>
+ <item quantity="other">%1$d Bilder wurden in Pictures/ClearPDF gespeichert</item>
</plurals>
<string name="msg_busy_creating_pdf">PDF wird erstellt …</string>
<!-- Create PDF takes at most this many files at once. -->
diff --git a/apps/pdfcraft-android/android/app/src/main/res/values-es/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values-es/strings.xml
index ceeb0ba..f85081f 100644
--- a/apps/pdfcraft-android/android/app/src/main/res/values-es/strings.xml
+++ b/apps/pdfcraft-android/android/app/src/main/res/values-es/strings.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- PdfCraft's text, in Spanish (Spain). The English original is values/strings.xml.
+ ClearPDF's text, in Spanish (Spain). The English original is values/strings.xml.
- To translate PdfCraft: copy this file to res/values-<language>/strings.xml (values-es for
+ To translate ClearPDF: copy this file to res/values-<language>/strings.xml (values-es for
Spanish, values-pt-rBR for Brazilian Portuguese, values-zh-rCN for simplified Chinese) and
translate the text between the tags. Keep each name, every placeholder (%1$s, %2$d: the
number says which value goes there, so a translation may move them), escapes such as \' and
@@ -10,7 +10,7 @@
few, many). A string left out shows in English.
-->
<resources>
- <string name="open_with">Abrir con PdfCraft</string>
+ <string name="open_with">Abrir con ClearPDF</string>
<!-- Shared: buttons and words used on many screens -->
<string name="common_ok">Aceptar</string>
@@ -97,7 +97,7 @@
<string name="home_device_files_title">Archivos de tu dispositivo</string>
<string name="home_device_files_body">Elige las carpetas de las que listar PDF, como Documentos o una carpeta dentro de Descargas. Los archivos que abras desde cualquier sitio se quedan en Recientes.</string>
<!-- On this device, before any folder is added: the longer explanation -->
- <string name="home_device_files_body_long">Elige las carpetas de las que listar PDF, como Documentos o una carpeta dentro de Descargas (Android no permite a las apps listar toda la carpeta Descargas). PdfCraft solo ve las carpetas que elijas, y los archivos que abras desde cualquier sitio se quedan en Recientes.</string>
+ <string name="home_device_files_body_long">Elige las carpetas de las que listar PDF, como Documentos o una carpeta dentro de Descargas (Android no permite a las apps listar toda la carpeta Descargas). ClearPDF solo ve las carpetas que elijas, y los archivos que abras desde cualquier sitio se quedan en Recientes.</string>
<string name="home_no_pdfs_title">No hay PDF en tus carpetas</string>
<string name="home_no_pdfs_body">Los PDF de las carpetas que añadiste aparecerán aquí.</string>
<string name="home_add_folder">Añadir carpeta</string>
@@ -200,18 +200,18 @@
<string name="home_no_results_body">Revisa la ortografía o prueba con un nombre más corto.</string>
<!-- Settings -->
- <string name="home_about_app">Acerca de PdfCraft</string>
+ <string name="home_about_app">Acerca de ClearPDF</string>
<string name="home_preferences">Preferencias</string>
<string name="home_help_support">Ayuda y soporte</string>
<string name="home_help">Ayuda</string>
<string name="home_report_problem">Informar de un problema o pedir una función</string>
- <string name="home_leaving_title">Sales de PdfCraft</string>
+ <string name="home_leaving_title">Sales de ClearPDF</string>
<string name="home_continue">Continuar</string>
<string name="home_leaving_body">Esto abre una página web en tu navegador.</string>
<!-- Settings: Preferences -->
<string name="home_section_notifications">Notificaciones</string>
- <string name="home_no_notifications">PdfCraft no envía notificaciones.</string>
+ <string name="home_no_notifications">ClearPDF no envía notificaciones.</string>
<string name="home_section_suggestions">Sugerencias automáticas</string>
<string name="home_offer_suggestions">Sugerir palabras que ya usaste al rellenar formularios</string>
<string name="home_clear_suggestions">Borrar sugerencias</string>
@@ -226,13 +226,13 @@
<!-- N, P, Page Down, Page Up, Ctrl+P, Ctrl, + and − are keys on the keyboard -->
<string name="home_keyboard_shortcuts_body">Con un teclado conectado: N o Av Pág para la página siguiente, P o Re Pág para la anterior, las flechas para desplazarte, Ctrl+P para imprimir y Ctrl y + o − para ampliar.</string>
<string name="home_section_extra">Funciones extra</string>
- <string name="home_extra_body">Cambios opcionales en el aspecto y el funcionamiento de PdfCraft.</string>
+ <string name="home_extra_body">Cambios opcionales en el aspecto y el funcionamiento de ClearPDF.</string>
<string name="home_status_bar_in_documents">Mostrar la barra de estado en los documentos</string>
<string name="home_status_bar_in_documents_body">La barra de estado se muestra con las barras de herramientas. Al tocar para ocultarlas, la página ocupa toda la pantalla, también alrededor de la cámara.</string>
<string name="home_search_count">Mostrar el número de resultados de búsqueda</string>
<string name="home_search_count_body">Buscar en un documento muestra en qué resultado estás y cuántos hay, por ejemplo 3 de 12.</string>
- <!-- Settings: About PdfCraft -->
+ <!-- Settings: About ClearPDF -->
<string name="home_section_about">Acerca de</string>
<!-- %1$s is the app's version, %2$s the engine's version -->
<string name="home_version">Versión %1$s (motor %2$s)</string>
@@ -243,7 +243,6 @@
<string name="home_source_code">Código fuente</string>
<string name="home_engine">Motor de PdfCraft</string>
<!-- Keep the licence names (MIT, Apache-2.0) and the trademark notice -->
- <string name="home_legal_notice">PdfCraft para Android se basa en el motor Rust de PdfCraft. MIT OR Apache-2.0. PdfCraft no está afiliado a Adobe; Acrobat es una marca registrada de Adobe Inc.</string>
<!-- Tool screens: Compress PDF -->
<string name="tools_compress_action">Comprimir</string>
@@ -497,7 +496,7 @@
<!-- Voice comments: the microphone was refused before -->
<string name="voice_mic_title">¿Usar el micrófono?</string>
- <string name="voice_mic_rationale">PdfCraft necesita el micrófono para grabar comentarios de voz. Puedes permitirlo en los ajustes de la app.</string>
+ <string name="voice_mic_rationale">ClearPDF necesita el micrófono para grabar comentarios de voz. Puedes permitirlo en los ajustes de la app.</string>
<string name="voice_open_settings">Abrir ajustes</string>
<string name="voice_not_now">Ahora no</string>
@@ -581,7 +580,7 @@
<string name="sign_remove_id_title">¿Quitar el ID digital?</string>
<string name="sign_remove">Quitar</string>
<!-- Translator note: %1$s is the person's name on the digital ID -->
- <string name="sign_remove_id_message">Se quita de PdfCraft el ID digital de %1$s. Los documentos ya firmados con él conservan sus firmas.</string>
+ <string name="sign_remove_id_message">Se quita de ClearPDF el ID digital de %1$s. Los documentos ya firmados con él conservan sus firmas.</string>
<!-- Digital signatures: the password of a digital ID file being added -->
<string name="sign_add">Añadir</string>
@@ -600,7 +599,7 @@
<string name="sign_password_again">La contraseña otra vez</string>
<string name="sign_password_short">La contraseña necesita al menos 8 caracteres.</string>
<string name="sign_password_mismatch">Las contraseñas no coinciden.</string>
- <string name="sign_password_note">PdfCraft no guarda la contraseña y no puede recuperarla: la escribes cada vez que firmas.</string>
+ <string name="sign_password_note">ClearPDF no guarda la contraseña y no puede recuperarla: la escribes cada vez que firmas.</string>
<!-- Digital signatures: tapping an empty signature field -->
<string name="sign_add_your_signature">Añade tu firma</string>
@@ -974,11 +973,11 @@
<!-- Messages: notices at the bottom of the screen, progress, errors -->
<!-- ================================================================== -->
<!-- Messages: opening documents -->
- <string name="msg_engine_not_started">No se pudo iniciar PdfCraft.</string>
+ <string name="msg_engine_not_started">No se pudo iniciar ClearPDF.</string>
<string name="msg_file_moved">Este archivo se ha movido o eliminado.</string>
- <string name="msg_opened_own_copy">Se abrió la copia de PdfCraft. Para cambiar el original, ábrelo de nuevo desde la app donde está.</string>
+ <string name="msg_opened_own_copy">Se abrió la copia de ClearPDF. Para cambiar el original, ábrelo de nuevo desde la app donde está.</string>
<!-- "Open file" is the name of the button on Home that picks a file. -->
- <string name="msg_file_access_lost">PdfCraft ya no puede abrir este archivo. Ábrelo de nuevo desde la app donde está o con Abrir archivo.</string>
+ <string name="msg_file_access_lost">ClearPDF ya no puede abrir este archivo. Ábrelo de nuevo desde la app donde está o con Abrir archivo.</string>
<!-- Messages: undo and redo. %1$s is the name of the edit, as the engine gives it (for example "Add comment"). -->
<string name="msg_undone">%1$s deshecho</string>
@@ -1045,7 +1044,7 @@
<!-- %1$s is the name of the person the digital ID belongs to. -->
<string name="msg_id_added">ID digital de %1$s añadido</string>
<!-- %1$s is the reason the file was refused. -->
- <string name="msg_id_unusable">PdfCraft no puede usar este archivo como ID digital: %1$s</string>
+ <string name="msg_id_unusable">ClearPDF no puede usar este archivo como ID digital: %1$s</string>
<string name="msg_busy_creating_id">Creando tu ID digital…</string>
<string name="msg_id_created">ID digital creado</string>
<string name="msg_busy_signing">Firmando…</string>
@@ -1077,7 +1076,7 @@
<!-- Messages: forms -->
<string name="msg_form_cleared">Formulario borrado</string>
- <string name="msg_button_submit">Este botón envía el formulario por internet, algo que PdfCraft no hace.</string>
+ <string name="msg_button_submit">Este botón envía el formulario por internet, algo que ClearPDF no hace.</string>
<!-- Words remembered from form fields, offered while typing. -->
<string name="msg_suggestions_cleared">Sugerencias borradas</string>
@@ -1098,10 +1097,10 @@
<string name="msg_busy_exporting_images">Exportando imágenes…</string>
<!-- %1$d is the page being exported, %2$d how many pages there are. -->
<string name="msg_busy_exporting_page">Exportando página %1$d de %2$d…</string>
- <!-- Pictures/PdfCraft is a folder on the phone: keep it as it is. -->
+ <!-- Pictures/ClearPDF is a folder on the phone: keep it as it is. -->
<plurals name="msg_images_saved">
- <item quantity="one">%1$d imagen guardada en Pictures/PdfCraft</item>
- <item quantity="other">%1$d imágenes guardadas en Pictures/PdfCraft</item>
+ <item quantity="one">%1$d imagen guardada en Pictures/ClearPDF</item>
+ <item quantity="other">%1$d imágenes guardadas en Pictures/ClearPDF</item>
</plurals>
<string name="msg_busy_creating_pdf">Creando PDF…</string>
<!-- Create PDF takes at most this many files at once. -->
diff --git a/apps/pdfcraft-android/android/app/src/main/res/values-fr/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values-fr/strings.xml
index 45d13c9..4ce62e9 100644
--- a/apps/pdfcraft-android/android/app/src/main/res/values-fr/strings.xml
+++ b/apps/pdfcraft-android/android/app/src/main/res/values-fr/strings.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Textes de PdfCraft, en français (France).
+ Textes de ClearPDF, en français (France).
-->
<resources>
- <string name="open_with">Ouvrir dans PdfCraft</string>
+ <string name="open_with">Ouvrir dans ClearPDF</string>
<!-- Shared: buttons and words used on many screens -->
<string name="common_ok">OK</string>
@@ -90,7 +90,7 @@
<string name="home_device_files_title">Fichiers sur votre appareil</string>
<string name="home_device_files_body">Choisissez les dossiers où chercher des PDF, comme Documents ou un dossier dans Téléchargements. Les fichiers ouverts depuis n\'importe où restent dans Récents.</string>
<!-- On this device, before any folder is added: the longer explanation -->
- <string name="home_device_files_body_long">Choisissez les dossiers où chercher des PDF, comme Documents ou un dossier dans Téléchargements (Android ne permet pas aux applications de lister tout le dossier Téléchargements). PdfCraft ne voit que les dossiers que vous choisissez, et les fichiers ouverts depuis n\'importe où restent dans Récents.</string>
+ <string name="home_device_files_body_long">Choisissez les dossiers où chercher des PDF, comme Documents ou un dossier dans Téléchargements (Android ne permet pas aux applications de lister tout le dossier Téléchargements). ClearPDF ne voit que les dossiers que vous choisissez, et les fichiers ouverts depuis n\'importe où restent dans Récents.</string>
<string name="home_no_pdfs_title">Aucun PDF dans vos dossiers</string>
<string name="home_no_pdfs_body">Les PDF des dossiers ajoutés apparaîtront ici.</string>
<string name="home_add_folder">Ajouter un dossier</string>
@@ -193,18 +193,18 @@
<string name="home_no_results_body">Vérifiez l\'orthographe ou essayez un nom plus court.</string>
<!-- Settings -->
- <string name="home_about_app">À propos de PdfCraft</string>
+ <string name="home_about_app">À propos de ClearPDF</string>
<string name="home_preferences">Préférences</string>
<string name="home_help_support">Aide et assistance</string>
<string name="home_help">Aide</string>
<string name="home_report_problem">Signaler un problème ou demander une fonctionnalité</string>
- <string name="home_leaving_title">Quitter PdfCraft</string>
+ <string name="home_leaving_title">Quitter ClearPDF</string>
<string name="home_continue">Continuer</string>
<string name="home_leaving_body">Une page web va s\'ouvrir dans votre navigateur.</string>
<!-- Settings: Preferences -->
<string name="home_section_notifications">Notifications</string>
- <string name="home_no_notifications">PdfCraft n\'envoie pas de notifications.</string>
+ <string name="home_no_notifications">ClearPDF n\'envoie pas de notifications.</string>
<string name="home_section_suggestions">Suggestions automatiques</string>
<string name="home_offer_suggestions">Proposer les mots déjà utilisés pour remplir les formulaires</string>
<string name="home_clear_suggestions">Effacer les suggestions</string>
@@ -219,13 +219,13 @@
<!-- N, P, Page Down, Page Up, Ctrl+P, Ctrl, + and − are keys on the keyboard -->
<string name="home_keyboard_shortcuts_body">Avec un clavier connecté : N ou Page suivante pour la page suivante, P ou Page précédente pour la page précédente, les flèches pour faire défiler, Ctrl+P pour imprimer, Ctrl et + ou − pour zoomer.</string>
<string name="home_section_extra">Fonctionnalités supplémentaires</string>
- <string name="home_extra_body">Modifications facultatives de l\'apparence et du fonctionnement de PdfCraft.</string>
+ <string name="home_extra_body">Modifications facultatives de l\'apparence et du fonctionnement de ClearPDF.</string>
<string name="home_status_bar_in_documents">Afficher la barre d\'état dans les documents</string>
<string name="home_status_bar_in_documents_body">La barre d\'état s\'affiche avec les barres d\'outils. Quand vous touchez l\'écran pour les masquer, la page occupe tout l\'écran, y compris autour de la caméra.</string>
<string name="home_search_count">Afficher le nombre de résultats de recherche</string>
<string name="home_search_count_body">La recherche dans un document indique à quel résultat vous êtes et combien il y en a, par exemple 3 sur 12.</string>
- <!-- Settings: About PdfCraft -->
+ <!-- Settings: About ClearPDF -->
<string name="home_section_about">À propos</string>
<!-- %1$s is the app's version, %2$s the engine's version -->
<string name="home_version">Version %1$s (moteur %2$s)</string>
@@ -236,7 +236,6 @@
<string name="home_source_code">Code source</string>
<string name="home_engine">Moteur PdfCraft</string>
<!-- Keep the licence names (MIT, Apache-2.0) and the trademark notice -->
- <string name="home_legal_notice">PdfCraft pour Android repose sur le moteur Rust de PdfCraft. MIT OR Apache-2.0. PdfCraft n\'est pas affilié à Adobe ; Acrobat est une marque d\'Adobe Inc.</string>
<!-- Tool screens: Compress PDF -->
<string name="tools_compress_action">Compresser</string>
@@ -474,7 +473,7 @@
<!-- Voice comments: the microphone was refused before -->
<string name="voice_mic_title">Utiliser le microphone ?</string>
- <string name="voice_mic_rationale">PdfCraft a besoin du microphone pour enregistrer des commentaires vocaux. Vous pouvez l\'autoriser dans les réglages de l\'application.</string>
+ <string name="voice_mic_rationale">ClearPDF a besoin du microphone pour enregistrer des commentaires vocaux. Vous pouvez l\'autoriser dans les réglages de l\'application.</string>
<string name="voice_open_settings">Ouvrir les réglages</string>
<string name="voice_not_now">Pas maintenant</string>
@@ -538,7 +537,7 @@
<string name="sign_remove_id_description">Supprimer l\'identité numérique de %1$s</string>
<string name="sign_remove_id_title">Supprimer l\'identité numérique ?</string>
<string name="sign_remove">Supprimer</string>
- <string name="sign_remove_id_message">L\'identité numérique de %1$s est supprimée de PdfCraft. Les documents déjà signés avec elle conservent leurs signatures.</string>
+ <string name="sign_remove_id_message">L\'identité numérique de %1$s est supprimée de ClearPDF. Les documents déjà signés avec elle conservent leurs signatures.</string>
<!-- Digital signatures: the password of a digital ID file being added -->
<string name="sign_add">Ajouter</string>
@@ -555,7 +554,7 @@
<string name="sign_password_again">Répétez le mot de passe</string>
<string name="sign_password_short">Le mot de passe doit comporter au moins 8 caractères.</string>
<string name="sign_password_mismatch">Les mots de passe ne correspondent pas.</string>
- <string name="sign_password_note">PdfCraft ne conserve pas le mot de passe et ne peut pas le récupérer : vous le saisissez à chaque signature.</string>
+ <string name="sign_password_note">ClearPDF ne conserve pas le mot de passe et ne peut pas le récupérer : vous le saisissez à chaque signature.</string>
<!-- Digital signatures: tapping an empty signature field -->
<string name="sign_add_your_signature">Ajouter votre signature</string>
@@ -874,10 +873,10 @@
<!-- Messages: notices at the bottom of the screen, progress, errors -->
<!-- ================================================================== -->
<!-- Messages: opening documents -->
- <string name="msg_engine_not_started">PdfCraft n\'a pas pu démarrer.</string>
+ <string name="msg_engine_not_started">ClearPDF n\'a pas pu démarrer.</string>
<string name="msg_file_moved">Ce fichier a été déplacé ou supprimé.</string>
- <string name="msg_opened_own_copy">Copie de PdfCraft ouverte. Pour modifier l\'original, rouvrez-le depuis l\'application où il se trouve.</string>
- <string name="msg_file_access_lost">PdfCraft ne peut plus ouvrir ce fichier. Rouvrez-le depuis l\'application où il se trouve, ou avec Ouvrir un fichier.</string>
+ <string name="msg_opened_own_copy">Copie de ClearPDF ouverte. Pour modifier l\'original, rouvrez-le depuis l\'application où il se trouve.</string>
+ <string name="msg_file_access_lost">ClearPDF ne peut plus ouvrir ce fichier. Rouvrez-le depuis l\'application où il se trouve, ou avec Ouvrir un fichier.</string>
<!-- Messages: undo and redo. %1$s is the name of the edit, as the engine gives it (for example "Add comment"). -->
<string name="msg_undone">%1$s annulé</string>
@@ -936,7 +935,7 @@
<string name="msg_sign_read_only">Ce document ne peut pas être modifié, il ne peut donc pas être signé.</string>
<string name="msg_id_cannot_sign">Cette identité numérique ne peut pas signer de documents. %1$s</string>
<string name="msg_id_added">Identité numérique de %1$s ajoutée</string>
- <string name="msg_id_unusable">PdfCraft ne peut pas utiliser ce fichier comme identité numérique : %1$s</string>
+ <string name="msg_id_unusable">ClearPDF ne peut pas utiliser ce fichier comme identité numérique : %1$s</string>
<string name="msg_busy_creating_id">Création de votre identité numérique…</string>
<string name="msg_id_created">Identité numérique créée</string>
<string name="msg_busy_signing">Signature…</string>
@@ -966,7 +965,7 @@
<!-- Messages: forms -->
<string name="msg_form_cleared">Formulaire effacé</string>
- <string name="msg_button_submit">Ce bouton envoie le formulaire en ligne, ce que PdfCraft ne fait pas.</string>
+ <string name="msg_button_submit">Ce bouton envoie le formulaire en ligne, ce que ClearPDF ne fait pas.</string>
<string name="msg_suggestions_cleared">Suggestions effacées</string>
<!-- Messages: picked files. %1$s is a file name. -->
@@ -984,10 +983,10 @@
<string name="msg_busy_exporting_to">Export en %1$s…</string>
<string name="msg_busy_exporting_images">Export des images…</string>
<string name="msg_busy_exporting_page">Export de la page %1$d sur %2$d…</string>
- <!-- Pictures/PdfCraft is a folder on the phone: keep it as it is. -->
+ <!-- Pictures/ClearPDF is a folder on the phone: keep it as it is. -->
<plurals name="msg_images_saved">
- <item quantity="one">%1$d image enregistrée dans Pictures/PdfCraft</item>
- <item quantity="other">%1$d images enregistrées dans Pictures/PdfCraft</item>
+ <item quantity="one">%1$d image enregistrée dans Pictures/ClearPDF</item>
+ <item quantity="other">%1$d images enregistrées dans Pictures/ClearPDF</item>
</plurals>
<string name="msg_busy_creating_pdf">Création du PDF…</string>
<!-- Create PDF takes at most this many files at once. -->
diff --git a/apps/pdfcraft-android/android/app/src/main/res/values-it/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values-it/strings.xml
index d04a42d..5f05de2 100644
--- a/apps/pdfcraft-android/android/app/src/main/res/values-it/strings.xml
+++ b/apps/pdfcraft-android/android/app/src/main/res/values-it/strings.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Traduzione italiana completa di PdfCraft.
+ Traduzione italiana completa di ClearPDF.
Percorso: res/values-it/strings.xml
@@ -9,7 +9,7 @@
mantenuti compatibili con le risorse Android.
-->
<resources>
- <string name="open_with">Apri in PdfCraft</string>
+ <string name="open_with">Apri in ClearPDF</string>
<!-- ================================================================ -->
<!-- Elementi comuni: pulsanti e termini condivisi -->
@@ -106,7 +106,7 @@
<string name="home_no_starred_body">Aggiungi un file ai preferiti dal suo menu per ritrovarlo rapidamente qui.</string>
<string name="home_device_files_title">File sul dispositivo</string>
<string name="home_device_files_body">Scegli le cartelle da cui elencare i PDF, ad esempio Documenti o una cartella all\'interno di Download. I file che apri da qualsiasi posizione rimangono in Recenti.</string>
- <string name="home_device_files_body_long">Scegli le cartelle da cui elencare i PDF, ad esempio Documenti o una cartella all\'interno di Download (Android non consente alle app di elencare l\'intera cartella Download). PdfCraft può accedere solo alle cartelle che scegli e i file che apri da qualsiasi posizione rimangono in Recenti.</string>
+ <string name="home_device_files_body_long">Scegli le cartelle da cui elencare i PDF, ad esempio Documenti o una cartella all\'interno di Download (Android non consente alle app di elencare l\'intera cartella Download). ClearPDF può accedere solo alle cartelle che scegli e i file che apri da qualsiasi posizione rimangono in Recenti.</string>
<string name="home_no_pdfs_title">Nessun PDF nelle tue cartelle</string>
<string name="home_no_pdfs_body">I PDF presenti nelle cartelle che hai aggiunto verranno visualizzati qui.</string>
<string name="home_add_folder">Aggiungi una cartella</string>
@@ -200,19 +200,19 @@
<!-- Impostazioni -->
- <string name="home_about_app">Informazioni su PdfCraft</string>
+ <string name="home_about_app">Informazioni su ClearPDF</string>
<string name="home_preferences">Preferenze</string>
<string name="home_help_support">Guida e supporto</string>
<string name="home_help">Guida</string>
<string name="home_report_problem">Segnala un problema o suggerisci una funzionalità</string>
- <string name="home_leaving_title">Uscita da PdfCraft</string>
+ <string name="home_leaving_title">Uscita da ClearPDF</string>
<string name="home_continue">Continua</string>
<string name="home_leaving_body">Verrà aperta una pagina web nel browser.</string>
<!-- Preferenze -->
<string name="home_section_notifications">Notifiche</string>
- <string name="home_no_notifications">PdfCraft non invia notifiche.</string>
+ <string name="home_no_notifications">ClearPDF non invia notifiche.</string>
<string name="home_section_suggestions">Suggerimenti automatici</string>
<string name="home_offer_suggestions">Suggerisci le parole utilizzate in precedenza durante la compilazione dei moduli</string>
<string name="home_clear_suggestions">Cancella suggerimenti</string>
@@ -225,13 +225,13 @@
<string name="home_keyboard_shortcuts">Scorciatoie da tastiera</string>
<string name="home_keyboard_shortcuts_body">Con una tastiera collegata: N o PagGiù per la pagina successiva, P o PagSu per quella precedente, i tasti freccia per scorrere, Ctrl+P per stampare, Ctrl e + o − per modificare lo zoom.</string>
<string name="home_section_extra">Funzioni extra</string>
- <string name="home_extra_body">Modifiche facoltative all\'aspetto e al funzionamento di PdfCraft.</string>
+ <string name="home_extra_body">Modifiche facoltative all\'aspetto e al funzionamento di ClearPDF.</string>
<string name="home_status_bar_in_documents">Mostra la barra di stato nei documenti</string>
<string name="home_status_bar_in_documents_body">La barra di stato appare insieme alle barre degli strumenti. Quando tocchi per nasconderle, la pagina usa tutto lo schermo, anche intorno alla fotocamera.</string>
<string name="home_search_count">Mostra il numero dei risultati di ricerca</string>
<string name="home_search_count_body">La ricerca in un documento mostra a quale risultato sei e quanti ce ne sono, ad esempio 3 di 12.</string>
- <!-- Informazioni su PdfCraft -->
+ <!-- Informazioni su ClearPDF -->
<string name="home_section_about">Informazioni</string>
<string name="home_version">Versione %1$s (motore %2$s)</string>
@@ -240,7 +240,6 @@
<string name="home_licences">Licenze open source</string>
<string name="home_source_code">Codice sorgente</string>
<string name="home_engine">Motore PdfCraft</string>
- <string name="home_legal_notice">PdfCraft per Android è basato sul motore Rust di PdfCraft. MIT OR Apache-2.0. PdfCraft non è affiliato ad Adobe; Acrobat è un marchio di Adobe Inc.</string>
<!-- ================================================================ -->
<!-- Schermate degli strumenti -->
@@ -500,7 +499,7 @@
<!-- Autorizzazione del microfono -->
<string name="voice_mic_title">Utilizzare il microfono?</string>
- <string name="voice_mic_rationale">PdfCraft necessita dell\'accesso al microfono per registrare commenti vocali. Puoi autorizzarlo nelle impostazioni dell\'app.</string>
+ <string name="voice_mic_rationale">ClearPDF necessita dell\'accesso al microfono per registrare commenti vocali. Puoi autorizzarlo nelle impostazioni dell\'app.</string>
<string name="voice_open_settings">Apri impostazioni</string>
<string name="voice_not_now">Non ora</string>
@@ -571,7 +570,7 @@
<string name="sign_remove_id_description">Rimuovi l\'ID digitale di %1$s</string>
<string name="sign_remove_id_title">Rimuovere l\'ID digitale?</string>
<string name="sign_remove">Rimuovi</string>
- <string name="sign_remove_id_message">L\'ID digitale di %1$s verrà rimosso da PdfCraft. I documenti già firmati con questo ID manterranno le rispettive firme.</string>
+ <string name="sign_remove_id_message">L\'ID digitale di %1$s verrà rimosso da ClearPDF. I documenti già firmati con questo ID manterranno le rispettive firme.</string>
<!-- Password del file ID digitale -->
@@ -590,7 +589,7 @@
<string name="sign_password_again">Ripeti la password</string>
<string name="sign_password_short">La password deve contenere almeno 6 caratteri.</string>
<string name="sign_password_mismatch">Le password non corrispondono.</string>
- <string name="sign_password_note">PdfCraft non conserva la password e non può recuperarla: dovrai inserirla ogni volta che firmi.</string>
+ <string name="sign_password_note">ClearPDF non conserva la password e non può recuperarla: dovrai inserirla ogni volta che firmi.</string>
<!-- Campo firma vuoto -->
@@ -959,10 +958,10 @@
<!-- Apertura dei documenti -->
- <string name="msg_engine_not_started">Impossibile avviare PdfCraft.</string>
+ <string name="msg_engine_not_started">Impossibile avviare ClearPDF.</string>
<string name="msg_file_moved">Questo file è stato spostato o eliminato.</string>
- <string name="msg_opened_own_copy">È stata aperta la copia di PdfCraft. Per modificare l\'originale, aprilo nuovamente dall\'app in cui si trova.</string>
- <string name="msg_file_access_lost">PdfCraft non può più aprire questo file. Aprilo nuovamente dall\'app in cui si trova oppure utilizzando Apri file.</string>
+ <string name="msg_opened_own_copy">È stata aperta la copia di ClearPDF. Per modificare l\'originale, aprilo nuovamente dall\'app in cui si trova.</string>
+ <string name="msg_file_access_lost">ClearPDF non può più aprire questo file. Aprilo nuovamente dall\'app in cui si trova oppure utilizzando Apri file.</string>
<!-- Annulla e ripristina -->
@@ -1033,7 +1032,7 @@
<string name="msg_sign_read_only">Questo documento non può essere modificato, quindi non può essere firmato.</string>
<string name="msg_id_cannot_sign">Questo ID digitale non può firmare documenti. %1$s</string>
<string name="msg_id_added">ID digitale di %1$s aggiunto</string>
- <string name="msg_id_unusable">PdfCraft non può utilizzare questo file come ID digitale: %1$s</string>
+ <string name="msg_id_unusable">ClearPDF non può utilizzare questo file come ID digitale: %1$s</string>
<string name="msg_busy_creating_id">Creazione dell\'ID digitale…</string>
<string name="msg_id_created">ID digitale creato</string>
<string name="msg_busy_signing">Firma in corso…</string>
@@ -1065,7 +1064,7 @@
<!-- Moduli -->
<string name="msg_form_cleared">Modulo cancellato</string>
- <string name="msg_button_submit">Questo pulsante invia il modulo online, operazione non supportata da PdfCraft.</string>
+ <string name="msg_button_submit">Questo pulsante invia il modulo online, operazione non supportata da ClearPDF.</string>
<string name="msg_suggestions_cleared">Suggerimenti cancellati</string>
<!-- File selezionati -->
@@ -1086,8 +1085,8 @@
<string name="msg_busy_exporting_images">Esportazione delle immagini…</string>
<string name="msg_busy_exporting_page">Esportazione della pagina %1$d di %2$d…</string>
<plurals name="msg_images_saved">
- <item quantity="one">%1$d immagine salvata in Pictures/PdfCraft</item>
- <item quantity="other">%1$d immagini salvate in Pictures/PdfCraft</item>
+ <item quantity="one">%1$d immagine salvata in Pictures/ClearPDF</item>
+ <item quantity="other">%1$d immagini salvate in Pictures/ClearPDF</item>
</plurals>
<string name="msg_busy_creating_pdf">Creazione del PDF…</string>
<plurals name="msg_create_first_files">
diff --git a/apps/pdfcraft-android/android/app/src/main/res/values-night/themes.xml b/apps/pdfcraft-android/android/app/src/main/res/values-night/themes.xml
index 713a470..63f443b 100644
--- a/apps/pdfcraft-android/android/app/src/main/res/values-night/themes.xml
+++ b/apps/pdfcraft-android/android/app/src/main/res/values-night/themes.xml
@@ -2,7 +2,7 @@
<resources>
<color name="window_background">#FF1D1D1D</color>
- <style name="Theme.PdfCraft" parent="android:Theme.Material.NoActionBar">
+ <style name="Theme.ClearPDF" parent="android:Theme.Material.NoActionBar">
<item name="android:windowBackground">@color/window_background</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
diff --git a/apps/pdfcraft-android/android/app/src/main/res/values-pt-rBR/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values-pt-rBR/strings.xml
index fb40dff..e403b91 100644
--- a/apps/pdfcraft-android/android/app/src/main/res/values-pt-rBR/strings.xml
+++ b/apps/pdfcraft-android/android/app/src/main/res/values-pt-rBR/strings.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="open_with">Abrir no PdfCraft</string>
+ <string name="open_with">Abrir no ClearPDF</string>
<string name="common_ok">OK</string>
<string name="common_cancel">Cancelar</string>
<string name="common_done">Concluído</string>
@@ -70,7 +70,7 @@
<string name="home_no_starred_body">Marque um arquivo como favorito no menu para encontrá-lo aqui rapidamente.</string>
<string name="home_device_files_title">Arquivos no seu dispositivo</string>
<string name="home_device_files_body">Escolha pastas para listar PDFs, como Documentos ou uma pasta dentro de Downloads. Os arquivos abertos de qualquer lugar ficam em Recentes.</string>
- <string name="home_device_files_body_long">Escolha pastas para listar PDFs, como Documentos ou uma pasta dentro de Downloads (o Android não permite que apps listem toda a pasta Downloads). O PdfCraft só vê as pastas escolhidas, e os arquivos abertos de qualquer lugar ficam em Recentes.</string>
+ <string name="home_device_files_body_long">Escolha pastas para listar PDFs, como Documentos ou uma pasta dentro de Downloads (o Android não permite que apps listem toda a pasta Downloads). O ClearPDF só vê as pastas escolhidas, e os arquivos abertos de qualquer lugar ficam em Recentes.</string>
<string name="home_no_pdfs_title">Nenhum PDF nas suas pastas</string>
<string name="home_no_pdfs_body">Os PDFs nas pastas adicionadas aparecerão aqui.</string>
<string name="home_add_folder">Adicionar uma pasta</string>
@@ -140,16 +140,16 @@
<string name="home_sort_newest">Modificados mais recentemente</string>
<string name="home_no_results">Nenhum resultado</string>
<string name="home_no_results_body">Confira a ortografia ou tente um nome mais curto.</string>
- <string name="home_about_app">Sobre o PdfCraft</string>
+ <string name="home_about_app">Sobre o ClearPDF</string>
<string name="home_preferences">Preferências</string>
<string name="home_help_support">Ajuda e suporte</string>
<string name="home_help">Ajuda</string>
<string name="home_report_problem">Relatar um problema ou pedir um recurso</string>
- <string name="home_leaving_title">Saindo do PdfCraft</string>
+ <string name="home_leaving_title">Saindo do ClearPDF</string>
<string name="home_continue">Continuar</string>
<string name="home_leaving_body">Isso abrirá uma página da Web no seu navegador.</string>
<string name="home_section_notifications">Notificações</string>
- <string name="home_no_notifications">O PdfCraft não envia notificações.</string>
+ <string name="home_no_notifications">O ClearPDF não envia notificações.</string>
<string name="home_section_suggestions">Sugestões automáticas</string>
<string name="home_offer_suggestions">Sugerir palavras já usadas ao preencher formulários</string>
<string name="home_clear_suggestions">Limpar sugestões</string>
@@ -162,7 +162,7 @@
<string name="home_keyboard_shortcuts">Atalhos do teclado</string>
<string name="home_keyboard_shortcuts_body">Com um teclado conectado: N ou Page Down para a próxima página, P ou Page Up para a anterior, as setas para rolar, Ctrl+P para imprimir e Ctrl e + ou − para ampliar ou reduzir.</string>
<string name="home_section_extra">Recursos extras</string>
- <string name="home_extra_body">Alterações opcionais na aparência e no funcionamento do PdfCraft.</string>
+ <string name="home_extra_body">Alterações opcionais na aparência e no funcionamento do ClearPDF.</string>
<string name="home_status_bar_in_documents">Mostrar a barra de status nos documentos</string>
<string name="home_status_bar_in_documents_body">A barra de status aparece junto com as barras de ferramentas. Ao tocar para ocultá-las, a página ocupa a tela toda, inclusive ao redor da câmera.</string>
<string name="home_search_count">Mostrar o número de resultados da pesquisa</string>
@@ -174,7 +174,6 @@
<string name="home_licences">Licenças de código aberto</string>
<string name="home_source_code">Código-fonte</string>
<string name="home_engine">Mecanismo do PdfCraft</string>
- <string name="home_legal_notice">O PdfCraft para Android é desenvolvido com o mecanismo Rust do PdfCraft. MIT OR Apache-2.0. O PdfCraft não é afiliado à Adobe; Acrobat é uma marca comercial da Adobe Inc.</string>
<string name="tools_compress_action">Comprimir</string>
<string name="tools_compression_level">Nível de compressão:</string>
<string name="tools_compress_high">Alta compressão</string>
@@ -329,7 +328,7 @@
<string name="voice_play_audio">Reproduzir áudio</string>
<string name="voice_comment_kind">Comentário de voz</string>
<string name="voice_mic_title">Usar o microfone?</string>
- <string name="voice_mic_rationale">O PdfCraft precisa do microfone para gravar comentários de voz. Você pode permitir o acesso nas configurações do app.</string>
+ <string name="voice_mic_rationale">O ClearPDF precisa do microfone para gravar comentários de voz. Você pode permitir o acesso nas configurações do app.</string>
<string name="voice_open_settings">Abrir configurações</string>
<string name="voice_not_now">Agora não</string>
<string name="pages_title">Páginas</string>
@@ -379,7 +378,7 @@
<string name="sign_remove_id_description">Remover a ID digital de %1$s</string>
<string name="sign_remove_id_title">Remover ID digital?</string>
<string name="sign_remove">Remover</string>
- <string name="sign_remove_id_message">A ID digital de %1$s será removida do PdfCraft. Os documentos já assinados com ela manterão as assinaturas.</string>
+ <string name="sign_remove_id_message">A ID digital de %1$s será removida do ClearPDF. Os documentos já assinados com ela manterão as assinaturas.</string>
<string name="sign_add">Adicionar</string>
<string name="sign_id_password_prompt">Digite a senha que protege %1$s.</string>
<string name="sign_create_about">Uma ID digital criada aqui é autoassinada: um documento assinado com ela mostra qualquer alteração feita depois da assinatura, mas ninguém mais confirma que é você. Para isso, use o arquivo de ID fornecido por uma organização ou autoridade certificadora.</string>
@@ -392,7 +391,7 @@
<string name="sign_password_again">Digite a senha novamente</string>
<string name="sign_password_short">A senha precisa ter pelo menos 8 caracteres.</string>
<string name="sign_password_mismatch">As senhas não correspondem.</string>
- <string name="sign_password_note">O PdfCraft não guarda nem recupera a senha: você precisa digitá-la sempre que assinar.</string>
+ <string name="sign_password_note">O ClearPDF não guarda nem recupera a senha: você precisa digitá-la sempre que assinar.</string>
<string name="sign_add_your_signature">Adicionar sua assinatura</string>
<string name="sign_signatures">Assinaturas</string>
<string name="sign_none">Este documento não tem assinaturas.</string>
@@ -633,10 +632,10 @@
<string name="forms_reset">Redefinir</string>
<string name="forms_previous_field">Campo anterior</string>
<string name="forms_next_field">Próximo campo</string>
- <string name="msg_engine_not_started">Não foi possível iniciar o PdfCraft.</string>
+ <string name="msg_engine_not_started">Não foi possível iniciar o ClearPDF.</string>
<string name="msg_file_moved">Este arquivo foi movido ou excluído.</string>
- <string name="msg_opened_own_copy">Cópia do PdfCraft aberta. Para alterar o original, abra-o novamente no app em que ele está.</string>
- <string name="msg_file_access_lost">O PdfCraft não consegue mais abrir este arquivo. Abra-o novamente no app em que ele está ou use Abrir arquivo.</string>
+ <string name="msg_opened_own_copy">Cópia do ClearPDF aberta. Para alterar o original, abra-o novamente no app em que ele está.</string>
+ <string name="msg_file_access_lost">O ClearPDF não consegue mais abrir este arquivo. Abra-o novamente no app em que ele está ou use Abrir arquivo.</string>
<string name="msg_undone">%1$s desfeito</string>
<string name="msg_redone">%1$s refeito</string>
<string name="msg_tool_blocked_security">Esta ferramenta não está disponível devido às configurações de segurança do documento.</string>
@@ -671,7 +670,7 @@
<string name="msg_sign_read_only">Este documento não pode ser alterado nem assinado.</string>
<string name="msg_id_cannot_sign">Esta ID digital não pode assinar documentos. %1$s</string>
<string name="msg_id_added">ID digital de %1$s adicionada</string>
- <string name="msg_id_unusable">O PdfCraft não pode usar este arquivo como ID digital: %1$s</string>
+ <string name="msg_id_unusable">O ClearPDF não pode usar este arquivo como ID digital: %1$s</string>
<string name="msg_busy_creating_id">Criando sua ID digital…</string>
<string name="msg_id_created">ID digital criada</string>
<string name="msg_busy_signing">Assinando…</string>
@@ -694,7 +693,7 @@
<string name="msg_picture_unreadable">Não foi possível ler a imagem.</string>
<string name="msg_gif_not_supported">Não é possível adicionar imagens GIF.</string>
<string name="msg_form_cleared">Formulário limpo</string>
- <string name="msg_button_submit">Este botão enviaria o formulário pela internet, o que o PdfCraft não faz.</string>
+ <string name="msg_button_submit">Este botão enviaria o formulário pela internet, o que o ClearPDF não faz.</string>
<string name="msg_suggestions_cleared">Sugestões limpas</string>
<string name="msg_that_file_unreadable">Não foi possível ler esse arquivo.</string>
<string name="msg_named_file_unreadable">Não foi possível ler %1$s.</string>
@@ -709,8 +708,8 @@
<string name="msg_busy_exporting_images">Exportando imagens…</string>
<string name="msg_busy_exporting_page">Exportando a página %1$d de %2$d…</string>
<plurals name="msg_images_saved">
- <item quantity="one">%1$d imagem salva em Pictures/PdfCraft</item>
- <item quantity="other">%1$d imagens salvas em Pictures/PdfCraft</item>
+ <item quantity="one">%1$d imagem salva em Pictures/ClearPDF</item>
+ <item quantity="other">%1$d imagens salvas em Pictures/ClearPDF</item>
</plurals>
<string name="msg_busy_creating_pdf">Criando PDF…</string>
<plurals name="msg_create_first_files">
diff --git a/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml
index 53bb465..a3319af 100644
--- a/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml
+++ b/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- PdfCraft's text, in US English.
+ ClearPDF's text, in US English.
- To translate PdfCraft: copy this file to res/values-<language>/strings.xml (values-es for
+ To translate ClearPDF: copy this file to res/values-<language>/strings.xml (values-es for
Spanish, values-pt-rBR for Brazilian Portuguese, values-zh-rCN for simplified Chinese) and
translate the text between the tags. Keep each name, every placeholder (%1$s, %2$d: the
number says which value goes there, so a translation may move them), escapes such as \' and
@@ -10,8 +10,8 @@
few, many). A string left out shows in English.
-->
<resources>
- <string name="app_name" translatable="false">PdfCraft</string>
- <string name="open_with">Open in PdfCraft</string>
+ <string name="app_name" translatable="false">ClearPDF</string>
+ <string name="open_with">Open in ClearPDF</string>
<!-- Shared: buttons and words used on many screens -->
<string name="common_ok">OK</string>
@@ -98,7 +98,7 @@
<string name="home_device_files_title">Files on your device</string>
<string name="home_device_files_body">Choose folders to list PDFs from, such as Documents or a folder inside Download. Files you open from anywhere stay in Recent.</string>
<!-- On this device, before any folder is added: the longer explanation -->
- <string name="home_device_files_body_long">Choose folders to list PDFs from, such as Documents or a folder inside Download (Android doesn\'t let apps list the whole Download folder). PdfCraft sees only the folders you choose, and files you open from anywhere stay in Recent.</string>
+ <string name="home_device_files_body_long">Choose folders to list PDFs from, such as Documents or a folder inside Download (Android doesn\'t let apps list the whole Download folder). ClearPDF sees only the folders you choose, and files you open from anywhere stay in Recent.</string>
<string name="home_no_pdfs_title">No PDFs in your folders</string>
<string name="home_no_pdfs_body">PDFs in the folders you added will appear here.</string>
<string name="home_add_folder">Add a folder</string>
@@ -201,18 +201,18 @@
<string name="home_no_results_body">Check the spelling, or try a shorter name.</string>
<!-- Settings -->
- <string name="home_about_app">About PdfCraft</string>
+ <string name="home_about_app">About ClearPDF</string>
<string name="home_preferences">Preferences</string>
<string name="home_help_support">Help &amp; Support</string>
<string name="home_help">Help</string>
<string name="home_report_problem">Report a problem or request a feature</string>
- <string name="home_leaving_title">Leaving PdfCraft</string>
+ <string name="home_leaving_title">Leaving ClearPDF</string>
<string name="home_continue">Continue</string>
<string name="home_leaving_body">This opens a web page in your browser.</string>
<!-- Settings: Preferences -->
<string name="home_section_notifications">Notifications</string>
- <string name="home_no_notifications">PdfCraft doesn\'t send notifications.</string>
+ <string name="home_no_notifications">ClearPDF doesn\'t send notifications.</string>
<string name="home_section_suggestions">Auto-suggestions</string>
<string name="home_offer_suggestions">Offer words you used before when filling in forms</string>
<string name="home_clear_suggestions">Clear suggestions</string>
@@ -227,13 +227,13 @@
<!-- N, P, Page Down, Page Up, Ctrl+P, Ctrl, + and − are keys on the keyboard -->
<string name="home_keyboard_shortcuts_body">With a keyboard connected: N or Page Down for the next page, P or Page Up for the previous one, the arrow keys to scroll, Ctrl+P to print, Ctrl and + or − to zoom.</string>
<string name="home_section_extra">Extra Features</string>
- <string name="home_extra_body">Optional changes to how PdfCraft looks and works.</string>
+ <string name="home_extra_body">Optional changes to how ClearPDF looks and works.</string>
<string name="home_status_bar_in_documents">Show the status bar in documents</string>
<string name="home_status_bar_in_documents_body">The status bar shows with the toolbars. When you tap to hide them, the page uses the whole screen, around the camera too.</string>
<string name="home_search_count">Show the number of search results</string>
<string name="home_search_count_body">Find in a document shows which result you\'re on and how many there are, such as 3 of 12.</string>
- <!-- Settings: About PdfCraft -->
+ <!-- Settings: About ClearPDF -->
<string name="home_section_about">About</string>
<!-- %1$s is the app's version, %2$s the engine's version -->
<string name="home_version">Version %1$s (engine %2$s)</string>
@@ -244,7 +244,7 @@
<string name="home_source_code">Source code</string>
<string name="home_engine">PdfCraft engine</string>
<!-- Keep the licence names (MIT, Apache-2.0) and the trademark notice -->
- <string name="home_legal_notice">PdfCraft for Android is built on PdfCraft\'s Rust engine. MIT OR Apache-2.0. PdfCraft is not affiliated with Adobe; Acrobat is a trademark of Adobe Inc.</string>
+ <string name="home_legal_notice">ClearPDF is built on the Rust engine of PdfCraft by storytold, and on PdfCraft for Android by the ArtCraft Team. MIT OR Apache-2.0. ClearPDF is not affiliated with Adobe; Acrobat is a trademark of Adobe Inc.</string>
<!-- Tool screens: Compress PDF -->
<string name="tools_compress_action">Compress</string>
@@ -367,7 +367,7 @@
<!-- Open-source licences: the parts that are not names -->
<string name="root_licence_pdfcraft">PdfCraft (engine and app)</string>
- <string name="root_licence_pdfcraft_terms">MIT OR Apache-2.0, by storytold and contributors</string>
+ <string name="root_licence_pdfcraft_terms">MIT OR Apache-2.0, by storytold, the ArtCraft Team and contributors</string>
<string name="root_licence_lucide">Lucide icons</string>
<string name="root_licence_inter">Inter typeface</string>
<string name="root_licence_dancing_script">Dancing Script typeface (typed signatures)</string>
@@ -498,7 +498,7 @@
<!-- Voice comments: the microphone was refused before -->
<string name="voice_mic_title">Use the microphone?</string>
- <string name="voice_mic_rationale">PdfCraft needs the microphone to record voice comments. You can allow it in the app\'s settings.</string>
+ <string name="voice_mic_rationale">ClearPDF needs the microphone to record voice comments. You can allow it in the app\'s settings.</string>
<string name="voice_open_settings">Open settings</string>
<string name="voice_not_now">Not now</string>
@@ -582,7 +582,7 @@
<string name="sign_remove_id_title">Remove digital ID?</string>
<string name="sign_remove">Remove</string>
<!-- Translator note: %1$s is the person's name on the digital ID -->
- <string name="sign_remove_id_message">%1$s\'s digital ID is removed from PdfCraft. Documents already signed with it keep their signatures.</string>
+ <string name="sign_remove_id_message">%1$s\'s digital ID is removed from ClearPDF. Documents already signed with it keep their signatures.</string>
<!-- Digital signatures: the password of a digital ID file being added -->
<string name="sign_add">Add</string>
@@ -601,7 +601,7 @@
<string name="sign_password_again">The password again</string>
<string name="sign_password_short">The password needs at least 8 characters.</string>
<string name="sign_password_mismatch">The passwords don\'t match.</string>
- <string name="sign_password_note">PdfCraft doesn\'t keep the password and can\'t recover it: you type it each time you sign.</string>
+ <string name="sign_password_note">ClearPDF doesn\'t keep the password and can\'t recover it: you type it each time you sign.</string>
<!-- Digital signatures: tapping an empty signature field -->
<string name="sign_add_your_signature">Add your signature</string>
@@ -975,11 +975,11 @@
<!-- Messages: notices at the bottom of the screen, progress, errors -->
<!-- ================================================================== -->
<!-- Messages: opening documents -->
- <string name="msg_engine_not_started">PdfCraft couldn\'t start.</string>
+ <string name="msg_engine_not_started">ClearPDF couldn\'t start.</string>
<string name="msg_file_moved">This file has been moved or deleted.</string>
- <string name="msg_opened_own_copy">Opened PdfCraft\'s copy. To change the original, open it again from the app it\'s in.</string>
+ <string name="msg_opened_own_copy">Opened ClearPDF\'s copy. To change the original, open it again from the app it\'s in.</string>
<!-- "Open file" is the name of the button on Home that picks a file. -->
- <string name="msg_file_access_lost">PdfCraft can\'t open this file any more. Open it again from the app it\'s in, or with Open file.</string>
+ <string name="msg_file_access_lost">ClearPDF can\'t open this file any more. Open it again from the app it\'s in, or with Open file.</string>
<!-- Messages: undo and redo. %1$s is the name of the edit, as the engine gives it (for example "Add comment"). -->
<string name="msg_undone">%1$s undone</string>
@@ -1046,7 +1046,7 @@
<!-- %1$s is the name of the person the digital ID belongs to. -->
<string name="msg_id_added">Added %1$s\'s digital ID</string>
<!-- %1$s is the reason the file was refused. -->
- <string name="msg_id_unusable">PdfCraft can\'t use this file as a digital ID: %1$s</string>
+ <string name="msg_id_unusable">ClearPDF can\'t use this file as a digital ID: %1$s</string>
<string name="msg_busy_creating_id">Creating your digital ID…</string>
<string name="msg_id_created">Digital ID created</string>
<string name="msg_busy_signing">Signing…</string>
@@ -1078,7 +1078,7 @@
<!-- Messages: forms -->
<string name="msg_form_cleared">Form cleared</string>
- <string name="msg_button_submit">This button sends the form online, which PdfCraft doesn\'t do.</string>
+ <string name="msg_button_submit">This button sends the form online, which ClearPDF doesn\'t do.</string>
<!-- Words remembered from form fields, offered while typing. -->
<string name="msg_suggestions_cleared">Suggestions cleared</string>
@@ -1099,10 +1099,10 @@
<string name="msg_busy_exporting_images">Exporting images…</string>
<!-- %1$d is the page being exported, %2$d how many pages there are. -->
<string name="msg_busy_exporting_page">Exporting page %1$d of %2$d…</string>
- <!-- Pictures/PdfCraft is a folder on the phone: keep it as it is. -->
+ <!-- Pictures/ClearPDF is a folder on the phone: keep it as it is. -->
<plurals name="msg_images_saved">
- <item quantity="one">%1$d image saved to Pictures/PdfCraft</item>
- <item quantity="other">%1$d images saved to Pictures/PdfCraft</item>
+ <item quantity="one">%1$d image saved to Pictures/ClearPDF</item>
+ <item quantity="other">%1$d images saved to Pictures/ClearPDF</item>
</plurals>
<string name="msg_busy_creating_pdf">Creating PDF…</string>
<!-- Create PDF takes at most this many files at once. -->
@@ -1173,4 +1173,62 @@
<string name="service_action_forward">Forward 15 seconds</string>
<!-- Translator note: notification button that stops reading aloud -->
<string name="service_action_stop">Stop</string>
+
+ <!-- ClearPDF's own screens (the desk, files, tools, settings) -->
+ <string name="desk_greeting_morning">Good morning,</string>
+ <string name="desk_greeting_afternoon">Good afternoon,</string>
+ <string name="desk_greeting_evening">Good evening,</string>
+ <string name="desk_greeting_night">Still up?</string>
+ <string name="desk_tagline_reading">pick up where you left off.</string>
+ <string name="desk_tagline_empty">let\'s open something.</string>
+ <string name="desk_continue">Continue</string>
+ <string name="desk_page_of">Page %1$d of %2$d</string>
+ <string name="desk_pages">%1$d pages</string>
+ <string name="desk_make_something">Make something</string>
+ <string name="desk_on_your_desk">On your desk</string>
+ <string name="desk_see_all">See all</string>
+ <string name="desk_empty_title">Your desk is clear</string>
+ <string name="desk_empty_body">Open a PDF and it lands here, ready to pick up later.</string>
+ <string name="desk_all_tools">All tools</string>
+ <string name="desk_photos_to_pdf">Photos to PDF</string>
+ <string name="dock_desk">Desk</string>
+ <string name="dock_files">Files</string>
+ <string name="dock_tools">Tools</string>
+ <string name="dock_create">Create</string>
+ <string name="create_title">Start something</string>
+ <string name="create_subtitle">Open, scan or build a PDF.</string>
+ <string name="files_today">Today</string>
+ <string name="files_this_week">This week</string>
+ <string name="files_earlier">Earlier</string>
+ <string name="files_places">More places</string>
+ <string name="files_starred_empty_title">Nothing starred yet</string>
+ <string name="files_starred_empty_body">Star a file from its menu and it waits for you here.</string>
+ <plurals name="files_count">
+ <item quantity="one">%1$d file</item>
+ <item quantity="other">%1$d files</item>
+ </plurals>
+ <string name="tools_subtitle">Every way to bend a PDF, in one place.</string>
+ <string name="tools_featured">Start here</string>
+ <string name="settings_look">Look &amp; feel</string>
+ <string name="settings_theme">Theme</string>
+ <string name="settings_theme_system">Auto</string>
+ <string name="settings_theme_light">Light</string>
+ <string name="settings_theme_dark">Dark</string>
+ <string name="settings_glass">Glass</string>
+ <string name="settings_glass_clear">Clear</string>
+ <string name="settings_glass_frosted">Frosted</string>
+ <string name="settings_glass_crystal">Crystal</string>
+ <string name="settings_glass_lite">Lite</string>
+ <string name="settings_motion">Motion</string>
+ <string name="settings_motion_calm">Calm</string>
+ <string name="settings_motion_normal">Normal</string>
+ <string name="settings_motion_bouncy">Bouncy</string>
+ <string name="settings_motion_jelly">Jelly</string>
+ <string name="settings_haptics">Haptic feedback</string>
+ <string name="settings_reading">Reading</string>
+ <string name="settings_forms">Forms</string>
+ <string name="settings_about">About</string>
+ <string name="settings_credits_title">Built with friends</string>
+ <string name="settings_credits_body">ClearPDF runs on PdfCraft\'s Rust engine by storytold and PdfCraft for Android by the ArtCraft Team. Its glass is Kyant0\'s backdrop library.</string>
+ <string name="settings_version">Version %1$s</string>
</resources>
diff --git a/apps/pdfcraft-android/android/app/src/main/res/values/themes.xml b/apps/pdfcraft-android/android/app/src/main/res/values/themes.xml
index ad59dab..3d63a31 100644
--- a/apps/pdfcraft-android/android/app/src/main/res/values/themes.xml
+++ b/apps/pdfcraft-android/android/app/src/main/res/values/themes.xml
@@ -5,7 +5,7 @@
<!-- PdfCraft green, the app icon's field (assets/app-icon/README.md) -->
<color name="ic_launcher_background">#FFB70228</color>
- <style name="Theme.PdfCraft" parent="android:Theme.Material.Light.NoActionBar">
+ <style name="Theme.ClearPDF" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:windowBackground">@color/window_background</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/CommentListTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/CommentListTest.kt
similarity index 90%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/CommentListTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/CommentListTest.kt
index bfb016b..6e066f9 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/CommentListTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/CommentListTest.kt
@@ -1,8 +1,8 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
-import io.github.artcraftandroid.pdfcraft.ui.viewer.commentDateLabel
-import io.github.artcraftandroid.pdfcraft.ui.viewer.modifiedLabel
-import io.github.artcraftandroid.pdfcraft.ui.viewer.threadsTitle
+import com.chethan616.clearpdf.ui.viewer.commentDateLabel
+import com.chethan616.clearpdf.ui.viewer.modifiedLabel
+import com.chethan616.clearpdf.ui.viewer.threadsTitle
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/EditListsTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/EditListsTest.kt
similarity index 93%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/EditListsTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/EditListsTest.kt
index f3c46f6..5fd1191 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/EditListsTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/EditListsTest.kt
@@ -1,6 +1,6 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ListStyle
+import com.chethan616.clearpdf.ui.viewer.ListStyle
import org.junit.Assert.assertEquals
import org.junit.Test
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/FreeTextLayoutTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/FreeTextLayoutTest.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/FreeTextLayoutTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/FreeTextLayoutTest.kt
index feffb42..bc74147 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/FreeTextLayoutTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/FreeTextLayoutTest.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/PdfDateTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/PdfDateTest.kt
similarity index 94%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/PdfDateTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/PdfDateTest.kt
index e1403b1..53c80c4 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/PdfDateTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/PdfDateTest.kt
@@ -1,6 +1,6 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
-import io.github.artcraftandroid.pdfcraft.ui.viewer.pdfDateLabel
+import com.chethan616.clearpdf.ui.viewer.pdfDateLabel
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/QuickToolbarTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/QuickToolbarTest.kt
similarity index 82%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/QuickToolbarTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/QuickToolbarTest.kt
index 78b0a08..04ae060 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/QuickToolbarTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/QuickToolbarTest.kt
@@ -1,8 +1,8 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
-import io.github.artcraftandroid.pdfcraft.ui.viewer.QuickTool
-import io.github.artcraftandroid.pdfcraft.ui.viewer.QuickToolbarPrefs
-import io.github.artcraftandroid.pdfcraft.ui.viewer.toolbarSlots
+import com.chethan616.clearpdf.ui.viewer.QuickTool
+import com.chethan616.clearpdf.ui.viewer.QuickToolbarPrefs
+import com.chethan616.clearpdf.ui.viewer.toolbarSlots
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ReadAloudLanguageTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ReadAloudLanguageTest.kt
similarity index 84%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ReadAloudLanguageTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ReadAloudLanguageTest.kt
index 5442e41..b27ae1c 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ReadAloudLanguageTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ReadAloudLanguageTest.kt
@@ -1,6 +1,6 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
-import io.github.artcraftandroid.pdfcraft.ui.viewer.languageIndex
+import com.chethan616.clearpdf.ui.viewer.languageIndex
import java.util.Locale
import org.junit.Assert.assertEquals
import org.junit.Test
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ReadAloudWordsTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ReadAloudWordsTest.kt
similarity index 82%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ReadAloudWordsTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ReadAloudWordsTest.kt
index 243d32d..a96f2db 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ReadAloudWordsTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ReadAloudWordsTest.kt
@@ -1,6 +1,6 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ReadAloud
+import com.chethan616.clearpdf.ui.viewer.ReadAloud
import org.junit.Assert.assertEquals
import org.junit.Test
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ScanSessionTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ScanSessionTest.kt
similarity index 98%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ScanSessionTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ScanSessionTest.kt
index 7c1f5d7..c061615 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ScanSessionTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ScanSessionTest.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ShapeSnapTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ShapeSnapTest.kt
similarity index 94%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ShapeSnapTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ShapeSnapTest.kt
index 07412de..b1f1754 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ShapeSnapTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ShapeSnapTest.kt
@@ -1,8 +1,8 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import androidx.compose.ui.geometry.Offset
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ShapeSnap
-import io.github.artcraftandroid.pdfcraft.ui.viewer.SnappedShape
+import com.chethan616.clearpdf.ui.viewer.ShapeSnap
+import com.chethan616.clearpdf.ui.viewer.SnappedShape
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/SignatureBoxTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/SignatureBoxTest.kt
similarity index 89%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/SignatureBoxTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/SignatureBoxTest.kt
index 4e79318..9b9ff6b 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/SignatureBoxTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/SignatureBoxTest.kt
@@ -1,7 +1,7 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
-import io.github.artcraftandroid.pdfcraft.ui.viewer.fitSignatureBox
-import io.github.artcraftandroid.pdfcraft.ui.viewer.readableName
+import com.chethan616.clearpdf.ui.viewer.fitSignatureBox
+import com.chethan616.clearpdf.ui.viewer.readableName
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Test
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/UiTextTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/UiTextTest.kt
similarity index 97%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/UiTextTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/UiTextTest.kt
index 8fc7336..78f6524 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/UiTextTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/UiTextTest.kt
@@ -1,4 +1,4 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import java.io.File
import org.junit.Assert.assertTrue
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ViewerGeometryTest.kt b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ViewerGeometryTest.kt
similarity index 96%
rename from apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ViewerGeometryTest.kt
rename to apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ViewerGeometryTest.kt
index 7e44728..44b5eff 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/ViewerGeometryTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/com/chethan616/clearpdf/ui/ViewerGeometryTest.kt
@@ -1,10 +1,10 @@
-package io.github.artcraftandroid.pdfcraft.ui
+package com.chethan616.clearpdf.ui
import androidx.compose.ui.geometry.Offset
-import io.github.artcraftandroid.pdfcraft.ui.viewer.DocLayout
-import io.github.artcraftandroid.pdfcraft.ui.viewer.PageMode
-import io.github.artcraftandroid.pdfcraft.ui.viewer.PageSize
-import io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerState
+import com.chethan616.clearpdf.ui.viewer.DocLayout
+import com.chethan616.clearpdf.ui.viewer.PageMode
+import com.chethan616.clearpdf.ui.viewer.PageSize
+import com.chethan616.clearpdf.ui.viewer.ViewerState
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
diff --git a/apps/pdfcraft-android/android/backdrop/LICENSE b/apps/pdfcraft-android/android/backdrop/LICENSE
new file mode 100644
index 0000000..9935e87
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/LICENSE
@@ -0,0 +1,67 @@
+Apache License
+Version 2.0, January 2004
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner.
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License.
+
+END OF TERMS AND CONDITIONS
+
+Copyright 2024 Kyant
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/apps/pdfcraft-android/android/backdrop/build.gradle.kts b/apps/pdfcraft-android/android/backdrop/build.gradle.kts
new file mode 100644
index 0000000..bca4d1d
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/build.gradle.kts
@@ -0,0 +1,40 @@
+// The backdrop library of AndroidLiquidGlass by Kyant0 (Apache-2.0, LICENSE), as ClearPDF adapted it.
+// Only hand-port upstream fixes into it.
+plugins {
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.compose)
+}
+
+android {
+ namespace = "com.kyant.backdrop"
+ compileSdk = 37
+
+ defaultConfig {
+ minSdk = 29
+ consumerProguardFiles("consumer-rules.pro")
+ }
+
+ buildFeatures {
+ compose = true
+ }
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+ }
+}
+
+kotlin {
+ compilerOptions {
+ freeCompilerArgs.addAll("-Xcontext-parameters")
+ }
+}
+
+dependencies {
+ implementation(libs.androidx.core.ktx)
+ implementation(platform(libs.androidx.compose.bom))
+ implementation(libs.androidx.compose.foundation)
+ implementation(libs.androidx.compose.ui)
+ implementation(libs.androidx.compose.ui.graphics)
+ implementation(libs.kyant.shapes)
+}
diff --git a/apps/pdfcraft-android/android/backdrop/consumer-rules.pro b/apps/pdfcraft-android/android/backdrop/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/AndroidManifest.xml b/apps/pdfcraft-android/android/backdrop/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..cce937e
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/AndroidManifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+
+</manifest>
\ No newline at end of file
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/Backdrop.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/Backdrop.kt
new file mode 100644
index 0000000..cfb3c32
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/Backdrop.kt
@@ -0,0 +1,23 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop
+
+import androidx.compose.ui.graphics.GraphicsLayerScope
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.layout.LayoutCoordinates
+import androidx.compose.ui.unit.Density
+
+interface Backdrop {
+
+ val isCoordinatesDependent: Boolean
+
+ fun DrawScope.drawBackdrop(
+ density: Density,
+ coordinates: LayoutCoordinates?,
+ layerBlock: (GraphicsLayerScope.() -> Unit)? = null
+ )
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/BackdropEffectScope.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/BackdropEffectScope.kt
new file mode 100644
index 0000000..4adad36
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/BackdropEffectScope.kt
@@ -0,0 +1,84 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop
+
+import android.graphics.RenderEffect
+import android.graphics.RuntimeShader
+import android.os.Build
+import androidx.annotation.RequiresApi
+import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.graphics.Shape
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.unit.Density
+import androidx.compose.ui.unit.LayoutDirection
+
+sealed interface BackdropEffectScope : Density, RuntimeShaderCache {
+
+ val size: Size
+
+ val layoutDirection: LayoutDirection
+
+ val shape: Shape
+
+ var padding: Float
+
+ var renderEffect: RenderEffect?
+}
+
+internal abstract class BackdropEffectScopeImpl : BackdropEffectScope, RuntimeShaderCache {
+
+ override var density: Float = 1f
+ override var fontScale: Float = 1f
+ override var size: Size = Size.Unspecified
+ override var layoutDirection: LayoutDirection = LayoutDirection.Ltr
+ override var padding: Float = 0f
+ override var renderEffect: RenderEffect? = null
+
+ private val runtimeShaderCache = RuntimeShaderCacheImpl()
+
+ @RequiresApi(Build.VERSION_CODES.TIRAMISU)
+ override fun obtainRuntimeShader(key: String, string: String): RuntimeShader {
+ return runtimeShaderCache.obtainRuntimeShader(key, string)
+ }
+
+ fun update(scope: DrawScope): Boolean {
+ val newDensity = scope.density
+ val newFontScale = scope.fontScale
+ val newSize = scope.size
+ val newLayoutDirection = scope.layoutDirection
+
+ val changed = newDensity != density ||
+ newFontScale != fontScale ||
+ newSize != size ||
+ newLayoutDirection != layoutDirection
+
+ if (changed) {
+ density = newDensity
+ fontScale = newFontScale
+ size = newSize
+ layoutDirection = newLayoutDirection
+ }
+
+ return changed
+ }
+
+ fun apply(effects: BackdropEffectScope.() -> Unit) {
+ padding = 0f
+ renderEffect = null
+ effects()
+ }
+
+ fun reset() {
+ density = 1f
+ fontScale = 1f
+ size = Size.Unspecified
+ layoutDirection = LayoutDirection.Ltr
+ padding = 0f
+ renderEffect = null
+ runtimeShaderCache.clear()
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/DrawBackdropModifier.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/DrawBackdropModifier.kt
new file mode 100644
index 0000000..ed83d3c
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/DrawBackdropModifier.kt
@@ -0,0 +1,394 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop
+
+import android.os.Build
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableFloatStateOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.neverEqualPolicy
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.GraphicsLayerScope
+import androidx.compose.ui.graphics.Shape
+import androidx.compose.ui.graphics.asComposeRenderEffect
+import androidx.compose.ui.graphics.drawscope.ContentDrawScope
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.graphics.layer.GraphicsLayer
+import androidx.compose.ui.graphics.layer.drawLayer
+import androidx.compose.ui.layout.LayoutCoordinates
+import androidx.compose.ui.layout.Measurable
+import androidx.compose.ui.layout.MeasureResult
+import androidx.compose.ui.layout.MeasureScope
+import androidx.compose.ui.node.DrawModifierNode
+import androidx.compose.ui.node.GlobalPositionAwareModifierNode
+import androidx.compose.ui.node.LayoutModifierNode
+import androidx.compose.ui.node.ModifierNodeElement
+import androidx.compose.ui.node.ObserverModifierNode
+import androidx.compose.ui.node.observeReads
+import androidx.compose.ui.node.requireGraphicsContext
+import androidx.compose.ui.platform.InspectorInfo
+import androidx.compose.ui.unit.Constraints
+import androidx.compose.ui.unit.IntOffset
+import androidx.compose.ui.unit.IntSize
+import com.kyant.backdrop.backdrops.LayerBackdrop
+import com.kyant.backdrop.highlight.Highlight
+import com.kyant.backdrop.highlight.HighlightElement
+import com.kyant.backdrop.shadow.InnerShadow
+import com.kyant.backdrop.shadow.InnerShadowElement
+import com.kyant.backdrop.shadow.Shadow
+import com.kyant.backdrop.shadow.ShadowElement
+
+private val DefaultHighlight = { Highlight.Default }
+private val DefaultShadow = { Shadow.Default }
+private val DefaultOnDrawBackdrop: DrawScope.(DrawScope.() -> Unit) -> Unit = { it() }
+
+fun Modifier.drawPlainBackdrop(
+ backdrop: Backdrop,
+ shape: () -> Shape,
+ effects: BackdropEffectScope.() -> Unit,
+ layerBlock: (GraphicsLayerScope.() -> Unit)? = null,
+ exportedBackdrop: LayerBackdrop? = null,
+ onDrawBehind: (DrawScope.() -> Unit)? = null,
+ onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit = DefaultOnDrawBackdrop,
+ onDrawSurface: (DrawScope.() -> Unit)? = null,
+ onDrawFront: (DrawScope.() -> Unit)? = null
+): Modifier {
+ val shapeProvider = ShapeProvider(shape)
+ return this
+ .then(
+ if (layerBlock != null) {
+ Modifier.graphicsLayer(layerBlock)
+ } else {
+ Modifier
+ }
+ )
+ .then(
+ DrawBackdropElement(
+ backdrop = backdrop,
+ shapeProvider = shapeProvider,
+ effects = effects,
+ layerBlock = layerBlock,
+ exportedBackdrop = exportedBackdrop,
+ onDrawBehind = onDrawBehind,
+ onDrawBackdrop = onDrawBackdrop,
+ onDrawSurface = onDrawSurface,
+ onDrawFront = onDrawFront
+ )
+ )
+}
+
+fun Modifier.drawBackdrop(
+ backdrop: Backdrop,
+ shape: () -> Shape,
+ effects: BackdropEffectScope.() -> Unit,
+ highlight: (() -> Highlight?)? = DefaultHighlight,
+ shadow: (() -> Shadow?)? = DefaultShadow,
+ innerShadow: (() -> InnerShadow?)? = null,
+ layerBlock: (GraphicsLayerScope.() -> Unit)? = null,
+ exportedBackdrop: LayerBackdrop? = null,
+ onDrawBehind: (DrawScope.() -> Unit)? = null,
+ onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit = DefaultOnDrawBackdrop,
+ onDrawSurface: (DrawScope.() -> Unit)? = null,
+ onDrawFront: (DrawScope.() -> Unit)? = null
+): Modifier {
+ val shapeProvider = ShapeProvider(shape)
+ return this
+ .then(
+ if (layerBlock != null) {
+ Modifier.graphicsLayer(layerBlock)
+ } else {
+ Modifier
+ }
+ )
+ .then(
+ if (innerShadow != null) {
+ InnerShadowElement(
+ shapeProvider = shapeProvider,
+ shadow = innerShadow
+ )
+ } else {
+ Modifier
+ }
+ )
+ .then(
+ if (shadow != null) {
+ ShadowElement(
+ shapeProvider = shapeProvider,
+ shadow = shadow
+ )
+ } else {
+ Modifier
+ }
+ )
+ .then(
+ if (highlight != null) {
+ HighlightElement(
+ shapeProvider = shapeProvider,
+ highlight = highlight
+ )
+ } else {
+ Modifier
+ }
+ )
+ .then(
+ DrawBackdropElement(
+ backdrop = backdrop,
+ shapeProvider = shapeProvider,
+ effects = effects,
+ layerBlock = layerBlock,
+ exportedBackdrop = exportedBackdrop,
+ onDrawBehind = onDrawBehind,
+ onDrawBackdrop = onDrawBackdrop,
+ onDrawSurface = onDrawSurface,
+ onDrawFront = onDrawFront
+ )
+ )
+}
+
+private class DrawBackdropElement(
+ val backdrop: Backdrop,
+ val shapeProvider: ShapeProvider,
+ val effects: BackdropEffectScope.() -> Unit,
+ val layerBlock: (GraphicsLayerScope.() -> Unit)?,
+ val exportedBackdrop: LayerBackdrop?,
+ val onDrawBehind: (DrawScope.() -> Unit)?,
+ val onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit,
+ val onDrawSurface: (DrawScope.() -> Unit)?,
+ val onDrawFront: (DrawScope.() -> Unit)?
+) : ModifierNodeElement<DrawBackdropNode>() {
+
+ override fun create(): DrawBackdropNode {
+ return DrawBackdropNode(
+ backdrop = backdrop,
+ shapeProvider = shapeProvider,
+ effects = effects,
+ layerBlock = layerBlock,
+ exportedBackdrop = exportedBackdrop,
+ onDrawBehind = onDrawBehind,
+ onDrawBackdrop = onDrawBackdrop,
+ onDrawSurface = onDrawSurface,
+ onDrawFront = onDrawFront
+ )
+ }
+
+ override fun update(node: DrawBackdropNode) {
+ node.backdrop = backdrop
+ node.shapeProvider = shapeProvider
+ node.effects = effects
+ node.layerBlock = layerBlock
+ if (node.exportedBackdrop != exportedBackdrop) {
+ node.exportedBackdrop?.layerCoordinates = null
+ node.exportedBackdrop = exportedBackdrop
+ }
+ node.onDrawBehind = onDrawBehind
+ node.onDrawBackdrop = onDrawBackdrop
+ node.onDrawSurface = onDrawSurface
+ node.onDrawFront = onDrawFront
+ node.invalidateDrawCache()
+ }
+
+ override fun InspectorInfo.inspectableProperties() {
+ name = "drawBackdrop"
+ properties["backdrop"] = backdrop
+ properties["shapeProvider"] = shapeProvider
+ properties["effects"] = effects
+ properties["layerBlock"] = layerBlock
+ properties["exportedBackdrop"] = exportedBackdrop
+ properties["onDrawBehind"] = onDrawBehind
+ properties["onDrawBackdrop"] = onDrawBackdrop
+ properties["onDrawSurface"] = onDrawSurface
+ properties["onDrawFront"] = onDrawFront
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is DrawBackdropElement) return false
+
+ if (backdrop != other.backdrop) return false
+ if (shapeProvider != other.shapeProvider) return false
+ if (effects != other.effects) return false
+ if (layerBlock != other.layerBlock) return false
+ if (exportedBackdrop != other.exportedBackdrop) return false
+ if (onDrawBehind != other.onDrawBehind) return false
+ if (onDrawBackdrop != other.onDrawBackdrop) return false
+ if (onDrawSurface != other.onDrawSurface) return false
+ if (onDrawFront != other.onDrawFront) return false
+
+ return true
+ }
+
+ override fun hashCode(): Int {
+ var result = backdrop.hashCode()
+ result = 31 * result + shapeProvider.hashCode()
+ result = 31 * result + effects.hashCode()
+ result = 31 * result + (layerBlock?.hashCode() ?: 0)
+ result = 31 * result + (exportedBackdrop?.hashCode() ?: 0)
+ result = 31 * result + (onDrawBehind?.hashCode() ?: 0)
+ result = 31 * result + onDrawBackdrop.hashCode()
+ result = 31 * result + (onDrawSurface?.hashCode() ?: 0)
+ result = 31 * result + (onDrawFront?.hashCode() ?: 0)
+ return result
+ }
+}
+
+private class DrawBackdropNode(
+ var backdrop: Backdrop,
+ var shapeProvider: ShapeProvider,
+ var effects: BackdropEffectScope.() -> Unit,
+ var layerBlock: (GraphicsLayerScope.() -> Unit)?,
+ var exportedBackdrop: LayerBackdrop?,
+ var onDrawBehind: (DrawScope.() -> Unit)?,
+ var onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit,
+ var onDrawSurface: (DrawScope.() -> Unit)?,
+ var onDrawFront: (DrawScope.() -> Unit)?
+) : LayoutModifierNode, DrawModifierNode, GlobalPositionAwareModifierNode, ObserverModifierNode, Modifier.Node() {
+
+ private val effectScope =
+ object : BackdropEffectScopeImpl() {
+
+ override val shape: Shape get() = shapeProvider.innerShape
+ }
+
+ private var graphicsLayer: GraphicsLayer? = null
+
+ private val layoutLayerBlock: GraphicsLayerScope.() -> Unit = {
+ clip = true
+ shape = shapeProvider.shape
+ compositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen
+ }
+
+ private var layoutCoordinates: LayoutCoordinates? by mutableStateOf(null, neverEqualPolicy())
+
+ private var padding by mutableFloatStateOf(0f)
+
+ private val recordBackdropBlock: (DrawScope.() -> Unit) = {
+ val canvas = drawContext.canvas
+ val padding = padding
+
+ if (padding != 0f) {
+ canvas.translate(padding, padding)
+ }
+ onDrawBackdrop {
+ with(backdrop) {
+ drawBackdrop(
+ density = effectScope,
+ coordinates = layoutCoordinates,
+ layerBlock = layerBlock
+ )
+ }
+ }
+ if (padding != 0f) {
+ canvas.translate(-padding, -padding)
+ }
+ }
+
+ private val drawBackdropLayer: DrawScope.() -> Unit = {
+ val layer = graphicsLayer
+ if (layer != null) {
+ val padding = padding
+
+ recordLayer(
+ layer,
+ size = IntSize(
+ size.width.toInt() + padding.toInt() * 2,
+ size.height.toInt() + padding.toInt() * 2
+ ),
+ block = recordBackdropBlock
+ )
+
+ layer.topLeft =
+ if (padding != 0f) IntOffset(-padding.toInt(), -padding.toInt())
+ else IntOffset.Zero
+ drawLayer(layer)
+ }
+ }
+
+ override fun MeasureScope.measure(
+ measurable: Measurable,
+ constraints: Constraints
+ ): MeasureResult {
+ val placeable = measurable.measure(constraints)
+ return layout(placeable.width, placeable.height) {
+ placeable.placeWithLayer(IntOffset.Zero, layerBlock = layoutLayerBlock)
+ }
+ }
+
+ override fun ContentDrawScope.draw() {
+ if (effectScope.update(this)) {
+ updateEffects()
+ }
+
+ onDrawBehind?.invoke(this)
+ drawBackdropLayer()
+ onDrawSurface?.invoke(this)
+ drawContent()
+ onDrawFront?.invoke(this)
+
+ exportedBackdrop?.graphicsLayer?.let { layer ->
+ recordLayer(layer) {
+ onDrawBehind?.invoke(this)
+ drawBackdropLayer()
+ onDrawSurface?.invoke(this)
+ onDrawFront?.invoke(this)
+ }
+ }
+ }
+
+ override fun onGloballyPositioned(coordinates: LayoutCoordinates) {
+ if (coordinates.isAttached) {
+ if (backdrop.isCoordinatesDependent) {
+ layoutCoordinates = coordinates
+ } else {
+ if (layoutCoordinates != null) {
+ layoutCoordinates = null
+ }
+ }
+ exportedBackdrop?.layerCoordinates = coordinates
+ }
+ }
+
+ override fun onObservedReadsChanged() {
+ invalidateDrawCache()
+ }
+
+ fun invalidateDrawCache() {
+ observeEffects()
+ }
+
+ private fun observeEffects() {
+ observeReads { updateEffects() }
+ }
+
+ private fun updateEffects() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ effectScope.apply(effects)
+ graphicsLayer?.renderEffect = effectScope.renderEffect?.asComposeRenderEffect()
+ padding = effectScope.padding
+ }
+ }
+
+ override fun onAttach() {
+ val graphicsContext = requireGraphicsContext()
+ graphicsLayer = graphicsContext.createGraphicsLayer()
+
+ observeEffects()
+ }
+
+ override fun onDetach() {
+ val graphicsContext = requireGraphicsContext()
+ graphicsLayer?.let { layer ->
+ graphicsContext.releaseGraphicsLayer(layer)
+ graphicsLayer = null
+ }
+
+ effectScope.reset()
+ layoutCoordinates = null
+ exportedBackdrop?.layerCoordinates = null
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/InverseLayerScope.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/InverseLayerScope.kt
new file mode 100644
index 0000000..2d3ea46
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/InverseLayerScope.kt
@@ -0,0 +1,136 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop
+
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.graphics.BlendMode
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.ColorFilter
+import androidx.compose.ui.graphics.CompositingStrategy
+import androidx.compose.ui.graphics.DefaultCameraDistance
+import androidx.compose.ui.graphics.DefaultShadowColor
+import androidx.compose.ui.graphics.GraphicsLayerScope
+import androidx.compose.ui.graphics.Matrix
+import androidx.compose.ui.graphics.RectangleShape
+import androidx.compose.ui.graphics.RenderEffect
+import androidx.compose.ui.graphics.Shape
+import androidx.compose.ui.graphics.TransformOrigin
+import androidx.compose.ui.graphics.drawscope.DrawTransform
+import androidx.compose.ui.unit.Density
+import kotlin.math.PI
+import kotlin.math.cos
+import kotlin.math.sin
+
+internal class InverseLayerScope : GraphicsLayerScope {
+
+ override var size: Size = Size.Unspecified
+ override var density: Float = 1f
+ override var fontScale: Float = 1f
+
+ override var scaleX: Float = 1f
+ override var scaleY: Float = 1f
+ override var alpha: Float = 0f
+ override var translationX: Float = 0f
+ override var translationY: Float = 0f
+ override var shadowElevation: Float = 0f
+ override var ambientShadowColor: Color = DefaultShadowColor
+ override var spotShadowColor: Color = DefaultShadowColor
+ override var rotationX: Float = 0f
+ override var rotationY: Float = 0f
+ override var rotationZ: Float = 0f
+ override var cameraDistance: Float = DefaultCameraDistance
+ override var transformOrigin: TransformOrigin = TransformOrigin.Center
+ override var shape: Shape = RectangleShape
+ override var clip: Boolean = false
+ override var renderEffect: RenderEffect? = null
+ override var blendMode: BlendMode = BlendMode.SrcOver
+ override var colorFilter: ColorFilter? = null
+ override var compositingStrategy: CompositingStrategy = CompositingStrategy.Auto
+
+ private var matrix: Matrix? = null
+
+ fun DrawTransform.inverseTransform(
+ density: Density,
+ layerBlock: GraphicsLayerScope.() -> Unit
+ ) {
+ [email protected] = density.density
+ fontScale = density.fontScale
+
+ layerBlock()
+
+ inverseTransformAtTopLeft(
+ rotationZ = rotationZ,
+ scaleX = scaleX,
+ scaleY = scaleY
+ )
+ }
+
+ fun reset() {
+ size = Size.Unspecified
+ density = 1f
+ fontScale = 1f
+
+ scaleX = 1f
+ scaleY = 1f
+ alpha = 1f
+ translationX = 0f
+ translationY = 0f
+ shadowElevation = 0f
+ ambientShadowColor = DefaultShadowColor
+ spotShadowColor = DefaultShadowColor
+ rotationX = 0f
+ rotationY = 0f
+ rotationZ = 0f
+ cameraDistance = DefaultCameraDistance
+ transformOrigin = TransformOrigin.Center
+ shape = RectangleShape
+ clip = false
+ renderEffect = null
+ blendMode = BlendMode.SrcOver
+ colorFilter = null
+ compositingStrategy = CompositingStrategy.Auto
+
+ matrix = null
+ }
+
+ private fun DrawTransform.inverseTransformAtTopLeft(
+ rotationZ: Float = 0f,
+ scaleX: Float = 1f,
+ scaleY: Float = 1f
+ ) {
+ if (rotationZ == 0f) {
+ if (scaleX != 0f && scaleY != 0f) {
+ scale(1f / scaleX, 1f / scaleY, Offset.Zero)
+ }
+ return
+ }
+
+ val matrix = matrix ?: Matrix().also { matrix = it }
+ if (matrix.values.size < 16) return
+
+ val rz = rotationZ * (PI / 180.0)
+ val rsz = sin(rz).toFloat()
+ val rcz = cos(rz).toFloat()
+
+ val a00 = rcz * scaleX
+ val a01 = rsz * scaleY
+ val a10 = -rsz * scaleX
+ val a11 = rcz * scaleY
+
+ val det = a00 * a11 - a01 * a10
+ if (det == 0f) return
+ val invDet = 1f / det
+ matrix[0, 0] = a11 * invDet
+ matrix[0, 1] = -a01 * invDet
+ matrix[1, 0] = -a10 * invDet
+ matrix[1, 1] = a00 * invDet
+
+ transform(matrix)
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/LayerRecorder.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/LayerRecorder.kt
new file mode 100644
index 0000000..5aa307a
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/LayerRecorder.kt
@@ -0,0 +1,32 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop
+
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.graphics.layer.GraphicsLayer
+import androidx.compose.ui.node.DelegatableNode
+import androidx.compose.ui.node.requireDensity
+import androidx.compose.ui.unit.IntSize
+import androidx.compose.ui.unit.toIntSize
+
+context(node: DelegatableNode)
+internal fun DrawScope.recordLayer(
+ layer: GraphicsLayer,
+ size: IntSize = this.size.toIntSize(),
+ block: DrawScope.() -> Unit
+) {
+ val density = node.requireDensity()
+ layer.record(size) {
+ val prevDensity = drawContext.density
+ drawContext.density = density
+ try {
+ this.block()
+ } finally {
+ drawContext.density = prevDensity
+ }
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/Outline.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/Outline.kt
new file mode 100644
index 0000000..692e76e
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/Outline.kt
@@ -0,0 +1,24 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop
+
+import androidx.compose.ui.graphics.Canvas
+import androidx.compose.ui.graphics.Outline
+import androidx.compose.ui.graphics.Path
+
+internal fun Canvas.clipOutline(outline: Outline, path: Path?) {
+ when (outline) {
+ is Outline.Rectangle -> clipRect(outline.rect)
+ is Outline.Rounded -> {
+ path!!.rewind()
+ path.addRoundRect(outline.roundRect)
+ clipPath(path)
+ }
+
+ is Outline.Generic -> clipPath(outline.path)
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/RuntimeShaderCache.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/RuntimeShaderCache.kt
new file mode 100644
index 0000000..70c4a4e
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/RuntimeShaderCache.kt
@@ -0,0 +1,35 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop
+
+import android.graphics.RuntimeShader
+import android.os.Build
+import androidx.annotation.RequiresApi
+import org.intellij.lang.annotations.Language
+
+sealed interface RuntimeShaderCache {
+
+ @RequiresApi(Build.VERSION_CODES.TIRAMISU)
+ fun obtainRuntimeShader(
+ key: String,
+ @Language("AGSL") string: String
+ ): RuntimeShader
+}
+
+internal class RuntimeShaderCacheImpl : RuntimeShaderCache {
+
+ private val runtimeShaders = mutableMapOf<String, RuntimeShader>()
+
+ @RequiresApi(Build.VERSION_CODES.TIRAMISU)
+ override fun obtainRuntimeShader(key: String, string: String): RuntimeShader {
+ return runtimeShaders.getOrPut(key) { RuntimeShader(string) }
+ }
+
+ fun clear() {
+ runtimeShaders.clear()
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/Shaders.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/Shaders.kt
new file mode 100644
index 0000000..45d7d0f
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/Shaders.kt
@@ -0,0 +1,224 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+/*
+ Copyright 2025 Kyant
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+package com.kyant.backdrop
+
+import org.intellij.lang.annotations.Language
+
+@Language("AGSL")
+private const val RoundedRectSDF = """
+float radiusAt(float2 coord, float4 radii) {
+ if (coord.x >= 0.0) {
+ if (coord.y <= 0.0) return radii.y;
+ else return radii.z;
+ } else {
+ if (coord.y <= 0.0) return radii.x;
+ else return radii.w;
+ }
+}
+
+float sdRoundedRect(float2 coord, float2 halfSize, float radius) {
+ float2 cornerCoord = abs(coord) - (halfSize - float2(radius));
+ float outside = length(max(cornerCoord, 0.0)) - radius;
+ float inside = min(max(cornerCoord.x, cornerCoord.y), 0.0);
+ return outside + inside;
+}
+
+float2 gradSdRoundedRect(float2 coord, float2 halfSize, float radius) {
+ float2 cornerCoord = abs(coord) - (halfSize - float2(radius));
+ if (cornerCoord.x >= 0.0 || cornerCoord.y >= 0.0) {
+ return sign(coord) * normalize(max(cornerCoord, 0.0));
+ } else {
+ float gradX = step(cornerCoord.y, cornerCoord.x);
+ return sign(coord) * float2(gradX, 1.0 - gradX);
+ }
+}"""
+
+@Language("AGSL")
+internal const val RoundedRectRefractionShaderString = """
+uniform shader content;
+
+uniform float2 size;
+uniform float2 offset;
+uniform float4 cornerRadii;
+uniform float refractionHeight;
+uniform float refractionAmount;
+uniform float depthEffect;
+
+$RoundedRectSDF
+
+float circleMap(float x) {
+ return 1.0 - sqrt(1.0 - x * x);
+}
+
+half4 main(float2 coord) {
+ float2 halfSize = size * 0.5;
+ float2 centeredCoord = (coord + offset) - halfSize;
+ float radius = radiusAt(coord, cornerRadii);
+
+ float sd = sdRoundedRect(centeredCoord, halfSize, radius);
+ if (-sd >= refractionHeight) {
+ return content.eval(coord);
+ }
+ sd = min(sd, 0.0);
+
+ float d = circleMap(1.0 - -sd / refractionHeight) * refractionAmount;
+ float gradRadius = min(radius * 1.5, min(halfSize.x, halfSize.y));
+ float2 grad = normalize(gradSdRoundedRect(centeredCoord, halfSize, gradRadius) + depthEffect * normalize(centeredCoord));
+
+ float2 refractedCoord = coord + d * grad;
+ return content.eval(refractedCoord);
+}"""
+
+@Language("AGSL")
+internal val RoundedRectRefractionWithDispersionShaderString = """
+uniform shader content;
+
+uniform float2 size;
+uniform float2 offset;
+uniform float4 cornerRadii;
+uniform float refractionHeight;
+uniform float refractionAmount;
+uniform float depthEffect;
+uniform float chromaticAberration;
+
+$RoundedRectSDF
+
+float circleMap(float x) {
+ return 1.0 - sqrt(1.0 - x * x);
+}
+
+half4 main(float2 coord) {
+ float2 halfSize = size * 0.5;
+ float2 centeredCoord = (coord + offset) - halfSize;
+ float radius = radiusAt(coord, cornerRadii);
+
+ float sd = sdRoundedRect(centeredCoord, halfSize, radius);
+ if (-sd >= refractionHeight) {
+ return content.eval(coord);
+ }
+ sd = min(sd, 0.0);
+
+ float d = circleMap(1.0 - -sd / refractionHeight) * refractionAmount;
+ float gradRadius = min(radius * 1.5, min(halfSize.x, halfSize.y));
+ float2 grad = normalize(gradSdRoundedRect(centeredCoord, halfSize, gradRadius) + depthEffect * normalize(centeredCoord));
+
+ float2 refractedCoord = coord + d * grad;
+ float dispersionIntensity = chromaticAberration * ((centeredCoord.x * centeredCoord.y) / (halfSize.x * halfSize.y));
+ float2 dispersedCoord = d * grad * dispersionIntensity;
+
+ half4 color = half4(0.0);
+
+ half4 red = content.eval(refractedCoord + dispersedCoord);
+ color.r += red.r / 3.5;
+ color.a += red.a / 7.0;
+
+ half4 orange = content.eval(refractedCoord + dispersedCoord * (2.0 / 3.0));
+ color.r += orange.r / 3.5;
+ color.g += orange.g / 7.0;
+ color.a += orange.a / 7.0;
+
+ half4 yellow = content.eval(refractedCoord + dispersedCoord * (1.0 / 3.0));
+ color.r += yellow.r / 3.5;
+ color.g += yellow.g / 3.5;
+ color.a += yellow.a / 7.0;
+
+ half4 green = content.eval(refractedCoord);
+ color.g += green.g / 3.5;
+ color.a += green.a / 7.0;
+
+ half4 cyan = content.eval(refractedCoord - dispersedCoord * (1.0 / 3.0));
+ color.g += cyan.g / 3.5;
+ color.b += cyan.b / 3.0;
+ color.a += cyan.a / 7.0;
+
+ half4 blue = content.eval(refractedCoord - dispersedCoord * (2.0 / 3.0));
+ color.b += blue.b / 3.0;
+ color.a += blue.a / 7.0;
+
+ half4 purple = content.eval(refractedCoord - dispersedCoord);
+ color.r += purple.r / 7.0;
+ color.b += purple.b / 3.0;
+ color.a += purple.a / 7.0;
+
+ return color;
+}"""
+
+@Language("AGSL")
+internal const val DefaultHighlightShaderString = """
+uniform float2 size;
+uniform float4 cornerRadii;
+layout(color) uniform half4 color;
+uniform float angle;
+uniform float falloff;
+
+$RoundedRectSDF
+
+half4 main(float2 coord) {
+ float2 halfSize = size * 0.5;
+ float2 centeredCoord = coord - halfSize;
+ float radius = radiusAt(coord, cornerRadii);
+
+ float gradRadius = min(radius * 1.5, min(halfSize.x, halfSize.y));
+ float2 grad = gradSdRoundedRect(centeredCoord, halfSize, gradRadius);
+ float2 normal = float2(cos(angle), sin(angle));
+ float d = dot(grad, normal);
+ float intensity = pow(abs(d), falloff);
+ return color * intensity;
+}"""
+
+@Language("AGSL")
+internal const val AmbientHighlightShaderString = """
+uniform float2 size;
+uniform float4 cornerRadii;
+uniform float angle;
+uniform float falloff;
+
+$RoundedRectSDF
+
+half4 main(float2 coord) {
+ float2 halfSize = size * 0.5;
+ float2 centeredCoord = coord - halfSize;
+ float radius = radiusAt(coord, cornerRadii);
+
+ float gradRadius = min(radius * 1.5, min(halfSize.x, halfSize.y));
+ float2 grad = gradSdRoundedRect(centeredCoord, halfSize, gradRadius);
+ float2 normal = float2(cos(angle), sin(angle));
+ float d = dot(grad, normal);
+ float intensity = pow(abs(d), falloff);
+ float t = step(0.0, d);
+ return half4(t, t, t, 1.0) * intensity;
+}"""
+
+@Language("AGSL")
+internal const val GammaAdjustmentShaderString = """
+uniform shader content;
+
+uniform float power;
+
+half4 main(float2 coord) {
+ half4 color = content.eval(coord);
+ color.r = pow(color.r, power);
+ color.g = pow(color.g, power);
+ color.b = pow(color.b, power);
+ return color;
+}"""
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/ShapeProvider.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/ShapeProvider.kt
new file mode 100644
index 0000000..4c13df3
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/ShapeProvider.kt
@@ -0,0 +1,50 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop
+
+import androidx.compose.runtime.Immutable
+import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.graphics.Outline
+import androidx.compose.ui.graphics.Shape
+import androidx.compose.ui.unit.Density
+import androidx.compose.ui.unit.LayoutDirection
+
+@Immutable
+internal class ShapeProvider(val shapeBlock: () -> Shape) {
+
+ private var _shape: Shape? = null
+ private var _outline: Outline? = null
+ private var _size: Size = Size.Unspecified
+ private var _layoutDirection: LayoutDirection? = null
+ private var _density: Float? = null
+
+ val innerShape
+ get() = shapeBlock()
+
+ val shape = object : Shape {
+
+ override fun createOutline(
+ size: Size,
+ layoutDirection: LayoutDirection,
+ density: Density
+ ): Outline {
+ val shape = shapeBlock()
+ if (_shape != shape) {
+ _shape = shape
+ _outline = null
+ }
+ if (_outline == null || _size != size || _layoutDirection != layoutDirection || _density != density.density) {
+ _size = size
+ _layoutDirection = layoutDirection
+ _density = density.density
+ _outline = shape.createOutline(size, layoutDirection, density)
+ }
+
+ return _outline!!
+ }
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/Backdrop.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/Backdrop.kt
new file mode 100644
index 0000000..abbdbe8
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/Backdrop.kt
@@ -0,0 +1,43 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.backdrops
+
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.graphics.GraphicsLayerScope
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.layout.LayoutCoordinates
+import androidx.compose.ui.unit.Density
+import com.kyant.backdrop.Backdrop
+
+@Composable
+fun rememberBackdrop(
+ backdrop: Backdrop,
+ onDraw: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit
+): Backdrop {
+ return remember(backdrop, onDraw) {
+ Backdrop(backdrop, onDraw)
+ }
+}
+
+@Immutable
+private class Backdrop(
+ val backdrop: Backdrop,
+ val onDraw: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit
+) : Backdrop {
+
+ override val isCoordinatesDependent: Boolean = backdrop.isCoordinatesDependent
+
+ override fun DrawScope.drawBackdrop(
+ density: Density,
+ coordinates: LayoutCoordinates?,
+ layerBlock: (GraphicsLayerScope.() -> Unit)?
+ ) {
+ onDraw { with(backdrop) { drawBackdrop(density, coordinates, layerBlock) } }
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/CanvasBackdrop.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/CanvasBackdrop.kt
new file mode 100644
index 0000000..5227b15
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/CanvasBackdrop.kt
@@ -0,0 +1,41 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.backdrops
+
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.graphics.GraphicsLayerScope
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.layout.LayoutCoordinates
+import androidx.compose.ui.unit.Density
+import com.kyant.backdrop.Backdrop
+
+@Composable
+fun rememberCanvasBackdrop(
+ onDraw: DrawScope.() -> Unit
+): Backdrop {
+ return remember(onDraw) {
+ CanvasBackdrop(onDraw)
+ }
+}
+
+@Immutable
+private class CanvasBackdrop(
+ val onDraw: DrawScope.() -> Unit
+) : Backdrop {
+
+ override val isCoordinatesDependent: Boolean = false
+
+ override fun DrawScope.drawBackdrop(
+ density: Density,
+ coordinates: LayoutCoordinates?,
+ layerBlock: (GraphicsLayerScope.() -> Unit)?
+ ) {
+ onDraw()
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/CombinedBackdrop.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/CombinedBackdrop.kt
new file mode 100644
index 0000000..44772b9
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/CombinedBackdrop.kt
@@ -0,0 +1,105 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.backdrops
+
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.graphics.GraphicsLayerScope
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.layout.LayoutCoordinates
+import androidx.compose.ui.unit.Density
+import com.kyant.backdrop.Backdrop
+
+@Composable
+fun rememberCombinedBackdrop(
+ backdrop1: Backdrop,
+ backdrop2: Backdrop
+): Backdrop {
+ return remember(backdrop1, backdrop2) {
+ Combined2Backdrops(backdrop1, backdrop2)
+ }
+}
+
+@Composable
+fun rememberCombinedBackdrop(
+ backdrop1: Backdrop,
+ backdrop2: Backdrop,
+ backdrop3: Backdrop
+): Backdrop {
+ return remember(backdrop1, backdrop2, backdrop3) {
+ Combined3Backdrops(backdrop1, backdrop2, backdrop3)
+ }
+}
+
+@Composable
+fun rememberCombinedBackdrop(vararg backdrops: Backdrop): Backdrop {
+ return remember(*backdrops) {
+ CombinedBackdrops(*backdrops)
+ }
+}
+
+@Immutable
+private class Combined2Backdrops(
+ val backdrop1: Backdrop,
+ val backdrop2: Backdrop
+) : Backdrop {
+
+ override val isCoordinatesDependent: Boolean =
+ backdrop1.isCoordinatesDependent || backdrop2.isCoordinatesDependent
+
+ override fun DrawScope.drawBackdrop(
+ density: Density,
+ coordinates: LayoutCoordinates?,
+ layerBlock: (GraphicsLayerScope.() -> Unit)?
+ ) {
+ with(backdrop1) { drawBackdrop(density, coordinates, layerBlock) }
+ with(backdrop2) { drawBackdrop(density, coordinates, layerBlock) }
+ }
+}
+
+@Immutable
+private class Combined3Backdrops(
+ val backdrop1: Backdrop,
+ val backdrop2: Backdrop,
+ val backdrop3: Backdrop
+) : Backdrop {
+
+ override val isCoordinatesDependent: Boolean =
+ backdrop1.isCoordinatesDependent ||
+ backdrop2.isCoordinatesDependent ||
+ backdrop3.isCoordinatesDependent
+
+ override fun DrawScope.drawBackdrop(
+ density: Density,
+ coordinates: LayoutCoordinates?,
+ layerBlock: (GraphicsLayerScope.() -> Unit)?
+ ) {
+ with(backdrop1) { drawBackdrop(density, coordinates, layerBlock) }
+ with(backdrop2) { drawBackdrop(density, coordinates, layerBlock) }
+ with(backdrop3) { drawBackdrop(density, coordinates, layerBlock) }
+ }
+}
+
+@Immutable
+private class CombinedBackdrops(
+ vararg val backdrops: Backdrop
+) : Backdrop {
+
+ override val isCoordinatesDependent: Boolean =
+ backdrops.any { it.isCoordinatesDependent }
+
+ override fun DrawScope.drawBackdrop(
+ density: Density,
+ coordinates: LayoutCoordinates?,
+ layerBlock: (GraphicsLayerScope.() -> Unit)?
+ ) {
+ backdrops.forEach { backdrop ->
+ with(backdrop) { drawBackdrop(density, coordinates, layerBlock) }
+ }
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/EmptyBackdrop.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/EmptyBackdrop.kt
new file mode 100644
index 0000000..47c0398
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/EmptyBackdrop.kt
@@ -0,0 +1,31 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.backdrops
+
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.Stable
+import androidx.compose.ui.graphics.GraphicsLayerScope
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.layout.LayoutCoordinates
+import androidx.compose.ui.unit.Density
+import com.kyant.backdrop.Backdrop
+
+@Stable
+fun emptyBackdrop(): Backdrop = EmptyBackdrop
+
+@Immutable
+private object EmptyBackdrop : Backdrop {
+
+ override val isCoordinatesDependent: Boolean = false
+
+ override fun DrawScope.drawBackdrop(
+ density: Density,
+ coordinates: LayoutCoordinates?,
+ layerBlock: (GraphicsLayerScope.() -> Unit)?
+ ) {
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/LayerBackdrop.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/LayerBackdrop.kt
new file mode 100644
index 0000000..5167954
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/LayerBackdrop.kt
@@ -0,0 +1,80 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.backdrops
+
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.Stable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.graphics.GraphicsLayerScope
+import androidx.compose.ui.graphics.drawscope.ContentDrawScope
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.graphics.drawscope.withTransform
+import androidx.compose.ui.graphics.layer.GraphicsLayer
+import androidx.compose.ui.graphics.layer.drawLayer
+import androidx.compose.ui.graphics.rememberGraphicsLayer
+import androidx.compose.ui.layout.LayoutCoordinates
+import androidx.compose.ui.layout.positionInWindow
+import androidx.compose.ui.unit.Density
+import com.kyant.backdrop.Backdrop
+import com.kyant.backdrop.InverseLayerScope
+
+private val DefaultOnDraw: ContentDrawScope.() -> Unit = { drawContent() }
+
+@Composable
+fun rememberLayerBackdrop(
+ graphicsLayer: GraphicsLayer = rememberGraphicsLayer(),
+ onDraw: ContentDrawScope.() -> Unit = DefaultOnDraw
+): LayerBackdrop {
+ return remember(graphicsLayer, onDraw) {
+ LayerBackdrop(graphicsLayer, onDraw)
+ }
+}
+
+@Stable
+class LayerBackdrop internal constructor(
+ val graphicsLayer: GraphicsLayer,
+ internal val onDraw: ContentDrawScope.() -> Unit
+) : Backdrop {
+
+ override val isCoordinatesDependent: Boolean = true
+
+ internal var layerCoordinates: LayoutCoordinates? by mutableStateOf(null)
+
+ private var inverseLayerScope: InverseLayerScope? = null
+
+ override fun DrawScope.drawBackdrop(
+ density: Density,
+ coordinates: LayoutCoordinates?,
+ layerBlock: (GraphicsLayerScope.() -> Unit)?
+ ) {
+ val coordinates = coordinates ?: return
+ val layerCoordinates = layerCoordinates ?: return
+ withTransform({
+ if (layerBlock != null) {
+ with(obtainInverseLayerScope()) { inverseTransform(density, layerBlock) }
+ }
+ val offset =
+ try {
+ layerCoordinates.localPositionOf(coordinates)
+ } catch (_: Exception) {
+ // TODO: outer transformations lead to wrong position calculation
+ coordinates.positionInWindow() - layerCoordinates.positionInWindow()
+ }
+ translate(-offset.x, -offset.y)
+ }) {
+ drawLayer(graphicsLayer)
+ }
+ }
+
+ private fun obtainInverseLayerScope(): InverseLayerScope {
+ return inverseLayerScope?.apply { reset() }
+ ?: InverseLayerScope().also { inverseLayerScope = it }
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/LayerBackdropModifier.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/LayerBackdropModifier.kt
new file mode 100644
index 0000000..8ac46c8
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/backdrops/LayerBackdropModifier.kt
@@ -0,0 +1,75 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.backdrops
+
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.drawscope.ContentDrawScope
+import androidx.compose.ui.layout.LayoutCoordinates
+import androidx.compose.ui.node.DrawModifierNode
+import androidx.compose.ui.node.GlobalPositionAwareModifierNode
+import androidx.compose.ui.node.ModifierNodeElement
+import androidx.compose.ui.node.invalidateDraw
+import androidx.compose.ui.platform.InspectorInfo
+import com.kyant.backdrop.recordLayer
+
+fun Modifier.layerBackdrop(backdrop: LayerBackdrop): Modifier =
+ this then LayerBackdropElement(backdrop)
+
+private class LayerBackdropElement(
+ val backdrop: LayerBackdrop
+) : ModifierNodeElement<LayerBackdropNode>() {
+
+ override fun create(): LayerBackdropNode {
+ return LayerBackdropNode(backdrop)
+ }
+
+ override fun update(node: LayerBackdropNode) {
+ if (node.backdrop != backdrop) {
+ node.backdrop.layerCoordinates = null
+ node.backdrop = backdrop
+ }
+ node.invalidateDraw()
+ }
+
+ override fun InspectorInfo.inspectableProperties() {
+ name = "layerBackdrop"
+ properties["backdrop"] = backdrop
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is LayerBackdropElement) return false
+
+ if (backdrop != other.backdrop) return false
+
+ return true
+ }
+
+ override fun hashCode(): Int {
+ return backdrop.hashCode()
+ }
+}
+
+private class LayerBackdropNode(
+ var backdrop: LayerBackdrop
+) : DrawModifierNode, GlobalPositionAwareModifierNode, Modifier.Node() {
+
+ override fun ContentDrawScope.draw() {
+ drawContent()
+ recordLayer(backdrop.graphicsLayer) { backdrop.onDraw(this@draw) }
+ }
+
+ override fun onGloballyPositioned(coordinates: LayoutCoordinates) {
+ if (coordinates.isAttached) {
+ backdrop.layerCoordinates = coordinates
+ }
+ }
+
+ override fun onDetach() {
+ backdrop.layerCoordinates = null
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/Blur.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/Blur.kt
new file mode 100644
index 0000000..1ded516
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/Blur.kt
@@ -0,0 +1,45 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.effects
+
+import android.graphics.RenderEffect
+import android.os.Build
+import androidx.annotation.FloatRange
+import androidx.compose.ui.graphics.TileMode
+import androidx.compose.ui.graphics.toAndroidTileMode
+import com.kyant.backdrop.BackdropEffectScope
+
+fun BackdropEffectScope.blur(
+ @FloatRange(from = 0.0) radius: Float,
+ edgeTreatment: TileMode = TileMode.Clamp
+) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return
+ if (radius <= 0f) return
+
+ if (edgeTreatment != TileMode.Clamp || renderEffect != null) {
+ if (radius > padding) {
+ padding = radius
+ }
+ }
+
+ val currentEffect = renderEffect
+ renderEffect =
+ if (currentEffect != null) {
+ RenderEffect.createBlurEffect(
+ radius,
+ radius,
+ currentEffect,
+ edgeTreatment.toAndroidTileMode()
+ )
+ } else {
+ RenderEffect.createBlurEffect(
+ radius,
+ radius,
+ edgeTreatment.toAndroidTileMode()
+ )
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/ColorFilter.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/ColorFilter.kt
new file mode 100644
index 0000000..6531e10
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/ColorFilter.kt
@@ -0,0 +1,116 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.effects
+
+import android.graphics.ColorFilter
+import android.graphics.ColorMatrix
+import android.graphics.ColorMatrixColorFilter
+import android.graphics.RenderEffect
+import android.os.Build
+import androidx.annotation.FloatRange
+import androidx.compose.ui.graphics.asAndroidColorFilter
+import com.kyant.backdrop.BackdropEffectScope
+import com.kyant.backdrop.GammaAdjustmentShaderString
+import kotlin.math.pow
+
+fun BackdropEffectScope.colorFilter(colorFilter: ColorFilter) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return
+
+ val currentEffect = renderEffect
+ renderEffect =
+ if (currentEffect != null) {
+ RenderEffect.createColorFilterEffect(colorFilter, currentEffect)
+ } else {
+ RenderEffect.createColorFilterEffect(colorFilter)
+ }
+}
+
+fun BackdropEffectScope.colorFilter(colorFilter: androidx.compose.ui.graphics.ColorFilter) {
+ colorFilter(colorFilter.asAndroidColorFilter())
+}
+
+fun BackdropEffectScope.opacity(@FloatRange(from = 0.0, to = 1.0) alpha: Float) {
+ val colorMatrix = ColorMatrix(
+ floatArrayOf(
+ 1f, 0f, 0f, 0f, 0f,
+ 0f, 1f, 0f, 0f, 0f,
+ 0f, 0f, 1f, 0f, 0f,
+ 0f, 0f, 0f, alpha, 0f
+ )
+ )
+ colorFilter(ColorMatrixColorFilter(colorMatrix))
+}
+
+fun BackdropEffectScope.colorControls(
+ brightness: Float = 0f,
+ contrast: Float = 1f,
+ saturation: Float = 1f
+) {
+ if (brightness == 0f && contrast == 1f && saturation == 1f) {
+ return
+ }
+
+ colorFilter(colorControlsColorFilter(brightness, contrast, saturation))
+}
+
+fun BackdropEffectScope.vibrancy() {
+ colorFilter(VibrantColorFilter)
+}
+
+private val VibrantColorFilter = colorControlsColorFilter(saturation = 1.5f)
+
+fun BackdropEffectScope.exposureAdjustment(ev: Float) {
+ val scale = 2f.pow(ev / 2.2f)
+ val colorMatrix = ColorMatrix(
+ floatArrayOf(
+ scale, 0f, 0f, 0f, 0f,
+ 0f, scale, 0f, 0f, 0f,
+ 0f, 0f, scale, 0f, 0f,
+ 0f, 0f, 0f, 1f, 0f
+ )
+ )
+ colorFilter(ColorMatrixColorFilter(colorMatrix))
+}
+
+fun BackdropEffectScope.gammaAdjustment(power: Float) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return
+
+ val shader = obtainRuntimeShader("GammaAdjustment", GammaAdjustmentShaderString).apply {
+ setFloatUniform("power", power)
+ }
+ effect(RenderEffect.createRuntimeShaderEffect(shader, "content"))
+}
+
+private fun colorControlsColorFilter(
+ brightness: Float = 0f,
+ contrast: Float = 1f,
+ saturation: Float = 1f
+): ColorFilter {
+ val invSat = 1f - saturation
+ val r = 0.213f * invSat
+ val g = 0.715f * invSat
+ val b = 0.072f * invSat
+
+ val c = contrast
+ val t = (0.5f - c * 0.5f + brightness) * 255f
+ val s = saturation
+
+ val cr = c * r
+ val cg = c * g
+ val cb = c * b
+ val cs = c * s
+
+ val colorMatrix = ColorMatrix(
+ floatArrayOf(
+ cr + cs, cg, cb, 0f, t,
+ cr, cg + cs, cb, 0f, t,
+ cr, cg, cb + cs, 0f, t,
+ 0f, 0f, 0f, 1f, 0f
+ )
+ )
+ return ColorMatrixColorFilter(colorMatrix)
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/Lens.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/Lens.kt
new file mode 100644
index 0000000..d633b59
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/Lens.kt
@@ -0,0 +1,104 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.effects
+
+import android.graphics.RenderEffect
+import android.os.Build
+import androidx.annotation.FloatRange
+import androidx.compose.foundation.shape.CornerBasedShape
+import androidx.compose.ui.unit.LayoutDirection
+import androidx.compose.ui.util.fastCoerceAtLeast
+import androidx.compose.ui.util.fastCoerceAtMost
+import com.kyant.backdrop.BackdropEffectScope
+import com.kyant.backdrop.RoundedRectRefractionShaderString
+import com.kyant.backdrop.RoundedRectRefractionWithDispersionShaderString
+import com.kyant.shapes.RoundedRectangularShape
+
+fun BackdropEffectScope.lens(
+ @FloatRange(from = 0.0) refractionHeight: Float,
+ @FloatRange(from = 0.0) refractionAmount: Float,
+ depthEffect: Boolean = false,
+ chromaticAberration: Boolean = false
+) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return
+ if (refractionHeight <= 0f || refractionAmount <= 0f) return
+
+ if (padding > 0f) {
+ padding = (padding - refractionHeight).fastCoerceAtLeast(0f)
+ }
+
+ val cornerRadii = cornerRadii
+ val effect =
+ if (cornerRadii != null) {
+ val shader =
+ if (!chromaticAberration) {
+ obtainRuntimeShader(
+ "Refraction",
+ RoundedRectRefractionShaderString
+ )
+ } else {
+ obtainRuntimeShader(
+ "RefractionWithDispersion",
+ RoundedRectRefractionWithDispersionShaderString
+ )
+ }
+ shader.apply {
+ setFloatUniform("size", size.width, size.height)
+ setFloatUniform("offset", -padding, -padding)
+ setFloatUniform("cornerRadii", cornerRadii)
+ setFloatUniform("refractionHeight", refractionHeight)
+ setFloatUniform("refractionAmount", -refractionAmount)
+ setFloatUniform("depthEffect", if (depthEffect) 1f else 0f)
+ if (chromaticAberration) {
+ setFloatUniform("chromaticAberration", 1f)
+ }
+ }
+ RenderEffect.createRuntimeShaderEffect(shader, "content")
+ } else {
+ throwUnsupportedSDFException()
+ }
+ effect(effect)
+}
+
+private val BackdropEffectScope.cornerRadii: FloatArray?
+ get() = when (val shape = shape) {
+ is RoundedRectangularShape -> {
+ shape.cornerRadii(size, layoutDirection, this)
+ }
+
+ is CornerBasedShape -> {
+ val size = size
+ val maxRadius = size.minDimension / 2f
+ val isLtr = layoutDirection == LayoutDirection.Ltr
+ val topLeft =
+ if (isLtr) shape.topStart.toPx(size, this)
+ else shape.topEnd.toPx(size, this)
+ val topRight =
+ if (isLtr) shape.topEnd.toPx(size, this)
+ else shape.topStart.toPx(size, this)
+ val bottomRight =
+ if (isLtr) shape.bottomEnd.toPx(size, this)
+ else shape.bottomStart.toPx(size, this)
+ val bottomLeft =
+ if (isLtr) shape.bottomStart.toPx(size, this)
+ else shape.bottomEnd.toPx(size, this)
+ floatArrayOf(
+ topLeft.fastCoerceAtMost(maxRadius),
+ topRight.fastCoerceAtMost(maxRadius),
+ bottomRight.fastCoerceAtMost(maxRadius),
+ bottomLeft.fastCoerceAtMost(maxRadius)
+ )
+ }
+
+ else -> null
+ }
+
+private fun throwUnsupportedSDFException(): Nothing {
+ throw UnsupportedOperationException(
+ "Only RoundedRectangularShape or CornerBasedShape is supported in lens effects."
+ )
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/RenderEffect.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/RenderEffect.kt
new file mode 100644
index 0000000..3e32a8e
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/effects/RenderEffect.kt
@@ -0,0 +1,48 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.effects
+
+import android.graphics.RenderEffect
+import android.graphics.RuntimeShader
+import android.os.Build
+import com.kyant.backdrop.BackdropEffectScope
+import org.intellij.lang.annotations.Language
+
+fun BackdropEffectScope.effect(effect: RenderEffect) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return
+
+ val currentEffect = renderEffect
+ renderEffect =
+ if (currentEffect != null) {
+ RenderEffect.createChainEffect(effect, currentEffect)
+ } else {
+ effect
+ }
+}
+
+fun BackdropEffectScope.effect(effect: androidx.compose.ui.graphics.RenderEffect) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return
+
+ effect(effect.asAndroidRenderEffect())
+}
+
+/**
+ * Applies an AGSL [shaderString] as a RenderEffect, chained after the effects added so far.
+ * [uniformShaderName] is the `uniform shader` that receives the current (already-effected) content;
+ * [block] sets the other uniforms. No-op below Android 13 (TIRAMISU). Shaders are cached by [key].
+ */
+fun BackdropEffectScope.runtimeShaderEffect(
+ key: String,
+ @Language("AGSL") shaderString: String,
+ uniformShaderName: String,
+ block: RuntimeShader.() -> Unit
+) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return
+
+ val shader = obtainRuntimeShader(key, shaderString).apply(block)
+ effect(RenderEffect.createRuntimeShaderEffect(shader, uniformShaderName))
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/highlight/Highlight.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/highlight/Highlight.kt
new file mode 100644
index 0000000..e887251
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/highlight/Highlight.kt
@@ -0,0 +1,34 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.highlight
+
+import androidx.annotation.FloatRange
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.Stable
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.dp
+
+@Immutable
+data class Highlight(
+ val width: Dp = 0.5f.dp,
+ val blurRadius: Dp = width / 2f,
+ @param:FloatRange(from = 0.0, to = 1.0) val alpha: Float = 1f,
+ val style: HighlightStyle = HighlightStyle.Default
+) {
+
+ companion object {
+
+ @Stable
+ val Default: Highlight = Highlight()
+
+ @Stable
+ val Ambient: Highlight = Highlight(style = HighlightStyle.Ambient)
+
+ @Stable
+ val Plain: Highlight = Highlight(style = HighlightStyle.Plain)
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/highlight/HighlightModifier.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/highlight/HighlightModifier.kt
new file mode 100644
index 0000000..0112446
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/highlight/HighlightModifier.kt
@@ -0,0 +1,176 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.highlight
+
+import android.graphics.BlurMaskFilter
+import android.os.Build
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Outline
+import androidx.compose.ui.graphics.Paint
+import androidx.compose.ui.graphics.PaintingStyle
+import androidx.compose.ui.graphics.Path
+import androidx.compose.ui.graphics.drawOutline
+import androidx.compose.ui.graphics.drawscope.ContentDrawScope
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.graphics.drawscope.translate
+import androidx.compose.ui.graphics.layer.GraphicsLayer
+import androidx.compose.ui.graphics.layer.drawLayer
+import androidx.compose.ui.node.DrawModifierNode
+import androidx.compose.ui.node.ModifierNodeElement
+import androidx.compose.ui.node.invalidateDraw
+import androidx.compose.ui.node.requireGraphicsContext
+import androidx.compose.ui.platform.InspectorInfo
+import androidx.compose.ui.unit.Density
+import androidx.compose.ui.unit.IntSize
+import androidx.compose.ui.util.fastCoerceAtMost
+import com.kyant.backdrop.RuntimeShaderCacheImpl
+import com.kyant.backdrop.ShapeProvider
+import com.kyant.backdrop.clipOutline
+import kotlin.math.ceil
+
+internal class HighlightElement(
+ val shapeProvider: ShapeProvider,
+ val highlight: () -> Highlight?
+) : ModifierNodeElement<HighlightNode>() {
+
+ override fun create(): HighlightNode {
+ return HighlightNode(shapeProvider, highlight)
+ }
+
+ override fun update(node: HighlightNode) {
+ node.shapeProvider = shapeProvider
+ node.highlight = highlight
+ node.invalidateDraw()
+ }
+
+ override fun InspectorInfo.inspectableProperties() {
+ name = "highlight"
+ properties["shapeProvider"] = shapeProvider
+ properties["highlight"] = highlight
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is HighlightElement) return false
+
+ if (shapeProvider != other.shapeProvider) return false
+ if (highlight != other.highlight) return false
+
+ return true
+ }
+
+ override fun hashCode(): Int {
+ var result = shapeProvider.hashCode()
+ result = 31 * result + highlight.hashCode()
+ return result
+ }
+}
+
+internal class HighlightNode(
+ var shapeProvider: ShapeProvider,
+ var highlight: () -> Highlight?
+) : DrawModifierNode, Modifier.Node() {
+
+ override val shouldAutoInvalidate: Boolean = false
+
+ private var highlightLayer: GraphicsLayer? = null
+
+ private val paint =
+ Paint().apply {
+ style = PaintingStyle.Stroke
+ }
+ private var clipPath: Path? = null
+
+ private val runtimeShaderCache = RuntimeShaderCacheImpl()
+
+ private var prevStyle: HighlightStyle? = null
+
+ override fun ContentDrawScope.draw() {
+ val highlight = highlight()
+ if (highlight == null || highlight.width.value <= 0f) {
+ return drawContent()
+ }
+
+ drawContent()
+
+ val highlightLayer = highlightLayer
+ if (highlightLayer != null) {
+ val size = size
+ val density: Density = this
+ val layoutDirection = layoutDirection
+
+ val safeSize =
+ IntSize(
+ ceil(size.width).toInt() + 2,
+ ceil(size.height).toInt() + 2
+ )
+
+ val outline = shapeProvider.shape.createOutline(size, layoutDirection, density)
+ val clipPath =
+ if (outline is Outline.Rounded) {
+ clipPath ?: Path().also { clipPath = it }
+ } else {
+ null
+ }
+
+ configurePaint(highlight)
+
+ highlightLayer.alpha = highlight.alpha
+ highlightLayer.blendMode = highlight.style.blendMode
+ highlightLayer.record(safeSize) {
+ translate(1f, 1f) {
+ val canvas = drawContext.canvas
+ canvas.save()
+ canvas.clipOutline(outline, clipPath)
+ canvas.drawOutline(outline, paint)
+ canvas.restore()
+ }
+ }
+
+ translate(-1f, -1f) {
+ drawLayer(highlightLayer)
+ }
+ }
+ }
+
+ override fun onAttach() {
+ val graphicsContext = requireGraphicsContext()
+ highlightLayer = graphicsContext.createGraphicsLayer()
+ }
+
+ override fun onDetach() {
+ val graphicsContext = requireGraphicsContext()
+ highlightLayer?.let { layer ->
+ graphicsContext.releaseGraphicsLayer(layer)
+ highlightLayer = null
+ }
+ clipPath = null
+ runtimeShaderCache.clear()
+ prevStyle = null
+ }
+
+ private fun DrawScope.configurePaint(highlight: Highlight) {
+ paint.color = highlight.style.color
+ paint.strokeWidth =
+ ceil(highlight.width.toPx().fastCoerceAtMost(size.minDimension / 2f)) * 2f
+ val blurRadius = highlight.blurRadius.toPx()
+ paint.asFrameworkPaint().maskFilter =
+ if (blurRadius > 0f) {
+ BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.NORMAL)
+ } else {
+ null
+ }
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ paint.shader = with(highlight.style) {
+ createShader(
+ shape = shapeProvider.shape,
+ runtimeShaderCache = runtimeShaderCache
+ )
+ }
+ }
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/highlight/HighlightStyle.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/highlight/HighlightStyle.kt
new file mode 100644
index 0000000..61d04d9
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/highlight/HighlightStyle.kt
@@ -0,0 +1,164 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.highlight
+
+import android.os.Build
+import androidx.annotation.FloatRange
+import androidx.annotation.RequiresApi
+import androidx.compose.foundation.shape.CornerBasedShape
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.Stable
+import androidx.compose.ui.graphics.BlendMode
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.Shader
+import androidx.compose.ui.graphics.Shape
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.graphics.toArgb
+import androidx.compose.ui.unit.LayoutDirection
+import androidx.compose.ui.util.fastCoerceAtMost
+import com.kyant.backdrop.AmbientHighlightShaderString
+import com.kyant.backdrop.DefaultHighlightShaderString
+import com.kyant.backdrop.RuntimeShaderCache
+import kotlin.math.PI
+
+@Immutable
+interface HighlightStyle {
+
+ val color: Color
+
+ val blendMode: BlendMode
+
+ @RequiresApi(Build.VERSION_CODES.S)
+ fun DrawScope.createShader(
+ shape: Shape,
+ runtimeShaderCache: RuntimeShaderCache
+ ): Shader?
+
+ @Immutable
+ data class Plain(
+ override val color: Color = Color.White.copy(alpha = 0.38f),
+ override val blendMode: BlendMode = BlendMode.Plus
+ ) : HighlightStyle {
+
+ @RequiresApi(Build.VERSION_CODES.S)
+ override fun DrawScope.createShader(
+ shape: Shape,
+ runtimeShaderCache: RuntimeShaderCache
+ ): Shader? = null
+ }
+
+ @Immutable
+ data class Default(
+ override val color: Color = Color.White.copy(alpha = 0.5f),
+ override val blendMode: BlendMode = BlendMode.Plus,
+ val angle: Float = 45f,
+ @param:FloatRange(from = 0.0) val falloff: Float = 1f
+ ) : HighlightStyle {
+
+ @Deprecated(
+ "Use the constructor with color parameter instead.",
+ ReplaceWith("HighlightStyle.Default(color = Color.White.copy(alpha = intensity), angle = angle, falloff = falloff)")
+ )
+ constructor(
+ intensity: Float,
+ angle: Float = 45f,
+ falloff: Float = 1f
+ ) : this(
+ color = Color.White.copy(alpha = intensity),
+ angle = angle,
+ falloff = falloff
+ )
+
+ @RequiresApi(Build.VERSION_CODES.S)
+ override fun DrawScope.createShader(
+ shape: Shape,
+ runtimeShaderCache: RuntimeShaderCache
+ ): Shader? {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ runtimeShaderCache.obtainRuntimeShader(
+ "Default",
+ DefaultHighlightShaderString
+ ).apply {
+ setFloatUniform("size", size.width, size.height)
+ setFloatUniform("cornerRadii", getCornerRadii(shape))
+ setColorUniform("color", color.copy(alpha = 1f).toArgb())
+ setFloatUniform("angle", angle * (PI / 180f).toFloat())
+ setFloatUniform("falloff", falloff)
+ }
+ } else {
+ null
+ }
+ }
+ }
+
+ @Immutable
+ data class Ambient(
+ @param:FloatRange(from = 0.0, to = 1.0) val intensity: Float = 0.38f
+ ) : HighlightStyle {
+
+ override val color: Color = Color.White.copy(alpha = intensity)
+
+ override val blendMode: BlendMode = DrawScope.DefaultBlendMode
+
+ @RequiresApi(Build.VERSION_CODES.S)
+ override fun DrawScope.createShader(
+ shape: Shape,
+ runtimeShaderCache: RuntimeShaderCache
+ ): Shader? {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ runtimeShaderCache.obtainRuntimeShader(
+ "Ambient",
+ AmbientHighlightShaderString
+ ).apply {
+ setFloatUniform("size", size.width, size.height)
+ setFloatUniform("cornerRadii", getCornerRadii(shape))
+ setFloatUniform("angle", 45f * (PI / 180f).toFloat())
+ setFloatUniform("falloff", 1f)
+ }
+ } else {
+ null
+ }
+ }
+ }
+
+ companion object {
+
+ @Stable
+ val Default: Default = Default()
+
+ @Stable
+ val Ambient: Ambient = Ambient()
+
+ @Stable
+ val Plain: Plain = Plain()
+ }
+}
+
+private fun DrawScope.getCornerRadii(shape: Shape): FloatArray {
+ val size = size
+ val maxRadius = size.minDimension / 2f
+ val shape = shape as? CornerBasedShape ?: return FloatArray(4) { maxRadius }
+ val isLtr = layoutDirection == LayoutDirection.Ltr
+ val topLeft =
+ if (isLtr) shape.topStart.toPx(size, this)
+ else shape.topEnd.toPx(size, this)
+ val topRight =
+ if (isLtr) shape.topEnd.toPx(size, this)
+ else shape.topStart.toPx(size, this)
+ val bottomRight =
+ if (isLtr) shape.bottomEnd.toPx(size, this)
+ else shape.bottomStart.toPx(size, this)
+ val bottomLeft =
+ if (isLtr) shape.bottomStart.toPx(size, this)
+ else shape.bottomEnd.toPx(size, this)
+ return floatArrayOf(
+ topLeft.fastCoerceAtMost(maxRadius),
+ topRight.fastCoerceAtMost(maxRadius),
+ bottomRight.fastCoerceAtMost(maxRadius),
+ bottomLeft.fastCoerceAtMost(maxRadius)
+ )
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/InnerShadow.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/InnerShadow.kt
new file mode 100644
index 0000000..d056596
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/InnerShadow.kt
@@ -0,0 +1,47 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.shadow
+
+import androidx.annotation.FloatRange
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.Stable
+import androidx.compose.ui.graphics.BlendMode
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.graphics.lerp
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.DpOffset
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.lerp
+import androidx.compose.ui.util.lerp
+
+@Immutable
+data class InnerShadow(
+ val radius: Dp = 24f.dp,
+ val offset: DpOffset = DpOffset(0f.dp, radius),
+ val color: Color = Color.Black.copy(alpha = 0.15f),
+ @param:FloatRange(from = 0.0, to = 1.0) val alpha: Float = 1f,
+ val blendMode: BlendMode = DrawScope.DefaultBlendMode
+) {
+
+ companion object {
+
+ @Stable
+ val Default: InnerShadow = InnerShadow()
+ }
+}
+
+@Stable
+fun lerp(start: InnerShadow, stop: InnerShadow, fraction: Float): InnerShadow {
+ return InnerShadow(
+ radius = lerp(start.radius, stop.radius, fraction),
+ offset = lerp(start.offset, stop.offset, fraction),
+ color = lerp(start.color, stop.color, fraction),
+ alpha = lerp(start.alpha, stop.alpha, fraction),
+ blendMode = if (fraction < 0.5f) start.blendMode else stop.blendMode
+ )
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/InnerShadowModifier.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/InnerShadowModifier.kt
new file mode 100644
index 0000000..1a93453
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/InnerShadowModifier.kt
@@ -0,0 +1,172 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.shadow
+
+import android.os.Build
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.BlendMode
+import androidx.compose.ui.graphics.BlurEffect
+import androidx.compose.ui.graphics.Outline
+import androidx.compose.ui.graphics.Paint
+import androidx.compose.ui.graphics.Path
+import androidx.compose.ui.graphics.TileMode
+import androidx.compose.ui.graphics.drawOutline
+import androidx.compose.ui.graphics.drawscope.ContentDrawScope
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.graphics.layer.CompositingStrategy
+import androidx.compose.ui.graphics.layer.GraphicsLayer
+import androidx.compose.ui.graphics.layer.drawLayer
+import androidx.compose.ui.node.DrawModifierNode
+import androidx.compose.ui.node.ModifierNodeElement
+import androidx.compose.ui.node.invalidateDraw
+import androidx.compose.ui.node.requireGraphicsContext
+import androidx.compose.ui.platform.InspectorInfo
+import androidx.compose.ui.unit.Density
+import com.kyant.backdrop.ShapeProvider
+import com.kyant.backdrop.clipOutline
+
+internal class InnerShadowElement(
+ val shapeProvider: ShapeProvider,
+ val shadow: () -> InnerShadow?
+) : ModifierNodeElement<InnerShadowNode>() {
+
+ override fun create(): InnerShadowNode {
+ return InnerShadowNode(shapeProvider, shadow)
+ }
+
+ override fun update(node: InnerShadowNode) {
+ node.shapeProvider = shapeProvider
+ node.shadow = shadow
+ node.invalidateDraw()
+ }
+
+ override fun InspectorInfo.inspectableProperties() {
+ name = "innerShadow"
+ properties["shapeProvider"] = shapeProvider
+ properties["shadow"] = shadow
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is InnerShadowElement) return false
+
+ if (shapeProvider != other.shapeProvider) return false
+ if (shadow != other.shadow) return false
+
+ return true
+ }
+
+ override fun hashCode(): Int {
+ var result = shapeProvider.hashCode()
+ result = 31 * result + shadow.hashCode()
+ return result
+ }
+}
+
+internal class InnerShadowNode(
+ var shapeProvider: ShapeProvider,
+ var shadow: () -> InnerShadow?
+) : DrawModifierNode, Modifier.Node() {
+
+ override val shouldAutoInvalidate: Boolean = false
+
+ private var shadowLayer: GraphicsLayer? = null
+
+ private val paint = Paint()
+ private var clipPath: Path? = null
+
+ private var prevRadius = Float.NaN
+
+ override fun ContentDrawScope.draw() {
+ drawContent()
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return
+
+ val shadow = shadow() ?: return
+
+ val shadowLayer = shadowLayer
+ if (shadowLayer != null) {
+ val size = size
+ val density: Density = this
+ val layoutDirection = layoutDirection
+
+ val radius = shadow.radius.toPx()
+ val offsetX = shadow.offset.x.toPx()
+ val offsetY = shadow.offset.y.toPx()
+
+ val outline = shapeProvider.shape.createOutline(size, layoutDirection, density)
+ val clipPath =
+ if (outline is Outline.Rounded) {
+ clipPath ?: Path().also { clipPath = it }
+ } else {
+ null
+ }
+
+ configurePaint(shadow)
+
+ shadowLayer.alpha = shadow.alpha
+ shadowLayer.blendMode = shadow.blendMode
+ if (prevRadius != radius) {
+ shadowLayer.renderEffect =
+ if (radius > 0f) {
+ BlurEffect(radius, radius, TileMode.Decal)
+ } else {
+ null
+ }
+ prevRadius = radius
+ }
+ shadowLayer.record {
+ val canvas = drawContext.canvas
+ canvas.save()
+ canvas.clipOutline(outline, clipPath)
+ canvas.drawOutline(outline, paint)
+ canvas.translate(offsetX, offsetY)
+ canvas.drawOutline(outline, ShadowMaskPaint)
+ canvas.translate(-offsetX, -offsetY)
+ canvas.restore()
+ }
+
+ val canvas = drawContext.canvas
+ canvas.save()
+ canvas.clipOutline(outline, clipPath)
+ drawLayer(shadowLayer)
+ canvas.restore()
+ }
+ }
+
+ override fun onAttach() {
+ val graphicsContext = requireGraphicsContext()
+ shadowLayer =
+ graphicsContext.createGraphicsLayer().apply {
+ compositingStrategy = CompositingStrategy.Offscreen
+ }
+ }
+
+ override fun onDetach() {
+ val graphicsContext = requireGraphicsContext()
+ shadowLayer?.let { layer ->
+ graphicsContext.releaseGraphicsLayer(layer)
+ shadowLayer = null
+ }
+ }
+
+ private fun DrawScope.configurePaint(shadow: InnerShadow) {
+ paint.color = shadow.color
+ }
+
+ private fun DrawScope.drawMaskedShadow(outline: Outline, layer: GraphicsLayer) {
+ val canvas = drawContext.canvas
+ canvas.save()
+ canvas.clipOutline(outline, clipPath)
+ drawLayer(layer)
+ canvas.restore()
+ }
+}
+
+private val ShadowMaskPaint = Paint().apply {
+ blendMode = BlendMode.Clear
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/Shadow.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/Shadow.kt
new file mode 100644
index 0000000..f5ba49d
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/Shadow.kt
@@ -0,0 +1,33 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.shadow
+
+import androidx.annotation.FloatRange
+import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.Stable
+import androidx.compose.ui.graphics.BlendMode
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.DpOffset
+import androidx.compose.ui.unit.dp
+
+@Immutable
+data class Shadow(
+ val radius: Dp = 24f.dp,
+ val offset: DpOffset = DpOffset(0f.dp, radius / 6f),
+ val color: Color = Color.Black.copy(alpha = 0.1f),
+ @param:FloatRange(from = 0.0, to = 1.0) val alpha: Float = 1f,
+ val blendMode: BlendMode = DrawScope.DefaultBlendMode
+) {
+
+ companion object {
+
+ @Stable
+ val Default: Shadow = Shadow()
+ }
+}
diff --git a/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/ShadowModifier.kt b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/ShadowModifier.kt
new file mode 100644
index 0000000..390f4ad
--- /dev/null
+++ b/apps/pdfcraft-android/android/backdrop/src/main/java/com/kyant/backdrop/shadow/ShadowModifier.kt
@@ -0,0 +1,149 @@
+/*
+ * Adapted from AndroidLiquidGlass by kyant0.
+ * Source: https://github.com/Kyant0/AndroidLiquidGlass
+ * Licensed under the Apache License, Version 2.0.
+ */
+
+package com.kyant.backdrop.shadow
+
+import android.graphics.BlurMaskFilter
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.BlendMode
+import androidx.compose.ui.graphics.Paint
+import androidx.compose.ui.graphics.drawOutline
+import androidx.compose.ui.graphics.drawscope.ContentDrawScope
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.graphics.drawscope.translate
+import androidx.compose.ui.graphics.layer.CompositingStrategy
+import androidx.compose.ui.graphics.layer.GraphicsLayer
+import androidx.compose.ui.graphics.layer.drawLayer
+import androidx.compose.ui.node.DrawModifierNode
+import androidx.compose.ui.node.ModifierNodeElement
+import androidx.compose.ui.node.invalidateDraw
+import androidx.compose.ui.node.requireGraphicsContext
+import androidx.compose.ui.platform.InspectorInfo
+import androidx.compose.ui.unit.Density
+import androidx.compose.ui.unit.IntSize
+import com.kyant.backdrop.ShapeProvider
+import kotlin.math.ceil
+
+internal class ShadowElement(
+ val shapeProvider: ShapeProvider,
+ val shadow: () -> Shadow?
+) : ModifierNodeElement<ShadowNode>() {
+
+ override fun create(): ShadowNode {
+ return ShadowNode(shapeProvider, shadow)
+ }
+
+ override fun update(node: ShadowNode) {
+ node.shapeProvider = shapeProvider
+ node.shadow = shadow
+ node.invalidateDraw()
+ }
+
+ override fun InspectorInfo.inspectableProperties() {
+ name = "shadow"
+ properties["shapeProvider"] = shapeProvider
+ properties["shadow"] = shadow
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is ShadowElement) return false
+
+ if (shapeProvider != other.shapeProvider) return false
+ if (shadow != other.shadow) return false
+
+ return true
+ }
+
+ override fun hashCode(): Int {
+ var result = shapeProvider.hashCode()
+ result = 31 * result + shadow.hashCode()
+ return result
+ }
+}
+
+internal class ShadowNode(
+ var shapeProvider: ShapeProvider,
+ var shadow: () -> Shadow?
+) : DrawModifierNode, Modifier.Node() {
+
+ override val shouldAutoInvalidate: Boolean = false
+
+ private var shadowLayer: GraphicsLayer? = null
+
+ private val paint = Paint()
+
+ override fun ContentDrawScope.draw() {
+ val shadow = shadow() ?: return drawContent()
+
+ val shadowLayer = shadowLayer
+ if (shadowLayer != null) {
+ val size = size
+ val density: Density = this
+ val layoutDirection = layoutDirection
+
+ val radius = shadow.radius.toPx()
+ val offsetX = shadow.offset.x.toPx()
+ val offsetY = shadow.offset.y.toPx()
+ val shadowSize = IntSize(
+ ceil(size.width + radius * 4f + offsetX).toInt(),
+ ceil(size.height + radius * 4f + offsetY).toInt()
+ )
+ val outline = shapeProvider.shape.createOutline(size, layoutDirection, density)
+
+ configurePaint(shadow)
+
+ shadowLayer.alpha = shadow.alpha
+ shadowLayer.blendMode = shadow.blendMode
+ shadowLayer.record(shadowSize) {
+ translate(radius * 2f + offsetX, radius * 2f + offsetY) {
+ val canvas = drawContext.canvas
+ canvas.drawOutline(outline, paint)
+ canvas.translate(-offsetX, -offsetY)
+ canvas.drawOutline(outline, ShadowMaskPaint)
+ canvas.translate(offsetX, offsetY)
+ }
+ }
+
+ translate(-radius * 2f, -radius * 2f) {
+ drawLayer(shadowLayer)
+ }
+ }
+
+ drawContent()
+ }
+
+ override fun onAttach() {
+ val graphicsContext = requireGraphicsContext()
+ shadowLayer =
+ graphicsContext.createGraphicsLayer().apply {
+ compositingStrategy = CompositingStrategy.Offscreen
+ }
+ }
+
+ override fun onDetach() {
+ val graphicsContext = requireGraphicsContext()
+ shadowLayer?.let { layer ->
+ graphicsContext.releaseGraphicsLayer(layer)
+ shadowLayer = null
+ }
+ }
+
+ private fun DrawScope.configurePaint(shadow: Shadow) {
+ paint.color = shadow.color
+ val blurRadius = shadow.radius.toPx()
+ paint.asFrameworkPaint().maskFilter =
+ if (blurRadius > 0f) {
+ BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.NORMAL)
+ } else {
+ null
+ }
+ }
+}
+
+private val ShadowMaskPaint = Paint().apply {
+ blendMode = BlendMode.Clear
+}
diff --git a/apps/pdfcraft-android/android/build.gradle.kts b/apps/pdfcraft-android/android/build.gradle.kts
index 020183f..6062672 100644
--- a/apps/pdfcraft-android/android/build.gradle.kts
+++ b/apps/pdfcraft-android/android/build.gradle.kts
@@ -1,4 +1,5 @@
plugins {
alias(libs.plugins.android.application) apply false
+ alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.compose) apply false
}
diff --git a/apps/pdfcraft-android/android/gradle.properties b/apps/pdfcraft-android/android/gradle.properties
index 8695837..806f854 100644
--- a/apps/pdfcraft-android/android/gradle.properties
+++ b/apps/pdfcraft-android/android/gradle.properties
@@ -7,11 +7,11 @@ android.nonTransitiveRClass=true
kotlin.code.style=official
# The Rust library's ABIs: arm64-v8a for phones, x86_64 for the emulator. Build one to save time,
-# e.g. `./gradlew installRelease -Ppdfcraft.abis=arm64-v8a`.
-pdfcraft.abis=arm64-v8a,x86_64
+# e.g. `./gradlew installRelease -Pclearpdf.abis=arm64-v8a`.
+clearpdf.abis=arm64-v8a,x86_64
# The app's version and its version code (before the ABI digit: see app/build.gradle.kts, the build
# checks the two agree). Set both to the release's before tagging it: the release workflow refuses a
# tag that differs, and F-Droid's update check reads them from here.
-pdfcraft.version=0.0.7-beta
-pdfcraft.versionCode=701
+clearpdf.version=3.0.0-alpha
+clearpdf.versionCode=3000001
diff --git a/apps/pdfcraft-android/android/gradle/libs.versions.toml b/apps/pdfcraft-android/android/gradle/libs.versions.toml
index 486b641..6fe0723 100644
--- a/apps/pdfcraft-android/android/gradle/libs.versions.toml
+++ b/apps/pdfcraft-android/android/gradle/libs.versions.toml
@@ -10,6 +10,8 @@ kotlinxCoroutines = "1.10.2"
jna = "5.19.1"
junit = "4.13.2"
exifinterface = "1.4.1"
+# AndroidLiquidGlass shapes (Apache-2.0, Kyant0), used by the backdrop module
+kyantShapes = "1.0.0"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -18,6 +20,8 @@ androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "l
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
+androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation" }
+kyant-shapes = { group = "io.github.kyant0", name = "shapes", version.ref = "kyantShapes" }
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" }
@@ -27,4 +31,5 @@ androidx-exifinterface = { group = "androidx.exifinterface", name = "exifinterfa
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
+android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
diff --git a/apps/pdfcraft-android/android/settings.gradle.kts b/apps/pdfcraft-android/android/settings.gradle.kts
index 1c3ce87..b564b16 100644
--- a/apps/pdfcraft-android/android/settings.gradle.kts
+++ b/apps/pdfcraft-android/android/settings.gradle.kts
@@ -21,5 +21,6 @@ dependencyResolutionManagement {
}
}
-rootProject.name = "PdfCraft"
+rootProject.name = "ClearPDF"
include(":app")
+include(":backdrop")
diff --git a/apps/pdfcraft-android/uniffi.toml b/apps/pdfcraft-android/uniffi.toml
index 5124a47..03e3fc1 100644
--- a/apps/pdfcraft-android/uniffi.toml
+++ b/apps/pdfcraft-android/uniffi.toml
@@ -1,5 +1,5 @@
# UniFFI bindings of the `pdfcraft_android` library.
[bindings.kotlin]
-package_name = "io.github.artcraftandroid.pdfcraft.core"
+package_name = "com.chethan616.clearpdf.core"
cdylib_name = "pdfcraft_android"