mirror of
https://github.com/apache/cordova-plugin-splashscreen.git
synced 2026-02-05 00:01:30 +08:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e43615e25 | ||
|
|
ac39b04b6f | ||
|
|
66f7ee34d1 | ||
|
|
41ca5809b1 | ||
|
|
0a8b5be3d1 | ||
|
|
d65c0c7cc5 | ||
|
|
4102589bd5 | ||
|
|
1eac08c558 | ||
|
|
80b01049c8 | ||
|
|
4adff6f1c9 | ||
|
|
3d924fce1b | ||
|
|
6a737203da | ||
|
|
acb45f3a38 | ||
|
|
8d66b9e353 | ||
|
|
edb6c3d6f8 |
23
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
23
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<!--
|
||||
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
|
||||
- [ ] [ICLA](http://www.apache.org/licenses/icla.txt) has been signed and submitted to secretary@apache.org.
|
||||
- [ ] [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,8 +1,9 @@
|
||||
language: objective-c
|
||||
osx_image: xcode7
|
||||
sudo: false
|
||||
node_js:
|
||||
- "4.2"
|
||||
env:
|
||||
- TEST_DIR=.
|
||||
- TEST_DIR=./tests/ios
|
||||
script: cd $TEST_DIR && npm install && npm test
|
||||
script: cd $TEST_DIR && npm install && (npm test || npm test)
|
||||
|
||||
135
README.md
135
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,7 +21,9 @@
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-splashscreen)
|
||||
|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI |
|
||||
|:-:|:-:|:-:|:-:|:-:|:-:|
|
||||
|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-splashscreen/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-splashscreen/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-splashscreen/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-splashscreen/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-splashscreen/)|[](https://travis-ci.org/apache/cordova-plugin-splashscreen)|
|
||||
|
||||
# cordova-plugin-splashscreen
|
||||
|
||||
@@ -40,14 +46,33 @@ 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.
|
||||
|
||||
## 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 directory and not to the www directory. You can name the source image whatever you like. The internal name in the app is determined by Cordova.
|
||||
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">
|
||||
@@ -96,30 +121,75 @@ Please notice that the value of the "src" attribute is relative to the project d
|
||||
|
||||
#### config.xml
|
||||
|
||||
- __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.
|
||||
- `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.
|
||||
|
||||
```xml
|
||||
<preference name="AutoHideSplashScreen" value="true" />
|
||||
```
|
||||
|
||||
- __SplashScreenDelay__ (number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen.
|
||||
- `SplashScreenDelay` (number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen.
|
||||
|
||||
```xml
|
||||
<preference name="SplashScreenDelay" value="3000" />
|
||||
```
|
||||
|
||||
### Android Quirks
|
||||
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. )
|
||||
|
||||
In your `config.xml`, you need to add the following preferences:
|
||||
To disable the splashscreen add the following preference to `config.xml`:
|
||||
```xml
|
||||
<preference name="SplashScreenDelay" value="0"/>
|
||||
```
|
||||
|
||||
**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.
|
||||
|
||||
```xml
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
```
|
||||
|
||||
- `FadeSplashScreenDuration` (float, defaults to `500`): Specifies the
|
||||
number of milliseconds for the splash screen fade effect to execute.
|
||||
|
||||
```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`:
|
||||
|
||||
- 00:00 - splashscreen is shown
|
||||
- 00:02 - fading has started
|
||||
- 00:03 - splashscreen is hidden
|
||||
|
||||
Turning the fading off via `<preference name="FadeSplashScreen" value="false"/>` technically means fading duration to be `0` so that in this example the overall splash delay will still be 3 seconds.
|
||||
|
||||
_Note_: This only applies to the app startup - you need to take the fading timeout into account when manually showing/hiding the splashscreen in the code:
|
||||
|
||||
```javascript
|
||||
navigator.splashscreen.show();
|
||||
window.setTimeout(function () {
|
||||
navigator.splashscreen.hide();
|
||||
}, splashDuration - fadeDuration);
|
||||
```
|
||||
|
||||
- `ShowSplashScreenSpinner` (boolean, defaults to `true`): Set to `false`
|
||||
to hide the splash-screen spinner.
|
||||
|
||||
```xml
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
```
|
||||
|
||||
### Android Quirks
|
||||
|
||||
In your `config.xml`, you can add the following preferences:
|
||||
|
||||
```xml
|
||||
<preference name="SplashScreenDelay" value="3000" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
<preference name="SplashShowOnlyFirstTime" value="true|false" />
|
||||
```
|
||||
|
||||
The first parameter represents how long the splashscreen will appear in milliseconds. It defaults to 3000 ms.
|
||||
|
||||
"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.
|
||||
@@ -143,49 +213,24 @@ You can use the following preferences in your `config.xml`:
|
||||
|
||||
__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.
|
||||
|
||||
### Android and iOS Quirks
|
||||
### iOS Quirks
|
||||
|
||||
- In iOS, the splashscreen images are called launch images. These images are mandatory on iOS.
|
||||
|
||||
- `FadeSplashScreen` (boolean, defaults to `true`): Set to `false` to
|
||||
prevent the splash screen from fading in and out when its display
|
||||
state changes.
|
||||
### Windows Quirks
|
||||
|
||||
- `SplashScreenSpinnerColor` (string, defaults to system accent color): hash, rgb notation or CSS color name.
|
||||
|
||||
```xml
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
<preference name="SplashScreenSpinnerColor" value="#242424"/>
|
||||
<preference name="SplashScreenSpinnerColor" value="DarkRed"/>
|
||||
<preference name="SplashScreenSpinnerColor" value="rgb(50,128,128)"/>
|
||||
```
|
||||
|
||||
- `FadeSplashScreenDuration` (float, defaults to `3000`): Specifies the
|
||||
number of milliseconds for the splash screen fade effect to execute.
|
||||
- `SplashScreenBackgroundColor` (string, defaults to #464646): hex notation.
|
||||
|
||||
```xml
|
||||
<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. )
|
||||
|
||||
_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`:
|
||||
|
||||
- 00:00 - splashscreen is shown
|
||||
- 00:02 - fading has started
|
||||
- 00:03 - splashscreen is hidden
|
||||
|
||||
Turning the fading off via `<preference name="FadeSplashScreen" value="false"/>` technically means fading duration to be `0` so that in this example the overall splash delay will still be 3 seconds.
|
||||
|
||||
_Note_: This only applies to the app startup - you need to take the fading timeout into account when manually showing/hiding the splashscreen in the code:
|
||||
|
||||
```javascript
|
||||
navigator.splashscreen.show();
|
||||
window.setTimeout(function () {
|
||||
navigator.splashscreen.hide();
|
||||
}, splashDuration - fadeDuration);
|
||||
```
|
||||
|
||||
- `ShowSplashScreenSpinner` (boolean, defaults to `true`): Set to `false`
|
||||
to hide the splash-screen spinner.
|
||||
|
||||
```xml
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
<preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -20,12 +20,26 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 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 Fix splashscreen **iOS** native tests. Added `jshintignore` for tests/ios
|
||||
* CB-10895 Transparent Splashscreen view sometimes remains
|
||||
* CB-10562 `hide()` not working in latest splashscreen plug in 3.1.0 in **iOS**
|
||||
* CB-10688 Plugin Splashscreen Readme must have examples.
|
||||
* CB-10864 Run **iOS** native tests on Travis
|
||||
* [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](https://issues.apache.org/jira/browse/CB-10764) Remove emoji in cordova-plugin-splashscreen
|
||||
@@ -42,14 +56,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
|
||||
|
||||
20
package.json
20
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-plugin-splashscreen",
|
||||
"version": "3.2.2",
|
||||
"version": "4.0.0",
|
||||
"description": "Cordova Splashscreen Plugin",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-splashscreen",
|
||||
@@ -38,12 +38,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.2">
|
||||
version="4.0.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">
|
||||
|
||||
@@ -52,6 +52,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;
|
||||
@@ -82,7 +83,13 @@ public class SplashScreen extends CordovaPlugin {
|
||||
return;
|
||||
}
|
||||
// Make WebView invisible while loading URL
|
||||
getView().setVisibility(View.INVISIBLE);
|
||||
// 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 = preferences.getInteger("SplashDrawableId", 0);
|
||||
if (drawableId == 0) {
|
||||
String splashResource = preferences.getString("SplashScreen", "screen");
|
||||
@@ -117,7 +124,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
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#import "CDVViewController+SplashScreen.h"
|
||||
|
||||
#define kSplashScreenDurationDefault 3000.0f
|
||||
#define kFadeDurationDefault 500.0f
|
||||
|
||||
|
||||
@implementation CDVSplashScreen
|
||||
@@ -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]];
|
||||
@@ -141,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);
|
||||
@@ -165,7 +174,7 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -173,15 +182,15 @@
|
||||
{
|
||||
// Use UILaunchImageFile if specified in plist. Otherwise, use Default.
|
||||
NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
|
||||
|
||||
|
||||
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];
|
||||
@@ -250,7 +259,7 @@
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
imageName = [imageName stringByAppendingString:@"-Landscape"];
|
||||
break;
|
||||
|
||||
|
||||
case UIInterfaceOrientationPortrait:
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
default:
|
||||
@@ -259,7 +268,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return imageName;
|
||||
}
|
||||
|
||||
@@ -390,7 +399,7 @@
|
||||
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];
|
||||
@@ -456,7 +465,7 @@
|
||||
[weakSelf hideViews];
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
// Always destroy views, otherwise you could have an
|
||||
// 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) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-splashscreen-tests"
|
||||
version="3.2.2">
|
||||
version="4.0.0">
|
||||
<name>Cordova Splashscreen Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
|
||||
@@ -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