| # Air Mouse โ Complete Application Documentation | |
| ## ๐ Table of Contents | |
| 1. [Project Overview](#project-overview) | |
| 2. [Architecture](#architecture) | |
| 3. [Package Structure](#package-structure) | |
| 4. [Core Components](#core-components) | |
| 5. [Data Flow](#data-flow) | |
| 6. [Dependency Injection](#dependency-injection) | |
| 7. [UI Layer](#ui-layer) | |
| 8. [Domain Layer](#domain-layer) | |
| 9. [Data Layer](#data-layer) | |
| 10. [Infrastructure Layer](#infrastructure-layer) | |
| 11. [Building & Running](#building--running) | |
| 12. [Testing](#testing) | |
| 13. [Contributing](#contributing) | |
| --- | |
| ## 1. Project Overview | |
| ### 1.1 What is Air Mouse? | |
| Air Mouse is a **production-ready Android application** that turns your smartphone into a wireless mouse, gesture controller, and presentation remote. The app uses device sensors (gyroscope, accelerometer, magnetometer) to detect movement and gestures, then sends commands to a PC server over WebSocket/TCP/UDP. | |
| ### 1.2 Key Features | |
| | Category | Features | | |
| |----------|----------| | |
| | **Mouse Control** | Cursor movement, left/right click, double click, scroll | | |
| | **Gestures** | Click, double-click, right-click, scroll, swipe, custom gestures | | |
| | **Touchpad** | Full touchpad simulation with multi-touch gestures | | |
| | **Voice Commands** | Wake word detection, custom commands, voice feedback | | |
| | **Proximity Lock** | Auto-lock/unlock PC when you walk away | | |
| | **Calibration** | Gyroscope, accelerometer, magnetometer calibration | | |
| | **Presentation Mode** | Laser pointer, annotations, timer, Q&A | | |
| | **Game Profiles** | Automatic game detection with custom settings | | |
| | **Macro Recorder** | Record and playback mouse/keyboard macros | | |
| | **Screen Mirroring** | Real-time screen streaming to PC | | |
| | **Profiles** | Multiple user profiles with custom settings | | |
| | **Themes** | 20+ themes with accent colors | | |
| | **Accessibility** | High contrast, large text, screen reader support | | |
| | **Server Logs** | Real-time log viewer with filters and export | | |
| | **File Transfer** | Transfer files between phone and PC | | |
| | **Data Sync** | Sync calibration, gestures, profiles to server | | |
| ### 1.3 Technology Stack | |
| | Component | Technology | | |
| |-----------|------------| | |
| | **UI Framework** | Jetpack Compose (Material 3) | | |
| | **Architecture** | Clean Architecture + MVI | | |
| | **Dependency Injection** | Dagger Hilt | | |
| | **Database** | Room (SQLite) | | |
| | **Preferences** | SharedPreferences + DataStore | | |
| | **Networking** | OkHttp, WebSocket, TCP, UDP | | |
| | **Concurrency** | Kotlin Coroutines & Flow | | |
| | **Sensor Fusion** | Madgwick AHRS | | |
| | **Build Tool** | Gradle (Kotlin DSL) | | |
| | **Minimum SDK** | API 24 (Android 7.0) | | |
| | **Target SDK** | API 34 (Android 14) | | |
| ### 1.4 Version Information | |
| | Version | Release Date | Key Changes | | |
| |---------|--------------|-------------| | |
| | **3.0.0** | 2025-01-15 | Complete rewrite with Compose, Clean Architecture, MVI | | |
| --- | |
| ## 2. Architecture | |
| ### 2.1 Clean Architecture Overview | |
| The application follows **Clean Architecture** with four distinct layers: | |
| ``` | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| โ PRESENTATION LAYER โ | |
| โ (Compose UI / ViewModels) โ | |
| โ โ | |
| โ DEPENDS ON โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| โ | |
| โผ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| โ DOMAIN LAYER โ | |
| โ (Models / Use Cases / Interfaces) โ | |
| โ โ | |
| โ INDEPENDENT OF FRAMEWORKS โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| โ | |
| โผ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| โ DATA LAYER โ | |
| โ (Repository Implementations / Data Sources) โ | |
| โ โ | |
| โ DEPENDS ON โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| โ | |
| โผ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| โ INFRASTRUCTURE LAYER โ | |
| โ (Network / Sensors / Database / Utilities) โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| ``` | |
| ### 2.2 Dependency Direction | |
| ``` | |
| Presentation โ Domain โ Data โ Infrastructure | |
| โ โ โ โ | |
| โโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโ | |
| (Dependency Injection) | |
| ``` | |
| ### 2.3 MVI Pattern (Model-View-Intent) | |
| All screens follow the **MVI (Model-View-Intent)** pattern: | |
| ``` | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| โ MVI PATTERN โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค | |
| โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ VIEW โ โ | |
| โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ | |
| โ โ โ Compose Screen โ โ โ | |
| โ โ โ โข Renders UI based on State โ โ โ | |
| โ โ โ โข Dispatches Events to ViewModel โ โ โ | |
| โ โ โ โข Handles Effects (navigation, toasts) โ โ โ | |
| โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ โ | |
| โ โผ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ VIEW MODEL โ โ | |
| โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ | |
| โ โ โ StateFlow<UiState> โ SharedFlow<Effect> โ โ โ | |
| โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค โ โ | |
| โ โ โ fun handleEvent(event: Event) { โ โ โ | |
| โ โ โ when (event) { ... } โ โ โ | |
| โ โ โ } โ โ โ | |
| โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ โ | |
| โ โผ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ MODEL โ โ | |
| โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ | |
| โ โ โ data class UiState(...) โ โ โ | |
| โ โ โ sealed class Event { ... } โ โ โ | |
| โ โ โ sealed class Effect { ... } โ โ โ | |
| โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| ``` | |
| --- | |
| ## 3. Package Structure | |
| ### 3.1 Complete Package Tree | |
| ``` | |
| com.airmouse/ | |
| โโโ AirMouseApplication.kt # Application class | |
| โโโ PreferencesManager.kt # Preferences interface | |
| โโโ SensorService.kt # Sensor service interface | |
| โ | |
| โโโ data/ # DATA LAYER | |
| โ โโโ datasource/ | |
| โ โ โโโ local/ # Local data sources | |
| โ โ โ โโโ AppDatabase.kt # Room database | |
| โ โ โ โโโ Converters.kt # Room type converters | |
| โ โ โ โโโ entities/ # Room entities (8 files) | |
| โ โ โ โโโ dao/ # Room DAOs (8 files) | |
| โ โ โ โโโ interfaces/ # Local data source interfaces (6 files) | |
| โ โ โ โโโ implementations/ # Local data source impls (6 files) | |
| โ โ โ โโโ models/ # Local data models (5 files) | |
| โ โ โโโ remote/ # Remote data sources | |
| โ โ โโโ interfaces/ # Remote data source interfaces (4 files) | |
| โ โ โโโ implementations/ # Remote data source impls (4 files) | |
| โ โโโ repository/ # Repository implementations (11 files) | |
| โ โโโ mapper/ # Domain โ Entity mappers (2 files) | |
| โ | |
| โโโ domain/ # DOMAIN LAYER | |
| โ โโโ model/ # Domain models (50+ files) | |
| โ โโโ repository/ # Repository interfaces (11 files) | |
| โ โโโ usecase/ # Use cases (16 files) | |
| โ โโโ feature/ # Feature orchestrators (10 files) | |
| โ | |
| โโโ presentation/ # PRESENTATION LAYER | |
| โ โโโ ui/ # UI Screens | |
| โ โ โโโ home/ # Home screen | |
| โ โ โโโ settings/ # Settings screen | |
| โ โ โโโ calibration/ # Calibration screens | |
| โ โ โโโ touchpad/ # Touchpad screen | |
| โ โ โโโ voice/ # Voice commands screen | |
| โ โ โโโ themes/ # Themes screen | |
| โ โ โโโ accessibility/ # Accessibility screen | |
| โ โ โโโ profiles/ # Profiles screen | |
| โ โ โโโ proximity/ # Proximity screen | |
| โ โ โโโ logs/ # Server logs screen | |
| โ โ โโโ help/ # Help screen | |
| โ โ โโโ about/ # About screen (stub) | |
| โ โ โโโ statistics/ # Statistics screen (stub) | |
| โ โ โโโ gesture/ # Gesture studio (stub) | |
| โ โ โโโ edge/ # Edge gestures (stub) | |
| โ โ โโโ network/ # Network discovery (stub) | |
| โ โ โโโ sensor/ # Sensor visualizer (stub) | |
| โ โ โโโ battery/ # Battery screen (stub) | |
| โ โ โโโ files/ # File transfer (stub) | |
| โ โ โโโ onboarding/ # Onboarding screens | |
| โ โ โโโ main/ # Main screen components | |
| โ โโโ navigation/ # Navigation | |
| โ โ โโโ Destinations.kt | |
| โ โ โโโ NavigationActions.kt | |
| โ โ โโโ AirMouseNavHost.kt | |
| โ โ โโโ AirMouseBottomBar.kt | |
| โ โโโ theme/ # Theming | |
| โ โ โโโ Theme.kt | |
| โ โ โโโ ThemeColors.kt | |
| โ โ โโโ Color.kt | |
| โ โ โโโ Dimensions.kt | |
| โ โ โโโ Shapes.kt | |
| โ โโโ components/ # Reusable UI components (28 files) | |
| โ โโโ extensions/ # Compose extensions | |
| โ โโโ MainActivity.kt # Main activity | |
| โ | |
| โโโ network/ # INFRASTRUCTURE โ NETWORK | |
| โ โโโ ConnectionManager.kt # Core network manager | |
| โ โโโ UdpDiscovery.kt # UDP server discovery | |
| โ โโโ AutoReconnectManager.kt # Automatic reconnection | |
| โ โโโ NetworkQualityMonitor.kt # Network quality monitoring | |
| โ โโโ MessageTypes.kt # Protocol constants | |
| โ โโโ AirMouseProtocolMessages.kt # Message builders | |
| โ โโโ ConnectionHelper.kt # Extension functions | |
| โ โโโ TcpClient.kt # DEPRECATED โ TCP client | |
| โ โโโ WebSocketManager.kt # DEPRECATED โ WebSocket client | |
| โ | |
| โโโ sensors/ # INFRASTRUCTURE โ SENSORS | |
| โ โโโ SensorService.kt # Main sensor service | |
| โ โโโ CalibrationHelper.kt # Sensor calibration | |
| โ โโโ EnhancedGestureDetector.kt # Advanced gesture detection | |
| โ โโโ MadgwickAHRS.kt # Sensor fusion algorithm | |
| โ โโโ MotionAnalyzer.kt # Motion feature analysis | |
| โ โโโ MotionDetector.kt # Basic motion detection | |
| โ โโโ OrientationTracker.kt # Orientation tracking | |
| โ โโโ SensorDataLogger.kt # CSV logging | |
| โ โโโ SensorDataProcessor.kt # Signal processing filters | |
| โ โโโ SensorFusion.kt # Static fusion utilities | |
| โ โโโ SensorManagerHelper.kt # Sensor availability | |
| โ โโโ GestureDetector.kt # Legacy gesture detector | |
| โ | |
| โโโ utils/ # INFRASTRUCTURE โ UTILITIES | |
| โ โโโ PreferencesManager.kt # Core preferences | |
| โ โโโ PreferencesKeys.kt # Preference keys (138 constants) | |
| โ โโโ LogManager.kt # Centralized logging | |
| โ โโโ PermissionHelper.kt # Permission management | |
| โ โโโ VibrateUtils.kt # Haptic feedback | |
| โ โโโ AudioUtils.kt # Sound playback | |
| โ โโโ BluetoothUtils.kt # Bluetooth operations | |
| โ โโโ BatterySaver.kt # Battery optimization | |
| โ โโโ ConnectedDeviceStore.kt # Device history | |
| โ โโโ QRScanner.kt # QR code scanning | |
| โ โโโ AnimationUtils.kt # Animation helpers | |
| โ โโโ StringUtils.kt # String helpers | |
| โ โโโ ValidationUtils.kt # Validation helpers | |
| โ โโโ MathUtils.kt # Math helpers | |
| โ โโโ ConversionUtils.kt # Unit conversion | |
| โ โโโ DateUtils.kt # Date formatting | |
| โ โโโ ColorUtils.kt # Color manipulation | |
| โ โโโ FileHelper.kt # File operations | |
| โ โโโ JsonHelper.kt # JSON serialization | |
| โ โโโ NetworkUtils.kt # Network utilities | |
| โ โโโ ResourceHelper.kt # Resource access | |
| โ โโโ ThemeManager.kt # Theme management | |
| โ โโโ DialogHelper.kt # Dialog helpers | |
| โ โโโ ViewHelpers.kt # View extensions | |
| โ โโโ ResultExtensions.kt # Result<T> extensions | |
| โ โโโ SensorUtils.kt # Sensor utilities | |
| โ โโโ ErrorHandler.kt # Error handling | |
| โ โโโ AppConstants.kt # Constants | |
| โ โโโ ApplicationContext.kt # Hilt qualifier | |
| โ โโโ Utils.kt # General utilities | |
| โ | |
| โโโ notifications/ # INFRASTRUCTURE โ NOTIFICATIONS | |
| โ โโโ NotificationManager.kt # Notification management | |
| โ | |
| โโโ files/ # INFRASTRUCTURE โ FILE TRANSFER | |
| โ โโโ FileTransferService.kt # File transfer service | |
| โ | |
| โโโ mirroring/ # INFRASTRUCTURE โ SCREEN MIRRORING | |
| โ โโโ ScreenMirroringService.kt # Screen mirroring service | |
| โ | |
| โโโ gaming/ # INFRASTRUCTURE โ GAMING | |
| โ โโโ GameProfilesManager.kt # Game profiles management | |
| โ | |
| โโโ macros/ # INFRASTRUCTURE โ MACROS | |
| โ โโโ MacroRecorder.kt # Macro recording & playback | |
| โ | |
| โโโ sync/ # INFRASTRUCTURE โ SYNC | |
| โ โโโ DataSyncManager.kt # Data synchronization | |
| โ | |
| โโโ di/ # DEPENDENCY INJECTION | |
| โ โโโ AppContainer.kt | |
| โ โโโ AppModule.kt | |
| โ โโโ NetworkModule.kt | |
| โ โโโ DatabaseModule.kt | |
| โ โโโ SensorModule.kt | |
| โ โโโ ServiceModule.kt | |
| โ โโโ RepositoryModule.kt | |
| โ โโโ UseCaseModule.kt | |
| โ โโโ FeatureModule.kt | |
| โ โโโ ViewModelModule.kt | |
| โ โโโ CalibrationModule.kt | |
| โ โโโ CoroutineModule.kt | |
| โ โโโ GestureRepositoryModule.kt | |
| โ | |
| โโโ ui/ # UI UTILITIES | |
| โโโ BaseActivity.kt | |
| โโโ DebugOverlay.kt | |
| โโโ SensorCubeView.kt | |
| โโโ UiStyleUtils.kt | |
| โโโ WebViewActivity.kt | |
| โโโ onboarding/ | |
| โโโ OnboardingActivity.kt | |
| โโโ OnboardingItem.kt | |
| โโโ OnboardingPagerAdapter.kt | |
| ``` | |
| ### 3.2 File Count Summary | |
| | Layer | Files | Lines of Code (approx) | | |
| |-------|-------|------------------------| | |
| | **Domain** | 87+ | ~6,400 | | |
| | **Data** | 60+ | ~4,500 | | |
| | **Presentation** | 80+ | ~12,000 | | |
| | **Infrastructure** | 100+ | ~8,000 | | |
| | **Total** | **327+** | **~30,900** | | |
| --- | |
| ## 4. Core Components | |
| ### 4.1 Domain Layer | |
| #### Models (50+ files) | |
| | Category | Models | Purpose | | |
| |----------|--------|---------| | |
| | **Calibration** | `CalibrationStatus`, `CalibrationQuality`, `CalibrationData`, `SensorCalibrationData`, `CalibrationProgress` | Sensor calibration | | |
| | **Connection** | `ConnectionStatus`, `ConnectionProtocol`, `ConnectionConfig`, `ConnectionQuality`, `DiscoveredServer` | Network connection | | |
| | **Gesture** | `GestureType`, `GestureEvent`, `CustomGestureTemplate`, `GestureTemplate`, `GestureTrainingStats` | Gesture detection | | |
| | **Mouse** | `MouseButton`, `MouseEvent`, `MovementProfile`, `MouseStatistics` | Mouse control | | |
| | **Proximity** | `ProximityState`, `ProximityConfig`, `ProximityCalibration` | Proximity detection | | |
| | **Statistics** | `StatisticsSummary`, `DailyStats`, `HistoricalStatistics`, `GestureStats` | Usage statistics | | |
| | **Profile** | `UserProfile`, `ProfileSettings`, `ProfileSort`, `ViewMode` | User profiles | | |
| | **Voice** | `VoiceCommand`, `VoiceCommandConfig`, `VoiceCommandHistory` | Voice commands | | |
| | **Update** | `UpdateResult`, `VersionInfo`, `UpdateInfo`, `UpdateProgress` | App updates | | |
| | **Bluetooth** | `BluetoothDeviceInfo`, `BLEService`, `BLECharacteristic` | Bluetooth communication | | |
| | **Error** | `ErrorType`, `AppError` | Error handling | | |
| #### Repository Interfaces (11 files) | |
| | Repository | Purpose | Key Methods | | |
| |------------|---------|-------------| | |
| | `ICalibrationRepository` | Sensor calibration | `calibrateGyroscope()`, `getCalibrationData()` | | |
| | `IConnectionRepository` | Network connection | `connect()`, `disconnect()`, `sendMove()` | | |
| | `IGestureRepository` | Gesture detection | `detectGesture()`, `addCustomGesture()` | | |
| | `IMouseRepository` | Cursor control | `move()`, `click()`, `scroll()` | | |
| | `IProfileRepository` | User profiles | `createProfile()`, `updateProfile()` | | |
| | `IProximityRepository` | Proximity detection | `startMonitoring()`, `getProximityState()` | | |
| | `ISensorRepository` | Sensor data | `observeSensorData()`, `startSensors()` | | |
| | `ISettingsRepository` | App settings | `getSensitivity()`, `setTheme()` | | |
| | `IStatisticsRepository` | Usage statistics | `recordClick()`, `getCurrentSession()` | | |
| | `IUpdateRepository` | App updates | `checkForUpdates()`, `downloadUpdate()` | | |
| | `IVoiceCommandRepository` | Voice commands | `processVoiceInput()`, `addCommand()` | | |
| #### Use Cases (16 files) | |
| | Use Case | Purpose | | |
| |----------|---------| | |
| | `CalibrationUseCase` | Sensor calibration orchestration | | |
| | `ConnectToServerUseCase` | Server connection management | | |
| | `SendMovementUseCase` | Cursor movement and clicks | | |
| | `DetectGestureUseCase` | Gesture detection | | |
| | `DiscoverServersUseCase` | UDP server discovery | | |
| | `GetConnectionStatusUseCase` | Connection status retrieval | | |
| | `GetStatisticsUseCase` | Usage statistics retrieval | | |
| | `RecordStatisticsUseCase` | Usage statistics recording | | |
| | `ManageProfileUseCase` | User profile management | | |
| | `ManageGestureTemplatesUseCase` | Gesture template management | | |
| | `HandleVoiceCommandUseCase` | Voice command processing | | |
| | `GetProximityStateUseCase` | Proximity state retrieval | | |
| | `UpdateProximityConfigUseCase` | Proximity configuration | | |
| | `TestConnectionUseCase` | Connection testing | | |
| | `CheckForUpdatesUseCase` | App update checking | | |
| | `GetGestureStatisticsUseCase` | Gesture statistics retrieval | | |
| ### 4.2 Data Layer | |
| #### Repository Implementations (11 files) | |
| | Repository | Data Sources | | |
| |------------|--------------| | |
| | `CalibrationRepositoryImpl` | `ICalibrationDataSource`, `CalibrationHelper` | | |
| | `ConnectionRepositoryImpl` | `IConnectionDataSource` | | |
| | `GestureRepositoryImpl` | `IGestureDataSource`, `EnhancedGestureDetector` | | |
| | `MouseRepositoryImpl` | `ConnectionManager` | | |
| | `ProfileRepositoryImpl` | `IProfileDataSource` | | |
| | `ProximityRepositoryImpl` | `BluetoothAdapter`, `ConnectionManager` | | |
| | `SensorRepositoryImpl` | `SensorManager`, `CalibrationHelper` | | |
| | `SettingsRepositoryImpl` | `IPreferencesDataSource` | | |
| | `StatisticsRepositoryImpl` | `IStatisticsDataSource` | | |
| | `UpdateRepositoryImpl` | `IPreferencesDataSource` | | |
| | `VoiceCommandRepositoryImpl` | `IPreferencesDataSource` | | |
| #### Local Data Sources | |
| | Data Source | Storage | Purpose | | |
| |-------------|---------|---------| | |
| | `CalibrationDataSourceImpl` | Preferences | Sensor calibration data | | |
| | `GestureDataSourceImpl` | Preferences (JSON) | Gesture templates, training, stats | | |
| | `ProfileDataSourceImpl` | Preferences (JSON) | User profiles, settings | | |
| | `StatisticsDataSourceImpl` | Preferences (JSON) | Session, daily, historical stats | | |
| | `PreferencesDataSourceImpl` | Preferences | Generic preferences | | |
| | `LocalDataSourceImpl` | Room + Preferences | Unified local data access | | |
| #### Room Database | |
| | Entity | DAO | Purpose | | |
| |--------|-----|---------| | |
| | `CalibrationEntity` | `CalibrationDao` | Sensor calibration data | | |
| | `ProfileEntity` | `ProfileDao` | User profiles | | |
| | `GestureTemplateEntity` | `GestureDao` | Gesture templates | | |
| | `TrainingSampleEntity` | `TrainingSampleDao` | ML training data | | |
| | `StatisticsEntity` | `StatisticsDao` | Session statistics | | |
| | `DailyStatsEntity` | `DailyStatsDao` | Daily aggregated stats | | |
| | `GestureStatsEntity` | `GestureStatsDao` | Per-gesture stats | | |
| | `SettingsEntity` | `SettingsDao` | App settings | | |
| ### 4.3 Infrastructure Layer | |
| #### Network | |
| | Component | Purpose | Protocol | | |
| |-----------|---------|----------| | |
| | `ConnectionManager` | Core network manager | WebSocket/TCP/UDP | | |
| | `UdpDiscovery` | Server discovery | UDP | | |
| | `AutoReconnectManager` | Reconnection logic | - | | |
| | `NetworkQualityMonitor` | Quality monitoring | - | | |
| #### Sensors | |
| | Component | Purpose | | |
| |-----------|---------| | |
| | `SensorService` | Central sensor manager | | |
| | `CalibrationHelper` | Sensor calibration | | |
| | `EnhancedGestureDetector` | Gesture detection | | |
| | `MadgwickAHRS` | Sensor fusion algorithm | | |
| | `MotionAnalyzer` | Motion analysis | | |
| #### Utilities (32 files) | |
| | Category | Files | | |
| |----------|-------| | |
| | **Preferences** | `PreferencesManager`, `PreferencesKeys`, `PreferencesHelper`, `SharedPrefsUtils`, `PreferencesDataStore` | | |
| | **Logging** | `LogManager`, `ErrorHandler` | | |
| | **Permissions** | `PermissionHelper`, `PermissionManager`, `PermissionUIHelper`, `PermissionUtils` | | |
| | **Bluetooth** | `BluetoothUtils` | | |
| | **Network** | `NetworkUtils`, `NetworkStateHelper` | | |
| | **Audio/Vibration** | `VibrateUtils`, `AudioUtils` | | |
| | **Battery** | `BatterySaver`, `BatteryOptimizer` | | |
| | **Math** | `MathUtils`, `ConversionUtils` | | |
| | **Date** | `DateUtils` | | |
| | **File** | `FileHelper`, `JsonHelper` | | |
| | **QR** | `QRScanner` | | |
| | **Animation** | `AnimationUtils` | | |
| | **Color** | `ColorUtils` | | |
| | **Validation** | `StringUtils`, `ValidationUtils` | | |
| ### 4.4 Presentation Layer | |
| #### Screens (22+ files) | |
| | Screen | Status | ViewModel | | |
| |--------|--------|-----------| | |
| | **Home** | โ Complete | `HomeViewModel` | | |
| | **Settings** | โ Complete | `SettingsViewModel` | | |
| | **Calibration** | โ Complete | `CalibrationViewModel` | | |
| | **Touchpad** | โ Complete | `TouchpadViewModel` | | |
| | **Voice Commands** | โ Complete | `VoiceCommandsViewModel` | | |
| | **Themes** | โ Complete | `ThemesViewModel` | | |
| | **Accessibility** | โ Complete | `AccessibilityViewModel` | | |
| | **Profiles** | โ Complete | `ProfilesViewModel` | | |
| | **Proximity** | โ Complete | `ProximityViewModel` | | |
| | **Server Logs** | โ Complete | `ServerLogsViewModel` | | |
| | **Help** | โ Complete | `HelpViewModel` | | |
| | **Statistics** | โ ๏ธ Stub | `StatisticsViewModel` | | |
| | **About** | โ ๏ธ Stub | `AboutViewModel` | | |
| | **Gesture Studio** | โ ๏ธ Stub | `GestureStudioViewModel` | | |
| | **Edge Gestures** | โ ๏ธ Stub | `EdgeGesturesViewModel` | | |
| | **Network Discovery** | โ ๏ธ Stub | `NetworkDiscoveryViewModel` | | |
| | **Sensor Visualizer** | โ ๏ธ Stub | `SensorVisualizerViewModel` | | |
| | **Battery** | โ ๏ธ Stub | `BatteryViewModel` | | |
| | **File Transfer** | โ ๏ธ Stub | `FileTransferViewModel` | | |
| #### UI Components (28 files) | |
| | Category | Components | | |
| |----------|------------| | |
| | **Animations** | `AnimatedCheckbox`, `AnimatedSwitch`, `AnimatedToast`, `AnimatedCounter`, `AnimatedConnectionStatus` | | |
| | **Status** | `BatteryLevelIndicator`, `ConnectionStatusBadge`, `NotificationBadge` | | |
| | **Charts** | `DataChart`, `GestureWaveform`, `RadarAnimation` | | |
| | **Cards** | `GlassCard`, `NeumorphicCard`, `InteractiveTutorialCard` | | |
| | **Buttons** | `NeonButton`, `GradientIconButton`, `FloatingActionMenu` | | |
| | **Effects** | `FloatingParticles`, `ParticleBackground`, `VoiceWaveAnimation`, `HolographicText` | | |
| | **Utilities** | `ShimmerEffect`, `SkeletonScreen`, `PullToRefresh`, `SlideUpPanel` | | |
| | **Visualization** | `SensorVisualizer`, `GestureWaveform` | | |
| --- | |
| ## 5. Data Flow | |
| ### 5.1 Complete Data Flow Diagram | |
| ``` | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| โ DATA FLOW โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค | |
| โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ USER INTERACTION โ โ | |
| โ โ (Touch / Gesture / Voice) โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ โ | |
| โ โผ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ VIEW MODEL โ โ | |
| โ โ (StateFlow / SharedFlow / Events) โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ โ | |
| โ โผ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ USE CASE โ โ | |
| โ โ (Business Logic) โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ โ | |
| โ โผ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ REPOSITORY INTERFACE โ โ | |
| โ โ (Domain Contract) โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ โ | |
| โ โผ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ REPOSITORY IMPLEMENTATION โ โ | |
| โ โ (Data Layer) โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ โ | |
| โ โผ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ DATA SOURCE โ โ | |
| โ โ (Room / Preferences / Network) โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ STATE FLOW BACK โ โ | |
| โ โ Data Source โ Repository โ Use Case โ ViewModel โ UI โ โ | |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ | |
| โ โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| ``` | |
| ### 5.2 Example: Connect to Server | |
| ``` | |
| 1. User taps "Connect" button | |
| โ | |
| 2. HomeViewModel.connect() | |
| โ | |
| 3. ConnectToServerUseCase(config) | |
| โ | |
| 4. ConnectionRepository.connect(config) | |
| โ | |
| 5. ConnectionDataSourceImpl.connect(ip, port) | |
| โ | |
| 6. ConnectionManager.connect(ip, port) | |
| โ | |
| 7. WebSocket/TCP/UDP connection | |
| โ | |
| 8. ConnectionManager emits status update | |
| โ | |
| 9. ConnectionRepository observes status change | |
| โ | |
| 10. ConnectToServerUseCase returns Result<Boolean> | |
| โ | |
| 11. HomeViewModel updates UI state | |
| โ | |
| 12. HomeScreen shows "Connected" status | |
| ``` | |
| ### 5.3 Example: Gesture Detection | |
| ``` | |
| 1. User performs gesture | |
| โ | |
| 2. EnhancedGestureDetector detects gesture | |
| โ | |
| 3. GestureRepositoryImpl.detectGesture(sensorData) | |
| โ | |
| 4. DetectGestureUseCase(sensorData) | |
| โ | |
| 5. HomeViewModel receives gesture event | |
| โ | |
| 6. HomeViewModel updates UI state | |
| โ | |
| 7. HomeScreen shows gesture notification | |
| โ | |
| 8. GestureDataSourceImpl.incrementGestureCount(gesture, confidence) | |
| โ | |
| 9. PreferencesManager updates statistics | |
| ``` | |
| --- | |
| ## 6. Dependency Injection | |
| ### 6.1 Hilt Modules | |
| | Module | Purpose | Key Dependencies | | |
| |--------|---------|------------------| | |
| | **AppModule** | Core dependencies | `Context`, `PreferencesManager`, `Vibrator`, `BluetoothAdapter`, `UsbManager` | | |
| | **NetworkModule** | Network dependencies | `OkHttpClient`, `ConnectionManager`, `UdpDiscovery`, `NetworkStateHelper` | | |
| | **DatabaseModule** | Room database | `AppDatabase`, all DAOs | | |
| | **SensorModule** | Sensor dependencies | `SensorManager`, `CalibrationHelper`, `EnhancedGestureDetector` | | |
| | **ServiceModule** | Service dependencies | `SensorService`, `PresentationModeService` | | |
| | **RepositoryModule** | Repository bindings | All repository implementations | | |
| | **UseCaseModule** | Use case providers | All use cases | | |
| | **FeatureModule** | Feature orchestrators | `ConnectionFeature`, `MouseControlFeature`, etc. | | |
| | **ViewModelModule** | ViewModel bindings | All ViewModels | | |
| | **CalibrationModule** | Calibration dependencies | `ICalibrationDataSource` | | |
| | **CoroutineModule** | Coroutine dispatchers | `IoDispatcher`, `MainDispatcher`, `DefaultDispatcher` | | |
| | **GestureRepositoryModule** | Gesture repository | `IGestureRepository`, `GestureRepositoryImpl` | | |
| ### 6.2 Dependency Injection Example | |
| ```kotlin | |
| // In ViewModel | |
| @HiltViewModel | |
| class HomeViewModel @Inject constructor( | |
| private val connectionFeature: ConnectionFeature, | |
| private val sensorFeature: SensorFeature, | |
| private val prefs: PreferencesManager | |
| ) : ViewModel() { ... } | |
| // In Activity | |
| @AndroidEntryPoint | |
| class MainActivity : ComponentActivity() { | |
| @Inject | |
| lateinit var prefs: PreferencesManager | |
| @Inject | |
| lateinit var sensorService: SensorService | |
| } | |
| ``` | |
| --- | |
| ## 7. UI Layer | |
| ### 7.1 Navigation | |
| The app uses **Jetpack Compose Navigation** with a sealed class for type-safe routing. | |
| ```kotlin | |
| sealed class Destinations( | |
| val route: String, | |
| val title: String, | |
| val icon: ImageVector | |
| ) { | |
| object Home : Destinations("home", "Home", Icons.Default.Home) | |
| object Settings : Destinations("settings", "Settings", Icons.Default.Settings) | |
| // ... 20+ destinations | |
| } | |
| ``` | |
| **Bottom Navigation Destinations:** | |
| - Home | |
| - Statistics | |
| - Settings | |
| - Help | |
| **Full Destinations List (23):** | |
| 1. Home | |
| 2. Statistics | |
| 3. Settings | |
| 4. Help | |
| 5. About | |
| 6. Calibration | |
| 7. Calibration Result | |
| 8. Sensor Visualizer | |
| 9. Gesture Studio | |
| 10. Edge Gestures | |
| 11. Touchpad | |
| 12. Touchpad Settings | |
| 13. Network Discovery | |
| 14. Server Logs | |
| 15. Proximity | |
| 16. Voice Commands | |
| 17. Profiles | |
| 18. Themes | |
| 19. Battery | |
| 20. Accessibility | |
| 21. Onboarding | |
| 22. File Transfer | |
| ### 7.2 Theming | |
| The app supports **20+ themes** with dynamic accent colors. | |
| ```kotlin | |
| @Composable | |
| fun AirMouseTheme( | |
| darkTheme: Boolean = isSystemInDarkTheme(), | |
| useDynamicColor: Boolean = true, | |
| themeColors: ThemeColorScheme? = null, | |
| content: @Composable () -> Unit | |
| ) { ... } | |
| ``` | |
| **Supported Themes:** | |
| | Category | Themes | | |
| |----------|--------| | |
| | **Standard** | System, Light, Dark, Pure Black, High Contrast | | |
| | **Nature** | Ocean, Sunset, Forest, Mint, Peach, Sky | | |
| | **Vibrant** | Purple Haze, Cherry, Neon, Lavender | | |
| | **Premium** | Midnight, Gold, Matrix, Cotton Candy, Coffee | | |
| ### 7.3 Screen Architecture (MVI) | |
| All screens follow the MVI pattern: | |
| ```kotlin | |
| // State | |
| data class SettingsUiState( | |
| val sensitivity: Float = 0.5f, | |
| val hapticEnabled: Boolean = true, | |
| val isLoading: Boolean = false | |
| ) | |
| // Event | |
| sealed class SettingsEvent { | |
| data class UpdateSensitivity(val value: Float) : SettingsEvent() | |
| object ToggleHaptic : SettingsEvent() | |
| } | |
| // Effect | |
| sealed class SettingsEffect { | |
| data class ShowToast(val message: String) : SettingsEffect() | |
| } | |
| // ViewModel | |
| @HiltViewModel | |
| class SettingsViewModel @Inject constructor( | |
| private val settingsRepository: ISettingsRepository | |
| ) : ViewModel() { | |
| private val _uiState = MutableStateFlow(SettingsUiState()) | |
| val uiState: StateFlow<SettingsUiState> = _uiState.asStateFlow() | |
| fun handleEvent(event: SettingsEvent) { ... } | |
| } | |
| ``` | |
| --- | |
| ## 8. Domain Layer | |
| ### 8.1 Repository Interfaces | |
| | Repository | Purpose | Key Methods | | |
| |------------|---------|-------------| | |
| | `ICalibrationRepository` | Sensor calibration | `calibrateGyroscope()`, `getCalibrationData()` | | |
| | `IConnectionRepository` | Network connection | `connect()`, `disconnect()`, `sendMove()` | | |
| | `IGestureRepository` | Gesture detection | `detectGesture()`, `addCustomGesture()` | | |
| | `IMouseRepository` | Cursor control | `move()`, `click()`, `scroll()` | | |
| | `IProfileRepository` | User profiles | `createProfile()`, `updateProfile()` | | |
| | `IProximityRepository` | Proximity detection | `startMonitoring()`, `getProximityState()` | | |
| | `ISensorRepository` | Sensor data | `observeSensorData()`, `startSensors()` | | |
| | `ISettingsRepository` | App settings | `getSensitivity()`, `setTheme()` | | |
| | `IStatisticsRepository` | Usage statistics | `recordClick()`, `getCurrentSession()` | | |
| | `IUpdateRepository` | App updates | `checkForUpdates()`, `downloadUpdate()` | | |
| | `IVoiceCommandRepository` | Voice commands | `processVoiceInput()`, `addCommand()` | | |
| ### 8.2 Use Cases | |
| | Use Case | Purpose | | |
| |----------|---------| | |
| | `CalibrationUseCase` | Sensor calibration orchestration | | |
| | `ConnectToServerUseCase` | Server connection management | | |
| | `SendMovementUseCase` | Cursor movement and clicks | | |
| | `DetectGestureUseCase` | Gesture detection | | |
| | `DiscoverServersUseCase` | UDP server discovery | | |
| | `GetConnectionStatusUseCase` | Connection status retrieval | | |
| | `GetStatisticsUseCase` | Usage statistics retrieval | | |
| | `RecordStatisticsUseCase` | Usage statistics recording | | |
| | `ManageProfileUseCase` | User profile management | | |
| | `ManageGestureTemplatesUseCase` | Gesture template management | | |
| | `HandleVoiceCommandUseCase` | Voice command processing | | |
| | `GetProximityStateUseCase` | Proximity state retrieval | | |
| | `UpdateProximityConfigUseCase` | Proximity configuration | | |
| | `TestConnectionUseCase` | Connection testing | | |
| | `CheckForUpdatesUseCase` | App update checking | | |
| | `GetGestureStatisticsUseCase` | Gesture statistics retrieval | | |
| --- | |
| ## 9. Data Layer | |
| ### 9.1 Data Sources | |
| | Data Source | Storage | Purpose | | |
| |-------------|---------|---------| | |
| | `CalibrationDataSourceImpl` | Preferences | Sensor calibration data | | |
| | `GestureDataSourceImpl` | Preferences (JSON) | Gesture templates, training, stats | | |
| | `ProfileDataSourceImpl` | Preferences (JSON) | User profiles, settings | | |
| | `StatisticsDataSourceImpl` | Preferences (JSON) | Session, daily, historical stats | | |
| | `PreferencesDataSourceImpl` | Preferences | Generic preferences | | |
| | `LocalDataSourceImpl` | Room + Preferences | Unified local data access | | |
| ### 9.2 Room Database | |
| | Entity | DAO | Purpose | | |
| |--------|-----|---------| | |
| | `CalibrationEntity` | `CalibrationDao` | Sensor calibration data | | |
| | `ProfileEntity` | `ProfileDao` | User profiles | | |
| | `GestureTemplateEntity` | `GestureDao` | Gesture templates | | |
| | `TrainingSampleEntity` | `TrainingSampleDao` | ML training data | | |
| | `StatisticsEntity` | `StatisticsDao` | Session statistics | | |
| | `DailyStatsEntity` | `DailyStatsDao` | Daily aggregated stats | | |
| | `GestureStatsEntity` | `GestureStatsDao` | Per-gesture stats | | |
| | `SettingsEntity` | `SettingsDao` | App settings | | |
| --- | |
| ## 10. Infrastructure Layer | |
| ### 10.1 Network | |
| | Component | Purpose | Protocol | | |
| |-----------|---------|----------| | |
| | `ConnectionManager` | Core network manager | WebSocket/TCP/UDP | | |
| | `UdpDiscovery` | Server discovery | UDP | | |
| | `AutoReconnectManager` | Reconnection logic | - | | |
| | `NetworkQualityMonitor` | Quality monitoring | - | | |
| **ConnectionManager Features:** | |
| - Multi-protocol (WebSocket/TCP/UDP) | |
| - Auto-reconnection with exponential backoff | |
| - Heartbeat (Ping/Pong) | |
| - Reliable message delivery (ACK-based retransmission) | |
| - Connection quality monitoring | |
| - StateFlow for reactive UI updates | |
| ### 10.2 Sensors | |
| | Component | Purpose | | |
| |-----------|---------| | |
| | `SensorService` | Central sensor manager | | |
| | `CalibrationHelper` | Sensor calibration (gyro, accel, mag) | | |
| | `EnhancedGestureDetector` | Gesture detection (click, scroll, swipe) | | |
| | `MadgwickAHRS` | Sensor fusion algorithm | | |
| | `MotionAnalyzer` | Motion analysis | | |
| | `SensorDataLogger` | CSV logging for debugging | | |
| ### 10.3 Utilities (32 files) | |
| | Category | Files | Purpose | | |
| |----------|-------|---------| | |
| | **Preferences** | `PreferencesManager`, `PreferencesKeys`, `PreferencesHelper` | Persistent storage | | |
| | **Permissions** | `PermissionHelper`, `PermissionManager` | Runtime permissions | | |
| | **Bluetooth** | `BluetoothUtils` | Bluetooth operations | | |
| | **Network** | `NetworkUtils`, `NetworkStateHelper` | Network connectivity | | |
| | **Audio** | `AudioUtils` | Sound playback | | |
| | **Haptic** | `VibrateUtils` | Haptic feedback | | |
| | **Battery** | `BatterySaver`, `BatteryOptimizer` | Power management | | |
| | **Math** | `MathUtils`, `ConversionUtils` | Mathematical operations | | |
| | **Date** | `DateUtils` | Date/time formatting | | |
| | **File** | `FileHelper`, `JsonHelper` | File operations | | |
| | **QR** | `QRScanner` | QR code scanning | | |
| | **Animation** | `AnimationUtils` | Animation helpers | | |
| | **Color** | `ColorUtils` | Color manipulation | | |
| | **Validation** | `StringUtils`, `ValidationUtils` | Input validation | | |
| | **Logging** | `LogManager`, `ErrorHandler` | Error handling | | |
| --- | |
| ## 11. Building & Running | |
| ### 11.1 Prerequisites | |
| | Tool | Version | | |
| |------|---------| | |
| | **Android Studio** | Hedgehog or newer | | |
| | **JDK** | 17 or newer | | |
| | **Gradle** | 8.4+ | | |
| | **Android SDK** | API 34 | | |
| | **Kotlin** | 1.9.24 | | |
| ### 11.2 Build Commands | |
| ```bash | |
| # Clean build | |
| ./gradlew clean | |
| # Build debug APK | |
| ./gradlew assembleDebug | |
| # Build release APK | |
| ./gradlew assembleRelease | |
| # Run all tests | |
| ./gradlew test | |
| # Run instrumentation tests | |
| ./gradlew connectedAndroidTest | |
| # Generate signed release APK | |
| ./gradlew bundleRelease | |
| ``` | |
| ### 11.3 Gradle Configuration | |
| ```groovy | |
| // Project build.gradle | |
| buildscript { | |
| ext.kotlin_version = '1.9.24' | |
| ext.hilt_version = '2.52' | |
| dependencies { | |
| classpath 'com.android.tools.build:gradle:8.5.0' | |
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |
| classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version" | |
| classpath "com.google.devtools.ksp:ksp-gradle-plugin:1.9.24-1.0.20" | |
| } | |
| } | |
| // App build.gradle | |
| android { | |
| compileSdk 34 | |
| minSdk 24 | |
| targetSdk 34 | |
| versionCode 30 | |
| versionName "3.0.0" | |
| } | |
| dependencies { | |
| implementation 'androidx.core:core-ktx:1.12.0' | |
| implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0' | |
| implementation 'androidx.activity:activity-compose:1.8.0' | |
| implementation platform('androidx.compose:compose-bom:2024.02.00') | |
| implementation 'androidx.compose.ui:ui' | |
| implementation 'androidx.compose.ui:ui-graphics' | |
| implementation 'androidx.compose.ui:ui-tooling-preview' | |
| implementation 'androidx.compose.material3:material3' | |
| implementation 'com.google.dagger:hilt-android:2.52' | |
| implementation 'androidx.room:room-runtime:2.6.0' | |
| implementation 'androidx.room:room-ktx:2.6.0' | |
| implementation 'com.squareup.okhttp3:okhttp:4.12.0' | |
| implementation 'com.journeyapps:zxing-android-embedded:4.3.0' | |
| } | |
| ``` | |
| --- | |
| ## 12. Testing | |
| ### 12.1 Test Structure | |
| ``` | |
| app/src/test/ | |
| โโโ domain/ | |
| โ โโโ model/ # Model tests | |
| โ โโโ repository/ # Repository interface tests | |
| โ โโโ usecase/ # Use case tests | |
| โโโ data/ | |
| โ โโโ datasource/ # Data source tests | |
| โ โโโ repository/ # Repository implementation tests | |
| โโโ presentation/ | |
| โโโ ui/ # UI tests | |
| โโโ viewmodel/ # ViewModel tests | |
| app/src/androidTest/ | |
| โโโ presentation/ | |
| โโโ ui/ # Instrumentation UI tests | |
| ``` | |
| ### 12.2 Key Test Classes | |
| | Test Class | Purpose | | |
| |------------|---------| | |
| | `CalibrationUseCaseTest` | Test calibration business logic | | |
| | `ConnectionManagerTest` | Test network connection | | |
| | `GestureDetectorTest` | Test gesture detection | | |
| | `SettingsViewModelTest` | Test settings ViewModel | | |
| | `HomeScreenTest` | Test home screen UI | | |
| ### 12.3 Running Tests | |
| ```bash | |
| # Run unit tests | |
| ./gradlew testDebugUnitTest | |
| # Run instrumentation tests | |
| ./gradlew connectedAndroidTest | |
| # Run a specific test class | |
| ./gradlew test --tests "com.airmouse.domain.usecase.CalibrationUseCaseTest" | |
| ``` | |
| --- | |
| ## 13. Contributing | |
| ### 13.1 Code Style | |
| - **Kotlin** with official Kotlin coding conventions | |
| - **Jetpack Compose** with Material 3 guidelines | |
| - **Clean Architecture** with clear layer separation | |
| - **MVI** pattern for all screens | |
| - **Kotlin Coroutines & Flow** for concurrency | |
| - **Dagger Hilt** for dependency injection | |
| ### 13.2 Commit Message Format | |
| ``` | |
| <type>(<scope>): <subject> | |
| <body> | |
| <footer> | |
| ``` | |
| **Types:** | |
| - `feat`: New feature | |
| - `fix`: Bug fix | |
| - `docs`: Documentation | |
| - `style`: Code style | |
| - `refactor`: Code refactoring | |
| - `test`: Tests | |
| - `chore`: Build/CI | |
| ### 13.3 Development Guidelines | |
| 1. **Domain Layer:** | |
| - Models should be pure Kotlin (no Android dependencies) | |
| - Repository interfaces should be in domain | |
| - Use cases should contain business logic | |
| 2. **Data Layer:** | |
| - Repository implementations should be in data | |
| - Data sources should abstract storage | |
| - Room entities should be in data | |
| 3. **Presentation Layer:** | |
| - Screens should follow MVI pattern | |
| - ViewModels should handle UI state | |
| - Effects should be used for side effects | |
| 4. **Testing:** | |
| - Unit tests for all use cases | |
| - Integration tests for repositories | |
| - UI tests for critical flows | |
| --- | |
| ## โ Summary | |
| | Aspect | Description | | |
| |--------|-------------| | |
| | **Project** | Air Mouse โ Wireless mouse and gesture control | | |
| | **Architecture** | Clean Architecture + MVI | | |
| | **UI** | Jetpack Compose Material 3 | | |
| | **DI** | Dagger Hilt | | |
| | **Database** | Room | | |
| | **Network** | WebSocket, TCP, UDP | | |
| | **Sensors** | Gyroscope, Accelerometer, Magnetometer | | |
| | **Features** | 20+ screens, 65 settings, 16 use cases | | |
| | **Files** | 327+ files | | |
| | **Lines of Code** | ~30,900 | | |
| | **Platform** | Android 7.0+ | | |
| | **Version** | 3.0.0 | | |
| --- | |
| **Air Mouse is a complete, production-ready application that demonstrates best practices in Android development with Clean Architecture, Jetpack Compose, and MVI pattern.** |
Xet Storage Details
- Size:
- 51.8 kB
- Xet hash:
- 6b4fc2f5ca3fad3ae13734f26923edcbd90e033f016be664c5958c1fa1150aec
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.