diff options
Diffstat (limited to 'plugins/org.apache.cordova.splashscreen/src')
8 files changed, 0 insertions, 964 deletions
diff --git a/plugins/org.apache.cordova.splashscreen/src/android/SplashScreen.java b/plugins/org.apache.cordova.splashscreen/src/android/SplashScreen.java deleted file mode 100644 index ec3ad931..00000000 --- a/plugins/org.apache.cordova.splashscreen/src/android/SplashScreen.java +++ /dev/null @@ -1,281 +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. -*/ - -package org.apache.cordova.splashscreen; - -import android.app.Dialog; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.graphics.Color; -import android.os.Handler; -import android.view.Display; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.widget.LinearLayout; - -import org.apache.cordova.CallbackContext; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.CordovaWebView; -import org.json.JSONArray; -import org.json.JSONException; - -public class SplashScreen extends CordovaPlugin { - private static final String LOG_TAG = "SplashScreen"; - // Cordova 3.x.x has a copy of this plugin bundled with it (SplashScreenInternal.java). - // 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 Dialog splashDialog; - private static ProgressDialog spinnerDialog; - private static boolean firstShow = true; - - // Helper to be compile-time compatable with both Cordova 3.x and 4.x. - private View getView() { - try { - return (View)webView.getClass().getMethod("getView").invoke(webView); - } catch (Exception e) { - return (View)webView; - } - } - - @Override - protected void pluginInitialize() { - if (HAS_BUILT_IN_SPLASH_SCREEN || !firstShow) { - 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", null); - 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); - } - } - - firstShow = false; - loadSpinner(); - showSplashScreen(true); - } - - @Override - public void onPause(boolean multitasking) { - if (HAS_BUILT_IN_SPLASH_SCREEN) { - return; - } - // hide the splash screen to avoid leaking a window - this.removeSplashScreen(); - } - - @Override - public void onDestroy() { - if (HAS_BUILT_IN_SPLASH_SCREEN) { - return; - } - // hide the splash screen to avoid leaking a window - this.removeSplashScreen(); - firstShow = true; - } - - @Override - public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (action.equals("hide")) { - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - webView.postMessage("splashscreen", "hide"); - } - }); - } else if (action.equals("show")) { - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - webView.postMessage("splashscreen", "show"); - } - }); - } else if (action.equals("spinnerStart")) { - if (!HAS_BUILT_IN_SPLASH_SCREEN) { - final String title = args.getString(0); - final String message = args.getString(1); - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - spinnerStart(title, message); - } - }); - } - } else { - return false; - } - - callbackContext.success(); - return true; - } - - @Override - public Object onMessage(String id, Object data) { - if (HAS_BUILT_IN_SPLASH_SCREEN) { - return null; - } - if ("splashscreen".equals(id)) { - if ("hide".equals(data.toString())) { - this.removeSplashScreen(); - } else { - this.showSplashScreen(false); - } - } else if ("spinner".equals(id)) { - if ("stop".equals(data.toString())) { - this.spinnerStop(); - getView().setVisibility(View.VISIBLE); - } - } else if ("onReceivedError".equals(id)) { - spinnerStop(); - } - return null; - } - - private void removeSplashScreen() { - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - if (splashDialog != null && splashDialog.isShowing()) { - splashDialog.dismiss(); - splashDialog = null; - } - } - }); - } - - /** - * Shows the splash screen over the full Activity - */ - @SuppressWarnings("deprecation") - private void showSplashScreen(final boolean hideAfterDelay) { - final int splashscreenTime = preferences.getInteger("SplashScreenDelay", 3000); - final int drawableId = preferences.getInteger("SplashDrawableId", 0); - - // If the splash dialog is showing don't try to show it again - if (this.splashDialog != null && splashDialog.isShowing()) { - return; - } - if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) { - return; - } - - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - // Get reference to display - Display display = cordova.getActivity().getWindowManager().getDefaultDisplay(); - Context context = webView.getContext(); - - // Create the layout for the dialog - LinearLayout root = new LinearLayout(context); - root.setMinimumHeight(display.getHeight()); - root.setMinimumWidth(display.getWidth()); - root.setOrientation(LinearLayout.VERTICAL); - - // TODO: Use the background color of the webview's parent instead of using the - // preference. - root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK)); - root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT, 0.0F)); - root.setBackgroundResource(drawableId); - - // Create and show the dialog - splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar); - // check to see if the splash screen should be full screen - if ((cordova.getActivity().getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) - == WindowManager.LayoutParams.FLAG_FULLSCREEN) { - splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, - WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - splashDialog.setContentView(root); - splashDialog.setCancelable(false); - splashDialog.show(); - - // Set Runnable to remove splash screen just in case - if (hideAfterDelay) { - final Handler handler = new Handler(); - handler.postDelayed(new Runnable() { - public void run() { - removeSplashScreen(); - } - }, splashscreenTime); - } - } - }); - } - - /* - * Load the spinner - */ - private void loadSpinner() { - // If loadingDialog property, then show the App loading dialog for first page of app - String loading = null; - if (webView.canGoBack()) { - loading = preferences.getString("LoadingDialog", null); - } - else { - loading = preferences.getString("LoadingPageDialog", null); - } - if (loading != null) { - String title = ""; - String message = "Loading Application..."; - - if (loading.length() > 0) { - int comma = loading.indexOf(','); - if (comma > 0) { - title = loading.substring(0, comma); - message = loading.substring(comma + 1); - } - else { - title = ""; - message = loading; - } - } - spinnerStart(title, message); - } - } - - private void spinnerStart(final String title, final String message) { - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - spinnerStop(); - spinnerDialog = ProgressDialog.show(webView.getContext(), title, message, true, true, - new DialogInterface.OnCancelListener() { - public void onCancel(DialogInterface dialog) { - spinnerDialog = null; - } - }); - } - }); - } - - private void spinnerStop() { - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - if (spinnerDialog != null && spinnerDialog.isShowing()) { - spinnerDialog.dismiss(); - spinnerDialog = null; - } - } - }); - } -} diff --git a/plugins/org.apache.cordova.splashscreen/src/blackberry10/index.js b/plugins/org.apache.cordova.splashscreen/src/blackberry10/index.js deleted file mode 100644 index bd7e48c8..00000000 --- a/plugins/org.apache.cordova.splashscreen/src/blackberry10/index.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013 Research In Motion Limited. - * - * Licensed 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. - */ - -module.exports = { - show: function (success, fail, args, env) { - var result = new PluginResult(args, env); - result.error("Not supported on platform", false); - }, - - hide: function (success, fail, args, env) { - var result = new PluginResult(args, env); - window.qnx.webplatform.getApplication().windowVisible = true; - result.ok(undefined, false); - } -}; diff --git a/plugins/org.apache.cordova.splashscreen/src/ios/CDVSplashScreen.h b/plugins/org.apache.cordova.splashscreen/src/ios/CDVSplashScreen.h deleted file mode 100644 index 0d6ae397..00000000 --- a/plugins/org.apache.cordova.splashscreen/src/ios/CDVSplashScreen.h +++ /dev/null @@ -1,43 +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. - */ - -#import <Foundation/Foundation.h> -#import <Cordova/CDVPlugin.h> - -typedef struct { - BOOL iPhone; - BOOL iPad; - BOOL iPhone5; - BOOL iPhone6; - BOOL iPhone6Plus; - BOOL retina; - -} CDV_iOSDevice; - -@interface CDVSplashScreen : CDVPlugin { - UIActivityIndicatorView* _activityView; - UIImageView* _imageView; - NSString* _curImageName; - BOOL _visible; -} - -- (void)show:(CDVInvokedUrlCommand*)command; -- (void)hide:(CDVInvokedUrlCommand*)command; - -@end diff --git a/plugins/org.apache.cordova.splashscreen/src/ios/CDVSplashScreen.m b/plugins/org.apache.cordova.splashscreen/src/ios/CDVSplashScreen.m deleted file mode 100644 index c28ae2f5..00000000 --- a/plugins/org.apache.cordova.splashscreen/src/ios/CDVSplashScreen.m +++ /dev/null @@ -1,308 +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. - */ - -#import "CDVSplashScreen.h" -#import <Cordova/CDVViewController.h> -#import <Cordova/CDVScreenOrientationDelegate.h> - -#define kSplashScreenDurationDefault 0.25f - - -@implementation CDVSplashScreen - -- (void)pluginInitialize -{ - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad) name:CDVPageDidLoadNotification object:self.webView]; - - [self setVisible:YES]; -} - -- (void)show:(CDVInvokedUrlCommand*)command -{ - [self setVisible:YES]; -} - -- (void)hide:(CDVInvokedUrlCommand*)command -{ - [self setVisible:NO]; -} - -- (void)pageDidLoad -{ - id autoHideSplashScreenValue = [self.commandDelegate.settings objectForKey:[@"AutoHideSplashScreen" lowercaseString]]; - - // if value is missing, default to yes - if ((autoHideSplashScreenValue == nil) || [autoHideSplashScreenValue boolValue]) { - [self setVisible:NO]; - } -} - -- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context -{ - [self updateImage]; -} - -- (void)createViews -{ - /* - * The Activity View is the top spinning throbber in the status/battery bar. We init it with the default Grey Style. - * - * whiteLarge = UIActivityIndicatorViewStyleWhiteLarge - * white = UIActivityIndicatorViewStyleWhite - * gray = UIActivityIndicatorViewStyleGray - * - */ - NSString* topActivityIndicator = [self.commandDelegate.settings objectForKey:[@"TopActivityIndicator" lowercaseString]]; - UIActivityIndicatorViewStyle topActivityIndicatorStyle = UIActivityIndicatorViewStyleGray; - - if ([topActivityIndicator isEqualToString:@"whiteLarge"]) { - topActivityIndicatorStyle = UIActivityIndicatorViewStyleWhiteLarge; - } else if ([topActivityIndicator isEqualToString:@"white"]) { - topActivityIndicatorStyle = UIActivityIndicatorViewStyleWhite; - } else if ([topActivityIndicator isEqualToString:@"gray"]) { - topActivityIndicatorStyle = UIActivityIndicatorViewStyleGray; - } - - UIView* parentView = self.viewController.view; - parentView.userInteractionEnabled = NO; // disable user interaction while splashscreen is shown - _activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:topActivityIndicatorStyle]; - _activityView.center = CGPointMake(parentView.bounds.size.width / 2, parentView.bounds.size.height / 2); - _activityView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin - | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin; - [_activityView startAnimating]; - - // Set the frame & image later. - _imageView = [[UIImageView alloc] init]; - [parentView addSubview:_imageView]; - - id showSplashScreenSpinnerValue = [self.commandDelegate.settings objectForKey:[@"ShowSplashScreenSpinner" lowercaseString]]; - // backwards compatibility - if key is missing, default to true - if ((showSplashScreenSpinnerValue == nil) || [showSplashScreenSpinnerValue boolValue]) { - [parentView addSubview:_activityView]; - } - - // Frame is required when launching in portrait mode. - // Bounds for landscape since it captures the rotation. - [parentView addObserver:self forKeyPath:@"frame" options:0 context:nil]; - [parentView addObserver:self forKeyPath:@"bounds" options:0 context:nil]; - - [self updateImage]; -} - -- (void)destroyViews -{ - [_imageView removeFromSuperview]; - [_activityView removeFromSuperview]; - _imageView = nil; - _activityView = nil; - _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"]; -} - -- (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); - device.iPhone5 = (device.iPhone && limit == 568.0); - // note these below is not a true device detect, for example if you are on an - // iPhone 6/6+ but the app is scaled it will prob set iPhone5 as true, but - // 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; -} - -- (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"]; - - 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]; - } else { - imageName = @"Default"; - } - - if (device.iPhone5) { // does not support landscape - imageName = [imageName stringByAppendingString:@"-568h"]; - } else if (device.iPhone6) { // does not support landscape - imageName = [imageName stringByAppendingString:@"-667h"]; - } else if (device.iPhone6Plus) { // supports landscape - if (isOrientationLocked) { - imageName = [imageName stringByAppendingString:(supportsLandscape ? @"-Landscape" : @"")]; - } else { - switch (currentOrientation) { - case UIInterfaceOrientationLandscapeLeft: - case UIInterfaceOrientationLandscapeRight: - imageName = [imageName stringByAppendingString:@"-Landscape"]; - break; - default: - break; - } - } - imageName = [imageName stringByAppendingString:@"-736h"]; - - } else if (device.iPad) { // supports landscape - if (isOrientationLocked) { - imageName = [imageName stringByAppendingString:(supportsLandscape ? @"-Landscape" : @"-Portrait")]; - } else { - switch (currentOrientation) { - case UIInterfaceOrientationLandscapeLeft: - case UIInterfaceOrientationLandscapeRight: - imageName = [imageName stringByAppendingString:@"-Landscape"]; - break; - - case UIInterfaceOrientationPortrait: - case UIInterfaceOrientationPortraitUpsideDown: - default: - imageName = [imageName stringByAppendingString:@"-Portrait"]; - break; - } - } - } - - return imageName; -} - -// Sets the view's frame and image. -- (void)updateImage -{ - NSString* imageName = [self getImageName:self.viewController.interfaceOrientation delegate:(id<CDVScreenOrientationDelegate>)self.viewController device:[self getCurrentDevice]]; - - if (![imageName isEqualToString:_curImageName]) { - UIImage* img = [UIImage imageNamed:imageName]; - _imageView.image = img; - _curImageName = imageName; - } - - // Check that splash screen's image exists before updating bounds - if (_imageView.image) { - [self updateBounds]; - } else { - NSLog(@"WARNING: The splashscreen image named %@ was not found", imageName); - } -} - -- (void)updateBounds -{ - UIImage* img = _imageView.image; - 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; - UIInterfaceOrientation orientation = self.viewController.interfaceOrientation; - CGAffineTransform imgTransform = CGAffineTransformIdentity; - - /* If and only if an iPhone application is landscape-only as per - * UISupportedInterfaceOrientations, the view controller's orientation is - * landscape. In this case the image must be rotated in order to appear - * correctly. - */ - BOOL isIPad = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad; - if (UIInterfaceOrientationIsLandscape(orientation) && !isIPad) { - imgTransform = CGAffineTransformMakeRotation(M_PI / 2); - imgBounds.size = CGSizeMake(imgBounds.size.height, imgBounds.size.width); - } - - // 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]; - 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; - // This matches the behaviour of the native splash screen. - CGFloat ratio; - if (viewAspect > imgAspect) { - ratio = viewBounds.size.width / imgBounds.size.width; - } else { - ratio = viewBounds.size.height / imgBounds.size.height; - } - imgBounds.size.height *= ratio; - imgBounds.size.width *= ratio; - } - - _imageView.transform = imgTransform; - _imageView.frame = imgBounds; -} - -- (void)setVisible:(BOOL)visible -{ - if (visible == _visible) { - return; - } - _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]; - - if ((fadeSplashScreenValue == nil) || ![fadeSplashScreenValue boolValue]) { - fadeDuration = 0; - } - - // Never animate the showing of the splash screen. - if (visible) { - if (_imageView == nil) { - [self createViews]; - } - } else if (fadeDuration == 0) { - [self destroyViews]; - } else { - [UIView transitionWithView:self.viewController.view - duration:fadeDuration - options:UIViewAnimationOptionTransitionNone - animations:^(void) { - [_imageView setAlpha:0]; - [_activityView setAlpha:0]; - } - completion:^(BOOL finished) { - if (finished) { - [self destroyViews]; - } - } - ]; - } -} - -@end diff --git a/plugins/org.apache.cordova.splashscreen/src/tizen/SplashScreenProxy.js b/plugins/org.apache.cordova.splashscreen/src/tizen/SplashScreenProxy.js deleted file mode 100644 index fbd9f35f..00000000 --- a/plugins/org.apache.cordova.splashscreen/src/tizen/SplashScreenProxy.js +++ /dev/null @@ -1,43 +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. - * -*/ - -( function() { - -win = null; - -module.exports = { - show: function() { - if ( win === null ) { - win = window.open('splashscreen.html'); - } - }, - - hide: function() { - if ( win !== null ) { - win.close(); - win = null; - } - } -}; - -require("cordova/tizen/commandProxy").add("SplashScreen", module.exports); - -})(); diff --git a/plugins/org.apache.cordova.splashscreen/src/ubuntu/splashscreen.cpp b/plugins/org.apache.cordova.splashscreen/src/ubuntu/splashscreen.cpp deleted file mode 100644 index 1c9ecac8..00000000 --- a/plugins/org.apache.cordova.splashscreen/src/ubuntu/splashscreen.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * 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); -} diff --git a/plugins/org.apache.cordova.splashscreen/src/ubuntu/splashscreen.h b/plugins/org.apache.cordova.splashscreen/src/ubuntu/splashscreen.h deleted file mode 100644 index 1d437f84..00000000 --- a/plugins/org.apache.cordova.splashscreen/src/ubuntu/splashscreen.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * 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 diff --git a/plugins/org.apache.cordova.splashscreen/src/wp/SplashScreen.cs b/plugins/org.apache.cordova.splashscreen/src/wp/SplashScreen.cs deleted file mode 100644 index 4d3545b0..00000000 --- a/plugins/org.apache.cordova.splashscreen/src/wp/SplashScreen.cs +++ /dev/null @@ -1,167 +0,0 @@ -/* - Licensed 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. -*/ - -using System; -using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Ink; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; -using Microsoft.Phone.Info; -using System.Windows.Controls.Primitives; -using System.Diagnostics; -using System.Windows.Media.Imaging; -using System.Windows.Resources; -using System.IO; -using System.Xml.Linq; -using System.Linq; -using System.Windows.Threading; - -namespace WPCordovaClassLib.Cordova.Commands -{ - /// <summary> - /// Listens for changes to the state of the battery on the device. - /// Currently only the "isPlugged" parameter available via native APIs. - /// </summary> - public class SplashScreen : BaseCommand - { - private Popup popup; - private bool autohide = true; - - private static bool WasShown = false; - - public SplashScreen() - { - Image SplashScreen = new Image(); - BitmapImage splash_image = new BitmapImage(); - splash_image.SetSource(Application.GetResourceStream(new Uri(@"SplashScreenImage.jpg", UriKind.Relative)).Stream); - SplashScreen.Source = splash_image; - - // Instansiate the popup and set the Child property of Popup to SplashScreen - popup = new Popup() {IsOpen = false, Child = SplashScreen }; - // Orient the popup accordingly - popup.HorizontalAlignment = HorizontalAlignment.Stretch; - popup.VerticalAlignment = VerticalAlignment.Center; - - - LoadConfigValues(); - } - - public override void OnInit() - { - // we only want to autoload the first time a page is loaded. - if (!WasShown) - { - WasShown = true; - show(); - } - } - - void LoadConfigValues() - { - StreamResourceInfo streamInfo = Application.GetResourceStream(new Uri("config.xml", UriKind.Relative)); - - if (streamInfo != null) - { - StreamReader sr = new StreamReader(streamInfo.Stream); - //This will Read Keys Collection for the xml file - XDocument document = XDocument.Parse(sr.ReadToEnd()); - - var preferences = from results in document.Descendants() - where (string)results.Attribute("name") == "AutoHideSplashScreen" - select (string)results.Attribute("value") == "true"; - - if (preferences.Count() > 0 && preferences.First() == false) - { - autohide = false; - } - } - } - - public void show(string options = null) - { - Deployment.Current.Dispatcher.BeginInvoke(() => - { - if (popup.IsOpen) - { - return; - } - - popup.Child.Opacity = 0; - - Storyboard story = new Storyboard(); - DoubleAnimation animation; - animation = new DoubleAnimation(); - animation.From = 0.0; - animation.To = 1.0; - animation.Duration = new Duration(TimeSpan.FromSeconds(0.2)); - - Storyboard.SetTarget(animation, popup.Child); - Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity")); - story.Children.Add(animation); - - Debug.WriteLine("Fading the splash screen in"); - - story.Begin(); - - popup.IsOpen = true; - - if (autohide) - { - DispatcherTimer timer = new DispatcherTimer(); - timer.Tick += (object sender, EventArgs e) => - { - hide(); - }; - timer.Interval = TimeSpan.FromSeconds(1.2); - timer.Start(); - } - }); - } - - - public void hide(string options = null) - { - Deployment.Current.Dispatcher.BeginInvoke(() => - { - if (!popup.IsOpen) - { - return; - } - - popup.Child.Opacity = 1.0; - - Storyboard story = new Storyboard(); - DoubleAnimation animation; - animation = new DoubleAnimation(); - animation.From = 1.0; - animation.To = 0.0; - animation.Duration = new Duration(TimeSpan.FromSeconds(0.4)); - - Storyboard.SetTarget(animation, popup.Child); - Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity")); - story.Children.Add(animation); - story.Completed += (object sender, EventArgs e) => - { - popup.IsOpen = false; - }; - story.Begin(); - }); - } - } -} |
