Skip to content

Commit

Permalink
Remove branding on Android 12 if branding is not specified. Fixes #399.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbhanson committed Aug 1, 2022
1 parent f4f99cc commit 7aa5aaa
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## [2.2.7] - (2022-July-31)

- Remove branding on Android 12 if branding is not specified. Fixes [#399](https://github.com/jonbhanson/flutter_native_splash/issues/399).

## [2.2.6] - (2022-July-24)

- Fix parseColor test. Thanks [mihiro](https://github.com/mihiron) for [PR #393](https://github.com/jonbhanson/flutter_native_splash/pull/393).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -19,7 +19,7 @@ First, add `flutter_native_splash` as a dependency in your pubspec.yaml file.

```yaml
dependencies:
flutter_native_splash: ^2.2.6
flutter_native_splash: ^2.2.7
```

Don't forget to `flutter pub get`.
Expand Down
35 changes: 25 additions & 10 deletions lib/android.dart
Expand Up @@ -173,7 +173,10 @@ void _createAndroidSplash({
android12BrandingImagePath: brandingImagePath,
);

if (darkColor != null || darkBackgroundImage != null) {
if (android12DarkBackgroundColor != null ||
android12DarkImagePath != null ||
darkAndroid12IconBackgroundColor != null ||
brandingDarkImagePath != null) {
_applyStylesXml(
fullScreen: fullscreen,
file: _flavorHelper.androidV31StylesNightFile,
Expand Down Expand Up @@ -388,39 +391,51 @@ Future<void> _updateStylesFile({
);

// In Android 12, the color must be set directly in the styles.xml
if (android12BackgroundColor != null) {
if (android12BackgroundColor == null) {
removeElement(
launchTheme: launchTheme,
name: 'android:windowSplashScreenBackground',
);
} else {
replaceElement(
launchTheme: launchTheme,
name: 'android:windowSplashScreenBackground',
value: '#$android12BackgroundColor',
);
}

if (android12BrandingImagePath != null) {
replaceElement(
if (android12BrandingImagePath == null) {
removeElement(
launchTheme: launchTheme,
name: 'android:windowSplashScreenBrandingImage',
value: '@drawable/branding',
);
}

if (android12BrandingImagePath != null) {
} else {
replaceElement(
launchTheme: launchTheme,
name: 'android:windowSplashScreenBrandingImage',
value: '@drawable/branding',
);
}

if (android12ImagePath != null) {
if (android12ImagePath == null) {
removeElement(
launchTheme: launchTheme,
name: 'android:windowSplashScreenAnimatedIcon',
);
} else {
replaceElement(
launchTheme: launchTheme,
name: 'android:windowSplashScreenAnimatedIcon',
value: '@drawable/android12splash',
);
}

if (android12IconBackgroundColor != null) {
if (android12IconBackgroundColor == null) {
removeElement(
launchTheme: launchTheme,
name: 'android:windowSplashScreenIconBackgroundColor',
);
} else {
replaceElement(
launchTheme: launchTheme,
name: 'android:windowSplashScreenIconBackgroundColor',
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,7 +1,7 @@
name: flutter_native_splash
description: Customize Flutter's default white native splash screen with
background color and splash image. Supports dark mode, full screen, and more.
version: 2.2.6
version: 2.2.7
homepage: https://github.com/jonbhanson/flutter_native_splash

environment:
Expand Down

0 comments on commit 7aa5aaa

Please sign in to comment.