CB-11156 Change default FadeSplashScreenDuration value

This commit is contained in:
daserge 2016-04-27 11:55:31 +03:00
parent 3d924fce1b
commit 4adff6f1c9
3 changed files with 17 additions and 14 deletions

View File

@ -129,6 +129,8 @@ projectRoot
<preference name="SplashScreenDelay" value="3000" /> <preference name="SplashScreenDelay" 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. )
- `FadeSplashScreen` (boolean, defaults to `true`): Set to `false` to - `FadeSplashScreen` (boolean, defaults to `true`): Set to `false` to
prevent the splash screen from fading in and out when its display prevent the splash screen from fading in and out when its display
state changes. state changes.
@ -137,15 +139,13 @@ projectRoot
<preference name="FadeSplashScreen" value="false"/> <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. number of milliseconds for the splash screen fade effect to execute.
```xml ```xml
<preference name="FadeSplashScreenDuration" value="3000"/> <preference name="FadeSplashScreenDuration" value="750"/>
``` ```
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`: _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:00 - splashscreen is shown
@ -172,16 +172,13 @@ window.setTimeout(function () {
### Android Quirks ### Android Quirks
In your `config.xml`, you need to add the following preferences: In your `config.xml`, you can add the following preferences:
```xml ```xml
<preference name="SplashScreenDelay" value="3000" />
<preference name="SplashMaintainAspectRatio" value="true|false" /> <preference name="SplashMaintainAspectRatio" value="true|false" />
<preference name="SplashShowOnlyFirstTime" 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. "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. The plugin reloads splash drawable whenever orientation changes, so you can specify different drawables for portrait and landscape orientations.
@ -213,13 +210,17 @@ __Note__: `SplashScreen` value should be absolute in order to work in a sub-page
- `SplashScreenSpinnerColor` (string, defaults to system accent color): hash, rgb notation or CSS color name. - `SplashScreenSpinnerColor` (string, defaults to system accent color): hash, rgb notation or CSS color name.
<preference name="SplashScreenSpinnerColor" value="#242424"/> ```xml
<preference name="SplashScreenSpinnerColor" value="DarkRed"/> <preference name="SplashScreenSpinnerColor" value="#242424"/>
<preference name="SplashScreenSpinnerColor" value="rgb(50,128,128)"/> <preference name="SplashScreenSpinnerColor" value="DarkRed"/>
<preference name="SplashScreenSpinnerColor" value="rgb(50,128,128)"/>
```
- `SplashScreenBackgroundColor` (string, defaults to #464646): hex notation. - `SplashScreenBackgroundColor` (string, defaults to #464646): hex notation.
<preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/> ```xml
<preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
```
## Methods ## Methods

View File

@ -52,6 +52,7 @@ public class SplashScreen extends CordovaPlugin {
// Enable functionality only if running on 4.x.x. // 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 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_SPLASHSCREEN_DURATION = 3000;
private static final int DEFAULT_FADE_DURATION = 500;
private static Dialog splashDialog; private static Dialog splashDialog;
private static ProgressDialog spinnerDialog; private static ProgressDialog spinnerDialog;
private static boolean firstShow = true; private static boolean firstShow = true;
@ -117,7 +118,7 @@ public class SplashScreen extends CordovaPlugin {
private int getFadeDuration () { private int getFadeDuration () {
int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) ? int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) ?
preferences.getInteger("FadeSplashScreenDuration", DEFAULT_SPLASHSCREEN_DURATION) : 0; preferences.getInteger("FadeSplashScreenDuration", DEFAULT_FADE_DURATION) : 0;
if (fadeSplashScreenDuration < 30) { if (fadeSplashScreenDuration < 30) {
// [CB-9750] This value used to be in decimal seconds, so we will assume that if someone specifies 10 // [CB-9750] This value used to be in decimal seconds, so we will assume that if someone specifies 10

View File

@ -23,6 +23,7 @@
#import "CDVViewController+SplashScreen.h" #import "CDVViewController+SplashScreen.h"
#define kSplashScreenDurationDefault 3000.0f #define kSplashScreenDurationDefault 3000.0f
#define kFadeDurationDefault 500.0f
@implementation CDVSplashScreen @implementation CDVSplashScreen
@ -390,7 +391,7 @@
id fadeSplashScreenValue = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreen" lowercaseString]]; id fadeSplashScreenValue = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreen" lowercaseString]];
id fadeSplashScreenDuration = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreenDuration" 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]]; id splashDurationString = [self.commandDelegate.settings objectForKey: [@"SplashScreenDelay" lowercaseString]];
float splashDuration = splashDurationString == nil ? kSplashScreenDurationDefault : [splashDurationString floatValue]; float splashDuration = splashDurationString == nil ? kSplashScreenDurationDefault : [splashDurationString floatValue];