Skip to content

Commit 5b3c07e

Browse files
committed
Add Kiro steering rules for project context, Kotlin style, and Android XML guidelines
1 parent 45783e9 commit 5b3c07e

File tree

3 files changed

+237
-0
lines changed

3 files changed

+237
-0
lines changed

.kiro/steering/android-xml.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
inclusion: fileMatch
3+
fileMatchPattern: "*.xml"
4+
---
5+
6+
# Android XML Guidelines
7+
8+
## Layout Rules
9+
- Use ConstraintLayout atau LinearLayout untuk simple layouts
10+
- Use MaterialCardView untuk card-based items
11+
- Prefer `match_parent` dan `wrap_content` over fixed dimensions
12+
- Use `@dimen/` resources untuk spacing consistency
13+
14+
## Naming Conventions
15+
- Layout files: `activity_xxx.xml`, `fragment_xxx.xml`, `item_xxx.xml`, `bottom_sheet_xxx.xml`
16+
- IDs: camelCase dengan prefix (e.g., `tvAppName`, `btnSubmit`, `ivIcon`, `rvList`)
17+
- Prefixes: `tv` (TextView), `btn` (Button), `iv` (ImageView), `rv` (RecyclerView), `et` (EditText)
18+
19+
## Material 3 Components
20+
- Use `com.google.android.material.card.MaterialCardView`
21+
- Use `com.google.android.material.button.MaterialButton`
22+
- Use `com.google.android.material.chip.Chip`
23+
- Use `style="@style/Widget.Material3.Button.TonalButton"` for tonal buttons
24+
25+
## Accessibility
26+
- ALWAYS add `android:contentDescription` untuk ImageView/ImageButton
27+
- Use `android:importantForAccessibility` when needed
28+
- Provide meaningful descriptions, bukan "image" atau "button"
29+
30+
## Colors
31+
- Use `?attr/colorPrimary`, `?attr/colorSurface`, etc. untuk theme colors
32+
- Use `@color/` resources untuk custom colors
33+
- Support dark mode dengan proper color resources
34+
35+
## Strings
36+
- NEVER hardcode strings, use `@string/` resources
37+
- Use format strings untuk dynamic content: `@string/app_count``%d apps`
38+
39+
## Example Card Item
40+
```xml
41+
<com.google.android.material.card.MaterialCardView
42+
android:layout_width="match_parent"
43+
android:layout_height="wrap_content"
44+
android:layout_marginHorizontal="12dp"
45+
android:layout_marginVertical="4dp"
46+
app:cardElevation="0dp"
47+
app:cardCornerRadius="12dp"
48+
app:strokeWidth="1dp"
49+
app:strokeColor="@color/outline">
50+
51+
<!-- Content here -->
52+
53+
</com.google.android.material.card.MaterialCardView>
54+
```

.kiro/steering/kotlin-style.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
inclusion: fileMatch
3+
fileMatchPattern: "*.kt"
4+
---
5+
6+
# Kotlin Code Style Guide
7+
8+
## General Rules
9+
- Use 4 spaces for indentation
10+
- Max line length: 120 characters
11+
- Use trailing commas in multi-line declarations
12+
- Prefer expression bodies for simple functions
13+
14+
## Naming Conventions
15+
- Classes: PascalCase (e.g., `AppListViewModel`)
16+
- Functions: camelCase (e.g., `loadUserApps`)
17+
- Properties: camelCase (e.g., `isLoading`)
18+
- Constants: SCREAMING_SNAKE_CASE (e.g., `MAX_RETRY_COUNT`)
19+
- Private properties: prefix with underscore for backing fields (e.g., `_uiState`)
20+
21+
## Null Safety
22+
- Avoid `!!` operator, use safe calls `?.` or `?:`
23+
- Use `requireNotNull()` or `checkNotNull()` when null is unexpected
24+
- Prefer `val` over `var`
25+
26+
## Coroutines
27+
- Use `viewModelScope` in ViewModels
28+
- Use `lifecycleScope` in Fragments/Activities
29+
- Use `withContext(Dispatchers.IO)` for IO operations
30+
- Handle exceptions with try-catch or Result<T>
31+
32+
## Flow
33+
- Expose StateFlow for UI state
34+
- Use `asStateFlow()` for immutable exposure
35+
- Collect in `lifecycleScope.launch { }`
36+
37+
## Hilt
38+
- Annotate ViewModels with `@HiltViewModel`
39+
- Annotate Activities/Fragments with `@AndroidEntryPoint`
40+
- Use `@Inject constructor` for dependencies
41+
42+
## Error Handling
43+
```kotlin
44+
// Good
45+
fun doSomething(): Result<Unit> {
46+
return try {
47+
// operation
48+
Result.success(Unit)
49+
} catch (e: Exception) {
50+
Timber.e(e, "Operation failed")
51+
Result.failure(e)
52+
}
53+
}
54+
55+
// Bad
56+
fun doSomething() {
57+
try {
58+
// operation
59+
} catch (e: Exception) {
60+
e.printStackTrace() // Don't use this
61+
}
62+
}
63+
```
64+
65+
## ViewBinding Pattern
66+
```kotlin
67+
private var _binding: FragmentXxxBinding? = null
68+
private val binding get() = _binding
69+
70+
override fun onCreateView(...): View {
71+
_binding = FragmentXxxBinding.inflate(inflater, container, false)
72+
return _binding!!.root
73+
}
74+
75+
override fun onDestroyView() {
76+
super.onDestroyView()
77+
_binding = null
78+
}
79+
```
80+
81+
## Safe Binding Access
82+
```kotlin
83+
// Good - safe access
84+
val b = binding ?: return
85+
b.textView.text = "Hello"
86+
87+
// Bad - force unwrap
88+
binding!!.textView.text = "Hello"
89+
```

