How amrg101/materialpreferences works
Main Components
a. Core Layer:
• Core Settings Management
• Settings Model
• Settings Converters
• Storage Interface
• Setting Types (Bool, Int, String, etc.)
b. Storage Layer:
• DataStore Implementation
• Custom Storage Interface
c. Preference Screen Layer:
• Screen Base Components
• Specialized Preference Types:
• Boolean Preferences
• Input Preferences
• Choice Preferences
• Slider Preferences
• Image Preferences
d. UI Components:
• RecyclerView-based Preference Screen
• Custom ViewHolders
• Preference Adapters
Relationships
a. Data Flow:
User Input -> Preference Screen -> Settings Model -> Storage Layer
Storage Layer -> Settings Model -> UI Components (via Flow/LiveData)
b. Dependencies:
• Core module as the foundation
• Storage modules depending on core
• Screen modules depending on core
• Individual preference type modules extending the base screen module
┌─────────────────────────────────────────────────────────┐
• UI Layer │
• ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
• Bool │ │ Input │ │ Choice │ │ Other │ │
• Prefs │ │ Prefs │ │ Prefs │ │ Prefs │ │
• ┘ └─────────┘ └─────────┘ └─────────┘ │
• ┤
• Screen Base Layer │
• ┌─────────────────────────────────────────────────┐ │
• Preference Screen Components │ │
• ┘ │
• ┤
• Core Layer │
• ┌─────────────┐ ┌──────────────┐ ┌──────────┐ │
• Settings │ │ Settings │ │ Storage │ │
• Model │◄──►│ Converter │ │Interface │ │
• ┘ └──────────────┘ └──────────┘ │
• ┤
• Storage Layer │
• ┌─────────────┐ ┌──────────────┐ │
• DataStore │ │ Custom │ │
• Storage │ │ Storage │ │
• ┘ └──────────────┘ │
• ┘
Additional Elements
• Dependency injection points
• Extension points for custom implementations
Implementation Details
• Classes like SettingsModel, Storage, and PreferenceScreen
• Kotlin delegates usage
• Coroutines and Flow integration points
• DataStore implementation specifics
Notes
• Version information
• Technologies: Kotlin, Coroutines, Flow, DataStore
• Extensibility points for custom preferences