mirror of
https://github.com/apache/cordova-plugin-splashscreen.git
synced 2026-02-05 00:01:30 +08:00
Compare commits
71 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
326f13220e | ||
|
|
5ca43e8c5d | ||
|
|
278c5d8168 | ||
|
|
7cb318727b | ||
|
|
c2c3a980e1 | ||
|
|
1a4b51fbc8 | ||
|
|
0b75c1faa0 | ||
|
|
09e95a2628 | ||
|
|
3180758a4e | ||
|
|
50a55883d3 | ||
|
|
833dc7f783 | ||
|
|
e443871785 | ||
|
|
fcef678a7f | ||
|
|
e5c6772f17 | ||
|
|
7c0ab0fa51 | ||
|
|
7735ae0598 | ||
|
|
b0e1157c8a | ||
|
|
a18cc8241a | ||
|
|
bf9607e27f | ||
|
|
87d29ad6d3 | ||
|
|
2db7bac571 | ||
|
|
d6db9f3459 | ||
|
|
be635a36c1 | ||
|
|
d63786d33b | ||
|
|
98f83fea5a | ||
|
|
c81df6f274 | ||
|
|
ffda2e81b9 | ||
|
|
e0cf396835 | ||
|
|
7f140e0176 | ||
|
|
85aa605a12 | ||
|
|
7c687957f8 | ||
|
|
13849c3d20 | ||
|
|
90ba3dfc5b | ||
|
|
b1ceb532f8 | ||
|
|
1185561549 | ||
|
|
894d164191 | ||
|
|
caa5534c0d | ||
|
|
a922ce0453 | ||
|
|
6195d6741b | ||
|
|
0f2a069588 | ||
|
|
782939f7ef | ||
|
|
04667e04c0 | ||
|
|
de28cf89bf | ||
|
|
770c264d2c | ||
|
|
5a1ade6114 | ||
|
|
62509f6b47 | ||
|
|
2eb78b3724 | ||
|
|
6e43615e25 | ||
|
|
ac39b04b6f | ||
|
|
66f7ee34d1 | ||
|
|
41ca5809b1 | ||
|
|
0a8b5be3d1 | ||
|
|
d65c0c7cc5 | ||
|
|
4102589bd5 | ||
|
|
1eac08c558 | ||
|
|
80b01049c8 | ||
|
|
4adff6f1c9 | ||
|
|
3d924fce1b | ||
|
|
6a737203da | ||
|
|
acb45f3a38 | ||
|
|
8d66b9e353 | ||
|
|
edb6c3d6f8 | ||
|
|
14061d1999 | ||
|
|
6863886d74 | ||
|
|
9832d2e165 | ||
|
|
bea0a4e408 | ||
|
|
41d9ae94ff | ||
|
|
9ca15db91a | ||
|
|
f8311aaca8 | ||
|
|
abbb07e5ee | ||
|
|
2012ba9ab6 |
28
.appveyor.yml
Normal file
28
.appveyor.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
# appveyor file
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
max_jobs: 1
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf true
|
||||
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
|
||||
environment:
|
||||
nodejs_version: "4"
|
||||
matrix:
|
||||
- PLATFORM: windows-10-store
|
||||
JUST_BUILD: --justBuild
|
||||
install:
|
||||
- npm cache clean -f
|
||||
- node --version
|
||||
- npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git
|
||||
- npm install -g cordova
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD%
|
||||
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<!--
|
||||
Please make sure the checklist boxes are all checked before submitting the PR. The checklist
|
||||
is intended as a quick reference, for complete details please see our Contributor Guidelines:
|
||||
|
||||
http://cordova.apache.org/contribute/contribute_guidelines.html
|
||||
|
||||
Thanks!
|
||||
-->
|
||||
|
||||
### Platforms affected
|
||||
|
||||
|
||||
### What does this PR do?
|
||||
|
||||
|
||||
### What testing has been done on this change?
|
||||
|
||||
|
||||
### Checklist
|
||||
- [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
|
||||
- [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
|
||||
- [ ] Added automated test coverage as appropriate for this change.
|
||||
1
.jshintignore
Normal file
1
.jshintignore
Normal file
@@ -0,0 +1 @@
|
||||
tests/ios
|
||||
96
.travis.yml
96
.travis.yml
@@ -1,4 +1,94 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "4.2"
|
||||
addons:
|
||||
jwt:
|
||||
secure: UmbBQ73ydIzhTCfaTb/g0beTwnOHjYxlILmQYK2Tl9Gna/KbpawiVmbloX1eZakevkeYgzQmAHEF0LyDINy5AUk97azYeP0Sz/IOjIDfXAdc6U6sZb7BScneBMt6ET/hCprG4f3mbmleQ+gx+dmNWez6rlb3Xu+XWfJuwDfAWm0=
|
||||
env:
|
||||
global:
|
||||
- SAUCE_USERNAME=snay
|
||||
- TRAVIS_NODE_VERSION="4.2"
|
||||
matrix:
|
||||
include:
|
||||
- env: PLATFORM=browser-chrome
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-firefox
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-safari
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-edge
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: TEST_DIR=.
|
||||
language: objective-c
|
||||
osx_image: xcode7
|
||||
- env: TEST_DIR=./tests/ios
|
||||
language: objective-c
|
||||
osx_image: xcode7
|
||||
- env: PLATFORM=ios-9.3
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=ios-10.0
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=android-4.4
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- extra-android-m2repository
|
||||
- env: PLATFORM=android-5.1
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- extra-android-m2repository
|
||||
- env: PLATFORM=android-6.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- extra-android-m2repository
|
||||
- env: PLATFORM=android-7.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- extra-android-m2repository
|
||||
before_install:
|
||||
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm
|
||||
&& git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm
|
||||
install $TRAVIS_NODE_VERSION
|
||||
- node --version
|
||||
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
|
||||
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
|
||||
- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25,android-26;
|
||||
fi
|
||||
- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic
|
||||
&& npm install && popd
|
||||
- npm install -g cordova
|
||||
install:
|
||||
- npm install
|
||||
script:
|
||||
- if [[ "$TEST_DIR" != "" ]];
|
||||
then cd $TEST_DIR && npm install && (npm test || npm test);
|
||||
else node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce
|
||||
--buildName travis-plugin-splashscreen-$TRAVIS_JOB_NUMBER;
|
||||
fi
|
||||
|
||||
473
README.md
473
README.md
@@ -1,3 +1,7 @@
|
||||
---
|
||||
title: Splashscreen
|
||||
description: Control the splash screen for your app.
|
||||
---
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
@@ -17,11 +21,13 @@
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-splashscreen)
|
||||
|AppVeyor|Travis CI|
|
||||
|:-:|:-:|
|
||||
|[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-splashscreen)|[](https://travis-ci.org/apache/cordova-plugin-splashscreen)|
|
||||
|
||||
# cordova-plugin-splashscreen
|
||||
|
||||
This plugin displays and hides a splash screen during application launch.
|
||||
This plugin is required to work with splash screens. This plugin displays and hides a splash screen during application launch.
|
||||
|
||||
Report issues with this plugin on the [Apache Cordova issue tracker][Apache Cordova issue tracker].
|
||||
|
||||
@@ -40,74 +46,364 @@ Report issues with this plugin on the [Apache Cordova issue tracker][Apache Cord
|
||||
- BlackBerry 10
|
||||
- iOS
|
||||
- Windows Phone 7 and 8
|
||||
- Windows 8
|
||||
- Windows
|
||||
- Windows (`cordova-windows` version >= 4.4.0 is required)
|
||||
- Browser
|
||||
|
||||
__Note__: Extended splashscreen does not require the plugin on Windows (as opposed to Android and iOS) in case you don't use the plugin API, i.e. programmatic hide/show.
|
||||
|
||||
### iOS-specific information
|
||||
|
||||
There are two mechanisms for displaying a launch screen on iOS:
|
||||
|
||||
1. Legacy launch images: images are sized exactly for the device's screen size. Does not support the iPad Pro 12.9's native resolution or split-screen/slide-over multitasking.
|
||||
|
||||
2. Launch storyboard images: Images are sized based on scale, idiom, and size classes. Supports all devices, and can be used with split-screen/slide-over multitasking.
|
||||
|
||||
Apple is moving away from legacy launch images. There is no official support for providing a native-resolution launch image for the iPad Pro 12.9 or for providing launch images that work with split-screen multitasking or slide-over. If your app doesn't need to support these contexts, then you can continue to use legacy launch images for as long as you like.
|
||||
|
||||
The preferred method of providing launch images is to use a launch storyboard. For native app developers, the ideal launch storyboard is an unpopulated version of the app's user interface at launch. For non-native app developers who don't wish to learn Interface Builder, however, this plugin simulates the legacy launch image method as much as is feasible.
|
||||
|
||||
#### Legacy launch images
|
||||
|
||||
If you choose to use legacy launch images, you will use the following syntax in `config.xml`:
|
||||
|
||||
```
|
||||
<splash src="res/screen/ios/Default~iphone.png" width="320" height="480"/>
|
||||
<splash src="res/screen/ios/Default@2x~iphone.png" width="640" height="960"/>
|
||||
<splash src="res/screen/ios/Default-Portrait~ipad.png" width="768" height="1024"/>
|
||||
<splash src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
|
||||
<splash src="res/screen/ios/Default-Landscape~ipad.png" width="1024" height="768"/>
|
||||
<splash src="res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
|
||||
<splash src="res/screen/ios/Default-568h@2x~iphone.png" width="640" height="1136"/>
|
||||
<splash src="res/screen/ios/Default-667h.png" width="750" height="1334"/>
|
||||
<splash src="res/screen/ios/Default-736h.png" width="1242" height="2208"/>
|
||||
```
|
||||
|
||||
Technically the filename for the `src` attribute can be anything you want; the filenames are used because they match what will be used when your project is compiled. The width and height attributes determine which launch images are displayed on which devices as follows:
|
||||
|
||||
| width | height | device (orientation) |
|
||||
|:-----------:|:------------:|:--------------------------------:|
|
||||
| 320 | 480 | All non-retina iPhones and iPods |
|
||||
| 640 | 960 | iPhone 4/4s (portrait) |
|
||||
| 640 | 1136 | iPhone 5/5s/SE (portrait) |
|
||||
| 750 | 1334 | iPhone 6/6s/7 (portrait) |
|
||||
| 1242 | 2208 | iPhone 6+/6s+/7+ (portrait) |
|
||||
| 2208 | 1242 | iPhone 6+/6s+/7+ (landscape) |
|
||||
| 768 | 1024 | All non-retina iPads (portrait) |
|
||||
| 1024 | 768 | All non-retina iPads (landscape) |
|
||||
| 1536 | 2048 | All retina iPads (portrait) |
|
||||
| 2048 | 1536 | All retina iPads (landscape) |
|
||||
|
||||
Note: It is vitally important that the source image actually matches the size specified in the `width` and `height` attributes. If it does not, the device may fail to render it properly, if at all.
|
||||
|
||||
#### Launch storyboard images
|
||||
|
||||
In order to support newer form factors and split-screen/slide-over multitasking, you should use launch storyboard images. These are similar to the legacy launch images above, but there are crucial differences:
|
||||
|
||||
- images are not specific to a given device.
|
||||
|
||||
- images are scaled to fill the available viewport (while maintaining the aspect ratio).
|
||||
|
||||
- the outer edges of the images will be cropped, and the amount will vary based on device an viewport.
|
||||
|
||||
- there is no need to provide an image for each possible device, viewport, and orientation; iOS will choose the best image for the situation automatically.
|
||||
|
||||
##### Designing launch storyboard images
|
||||
|
||||
The key to designing a launch storyboard image is understanding that the edges of the image will almost certainly be cropped. Therefore, one should not place any important information near the edges of any images provided to the launch storyboard. Only the center is a safe area, and this all but guarantees that following Apple's advice of presenting an unpopulated user interface will not work well.
|
||||
|
||||
Instead, the following tips should enable you to create a launch image that works across a multitude of form factors, viewports, and orientations:
|
||||
|
||||
- Important graphics (logos, icons, titles) should be centered. The safe bounding region will vary, so you will need to test to ensure that the important graphics are never cropped. Better yet, don't supply any important graphics in the first place.
|
||||
|
||||
- You _can_ fine-tune the placement and size of these graphics, but you don't have the same fine-grained control as you did with legacy launch images.
|
||||
|
||||
- Use a simple color wash. If you use two colors, you'll want one color to fill the top half of the image, and the second to fill the bottom half. If you use a gradient, you'll probably want to ensure that the middle of the gradient lines up with the center of the image.
|
||||
|
||||
- Don't worry about pixel perfection -- because the images are scaled, there's almost no chance the images will be perfectly fit to the pixel grid. Since all supported iOS devices use retina screens, users will be hard pressed to notice it anyway.
|
||||
|
||||
It is important to understand the concept of scale, idiom, and size class traits in order to use launch storyboard images effectively. Of the images supplied to the launch storyboard, iOS will choose the image that best matches the device and viewport and render that image. It is possible to supply only one launch image if so desired, but it is also possible to fine-tune the displayed launch image based on traits. When fine-tuning, one can ignore traits that aren't targeted or supported by the app.
|
||||
|
||||
> Note: If you are using launch storyboard images, there is no need to include legacy images. If you do, the legacy images will be copied, but not used.
|
||||
|
||||
##### Scale
|
||||
|
||||
| scale | devices |
|
||||
|:-----------:|:----------------------:|
|
||||
| 1x | All non-retina devices |
|
||||
| 2x | Most retina devices |
|
||||
| 3x | iPhone 6+/6s+,7s+ |
|
||||
|
||||
In general, you'll want to supply 2x and 3x images. Cordova only supports retina devices now, so there's no point in supplying 1x images.
|
||||
|
||||
##### Idioms
|
||||
|
||||
| idiom | devices |
|
||||
|:-----------:|:-------------:|
|
||||
| ipad | All iPads |
|
||||
| iphone | All iPhones and iPod Touches |
|
||||
| universal | All devices |
|
||||
|
||||
You only need to provide universal images unless you need to fine-tune for a specific device idiom.
|
||||
|
||||
##### Size classes
|
||||
|
||||
There are two size classes applies to both screen axes. Narrow viewports are considered to be the "compact" size class, and remaining viewports are considered "regular". When supplying images to Xcode, however, one must choose between "any & compact" and "any & regular". To stay consistent with the native terminology, this feature will match based on "any" and "compact". `any` will match regular-sized viewports.
|
||||
|
||||
Note: this feature uses `com` as an abbreviation for "compact" classes.
|
||||
|
||||
The following classes are supported by this feature:
|
||||
|
||||
| width | height | orientation |
|
||||
|:-----------:|:------------:|:-----------------:|
|
||||
| any | any | any |
|
||||
| com | any | portrait |
|
||||
| any | com | landscape (wide) |
|
||||
| com | com | landscape (narrow)|
|
||||
|
||||
To see the complete list of size classes associated with devices and viewports, see <http://www.sizeclasses.com>.
|
||||
|
||||
##### Single-image launch screen
|
||||
|
||||
If your launch image is simple, you may be able to avoid creating a lot of different launch images and supply only one. The launch image needs to meet the following requirements:
|
||||
|
||||
- the image should be square
|
||||
|
||||
- the image should be large enough to fit on an iPad Pro 12.9": 2732x2732
|
||||
|
||||
- anything important should fit within the center
|
||||
|
||||
Keep in mind that the image will be cropped, possibly quite severely, depending upon the viewport.
|
||||
|
||||
Once the image is created, you can include it in your project by adding the following to `config.xml`:
|
||||
|
||||
```
|
||||
<splash src="res/screen/ios/Default@2x~universal~anyany.png" />
|
||||
```
|
||||
|
||||
Because only one image is provided, iOS will utilize it in every context.
|
||||
|
||||
##### Multi-image launch screen
|
||||
|
||||
If a single launch image won't meet your needs, you will probably need to supply at least six images, if not more. Furthermore, keep in mind that it will not be possible to fine tune the image to a specific device, but only to a device class, display factor, and viewport size.
|
||||
|
||||
If you don't need to target images to a specific idiom, you should create six images, as follows:
|
||||
|
||||
| scale | idiom | width | height | size | filename |
|
||||
|:-----------:|:-----------:|:-----------:|:------------:|:----------:|:--------------:|
|
||||
| 2x* | universal | any | any | 2732x2732 | `Default@2x~universal~anyany.png` |
|
||||
| 2x | universal | com | any | 1278x2732 | `Default@2x~universal~comany.png` |
|
||||
| 2x | universal | com | com | 1334x750 | `Default@2x~universal~comcom.png` |
|
||||
| 3x* | universal | any | any | 2208x2208 | `Default@3x~universal~anyany.png` |
|
||||
| 3x | universal | any | com | 2208x1242 | `Default@3x~universal~anycom.png` |
|
||||
| 3x | universal | com | any | 1242x2208 | `Default@3x~universal~comany.png` |
|
||||
|
||||
\* this image is required in order for iOS utilize the other images within this scale and idiom.
|
||||
|
||||
> Note: If the 3x sizes look small too you, that's because there's only one device class that currently has a 3x density: the iPhone 6+/6s+/7+.
|
||||
|
||||
The above looks like the following snippet when present in `config.xml`:
|
||||
|
||||
```
|
||||
<splash src="res/screen/ios/Default@2x~universal~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~universal~comany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~universal~comcom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~anycom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~comany.png" />
|
||||
```
|
||||
|
||||
Should one need to further fine tune based upon device idiom, one can do so. This might look like so:
|
||||
|
||||
| scale | idiom | width | height | size | filename |
|
||||
|:-----------:|:-----------:|:-----------:|:------------:|:----------:|:--------------:|
|
||||
| 2x* | iphone | any | any | 1334x1334 | `Default@2x~iphone~anyany.png` |
|
||||
| 2x | iphone | com | any | 750x1334 | `Default@2x~iphone~comany.png` |
|
||||
| 2x | iphone | com | com | 1334x750 | `Default@2x~iphone~comcom.png` |
|
||||
| 3x* | iphone | any | any | 2208x2208 | `Default@3x~iphone~anyany.png` |
|
||||
| 3x | iphone | any | com | 2208x1242 | `Default@3x~iphone~anycom.png` |
|
||||
| 3x | iphone | com | any | 1242x2208 | `Default@3x~iphone~comany.png` |
|
||||
| 2x* | ipad | any | any | 2732x2732 | `Default@2x~ipad~anyany.png` |
|
||||
| 2x | ipad | com | any | 1278x2732 | `Default@2x~ipad~comany.png` |
|
||||
|
||||
\* this image is required in order for iOS utilize the other images within this scale and idiom.
|
||||
|
||||
The above looks like the following in `config.xml`:
|
||||
|
||||
```
|
||||
<splash src="res/screen/ios/Default@2x~iphone~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~iphone~comany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~iphone~comcom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~iphone~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@3x~iphone~anycom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~iphone~comany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~ipad~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~ipad~comany.png" />
|
||||
```
|
||||
|
||||
##### Quirks and Known Issues
|
||||
|
||||
1. **App on target may not reflect changes to images**
|
||||
Once you run the app on a target, iOS caches the launch image. Unfortunately, when you chance the images, iOS does _not_ invalidate the cache, which means you'll still see the old launch image. You should either: delete the app, or reset content & settings (simulator).
|
||||
|
||||
2. **Simulator may not show expected images when launched from CLI**
|
||||
When Xcode deploys to a specific simulator, it only copies the assets that match the simulator's characteristics. For example, if you try to run an app on the iPhone 6s Plus simulator, only @3x launch images are copied. When compiling from the CLI, however, the default is to assume an iPhone 5s, which means only @2x launch images are copied. Unless your launch images are markedly different, chances are good the difference would go unnoticed, but this does mean that the only accurate method of testing is to test on a physical device.
|
||||
|
||||
3. **`anyany` must be provided for other variations to be used**
|
||||
If you don't provide an `anyany` version of the launch image for a specific scale and idiom, the other variations (like `anycom`, `comany`, and `comcom`) will ignored.
|
||||
|
||||
## Windows-specific information
|
||||
|
||||
Splash screen images can be defined using the [MRT](https://cordova.apache.org/docs/en/dev/config_ref/images.html#windows) concept.
|
||||
If you specify src="res/windows/splashscreen.png" the following files will be copied into the application's images folder:
|
||||
`res/windows/splashscreen.png` | `res/windows/splashscreen.scale-100.png`, `res/windows/splashscreen.scale-125.png`, etc.
|
||||
The following are supported:
|
||||
|
||||
| Scale, % | Project | Width | Height | Filename |
|
||||
|:------------:|:-------------------:|:-----------:|:------------:|:---------------------------------:|
|
||||
| 100 | Windows 10/8.1 | 620 | 300 | `splashscreen.png` \| `splashscreen.scale-100.png` |
|
||||
| 125 | Windows 10 | 775 | 375 | `splashscreen.scale-125.png` |
|
||||
| 150 | Windows 10 | 930 | 450 | `splashscreen.scale-150.png` |
|
||||
| 200 | Windows 10 | 1240 | 600 | `splashscreen.scale-200.png` |
|
||||
| 400 | Windows 10 | 2480 | 1200 | `splashscreen.scale-400.png` |
|
||||
| 140 | Windows 8.1 | 868 | 420 | `splashscreen.scale-140.png` |
|
||||
| 180 | Windows 8.1 | 1116 | 540 | `splashscreen.scale-180.png` |
|
||||
| 100 | Windows Phone 8.1 | 480 | 800 | `splashscreenphone.png` \| `splashscreenphone.scale-100.png` |
|
||||
| 140 | Windows Phone 8.1 | 672 | 1120 | `splashscreenphone.scale-140.png` |
|
||||
| 240 | Windows Phone 8.1 | 1152 | 1920 | `splashscreenphone.scale-240.png` |
|
||||
|
||||
__Note__: SplashScreens size for Windows 10 project should not exceed 200 KBytes.
|
||||
__Note__: Supported formats are `.png`, `.jpg`, `.jpeg`. Mixing of the extensions within a target is not supported. I.e. you can have `splashscreen.jpg` and `splashscreenphone.png` but not `splashscreen.scale-100.png`, `splashscreen.scale-400.jpg`.
|
||||
__Note__: You may need to reopen Visual Studio solution after changing the images and doing a `cordova prepare` for the changes to take effect.
|
||||
|
||||
## Example Configuration
|
||||
In the top-level `config.xml` file (not the one in `platforms`), add configuration elements like those specified here.
|
||||
|
||||
Please notice that the value of the "src" attribute is relative to the project root directory and not to the www directory (see `Directory structure` below). You can name the source image whatever you like. The internal name in the app is determined by Cordova.
|
||||
|
||||
Directory structure:
|
||||
|
||||
```
|
||||
projectRoot
|
||||
hooks
|
||||
platforms
|
||||
plugins
|
||||
www
|
||||
css
|
||||
img
|
||||
js
|
||||
res
|
||||
screen
|
||||
android
|
||||
ios
|
||||
windows
|
||||
```
|
||||
|
||||
```xml
|
||||
<platform name="android">
|
||||
<!-- you can use any density that exists in the Android project -->
|
||||
<splash src="res/screen/android/splash-land-hdpi.png" density="land-hdpi"/>
|
||||
<splash src="res/screen/android/splash-land-ldpi.png" density="land-ldpi"/>
|
||||
<splash src="res/screen/android/splash-land-mdpi.png" density="land-mdpi"/>
|
||||
<splash src="res/screen/android/splash-land-xhdpi.png" density="land-xhdpi"/>
|
||||
|
||||
<splash src="res/screen/android/splash-port-hdpi.png" density="port-hdpi"/>
|
||||
<splash src="res/screen/android/splash-port-ldpi.png" density="port-ldpi"/>
|
||||
<splash src="res/screen/android/splash-port-mdpi.png" density="port-mdpi"/>
|
||||
<splash src="res/screen/android/splash-port-xhdpi.png" density="port-xhdpi"/>
|
||||
</platform>
|
||||
|
||||
<platform name="ios">
|
||||
<!-- There are two mechanisms for showing launch images.
|
||||
-- Legacy method (supports all devices except iPad Pro 12.9):
|
||||
-- Note: Images are determined by width and height. The following are supported -->
|
||||
<splash src="res/screen/ios/Default~iphone.png" width="320" height="480"/>
|
||||
<splash src="res/screen/ios/Default@2x~iphone.png" width="640" height="960"/>
|
||||
<splash src="res/screen/ios/Default-Portrait~ipad.png" width="768" height="1024"/>
|
||||
<splash src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
|
||||
<splash src="res/screen/ios/Default-Landscape~ipad.png" width="1024" height="768"/>
|
||||
<splash src="res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
|
||||
<splash src="res/screen/ios/Default-568h@2x~iphone.png" width="640" height="1136"/>
|
||||
<splash src="res/screen/ios/Default-667h.png" width="750" height="1334"/>
|
||||
<splash src="res/screen/ios/Default-736h.png" width="1242" height="2208"/>
|
||||
<splash src="res/screen/ios/Default-Landscape-736h.png" width="2208" height="1242"/>
|
||||
<!-- Storyboard method (supports all devices):
|
||||
-- Important: If you use the storyboard method, legacy images are
|
||||
-- copied but ignored.
|
||||
-- Note: images are determined by scale, idiom, and size traits. The following
|
||||
-- are suggested based on current device form factors -->
|
||||
<splash src="res/screen/ios/Default@2x~universal~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~universal~comany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~universal~comcom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~anycom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~comany.png" />
|
||||
|
||||
</platform>
|
||||
|
||||
<!-- Configuration using MRT concept (Recommended, see "Windows-specific information" section for details): -->
|
||||
<platform name="windows">
|
||||
<splash src="res/screen/windows/splashscreen.png" target="SplashScreen"/>
|
||||
<splash src="res/screen/windows/splashscreenphone.png" target="SplashScreenPhone"/>
|
||||
</platform>
|
||||
|
||||
<!-- Configuration using image size: -->
|
||||
<!--<platform name="windows">
|
||||
<splash src="res/screen/windows/splashscreen.png" width="620" height="300"/>
|
||||
<splash src="res/screen/windows/splashscreenphone.png" width="1152" height="1920"/>
|
||||
</platform>-->
|
||||
|
||||
<platform name="blackberry10">
|
||||
<!-- Add a rim:splash element for each resolution and locale you wish -->
|
||||
<!-- http://developer.blackberry.com/html5/documentation/rim_splash_element.html -->
|
||||
<rim:splash src="res/screen/blackberry/splashscreen.png"/>
|
||||
</platform>
|
||||
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
```
|
||||
|
||||
## Preferences
|
||||
|
||||
#### config.xml
|
||||
|
||||
- __SplashScreen__ (string). The resource name which is used for the displaying splash screen. Different platforms use values for this.
|
||||
- `AutoHideSplashScreen` (boolean, default to `true`). Indicates whether to hide splash screen automatically or not. Splash screen hidden after amount of time specified in the `SplashScreenDelay` preference.
|
||||
|
||||
<preference name="SplashScreen" value="resourcename" />
|
||||
```xml
|
||||
<preference name="AutoHideSplashScreen" value="true" />
|
||||
```
|
||||
|
||||
- __AutoHideSplashScreen__ (boolean, default to `true`). Indicates wherether hide splash screen automatically or not. Splash screen hidden after amount of time specified in the `SplashScreenDelay` preference.
|
||||
- `SplashScreenDelay` (number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen.
|
||||
|
||||
<preference name="AutoHideSplashScreen" value="true" />
|
||||
|
||||
- __SplashScreenDelay__ (number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen.
|
||||
|
||||
<preference name="SplashScreenDelay" value="3000" />
|
||||
|
||||
|
||||
### Android Quirks
|
||||
|
||||
In your `config.xml`, you need to add the following preferences:
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
```xml
|
||||
<preference name="SplashScreenDelay" value="3000" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
<preference name="SplashShowOnlyFirstTime" value="true|false" />
|
||||
```
|
||||
|
||||
Where foo is the name of the splashscreen file, preferably a 9 patch file. Make sure to add your splashcreen files to your res/xml directory under the appropriate folders. The second parameter represents how long the splashscreen will appear in milliseconds. It defaults to 3000 ms. See [Icons and Splash Screens](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html)
|
||||
for more information.
|
||||
Note also that this value used to be seconds, and not milliseconds, so values less than 30 will still be treated as seconds. ( Consider this a deprecated patch that will disapear in some future version. )
|
||||
|
||||
"SplashMaintainAspectRatio" preference is optional. If set to true, splash screen drawable is not stretched to fit screen, but instead simply "covers" the screen, like CSS "background-size:cover". This is very useful when splash screen images cannot be distorted in any way, for example when they contain scenery or text. This setting works best with images that have large margins (safe areas) that can be safely cropped on screens with different aspect ratios.
|
||||
To disable the splashscreen add the following preference to `config.xml`:
|
||||
```xml
|
||||
<preference name="SplashScreenDelay" value="0"/>
|
||||
```
|
||||
|
||||
The plugin reloads splash drawable whenever orientation changes, so you can specify different drawables for portrait and landscape orientations.
|
||||
**Windows Quirk**: You should disable the splashscreen in case you are updating the entire document body dynamically (f.e. with a SPA router) to avoid affecting UI/controls.
|
||||
Note that you should also directly reference `WinJS/base.js` in the page HTML in this case to avoid the issues with activation context ([CB-11658](https://issues.apache.org/jira/browse/CB-11658)).
|
||||
|
||||
"SplashShowOnlyFirstTime" preference is also optional and defaults to `true`. When set to `true` splash screen will only appear on application launch. However, if you plan to use `navigator.app.exitApp()` to close application and force splash screen appear on next launch, you should set this property to `false` (this also applies to closing the App with Back button).
|
||||
|
||||
### Browser Quirks
|
||||
|
||||
You can use the following preferences in your `config.xml`:
|
||||
|
||||
<platform name="browser">
|
||||
<preference name="SplashScreen" value="/images/browser/splashscreen.jpg" /> <!-- defaults to "/img/logo.png" -->
|
||||
<preference name="SplashScreenDelay" value="3000" /> <!-- defaults to "3000" -->
|
||||
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
|
||||
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
|
||||
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
|
||||
</platform>
|
||||
|
||||
__Note__: `SplashScreen` value should be absolute in order to work in a sub-page.
|
||||
|
||||
### Android and iOS Quirks
|
||||
**iOS Quirk**: to disable the splashscreen on `ios` platform you should also add `<preference name="FadeSplashScreenDuration" value="0"/>` to `config.xml`.
|
||||
|
||||
- `FadeSplashScreen` (boolean, defaults to `true`): Set to `false` to
|
||||
prevent the splash screen from fading in and out when its display
|
||||
state changes.
|
||||
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
```xml
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
```
|
||||
|
||||
- `FadeSplashScreenDuration` (float, defaults to `3000`): Specifies the
|
||||
- `FadeSplashScreenDuration` (float, defaults to `500`): Specifies the
|
||||
number of milliseconds for the splash screen fade effect to execute.
|
||||
|
||||
<preference name="FadeSplashScreenDuration" value="3000"/>
|
||||
|
||||
Note also that this value used to be seconds, and not milliseconds, so values less than 30 will still be treated as seconds. ( Consider this a deprecated patch that will disapear in some future version. )
|
||||
```xml
|
||||
<preference name="FadeSplashScreenDuration" value="750"/>
|
||||
```
|
||||
|
||||
_Note_: `FadeSplashScreenDuration` is included into `SplashScreenDelay`, for example if you have `<preference name="SplashScreenDelay" value="3000" />` and `<preference name="FadeSplashScreenDuration" value="1000"/>` defined in `config.xml`:
|
||||
|
||||
@@ -129,7 +425,65 @@ window.setTimeout(function () {
|
||||
- `ShowSplashScreenSpinner` (boolean, defaults to `true`): Set to `false`
|
||||
to hide the splash-screen spinner.
|
||||
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
```xml
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
```
|
||||
|
||||
### Android Quirks
|
||||
|
||||
In your `config.xml`, you can add the following preferences:
|
||||
|
||||
```xml
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
<preference name="SplashShowOnlyFirstTime" value="true|false" />
|
||||
<preference name="SplashScreenSpinnerColor" value="white" />
|
||||
```
|
||||
|
||||
"SplashMaintainAspectRatio" preference is optional. If set to true, splash screen drawable is not stretched to fit screen, but instead simply "covers" the screen, like CSS "background-size:cover". This is very useful when splash screen images cannot be distorted in any way, for example when they contain scenery or text. This setting works best with images that have large margins (safe areas) that can be safely cropped on screens with different aspect ratios.
|
||||
|
||||
The plugin reloads splash drawable whenever orientation changes, so you can specify different drawables for portrait and landscape orientations.
|
||||
|
||||
"SplashShowOnlyFirstTime" preference is also optional and defaults to `true`. When set to `true` splash screen will only appear on application launch. However, if you plan to use `navigator.app.exitApp()` to close application and force splash screen appear on next launch, you should set this property to `false` (this also applies to closing the App with Back button).
|
||||
|
||||
"SplashScreenSpinnerColor" preference is also optional and is ignored when not set. Setting it to a valid color name or HEX color code will change the color of the spinner on Android 5.0+ devices.
|
||||
|
||||
### Browser Quirks
|
||||
|
||||
You can use the following preferences in your `config.xml`:
|
||||
|
||||
```xml
|
||||
<platform name="browser">
|
||||
<preference name="SplashScreen" value="/images/browser/splashscreen.jpg" /> <!-- defaults to "/img/logo.png" -->
|
||||
<preference name="AutoHideSplashScreen" value="true" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenDelay" value="3000" /> <!-- defaults to "3000" -->
|
||||
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
|
||||
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
|
||||
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
|
||||
</platform>
|
||||
```
|
||||
|
||||
__Note__: `SplashScreen` value should be absolute in order to work in a sub-page. The `SplashScreen` value is used only for the browser platform. The value will be ignored for other platforms.
|
||||
|
||||
### iOS Quirks
|
||||
|
||||
- In iOS, the splashscreen images are called launch images. These images are mandatory on iOS.
|
||||
|
||||
### Windows Quirks
|
||||
|
||||
- `SplashScreenSpinnerColor` (string, defaults to system accent color): hash, rgb notation or CSS color name.
|
||||
|
||||
```xml
|
||||
<preference name="SplashScreenSpinnerColor" value="#242424"/>
|
||||
<preference name="SplashScreenSpinnerColor" value="DarkRed"/>
|
||||
<preference name="SplashScreenSpinnerColor" value="rgb(50,128,128)"/>
|
||||
```
|
||||
|
||||
- `SplashScreenBackgroundColor` (string, defaults to #464646): hex notation.
|
||||
|
||||
```xml
|
||||
<preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -140,7 +494,9 @@ window.setTimeout(function () {
|
||||
|
||||
Dismiss the splash screen.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
```js
|
||||
navigator.splashscreen.hide();
|
||||
```
|
||||
|
||||
|
||||
### BlackBerry 10, WP8, iOS Quirk
|
||||
@@ -149,16 +505,19 @@ The `config.xml` file's `AutoHideSplashScreen` setting must be
|
||||
`false`. To delay hiding the splash screen for two seconds, add a
|
||||
timer such as the following in the `deviceready` event handler:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
```js
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
```
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
Displays the splash screen.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
```js
|
||||
navigator.splashscreen.show();
|
||||
```
|
||||
|
||||
Your application cannot call `navigator.splashscreen.show()` until the app has
|
||||
started and the `deviceready` event has fired. But since typically the splash
|
||||
@@ -166,9 +525,7 @@ screen is meant to be visible before your app has started, that would seem to
|
||||
defeat the purpose of the splash screen. Providing some configuration in
|
||||
`config.xml` will automatically `show` the splash screen immediately after your
|
||||
app launch and before it has fully started and received the `deviceready`
|
||||
event. See [Icons and Splash Screens](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html)
|
||||
for more information on doing this configuration. For this reason, it is
|
||||
unlikely you need to call `navigator.splashscreen.show()` to make the splash
|
||||
event. For this reason, it is unlikely you need to call `navigator.splashscreen.show()` to make the splash
|
||||
screen visible for app startup.
|
||||
|
||||
[Apache Cordova issue tracker]: https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Splashscreen%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC
|
||||
|
||||
@@ -20,11 +20,62 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 4.1.0 (Nov 06, 2017)
|
||||
* [CB-13473](https://issues.apache.org/jira/browse/CB-13473) (CI) Removed **Browser** builds from AppVeyor
|
||||
* [CB-12011](https://issues.apache.org/jira/browse/CB-12011) (android) added the possibility to change the spinner color on **Android 5.0**+ apps
|
||||
* [CB-13028](https://issues.apache.org/jira/browse/CB-13028) (CI) **Browser** builds on Travis and AppVeyor
|
||||
* [CB-13094](https://issues.apache.org/jira/browse/CB-13094) (android) Don't show splash when activity being finished
|
||||
* [CB-11487](https://issues.apache.org/jira/browse/CB-11487) (browser) Documented `AutoHideSplashScreen` for **Browser**
|
||||
* [CB-11488](https://issues.apache.org/jira/browse/CB-11488) (browser) The `hide()` call became non re-entrant after the addition of fade out. This fixes the issue.
|
||||
* [CB-11487](https://issues.apache.org/jira/browse/CB-11487) (browser) The standard `AutoHideSplashScreen` `config.xml` property is now supported by the **Browser** platform.
|
||||
* [CB-11486](https://issues.apache.org/jira/browse/CB-11486) (browser) `splashScreenDelay` now feed through `parseInt` to ensure it is an integer by the time it's value is passed in to `setTimeout()` in `hide()`.
|
||||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
|
||||
|
||||
### 4.0.3 (Apr 27, 2017)
|
||||
* [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badge to `README`
|
||||
* [CB-12685](https://issues.apache.org/jira/browse/CB-12685) added `package.json` to tests folder
|
||||
|
||||
### 4.0.2 (Feb 28, 2017)
|
||||
* [CB-12353](https://issues.apache.org/jira/browse/CB-12353) Corrected merges usage in `plugin.xml`
|
||||
* [CB-12369](https://issues.apache.org/jira/browse/CB-12369) Add plugin typings from `DefinitelyTyped`
|
||||
* [CB-12363](https://issues.apache.org/jira/browse/CB-12363) Added build badges for **iOS 9.3** and **iOS 10.0**
|
||||
* [CB-12230](https://issues.apache.org/jira/browse/CB-12230) Removed **Windows 8.1** build badges
|
||||
|
||||
### 4.0.1 (Dec 07, 2016)
|
||||
* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 4.0.1
|
||||
* [CB-11751](https://issues.apache.org/jira/browse/CB-11751) 'extendedSplashScreen' is undefined Document that splashscreen needs to be disabled on Windows in case of updating entire document body
|
||||
* [CB-9287](https://issues.apache.org/jira/browse/CB-9287) Not enough Icons and Splashscreens for **Windows 8.1** and Windows Phone 8.1
|
||||
* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been submitted…"
|
||||
* [CB-11830](https://issues.apache.org/jira/browse/CB-11830) (iOS) Fix doc typos in PR#114
|
||||
* [CB-11829](https://issues.apache.org/jira/browse/CB-11829) (iOS) Support for CB-9762; docs (CB-11830)
|
||||
* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
|
||||
|
||||
### 4.0.0 (Sep 08, 2016)
|
||||
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
|
||||
* [CB-11326](https://issues.apache.org/jira/browse/CB-11326) Prevent crash when initializing plugin after navigating to another URL
|
||||
* Fix crash on **iOS** when reloading page from remote **Safari**
|
||||
* Add badges for paramedic builds on Jenkins
|
||||
* Add pull request template.
|
||||
* [CB-11179](https://issues.apache.org/jira/browse/CB-11179) Extend the windows-splashscreen docs
|
||||
* [CB-11159](https://issues.apache.org/jira/browse/CB-11159) Fix flaky splashscreen native tests
|
||||
* [CB-11156](https://issues.apache.org/jira/browse/CB-11156) Change default `FadeSplashScreenDuration` value
|
||||
* [CB-8056](https://issues.apache.org/jira/browse/CB-8056) Updated the dependency version, added it to the docs
|
||||
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
|
||||
* [CB-8056](https://issues.apache.org/jira/browse/CB-8056) Implement splashscreen for **Windows** platform
|
||||
* [CB-6498](https://issues.apache.org/jira/browse/CB-6498) Misleading documentation in **Android** Quirks
|
||||
|
||||
### 3.2.2 (Apr 15, 2016)
|
||||
* [CB-10979](https://issues.apache.org/jira/browse/CB-10979) Fix splashscreen **iOS** native tests. Added `jshintignore` for tests/ios
|
||||
* [CB-10895](https://issues.apache.org/jira/browse/CB-10895) Transparent Splashscreen view sometimes remains
|
||||
* [CB-10562](https://issues.apache.org/jira/browse/CB-10562) `hide()` not working in latest splashscreen plug in 3.1.0 in **iOS**
|
||||
* [CB-10688](https://issues.apache.org/jira/browse/CB-10688) Plugin Splashscreen Readme must have examples.
|
||||
* [CB-10864](https://issues.apache.org/jira/browse/CB-10864) Run **iOS** native tests on Travis
|
||||
|
||||
### 3.2.1 (Mar 09, 2016)
|
||||
* CB-10764: Remove emoji in cordova-plugin-splashscreen
|
||||
* CB-10650 Non-index content.src causes Splashscreen to be not displayed on ** Browser **
|
||||
* CB-10636 Add JSHint for plugins
|
||||
* CB-10606 fix deprecation warning for interfaceOrientation on ** iOS **
|
||||
* [CB-10764](https://issues.apache.org/jira/browse/CB-10764) Remove emoji in cordova-plugin-splashscreen
|
||||
* [CB-10650](https://issues.apache.org/jira/browse/CB-10650) Non-index content.src causes Splashscreen to be not displayed on **Browser**
|
||||
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add JSHint for plugins
|
||||
* [CB-10606](https://issues.apache.org/jira/browse/CB-10606) fix deprecation warning for interfaceOrientation on **iOS**
|
||||
* chore: edit package.json license to match SPDX id
|
||||
|
||||
### 3.2.0 (Feb 09, 2016)
|
||||
@@ -35,14 +86,14 @@
|
||||
* [CB-8396](https://issues.apache.org/jira/browse/CB-8396) Add AutoHideSplashScreen logic to Android's Splashscreen
|
||||
|
||||
### 3.1.0 (Jan 15, 2016)
|
||||
* CB-9538 Implementing `FadeSplashScreen` feature for **Android**
|
||||
* CB-9240 Cordova splash screen plugin **iPad** landscape mode issue
|
||||
* CB-10263 Fix splashscreen plugin filenames for Asset Catalog
|
||||
* CB-9374 **Android** add `SplashShowOnlyFirstTime` as preference
|
||||
* CB-10244 Don't rotate the **iPhone 6 Plus** splash
|
||||
* CB-9043 Fix the **ios** splashscreen being deformed on orientation change
|
||||
* CB-10079 Splashscreen plugin does not honor `SplashScreenDelay` on **iOS**
|
||||
* CB-10231 Fix `FadeSplashScreen` to default to true on **iOS**
|
||||
* [CB-9538](https://issues.apache.org/jira/browse/CB-9538) Implementing `FadeSplashScreen` feature for **Android**
|
||||
* [CB-9240](https://issues.apache.org/jira/browse/CB-9240) Cordova splash screen plugin **iPad** landscape mode issue
|
||||
* [CB-10263](https://issues.apache.org/jira/browse/CB-10263) Fix splashscreen plugin filenames for Asset Catalog
|
||||
* [CB-9374](https://issues.apache.org/jira/browse/CB-9374) **Android** add `SplashShowOnlyFirstTime` as preference
|
||||
* [CB-10244](https://issues.apache.org/jira/browse/CB-10244) Don't rotate the **iPhone 6 Plus** splash
|
||||
* [CB-9043](https://issues.apache.org/jira/browse/CB-9043) Fix the **ios** splashscreen being deformed on orientation change
|
||||
* [CB-10079](https://issues.apache.org/jira/browse/CB-10079) Splashscreen plugin does not honor `SplashScreenDelay` on **iOS**
|
||||
* [CB-10231](https://issues.apache.org/jira/browse/CB-10231) Fix `FadeSplashScreen` to default to true on **iOS**
|
||||
|
||||
### 3.0.0 (Nov 18, 2015)
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
|
||||
@@ -62,7 +113,7 @@
|
||||
* [CB-3562](https://issues.apache.org/jira/browse/CB-3562): Disable screen rotation for iPhone when splash screen is shown. (closes #47)
|
||||
* [CB-8988](https://issues.apache.org/jira/browse/CB-8988): Fix rotation on iOS/iPad (closes #46)
|
||||
* [CB-8904](https://issues.apache.org/jira/browse/CB-8904): Don't reset the static variable when it's destroyed, otherwise we might as well just have a member variable
|
||||
* Removed wp7 from plugin.xml and package.json
|
||||
* Removed wp7 from `plugin.xml` and package.json
|
||||
* [CB-8750](https://issues.apache.org/jira/browse/CB-8750) [wp8]: Rewrite resoultion helper
|
||||
* [CB-8750](https://issues.apache.org/jira/browse/CB-8750) [wp8]: Allow resolution-specific splashscreen images
|
||||
* [CB-8758](https://issues.apache.org/jira/browse/CB-8758) [wp8]: UnauthorizedAccessException on hide()
|
||||
@@ -114,7 +165,7 @@
|
||||
|
||||
### 0.3.3 (Sep 17, 2014)
|
||||
* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-splashscreen documentation translation
|
||||
* Renamed test dir, added nested plugin.xml
|
||||
* Renamed test dir, added nested `plugin.xml`
|
||||
* added documentation for manual tests
|
||||
* [CB-7196](https://issues.apache.org/jira/browse/CB-7196) port splashscreen tests to framework
|
||||
|
||||
@@ -160,7 +211,7 @@
|
||||
* [CB-5124](https://issues.apache.org/jira/browse/CB-5124) - Remove splashscreen config.xml values from iOS Configuration Docs, move to plugin docs
|
||||
|
||||
### 0.2.4 (Oct 28, 2013)
|
||||
* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): add repo + issue tag to plugin.xml for splashscreen plugin
|
||||
* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): add repo + issue tag to `plugin.xml` for splashscreen plugin
|
||||
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Incremented plugin version on dev branch.
|
||||
|
||||
### 0.2.3 (Oct 9, 2013)
|
||||
|
||||
24
package.json
24
package.json
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"name": "cordova-plugin-splashscreen",
|
||||
"version": "3.2.1",
|
||||
"version": "4.1.0",
|
||||
"description": "Cordova Splashscreen Plugin",
|
||||
"types": "./types/index.d.ts",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-splashscreen",
|
||||
"platforms": [
|
||||
@@ -20,6 +21,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/cordova-plugin-splashscreen"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://issues.apache.org/jira/browse/CB"
|
||||
},
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"splashscreen",
|
||||
@@ -38,12 +42,20 @@
|
||||
"test": "npm run jshint",
|
||||
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
|
||||
},
|
||||
"engines": [
|
||||
{
|
||||
"name": "cordova-android",
|
||||
"version": ">=3.6.0"
|
||||
"engines": {
|
||||
"cordovaDependencies": {
|
||||
"2.0.0": {
|
||||
"cordova-android": ">=3.6.0"
|
||||
},
|
||||
"4.0.0": {
|
||||
"cordova-android": ">=3.6.0",
|
||||
"cordova-windows": ">=4.4.0"
|
||||
},
|
||||
"5.0.0": {
|
||||
"cordova": ">100"
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-splashscreen"
|
||||
version="3.2.1">
|
||||
version="4.1.0">
|
||||
<name>Splashscreen</name>
|
||||
<description>Cordova Splashscreen Plugin</description>
|
||||
<license>Apache 2.0</license>
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
<engines>
|
||||
<engine name="cordova-android" version=">=3.6.0" /><!-- Requires CordovaPlugin.preferences -->
|
||||
<engine name="cordova-windows" version=">=4.4.0" />
|
||||
</engines>
|
||||
|
||||
<js-module src="www/splashscreen.js" name="SplashScreen">
|
||||
@@ -107,14 +108,14 @@
|
||||
<!-- windows8 -->
|
||||
<platform name="windows8">
|
||||
<js-module src="www/windows/SplashScreenProxy.js" name="SplashScreenProxy">
|
||||
<merges target="" />
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
<!-- windows -->
|
||||
<platform name="windows">
|
||||
<js-module src="www/windows/SplashScreenProxy.js" name="SplashScreenProxy">
|
||||
<merges target="" />
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Handler;
|
||||
@@ -52,6 +53,7 @@ public class SplashScreen extends CordovaPlugin {
|
||||
// Enable functionality only if running on 4.x.x.
|
||||
private static final boolean HAS_BUILT_IN_SPLASH_SCREEN = Integer.valueOf(CordovaWebView.CORDOVA_VERSION.split("\\.")[0]) < 4;
|
||||
private static final int DEFAULT_SPLASHSCREEN_DURATION = 3000;
|
||||
private static final int DEFAULT_FADE_DURATION = 500;
|
||||
private static Dialog splashDialog;
|
||||
private static ProgressDialog spinnerDialog;
|
||||
private static boolean firstShow = true;
|
||||
@@ -76,24 +78,32 @@ public class SplashScreen extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private int getSplashId() {
|
||||
int drawableId = 0;
|
||||
String splashResource = preferences.getString("SplashScreen", "screen");
|
||||
if (splashResource != null) {
|
||||
drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getClass().getPackage().getName());
|
||||
if (drawableId == 0) {
|
||||
drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getPackageName());
|
||||
}
|
||||
}
|
||||
return drawableId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void pluginInitialize() {
|
||||
if (HAS_BUILT_IN_SPLASH_SCREEN) {
|
||||
return;
|
||||
}
|
||||
// Make WebView invisible while loading URL
|
||||
getView().setVisibility(View.INVISIBLE);
|
||||
int drawableId = preferences.getInteger("SplashDrawableId", 0);
|
||||
if (drawableId == 0) {
|
||||
String splashResource = preferences.getString("SplashScreen", "screen");
|
||||
if (splashResource != null) {
|
||||
drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getClass().getPackage().getName());
|
||||
if (drawableId == 0) {
|
||||
drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getPackageName());
|
||||
}
|
||||
preferences.set("SplashDrawableId", drawableId);
|
||||
// CB-11326 Ensure we're calling this on UI thread
|
||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getView().setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
int drawableId = getSplashId();
|
||||
|
||||
// Save initial orientation.
|
||||
orientation = cordova.getActivity().getResources().getConfiguration().orientation;
|
||||
@@ -117,7 +127,7 @@ public class SplashScreen extends CordovaPlugin {
|
||||
|
||||
private int getFadeDuration () {
|
||||
int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) ?
|
||||
preferences.getInteger("FadeSplashScreenDuration", DEFAULT_SPLASHSCREEN_DURATION) : 0;
|
||||
preferences.getInteger("FadeSplashScreenDuration", DEFAULT_FADE_DURATION) : 0;
|
||||
|
||||
if (fadeSplashScreenDuration < 30) {
|
||||
// [CB-9750] This value used to be in decimal seconds, so we will assume that if someone specifies 10
|
||||
@@ -198,7 +208,7 @@ public class SplashScreen extends CordovaPlugin {
|
||||
|
||||
// Splash drawable may change with orientation, so reload it.
|
||||
if (splashImageView != null) {
|
||||
int drawableId = preferences.getInteger("SplashDrawableId", 0);
|
||||
int drawableId = getSplashId();
|
||||
if (drawableId != 0) {
|
||||
splashImageView.setImageDrawable(cordova.getActivity().getResources().getDrawable(drawableId));
|
||||
}
|
||||
@@ -256,13 +266,17 @@ public class SplashScreen extends CordovaPlugin {
|
||||
@SuppressWarnings("deprecation")
|
||||
private void showSplashScreen(final boolean hideAfterDelay) {
|
||||
final int splashscreenTime = preferences.getInteger("SplashScreenDelay", DEFAULT_SPLASHSCREEN_DURATION);
|
||||
final int drawableId = preferences.getInteger("SplashDrawableId", 0);
|
||||
final int drawableId = getSplashId();
|
||||
|
||||
final int fadeSplashScreenDuration = getFadeDuration();
|
||||
final int effectiveSplashDuration = Math.max(0, splashscreenTime - fadeSplashScreenDuration);
|
||||
|
||||
lastHideAfterDelay = hideAfterDelay;
|
||||
|
||||
// Prevent to show the splash dialog if the activity is in the process of finishing
|
||||
if (cordova.getActivity().isFinishing()) {
|
||||
return;
|
||||
}
|
||||
// If the splash dialog is showing don't try to show it again
|
||||
if (splashDialog != null && splashDialog.isShowing()) {
|
||||
return;
|
||||
@@ -354,6 +368,27 @@ public class SplashScreen extends CordovaPlugin {
|
||||
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
|
||||
progressBar.setLayoutParams(layoutParams);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
String colorName = preferences.getString("SplashScreenSpinnerColor", null);
|
||||
if(colorName != null){
|
||||
int[][] states = new int[][] {
|
||||
new int[] { android.R.attr.state_enabled}, // enabled
|
||||
new int[] {-android.R.attr.state_enabled}, // disabled
|
||||
new int[] {-android.R.attr.state_checked}, // unchecked
|
||||
new int[] { android.R.attr.state_pressed} // pressed
|
||||
};
|
||||
int progressBarColor = Color.parseColor(colorName);
|
||||
int[] colors = new int[] {
|
||||
progressBarColor,
|
||||
progressBarColor,
|
||||
progressBarColor,
|
||||
progressBarColor
|
||||
};
|
||||
ColorStateList colorStateList = new ColorStateList(states, colors);
|
||||
progressBar.setIndeterminateTintList(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
centeredLayout.addView(progressBar);
|
||||
|
||||
spinnerDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
|
||||
@@ -31,6 +31,7 @@ var splashScreenDelay = 3000; // in milliseconds
|
||||
var showSplashScreen = true; // show splashcreen by default
|
||||
var cordova = require('cordova');
|
||||
var configHelper = cordova.require('cordova/confighelper');
|
||||
var autoHideSplashScreen = true;
|
||||
|
||||
function updateImageLocation() {
|
||||
position.width = Math.min(splashImageWidth, window.innerWidth);
|
||||
@@ -66,6 +67,7 @@ var SplashScreen = {
|
||||
localSplash = document.createElement("div");
|
||||
localSplash.style.backgroundColor = bgColor;
|
||||
localSplash.style.position = "absolute";
|
||||
localSplash.style["z-index"] = "99999";
|
||||
|
||||
localSplashImage = document.createElement("img");
|
||||
localSplashImage.src = imageSrc;
|
||||
@@ -75,13 +77,34 @@ var SplashScreen = {
|
||||
|
||||
localSplash.appendChild(localSplashImage);
|
||||
document.body.appendChild(localSplash);
|
||||
|
||||
// deviceready fires earlier than the plugin init on cold-start
|
||||
if (SplashScreen.shouldHideImmediately) {
|
||||
SplashScreen.shouldHideImmediately = false;
|
||||
window.setTimeout(function () {
|
||||
SplashScreen.hide();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
},
|
||||
hide: function () {
|
||||
if(localSplash) {
|
||||
window.removeEventListener("resize", onResize, false);
|
||||
document.body.removeChild(localSplash);
|
||||
var innerLocalSplash = localSplash;
|
||||
localSplash = null;
|
||||
window.removeEventListener("resize", onResize, false);
|
||||
|
||||
innerLocalSplash.style.opacity = '0';
|
||||
innerLocalSplash.style["-webkit-transition"] = "opacity 1s ease-in-out";
|
||||
innerLocalSplash.style["-moz-transition"] = "opacity 1s ease-in-out";
|
||||
innerLocalSplash.style["-ms-transition"] = "opacity 1s ease-in-out";
|
||||
innerLocalSplash.style["-o-transition"] = "opacity 1s ease-in-out";
|
||||
|
||||
window.setTimeout(function () {
|
||||
document.body.removeChild(innerLocalSplash);
|
||||
innerLocalSplash = null;
|
||||
}, 1000);
|
||||
} else {
|
||||
SplashScreen.shouldHideImmediately = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -97,12 +120,16 @@ function readPreferencesFromCfg(cfg) {
|
||||
}
|
||||
|
||||
splashScreenDelay = cfg.getPreferenceValue('SplashScreenDelay') || splashScreenDelay;
|
||||
splashScreenDelay = parseInt(splashScreenDelay, 10);
|
||||
|
||||
imageSrc = cfg.getPreferenceValue('SplashScreen') || imageSrc;
|
||||
bgColor = cfg.getPreferenceValue('SplashScreenBackgroundColor') || bgColor;
|
||||
splashImageWidth = cfg.getPreferenceValue('SplashScreenWidth') || splashImageWidth;
|
||||
splashImageHeight = cfg.getPreferenceValue('SplashScreenHeight') || splashImageHeight;
|
||||
autoHideSplashScreen = cfg.getPreferenceValue('AutoHideSplashScreen') || autoHideSplashScreen;
|
||||
autoHideSplashScreen = (autoHideSplashScreen === true || autoHideSplashScreen.toLowerCase() === 'true');
|
||||
} catch(e) {
|
||||
var msg = '[Browser][SplashScreen] Error occured on loading preferences from config.xml: ' + JSON.stringify(e);
|
||||
var msg = '[Browser][SplashScreen] Error occurred on loading preferences from config.xml: ' + JSON.stringify(e);
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
@@ -121,12 +148,17 @@ function showAndHide() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to read config.xml and override default properties and then shows and hides splashcreen if it is enabled.
|
||||
* Tries to read config.xml and override default properties and then shows and hides splashscreen if it is enabled.
|
||||
*/
|
||||
(function initAndShow() {
|
||||
configHelper.readConfig(function(config) {
|
||||
readPreferencesFromCfg(config);
|
||||
showAndHide();
|
||||
if (autoHideSplashScreen) {
|
||||
showAndHide();
|
||||
} else {
|
||||
SplashScreen.show();
|
||||
}
|
||||
|
||||
}, function(err) {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef struct {
|
||||
UIImageView* _imageView;
|
||||
NSString* _curImageName;
|
||||
BOOL _visible;
|
||||
BOOL _destroyed;
|
||||
}
|
||||
|
||||
- (void)show:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#import "CDVViewController+SplashScreen.h"
|
||||
|
||||
#define kSplashScreenDurationDefault 3000.0f
|
||||
#define kFadeDurationDefault 500.0f
|
||||
|
||||
|
||||
@implementation CDVSplashScreen
|
||||
@@ -41,7 +42,7 @@
|
||||
|
||||
- (void)hide:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
[self setVisible:NO];
|
||||
[self setVisible:NO andForce:YES];
|
||||
}
|
||||
|
||||
- (void)pageDidLoad
|
||||
@@ -76,7 +77,7 @@
|
||||
BOOL autorotateValue = (device.iPad || device.iPhone6Plus) ?
|
||||
[(CDVViewController *)self.viewController shouldAutorotateDefaultValue] :
|
||||
NO;
|
||||
|
||||
|
||||
[(CDVViewController *)self.viewController setEnabledAutorotation:autorotateValue];
|
||||
|
||||
NSString* topActivityIndicator = [self.commandDelegate.settings objectForKey:[@"TopActivityIndicator" lowercaseString]];
|
||||
@@ -120,6 +121,7 @@
|
||||
[parentView addObserver:self forKeyPath:@"bounds" options:0 context:nil];
|
||||
|
||||
[self updateImage];
|
||||
_destroyed = NO;
|
||||
}
|
||||
|
||||
- (void)hideViews
|
||||
@@ -130,6 +132,7 @@
|
||||
|
||||
- (void)destroyViews
|
||||
{
|
||||
_destroyed = YES;
|
||||
[(CDVViewController *)self.viewController setEnabledAutorotation:[(CDVViewController *)self.viewController shouldAutorotateDefaultValue]];
|
||||
|
||||
[_imageView removeFromSuperview];
|
||||
@@ -139,20 +142,28 @@
|
||||
_curImageName = nil;
|
||||
|
||||
self.viewController.view.userInteractionEnabled = YES; // re-enable user interaction upon completion
|
||||
[self.viewController.view removeObserver:self forKeyPath:@"frame"];
|
||||
[self.viewController.view removeObserver:self forKeyPath:@"bounds"];
|
||||
@try {
|
||||
[self.viewController.view removeObserver:self forKeyPath:@"frame"];
|
||||
[self.viewController.view removeObserver:self forKeyPath:@"bounds"];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
// When reloading the page from a remotely connected Safari, there
|
||||
// are no observers, so the removeObserver method throws an exception,
|
||||
// that we can safely ignore.
|
||||
// Alternatively we can check whether there are observers before calling removeObserver
|
||||
}
|
||||
}
|
||||
|
||||
- (CDV_iOSDevice) getCurrentDevice
|
||||
{
|
||||
CDV_iOSDevice device;
|
||||
|
||||
|
||||
UIScreen* mainScreen = [UIScreen mainScreen];
|
||||
CGFloat mainScreenHeight = mainScreen.bounds.size.height;
|
||||
CGFloat mainScreenWidth = mainScreen.bounds.size.width;
|
||||
|
||||
|
||||
int limit = MAX(mainScreenHeight,mainScreenWidth);
|
||||
|
||||
|
||||
device.iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
|
||||
device.iPhone = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone);
|
||||
device.retina = ([mainScreen scale] == 2.0);
|
||||
@@ -163,23 +174,38 @@
|
||||
// this is appropriate for detecting the runtime screen environment
|
||||
device.iPhone6 = (device.iPhone && limit == 667.0);
|
||||
device.iPhone6Plus = (device.iPhone && limit == 736.0);
|
||||
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
- (BOOL) isUsingCDVLaunchScreen {
|
||||
NSString* launchStoryboardName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
|
||||
if (launchStoryboardName) {
|
||||
return ([launchStoryboardName isEqualToString:@"CDVLaunchScreen"]);
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id<CDVScreenOrientationDelegate>)orientationDelegate device:(CDV_iOSDevice)device
|
||||
{
|
||||
// Use UILaunchImageFile if specified in plist. Otherwise, use Default.
|
||||
NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
|
||||
|
||||
|
||||
// detect if we are using CB-9762 Launch Storyboard; if so, return the associated image instead
|
||||
if ([self isUsingCDVLaunchScreen]) {
|
||||
imageName = @"LaunchStoryboard";
|
||||
return imageName;
|
||||
}
|
||||
|
||||
NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations];
|
||||
|
||||
|
||||
// Checks to see if the developer has locked the orientation to use only one of Portrait or Landscape
|
||||
BOOL supportsLandscape = (supportedOrientations & UIInterfaceOrientationMaskLandscape);
|
||||
BOOL supportsPortrait = (supportedOrientations & UIInterfaceOrientationMaskPortrait || supportedOrientations & UIInterfaceOrientationMaskPortraitUpsideDown);
|
||||
// this means there are no mixed orientations in there
|
||||
BOOL isOrientationLocked = !(supportsPortrait && supportsLandscape);
|
||||
|
||||
|
||||
if (imageName)
|
||||
{
|
||||
imageName = [imageName stringByDeletingPathExtension];
|
||||
@@ -248,7 +274,7 @@
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
imageName = [imageName stringByAppendingString:@"-Landscape"];
|
||||
break;
|
||||
|
||||
|
||||
case UIInterfaceOrientationPortrait:
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
default:
|
||||
@@ -257,7 +283,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return imageName;
|
||||
}
|
||||
|
||||
@@ -323,6 +349,14 @@
|
||||
|
||||
- (void)updateBounds
|
||||
{
|
||||
if ([self isUsingCDVLaunchScreen]) {
|
||||
// CB-9762's launch screen expects the image to fill the screen and be scaled using AspectFill.
|
||||
CGSize viewportSize = [UIApplication sharedApplication].delegate.window.bounds.size;
|
||||
_imageView.frame = CGRectMake(0, 0, viewportSize.width, viewportSize.height);
|
||||
_imageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
return;
|
||||
}
|
||||
|
||||
UIImage* img = _imageView.image;
|
||||
CGRect imgBounds = (img) ? CGRectMake(0, 0, img.size.width, img.size.height) : CGRectZero;
|
||||
|
||||
@@ -376,14 +410,19 @@
|
||||
|
||||
- (void)setVisible:(BOOL)visible
|
||||
{
|
||||
if (visible != _visible)
|
||||
[self setVisible:visible andForce:NO];
|
||||
}
|
||||
|
||||
- (void)setVisible:(BOOL)visible andForce:(BOOL)force
|
||||
{
|
||||
if (visible != _visible || force)
|
||||
{
|
||||
_visible = visible;
|
||||
|
||||
id fadeSplashScreenValue = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreen" lowercaseString]];
|
||||
id fadeSplashScreenDuration = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreenDuration" lowercaseString]];
|
||||
|
||||
float fadeDuration = fadeSplashScreenDuration == nil ? kSplashScreenDurationDefault : [fadeSplashScreenDuration floatValue];
|
||||
float fadeDuration = fadeSplashScreenDuration == nil ? kFadeDurationDefault : [fadeSplashScreenDuration floatValue];
|
||||
|
||||
id splashDurationString = [self.commandDelegate.settings objectForKey: [@"SplashScreenDelay" lowercaseString]];
|
||||
float splashDuration = splashDurationString == nil ? kSplashScreenDurationDefault : [splashDurationString floatValue];
|
||||
@@ -433,26 +472,32 @@
|
||||
__weak __typeof(self) weakSelf = self;
|
||||
float effectiveSplashDuration;
|
||||
|
||||
if (!autoHideSplashScreen) {
|
||||
// [CB-10562] AutoHideSplashScreen may be "true" but we should still be able to hide the splashscreen manually.
|
||||
if (!autoHideSplashScreen || force) {
|
||||
effectiveSplashDuration = (fadeDuration) / 1000;
|
||||
} else {
|
||||
effectiveSplashDuration = (splashDuration - fadeDuration) / 1000;
|
||||
}
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (uint64_t) effectiveSplashDuration * NSEC_PER_SEC), dispatch_get_main_queue(), CFBridgingRelease(CFBridgingRetain(^(void) {
|
||||
[UIView transitionWithView:self.viewController.view
|
||||
duration:(fadeDuration / 1000)
|
||||
options:UIViewAnimationOptionTransitionNone
|
||||
animations:^(void) {
|
||||
[weakSelf hideViews];
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
if (finished) {
|
||||
[weakSelf destroyViews];
|
||||
// TODO: It might also be nice to have a js event happen here -jm
|
||||
}
|
||||
}
|
||||
if (!_destroyed) {
|
||||
[UIView transitionWithView:self.viewController.view
|
||||
duration:(fadeDuration / 1000)
|
||||
options:UIViewAnimationOptionTransitionNone
|
||||
animations:^(void) {
|
||||
[weakSelf hideViews];
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
// Always destroy views, otherwise you could have an
|
||||
// invisible splashscreen that is overlayed over your active views
|
||||
// which causes that no touch events are passed
|
||||
if (!_destroyed) {
|
||||
[weakSelf destroyViews];
|
||||
// TODO: It might also be nice to have a js event happen here -jm
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache Version 2.0",
|
||||
"dependencies": {
|
||||
"cordova-ios": "^3.6.0"
|
||||
"cordova-ios": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xcodebuild test -workspace CDVSplashScreenTest.xcworkspace -scheme CDVSplashScreenLibTests -destination 'platform=iOS Simulator,name=iPhone 5' CONFIGURATION_BUILD_DIR='/tmp'"
|
||||
}
|
||||
}
|
||||
"test": "xcodebuild test -workspace CDVSplashScreenTest.xcworkspace -scheme CDVSplashScreenLibTests -destination 'platform=iOS Simulator,name=iPhone 5' CONFIGURATION_BUILD_DIR='/tmp' HEADER_SEARCH_PATHS='$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include'"
|
||||
}
|
||||
}
|
||||
|
||||
14
tests/package.json
Normal file
14
tests/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "cordova-plugin-splashscreen-tests",
|
||||
"version": "4.0.3-dev",
|
||||
"description": "",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-splashscreen-tests",
|
||||
"platforms": []
|
||||
},
|
||||
"keywords": [
|
||||
"ecosystem:cordova"
|
||||
],
|
||||
"author": "",
|
||||
"license": "Apache 2.0"
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-splashscreen-tests"
|
||||
version="3.2.1">
|
||||
version="4.1.0">
|
||||
<name>Cordova Splashscreen Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
|
||||
17
types/index.d.ts
vendored
Normal file
17
types/index.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Type definitions for Apache Cordova Splashscreen plugin
|
||||
// Project: https://github.com/apache/cordova-plugin-splashscreen
|
||||
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
//
|
||||
// Copyright (c) Microsoft Open Technologies Inc
|
||||
// Licensed under the MIT license.
|
||||
|
||||
interface Navigator {
|
||||
/** This plugin displays and hides a splash screen during application launch. */
|
||||
splashscreen: {
|
||||
/** Dismiss the splash screen. */
|
||||
hide(): void;
|
||||
/** Displays the splash screen. */
|
||||
show(): void;
|
||||
}
|
||||
}
|
||||
@@ -20,56 +20,15 @@
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true */
|
||||
/*global WinJS */
|
||||
|
||||
var cordova = require('cordova');
|
||||
|
||||
var isPhone = (cordova.platformId == "windows") && WinJS.Utilities.isPhone;
|
||||
var isHosted = window.location.protocol.indexOf('http') === 0;
|
||||
var localSplash = null, localSplashImage = null;
|
||||
var bgColor = "#464646"; // default backgrond color; TDOO - read it from .appxmanifest
|
||||
var splashImageSrc = (isHosted ? "ms-appx-web" : "ms-appx") + ":///images/" +
|
||||
(isPhone ? "splashscreenphone.png" : "splashscreen.png");
|
||||
var splash = require('cordova/splashscreen');
|
||||
|
||||
var SplashScreen = {
|
||||
setBGColor: function (cssBGColor) {
|
||||
bgColor = cssBGColor;
|
||||
if (localSplash) {
|
||||
localSplash.style.backgroundColor = bgColor;
|
||||
}
|
||||
},
|
||||
show: function () {
|
||||
if (localSplash) {
|
||||
return; // already showed
|
||||
}
|
||||
|
||||
localSplash = document.createElement("div");
|
||||
localSplash.style.backgroundColor = bgColor;
|
||||
localSplash.style.position = "fixed";
|
||||
localSplash.style.top = "0";
|
||||
localSplash.style.width = "100%";
|
||||
localSplash.style.height = "100%";
|
||||
|
||||
localSplashImage = document.createElement("img");
|
||||
localSplashImage.src = splashImageSrc;
|
||||
localSplashImage.style.maxWidth = "100%";
|
||||
localSplashImage.style.maxHeight = "100%";
|
||||
// center horizontally
|
||||
localSplashImage.style.margin = "0 auto";
|
||||
localSplashImage.style.display = "block";
|
||||
// center vertically
|
||||
localSplashImage.style.position = "relative";
|
||||
localSplashImage.style.top = "50%";
|
||||
localSplashImage.style.transform = "translateY(-50%)";
|
||||
|
||||
localSplash.appendChild(localSplashImage);
|
||||
document.body.appendChild(localSplash);
|
||||
splash.show();
|
||||
},
|
||||
hide: function () {
|
||||
if (localSplash) {
|
||||
document.body.removeChild(localSplash);
|
||||
localSplash = null;
|
||||
}
|
||||
splash.hide();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user