@@ -82,16 +82,20 @@ function createAlertDialogBuilder(options?: DialogOptions & MDCAlertControlerOpt
82
82
}
83
83
84
84
function showDialog ( dlg : androidx . appcompat . app . AlertDialog , options : DialogOptions & MDCAlertControlerOptions , resolve ?: Function ) {
85
+ dlg . show ( ) ;
86
+
87
+ const packageName = dlg . getContext ( ) . getPackageName ( ) ;
88
+
85
89
if ( options . titleColor ) {
86
- const textViewId = dlg . getContext ( ) . getResources ( ) . getIdentifier ( 'android:id/ alertTitle' , null , null ) ;
90
+ const textViewId = dlg . getContext ( ) . getResources ( ) . getIdentifier ( 'alertTitle' , 'id' , packageName ) ;
87
91
if ( textViewId ) {
88
92
const tv = < android . widget . TextView > dlg . findViewById ( textViewId ) ;
89
93
if ( tv ) {
90
94
tv . setTextColor ( options . titleColor . android ) ;
91
95
}
92
96
}
93
97
if ( options . messageColor ) {
94
- const messageTextViewId = dlg . getContext ( ) . getResources ( ) . getIdentifier ( 'android:id/ message' , null , null ) ;
98
+ const messageTextViewId = dlg . getContext ( ) . getResources ( ) . getIdentifier ( 'message' , 'id' , packageName ) ;
95
99
if ( messageTextViewId ) {
96
100
const messageTextView = < android . widget . TextView > dlg . findViewById ( messageTextViewId ) ;
97
101
if ( messageTextView ) {
@@ -128,22 +132,18 @@ function showDialog(dlg: androidx.appcompat.app.AlertDialog, options: DialogOpti
128
132
// let { color, backgroundColor } = getButtonColors();
129
133
130
134
if ( options . buttonInkColor || options . buttonTitleColor ) {
131
- let buttons : android . widget . Button [ ] = [ ] ;
132
- for ( let i = 0 ; i < 3 ; i ++ ) {
133
- let id = dlg
134
- . getContext ( )
135
- . getResources ( )
136
- . getIdentifier ( 'android:id/button' + i , null , null ) ;
137
- buttons [ i ] = < android . widget . Button > dlg . findViewById ( id ) ;
138
- }
135
+ let buttons : android . widget . Button [ ] = [
136
+ dlg . getButton ( android . content . DialogInterface . BUTTON_POSITIVE ) ,
137
+ dlg . getButton ( android . content . DialogInterface . BUTTON_NEGATIVE ) ,
138
+ dlg . getButton ( android . content . DialogInterface . BUTTON_NEUTRAL )
139
+ ] ;
139
140
140
141
buttons . forEach ( ( button ) => {
141
142
if ( button ) {
142
143
button . setTextColor ( ( options . buttonInkColor || options . buttonTitleColor ) . android ) ;
143
144
}
144
145
} ) ;
145
146
}
146
- dlg . show ( ) ;
147
147
return dlg ;
148
148
}
149
149
@@ -203,7 +203,6 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
203
203
dlg . setButton (
204
204
android . content . DialogInterface . BUTTON_POSITIVE ,
205
205
options . okButtonText ,
206
- null ,
207
206
new android . content . DialogInterface . OnClickListener ( {
208
207
onClick : function ( dialog : android . content . DialogInterface , id : number ) {
209
208
onDone ( true , dialog ) ;
@@ -219,7 +218,6 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
219
218
dlg . setButton (
220
219
android . content . DialogInterface . BUTTON_NEGATIVE ,
221
220
options . cancelButtonText ,
222
- null ,
223
221
new android . content . DialogInterface . OnClickListener ( {
224
222
onClick : function ( dialog : android . content . DialogInterface , id : number ) {
225
223
onDone ( false , dialog ) ;
@@ -240,7 +238,6 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
240
238
dlg . setButton (
241
239
android . content . DialogInterface . BUTTON_NEUTRAL ,
242
240
options . neutralButtonText ,
243
- null ,
244
241
new android . content . DialogInterface . OnClickListener ( {
245
242
onClick : function ( dialog : android . content . DialogInterface , id : number ) {
246
243
onDone ( undefined , dialog ) ;
0 commit comments