diff --git a/LICENSE b/LICENSE
index 21786a6..e69de29 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,20 +0,0 @@
-Copyright (c) 2015 Domonkos Pal
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
diff --git a/README.md b/README.md
index 2035ff4..0274c31 100644
--- a/README.md
+++ b/README.md
@@ -5,17 +5,15 @@ PhoneGap waiting dialog / progress dialog plugin with spinner for Android, iOS a
## Installation
-Latest stable release: ```phonegap local plugin add cordova-plugin-spinner-dialog```
-or ```cordova plugin add cordova-plugin-spinner-dialog```
+Latest stable release: ```phonegap local plugin add hu.dpal.phonegap.plugins.spinnerdialog```
+or ```cordova plugin add hu.dpal.phonegap.plugins.spinnerdialog```
Current state from git: ```phonegap local plugin add https://github.com/Paldom/SpinnerDialog.git```
or ```cordova plugin add https://github.com/Paldom/SpinnerDialog.git```
## Installation - PhoneGap Build
-Add following to config.xml: ``````
-
-For older versions, use the following: ``````
+Add following to config.xml: ``````
or ``````
## Methods
@@ -61,23 +59,7 @@ or ``` (https://github.com/Paldom)",
- "license": "MIT",
- "bugs": {
- "url": "https://github.com/Paldom/SpinnerDialog/issues"
- },
- "homepage": "https://github.com/Paldom/SpinnerDialog#readme"
-}
diff --git a/plugin.xml b/plugin.xml
index 15271ce..051249d 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -1,7 +1,7 @@
SpinnerDialog
@@ -50,6 +50,13 @@
+
+
+
+
+
+
+
diff --git a/src/android/SpinnerDialog.java b/src/android/SpinnerDialog.java
index 41e6352..147c3a4 100644
--- a/src/android/SpinnerDialog.java
+++ b/src/android/SpinnerDialog.java
@@ -11,6 +11,7 @@
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.widget.ProgressBar;
+import android.graphics.drawable.ColorDrawable;
public class SpinnerDialog extends CordovaPlugin {
@@ -49,6 +50,7 @@ public void onCancel(DialogInterface dialog) {
}
if (title == null && message == null) {
+ dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.setContentView(new ProgressBar(cordova.getActivity()));
}
diff --git a/src/ios/CDVSpinnerDialog.m b/src/ios/CDVSpinnerDialog.m
index 71be635..375638b 100644
--- a/src/ios/CDVSpinnerDialog.m
+++ b/src/ios/CDVSpinnerDialog.m
@@ -7,16 +7,18 @@
#import "CDVSpinnerDialog.h"
+#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1]
+
+#define UIColorFromRGBOpaque(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:0.65]
+
@interface CDVSpinnerDialog () {
UIActivityIndicatorView *indicator;
NSString *callbackId;
NSString *title;
NSString *message;
NSNumber *isFixed;
- NSString *alpha;
- NSString *red;
- NSString *green;
- NSString *blue;
+ NSString *color;
+ NSString *backgorundColor;
}
@property (nonatomic, retain) UIActivityIndicatorView *indicator;
@@ -53,18 +55,36 @@ - (void)handleTapGesture:(UITapGestureRecognizer *)gesture
- (UIView *)overlay {
if (!_overlay) {
_overlay = [[UIView alloc] initWithFrame:self.rectForView];
- _overlay.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:[alpha floatValue]];
_indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
_indicator.center = _overlay.center;
+ if(backgorundColor && ![backgorundColor isEqualToString: @"null"] && ![backgorundColor isEqualToString: @""]){
+ if([backgorundColor rangeOfString:@"#"].location != NSNotFound){
+ backgorundColor = [backgorundColor stringByReplacingOccurrencesOfString:@"#" withString:@""];
+ }
+ unsigned int baseValue;
+ [[NSScanner scannerWithString:backgorundColor] scanHexInt:&baseValue];
+ _overlay.backgroundColor = UIColorFromRGBOpaque(baseValue);
+ } else
+ _overlay.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.65];
[_indicator startAnimating];
[_overlay addSubview:_indicator];
_messageView = [[UILabel alloc] initWithFrame: self.rectForView];
[_messageView setText: message == nil ? title : message];
- [_messageView setTextColor: [UIColor colorWithRed:[red floatValue] green:[green floatValue] blue:[blue floatValue] alpha:0.85]];
+ //[_messageView setTextColor: [UIColor colorWithRed:1 green:1 blue:1 alpha:0.85]];
+ if(color && ![color isEqualToString: @"null"] && ![color isEqualToString: @""]){
+ if([color rangeOfString:@"#"].location != NSNotFound){
+ color = [color stringByReplacingOccurrencesOfString:@"#" withString:@""];
+ }
+ unsigned int baseValue;
+ [[NSScanner scannerWithString:color] scanHexInt:&baseValue];
+ [_messageView setTextColor: UIColorFromRGB(baseValue)];
+ }
[_messageView setBackgroundColor: [UIColor colorWithRed:0 green:0 blue:0 alpha:0]];
[_messageView setTextAlignment: NSTextAlignmentCenter];
_messageView.center = (CGPoint){_overlay.center.x, _overlay.center.y + 40};
+ _messageView.lineBreakMode = NSLineBreakByWordWrapping;
+ _messageView.numberOfLines = 0;
[_overlay addSubview:_messageView];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
@@ -81,11 +101,9 @@ - (void) show:(CDVInvokedUrlCommand*)command {
title = [command argumentAtIndex:0];
message = [command argumentAtIndex:1];
isFixed = [command argumentAtIndex:2];
- alpha = [command argumentAtIndex:3];
- red = [command argumentAtIndex:4];
- green = [command argumentAtIndex:5];
- blue = [command argumentAtIndex:6];
-
+ color = [command argumentAtIndex:3];
+ backgorundColor = [command argumentAtIndex:4];
+
UIViewController *rootViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
[rootViewController.view addSubview:self.overlay];
diff --git a/src/windows/SpinnerDialogProxy.js b/src/windows/SpinnerDialogProxy.js
new file mode 100644
index 0000000..e3c9698
--- /dev/null
+++ b/src/windows/SpinnerDialogProxy.js
@@ -0,0 +1,63 @@
+cordova.commandProxy.add("SpinnerDialog", {
+ show: function (successCallback, errorCallback, params) {
+ if(!document.getElementById("SpinnerDialogPlugin"))
+ addSpinner(params);
+ else {
+ hideSpinner();
+ addSpinner(params);
+ }
+ },
+ hide: function (successCallback, errorCallback, params) {
+ hideSpinner();
+ }
+});
+
+function showSpinner(){
+ var element = document.getElementById("SpinnerDialogPlugin");
+ if(element) element.style.display = "block";
+};
+
+function hideSpinner(){
+ var element = document.getElementById("SpinnerDialogPlugin");
+ if(element) {
+ //element.style.display = "none";
+ element.parentNode.removeChild(element);
+ }
+};
+
+function addSpinner(params) {
+ var element = element || document.createElement("div");
+ element.setAttribute("id", "SpinnerDialogPlugin");
+ element.style.width = "100%";
+ element.style.height = "100%";
+ element.style.position = "absolute";
+ element.style.top = "0px";
+ element.style.left = "0px";
+ element.style.opacity = .5; //For real browsers;
+ element.style.filter = "alpha(opacity=50)"; //For IE;
+ element.style.background = params[4] ? params[4] : "#000000";
+ element.style.zIndex = "999999";
+ //element.style.display = "none";
+
+ var progressContainer = progressContainer || document.createElement("div");
+ progressContainer.style.position = "absolute";
+ progressContainer.style.top = "50%";
+ progressContainer.style.left = "50%";
+ progressContainer.style.transform = "translate(-50%, -50%)";
+
+ var progress = progress || document.createElement("progress");
+
+ var progressMessage = progressMessage|| document.createElement("div");
+ progressMessage.style.marginTop = "2px;"
+ progressMessage.style.textAlign = "center";
+ progressMessage.style.color = params[3] ? params[3] : "#FFFFFF";
+ progressMessage.innerHTML = params[1] ? params[1] : "";
+
+ progressContainer.appendChild(progress);
+ progressContainer.appendChild(progressMessage);
+ element.appendChild(progressContainer);
+
+ //element.innerHTML = "";
+
+ document.body.appendChild(element);
+};
\ No newline at end of file
diff --git a/www/spinner.js b/www/spinner.js
index ade723d..8b3c060 100644
--- a/www/spinner.js
+++ b/www/spinner.js
@@ -2,23 +2,15 @@ var exec = require('cordova/exec');
module.exports = {
- show: function (title, message, cancelCallback, iosOptions) {
+ show : function(title, message, cancelCallback, color, backgroundColor) {
if (cancelCallback == true && typeof cancelCallback !== "function") {
- cancelCallback = function () { };
+ cancelCallback = function () {};
}
- var isPlatformIos = (navigator.userAgent.match(/iPad/i)) == "iPad" || (navigator.userAgent.match(/iPhone/i)) == "iPhone" ? true : false;
- var params = [title, message, !!cancelCallback];
- if (isPlatformIos) {
- if (typeof iosOptions != "object") {
- iosOptions = { overlayOpacity: 0.35, textColorRed: 1, textColorGreen: 1, textColorBlue: 1 }
- }
- params = params.concat([(iosOptions.overlayOpacity || 0.35), (iosOptions.textColorRed || 1), (iosOptions.textColorGreen || 1), (iosOptions.textColorBlue || 1)])
- }
- cordova.exec(cancelCallback, null, 'SpinnerDialog', 'show', params);
-
+ cordova.exec(cancelCallback, null, 'SpinnerDialog', 'show', [ title, message, !!cancelCallback, color, backgroundColor ]);
},
- hide: function (success, fail) {
- cordova.exec(success, fail, 'SpinnerDialog', 'hide', ["", ""]);
+
+ hide : function(success, fail) {
+ cordova.exec(success, fail, 'SpinnerDialog', 'hide', [ "","" ]);
}
};
\ No newline at end of file