# KTag Sample Subapp A minimal Jetpack Compose subapp template for creating new KTag applications. ## Overview The Sample subapp provides a starting point for creating new subapps in the KTag ecosystem. It demonstrates the minimal required structure and can be copied as a template for new functionality. ## Architecture The simplest possible subapp structure: ``` ┌─────────────────────────────────────────────────────────┐ │ SampleActivity │ │ (Compose Host) │ │ • Single "Hello World" screen │ └─────────────────────────────────────────────────────────┘ ``` ## File Structure ``` src/main/java/club/clubk/ktag/apps/sample/ ├── SampleActivity.kt # Main activity with Compose UI ├── SampleSubApp.kt # Subapp registration └── SampleInitializer.kt # Startup initializer ``` ## Creating a New Subapp To create a new subapp based on this template: 1. **Copy the module**: Duplicate `subapp-sample` directory 2. **Rename the package**: Update package name in all files 3. **Update build.gradle.kts**: Change namespace 4. **Register the subapp**: Update `SampleSubApp` with new ID, name, icon 5. **Add to settings.gradle.kts**: Include new module 6. **Add dependency**: Include in main app's dependencies ## Required Components ### SubApp Interface Every subapp must implement the `SubApp` interface: ```kotlin class MySubApp : SubApp { override val id = "myapp" // Unique identifier override val name = "My App" // Display name override val icon = R.drawable.ic_myapp // Launcher icon override fun createIntent(context: Context): Intent { return Intent(context, MyActivity::class.java) } } ``` ### Initializer Register the subapp at startup: ```kotlin class MyInitializer : Initializer { override fun create(context: Context) { SubAppRegistry.register(MySubApp()) } override fun dependencies(): List>> = emptyList() } ``` ### AndroidManifest.xml Declare the activity and initializer: ```xml ``` ## Optional Features For more complex subapps, consider adding: | Feature | Reference | |---------|-----------| | Settings | See `subapp-koth` or `subapp-medic` | | MQTT | Implement `SettingsSubApp` interface | | BLE | See `subapp-bletool` or `subapp-koth` | | USB Serial | See `subapp-terminal` | | ViewModel | See `subapp-koth` or `subapp-medic` | ## Dependencies - Jetpack Compose (Material3) - AndroidX Startup (for initialization)