Screens and ViewModels

Every feature screen in Scanly v1.0.22 and its responsibilities.

Screen inventory

FeatureScreenViewModelRoutePrimary responsibilities
OnboardingWelcomeScreen, OnboardingScreen (in OnboardingFlow)OnboardingViewModel(gate in MainActivity)Welcome screen with app language choice, three-page intro, then a camera-permission step when the camera is not yet allowed; persist completion
HomeHomeScreenHomeViewModelhomeRecent folders and documents (shimmer placeholders until the first load), scan/import/folder, suggest names, daily Pip tip, library shortcut
Widgets / shortcuts(system chrome)LaunchActionViewModelvia MainActivity intentsScan, Import, QR, Library redirects
LibraryLibraryScreenLibraryViewModellibraryPaper cards, overflow/long-press actions, search, filter pills, sort, CRUD, suggest names
Library searchLibrarySearchScreenLibrarySearchViewModellibrary/searchSearch names and page text, recent searches, type filters, ranked excerpts
Extracted textPageTextScreenPageTextViewModeldocument/{documentId}/textRead or correct recognized text; copy/share; show text regions on the scan
Tools hubToolsScreenToolsViewModeltoolsScan / PDF / Utilities groups; inset transparent 2.5D tool artwork inside rounded outlines without tinted fills (ToolIllustrations.kt, tools_art_*.webp), including document-based Merge / Split; Utilities: QR & barcode (opens straight into scanning), Image to text, My signatures
Image to textImageTextRoute (reuses PdfFilePickerScreen)ImageTextViewModeltools/textPhotos → new document → Extracted text; scans open their Extracted text directly
QR toolQrToolScreen (+ QrScanScreen, QrResultScreen, QrCreateScreen, QrHistoryScreen)QrToolViewModeltools/qrScan with torch and photo import, typed results, Create types with caption and ink, on-phone history
PDF readerPdfReaderRoutePdfReaderViewModeltools/pdf/readerPicker step, dark reader with one page counter, hideable chrome, Pages grid, Layout; ⋮ menu (PdfReaderOverflowMenu) with Share, All pages, hand-off to each PDF tool, Open another PDF; also the target of Open in Scanly
PDF mergePdfMergeRoutePdfMergeViewModeltools/pdf/mergeMulti-select picker → order & name → done
PDF splitPdfSplitRoutePdfSplitViewModeltools/pdf/splitSingle picker → where to split (Custom / Every N / Extract, plan in PdfSplitPlan.kt) → working → done (rename, save as PDFs or ZIP, share)
PDF compressPdfCompressRoutePdfCompressViewModeltools/pdf/compressPicker → quality → working → done with saving and before/after
PDF passwordPdfPasswordRoutePdfPasswordViewModeltools/pdf/passwordPicker → Add password (strength, restrict editing) or Remove password, chosen by the file → done
PDF watermarkPdfWatermarkRoutePdfWatermarkViewModeltools/pdf/watermarkPicker → editor with pinned live preview (presets, date, style, colour, pages) → done
PDF to imagesPdfToImagesRoutePdfToImagesViewModeltools/pdf/to-imagesPicker → pages, JPG/PNG, Sharing or Print size → images in Pictures/Scanly, share all or some
PDF signingPdfSignRoutePdfSignViewModeltools/pdf/signPick a PDF, place marks across pages, review, save or share a new signed PDF
Scan signingDocumentSignRoute + SignEditorScreenDocumentSignViewModeldocument/{documentId}/signPlace editable marks on scan pages; update page composites and thumbnails
Saved signaturesSignatureManageRouteSignatureManageViewModelsignatures/manageReview and delete saved signatures or initials
Create signatureSignatureCreateRouteSignatureCreateViewModelsignatures/create?kind={kind}Draw a signature/initials or extract ink from an imported photo
Group detailGroupDetailScreenGroupDetailViewModelgroup/{groupId}Membership (Add documents sheet with cover thumbnails and edited dates), rename, delete, group export, create doc in group
Document detailDocumentDetailScreenDocumentDetailViewModeldocument/{documentId}Portrait page tiles, tap-to-review, long-press reorder, rename, import, export/save, move to group; ⋮ also opens Split into documents and the PDF tools with this document as ?source=
Split into documentsDocumentSplitRouteDocumentSplitViewModeldocument/{documentId}/splitCut grid → SplitDocumentUseCase → DocumentSplitRepository copies pages, page_texts and page_markups into new documents; optional move of the original to Recently deleted
Scan sessionScanSessionScreenScanSessionViewModelcamera/session/{docId}Camera permission (ask first), CameraX, gate + multi-model overlay, stability, auto-capture, finalize
Page previewPageImagePreviewScreenPageImagePreviewViewModelpreview/page/{pageId}Image-only paging, zoom, share/edit/retake/delete overflow
Page editorPageEditorScreenPageEditorViewModeleditor/page/{pageId}Opens filter/adjust/crop; retake, delete
Filter pickerFilterPickerScreen(shares PageEditorViewModel)(editor overlay)Full-screen live preview + preset chips
Filter adjustFilterCustomizeScreen(shares PageEditorViewModel)(editor overlay)Brightness/contrast/saturation/sharpness sliders
Page cropPageCropScreenPageCropViewModelcrop/page/{pageId}AI detect, rotate, four-point crop handles, reset, apply
SettingsSettingsScreenSettingsViewModelsettingsLook & feel, document detection, links, manual update check
LanguageSettingsLanguageScreen—settings/languageChoose a pending language and tap Apply to save it through AppLocales
Pip settingsSettingsPipScreenPipViewModelsettings/pipPip master switch, Home tips, camera coaching, export cheers, animation
StorageSettingsStorageScreenSettingsViewModelsettings/storageUsage, export destination, clear temporary exports, clean empty items, clear data
Model benchmarkModelBenchmarkRouteModelBenchmarkViewModelsettings/model-benchmarkPer-image overview with polygon overlays on scaled previews for each corner model, plus gate/pipeline stats
FAQsSettingsFaqScreenSettingsViewModelsettings/faqBundled FAQ content
LicensesSettingsLicensesScreenSettingsViewModelsettings/licensesThird-party license list
LegalLegalDocumentScreen—legal/{documentType}Privacy / terms WebView content
App updateAppUpdateDialogAppUpdateViewModel(overlay)Channel-specific update check, cooldown
Flexible updateFlexibleUpdateSnackbarAppUpdateViewModel(overlay)Restart prompt after Play flexible download
PlaceholderFeaturePlaceholderScreen—camera, review, editorLegacy stubs — do not extend

