Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c2813f505 | ||
|
|
7c520181c3 | ||
|
|
a5d40d0a95 | ||
|
|
c2d22c0671 | ||
|
|
d799eda020 | ||
|
|
9541c1eb37 | ||
|
|
e73b59024a | ||
|
|
01edc0ead2 | ||
|
|
b998129669 | ||
|
|
c9ff4b428b | ||
|
|
75f78b9032 | ||
|
|
02492654ef | ||
|
|
4b757c8e73 | ||
|
|
71ea946746 | ||
|
|
1cfd009c91 | ||
|
|
6c12ea4380 | ||
|
|
8326da4ee2 | ||
|
|
b0543eee77 | ||
|
|
0b733d1797 | ||
|
|
c2dea2fc02 | ||
|
|
abc62a5eda | ||
|
|
2dc0f42b8f | ||
|
|
71a8c9cc33 | ||
|
|
52b6c539d3 | ||
|
|
10e7e9a1d5 | ||
|
|
f1aed7d844 | ||
|
|
87a701004d | ||
|
|
4ce42a0c99 | ||
|
|
d937fcb43b | ||
|
|
4275e57a73 | ||
|
|
1111c8b3b9 | ||
|
|
96d5875dc3 | ||
|
|
5f83eda5e8 |
23
CHANGELOG.md
23
CHANGELOG.md
@@ -1,23 +0,0 @@
|
||||
<!--
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
|
||||
32
README.md
32
README.md
@@ -1,18 +1,22 @@
|
||||
cordova-plugin-splashscreen
|
||||
----------------------------
|
||||
<!---
|
||||
license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
For Android,
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
In your config.xml, you need to add the following preference
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
`<preference name="splashscreen" value="foo" />`
|
||||
# org.apache.cordova.splashscreen
|
||||
|
||||
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.
|
||||
|
||||
For Android, you also have to edit your projects main java file. You must add a second parameter representing a time delay to your super.loadUrl.
|
||||
|
||||
`super.loadUrl(Config.getStartUrl(), 10000);`
|
||||
|
||||
To install this plugin, follow the [Command-line Interface Guide](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface).
|
||||
|
||||
If you are not using the Cordova Command-line Interface, follow [Using Plugman to Manage Plugins](http://cordova.apache.org/docs/en/edge/plugin_ref_plugman.md.html).
|
||||
Plugin documentation: [doc/index.md](doc/index.md)
|
||||
|
||||
47
RELEASENOTES.md
Normal file
47
RELEASENOTES.md
Normal file
@@ -0,0 +1,47 @@
|
||||
<!--
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 0.2.2 (Sept 25, 2013)
|
||||
* CB-4889 bumping&resetting version
|
||||
* CB-4889 renaming org.apache.cordova.core.splashscreen to org.apache.cordova.splashscreen
|
||||
* Rename CHANGELOG.md -> RELEASENOTES.md
|
||||
* [CB-4806] Update splashscreen image bounds for iOS 7
|
||||
* [CB-4752] Incremented plugin version on dev branch.
|
||||
|
||||
### 0.2.3 (Oct 9, 2013)
|
||||
* [CB-4806] (Re-fix) Update splashscreen image bounds for iOS 7
|
||||
* [CB-4934] plugin-splashscreen should not show by default on Windows8
|
||||
* [CB-4929] plugin-splashscreen not loading proxy windows8
|
||||
* [CB-4915] Incremented plugin version on dev branch.
|
||||
|
||||
### 0.2.4 (Oct 28, 2013)
|
||||
* CB-5128: add repo + issue tag to plugin.xml for splashscreen plugin
|
||||
* [CB-5010] Incremented plugin version on dev branch.
|
||||
|
||||
### 0.2.5 (Dec 4, 2013)
|
||||
* add ubuntu platform
|
||||
* Added amazon-fireos platform. Change to use amazon-fireos as a platform if the user agent string contains 'cordova-amazon-fireos'
|
||||
* CB-5124 - Remove splashscreen config.xml values from iOS Configuration Docs, move to plugin docs
|
||||
|
||||
### 0.2.6 (Jan 02, 2014)
|
||||
* CB-5658 Add doc/index.md for Splashscreen plugin
|
||||
* Handle error when splash image is missing.
|
||||
94
doc/index.md
Normal file
94
doc/index.md
Normal file
@@ -0,0 +1,94 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# org.apache.cordova.splashscreen
|
||||
|
||||
This plugin displays and hides a splash screen during application launch.
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add org.apache.cordova.splashscreen
|
||||
|
||||
|
||||
## Supported Platforms
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- iOS
|
||||
- Windows Phone 7 and 8
|
||||
- Windows 8
|
||||
|
||||
|
||||
## Methods
|
||||
|
||||
- splashscreen.show
|
||||
- splashscreen.hide
|
||||
|
||||
### Android Quirks
|
||||
|
||||
In your config.xml, you need to add the following preference
|
||||
|
||||
`<preference name="splashscreen" value="foo" />`
|
||||
|
||||
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.
|
||||
|
||||
For Android, you also have to edit your projects main java file. You must add a second parameter representing a time delay to your super.loadUrl.
|
||||
|
||||
`super.loadUrl(Config.getStartUrl(), 10000);`
|
||||
|
||||
## splashscreen.hide
|
||||
|
||||
Dismiss the splash screen.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### BlackBerry 10 Quirk
|
||||
|
||||
The `config.xml` file's `AutoHideSplashScreen` setting must be `false`.
|
||||
|
||||
### iOS Quirk
|
||||
|
||||
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);
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
Displays the splash screen.
|
||||
|
||||
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
|
||||
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
|
||||
screen visible for app startup.
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
---
|
||||
license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
---
|
||||
|
||||
hide
|
||||
===============
|
||||
|
||||
Dismiss the splash screen.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
navigator.splashscreen.hide() dismisses the applications splash screen.
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
|
||||
Quick Example
|
||||
-------------
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
Full Example
|
||||
------------
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Splashscreen Example</title>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
// Wait for Cordova to load
|
||||
//
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
|
||||
// Cordova is ready
|
||||
//
|
||||
function onDeviceReady() {
|
||||
navigator.splashscreen.hide();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Example</h1>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
iOS Quirk
|
||||
------------
|
||||
|
||||
1. In your **config.xml**, you need to [modify the value](guide_project-settings_index.md.html#Project%20Settings) for **"AutoHideSplashScreen”** to false
|
||||
|
||||
2. Then, if you want to delay hiding the splash screen for 2 seconds, you can do this in your **deviceready** event handler:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
@@ -1,90 +0,0 @@
|
||||
---
|
||||
license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
---
|
||||
|
||||
Splashscreen
|
||||
==========
|
||||
|
||||
> Enables developers to show/hide the application's splash screen.
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
- show
|
||||
- hide
|
||||
|
||||
Permissions
|
||||
-----------
|
||||
|
||||
### Android
|
||||
|
||||
#### app/res/xml/config.xml
|
||||
|
||||
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
|
||||
|
||||
### iOS
|
||||
|
||||
#### config.xml
|
||||
|
||||
<plugin name="SplashScreen" value="CDVSplashScreen" />
|
||||
|
||||
Setup
|
||||
-----
|
||||
|
||||
### Android
|
||||
|
||||
1. Copy your splash screen image into the res/drawable directories of your Android project. The sizes of each image should be:
|
||||
|
||||
- xlarge (xhdpi): at least 960 x 720
|
||||
- large (hdpi): at least 640 x 480
|
||||
- medium (mdpi): at least 470 x 320
|
||||
- small (ldpi): at least 426 x 320
|
||||
|
||||
It is highly recommended that you use a [9-patch image](https://developer.android.com/tools/help/draw9patch.html) for your splash screen.
|
||||
|
||||
2. In the onCreate method of the class that extends DroidGap add the following two lines:
|
||||
|
||||
super.setIntegerProperty("splashscreen", R.drawable.splash);
|
||||
super.loadUrl(Config.getStartUrl(), 10000);
|
||||
|
||||
The first line 'super.setIntegerProperty' sets the image to be displayed as the splashscreen. If you have named your image anything other than splash.png you will have to modify this line.
|
||||
The second line is the normal 'super.loadUrl' line but it has a second parameter which is the timeout value for the splash screen. In this example the splash screen will display for 10 seconds. If you want to dismiss the splash screen once you get the "deviceready" event you should call the navigator.splashscreen.hide() method.
|
||||
|
||||
### iOS
|
||||
|
||||
1. Copy your splash screen images into the **Resources/splash** directory of your iOS project. Only add the images for the devices you want to support (iPad screen size or iPhone screen size). The sizes of each image should be:
|
||||
|
||||
- Default-568h@2x~iphone.png (640x1136 pixels)
|
||||
- Default-Landscape@2x~ipad.png (2048x1496 pixels)
|
||||
- Default-Landscape~ipad.png (1024x748 pixels)
|
||||
- Default-Portrait@2x~ipad.png (1536x2008 pixels)
|
||||
- Default-Portrait~ipad.png (768x1004 pixels)
|
||||
- Default@2x~iphone.png (640x960 pixels)
|
||||
- Default~iphone.png (320x480 pixels)
|
||||
|
||||
### BlackBerry10
|
||||
|
||||
## Quirks
|
||||
|
||||
The SplashScreen BlackBerry10 plugin implements hide(), but show() is not possible using the built in OS mechanism. The advantage to using this is the splash screen is displayed before WebKit boots and issupports multiple images for various device resolutions and orientations.
|
||||
We also implemented the AutoHideSplashScreen config.xml value, similar to iOS.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
---
|
||||
license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
---
|
||||
|
||||
show
|
||||
===============
|
||||
|
||||
Displays the splash screen.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
navigator.splashscreen.show() displays the applications splash screen.
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
|
||||
Quick Example
|
||||
-------------
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
Full Example
|
||||
------------
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Splashscreen Example</title>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
// Wait for Cordova to load
|
||||
//
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
|
||||
// Cordova is ready
|
||||
//
|
||||
function onDeviceReady() {
|
||||
navigator.splashscreen.show();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Example</h1>
|
||||
</body>
|
||||
</html>
|
||||
23
plugin.xml
23
plugin.xml
@@ -1,12 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="org.apache.cordova.core.splashscreen"
|
||||
version="0.2.0">
|
||||
id="org.apache.cordova.splashscreen"
|
||||
version="0.2.6">
|
||||
<name>Splashscreen</name>
|
||||
<description>Cordova Splashscreen Plugin</description>
|
||||
<license>Apache 2.0</license>
|
||||
<keywords>cordova,splashscreen</keywords>
|
||||
<repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git</repo>
|
||||
<issue>https://issues.apache.org/jira/browse/CB/component/12320653</issue>
|
||||
|
||||
|
||||
<js-module src="www/splashscreen.js" name="SplashScreen">
|
||||
@@ -24,6 +26,23 @@
|
||||
<source-file src="src/android/SplashScreen.java" target-dir="src/org/apache/cordova/splashscreen" />
|
||||
</platform>
|
||||
|
||||
<!-- amazon-fireos -->
|
||||
<platform name="amazon-fireos">
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="SplashScreen">
|
||||
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/android/SplashScreen.java" target-dir="src/org/apache/cordova/splashscreen" />
|
||||
</platform>
|
||||
|
||||
<!-- ubuntu -->
|
||||
<platform name="ubuntu">
|
||||
<header-file src="src/ubuntu/splashscreen.h" />
|
||||
<source-file src="src/ubuntu/splashscreen.cpp" />
|
||||
</platform>
|
||||
|
||||
<!-- ios -->
|
||||
<platform name="ios">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
|
||||
@@ -163,15 +163,17 @@
|
||||
- (void)updateBounds
|
||||
{
|
||||
UIImage* img = _imageView.image;
|
||||
CGRect imgBounds = CGRectMake(0, 0, img.size.width, img.size.height);
|
||||
CGRect imgBounds = (img) ? CGRectMake(0, 0, img.size.width, img.size.height) : CGRectZero;
|
||||
|
||||
CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size;
|
||||
|
||||
// There's a special case when the image is the size of the screen.
|
||||
if (CGSizeEqualToSize(screenSize, imgBounds.size)) {
|
||||
CGRect statusFrame = [self.viewController.view convertRect:[UIApplication sharedApplication].statusBarFrame fromView:nil];
|
||||
imgBounds.origin.y -= statusFrame.size.height;
|
||||
} else {
|
||||
if (!(IsAtLeastiOSVersion(@"7.0"))) {
|
||||
imgBounds.origin.y -= statusFrame.size.height;
|
||||
}
|
||||
} else if (imgBounds.size.width > 0) {
|
||||
CGRect viewBounds = self.viewController.view.bounds;
|
||||
CGFloat imgAspect = imgBounds.size.width / imgBounds.size.height;
|
||||
CGFloat viewAspect = viewBounds.size.width / viewBounds.size.height;
|
||||
|
||||
42
src/ubuntu/splashscreen.cpp
Normal file
42
src/ubuntu/splashscreen.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2013 Canonical Ltd.
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QQuickItem>
|
||||
|
||||
#include "splashscreen.h"
|
||||
#include <cordova.h>
|
||||
|
||||
#define SPLASHSCREEN_STATE_NAME "splashscreen"
|
||||
|
||||
Splashscreen::Splashscreen(Cordova *cordova): CPlugin(cordova) {
|
||||
}
|
||||
|
||||
void Splashscreen::show(int, int) {
|
||||
m_cordova->rootObject()->setProperty("splashscreenPath", m_cordova->getSplashscreenPath());
|
||||
|
||||
m_cordova->pushViewState(SPLASHSCREEN_STATE_NAME);
|
||||
}
|
||||
|
||||
void Splashscreen::hide(int, int) {
|
||||
m_cordova->popViewState(SPLASHSCREEN_STATE_NAME);
|
||||
}
|
||||
52
src/ubuntu/splashscreen.h
Normal file
52
src/ubuntu/splashscreen.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2013 Canonical Ltd.
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPLASHSCREEN_H
|
||||
#define SPLASHSCREEN_H
|
||||
|
||||
#include <QtCore>
|
||||
#include <cplugin.h>
|
||||
|
||||
class Splashscreen: public CPlugin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Splashscreen(Cordova *cordova);
|
||||
|
||||
virtual const QString fullName() override {
|
||||
return Splashscreen::fullID();
|
||||
}
|
||||
|
||||
virtual const QString shortName() override {
|
||||
return "SplashScreen";
|
||||
}
|
||||
|
||||
static const QString fullID() {
|
||||
return "SplashScreen";
|
||||
}
|
||||
|
||||
public slots:
|
||||
void show(int, int);
|
||||
void hide(int, int);
|
||||
};
|
||||
|
||||
#endif // SPLASHSCREEN_H
|
||||
6
test/cordova-incl.js
vendored
6
test/cordova-incl.js
vendored
@@ -20,7 +20,9 @@
|
||||
*/
|
||||
|
||||
var PLAT;
|
||||
if (/Android/.exec(navigator.userAgent)) {
|
||||
if (/cordova-amazon-fireos/.exec(navigator.userAgent)) {
|
||||
PLAT = 'amazon-fireos';
|
||||
} else if (/Android/.exec(navigator.userAgent)) {
|
||||
PLAT = 'android';
|
||||
} else if (/(iPad)|(iPhone)|(iPod)/.exec(navigator.userAgent)) {
|
||||
PLAT = 'ios';
|
||||
@@ -61,7 +63,7 @@ if (!window._doNotWriteCordovaScript) {
|
||||
}
|
||||
|
||||
function backHome() {
|
||||
if (window.device && device.platform && device.platform.toLowerCase() == 'android') {
|
||||
if (window.device && device.platform && (device.platform.toLowerCase() == 'android' || device.platform.toLowerCase() == 'amazon-fireos')) {
|
||||
navigator.app.backHistory();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -19,75 +19,77 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*global Windows:true */
|
||||
/*jslint sloppy:true */
|
||||
/*global Windows:true, require, module, window, document, WinJS */
|
||||
|
||||
var cordova = require('cordova'),
|
||||
channel = require('cordova/channel');
|
||||
var cordova = require('cordova'),
|
||||
channel = require('cordova/channel');
|
||||
|
||||
/* This is the actual implementation part that returns the result on Windows 8
|
||||
*/
|
||||
|
||||
var position = { x: 0, y: 0, width: 0, height: 0 }; // defined by evt.detail.splashScreen.imageLocation
|
||||
var splash = null; //
|
||||
var localSplash; // the image to display
|
||||
var localSplashImage;
|
||||
var bgColor = "#464646";
|
||||
var position = { x: 0, y: 0, width: 0, height: 0 }; // defined by evt.detail.splashScreen.imageLocation
|
||||
var splash = null; //
|
||||
var localSplash; // the image to display
|
||||
var localSplashImage;
|
||||
var bgColor = "#464646";
|
||||
|
||||
function onResize(evt) {
|
||||
if (splash) {
|
||||
position = splash.imageLocation;
|
||||
updateImageLocation();
|
||||
|
||||
|
||||
function updateImageLocation() {
|
||||
localSplash.style.width = window.innerWidth + "px";
|
||||
localSplash.style.height = window.innerHeight + "px";
|
||||
localSplash.style.top = "0px";
|
||||
localSplash.style.left = "0px";
|
||||
|
||||
localSplashImage.style.top = position.y + "px";
|
||||
localSplashImage.style.left = position.x + "px";
|
||||
localSplashImage.style.height = position.height + "px";
|
||||
localSplashImage.style.width = position.width + "px";
|
||||
}
|
||||
|
||||
function onResize(evt) {
|
||||
if (splash) {
|
||||
position = splash.imageLocation;
|
||||
updateImageLocation();
|
||||
}
|
||||
}
|
||||
|
||||
var SplashScreen = {
|
||||
setBGColor: function (cssBGColor) {
|
||||
bgColor = cssBGColor;
|
||||
if (localSplash) {
|
||||
localSplash.style.backgroundColor = bgColor;
|
||||
}
|
||||
},
|
||||
show: function () {
|
||||
window.addEventListener("resize", onResize, false);
|
||||
localSplash = document.createElement("div");
|
||||
localSplash.style.backgroundColor = bgColor;
|
||||
localSplash.style.position = "absolute";
|
||||
|
||||
localSplashImage = document.createElement("img");
|
||||
localSplashImage.src = "img/splashscreen.png";
|
||||
localSplashImage.style.position = "absolute";
|
||||
|
||||
updateImageLocation();
|
||||
|
||||
localSplash.appendChild(localSplashImage);
|
||||
document.body.appendChild(localSplash);
|
||||
},
|
||||
hide: function () {
|
||||
window.removeEventListener("resize", onResize, false);
|
||||
document.body.removeChild(localSplash);
|
||||
localSplash = null;
|
||||
}
|
||||
};
|
||||
|
||||
function updateImageLocation() {
|
||||
localSplash.style.width = window.innerWidth + "px";
|
||||
localSplash.style.height = window.innerHeight + "px";
|
||||
localSplash.style.top = "0px";
|
||||
localSplash.style.left = "0px";
|
||||
|
||||
localSplashImage.style.top = position.y + "px";
|
||||
localSplashImage.style.left = position.x + "px";
|
||||
localSplashImage.style.height = position.height + "px";
|
||||
localSplashImage.style.width = position.width + "px";
|
||||
}
|
||||
|
||||
var SplashScreen = {
|
||||
setBGColor:function(cssBGColor) {
|
||||
bgColor = cssBGColor;
|
||||
if (localSplash) {
|
||||
localSplash.style.backgroundColor = bgColor;
|
||||
}
|
||||
},
|
||||
show:function(){
|
||||
window.addEventListener("resize", onResize, false);
|
||||
localSplash = document.createElement("div");
|
||||
localSplash.style.backgroundColor = bgColor;;
|
||||
localSplash.style.position = "absolute";
|
||||
|
||||
var img = localSplashImage = document.createElement("img");
|
||||
img.src = "img/splashscreen.png";
|
||||
img.style.position = "absolute";
|
||||
|
||||
updateImageLocation();
|
||||
|
||||
localSplash.appendChild(localSplashImage);
|
||||
document.body.appendChild(localSplash);
|
||||
},
|
||||
hide:function(){
|
||||
window.removeEventListener("resize", onResize, false);
|
||||
document.body.removeChild(localSplash);
|
||||
localSplash = null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SplashScreen;
|
||||
module.exports = SplashScreen;
|
||||
|
||||
function activated(evt) {
|
||||
if (evt.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
|
||||
splash = evt.detail.splashScreen;
|
||||
position = evt.detail.splashScreen.imageLocation;
|
||||
SplashScreen.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,5 +102,5 @@ channel.onCordovaReady.subscribe(function (evt) {
|
||||
}, false);
|
||||
});
|
||||
|
||||
require("cordova/commandProxy").add("SplashScreen",SplashScreen);
|
||||
require("cordova/windows8/commandProxy").add("SplashScreen", SplashScreen);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user