28
28
import android .content .res .XmlResourceParser ;
29
29
import android .text .format .DateFormat ;
30
30
import android .util .Log ;
31
+ import android .view .View ;
31
32
import android .webkit .WebView ;
33
+ import android .widget .Button ;
32
34
33
35
import com .atomjack .vcfp .R ;
34
36
@@ -55,6 +57,8 @@ public class ChangeLogDialog {
55
57
56
58
protected DialogInterface .OnDismissListener mOnDismissListener ;
57
59
60
+ private View customView = null ;
61
+
58
62
public ChangeLogDialog (final Context context ) {
59
63
mContext = context ;
60
64
}
@@ -184,7 +188,7 @@ public String getHTML() {
184
188
//Create HTML change log
185
189
return getHTMLChangelog (R .xml .changelog , resources , 0 );
186
190
}
187
-
191
+
188
192
//Call to show the change log dialog
189
193
public void show () {
190
194
show (0 );
@@ -216,35 +220,58 @@ protected void show(final int version) {
216
220
return ;
217
221
}
218
222
219
- //Create web view and load html
220
- final WebView webView = new WebView (mContext );
221
- webView .loadDataWithBaseURL (null , htmlChangelog , "text/html" , "utf-8" , null );
222
- final AlertDialog .Builder builder = new AlertDialog .Builder (mContext )
223
- .setTitle (title )
224
- .setView (webView )
225
- .setPositiveButton (closeString , new Dialog .OnClickListener () {
223
+
224
+ final AlertDialog .Builder builder = new AlertDialog .Builder (mContext );
225
+ if (customView != null ) {
226
+ builder .setView (customView );
227
+ final AlertDialog dialog = builder .create ();
228
+ // customView.findViewWithTag()
229
+ WebView whatsNewWebView = (WebView )customView .findViewById (mContext .getResources ().getIdentifier ("whatsNewWebView" , "id" , mContext .getPackageName ()));
230
+ whatsNewWebView .loadDataWithBaseURL (null , htmlChangelog , "text/html" , "utf-8" , null );
231
+ Button whatsNewCloseButton = (Button )customView .findViewById (mContext .getResources ().getIdentifier ("whatsNewCloseButton" , "id" , mContext .getPackageName ()));
232
+ if (whatsNewCloseButton != null ) {
233
+ whatsNewCloseButton .setOnClickListener (new View .OnClickListener () {
234
+ @ Override
235
+ public void onClick (View v ) {
236
+ dialog .dismiss ();
237
+ }
238
+ });
239
+ }
240
+ dialog .show ();
241
+ } else {
242
+ //Create web view and load html
243
+ final WebView webView = new WebView (mContext );
244
+ webView .loadDataWithBaseURL (null , htmlChangelog , "text/html" , "utf-8" , null );
245
+
246
+ builder .setTitle (title )
247
+ .setView (webView )
248
+ .setPositiveButton (closeString , new Dialog .OnClickListener () {
226
249
public void onClick (final DialogInterface dialogInterface , final int i ) {
227
- dialogInterface .dismiss ();
250
+ dialogInterface .dismiss ();
228
251
}
229
- })
230
- .setOnCancelListener ( new OnCancelListener () {
231
-
232
- @ Override
233
- public void onCancel (DialogInterface dialog ) {
234
- dialog .dismiss ();
235
- }
236
- });
237
- AlertDialog dialog = builder .create ();
238
- dialog .setOnDismissListener (new DialogInterface .OnDismissListener () {
252
+ })
253
+ .setOnCancelListener (new OnCancelListener () {
254
+
255
+ @ Override
256
+ public void onCancel (DialogInterface dialog ) {
257
+ dialog .dismiss ();
258
+ }
259
+ });
260
+ AlertDialog dialog = builder .create ();
261
+ dialog .setOnDismissListener (new DialogInterface .OnDismissListener () {
239
262
@ Override
240
263
public void onDismiss (final DialogInterface dialog ) {
241
- if (mOnDismissListener != null ) {
242
- mOnDismissListener .onDismiss (dialog );
243
- }
264
+ if (mOnDismissListener != null ) {
265
+ mOnDismissListener .onDismiss (dialog );
266
+ }
244
267
}
245
- });
246
- dialog .show ();
268
+ });
269
+ dialog .show ();
270
+ }
247
271
}
248
272
273
+ public void setCustomView (View view ) {
274
+ customView = view ;
275
+ }
249
276
}
250
277
0 commit comments