77
88## Core Architecture Patterns
99
10- - ** MVVM** : ViewModels with LiveData/ StateFlow for UI state management
10+ - ** MVVM** : ViewModels with StateFlow for UI state management
1111- ** Dependency Injection** : Hilt/Dagger for dependency management
1212- ** Coroutines** : Extensive use of Kotlin coroutines for async operations
1313- ** Repository Pattern** : Data layer abstraction with sealed State classes
14- - ** Single Activity** : Navigation Component with multiple fragments
14+ - ** Single Activity** : Navigation3 with Compose screens
1515
1616## Base UI Classes (` app/src/main/java/eu/darken/myperm/common/uix/ ` )
1717
18- - ` ViewModel3 ` : Full MVVM support with nav events + error events (most feature VMs extend this)
18+ - ` ViewModel4 ` : Primary base class — implements ` NavigationEventSource ` + ` ErrorEventSource2 ` via ` SingleEventFlow ` (all
19+ feature VMs extend this)
20+ - ` ViewModel3 ` : Legacy MVVM base with ` SingleLiveEvent ` (still exists, not used by new code)
1921- ` ViewModel2 ` : Coroutine scope with error handlers
2022- ` ViewModel1 ` : Basic logging
21- - ` Fragment3 ` : MVVM integration, observes navEvents/errorEvents from ViewModel
22- - ` Fragment2 ` : Lifecycle logging
2323- ` Activity2 ` : Base activity with logging
24+ - ` Service2 ` : Base service with logging
2425
2526## Repository Pattern
2627
@@ -38,16 +39,17 @@ sealed class State {
3839
3940## Navigation System
4041
41- - Single Activity (` MainActivity ` ) with ` NavHostFragment `
42- - AndroidX Navigation with Safe Args (KSP-generated )
43- - Navigation graphs: ` res/navigation/main_navigation.xml ` , ` res/navigation/bottom_navigation.xml `
44- - ` NavEventSource ` interface: ViewModels expose ` navEvents: SingleLiveEvent<NavDirections> `
45- - ` ErrorEventSource ` interface: ViewModels expose ` errorEvents: SingleLiveEvent <Throwable> `
42+ - Single Activity (` MainActivity ` ) with Navigation3 (Compose-based, no fragments)
43+ - Custom ` NavigationController ` + ` NavigationEntry ` (not AndroidX Navigation fragments )
44+ - ` NavigationEventSource ` interface: ViewModels expose ` navEvents: SingleEventFlow<NavEvent> `
45+ - ` NavEvent ` sealed class: ` GoTo(destination, popUpTo, inclusive) ` and ` Up `
46+ - ` ErrorEventSource2 ` interface: ViewModels expose ` errorEvents: SingleEventFlow <Throwable> `
4647
4748## Settings System
4849
49- - ` GeneralSettings ` singleton uses SharedPreferences with Moshi JSON serialization
50- - Flow-based preference reading via ` createFlowPreference() `
50+ - ` GeneralSettings ` singleton uses DataStore Preferences with Kotlinx Serialization
51+ - Flow-based preference reading via ` createValue() ` with ` kotlinxReader ` /` kotlinxWriter ` helpers
52+ - SharedPreferences retained only for migration via ` SharedPreferencesMigration `
5153- Located in ` settings/core/GeneralSettings.kt `
5254
5355## Data Flow
@@ -57,36 +59,45 @@ The app follows unidirectional data flow:
57591 . ` AppRepo ` queries PackageManager for installed apps
58602 . ` PermissionRepo ` aggregates permission data from apps
59613 . ViewModels combine repository flows with filter/sort options
60- 4 . UI observes ViewModel state via LiveData
62+ 4 . Compose UI collects ViewModel state via StateFlow
61635 . User actions trigger ViewModel methods which update repository or navigate
6264
6365## Project Structure
6466
67+ Representative structure (not exhaustive):
68+
6569```
6670app/src/main/java/eu/darken/myperm/
6771├── main/ # MainActivity, main navigation hub
6872├── permissions/ # Permissions feature
6973│ ├── core/ # PermissionRepo, data models
70- │ └── ui/ # List and details fragments
74+ │ └── ui/ # List and details Compose screens
7175├── apps/ # Apps feature
7276│ ├── core/ # AppRepo, PackageManager interactions
73- │ └── ui/ # List and details fragments
77+ │ └── ui/ # List and details Compose screens
78+ ├── watcher/ # Permission change monitoring
79+ │ ├── core/ # WatcherManager, SnapshotDiffer, PermissionDiff
80+ │ └── ui/ # Dashboard and report detail screens
7481├── settings/ # Settings feature
7582│ ├── core/ # GeneralSettings
76- │ └── ui/ # Settings fragments
83+ │ └── ui/ # Settings Compose screens
7784└── common/ # Shared utilities
78- ├── uix/ # Base UI classes
85+ ├── uix/ # Base UI classes (ViewModel4, Activity2, Service2)
86+ ├── compose/ # Shared Compose components
7987 ├── coroutine/ # DispatcherProvider, AppScope
8088 ├── dagger/ # Hilt DI modules
81- ├── navigation/ # Nav extensions
82- ├── lists/ # ModularAdapter pattern for RecyclerView
83- └── preferences/# FlowPreference utilities
89+ ├── datastore/ # DataStore helpers (createValue, kotlinxReader/Writer)
90+ ├── navigation/ # Navigation3 extensions, NavigationEventSource
91+ ├── room/ # Room database, DAOs, entities
92+ └── serialization/ # Kotlinx Serialization utilities
8493```
8594
8695## Key Dependencies
8796
97+ - ** Jetpack Compose** : UI framework (Material 3)
8898- ** Hilt** : Dependency injection framework
89- - ** AndroidX Navigation** : Fragment navigation with SafeArgs
90- - ** Moshi** : JSON serialization for settings and data
99+ - ** Navigation3** : Compose-based navigation
100+ - ** Kotlinx Serialization** : JSON serialization for settings and data
101+ - ** DataStore** : Preferences storage
102+ - ** Room** : Database for watcher snapshots
91103- ** Coil** : Image loading for app icons
92- - ** Material Design** : UI components
0 commit comments