Initial public release.
This commit is contained in:
parent
ed31acd60f
commit
58d87b11b7
249 changed files with 15831 additions and 4 deletions
104
subapp-sample/README.md
Normal file
104
subapp-sample/README.md
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
# 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<Unit> {
|
||||
override fun create(context: Context) {
|
||||
SubAppRegistry.register(MySubApp())
|
||||
}
|
||||
|
||||
override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
|
||||
}
|
||||
```
|
||||
|
||||
### AndroidManifest.xml
|
||||
|
||||
Declare the activity and initializer:
|
||||
|
||||
```xml
|
||||
<activity android:name=".MyActivity" android:exported="false" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.startup.InitializationProvider"
|
||||
android:authorities="${applicationId}.androidx-startup">
|
||||
<meta-data
|
||||
android:name=".MyInitializer"
|
||||
android:value="androidx.startup" />
|
||||
</provider>
|
||||
```
|
||||
|
||||
## 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue