Files
2026-08-03 13:25:22 +02:00

115 lines
4.3 KiB
Markdown

# SAIpp - Barcode Scanner & MariaDB Connector
Android application developed in Kotlin using Jetpack Compose that scans barcodes and saves them directly to a self-hosted MariaDB database.
## 🚀 Features
- **Dashboard**: High-level overview of inventory stats (Total SAIs, available, etc.) on the home screen.
- **Instant Scan & Quick Info**: Scan any SAI to see its details and current assignee immediately.
- **Search & Filter**: Robust search bars across all lists with optional barcode scanning for SAIs.
- **Smart Status Management**: Automatic SAI status updates (Available/Assigned) based on assignment records.
- **Confirmation Safety**: Built-in confirmation dialogs for all delete operations.
- **Modern UI**: Clean, card-based Material 3 interface with intuitive icons and native date pickers.
- **Visual Overlay**: Centered scanning guide with a red line to help align barcodes.
- **ML Kit Integration**: High-performance barcode detection (HD 720p analysis).
- **Confirmation Flow**: Scanned results are shown in a popup dialog before saving.
- **MariaDB Connectivity**: Direct connection to a remote database via JDBC.
- **Localization**: All app strings are managed in `strings.xml` for easy translation.
- **Modern UI**: Built with Jetpack Compose and Material 3.
- **Permission Handling**: Automatic runtime camera permission requests.
## 🛠️ Requirements
- Android device with API 34+ (Android 14+).
- MariaDB Server accessible from the mobile device network on port 3306.
- Camera hardware.
## 📱 User Interface
The app features a professional scanning interface:
1. **Connection Bar**: A status pill at the top (Green: Connected, Red: Error, Gray: Checking).
2. **Scanner Guide**: A white square frame indicates the target area with a red alignment line.
3. **Detection Popup**: When a code is read, a dialog appears with the value.
4. **Database Actions**: Buttons to "Guardar" (Save) or "Cerrar" (Dismiss).
## ⚙️ Configuration
### 1. Database Setup
Ensure your MariaDB database has the following tables:
```sql
-- Table for SAIs
CREATE TABLE SAIs (
id_sai INT AUTO_INCREMENT PRIMARY KEY,
ns VARCHAR(255) NOT NULL UNIQUE,
modelo VARCHAR(255),
estado ENUM('Disponible', 'Asignado', 'En reparación', 'Baja') NOT NULL DEFAULT 'Disponible'
);
-- Table for Batteries
CREATE TABLE Bateria (
id_bateria INT AUTO_INCREMENT PRIMARY KEY,
id_sai INT,
marca VARCHAR(255),
fecha_instalacion DATE,
FOREIGN KEY (id_sai) REFERENCES SAIs(id_sai)
);
-- Table for People
CREATE TABLE Persona (
id_persona INT AUTO_INCREMENT PRIMARY KEY,
nombre VARCHAR(255) NOT NULL,
activo TINYINT(1) DEFAULT 1
);
-- Table for SAI - Person Assignments
CREATE TABLE Asignado (
id_asignacion INT AUTO_INCREMENT PRIMARY KEY,
id_sai INT,
id_persona INT,
fecha_asignado DATE,
fecha_devolucion DATE,
observaciones VARCHAR(255),
FOREIGN KEY (id_sai) REFERENCES SAIs(id_sai),
FOREIGN KEY (id_persona) REFERENCES Persona(id_persona)
);
```
### 2. App Credentials
Update your database connection details in:
`app/src/main/java/com/example/saipp/data/MariaDbConnection.kt`
> [!IMPORTANT]
> Use the raw domain or IP for the `HOST`. **Do NOT include `https://`**.
```kotlin
private const val HOST = "mariadb.peta9.com" // Example: "192.168.1.50"
private const val PORT = "3306"
private const val DATABASE = "sais_db"
private const val USER = "sais_dba"
private const val PASSWORD = "your_password"
```
### 3. Network Access
- Ensure the MariaDB port (default **3306**) is open.
- Your MariaDB user must allow remote connections:
```sql
GRANT ALL PRIVILEGES ON sais_db.* TO 'sais_dba'@'%' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
```
## 📦 Dependencies
- **CameraX**: For camera preview and high-resolution frame capture.
- **ML Kit Barcode Scanning**: For processing all barcode formats.
- **MariaDB Java Client**: JDBC driver for database communication.
- **Coroutines**: For asynchronous database and connection checks.
## ⚠️ Security Warning
> [!CAUTION]
> This project uses a **direct JDBC connection**. This is suitable for personal projects or internal tools, but is **not recommended for production apps** as it requires storing credentials in the code and exposing database ports.
## 📄 License
This project is for educational/personal use.