From b957d0860fa6b682c0a3e933311a87a833160374 Mon Sep 17 00:00:00 2001 From: Jon Hanson Date: Sun, 19 Feb 2023 12:44:40 -0500 Subject: [PATCH] Remove `v31/styles.xml` files if not in use. Fixes #514. Remove web changes on `remove` command. Fixes #516. --- CHANGELOG.md | 4 ++++ README.md | 4 ++-- example/pubspec.lock | 8 ++++---- lib/android.dart | 6 ++++++ lib/web.dart | 30 ++++++++++++++++++++++++++++++ pubspec.yaml | 8 ++++---- 6 files changed, 50 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b93da83..59b8219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.2.18] - (2023-Feb-19) +- Remove `v31/styles.xml` files if not in use. Fixes [#514](https://github.com/jonbhanson/flutter_native_splash/issues/514). +- Remove web changes on `remove` command. Fixes [#516](https://github.com/jonbhanson/flutter_native_splash/issues/516). + ## [2.2.17] - (2023-Jan-15) - Updated image dependency to v4.0.10. Fixes [#497](https://github.com/jonbhanson/flutter_native_splash/issues/497). - Changed image processing from linear to cubic to improve image quality. Fixes [#472](https://github.com/jonbhanson/flutter_native_splash/issues/472). diff --git a/README.md b/README.md index f18ec64..0e0aa60 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ First, add `flutter_native_splash` as a dependency in your pubspec.yaml file. ```yaml dependencies: - flutter_native_splash: ^2.2.17 + flutter_native_splash: ^2.2.18 ``` Don't forget to `flutter pub get`. @@ -230,7 +230,7 @@ Be aware of the following considerations regarding these elements: 4. `color` the window background consists of a single opaque color. -~~**_PLEASE NOTE:_** The splash screen may not appear when you launch the app from Android Studio. However, it should appear when you launch by clicking on the launch icon in Android.~~ This seems to be resolved now. +**_PLEASE NOTE:_** The splash screen may not appear when you launch the app from Android Studio on API 31. However, it should appear when you launch by clicking on the launch icon in Android. This seems to be resolved in API 32+. **_PLEASE NOTE:_** There are a number of reports that non-Google launchers do not display the launch image correctly. If the launch image does not display correctly, please try the Google launcher to confirm that this package is working. diff --git a/example/pubspec.lock b/example/pubspec.lock index af4ee6f..23c8050 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -14,7 +14,7 @@ packages: name: args url: "https://pub.dartlang.org" source: hosted - version: "2.3.1" + version: "2.4.0" async: dependency: transitive description: @@ -96,7 +96,7 @@ packages: path: ".." relative: true source: path - version: "2.2.17" + version: "2.2.18" flutter_test: dependency: "direct dev" description: flutter @@ -120,7 +120,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "4.0.10" + version: "4.0.15" js: dependency: transitive description: @@ -230,7 +230,7 @@ packages: name: universal_io url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.2.0" vector_math: dependency: transitive description: diff --git a/lib/android.dart b/lib/android.dart index 5359e34..2230be5 100644 --- a/lib/android.dart +++ b/lib/android.dart @@ -184,6 +184,9 @@ void _createAndroidSplash({ android12IconBackgroundColor: android12IconBackgroundColor, android12BrandingImagePath: android12BrandingImagePath, ); + } else { + File file = File(_flavorHelper.androidV31StylesFile); + if (file.existsSync()) file.deleteSync(); } if (android12DarkBackgroundColor != null || @@ -199,6 +202,9 @@ void _createAndroidSplash({ android12IconBackgroundColor: darkAndroid12IconBackgroundColor, android12BrandingImagePath: android12DarkBrandingImagePath, ); + } else { + File file = File(_flavorHelper.androidV31StylesNightFile); + if (file.existsSync()) file.deleteSync(); } _applyStylesXml( diff --git a/lib/web.dart b/lib/web.dart index 4956d4b..3f9cc50 100644 --- a/lib/web.dart +++ b/lib/web.dart @@ -26,6 +26,36 @@ void _createWebSplash({ return; } + // Config for removing splash screen: + if (imagePath == null && + darkImagePath == null && + color == "ffffff" && + darkColor == "000000" && + brandingImagePath == null && + brandingDarkImagePath == null && + backgroundImage == null && + darkBackgroundImage == null) { + Directory splashFolder = Directory(_webSplashFolder); + if (splashFolder.existsSync()) splashFolder.deleteSync(recursive: true); + final webIndex = File(_webIndex); + final document = html_parser.parse(webIndex.readAsStringSync()); + // Remove items that may have been added to index.html: + document + .querySelector( + 'link[rel="stylesheet"][type="text/css"][href="splash/style.css"]') + ?.remove(); + document + .querySelector( + 'meta[content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"][name="viewport"]', + ) + ?.remove(); + document.querySelector('script[src="splash/splash.js"]')?.remove(); + document.querySelector('picture#splash')?.remove(); + document.querySelector('picture#splash-branding')?.remove(); + webIndex.writeAsStringSync(document.outerHtml); + return; + } + darkImagePath ??= imagePath; _createWebImages( imagePath: imagePath, diff --git a/pubspec.yaml b/pubspec.yaml index 4986cc4..5ad40b6 100644 --- a/pubspec.yaml +++ b/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.17 +version: 2.2.18 repository: https://github.com/jonbhanson/flutter_native_splash issue_tracker: https://github.com/jonbhanson/flutter_native_splash/issues @@ -10,17 +10,17 @@ environment: flutter: ">=2.5.0" dependencies: - args: ^2.3.1 + args: ^2.4.0 flutter: sdk: flutter flutter_web_plugins: sdk: flutter js: ^0.6.4 html: ^0.15.1 - image: ^4.0.10 + image: ^4.0.15 meta: ^1.8.0 path: ^1.8.2 - universal_io: ^2.0.4 + universal_io: ^2.2.0 xml: ^6.1.0 yaml: ^3.1.1