Repository navigation
Conversation
…tting On Android 12+ the splash follows the phone's dark mode. With `app_theme_styles: true` in the android_12 section, the generator adds NativeSplashLight and NativeSplashDark to the non-night v31 styles file. An app can pass them to SplashScreen.setSplashScreenTheme so the splash follows its own theme setting. A drawable with a night variant still follows the phone's theme inside a fixed style, so when image_dark or branding_dark differs from the light one, the styles use copies written only to non-night folders. Turning the option off, or running remove, deletes the styles and the copies. LaunchTheme's Android 12 items now go through the same helper; generated output for existing configs is unchanged. Refs jonbhanson#542
Adds a README section with the method channel an app adds to MainActivity to call SplashScreen.setSplashScreenTheme, notes that UiModeManager.setApplicationNightMode is not enough on Samsung's launcher, and updates the FAQ on basing light/dark on app settings. Closes jonbhanson#542
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #542
My app lets people pick Light or Dark, and on Android 12+ the splash always followed the phone instead. So with the phone in dark mode and the app on Light you'd get a dark splash. Android has
SplashScreen.setSplashScreenThemefor this, but there was no theme to pass it, sinceLaunchThemehas a light and a night version.This adds an opt-in
app_theme_styles: trueunderandroid_12. It generatesNativeSplashLightandNativeSplashDarkinvalues-v31/styles.xmlonly, so they don't change with the phone's theme. Ifimage_darkis different fromimage, it also writes copies of the images with no night version, because a drawable that has one still gets picked by the phone's theme, even from a fixed style. Same forbranding_dark. Turning it off or runningremovecleans everything up. Without the option nothing changes: I diffed the generated res folder on master and on this branch with everyandroid_12key set, and it's identical.The package dropped its native code in #828, so I didn't add a plugin back. The README has a short Kotlin method channel for
MainActivityand the Dart call instead. Happy to turn it into a Dart API if you'd rather have that.Worth knowing:
UiModeManager.setApplicationNightModeisn't enough on its own. On my Galaxy S20 FE (Android 13) the splash still followed the phone when I opened the app from its icon.setSplashScreenThemeworks either way. Android saves the style by name, soNativeSplashLightandNativeSplashDarkshouldn't be renamed later.I added tests in
test/android_test.dartand checked it on the S20 FE in dark mode with a test app using the README code, red icon for light and green for dark. Left to right: nothing picked, Light, System, and Light pointed at the night drawable instead of the copy (wrong icon, which is why the copies are there).flutter analyzeshows 12XmlNamedeprecation infos with xml 7.1.0, but those are on master too.