250 lines
14 KiB
Markdown
250 lines
14 KiB
Markdown
<p align="center">
|
||
<img src="Icon.png" alt="Schnappix Logo" width="128" />
|
||
</p>
|
||
|
||
<h1 align="center">Schnappix</h1>
|
||
<p align="center"><strong>Tablet-optimized Android Photobooth app built with React Native and Expo, featuring Kiosk Mode, silent IPP printing, USB cameras, photo frames, and a sticker editor.</strong></p>
|
||
|
||
<p align="center">
|
||
<a href="README.md">🇬🇧 English</a> · <a href="LIESMICH.md">🇩🇪 Deutsch</a>
|
||
</p>
|
||
|
||
---
|
||
|
||
## Overview
|
||
|
||
Schnappix is a tablet-optimized Photobooth application built with React Native and Expo (Android package `de.orfel.schnappix`). It delivers an interactive, offline-first photo-capturing experience for events—complete with countdown, burst mode, generated collages, custom PNG photo frames, a social-media-style sticker editor, silent network printing over IPP, native Android Device Owner Kiosk Mode, external USB camera support, and an on-device Admin Dashboard.
|
||
|
||
---
|
||
|
||
## Features
|
||
|
||
- **Photobooth Experience**: Intuitive flow from welcome screen to countdown, photo capture, and final preview—with `CameraScreen` kept mounted in the background to prevent Android camera hardware crashes.
|
||
- **Multiple Photos & Collages**: Capture single shots or multi-photo sequences (up to 4 photos kept for collages) and review/edit them together.
|
||
- **Sticker & Emoji Editor**: Add curated party emojis and dynamic date/time/event stickers that can be dragged, pinched to resize, and rotated with two fingers.
|
||
- **Photo Frames**: Overlay transparent PNG frames (12 built-in designs in `assets/frames/`). Admins can set frames to off, always-on, or guest-selectable.
|
||
- **Continuous Shooting (Burst Mode)**: Automatically capture 1–5 shots in sequence with a configurable interval for collage printing.
|
||
- **Date/Time & Event Overlay**: Optionally stamp the date or date + time and configured event name onto photos with adjustable transform.
|
||
- **Camera Flash Effect**: Full-screen white flash animation on every capture for an authentic photobooth feel.
|
||
- **Direct Silent Printing (IPP)**: Built-in Internet Printing Protocol (`ipp-encoder`) client sending `image/jpeg` print jobs directly to port `631` (`/ipp/print`) with exponential backoff retries (up to 3 attempts), bypassing OS print dialogs. Leaving the printer IP empty enables digital-only mode.
|
||
- **Kiosk Mode (Lock Task Mode)**: Custom native Android module (`modules/kiosk-mode`) and config plugin (`plugins/withKioskAdmin`) to lock the tablet down to Schnappix without confirmation prompts when configured as Device Owner.
|
||
- **USB & Front Camera Support**: Supports internal front/rear cameras as well as external UVC USB cameras via custom native module (`modules/usb-camera`) and plugin (`plugins/withUsbCamera`).
|
||
- **Admin Dashboard**: PIN-protected settings screen (`AdminScreen`) to configure all parameters on the fly, persisted in `settings.json`.
|
||
- **Offline Gallery Storage (MediaStore API)**: Saves originals and final collages directly into structured Android gallery albums (`Schnappix - <EventName> - Originale` and `Schnappix - <EventName> - Collagen`).
|
||
|
||
---
|
||
|
||
## How It Works & Tech Stack
|
||
|
||
### Tech Stack
|
||
|
||
| Layer | Technology |
|
||
|---|---|
|
||
| **Framework** | [React Native](https://reactnative.dev/) (`0.81.5`) & [Expo](https://expo.dev/) (SDK `54`, New Architecture enabled) |
|
||
| **Language** | TypeScript (`^5.3.0`) & React (`19.1.0`) |
|
||
| **Camera & Media** | `expo-camera`, `expo-image`, `expo-image-manipulator`, `expo-file-system`, `expo-media-library` |
|
||
| **Editing & Capture** | `react-native-view-shot`, `react-native-gesture-handler`, `react-native-reanimated`, `react-native-worklets`, `expo-linear-gradient` |
|
||
| **Printing** | `ipp-encoder` (`^5.0.0`) + `buffer` (raw IPP v1.1 `Print-Job` over HTTP `POST` to `:631/ipp/print`) |
|
||
| **Icons** | `@fortawesome/react-native-fontawesome` (`fa-solid`), `react-native-svg` |
|
||
| **Native Modules & Plugins** | Local Expo modules (`kiosk-mode`, `usb-camera`) and config plugins (`withKioskAdmin`, `withUsbCamera`, `withLocalAars`, `withRemoveMediaPermissions`, `withProguardRules`, `withAndroidSigning`, `withOptimization`, `withMmkvForce`) |
|
||
| **Android Target** | `compileSdkVersion 36`, `targetSdkVersion 36`, `ndkVersion 28.0.12932649`, landscape orientation |
|
||
|
||
### Design Theme (`src/styles/theme.ts`)
|
||
|
||
Schnappix uses a **neon synthwave** aesthetic matching `Icon.png`:
|
||
- **Primary**: Electric magenta `#ff2bd6` (gradient stops `#ff2bd6` → `#a033ff` → `#28dfff`)
|
||
- **Accent**: Cyan blue `#28dfff`
|
||
- **Background**: Deep navy/black `#050510` (surface `#0D0D1A`, secondary `#151528`)
|
||
- **Effects**: Neon glow shadows and glassmorphism overlays (`rgba(13, 13, 26, 0.85)`)
|
||
- **Icons**: Font Awesome Solid icons with neon styling
|
||
|
||
### Photo Saving (MediaStore API)
|
||
|
||
`src/services/storage.ts` saves images via the native `KioskMode.saveImageToAlbum` MediaStore helper (Android 10+ `RELATIVE_PATH`), avoiding legacy storage permission prompts:
|
||
- Albums: `Schnappix - <EventName> - Originale` (raw shots) and `Schnappix - <EventName> - Collagen` (final exports)
|
||
- Filenames: `<SafeEventName>_YYYY-MM-DD_HH-mm-ss_<Raw|Collage>.<ext>`
|
||
|
||
> [!CAUTION]
|
||
> Do **not** attempt to force legacy `WRITE_EXTERNAL_STORAGE` or `READ_EXTERNAL_STORAGE` permissions on Android 13+; `plugins/withRemoveMediaPermissions.js` intentionally strips incompatible media permissions for Play Store and modern Android compliance.
|
||
|
||
---
|
||
|
||
## Prerequisites & Installation
|
||
|
||
### Prerequisites
|
||
|
||
- Node.js (`v18+`) and `npm`
|
||
- Expo CLI / EAS CLI (`>= 19.1.0` for EAS builds)
|
||
- Android Studio & Android SDK / NDK (`28.0.12932649`) for building the native Android project
|
||
|
||
### Local Setup
|
||
|
||
1. Clone the repository:
|
||
```bash
|
||
git clone https://git.orfel.de/Jannik/Schnappix.git
|
||
cd Schnappix
|
||
```
|
||
|
||
2. Install dependencies:
|
||
```bash
|
||
npm install
|
||
```
|
||
|
||
3. Prebuild the native Android project (required due to custom native modules and config plugins):
|
||
```bash
|
||
npx expo prebuild --clean --platform android
|
||
```
|
||
|
||
4. Run the app on an Android device or emulator:
|
||
```bash
|
||
npm run android
|
||
```
|
||
|
||
### Development & Build Rules
|
||
|
||
Schnappix follows strict versioning and release conventions:
|
||
|
||
1. **Versioning**: Version format is `23.01.X`, where `X` matches `expo.android.versionCode` in `app.json` (currently `23.01.78` / `versionCode: 78`).
|
||
2. **Build Outputs**: Production releases must always be built as **both** `.apk` and `.aab`, named `Schnappix_v23.01.X.apk` and `Schnappix_v23.01.X.aab`.
|
||
3. **Package Name**: Must strictly remain `de.orfel.schnappix`.
|
||
|
||
> [!NOTE]
|
||
> Note on settings persistence (`src/services/settings.ts`): When `Application.getLastUpdateTimeAsync()` detects that the app was updated or freshly installed (or `appLastUpdate` is missing), `loadSettings()` resets `settings.json` to `DEFAULT_SETTINGS`.
|
||
|
||
---
|
||
|
||
## Configuration
|
||
|
||
Tap the settings icon (⚙️) on the home screen and enter the admin PIN (default: `1234`) to open the **Admin Dashboard**.
|
||
|
||
### Admin Settings Overview (`src/services/settings.ts`)
|
||
|
||
| Setting | Internal Key | Description | Default |
|
||
|---|---|---|---|
|
||
| **Drucker IP-Adresse** | `printerIp` | Local IP of the IPP printer (e.g. Canon Selphy CP1300). Leave empty for digital-only mode | `192.168.0.1` |
|
||
| **Countdown-Dauer** | `countdownDuration` | Seconds before photo capture | `3` |
|
||
| **Admin-Passwort** | `adminPassword` | PIN to access the Admin Dashboard | `1234` |
|
||
| **Begrüßungstext** | `welcomeText` | Welcome headline on the home screen | `Zeit für ein Erinnerungsfoto!` |
|
||
| **Footer-Text** | `footerText` | Footer text on the home screen | `Display tippen! • Lächeln! • Foto schnappen!` |
|
||
| **Event-Name** | `eventText` | Event title for date stickers & album folder names (prompted via modal if empty) | `""` *(empty)* |
|
||
| **Serienbild-Anzahl** | `burstCount` | Number of photos per burst (`1` = single shot, `2–5` = burst) | `1` |
|
||
| **Serienbild-Abstand** | `burstIntervalSec` | Seconds between burst shots | `5` |
|
||
| **Fotorahmen-Modus** | `frameMode` | `off` (*Aus*) / `always` (*Immer an*) / `available` (*Verfügbar*) | `available` |
|
||
| **Datum-Einblendung** | `dateOverlay` | `off` (*Aus*) / `date` (*Nur Datum*) / `datetime` (*Datum + Uhrzeit*) | `off` |
|
||
| **Kiosk-Modus** | `kioskModeEnabled` | Locks the tablet to Schnappix (auto-starts on launch if enabled) | `false` (*Aus*) |
|
||
| **Frontkamera nutzen** | `useFrontCamera` | Toggles between front camera and rear/USB camera | `true` (*An*) |
|
||
| **Logs aktivieren** | `enableLogs` | Enables detailed in-app file logging | `true` (*An*) |
|
||
|
||
### Kiosk Mode (Android Device Owner) Setup
|
||
|
||
To use **true Kiosk Mode** (Lock Task Mode) without system confirmation prompts and without external MDM software, Schnappix must be registered as the Android **Device Owner**:
|
||
|
||
**Prerequisites:**
|
||
1. The Android tablet must have **no accounts** (such as a Google Account) configured—ideally start from a factory-reset device.
|
||
2. Enable **Developer Options** and **USB Debugging** on the tablet.
|
||
3. Install the Schnappix APK on the tablet.
|
||
|
||
**Setup Command:**
|
||
|
||
```bash
|
||
adb shell dpm set-device-owner de.orfel.schnappix/expo.modules.kioskmode.AdminReceiver
|
||
```
|
||
|
||
Expected confirmation:
|
||
`Success: Device owner set to package de.orfel.schnappix`
|
||
|
||
You can now disconnect USB and toggle **Kiosk-Modus** in the Admin Dashboard.
|
||
|
||
> [!WARNING]
|
||
> Once set as Device Owner, Android prevents normal uninstallation of Schnappix. You must either factory-reset the device or remove Device Owner status programmatically.
|
||
|
||
### Photo Frames — Setup Guide (`src/data/frames.ts`)
|
||
|
||
Custom photo frames are transparent PNG overlays rendered on top of captured photos before saving or printing.
|
||
|
||
| Property | Requirement |
|
||
|---|---|
|
||
| **Format** | PNG with **alpha channel** (transparency) |
|
||
| **Resolution** | **1500 × 1000 px** (3:2 landscape ratio, matching tablet display and print output) |
|
||
| **Transparency** | The photo area **must be fully transparent** (`alpha = 0`) |
|
||
| **File size** | Keep each file under **500 KB** for fast rendering |
|
||
| **Naming** | `frame_<name>.png` (e.g. `frame_balloons.png`) |
|
||
|
||
**Adding a new frame:**
|
||
1. Place the PNG file into `assets/frames/`.
|
||
2. Register it in `src/data/frames.ts`:
|
||
```typescript
|
||
export const FRAMES: FrameDefinition[] = [
|
||
{ id: 'balloons', name: 'Luftballons', asset: require('../../assets/frames/frame_balloons.png') },
|
||
];
|
||
```
|
||
3. Rebuild the Android app (`npx expo prebuild --clean --platform android` and `npm run android`).
|
||
4. Select the frame mode (`always` or `available`) in the Admin Dashboard.
|
||
|
||
---
|
||
|
||
## Usage
|
||
|
||
### Guest Photobooth Flow
|
||
|
||
1. **Welcome Screen**: Guest taps the screen to start (if `Event-Name` is empty, the Admin modal prompts for an event name first).
|
||
2. **Capture**: Countdown runs (`countdownDuration`), white screen flash fires, and either a single shot or burst sequence (`1–5` photos) is captured.
|
||
3. **Preview & Sticker Editor**:
|
||
- Tap **Sticker** to open `StickerTray` and add curated party emojis.
|
||
- Drag stickers anywhere, pinch to resize, and use two fingers to rotate (`DraggableSticker`).
|
||
- Tap a sticker to select it and press `×` to delete it.
|
||
- Dynamic date, time, and event-name stickers render automatically according to Admin settings.
|
||
- Choose a photo frame via `FramePicker` (when `frameMode` is `available`) or add more photos to build a collage.
|
||
- Save directly to the device gallery (`MediaStore`) and print silently via IPP.
|
||
|
||
### Useful npm Scripts
|
||
|
||
- `npm start` — Start Expo dev server
|
||
- `npm run android` — Build and run native Android app (`expo run:android`)
|
||
- `npm run ios` — Run iOS build (`expo run:ios`)
|
||
- `npm run web` — Run web preview (`expo start --web`)
|
||
|
||
---
|
||
|
||
## Project Structure
|
||
|
||
```text
|
||
Schnappix/
|
||
├── assets/
|
||
│ ├── frames/ # 12 built-in transparent PNG photo frames (1500×1000)
|
||
│ └── graphics/ # Store & sample promotional graphics
|
||
├── modules/
|
||
│ ├── kiosk-mode/ # Native Android Lock Task + MediaStore saving module
|
||
│ └── usb-camera/ # Native Android UVC USB camera module & AARs
|
||
├── plugins/ # Expo config plugins (kiosk, USB, AARs, signing, ProGuard, etc.)
|
||
├── src/
|
||
│ ├── components/ # DraggableSticker, FrameOverlay, FramePicker, GradientButton, Icon, StickerTray
|
||
│ ├── data/
|
||
│ │ └── frames.ts # Built-in photo frame registry
|
||
│ ├── screens/
|
||
│ │ ├── CameraScreen.tsx # Welcome overlay, countdown, flash, camera/USB capture
|
||
│ │ ├── PreviewScreen.tsx # Collage view, frame picker, sticker editor, print & save
|
||
│ │ └── AdminScreen.tsx # PIN-protected configuration dashboard
|
||
│ ├── services/
|
||
│ │ ├── logger.ts # Persistent file logger
|
||
│ │ ├── printer.ts # Silent IPP v1.1 JPEG network printing
|
||
│ │ ├── settings.ts # settings.json persistence & update-reset logic
|
||
│ │ └── storage.ts # Android MediaStore album saving
|
||
│ ├── styles/
|
||
│ │ └── theme.ts # Neon synthwave colors, spacing & gradients
|
||
│ └── types/
|
||
│ └── ipp-encoder.d.ts # TypeScript declarations for ipp-encoder
|
||
├── App.tsx # Root state machine & persistent CameraScreen host
|
||
├── app.json # Expo configuration (version 23.01.78, de.orfel.schnappix)
|
||
├── eas.json # EAS Build profiles (development, preview APK, production)
|
||
├── Icon.png # App icon
|
||
├── package.json # Dependencies and scripts
|
||
└── withAndroidSigning.js # Android release keystore signing plugin
|
||
```
|
||
|
||
---
|
||
|
||
## License
|
||
|
||
Licensed under the MIT License — see [LICENSE](LICENSE) for details.
|