Files
sar-android/CLAUDE.md
Julio Schlickmann dc61705c91 add project files
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 22:33:42 -03:00

60 lines
3.2 KiB
Markdown

# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
SAR Android (Sistema de Atendimento ao Representante) is a legacy Java Android sales-representative app. It allows sales reps to manage clients, products, and orders offline, then sync with a central PostgreSQL server.
**Language:** Java (no Kotlin)
**Build System:** Eclipse ADT (pre-Gradle) — no `build.gradle`; configured via `.project`, `.classpath`, and `project.properties`
**Min SDK:** 19 | **Target SDK:** 35
**Root package:** `br.com.jcsinformatica.sarandroid`
## Building
This is an Eclipse ADT project, not an Android Studio/Gradle project. There are no `gradlew` commands.
- Open in **Eclipse with ADT plugin** or import into Android Studio using "Import Eclipse ADT Project"
- SDK target is set in `project.properties` (`target=android-23`)
- ProGuard config exists in `proguard-project.txt` but is disabled
- Lint suppressions are in `lint.xml`
There are no automated tests (no `test/` or `androidTest/` directories, no JUnit/Espresso setup).
## Architecture
### Entry Flow
`SplashScreen``LoginActivity``MainActivity` (expandable menu) → feature Activities
### Key Classes
- **`Global`** — static singleton holding runtime state: current `Empresa`, `Pedido`, `ItemPedido`. Call `Global.getEmpresa()` (throws `WarningException` if unset).
- **`GlobalActivity`** — base `Activity` subclass for all post-login screens; reads company name from `Global` and sets the title.
- **`DatabaseHelper`** — `SQLiteOpenHelper` managing the local SQLite schema.
- **`ConnectionManager`** — manages PostgreSQL JDBC connections (20s timeout); used for remote sync.
### Package Structure
| Package | Role |
|---------|------|
| `vo/` | Plain value objects (models): `Produto`, `Cliente`, `Pedido`, `ItemPedido`, `Empresa`, `Representante`, etc. |
| `database/` | SQLite DAOs (named `*DB.java` or `*BD.java`): CRUD + sync logic with MD5 change detection |
| `postgres/` | PostgreSQL JDBC operations mirroring the DAO layer (`*PGSQL.java`) |
| `uimodels/` | Custom list adapters and UI helpers |
| `pedido/` | Order/quote Activities (`UpdatePedidoActivity`, `UpdatePedItemActivity`, `BrowsePedido`, etc.) |
| `produto/` | Product Activities (`BrowseProduto`, `UpdateProduto`, `FotosProduto`) |
| `cliente/` | Client Activities (`BrowseCliente`, `UpdateCliente`) |
| `comunicacao/` | `ComunicaActivity` — orchestrates full data sync with the PostgreSQL server |
| `consulta/` | Query/report Activities (`BrowsePedidoConsulta`, `ConsultaVendasActivity`) |
### Dual-Database Sync Pattern
All persistent data lives in local **SQLite** and is periodically synced to/from **PostgreSQL** over direct JDBC. The pattern per entity:
1. `*DB.java` — reads/writes SQLite, computes MD5 checksums for change detection
2. `*PGSQL.java` — mirrors inserts/updates to the PostgreSQL server
3. `ComunicaActivity` acts as the sync orchestrator and provides a callback interface for progress updates
### Third-Party Libraries (in `libs/`)
- `postgresql-8.2-jdbc3.jar` — PostgreSQL JDBC driver
- `joda-time-2.5.jar` — date/time calculations
- `commons-net-3.3.jar` — FTP support