The App Category module is a core pillar of the application’s organization logic. It identifies every installed app on the user’s device and assigns it a category (e.g., “Social”, “Games”, “Productivity”).To the user, this manifests as a clean, grouped list of apps where they can search, view categorization status, and manually override classifications if the automated system misses the mark.
Scroll-Aware Search: The search bar collapses/expands based on events to maximize screen real estate.
Expandable Grouping: Apps are grouped into “Cards” by category. These cards use AnimatedVisibility for smooth expansion and show a “cluster” of app icons when collapsed.
Manual Override: A CategorizeAppBottomSheet allows users to manually pick a category from a predefined list if the automated sync fails.
When the module starts, it doesn’t just wait for the user. It employs a multi-stage sync strategy:
Metadata Scan: The AppMetadataRepository scans the device for installed apps and caches their icons to internal storage.
Observer Pattern: A background observer watches for new app installations. When a new app is detected, it triggers an immediate “Targeted Sync”.
Background Workers: The module uses to perform batch API requests (up to 100 apps at a time) to fetch categories without draining the battery or blocking the UI.
Icon Caching: Icons are extracted once and saved as .png files in the app’s internal directory. This prevents the PackageManager from being a bottleneck during list scrolling.
Computation Offloading: All grouping and filtering logic is shifted to Dispatchers.Default using the flowOn operator to keep the Main Thread free for UI rendering.