Android: Reports (PDF)
Technical specification for PDF report generation and storage in the PestControlOS Android app.
Generation (iText)
- Templates: General service reports, rodent (Initial/Routine/Call-Out/External), ERA (Toxic/Non-Toxic). Implemented via
PDFReportGeneratorandPDFReportGeneratorWithTemplate. - Compression: All generated PDFs (Action Forms, Create Report) are automatically compressed; no user option.
- Create Report:
ReportActivitycollects form data; on save callsPDFReportGenerator.generatePDFReport(...)orPDFReportGeneratorWithTemplate.generatePdf(..., settings). PestControlOS template: fixed logo (drawable), title "PestControlOS Report", body viaaddReportBodyToDocument(...). Page handlerPdfWatermarkAndFooterHandleradds watermark and footer. Images added only when user has selected at least one (no placeholder when none).
Password protection
- Create Report: Optional checkbox "Password protect PDF"; owner password set; PDF encrypted (viewing/printing allowed; editing requires password). iText encryption API.
- Action Forms: Optional password via checkbox; dialog prompts for owner password; same view/print vs edit semantics.
Storage
- Firebase Storage: Year folders
ReportsYY/(e.g.Reports26/), optionally month subfolders. Path and naming flexible; contract-specific search scoped by year folder. When logged in, post-save dialog offers "Upload to Firebase". - Local: App external files (quotes, service agreements). Stored reports list; download/share. Offline users do not see Upload option; authenticated users can upload after save.
Custom templates and default offline report creation
- All users (offline and authenticated) have the same custom template and custom report capability. There is no difference between offline and logged-in users for template and report creation: both can use offline custom templates and default offline report creation.
- Offline custom templates: Custom templates are stored entirely locally (
PdfTemplateStorage: SharedPreferences + JSON for header blocks; logo and watermark image files incontext.getFilesDir()/pdf_template/). No Firebase dependency. Users can create as many named templates as needed; each template stores main header text, main header colour (Blue/Black/Dark Gray/Red/Green), logo path, watermark (on/off, text or image), and an ordered list of header blocks (text with style H1/H2/BODY or image). Save template settings saves the current setup as a named template and clears the form for the next; View templates lists all saved templates; Use opens Create Report with that template; Delete removes with confirmation. Templates are reusable for any future report. - Default offline report creation: When offline (or when not using Firebase for the report flow), the app supports full report creation: user selects PestControlOS template or My Template (or a saved custom template), configures or reuses settings, and generates the PDF. All generation is local; no server required. This is the default behaviour for offline users and remains available to authenticated users alongside PestControlOS/custom choice.
- PDFReportGeneratorWithTemplate: For PestControlOS selection, delegates to
PDFReportGenerator.generatePDFReport(...). For MY_TEMPLATE or a saved custom template, creates document with custom header: logo (200×200) first, then main header paragraph in chosen colour; custom watermark/footer viaCustomWatermarkAndFooterHandler; header blocks in body only; footer "Created by reporting system"; thenaddReportBodyToDocument(...)so body layout (margins, fonts, sections, table, footer, page numbers) is identical to PestControlOS. Body layout is the same in both modes; only header area and watermark differ for custom templates. - Key classes:
PdfTemplateSettings,SavedTemplate,PdfTemplateStorage,PDFReportGenerator,PDFReportGeneratorWithTemplate,PdfTemplateSettingsActivity,ViewTemplatesActivity.
Report selection and Create Report flow
- Report selection screen: "Custom Report (PDF Template)" opens PDF Template Settings; "Create Custom Report" opens the Create Report form with choice of Default (current settings) or "Select template…" (saved templates). User can create as many custom templates as needed and reuse any of them here.
- Create Report screen: User chooses Use PestControlOS Template, Use My Template (current settings), or a saved template from the list. PDF Template Settings is available to all users to create or edit templates. No restriction by login state: offline and authenticated users have the same custom template and custom report options.
Post-save dialog
- "Report Saved Successfully!" offers View, Share, and (when logged in) Upload to Firebase. Offline users see View and Share only.