Skip to content

Commit

Permalink
Add branding support in Android 12. Thanks Vladimir for the PR. Updat…
Browse files Browse the repository at this point in the history
…ed readme. Closes #317.  Closes #318.  Don't create a blank branding imageset.  Fixes #264.
  • Loading branch information
jonbhanson committed Mar 27, 2022
1 parent 8bad0f3 commit 05baf2c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## [2.1.2] - (2022-Mar-27)
* Add branding support in Android 12. Thanks [Vladimir](https://github.com/vlazdra) for the [PR](https://github.com/jonbhanson/flutter_native_splash/pull/316). Updated readme. Closes [#317](https://github.com/jonbhanson/flutter_native_splash/issues/317). Closes [#318](https://github.com/jonbhanson/flutter_native_splash/issues/318). Don't create a blank branding imageset. Fixes [#264](https://github.com/jonbhanson/flutter_native_splash/issues/264).
## [2.1.1] - (2022-Mar-13)
* Fix for pixelated splash image on web. Fixes [#263](https://github.com/jonbhanson/flutter_native_splash/issues/263).
## [2.1.0] - (2022-Mar-06)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ First, add `flutter_native_splash` as a dependency in your pubspec.yaml file.

```yaml
dependencies:
flutter_native_splash: ^2.1.1
flutter_native_splash: ^2.1.2
```

Don't forget to `flutter pub get`.
Expand Down Expand Up @@ -175,7 +175,7 @@ If you find this package useful, you can support it for free by giving it a thum

# Android 12 Support

Android 12 has a [new method](https://developer.android.com/about/versions/12/features/splash-screen) of adding splash screens, which consists of a window background, icon, and the icon background.
Android 12 has a [new method](https://developer.android.com/about/versions/12/features/splash-screen) of adding splash screens, which consists of a window background, icon, and the icon background. Note that a background image is not supported.

The package provides Android 12 support while maintaining the legacy splash screen for previous versions of Android.

Expand All @@ -184,7 +184,7 @@ The package provides Android 12 support while maintaining the legacy splash scre
# FAQs
## I got the error "A splash screen was provided to Flutter, but this is deprecated."

This message is not related to this package but is related to a [change](https://flutter.dev/docs/development/ui/advanced/splash-screen#migrating-from-manifest--activity-defined-custom-splash-screens) in how Flutter handles splash screens in Flutter 2.5. It is caused by having the following code in your `AndroidManifest.xml`, which was included by default in previous versions of Flutter:
This message is not related to this package but is related to a [change](https://flutter.dev/docs/development/ui/advanced/splash-screen#migrating-from-manifest--activity-defined-custom-splash-screens) in how Flutter handles splash screens in Flutter 2.5. It is caused by having the following code in your `android/app/src/main/AndroidManifest.xml`, which was included by default in previous versions of Flutter:

```xml
<meta-data
Expand Down
9 changes: 0 additions & 9 deletions lib/android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,3 @@ void replaceElement({
launchTheme.children.add(XmlElement(XmlName('item'),
[XmlAttribute(XmlName('name'), name)], [XmlText(value)]));
}

void removeElement({required XmlElement launchTheme, required String name}) {
launchTheme.children.removeWhere(
(element) => element.attributes.any(
(attribute) =>
attribute.name.toString() == 'name' && attribute.value == name,
),
);
}
6 changes: 6 additions & 0 deletions lib/cli_commands.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ void _checkConfig(Map<String, dynamic> config) {
exit(1);
}

if (config.containsKey('branding_dark') && !config.containsKey('branding')) {
print('Your `flutter_native_splash` section contains `branding_dark` but '
'does not contain a `branding`.');
exit(1);
}

if (config.containsKey('android_12') && config['android_12'] is Map) {
Map android12Config = config['android_12'];
if (android12Config.containsKey('image_dark') &&
Expand Down
18 changes: 9 additions & 9 deletions lib/ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ void _createiOSSplash({
list: iOSBrandingImages,
targetPath: _iOSAssetsBrandingImageFolder);
} else {
for (var template in iOSBrandingImages) {
final file = File(_iOSAssetsBrandingImageFolder + template.fileName);
if (file.existsSync()) file.deleteSync();
}
Directory(_iOSAssetsBrandingImageFolder).delete(recursive: true);
}
if (brandingDarkImagePath != null) {
_applyImageiOS(
Expand All @@ -108,11 +105,14 @@ void _createiOSSplash({
launchImageFile.writeAsStringSync(
darkImagePath != null ? _iOSContentsJsonDark : _iOSContentsJson);

var brandingImageFile = File(_iOSAssetsBrandingImageFolder + 'Contents.json');
brandingImageFile.createSync(recursive: true);
brandingImageFile.writeAsStringSync(brandingDarkImagePath != null
? _iOSBrandingContentsJsonDark
: _iOSBrandingContentsJson);
if (brandingImagePath != null) {
var brandingImageFile =
File(_iOSAssetsBrandingImageFolder + 'Contents.json');
brandingImageFile.createSync(recursive: true);
brandingImageFile.writeAsStringSync(brandingDarkImagePath != null
? _iOSBrandingContentsJsonDark
: _iOSBrandingContentsJson);
}

_applyLaunchScreenStoryboard(
imagePath: imagePath,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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.1.1
version: 2.1.2
homepage: https://github.com/jonbhanson/flutter_native_splash

environment:
Expand Down

0 comments on commit 05baf2c

Please sign in to comment.