Navigation

All routes and user flows in Scanly v1.0.22.

Navigation is implemented with Navigation Compose in ScanlyNavHost.kt. Route helpers follow the *Destination object pattern with routePattern and route() factory functions.

Form factorChrome
PhoneScaffold + bottom NavigationBar
TabletDestination-owned NavigationRail (92 dp) with app logo on top-level screens
  • Start destination: home
  • Tab switches: no transition animation
  • Detail pushes: short fade with a small forward offset; back navigation reverses the motion
  • Large-screen stability: the tablet rail is composed inside each top-level destination, so entering or leaving a detail route never resizes the NavHost mid-transition
  • Top inset: each screen applies status-bar padding once (not doubled by the activity shell)

Top-level tabs

RouteScreenIn bottom nav / rail
homeHome dashboardYes
libraryFull libraryYes
toolsTools hub (Scan, PDF, Utilities)Yes
settingsSettingsYes

Legacy placeholder routes

These top-level routes still exist but show FeaturePlaceholderScreen — they are sprint-era stubs, not active flows:

RouteNote
cameraUse camera/session/{documentId} instead
reviewReview happens in document detail and page preview
editorUse editor/page/{pageId} instead

Typed routes (active flows)

Route patternHelper objectScreen
document/{documentId}DocumentDestinationDocument detail
library/searchLibrarySearchDestinationSearch document/folder names and recognized page text; owns query, filters, and result state
document/{documentId}/text?page={page}&query={query}PageTextDestinationExtracted text in Text or On page view, with optional search context
camera/session/{documentId}?replacePageId={pageId}ScanSessionDestinationScan session
preview/page/{pageId}PageImagePreviewDestinationPage preview
editor/page/{pageId}PageEditorDestinationPage editor (preview, filters/adjust overlays, retake, delete)
crop/page/{pageId}PageCropDestinationAI detect, rotate, four-point crop, reset, apply
group/{groupId}GroupDetailDestinationGroup detail
legal/{documentType}LegalDocumentDestinationPrivacy or terms viewer
settings/appearanceSettingsAppearanceDestinationTheme + pure black
settings/languageSettingsLanguageDestinationSelect System default or one of 25 app languages and tap Apply to save and switch
settings/pipSettingsPipDestinationPip master switch, tips, camera coaching, export cheers, animation
settings/detectionSettingsDetectionDestinationModels, gate, benchmark link
settings/widgetsSettingsWidgetsDestinationPin home-screen widgets
settings/aboutSettingsAboutDestinationVersion, updates, legal, support
settings/faqSettingsFaqDestinationFAQ sub-screen
settings/licensesSettingsLicensesDestinationOpen-source licenses
settings/storageSettingsStorageDestinationStorage usage, export destination, cleanup, clear data
settings/model-benchmarkSettingsModelBenchmarkDestinationTemporary local model comparison
tools/qrToolsQrDestinationQR scan, typed result, create, and history (in-route screens)
tools/textToolsImageTextDestinationImage to text: pick photos (imported as a new document, then replaced by its text screen) or a scan → document/{documentId}/text
tools/pdf/reader?filePath={filePath}&fileName={fileName}ToolsPdfReaderDestinationPDF reader; optional app-owned result file opens directly
tools/pdf/merge?source={source}ToolsPdfMergeDestinationPDF merge
tools/pdf/split?source={source}ToolsPdfSplitDestinationPDF split
tools/pdf/compress?source={source}ToolsPdfCompressDestinationPDF compress
tools/pdf/password?source={source}ToolsPdfPasswordDestinationPDF password protect/remove
tools/pdf/watermark?source={source}ToolsPdfWatermarkDestinationPDF text watermark
tools/pdf/to-images?source={source}ToolsPdfToImagesDestinationPDF to JPG/PNG images saved to Pictures/Scanly
tools/pdf/sign?source={source}ToolsPdfSignDestinationSign a device or Scanly library PDF, then save or share the signed copy
document/{documentId}/sign?page={page}DocumentSignDestinationPlace editable marks on Scanly pages in place
document/{documentId}/splitDocumentSplitDestinationSplit a document into new documents
signatures/manageSignatureManageDestinationManage saved signatures and initials
signatures/create?kind={kind}SignatureCreateDestinationDraw or import a reusable signature or initials

