[AC-4758] Android: add autoClose to AlertDialog to keep it open after clicking
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | n/a |
Status | Resolved |
Resolution | Won't Fix |
Resolution Date | 2017-01-29T16:16:33.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | alertDialog, android, community |
Reporter | Michael Gangolf |
Assignee | Shak Hossain |
Created | 2017-01-28T13:35:48.000+0000 |
Updated | 2017-01-29T16:16:33.000+0000 |
Description
Adding an
autoClose
property that will keep the AlertDialog open after clicking a button. Default will be true
so it will the same behaviour as before.
You have to manually call hide()
to close the dialog when autoClose:false
*Test code*
Ti.UI.setBackgroundColor('white');
var win = Ti.UI.createWindow({
title: 'Click window to test',
backgroundColor: 'white',
layout: "vertical"
});
var btn1 = Ti.UI.createButton({
title: "Alert 1"
});
win.add(btn1);
var btn2 = Ti.UI.createButton({
title: "Alert 2"
});
win.add(btn2);
var btn3 = Ti.UI.createButton({
title: "Alert 3"
});
win.add(btn3);
btn1.addEventListener('click', function(e) {
var dialog = Ti.UI.createAlertDialog({
message: 'autoClose not set - default way',
ok: 'Okay',
title: 'autoClose'
});
dialog.show();
});
btn2.addEventListener('click', function(e) {
var dialog = Ti.UI.createAlertDialog({
message: 'AutoClose true',
ok: 'Okay',
title: 'autoClose',
autoClose: true
});
dialog.show();
});
btn3.addEventListener('click', function(e) {
var dialog = Ti.UI.createAlertDialog({
cancel: 1,
buttonNames: ['Confirm', 'Cancel', 'Help'],
message: 'Click confirm and wait 3sec',
ok: 'Okay',
title: 'autoClose',
autoClose: false
});
dialog.addEventListener('click', function(e) {
Ti.API.info('e.index: ' + e.index);
if (e.index == 0) {
dialog.setMessage("closing...please wait 3sec")
setTimeout(function() {
dialog.hide();
}, 3000)
} else {
alert("Click confirm and wait")
}
});
dialog.show();
});
win.open();
* First button: default way
* Second button: autoClose: true
* Third button: autoClose: false (new way)
I have to be honest, I don't like that functionality and would propose to not add it to the SDK. And that because of the simple reason that (modal) alerts are supposed to be dismissed, so this would produce a UX leak that I'd like to prevent here. I'm open for discussion, but please consider to use a custom UI component to that special use-case.
I'll completely understand. It was a user request on tislack. The reason was that you are allowed to have inputs from the user in a dialog but you can't verify it without closing it when you click a button. Since it wasn't a big PR I'll did this. A workaround would already be to create a custom overlay view or window. This PR would just remove the need to create a custom window but stick to the AlertDialog to get the userdata. But a custom AlertDialog module would be also a good idea. Then its SDK independent
Thanks for the feedback. Resolving as
Won't Fix
based on the above reasons. Please feel free to patch the SDK anyway if this functionality is needed.