7
7
import android .os .Bundle ;
8
8
9
9
import android .text .Html ;
10
+ import android .text .util .Linkify ;
10
11
import android .util .TypedValue ;
11
12
12
13
import android .view .View ;
@@ -44,6 +45,7 @@ public class KAlertDialog extends AlertDialog implements View.OnClickListener {
44
45
45
46
private boolean mShowCancel , mShowContent , mShowTitleText , mCloseFromCancel , mShowConfirm ;
46
47
private int contentTextSize = 0 ;
48
+ private int titleTextSize = 0 ;
47
49
48
50
private FrameLayout mErrorFrame , mSuccessFrame , mProgressFrame , mWarningFrame ;
49
51
@@ -195,7 +197,7 @@ private void changeAlertType(int alertType, boolean fromCreate) {
195
197
setConfirmButtonColor (mColor );
196
198
break ;
197
199
case CUSTOM_IMAGE_TYPE :
198
- setCustomImage (mCustomImgDrawable );
200
+ setCustomImage1 (mCustomImgDrawable );
199
201
setConfirmButtonColor (mColor );
200
202
break ;
201
203
case PROGRESS_TYPE :
@@ -223,6 +225,9 @@ public KAlertDialog setTitleText(String text) {
223
225
mTitleText = text ;
224
226
if (mTitleTextView != null && mTitleText != null ) {
225
227
showTitleText ();
228
+ if (titleTextSize != 0 ) {
229
+ mTitleTextView .setTextSize (TypedValue .COMPLEX_UNIT_PX , spToPx (titleTextSize , getContext ()));
230
+ }
226
231
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
227
232
mTitleTextView .setText (Html .fromHtml (mTitleText ,1 ));
228
233
}else {
@@ -236,18 +241,19 @@ private void showTitleText() {
236
241
mShowTitleText = true ;
237
242
if (mTitleTextView != null ) {
238
243
mTitleTextView .setVisibility (View .VISIBLE );
244
+ mContentTextView .setAutoLinkMask (Linkify .ALL );
239
245
}
240
246
}
241
247
242
248
public KAlertDialog setCustomImage (int resourceId , Context context ) {
243
249
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
244
- return setCustomImage (getContext ().getResources ().getDrawable (resourceId ,context .getTheme ()));
250
+ return setCustomImage1 (getContext ().getResources ().getDrawable (resourceId ,context .getTheme ()));
245
251
} else {
246
- return setCustomImage (getContext ().getResources ().getDrawable (resourceId ));
252
+ return setCustomImage1 (getContext ().getResources ().getDrawable (resourceId ));
247
253
}
248
254
}
249
255
250
- public KAlertDialog setCustomImage (Drawable drawable ) {
256
+ private KAlertDialog setCustomImage1 (Drawable drawable ) {
251
257
mCustomImgDrawable = drawable ;
252
258
if (mCustomImage != null && mCustomImgDrawable != null ) {
253
259
mCustomImage .setVisibility (View .VISIBLE );
@@ -264,7 +270,7 @@ public KAlertDialog setContentText(String text) {
264
270
mContentTextView .setTextSize (TypedValue .COMPLEX_UNIT_PX , spToPx (contentTextSize , getContext ()));
265
271
}
266
272
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
267
- mContentTextView .setText (Html .fromHtml (mContentText ,1 ));
273
+ mContentTextView .setText (Html .fromHtml (mContentText ,0 ));
268
274
}else {
269
275
mContentTextView .setText (Html .fromHtml (mContentText ));
270
276
}
@@ -293,6 +299,7 @@ private void showContentText () {
293
299
mShowContent = true ;
294
300
if (mContentTextView != null ) {
295
301
mContentTextView .setVisibility (View .VISIBLE );
302
+ mContentTextView .setAutoLinkMask (Linkify .ALL );
296
303
}
297
304
}
298
305
@@ -424,6 +431,15 @@ public KAlertDialog cancelButtonColor (int color, Context context){
424
431
}
425
432
}
426
433
434
+ public KAlertDialog setTitleTextSize (int value ){
435
+ this .titleTextSize = value ;
436
+ return this ;
437
+ }
438
+
439
+ public int getTitleTextSize () {
440
+ return titleTextSize ;
441
+ }
442
+
427
443
public KAlertDialog setContentTextSize ( int value ){
428
444
this .contentTextSize = value ;
429
445
return this ;
0 commit comments