cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject android commit: [CB-1933] Changed button labels to an array.
Date Thu, 14 Mar 2013 15:34:37 GMT
Updated Branches:
  refs/heads/master 9fc1e7272 -> 0f70e04e6


[CB-1933] Changed button labels to an array.

This allows commas to be included in button label text.


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/0f70e04e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/0f70e04e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/0f70e04e

Branch: refs/heads/master
Commit: 0f70e04e6e0d19fbcb23d1787ce8d308a9b453c4
Parents: 9fc1e72
Author: Max Woghiren <max.woghiren@gmail.com>
Authored: Fri Feb 15 14:56:50 2013 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Thu Mar 14 11:34:29 2013 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/Notification.java |   63 ++++++++-------
 1 files changed, 34 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0f70e04e/framework/src/org/apache/cordova/Notification.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Notification.java b/framework/src/org/apache/cordova/Notification.java
index 958ab26..87fce9d 100755
--- a/framework/src/org/apache/cordova/Notification.java
+++ b/framework/src/org/apache/cordova/Notification.java
@@ -68,7 +68,7 @@ public class Notification extends CordovaPlugin {
             return true;
         }
         else if (action.equals("confirm")) {
-            this.confirm(args.getString(0), args.getString(1), args.getString(2), callbackContext);
+            this.confirm(args.getString(0), args.getString(1), args.getJSONArray(2), callbackContext);
             return true;
         }
         else if (action.equals("activityStart")) {
@@ -170,7 +170,7 @@ public class Notification extends CordovaPlugin {
                         callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
0));
                     }
                 });
-                
+
                 dlg.create();
                 dlg.show();
             };
@@ -188,10 +188,9 @@ public class Notification extends CordovaPlugin {
      * @param buttonLabels      A comma separated list of button labels (Up to 3 buttons)
      * @param callbackContext   The callback context.
      */
-    public synchronized void confirm(final String message, final String title, String buttonLabels,
final CallbackContext callbackContext) {
+    public synchronized void confirm(final String message, final String title, final JSONArray
buttonLabels, final CallbackContext callbackContext) {
 
         final CordovaInterface cordova = this.cordova;
-        final String[] fButtons = buttonLabels.split(",");
 
         Runnable runnable = new Runnable() {
             public void run() {
@@ -201,37 +200,43 @@ public class Notification extends CordovaPlugin {
                 dlg.setCancelable(true);
 
                 // First button
-                if (fButtons.length > 0) {
-                    dlg.setNegativeButton(fButtons[0],
-                            new AlertDialog.OnClickListener() {
-                                public void onClick(DialogInterface dialog, int which) {
-                                    dialog.dismiss();
-                                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
1));
-                                }
-                            });
+                if (buttonLabels.length() > 0) {
+                    try {
+						dlg.setNegativeButton(buttonLabels.getString(0),
+						        new AlertDialog.OnClickListener() {
+						            public void onClick(DialogInterface dialog, int which) {
+						                dialog.dismiss();
+						                callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
1));
+						            }
+						        });
+					} catch (JSONException e) { }
                 }
 
                 // Second button
-                if (fButtons.length > 1) {
-                    dlg.setNeutralButton(fButtons[1],
-                            new AlertDialog.OnClickListener() {
-                                public void onClick(DialogInterface dialog, int which) {
-                                    dialog.dismiss();
-                                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
2));
-                                }
-                            });
+                if (buttonLabels.length() > 1) {
+                    try {
+						dlg.setNeutralButton(buttonLabels.getString(1),
+						        new AlertDialog.OnClickListener() {
+						            public void onClick(DialogInterface dialog, int which) {
+						                dialog.dismiss();
+						                callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
2));
+						            }
+						        });
+					} catch (JSONException e) { }
                 }
 
                 // Third button
-                if (fButtons.length > 2) {
-                    dlg.setPositiveButton(fButtons[2],
-                            new AlertDialog.OnClickListener() {
-                                public void onClick(DialogInterface dialog, int which) {
-                                    dialog.dismiss();
-                                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
3));
-                                }
-                            }
-                            );
+                if (buttonLabels.length() > 2) {
+                    try {
+						dlg.setPositiveButton(buttonLabels.getString(2),
+						        new AlertDialog.OnClickListener() {
+						            public void onClick(DialogInterface dialog, int which) {
+						                dialog.dismiss();
+						                callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
3));
+						            }
+						        }
+						        );
+					} catch (JSONException e) { }
                 }
                 dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
                     public void onCancel(DialogInterface dialog)


Mime
View raw message