PDF tool source argument: optional; built by pdfToolRoute() in PdfToolSourceArgument.kt. It encodes a PdfToolSource (app file path, device uri, or lib document id, plus a display label) so a tool can start with a file already chosen — used by the reader's ⋮ menu. Plain routes without the argument still match and open the file picker.

Editor overlays (not NavHost routes): FilterPickerScreen and FilterCustomizeScreen share PageEditorViewModel and replace the editor content in place (same pattern as a full-screen mode, not a bottom sheet).

Back behavior

  • When opened from Tools, Back from a PDF reader returns to the file picker; Back from that picker exits to Tools. A PDF preview opened from a PDF tool returns to that tool's result screen. Choose another opens a temporary picker, where Back returns to the current reader.
  • A tool opened from the reader's ⋮ menu starts on its options step with the reader's file; Back returns to the reader.
  • In PDF compression, Back from options returns to the file picker; Back from that picker exits to Tools. Change opens a temporary picker, where Back returns to options.
  • In watermarking, Back from the editor returns to the picker; Change opens a temporary picker, where Back returns to the current editor.
  • Android Back closes the editor's full-screen filter and adjustment modes before leaving the editor. It is blocked while a page is being captured, cropped/saved, filter-saved, or processed by a PDF tool.

Scan session arguments

  • documentId (required) — target document
  • replacePageId (optional) — when set, capture replaces this page instead of adding a new one. On complete, navigates to editor/page/{replacePageId}.

Settings sub-screen ViewModel sharing

Settings sub-screens that edit preferences (appearance, detection, widgets, about, faq, licenses, storage) share SettingsViewModel via the parent settings back stack entry. The model benchmark owns a separate ViewModel because its runs and results are temporary.

External launch actions (widgets & shortcuts)

MainActivity accepts explicit launch actions from widgets and launcher shortcuts (singleTop). LaunchActionViewModel queues the action until onboarding is complete, then redirects:

ActionIntent actionRedirect
Scanin.c1ph3rj.scanly.action.SCANSuggest title → create document → camera/session/{documentId}
Importin.c1ph3rj.scanly.action.IMPORTSystem photo picker → import pipeline → document/{documentId}
QRin.c1ph3rj.scanly.action.QRTools tab → tools/qr?mode=scan
Libraryin.c1ph3rj.scanly.action.LIBRARYTop-level library

Config: AndroidManifest.xml receivers + res/xml/shortcuts.xml; providers live under feature/widget/.

Open with Scanly (PDFs from other apps)

MainActivity also has ACTION_VIEW (content/file, application/pdf) and ACTION_SEND (application/pdf) intent filters labelled Open in Scanly. IncomingPdf.uriFrom() reads the URI from the cold-start or new intent; once onboarding is COMPLETE, IncomingPdf.copyToCache() copies it to cache/incoming_pdf/ (keeping the newest few) and the app navigates to tools/pdf/reader?filePath=…&fileName=…. If the copy fails, a "Couldn't open that PDF." toast is shown. The source file is never modified.

Files / Gmail / Drive / chat → "Open in Scanly"
  └─► MainActivity (VIEW or SEND, application/pdf)
        └─► (after onboarding) copy to cache/incoming_pdf/
              └─► tools/pdf/reader?filePath=…&fileName=…

Widget / shortcut → scan

Widget or quick action (Scan)
  └─► MainActivity (action.SCAN)
        └─► (after onboarding) suggest title + create document
              └─► camera/session/{newDocId}

User flow diagrams

App startup

Launch
  └─► Onboarding required?
        ├─ Yes → OnboardingFlow (Welcome + language → Capture → Find → Share → optional camera sheet) → complete → Home
        └─ No  → Home
              └─► (background) update check if cooldown expired

Create and scan

Home / Library
  └─► Create + Scan (default name prefilled; clear or Suggest name)
        └─► camera/session/{newDocId}
              └─► capture page(s)
                    └─► document/{docId}

Edit a page

document/{docId}
  └─► preview/page/{pageId}
        ├─► overflow: Share / Edit / Retake / Delete
        └─► editor/page/{pageId}
              ├─► Filters  → full-screen FilterPickerScreen (live preview + presets; Done → editor)
              ├─► Adjust   → full-screen FilterCustomizeScreen (sliders + compare; Done → editor)
              ├─► crop/page/{pageId}
              │     ├─► AI Detect / rotate / handles / Reset
              │     └─► Done → reprocess crop+rotation → navigateUp → editor
              ├─► editor Done → reprocess filter + adjustments → back to preview/detail
              └─► retake → camera/session/{docId}?replacePageId={pageId}
                              └─► editor/page/{pageId}  (replacement complete)
