@@ -14,7 +14,7 @@ import {
1414 View ,
1515 capitalizationType ,
1616 fromObject ,
17- inputType ,
17+ inputType
1818} from '@nativescript/core' ;
1919import { LoginOptions , MDCAlertControlerOptions , PromptOptions } from './dialogs' ;
2020import { isDialogOptions } from './dialogs-common' ;
@@ -35,12 +35,14 @@ function createAlertDialogBuilder(options?: DialogOptions & MDCAlertControlerOpt
3535 }
3636 if ( options && options . cancelable === false ) {
3737 builder . setCancelable ( false ) ;
38- builder . setOnKeyListener ( new android . content . DialogInterface . OnKeyListener ( {
39- onKey ( dialog , keyCode , event ) {
40- // Prevent dialog close on back press button
41- return keyCode === android . view . KeyEvent . KEYCODE_BACK ;
42- }
43- } ) ) ;
38+ builder . setOnKeyListener (
39+ new android . content . DialogInterface . OnKeyListener ( {
40+ onKey ( dialog , keyCode , event ) {
41+ // Prevent dialog close on back press button
42+ return keyCode === android . view . KeyEvent . KEYCODE_BACK ;
43+ }
44+ } )
45+ ) ;
4446 }
4547 if ( options . titleIcon ) {
4648 builder . setIcon ( options . titleIcon . android ) ;
@@ -53,7 +55,7 @@ function createAlertDialogBuilder(options?: DialogOptions & MDCAlertControlerOpt
5355 options . view instanceof View
5456 ? options . view
5557 : Builder . createViewFromEntry ( {
56- moduleName : options . view as string ,
58+ moduleName : options . view as string
5759 } ) ;
5860
5961 view . cssClasses . add ( CSSUtils . MODAL_ROOT_VIEW_CSS_CLASS ) ;
@@ -159,7 +161,6 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
159161 callback && callback ( result ) ;
160162 } ;
161163
162- const activity = Application . android . foregroundActivity || ( Application . android . startActivity as globalAndroid . app . Activity ) ;
163164 builder . setOnDismissListener (
164165 new android . content . DialogInterface . OnDismissListener ( {
165166 onDismiss ( ) {
@@ -171,7 +172,7 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
171172 view . _isAddedToNativeVisualTree = false ;
172173 ( builder as any ) . _currentModalCustomView = null ;
173174 }
174- } ,
175+ }
175176 } )
176177 ) ;
177178 const dlg = builder . create ( ) ;
@@ -198,7 +199,7 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
198199 new android . content . DialogInterface . OnClickListener ( {
199200 onClick ( dialog : android . content . DialogInterface , id : number ) {
200201 onDone ( true , dialog ) ;
201- } ,
202+ }
202203 } )
203204 ) ;
204205 // alert.setPositiveButton(
@@ -214,7 +215,7 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
214215 new android . content . DialogInterface . OnClickListener ( {
215216 onClick ( dialog : android . content . DialogInterface , id : number ) {
216217 onDone ( false , dialog ) ;
217- } ,
218+ }
218219 } )
219220 ) ;
220221 // alert.setNegativeButton(
@@ -235,7 +236,7 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
235236 new android . content . DialogInterface . OnClickListener ( {
236237 onClick ( dialog : android . content . DialogInterface , id : number ) {
237238 onDone ( undefined , dialog ) ;
238- } ,
239+ }
239240 } )
240241 ) ;
241242 // alert.setNeutralButton(
@@ -255,7 +256,7 @@ export function alert(arg: any): Promise<void> {
255256 try {
256257 const defaultOptions = {
257258 title : DialogStrings . ALERT ,
258- okButtonText : DialogStrings . OK ,
259+ okButtonText : DialogStrings . OK
259260 } ;
260261 const options = ! isDialogOptions ( arg ) ? Object . assign ( defaultOptions , { message : arg + '' } ) : Object . assign ( defaultOptions , arg ) ;
261262
@@ -296,11 +297,11 @@ export function confirm(arg: any): Promise<boolean> {
296297 const defaultOptions = {
297298 title : DialogStrings . CONFIRM ,
298299 okButtonText : DialogStrings . OK ,
299- cancelButtonText : DialogStrings . CANCEL ,
300+ cancelButtonText : DialogStrings . CANCEL
300301 } ;
301302 const options = ! isDialogOptions ( arg )
302303 ? Object . assign ( defaultOptions , {
303- message : arg + '' ,
304+ message : arg + ''
304305 } )
305306 : Object . assign ( defaultOptions , arg ) ;
306307 const alert = createAlertDialogBuilder ( options ) ;
@@ -320,7 +321,7 @@ export function prompt(arg: any): Promise<PromptResult> {
320321 title : DialogStrings . PROMPT ,
321322 okButtonText : DialogStrings . OK ,
322323 cancelButtonText : DialogStrings . CANCEL ,
323- inputType : inputType . text ,
324+ inputType : inputType . text
324325 } ;
325326
326327 if ( arguments . length === 1 ) {
@@ -411,7 +412,7 @@ export function login(arg: any): Promise<LoginResult> {
411412 const defaultOptions = {
412413 title : DialogStrings . LOGIN ,
413414 okButtonText : DialogStrings . OK ,
414- cancelButtonText : DialogStrings . CANCEL ,
415+ cancelButtonText : DialogStrings . CANCEL
415416 } ;
416417
417418 if ( arguments . length === 1 ) {
@@ -471,7 +472,7 @@ export function login(arg: any): Promise<LoginResult> {
471472 resolve ( {
472473 result : r ,
473474 userName : userNameTextField . text ,
474- password : passwordTextField . text ,
475+ password : passwordTextField . text
475476 } ) ;
476477 } ,
477478 ( r ) => ( { result : r , userName : userNameTextField . text , password : passwordTextField . text } )
@@ -539,7 +540,7 @@ export function action(arg: any): Promise<string> {
539540 new android . content . DialogInterface . OnClickListener ( {
540541 onClick ( dialog : android . content . DialogInterface , which : number ) {
541542 resolve ( options . actions [ which ] ) ;
542- } ,
543+ }
543544 } )
544545 ) ;
545546 }
0 commit comments