Skip to content

Commit

Permalink
Merge pull request #279 from infil00p/master
Browse files Browse the repository at this point in the history
Clean-Up and Fix for Alert
  • Loading branch information
Joe Bowser committed Oct 21, 2011
2 parents 75f3651 + 628473c commit 64b770b
Showing 1 changed file with 36 additions and 17 deletions.
53 changes: 36 additions & 17 deletions framework/src/com/phonegap/DroidGap.java
Original file line number Diff line number Diff line change
Expand Up @@ -910,13 +910,32 @@ public boolean onJsAlert(WebView view, String url, String message, final JsResul
AlertDialog.Builder dlg = new AlertDialog.Builder(this.ctx);
dlg.setMessage(message);
dlg.setTitle("Alert");
dlg.setCancelable(false);
//Don't let alerts break the back button
dlg.setCancelable(true);
dlg.setPositiveButton(android.R.string.ok,
new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
result.confirm();
}
});
dlg.setOnCancelListener(
new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
result.confirm();
}
});
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
//DO NOTHING
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK)
{
result.confirm();
return false;
}
else
return true;
}
});
dlg.create();
dlg.show();
return true;
Expand Down Expand Up @@ -949,23 +968,23 @@ public void onClick(DialogInterface dialog, int which) {
}
});
dlg.setOnCancelListener(
new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
result.cancel();
}
});
new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
result.cancel();
}
});
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
//DO NOTHING
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK)
{
result.cancel();
return false;
}
else
return true;
}
});
//DO NOTHING
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK)
{
result.cancel();
return false;
}
else
return true;
}
});
dlg.create();
dlg.show();
return true;
Expand Down

0 comments on commit 64b770b

Please sign in to comment.