Skip to content

Conversation

@poliver
Copy link
Contributor

@poliver poliver commented Jun 15, 2025

Visually, there shouldn't be much difference, but this does allow for the clean up a number of .png assets and (now) redundant styles. These changes leverage Android's splash screen compatibility library, which backports Android 12's splash screen features to API 23+.

The splash screen's theme now extends the framework Theme.SplashScreen and is applied to the main Activity in essentially the same way it was before. It utilizes a single vector drawable for the logo across all API levels (derived from here, so please let me know if there's a better one I should use). I referenced these docs for new asset's dimensions. I just noticed while taking screenshots for this PR that the existing app crops the horse's ear on API 31+.

For reference, the Flutter samples apply a splash screen in a similar manner to this PR.

API 30 (30 and lower now using compat lib)

Dark before Dark after Light before Light after
dark_30_before dark_30_after light_30_before light_30_after

API 36 (31+ mostly unchanged)

Dark before Dark after Light before Light after
dark_36_before dark_36_after light_36_before light_36_after

@veloce
Copy link
Contributor

veloce commented Jun 15, 2025

Great stuff! Thanks for this.

(derived from here, so please let me know if there's a better one I should use).

You can find logo svg sources here: https://github.com/lichess-org/lila/tree/master/public/logo. (Note the logo looks good in your screenshots).

Copy link
Contributor

@veloce veloce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging from the screenshots this is better than before, so these changes look good to me.

However you might want to have a look at: https://pub.dev/packages/flutter_native_splash

We're using this package in the application, see:

This is needed to continue to show the splash screen while flutter is loading, so the splash screens defined here should be the same as the ones defined on android side.

# Conflicts:
#	android/app/src/main/res/values/colors.xml
@poliver
Copy link
Contributor Author

poliver commented Jun 15, 2025

Oh I see, what I removed is all codegen. Sorry, I'm new to Flutter. From what I can tell, flutter_native_splash simply generates the equivalent of my PR (I'm sure you already know this 😅). However, it does not leverage Android's splash screen compat library for API 26+ support of the Android 12 style, nor does it support svg. It's also apparently where that ?android:colorBackground is coming from.

I you'd like to replace what flutter_native_splash generates with this PR, it looks like I can add android: false to the package configuration to prevent it overwriting these changes. I don't imagine the splash screen will be changed very often, but I can understand if you'd like to keep the simplicity afforded by the codegen. I will say that flutter_native_splash's implementation of a splash screen on Android is quite strange, even despite its outdated method for doing so.

@veloce
Copy link
Contributor

veloce commented Jun 15, 2025

I you'd like to replace what flutter_native_splash generates with this PR, it looks like I can add android: false to the package configuration to prevent it overwriting these changes. I don't imagine the splash screen will be changed very often, but I can understand if you'd like to keep the simplicity afforded by the codegen. I will say that flutter_native_splash's implementation of a splash screen on Android is quite strange, even despite its outdated method for doing so.

Actually I don't remember how this package works, as it was a long time ago. From what I remember the reason I used this is to avoid an empty screen during the loading time of Flutter engine.
I don't care about code gen, and I'd rather use the android splash screen and the improvements you did.

As long as the trick of delaying the removal of splash screen, as done here:

FlutterNativeSplash.remove();
works I'm fine.

If I understand you correctly, we can use android: false, so we can use the native android config while retaining the control to hide the splash screen. So we should definitely go for it.

@poliver
Copy link
Contributor Author

poliver commented Jun 15, 2025

Looking at the implementation for FlutterNativeSplash.remove(), it only appears to do anything on web? Again, I'm not entirely sure about the inner workings of Flutter, but on the devices I've tested, the transition from splash to Flutter content looks to be unchanged with this PR.

If I understand you correctly, we can use android: false, so we can use the native android config while retaining the control to hide the splash screen. So we should definitely go for it.

Running flutter_native_splash does provide a native Android config, as seen below (as run against this branch), so there should be no change there as far as Flutter is concerned. It's just outdated, unfortunately. I will give android: false a shot and report back.
image

@poliver
Copy link
Contributor Author

poliver commented Jun 15, 2025

Applied official logo in df717db

@poliver
Copy link
Contributor Author

poliver commented Jun 15, 2025

Configured flutter_native_splash to only run for iOS in f38d60a

Comment on lines -32 to -38
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"/>
Copy link
Contributor Author

@poliver poliver Jun 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to no longer be necessary with Flutter 2.5 based on a note here. This meta data is not applied in the corresponding sample app.

<style name="SplashTheme" parent="SplashTheme.NightAdjusted">
<item name="windowSplashScreenBackground">@color/bg_splash</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_splash</item>
<item name="postSplashScreenTheme">@style/NormalTheme</item>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what tells Android to switch themes once the app is loaded.

@veloce veloce merged commit ffa95ea into lichess-org:main Jun 16, 2025
@veloce
Copy link
Contributor

veloce commented Jun 16, 2025

Tested on 3 different devices with Android 9, 10, 11, and an emulator with Android 15.

Thanks again!

@poliver poliver deleted the android_splash branch June 16, 2025 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants