summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorPliablePixels <pliablepixels@gmail.com>2015-09-15 09:32:35 -0400
committerPliablePixels <pliablepixels@gmail.com>2015-09-15 09:32:35 -0400
commit606d3b95e941f48c8963d3996920472145da1200 (patch)
tree1a966266ada12285a4e2082607da844d52d900bf /plugins
parent566510313bd07eeb64dcafdc85a0f8e08e528c64 (diff)
Added pindialog plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/android.json7
-rw-r--r--plugins/fetch.json9
-rw-r--r--plugins/hu.dpal.phonegap.plugins.PinDialog/LICENSE20
-rw-r--r--plugins/hu.dpal.phonegap.plugins.PinDialog/README.md43
-rw-r--r--plugins/hu.dpal.phonegap.plugins.PinDialog/plugin.xml44
-rw-r--r--plugins/hu.dpal.phonegap.plugins.PinDialog/src/android/PinDialog.java124
-rw-r--r--plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.h19
-rw-r--r--plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.m61
-rw-r--r--plugins/hu.dpal.phonegap.plugins.PinDialog/www/pin.js13
-rw-r--r--plugins/ios.json7
10 files changed, 347 insertions, 0 deletions
diff --git a/plugins/android.json b/plugins/android.json
index 14796dcc..c51ce331 100644
--- a/plugins/android.json
+++ b/plugins/android.json
@@ -41,6 +41,10 @@
"count": 1
},
{
+ "xml": "<feature name=\"PinDialog\"><param name=\"android-package\" value=\"hu.dpal.phonegap.plugins.PinDialog\" /></feature>",
+ "count": 1
+ },
+ {
"xml": "<feature name=\"Insomnia\"><param name=\"android-package\" value=\"nl.xservices.plugins.Insomnia\" /></feature>",
"count": 1
},
@@ -100,6 +104,9 @@
"de.appplant.cordova.plugin.email-composer": {
"PACKAGE_NAME": "com.pliablepixels.zmninja"
},
+ "hu.dpal.phonegap.plugins.PinDialog": {
+ "PACKAGE_NAME": "com.pliablepixels.zmninja"
+ },
"nl.x-services.plugins.insomnia": {
"PACKAGE_NAME": "com.pliablepixels.zmninja"
},
diff --git a/plugins/fetch.json b/plugins/fetch.json
index c3ce7777..748a4c08 100644
--- a/plugins/fetch.json
+++ b/plugins/fetch.json
@@ -120,5 +120,14 @@
},
"is_top_level": true,
"variables": {}
+ },
+ "hu.dpal.phonegap.plugins.PinDialog": {
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Paldom/PinDialog.git",
+ "subdir": "."
+ },
+ "is_top_level": true,
+ "variables": {}
}
} \ No newline at end of file
diff --git a/plugins/hu.dpal.phonegap.plugins.PinDialog/LICENSE b/plugins/hu.dpal.phonegap.plugins.PinDialog/LICENSE
new file mode 100644
index 00000000..3b489884
--- /dev/null
+++ b/plugins/hu.dpal.phonegap.plugins.PinDialog/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Paldom
+
+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/plugins/hu.dpal.phonegap.plugins.PinDialog/README.md b/plugins/hu.dpal.phonegap.plugins.PinDialog/README.md
new file mode 100644
index 00000000..0f5ba3b3
--- /dev/null
+++ b/plugins/hu.dpal.phonegap.plugins.PinDialog/README.md
@@ -0,0 +1,43 @@
+PinDialog
+=========
+
+PhoneGap numeric password dialog plugin for Android and iOS. Forked from https://github.com/apache/cordova-plugin-dialogs.git
+
+## Installation
+
+Latest stable release: ```phonegap local plugin add hu.dpal.phonegap.plugins.pindialog```
+or ```cordova plugin add hu.dpal.phonegap.plugins.pindialog```
+
+Current state from git: ```phonegap local plugin add https://github.com/Paldom/PinDialog.git```
+or ```cordova plugin add https://github.com/Paldom/PinDialog.git```
+
+## Installation - PhoneGap Build
+
+Add following to config.xml: ```<gap:plugin name="hu.dpal.phonegap.plugins.pindialog" />```
+or ```<gap:plugin name="hu.dpal.phonegap.plugins.pindialog" source="plugins.cordova.io" />```
+
+## Supported Platforms
+
+- Android
+- iOS
+
+## Usage:
+
+ // Show pin dialog
+ window.plugins.pinDialog.prompt("message", callback, "title", ["OK","Cancel"]);
+
+Callback:
+
+ function callback(results)
+ {
+ if(results.buttonIndex == 1)
+ {
+ // OK clicked, show input value
+ alert(results.input1);
+ }
+ if(results.buttonIndex == 2)
+ {
+ // Cancel clicked
+ alert("Cancel");
+ }
+ };
diff --git a/plugins/hu.dpal.phonegap.plugins.PinDialog/plugin.xml b/plugins/hu.dpal.phonegap.plugins.PinDialog/plugin.xml
new file mode 100644
index 00000000..95c37524
--- /dev/null
+++ b/plugins/hu.dpal.phonegap.plugins.PinDialog/plugin.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
+ id="hu.dpal.phonegap.plugins.PinDialog"
+ version="0.1.3">
+
+ <name>PinDialog</name>
+
+ <description>
+ PhoneGap numeric password dialog plugin for Android and iOS. Forked from https://github.com/apache/cordova-plugin-dialogs.git
+ </description>
+ <license>MIT</license>
+ <keywords>phonegap,android,ios,numeric,password,pin,dialog</keywords>
+
+ <js-module src="www/pin.js" name="PinDialog">
+ <merges target="window.plugins.pinDialog" />
+ </js-module>
+
+ <!-- android -->
+ <platform name="android">
+ <config-file target="res/xml/config.xml" parent="/*">
+ <feature name="PinDialog">
+ <param name="android-package" value="hu.dpal.phonegap.plugins.PinDialog"/>
+ </feature>
+ </config-file>
+
+ <source-file src="src/android/PinDialog.java" target-dir="src/hu/dpal/phonegap/plugins" />
+
+ </platform>
+
+ <!-- ios -->
+ <platform name="ios">
+ <config-file target="config.xml" parent="/*">
+ <feature name="PinDialog">
+ <param name="ios-package" value="CDVPinDialog"/>
+ </feature>
+ </config-file>
+
+ <header-file src="src/ios/CDVPinDialog.h" />
+ <source-file src="src/ios/CDVPinDialog.m" />
+ </platform>
+
+</plugin>
+
diff --git a/plugins/hu.dpal.phonegap.plugins.PinDialog/src/android/PinDialog.java b/plugins/hu.dpal.phonegap.plugins.PinDialog/src/android/PinDialog.java
new file mode 100644
index 00000000..6be1d6e3
--- /dev/null
+++ b/plugins/hu.dpal.phonegap.plugins.PinDialog/src/android/PinDialog.java
@@ -0,0 +1,124 @@
+package hu.dpal.phonegap.plugins;
+
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.CordovaInterface;
+import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.PluginResult;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.DialogInterface;
+import android.text.InputType;
+import android.text.method.PasswordTransformationMethod;
+import android.widget.EditText;
+
+
+public class PinDialog extends CordovaPlugin {
+
+ public ProgressDialog spinnerDialog = null;
+
+ public PinDialog() {
+ }
+
+ public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
+ if (action.equals("prompt")) {
+
+ final String message = args.getString(0);
+ final String title = args.getString(1);
+ final JSONArray buttonLabels = args.getJSONArray(2);
+
+ final CordovaInterface cordova = this.cordova;
+ final EditText promptInput = new EditText(cordova.getActivity());
+ promptInput.setInputType(InputType.TYPE_CLASS_NUMBER);
+ promptInput.setTransformationMethod(PasswordTransformationMethod.getInstance());
+
+ Runnable runnable = new Runnable() {
+ public void run() {
+ AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity());
+ dlg.setMessage(message);
+ dlg.setTitle(title);
+ dlg.setCancelable(true);
+
+ dlg.setView(promptInput);
+
+ final JSONObject result = new JSONObject();
+
+ // First button
+ if (buttonLabels.length() > 0) {
+ try {
+ dlg.setNegativeButton(buttonLabels.getString(0),
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ try {
+ result.put("buttonIndex",1);
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? "" : promptInput.getText());
+ } catch (JSONException e) { e.printStackTrace(); }
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
+ }
+ });
+ } catch (JSONException e) { }
+ }
+
+ // Second button
+ if (buttonLabels.length() > 1) {
+ try {
+ dlg.setNeutralButton(buttonLabels.getString(1),
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ try {
+ result.put("buttonIndex",2);
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? "" : promptInput.getText());
+ } catch (JSONException e) { e.printStackTrace(); }
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
+ }
+ });
+ } catch (JSONException e) { }
+ }
+
+ // Third button
+ if (buttonLabels.length() > 2) {
+ try {
+ dlg.setPositiveButton(buttonLabels.getString(2),
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ try {
+ result.put("buttonIndex",3);
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? "" : promptInput.getText());
+ } catch (JSONException e) { e.printStackTrace(); }
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
+ }
+ });
+ } catch (JSONException e) { }
+ }
+
+ dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
+ public void onCancel(DialogInterface dialog){
+ dialog.dismiss();
+ try {
+ result.put("buttonIndex",0);
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? "" : promptInput.getText());
+ } catch (JSONException e) { e.printStackTrace(); }
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
+ }
+ });
+
+ dlg.create();
+ dlg.show();
+
+ };
+ };
+ this.cordova.getActivity().runOnUiThread(runnable);
+
+
+ }
+
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.h b/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.h
new file mode 100644
index 00000000..415195d5
--- /dev/null
+++ b/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.h
@@ -0,0 +1,19 @@
+//
+// CDVPinDialog.h
+// HelloWorld
+//
+//
+//
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+#import <Cordova/CDVPlugin.h>
+
+
+@interface CDVPinDialog : CDVPlugin <UIAlertViewDelegate>{}
+@property (nonatomic, copy) NSString* callbackId;
+
+- (void)prompt:(CDVInvokedUrlCommand*)command;
+
+@end
+
diff --git a/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.m b/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.m
new file mode 100644
index 00000000..bd33a205
--- /dev/null
+++ b/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.m
@@ -0,0 +1,61 @@
+//
+// CDVPinDialog.m
+// HelloWorld
+//
+//
+//
+
+#import "CDVPinDialog.h"
+
+@implementation CDVPinDialog
+
+- (void)prompt:(CDVInvokedUrlCommand*)command
+{
+ self.callbackId = command.callbackId;
+ NSString* message = [command argumentAtIndex:0];
+ NSString* title = [command argumentAtIndex:1];
+ NSArray* buttons = [command argumentAtIndex:2];
+
+ UIAlertView* alertView = [[UIAlertView alloc]
+ initWithTitle:title
+ message:message
+ delegate:self
+ cancelButtonTitle:nil
+ otherButtonTitles:nil];
+
+ //alertView.callbackId = callbackId;
+
+ int count = [buttons count];
+
+ for (int n = 0; n < count; n++) {
+ [alertView addButtonWithTitle:[buttons objectAtIndex:n]];
+ }
+
+ alertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
+ UITextField* textField = [alertView textFieldAtIndex:0];
+
+ [alertView show];
+
+ [textField resignFirstResponder];
+ [textField setKeyboardType:UIKeyboardTypeNumberPad];
+ [textField becomeFirstResponder];
+
+}
+
+
+- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+{
+ CDVPluginResult* result;
+
+ NSString* value0 = [[alertView textFieldAtIndex:0] text];
+ NSDictionary* info = @{
+ @"buttonIndex":@(buttonIndex + 1),
+ @"input1":(value0 ? value0 : [NSNull null])
+ };
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
+
+ [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
+}
+
+
+@end
diff --git a/plugins/hu.dpal.phonegap.plugins.PinDialog/www/pin.js b/plugins/hu.dpal.phonegap.plugins.PinDialog/www/pin.js
new file mode 100644
index 00000000..0633748b
--- /dev/null
+++ b/plugins/hu.dpal.phonegap.plugins.PinDialog/www/pin.js
@@ -0,0 +1,13 @@
+var exec = require('cordova/exec');
+
+
+module.exports = {
+
+ prompt: function(message, resultCallback, title, buttonLabels) {
+ var _message = (message || "Message");
+ var _title = (title || "Title");
+ var _buttonLabels = (buttonLabels || ["OK","Cancel"]);
+ cordova.exec(resultCallback, null, "PinDialog", "prompt", [_message, _title, _buttonLabels]);
+ }
+
+}; \ No newline at end of file
diff --git a/plugins/ios.json b/plugins/ios.json
index b390a6f9..56f3a34e 100644
--- a/plugins/ios.json
+++ b/plugins/ios.json
@@ -29,6 +29,10 @@
"count": 1
},
{
+ "xml": "<feature name=\"PinDialog\"><param name=\"ios-package\" value=\"CDVPinDialog\" /></feature>",
+ "count": 1
+ },
+ {
"xml": "<feature name=\"Insomnia\"><param name=\"ios-package\" value=\"Insomnia\" /></feature>",
"count": 1
},
@@ -118,6 +122,9 @@
"de.appplant.cordova.plugin.email-composer": {
"PACKAGE_NAME": "com.pliablepixels.zmninja"
},
+ "hu.dpal.phonegap.plugins.PinDialog": {
+ "PACKAGE_NAME": "com.pliablepixels.zmninja"
+ },
"nl.x-services.plugins.insomnia": {
"PACKAGE_NAME": "com.pliablepixels.zmninja"
},