.kiro/steering/project-context.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# AppControlX Project Context
2+
3+
## Project Overview
4+
AppControlX adalah Android app untuk mengontrol aplikasi menggunakan Root atau Shizuku. App ini bisa freeze/unfreeze apps, manage battery optimization, dan batch operations.
5+
6+
## Tech Stack
7+
- **Language**: Kotlin 1.9
8+
- **Min SDK**: 29 (Android 10)
9+
- **Target SDK**: 34 (Android 14)
10+
- **Architecture**: MVVM + Repository Pattern
11+
- **DI**: Hilt 2.50
12+
- **Database**: Room 2.6
13+
- **Preferences**: DataStore
14+
- **Async**: Coroutines + Flow
15+
- **Root**: libsu by topjohnwu
16+
- **Shizuku**: Shizuku-API by RikkaApps
17+
- **Logging**: Timber
18+
- **Crash Reporting**: Firebase Crashlytics
19+
- **CI/CD**: GitHub Actions
20+
21+
## Project Structure
22+
```
23+
app/src/main/java/com/appcontrolx/
24+
├── data/
25+
│ ├── local/ # Room Database, DataStore
26+
│ └── repository/ # Data repositories
27+
├── di/ # Hilt modules (AppModule, DatabaseModule)
28+
├── executor/ # Command execution (RootExecutor, ShizukuExecutor)
29+
├── model/ # Data classes (AppInfo, ExecutionMode)
30+
├── presentation/
31+
│ └── viewmodel/ # ViewModels
32+
├── rollback/ # State management & rollback
33+
├── service/ # Business logic (AppFetcher, BatteryPolicyManager, PermissionBridge)
34+
├── ui/ # Activities, Fragments, Adapters
35+
├── utils/ # Helpers (Constants, SafetyValidator)
36+
└── worker/ # WorkManager workers
37+
```
38+
39+
## Key Files
40+
- `App.kt` - Application class dengan Hilt, Timber, Crashlytics init
41+
- `PermissionBridge.kt` - Deteksi execution mode (Root/Shizuku/None)
42+
- `RootExecutor.kt` - Execute shell commands dengan security validation
43+
- `BatteryPolicyManager.kt` - Manage app freeze, background restriction
44+
- `SafetyValidator.kt` - Protect critical system apps
45+
- `AppRepository.kt` - Central data access layer
46+
- `AppListViewModel.kt` - UI state management
47+
48+
## Coding Standards
49+
1. Gunakan Kotlin idioms (scope functions, null safety, etc.)
50+
2. Follow MVVM pattern - logic di ViewModel, UI di Fragment
51+
3. Inject dependencies via Hilt, jangan manual instantiation
52+
4. Gunakan Flow untuk reactive data
53+
5. Log dengan Timber, bukan Log.d
54+
6. Handle errors dengan Result<T>
55+
7. Validate package names sebelum execute commands
56+
8. Protect critical system apps (SafetyValidator)
57+
58+
## Security Rules
59+
- NEVER execute arbitrary shell commands
60+
- ALWAYS validate package names dengan regex
61+
- ALWAYS check SafetyValidator sebelum actions
62+
- Block dangerous commands (rm -rf, reboot, format, etc.)
63+
- Use command whitelist di RootExecutor
64+
65+
## UI Guidelines
66+
- Material 3 design
67+
- ViewBinding untuk views
68+
- Card-based layouts
69+
- Status badges untuk app states
70+
- Haptic feedback untuk selections
71+
- Accessibility support (content descriptions)
72+
73+
## Testing
74+
- Unit tests di `app/src/test/`
75+
- Use Mockito untuk mocking
76+
- Use Turbine untuk Flow testing
77+
- Target 50%+ code coverage
78+
79+
## Build Commands
80+
```bash
81+
./gradlew assembleDebug # Debug build
82+
./gradlew assembleRelease # Release build (minified)
83+
./gradlew test # Run unit tests
84+
./gradlew lint # Run lint checks
85+
```
86+
87+
## Common Issues
88+
1. Root access gagal → Check Shell.getShell() dipanggil dulu
89+
2. Type mismatch Result<String> vs Result<Unit> → Use .map { }
90+
3. NPE di Fragment → Use safe binding access pattern
91+
4. Mode tidak persist → Check Constants.PREFS_EXECUTION_MODE
92+
93+
## GitHub Repository
94+
https://github.com/risunCode/AppControl-X

0 commit comments

Comments
 (0)