Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23486] Android: Add an option to handle AlertDialog box outside touch.

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-06-14T20:51:52.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.0
ComponentsAndroid
LabelsAlertDalog
ReporterJebun Naher
AssigneeAshraf Abu
Created2016-06-09T09:17:54.000+0000
Updated2016-08-12T01:00:40.000+0000

Description

*Overview:* In android, when I click outside the AlertDialog, AlertDialog box will close. I need to close AlertDialog only when I click on cancel button in AlertDialog. [https://developer.android.com/reference/android/app/Dialog.html#setCanceledOnTouchOutside(boolean)]

steps to reproduce

1. Just create a sample project 2. Paste the following code 3. Run it on device and click the button 4. Then touch outside the dialog 5. It dismisses, the customer wants to prevent that

Test Code

var win = Ti.UI.createWindow({

});

var alertDialog = Ti.UI.createButton({
	title : 'ShowDialog',
	height : Ti.UI.SIZE,
	width : Ti.UI.SIZE,

});

// Listen for click events.
alertDialog.addEventListener('click', function() {
	var dialog = Ti.UI.createAlertDialog({
		message : 'The file has been deleted',
		cancel : 1,
		buttonNames : ['Confirm', 'Cancel'],
		message : 'Would you like to delete the file?',
		title : 'Delete'

	});
	dialog.show();
});

// Add to the parent view.
win.add(alertDialog);

win.open();

Thanks

Comments

  1. Chee Kiat Ng 2016-06-10

    not sure if this is native behavior. [~msamah]?
  2. Ashraf Abu 2016-06-10

    [~cng] This is an improvement ticket that requests for a property to be exposed to allow for that behaviour. It's something that should be doable.
  3. Ashraf Abu 2016-06-10

    [~jnaher] Just to make this ticket complete, could you have a sample code for the AlertDialog included in this ticket?
  4. Ashraf Abu 2016-06-13

    Master PR: https://github.com/appcelerator/titanium_mobile/pull/8053
  5. Lokesh Choudhary 2016-08-12

    Verified the implementation. The canceledOnTouchOutside property works as expected. Closing. Environment: Appc Studio : 4.7.0.201607250649 Ti SDK : 6.0.0.v20160810073036 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.6 Appc NPM : 4.2.7 Appc CLI : 6.0.0-24 Node: 4.4.4 Nexus 5 - Android 6.0.1

JSON Source