Fixes #633 On Android 12 and above, the splash screen was ignoring the user’s saved theme preference and instead defaulting to the system theme. This happened because the splash screen is rendered before Application.onCreate() finishes executing. At that point, the system’s UiModeManager hadn't been updated with the user's preferred theme, so it showed the wrong one. Changes: - Introduced initializeNightModeFromPreferences() in UiExtensions.kt. This method forces the correct theme mode synchronously during Application.onCreate(), ensuring it’s in place before the splash screen ever appears. - Added observeNightModePreferences() to actively listen for changes to the theme setting. This keeps UiModeManager updated in real time so future cold starts use the right theme immediately. - On Android 12+ (API 31+), now using UiModeManager.setApplicationNightMode() to set the theme properly. - For older versions, the implementation falls back to AppCompatDelegate.setDefaultNightMode() for compatibility. - Added a toDarkThemeConfig() extension function to translate the DataStore proto into the theme model used by the UI. - Included the AppCompat dependency in the app module to support these changes. Why the Observer Matters? Without it, any theme change made by the user wouldn't notify UiModeManager right away. That would mean the next time the app is launched cold, the splash screen would still use whatever theme was cached before—not the one the user just selected. This fix prevents that. Testing: - Confirmed that the splash screen reflects the saved theme preference, even on a fresh app start. - Checked all theme configurations: Light, Dark, and Follow System. - Verified behavior on both Android 12+ and Android 11 devices to ensure backward compatibility.pull/2012/head
parent
55970c2487
commit
d46db3b9bf
Loading…
Reference in new issue