App-level ViewModels

Hosted in MainActivity, not tied to a single screen:

ViewModelRole
AppSettingsViewModelObserves theme mode and pure black preference globally
OnboardingViewModelTracks onboarding completion state
AppUpdateViewModelAutomatic and manual update checks; dialog and snackbar state

ViewModel → use case mapping (key screens)

HomeViewModel

  • ObserveRecentDocumentsUseCase, ObserveRecentGroupsUseCase
  • CreateDocumentUseCase, CreateGroupUseCase
  • SuggestDocumentTitleUseCase, SuggestGroupTitleUseCase
  • ImportImagesUseCase

LibraryViewModel

  • ObserveDocumentsUseCase, ObserveGroupsUseCase, ObserveUngroupedDocumentsUseCase
  • CreateDocumentUseCase, DeleteDocumentUseCase, RenameDocumentUseCase
  • CreateGroupUseCase, DeleteGroupUseCase, RenameGroupUseCase
  • SuggestDocumentTitleUseCase, SuggestGroupTitleUseCase

DocumentDetailViewModel

  • ObserveDocumentUseCase, ObserveDocumentPagesUseCase
  • RenameDocumentUseCase, DeletePageUseCase, MovePageUseCase
  • SetDocumentGroupUseCase, ImportImagesUseCase, SuggestGroupTitleUseCase
  • ExportDocumentPdfUseCase, ExportDocumentImageArchiveUseCase
  • SaveExportArtifactUseCase
  • PrepareDocumentPdfShareUseCase, PrepareDocumentImageShareUseCase

ScanSessionViewModel

  • PreparePageCaptureUseCase, PrepareReplacementCaptureUseCase
  • FinalizeCapturedPageUseCase
  • Observes live model / automatic selection / document gate preferences
  • Uses DocumentGateDetector, DocumentCornerDetector, StableCornerSelector, DocumentGateStabilityTracker, and CaptureStabilityTracker for live overlay and auto-capture

PageEditorViewModel

  • ObservePageUseCase, UpdatePageEditsUseCase, DeletePageUseCase
  • Filter preset + per-page adjustments (brightness/contrast/saturation/sharpness) and page delete; adopts crop/rotation updates after the crop screen applies

PageCropViewModel

  • ObservePageUseCase, UpdatePageEditsUseCase, DetectDocumentCornersUseCase
  • Uses CropQuadEditor for rotation, interactive crop handles, and session reset
  • AI Detect runs still-image corner detection (same post-processing path as capture)

