Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress dialogs should be not cancellable outside the window #28

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/android/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Licensed to the Apache Software Foundation (ASF) under one
/**
* This class provides access to notifications on the device.
*
* Be aware that this implementation gets called on
* Be aware that this implementation gets called on
* navigator.notification.{alert|confirm|prompt}, and that there is a separate
* implementation in org.apache.cordova.CordovaChromeClient that gets
* called on a simple window.{alert|confirm|prompt}.
Expand Down Expand Up @@ -69,7 +69,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
* be returned in the event of an invalid action.
*/
if(this.cordova.getActivity().isFinishing()) return true;

if (action.equals("beep")) {
this.beep(args.getLong(0));
}
Expand Down Expand Up @@ -263,9 +263,9 @@ public void onCancel(DialogInterface dialog)
* @param callbackContext The callback context.
*/
public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels, final String defaultText, final CallbackContext callbackContext) {

final CordovaInterface cordova = this.cordova;

Runnable runnable = new Runnable() {
public void run() {
final EditText promptInput = new EditText(cordova.getActivity());
Expand All @@ -274,11 +274,11 @@ public void run() {
dlg.setMessage(message);
dlg.setTitle(title);
dlg.setCancelable(true);

dlg.setView(promptInput);

final JSONObject result = new JSONObject();

// First button
if (buttonLabels.length() > 0) {
try {
Expand All @@ -288,7 +288,7 @@ public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
try {
result.put("buttonIndex",1);
result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
} catch (JSONException e) { e.printStackTrace(); }
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
}
Expand Down Expand Up @@ -405,6 +405,7 @@ public void run() {
notification.progressDialog.setCancelable(true);
notification.progressDialog.setMax(100);
notification.progressDialog.setProgress(0);
notification.progressDialog.setCanceledOnTouchOutside(false);
notification.progressDialog.setOnCancelListener(
new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
Expand Down