freshplanet / ANE-Alert

Air Native Extension (iOS and Android) for Native Alerts
Apache License 2.0
64 stars 21 forks source link

Android alerts dismissed by tapping anywhere on the screen will not call its button's callback #3

Closed edmundito closed 9 years ago

edmundito commented 11 years ago

I noticed that on Android the behavior of the alert is a little different from iOS. When an ANE-Alert has one button, you can actually tap anywhere around the alert to dismiss it. However, if you have set up a Function callback for that button, and the user taps anywhere but the button itself, the alert goes away and that Function never gets called.

I have a very basic solution that fixes this issue. Basically, the setCancelable() property needs to be set to false in AirAlertShowAlert.java:

alertBuilder
  .setTitle(title)
  .setMessage(message)
  .setCancelable(false) // THIS
  .setNeutralButton(button1, Extension.context);

The new behavior is that the user is now required to click on the button before dismissing the dialog.

Let me know if you want me to push this change, unless the intended behavior was to indeed be able to dismiss the alert by tapping anywhere on the app, then we can talk about other solutions. :)

ataugeron commented 11 years ago

Your update sounds good, I didn't know you could dismiss the popup by clicking around. Feel free to make a pull request.

Sent from Mailbox for iPhone

On Sun, Aug 25, 2013 at 11:55 AM, Edmundo Ruiz notifications@github.com wrote:

I noticed that on Android the behavior of the alert is a little different from iOS. When an ANE-Alert has one button, you can actually tap anywhere around the alert to dismiss it. However, if you have set up a Function callback for that button, and the user taps anywhere but the button itself, the alert goes away and that Function never gets called. I have a very basic solution that fixes this issue. Basically, the setCancelable() property needs to be set to false in AirAlertShowAlert.java:

alertBuilder
  .setTitle(title)
  .setMessage(message)
  .setCancelable(false) // THIS
  .setNeutralButton(button1, Extension.context);

The new behavior is that the user is now required to click on the button before dismissing the dialog.

Let me know if you want me to push this change, unless the intended behavior was to indeed be able to dismiss the alert by tapping anywhere on the app, then we can talk about other solutions. :)

Reply to this email directly or view it on GitHub: https://github.com/freshplanet/ANE-Alert/issues/3