mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
[CB-1933] Changed button labels to an array.
This allows commas to be included in button label text.
This commit is contained in:
parent
9fc1e7272e
commit
0f70e04e6e
@ -68,7 +68,7 @@ public class Notification extends CordovaPlugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (action.equals("confirm")) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
else if (action.equals("activityStart")) {
|
else if (action.equals("activityStart")) {
|
||||||
@ -170,7 +170,7 @@ public class Notification extends CordovaPlugin {
|
|||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
|
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dlg.create();
|
dlg.create();
|
||||||
dlg.show();
|
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 buttonLabels A comma separated list of button labels (Up to 3 buttons)
|
||||||
* @param callbackContext The callback context.
|
* @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 CordovaInterface cordova = this.cordova;
|
||||||
final String[] fButtons = buttonLabels.split(",");
|
|
||||||
|
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -201,37 +200,43 @@ public class Notification extends CordovaPlugin {
|
|||||||
dlg.setCancelable(true);
|
dlg.setCancelable(true);
|
||||||
|
|
||||||
// First button
|
// First button
|
||||||
if (fButtons.length > 0) {
|
if (buttonLabels.length() > 0) {
|
||||||
dlg.setNegativeButton(fButtons[0],
|
try {
|
||||||
new AlertDialog.OnClickListener() {
|
dlg.setNegativeButton(buttonLabels.getString(0),
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
new AlertDialog.OnClickListener() {
|
||||||
dialog.dismiss();
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1));
|
dialog.dismiss();
|
||||||
}
|
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} catch (JSONException e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second button
|
// Second button
|
||||||
if (fButtons.length > 1) {
|
if (buttonLabels.length() > 1) {
|
||||||
dlg.setNeutralButton(fButtons[1],
|
try {
|
||||||
new AlertDialog.OnClickListener() {
|
dlg.setNeutralButton(buttonLabels.getString(1),
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
new AlertDialog.OnClickListener() {
|
||||||
dialog.dismiss();
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2));
|
dialog.dismiss();
|
||||||
}
|
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} catch (JSONException e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Third button
|
// Third button
|
||||||
if (fButtons.length > 2) {
|
if (buttonLabels.length() > 2) {
|
||||||
dlg.setPositiveButton(fButtons[2],
|
try {
|
||||||
new AlertDialog.OnClickListener() {
|
dlg.setPositiveButton(buttonLabels.getString(2),
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
new AlertDialog.OnClickListener() {
|
||||||
dialog.dismiss();
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3));
|
dialog.dismiss();
|
||||||
}
|
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3));
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
} catch (JSONException e) { }
|
||||||
}
|
}
|
||||||
dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
|
dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
|
||||||
public void onCancel(DialogInterface dialog)
|
public void onCancel(DialogInterface dialog)
|
||||||
|
Loading…
Reference in New Issue
Block a user