Home (new doc) or document/{docId} (add pages)
  └─► system image picker (≤50 images)
        └─► import pipeline (same as capture finalize)
              └─► document/{docId}

Group workflow

Library (Folders filter) or Home (recent groups)
  └─► group/{groupId}
        ├─► document/{docId}  (open member)
        ├─► rename / delete group
        ├─► add/remove documents
        └─► export merged PDF or zipped PDFs

Export

document/{docId} or group/{groupId}
  └─► export sheet (PDF options: password, page numbers, orientation, size, margins)
        ├─► Save → configured Downloads/SAF destination (unique filenames)
        └─► Share → cache/exports → FileProvider share sheet

Search page text

Home or Library → library/search
  └─► Search names or page text
        ├─► Page result → document/{documentId}/text?page={page}&query={query}
        └─► Filter by Everywhere / Names / Text in pages or document type

Sign documents

Tools → Sign PDF → choose phone/library PDF → add marks across pages
  └─► Review → Save to phone or Share (source PDF remains unchanged)

Document detail → Sign document → place marks on scan pages → save in place
  └─► Marks remain editable and are included in previews and exports

Settings

settings
  ├─► Look & feel: theme mode + pure black (AMOLED) toggle
  ├─► settings/storage (usage, export destination, temporary-export cleanup, clear data)
  ├─► Document detection: automatic or manual live/post models
  ├─► Document detection: physical-document gate on/off
  ├─► settings/model-benchmark (gate + four corner models on local images)
  ├─► settings/faq
  ├─► legal/{PRIVACY} or legal/{TERMS}
  ├─► settings/licenses
  └─► check for updates → AppUpdateDialog (channel-specific)

Onboarding gate

MainActivity uses AnimatedContent to switch between onboarding states:

StateUI
LOADINGBlank / loading
REQUIREDOnboardingFlow: WelcomeScreen (logo, summary, app language), then three-page OnboardingScreen, then optional camera-permission bottom sheet
COMPLETEScanlyNavHost

Automatic update checks run on ON_START only when onboarding is COMPLETE.

The welcome screen comes first on a fresh install. It shows the launcher logo, a one-line summary and the app language list (Phone language plus the 25 AppLanguage entries, searchable by native, current-language or English name). A pick calls AppLocales.setLanguage immediately, so the screen and the introduction re-render in that language. Below 600 dp it is one column with the list filling the remaining height; at 600 dp and wider, or in short landscape windows, the summary and the list sit side by side. Continue is always outside the scrolling list. Back from the first introduction page returns to it.

The onboarding pager retains its page across recreation and adapts to available bounds, including split screen. Below 600 dp, the approved mint, teal and peach document illustrations sit above localized headings and expanded descriptions. Portrait windows from 600–839 dp center that stack; wider or medium landscape windows use two panes. Main actions and page controls stay outside the scrollable content. Transparent WebP illustrations decode in the background, while native layers animate the capture scan line and search-word reveal. Illustration entrances and page transitions respect the existing motion preference and disabled system animations; off-screen scenes stop animating. Skip moves to Finish without completing onboarding. Scan my first page completes onboarding and queues scanning when camera access is granted; otherwise it opens a modal permission sheet. Enable camera launches the system request; granting it starts scanning, while Not now or denial completes to Home. Dismissing the sheet returns to Finish. Permanent denial offers Settings, and returning after granting starts scanning. Existing incoming PDF and shortcut destinations retain priority. The final introduction page has no import-photo button. The illustrative sample search term stays in English; all surrounding UI descriptions are localized in the 25 supported languages.

The capture beam scales with the artwork, follows the illustrated phone angle and casts a short light trail clipped to the page. The onboarding search example is decorative, with a search strip and matching highlighted word over the document illustration. The query is centred in the area after the magnifier, aligned to the bar angle, with font padding removed; both sample words scale with the illustration. It has no input, clipboard action or accessibility focus targets. Each pager page clips its artwork so layer motion stays within that page. Pagination uses 48 dp selectable targets with a small circular focus ring and press halo; focus remains attached while the pager settles.

View source on GitHub · Markdown