@@ -11,27 +11,27 @@ var STRING = "string",
1111 OK = "OK" ,
1212 CANCEL = "Cancel" ;
1313
14- function createAlertDialog ( options : dialogs . DialogOptions ) : android . app . AlertDialog . Builder {
14+ function createAlertDialog ( message : string , options : dialogs . DialogOptions ) : android . app . AlertDialog . Builder {
1515 var alert = new android . app . AlertDialog . Builder ( appmodule . android . foregroundActivity ) ;
16- alert . setTitle ( options . title ) ;
17- alert . setMessage ( options . message ) ;
16+ alert . setTitle ( options && options . title ? options . title : "" ) ;
17+ alert . setMessage ( message ) ;
1818 return alert ;
1919}
2020
2121function addButtonsToAlertDialog ( alert : android . app . AlertDialog . Builder , options : dialogs . ConfirmOptions ,
2222 okCallback : Function , cancelCallback ?: Function , neutralCallback ?: Function ) : void {
2323
24- if ( options . okButtonName ) {
25- alert . setPositiveButton ( options . okButtonName , new android . content . DialogInterface . OnClickListener ( {
24+ if ( options . okButtonText ) {
25+ alert . setPositiveButton ( options . okButtonText , new android . content . DialogInterface . OnClickListener ( {
2626 onClick : function ( dialog : android . content . DialogInterface , id : number ) {
2727 dialog . cancel ( ) ;
2828 okCallback ( ) ;
2929 }
3030 } ) ) ;
3131 }
3232
33- if ( options . cancelButtonName ) {
34- alert . setNegativeButton ( options . cancelButtonName , new android . content . DialogInterface . OnClickListener ( {
33+ if ( options . cancelButtonText ) {
34+ alert . setNegativeButton ( options . cancelButtonText , new android . content . DialogInterface . OnClickListener ( {
3535 onClick : function ( dialog : android . content . DialogInterface , id : number ) {
3636 dialog . cancel ( ) ;
3737 if ( cancelCallback ) {
@@ -41,8 +41,8 @@ function addButtonsToAlertDialog(alert: android.app.AlertDialog.Builder, options
4141 } ) ) ;
4242 }
4343
44- if ( options . otherButtonName ) {
45- alert . setNeutralButton ( options . otherButtonName , new android . content . DialogInterface . OnClickListener ( {
44+ if ( options . otherButtonText ) {
45+ alert . setNeutralButton ( options . otherButtonText , new android . content . DialogInterface . OnClickListener ( {
4646 onClick : function ( dialog : android . content . DialogInterface , id : number ) {
4747 dialog . cancel ( ) ;
4848 if ( neutralCallback ) {
@@ -53,14 +53,12 @@ function addButtonsToAlertDialog(alert: android.app.AlertDialog.Builder, options
5353 }
5454}
5555
56- export function alert ( arg : any ) : promises . Promise < void > {
56+ export function alert ( message : string , options = { title : ALERT , buttonText : OK } ) : promises . Promise < void > {
5757 var d = promises . defer < void > ( ) ;
5858 try {
59- var options = typeof arg === STRING ? { message : arg , title : ALERT , buttonName : OK } : arg
59+ var alert = createAlertDialog ( message , options ) ;
6060
61- var alert = createAlertDialog ( options ) ;
62-
63- alert . setPositiveButton ( options . buttonName , new android . content . DialogInterface . OnClickListener ( {
61+ alert . setPositiveButton ( options . buttonText , new android . content . DialogInterface . OnClickListener ( {
6462 onClick : function ( dialog : android . content . DialogInterface , id : number ) {
6563 dialog . cancel ( ) ;
6664 d . resolve ( ) ;
@@ -76,12 +74,10 @@ export function alert(arg: any): promises.Promise<void> {
7674 return d . promise ( ) ;
7775}
7876
79- export function confirm ( arg : any ) : promises . Promise < boolean > {
77+ export function confirm ( message : string , options = { title : ALERT , okButtonText : OK , cancelButtonText : CANCEL } ) : promises . Promise < boolean > {
8078 var d = promises . defer < boolean > ( ) ;
8179 try {
82- var options = typeof arg === STRING ? { message : arg , title : ALERT , okButtonName : OK , cancelButtonName : CANCEL } : arg
83-
84- var alert = createAlertDialog ( options ) ;
80+ var alert = createAlertDialog ( message , options ) ;
8581
8682 addButtonsToAlertDialog ( alert , options , function ( ) { d . resolve ( true ) ; } , function ( ) { d . resolve ( false ) ; } , function ( ) { d . resolve ( ) ; } ) ;
8783
@@ -94,12 +90,10 @@ export function confirm(arg: any): promises.Promise<boolean> {
9490 return d . promise ( ) ;
9591}
9692
97- export function prompt ( arg : any ) : promises . Promise < dialogs . PromptResult > {
93+ export function prompt ( message : string , options = { title : ALERT , okButtonText : OK , cancelButtonText : CANCEL , defaultText : "" } ) : promises . Promise < dialogs . PromptResult > {
9894 var d = promises . defer < dialogs . PromptResult > ( ) ;
9995 try {
100- var options = typeof arg === STRING ? { message : arg , title : ALERT , okButtonName : OK , cancelButtonName : CANCEL } : arg
101-
102- var alert = createAlertDialog ( options ) ;
96+ var alert = createAlertDialog ( message , options ) ;
10397
10498 var input = new android . widget . EditText ( appmodule . android . context ) ;
10599 input . setText ( options . defaultText ? options . defaultText : "" ) ;
0 commit comments