PageImagePreviewViewModel

  • ObservePageUseCase, ObserveDocumentPagesUseCase
  • DeletePageUseCase
  • Share uses processed image path via FileProvider

GroupDetailViewModel

  • ObserveGroupUseCase, ObserveGroupDocumentsUseCase
  • RenameGroupUseCase, DeleteGroupUseCase, SetDocumentGroupUseCase
  • SuggestDocumentTitleUseCase, CreateDocumentUseCase
  • ExportGroupPdfUseCase, ExportGroupZippedPdfsUseCase
  • PrepareGroupPdfShareUseCase, PrepareGroupZippedPdfsShareUseCase
  • SaveExportArtifactUseCase

SettingsViewModel

  • ObserveThemeModeUseCase, SetThemeModeUseCase
  • ObservePureBlackEnabledUseCase, SetPureBlackEnabledUseCase
  • Live / post model observe+set, automatic selection, document gate use cases
  • LoadSettingsContentUseCase, GetAppStorageUsageUseCase
  • ObserveExportDestinationUseCase, SetExportDestinationUseCase, ResetExportDestinationUseCase
  • ClearExportCacheUseCase, DeleteEmptyDocumentsUseCase, DeleteEmptyGroupsUseCase, ClearAllAppDataUseCase
  • ObserveRatingPromptStateUseCase, DismissSettingsRatingCardUseCase, MarkAppRatedUseCase
  • AutomaticDocumentModelSelector for calibrated automatic picks
  • Triggers AppUpdateViewModel.checkForUpdates(Manual)

LibrarySearchViewModel and PageTextViewModel

  • Search combines document/folder name results with on-device page-text results, recent searches, ranking, filters, and correction suggestions.
  • PageTextViewModel loads extracted page text, saves corrections, and prepares page/all-page copy and share actions.

Signing ViewModels

  • PdfSignViewModel opens a PDF signing session, manages marks by page, and saves the signed PDF as a separate output.
  • DocumentSignViewModel loads and saves editable markups for a Scanly document; SignEditorScreen handles mark placement and editing.
  • SignatureCreateViewModel saves drawn/imported signature images; SignatureManageViewModel observes and deletes them.

ModelBenchmarkViewModel

  • Injects DocumentCornerDetector and DocumentGateDetector directly for temporary local runs
  • Does not share SettingsViewModel (results are ephemeral)

Shared UI components

feature/components/:

FilePurpose
SharedComponents.ktPaper document/group cards, overflow/long-press actions, thumbnails
FabComponents.ktFAB menus for create/scan/import
ExportShareComponents.ktExport and share bottom sheets

core/ui/:

FilePurpose
ScanlyChrome.ktTop bars, shared chrome
ThumbnailCache.ktIn-memory thumbnail cache
PreviewImageSizer.ktConsistent preview dimensions
ImageImportSupport.ktSystem file picker for images (50 image limit)
AdaptiveLayout.ktPhone vs tablet / width-class helpers
ZoomableImageDialog.ktPinch-zoom preview (document detail)
ZoomableImageViewer.ktPinch-zoom viewer (page preview)

Large-screen editor layout

On tablet landscape (and other wide landscape windows that opt into tool two-pane), editor flows share EditorLandscapeChrome:

ScreenLeft paneRight pane
Page editorLive cropped previewVertical tool rail (Crop, Filters, Adjust, Retake, Delete)
Page cropInteractive crop canvasVertical rail (AI Detect, rotate, reset)
FiltersLive filter previewScope switch + 2-column preset grid
AdjustLive adjusted previewScrollable sliders

Phone portrait keeps the stacked preview-above-controls layout.

Editor package helpers (feature/editor/):

FileRole
EditorImageSupport.ktLive preview: decode, crop, filter, adjustments
EditorScrollbars.ktShared vertical scrollbar for Filters/Adjust panes
FilterPickerScreen.ktFull-screen filter preset picker
FilterCustomizeScreen.ktFull-screen filter fine-tuning
PageCropScreen.kt / PageCropViewModel.ktDedicated crop route

Scan session internals

Classes supporting ScanSessionScreen (not separate screens):

ClassRole
CaptureFrameQualityAnalyzerLighting, blur, obstruction feedback
CaptureStabilityTrackerAuto-capture phase machine (AutoCapturePhase); worst-corner motion
DocumentGateStabilityTrackerRequires consecutive accepted gate frames before corners run
StableCornerSelectorRank, confirm, and smooth the visible outline
CameraOverlayMapperMaps ML quad to overlay coordinates

View source on GitHub · Markdown