diff --git a/.github/labeler.yml b/.github/labeler.yml index 234f8a80b..dabbc6c4a 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -15,6 +15,8 @@ - packages/device_info/**/* 'p: device_info_plus': - packages/device_info_plus/**/* +'p: flutter_splash_tizen': + - packages/flutter_splash_tizen/**/* 'p: flutter_tts': - packages/flutter_tts/**/* 'p: geolocator': diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 3b787aeef..8e3c78dcf 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -32,7 +32,8 @@ jobs: --exclude wearable_rotary image_picker camera webview_flutter \ video_player permission_handler geolocator battery connectivity \ device_info package_info sensors share wifi_info_flutter \ - google_maps_flutter tizen_app_control url_launcher network_info_plus + google_maps_flutter tizen_app_control url_launcher network_info_plus \ + flutter_splash_tizen - name: Run tests for all plugins if: ${{ github.event_name == 'push' }} run: | @@ -43,9 +44,10 @@ jobs: --exclude wearable_rotary image_picker camera webview_flutter \ video_player permission_handler geolocator battery connectivity \ device_info package_info sensors share wifi_info_flutter \ - google_maps_flutter tizen_app_control url_launcher network_info_plus + google_maps_flutter tizen_app_control url_launcher network_info_plus \ + flutter_splash_tizen # The following packages are excluded from tests: - # wearable_rotary, image_picker: no tests. + # wearable_rotary, image_picker, flutter_splash_tizen: no tests. # camera: no supported profiles. # video_player: test frequently breaks due to memory issue(https://github.com/flutter-tizen/plugins/issues/135). # permission_handler: permission related test. diff --git a/README.md b/README.md index b25a3d910..a49f02d02 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina | [**camera_tizen**](packages/camera) | [camera](https://github.com/flutter/plugins/tree/master/packages/camera) (1st-party) | [![pub package](https://img.shields.io/pub/v/camera_tizen.svg)](https://pub.dev/packages/camera_tizen) | No | | [**connectivity_plus_tizen**](packages/connectivity_plus) | [connectivity_plus](https://github.com/fluttercommunity/plus_plugins/tree/main/packages/connectivity_plus) (1st-party) | [![pub package](https://img.shields.io/pub/v/connectivity_plus_tizen.svg)](https://pub.dev/packages/connectivity_plus_tizen) | No | | [**device_info_plus_tizen**](packages/device_info_plus) | [device_info_plus](https://github.com/fluttercommunity/plus_plugins/tree/main/packages/device_info_plus) (1st-party) | [![pub package](https://img.shields.io/pub/v/device_info_plus_tizen.svg)](https://pub.dev/packages/device_info_plus_tizen) | No | +| [**flutter_splash_tizen**](packages/flutter_splash_tizen) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/flutter_splash_tizen.svg)](https://pub.dev/packages/flutter_splash_tizen) | N/A | | [**flutter_tts_tizen**](packages/flutter_tts) | [flutter_tts](https://github.com/dlutton/flutter_tts) (3rd-party) | [![pub package](https://img.shields.io/pub/v/flutter_tts_tizen.svg)](https://pub.dev/packages/flutter_tts_tizen) | No | | [**geolocator_tizen**](packages/geolocator) | [geolocator](https://github.com/Baseflow/flutter-geolocator/tree/master/geolocator) (3rd-party) | [![pub package](https://img.shields.io/pub/v/geolocator_tizen.svg)](https://pub.dev/packages/geolocator_tizen) | No | | [**google_maps_flutter_tizen**](packages/google_maps_flutter) | [google_maps_flutter](https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter) (1st-party) | [![pub package](https://img.shields.io/pub/v/google_maps_flutter_tizen.svg)](https://pub.dev/packages/google_maps_flutter_tizen) | No | diff --git a/packages/flutter_splash_tizen/.gitignore b/packages/flutter_splash_tizen/.gitignore new file mode 100644 index 000000000..dfe665603 --- /dev/null +++ b/packages/flutter_splash_tizen/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +.dart_tool/ + +.packages +.pub/ +.vscode/ +.idea/ +build/ diff --git a/packages/flutter_splash_tizen/CHANGELOG.md b/packages/flutter_splash_tizen/CHANGELOG.md new file mode 100644 index 000000000..9d0b371f8 --- /dev/null +++ b/packages/flutter_splash_tizen/CHANGELOG.md @@ -0,0 +1,2 @@ +## 0.1.0 +* Initial release diff --git a/packages/flutter_splash_tizen/LICENSE b/packages/flutter_splash_tizen/LICENSE new file mode 100644 index 000000000..b8fc05698 --- /dev/null +++ b/packages/flutter_splash_tizen/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the copyright holder nor the names of the + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/flutter_splash_tizen/README.md b/packages/flutter_splash_tizen/README.md new file mode 100644 index 000000000..372e2b869 --- /dev/null +++ b/packages/flutter_splash_tizen/README.md @@ -0,0 +1,33 @@ +# flutter_splash_tizen + +Flutter-tizen package that allows to add custom splash-screen images into your apps. +## Getting Started + +First you should add the package to dev_dependencies section in your `pubspec.yaml` + +```yaml +dev_dependencies: + flutter_splash_tizen: ^0.1.0 +``` +After that run +``` +flutter-tizen pub get +``` +in order to download the dependency. + +By adding +```yaml +flutter_splash_tizen: + image: test.png +``` +section in your `pubspec.yaml` and running +``` +flutter-tizen pub run flutter_splash_tizen:create +``` +the image from `tizen/shared/res/test.png` will be added as splash screen. Each call of `create` will override the previous.
+ +If you wish to remove the splash image from your app simply run +``` +flutter-tizen pub run flutter_splash_tizen:remove +``` +Package has been tested on Mobile 6.0, Wearable 6.0 and IoT Headed 6.5 platform. diff --git a/packages/flutter_splash_tizen/analysis_options.yaml b/packages/flutter_splash_tizen/analysis_options.yaml new file mode 100644 index 000000000..f9b303465 --- /dev/null +++ b/packages/flutter_splash_tizen/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/packages/flutter_splash_tizen/bin/create.dart b/packages/flutter_splash_tizen/bin/create.dart new file mode 100644 index 000000000..65c73574a --- /dev/null +++ b/packages/flutter_splash_tizen/bin/create.dart @@ -0,0 +1,57 @@ +import 'dart:io'; +import 'package:yaml/yaml.dart'; +import 'package:xml/xml.dart'; + +Map? loadYamlFileSync(String path) { + File file = File(path); + if (file.existsSync()) { + return loadYaml(file.readAsStringSync()); + } + return null; +} + +XmlDocument? loadXMLFileSync(String path) { + File file = File(path); + if (file.existsSync()) { + return XmlDocument.parse(file.readAsStringSync()); + } + return null; +} + +void main() { + var doc = loadYamlFileSync("pubspec.yaml")?['flutter_splash_tizen']; + if (doc == null) throw const FormatException("could not read pubspec.yaml!"); + + String? image = doc["image"]; + if (image == null) { + throw const FormatException("could not find image section!"); + } + const String tizenManifestPath = "tizen/tizen-manifest.xml"; + + XmlDocument? tizenManifest = loadXMLFileSync(tizenManifestPath); + if (tizenManifest == null) { + throw const FormatException("could not read tizen-manifext.xml!"); + } + XmlNode el = tizenManifest.root; + + XmlElement? uiApp = el.getElement("manifest")?.getElement("ui-application"); + if (uiApp == null) { + throw const FormatException("error when reading $tizenManifestPath"); + } + XmlElement? splashScreens = uiApp.getElement("splash-screens"); + if (splashScreens == null) { + splashScreens = XmlElement(XmlName("splash-screens")); + uiApp.children.add(splashScreens); + } + + splashScreens.children.clear(); + XmlElement splashScreen = XmlElement(XmlName("splash-screen")); + splashScreen.setAttribute("src", image); + splashScreen.setAttribute("type", "img"); + splashScreen.setAttribute("indicator-display", "false"); + splashScreen.setAttribute("orientation", "portrait"); + splashScreens.children.add(splashScreen); + + File(tizenManifestPath) + .writeAsStringSync(el.toXmlString(pretty: true, indent: ' ') + '\n'); +} diff --git a/packages/flutter_splash_tizen/bin/remove.dart b/packages/flutter_splash_tizen/bin/remove.dart new file mode 100644 index 000000000..69f1a9972 --- /dev/null +++ b/packages/flutter_splash_tizen/bin/remove.dart @@ -0,0 +1,25 @@ +import 'dart:io'; +import 'package:xml/xml.dart'; + +void main() { + const String tizenManifestPath = "tizen/tizen-manifest.xml"; + File tizenManifestFile = File(tizenManifestPath); + if (!tizenManifestFile.existsSync()) { + throw const FormatException("could not read tizen-manifext.xml!"); + } + XmlDocument? tizenManifest = + XmlDocument.parse(tizenManifestFile.readAsStringSync()); + XmlNode el = tizenManifest.root; + + XmlElement? uiApp = el.getElement("manifest")?.getElement("ui-application"); + if (uiApp == null) { + throw const FormatException("error when reading $tizenManifestPath"); + } + XmlElement? splashScreens = uiApp.getElement("splash-screens"); + + if (splashScreens != null) { + splashScreens.children.clear(); + File(tizenManifestPath) + .writeAsStringSync(el.toXmlString(pretty: true, indent: ' ') + '\n'); + } +} diff --git a/packages/flutter_splash_tizen/example/.gitignore b/packages/flutter_splash_tizen/example/.gitignore new file mode 100644 index 000000000..eadf111d1 --- /dev/null +++ b/packages/flutter_splash_tizen/example/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# VS Code related +.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/packages/flutter_splash_tizen/example/README.md b/packages/flutter_splash_tizen/example/README.md new file mode 100644 index 000000000..2d9e3b99f --- /dev/null +++ b/packages/flutter_splash_tizen/example/README.md @@ -0,0 +1,3 @@ +# flutter_splash_tizen_example + +Demonstrates how to use the flutter_splash_tizen package. diff --git a/packages/flutter_splash_tizen/example/analysis_options.yaml b/packages/flutter_splash_tizen/example/analysis_options.yaml new file mode 100644 index 000000000..0bd999bf0 --- /dev/null +++ b/packages/flutter_splash_tizen/example/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +linter: + rules: diff --git a/packages/flutter_splash_tizen/example/lib/main.dart b/packages/flutter_splash_tizen/example/lib/main.dart new file mode 100644 index 000000000..6407eee7c --- /dev/null +++ b/packages/flutter_splash_tizen/example/lib/main.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +void main() => runApp(const MyApp()); + +class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Welcome to Flutter', + home: Scaffold( + appBar: AppBar( + title: const Text('Welcome to Flutter'), + ), + body: const Center( + child: Text('sample app for flutter splash tizen'), + ), + ), + ); + } +} diff --git a/packages/flutter_splash_tizen/example/pubspec.yaml b/packages/flutter_splash_tizen/example/pubspec.yaml new file mode 100644 index 000000000..0c434dfe6 --- /dev/null +++ b/packages/flutter_splash_tizen/example/pubspec.yaml @@ -0,0 +1,23 @@ +name: flutter_splash_tizen_example +description: Demonstrates how to use the flutter_splash_tizen package. + +publish_to: 'none' + +environment: + sdk: ">=2.12.0 <3.0.0" + +dependencies: + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter: + sdk: flutter + flutter_lints: ^1.0.0 + flutter_splash_tizen: + path: ../ + +flutter: + uses-material-design: true + +flutter_splash_tizen: + image: test.png diff --git a/packages/flutter_splash_tizen/example/tizen/.gitignore b/packages/flutter_splash_tizen/example/tizen/.gitignore new file mode 100644 index 000000000..750f3af1b --- /dev/null +++ b/packages/flutter_splash_tizen/example/tizen/.gitignore @@ -0,0 +1,5 @@ +flutter/ +.vs/ +*.user +bin/ +obj/ diff --git a/packages/flutter_splash_tizen/example/tizen/App.cs b/packages/flutter_splash_tizen/example/tizen/App.cs new file mode 100644 index 000000000..6dd4a6356 --- /dev/null +++ b/packages/flutter_splash_tizen/example/tizen/App.cs @@ -0,0 +1,20 @@ +using Tizen.Flutter.Embedding; + +namespace Runner +{ + public class App : FlutterApplication + { + protected override void OnCreate() + { + base.OnCreate(); + + GeneratedPluginRegistrant.RegisterPlugins(this); + } + + static void Main(string[] args) + { + var app = new App(); + app.Run(args); + } + } +} diff --git a/packages/flutter_splash_tizen/example/tizen/Runner.csproj b/packages/flutter_splash_tizen/example/tizen/Runner.csproj new file mode 100644 index 000000000..c3c43aed9 --- /dev/null +++ b/packages/flutter_splash_tizen/example/tizen/Runner.csproj @@ -0,0 +1,26 @@ + + + + Exe + tizen40 + + + + portable + + + none + + + + + + + + + + %(RecursiveDir) + + + + diff --git a/packages/flutter_splash_tizen/example/tizen/shared/res/ic_launcher.png b/packages/flutter_splash_tizen/example/tizen/shared/res/ic_launcher.png new file mode 100644 index 000000000..4d6372eeb Binary files /dev/null and b/packages/flutter_splash_tizen/example/tizen/shared/res/ic_launcher.png differ diff --git a/packages/flutter_splash_tizen/example/tizen/shared/res/test.png b/packages/flutter_splash_tizen/example/tizen/shared/res/test.png new file mode 100644 index 000000000..4d6372eeb Binary files /dev/null and b/packages/flutter_splash_tizen/example/tizen/shared/res/test.png differ diff --git a/packages/flutter_splash_tizen/example/tizen/tizen-manifest.xml b/packages/flutter_splash_tizen/example/tizen/tizen-manifest.xml new file mode 100644 index 000000000..585f29bd7 --- /dev/null +++ b/packages/flutter_splash_tizen/example/tizen/tizen-manifest.xml @@ -0,0 +1,13 @@ + + + + + + ic_launcher.png + + + + + + + diff --git a/packages/flutter_splash_tizen/pubspec.yaml b/packages/flutter_splash_tizen/pubspec.yaml new file mode 100644 index 000000000..618c1ac9b --- /dev/null +++ b/packages/flutter_splash_tizen/pubspec.yaml @@ -0,0 +1,20 @@ +name: flutter_splash_tizen +description: Flutter-tizen package that allows to add custom splash-screen images into your apps. +homepage: https://github.com/flutter-tizen/plugins +repository: https://github.com/flutter-tizen/plugins/tree/master/packages/flutter_splash_tizen +version: 0.1.0 + +environment: + sdk: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" + +dependencies: + flutter: + sdk: flutter + xml: ^5.3.1 + yaml: ^3.1.0 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^1.0.0 diff --git a/tools/recipe.yaml b/tools/recipe.yaml index b27d8061e..301731cfe 100644 --- a/tools/recipe.yaml +++ b/tools/recipe.yaml @@ -4,6 +4,7 @@ plugins: camera: [] connectivity_plus: ["wearable-5.5", "tv-6.0"] device_info_plus: ["wearable-5.5", "tv-6.0"] + flutter_splash_tizen: ["wearable-5.5"] flutter_tts: ["wearable-5.5", "tv-6.0"] geolocator: ["wearable-5.5"] google_maps_flutter: []