6
6
import android .content .res .Configuration ;
7
7
import android .content .res .TypedArray ;
8
8
import android .os .Build ;
9
- import android .text .Html ;
10
9
import android .text .Spanned ;
11
10
import android .view .LayoutInflater ;
12
11
import android .view .View ;
26
25
import dev .shreyaspatil .MaterialDialog .interfaces .OnDismissListener ;
27
26
import dev .shreyaspatil .MaterialDialog .interfaces .OnShowListener ;
28
27
import dev .shreyaspatil .MaterialDialog .model .DialogButton ;
29
- import dev .shreyaspatil .MaterialDialog .model .DialogText ;
28
+ import dev .shreyaspatil .MaterialDialog .model .DialogMessage ;
29
+ import dev .shreyaspatil .MaterialDialog .model .DialogTitle ;
30
30
import dev .shreyaspatil .MaterialDialog .model .TextAlignment ;
31
31
32
32
@ SuppressWarnings ("unused" )
@@ -40,8 +40,8 @@ public abstract class AbstractDialog implements DialogInterface {
40
40
41
41
protected Dialog mDialog ;
42
42
protected Activity mActivity ;
43
- protected DialogText title ;
44
- protected DialogText message ;
43
+ protected DialogTitle title ;
44
+ protected DialogMessage message ;
45
45
protected boolean mCancelable ;
46
46
protected DialogButton mPositiveButton ;
47
47
protected DialogButton mNegativeButton ;
@@ -57,8 +57,8 @@ public abstract class AbstractDialog implements DialogInterface {
57
57
protected OnShowListener mOnShowListener ;
58
58
59
59
protected AbstractDialog (@ NonNull Activity mActivity ,
60
- @ NonNull DialogText title ,
61
- @ NonNull DialogText message ,
60
+ @ NonNull DialogTitle title ,
61
+ @ NonNull DialogMessage message ,
62
62
boolean mCancelable ,
63
63
@ NonNull DialogButton mPositiveButton ,
64
64
@ NonNull DialogButton mNegativeButton ,
@@ -98,13 +98,8 @@ protected View createView(@NonNull LayoutInflater inflater, @Nullable ViewGroup
98
98
// Set Message
99
99
if (message != null ) {
100
100
mMessageView .setVisibility (View .VISIBLE );
101
- Spanned spannedMessage = null ;
102
- if (android .os .Build .VERSION .SDK_INT >= android .os .Build .VERSION_CODES .N ) {
103
- spannedMessage = Html .fromHtml (message .getText (), Html .FROM_HTML_MODE_COMPACT );
104
- } else {
105
- spannedMessage = Html .fromHtml (message .getText ());
106
- }
107
- mMessageView .setText (spannedMessage );
101
+
102
+ mMessageView .setText (message .getText ());
108
103
mMessageView .setTextAlignment (message .getTextAlignment ().getAlignment ());
109
104
} else {
110
105
mMessageView .setVisibility (View .GONE );
@@ -349,8 +344,8 @@ public interface OnClickListener {
349
344
*/
350
345
public static abstract class Builder <D extends AbstractDialog > {
351
346
protected final Activity activity ;
352
- protected DialogText title ;
353
- protected DialogText message ;
347
+ protected DialogTitle title ;
348
+ protected DialogMessage message ;
354
349
protected boolean isCancelable ;
355
350
protected DialogButton positiveButton ;
356
351
protected DialogButton negativeButton ;
@@ -380,12 +375,12 @@ public Builder<D> setTitle(@NonNull String title) {
380
375
*/
381
376
@ NonNull
382
377
public Builder <D > setTitle (@ NonNull String title , @ NonNull TextAlignment alignment ) {
383
- this .title = new DialogText (title , alignment );
378
+ this .title = new DialogTitle (title , alignment );
384
379
return this ;
385
380
}
386
381
387
382
/**
388
- * @param message Sets the Message of Material Dialog with the default alignment as center.
383
+ * @param message Sets the plain text Message of Material Dialog with the default alignment as center.
389
384
* @return this, for chaining.
390
385
*/
391
386
@ NonNull
@@ -394,13 +389,33 @@ public Builder<D> setMessage(@NonNull String message) {
394
389
}
395
390
396
391
/**
397
- * @param message Sets the Message of Material Dialog.
392
+ * @param message Sets the plain text Message of Material Dialog.
398
393
* @param alignment Sets the Alignment for the message.
399
394
* @return this, for chaining.
400
395
*/
401
396
@ NonNull
402
397
public Builder <D > setMessage (@ NonNull String message , @ NonNull TextAlignment alignment ) {
403
- this .message = new DialogText (message , alignment );
398
+ this .message = DialogMessage .text (message , alignment );
399
+ return this ;
400
+ }
401
+
402
+ /**
403
+ * @param message Sets the spanned text Message of Material Dialog with the default alignment as center.
404
+ * @return this, for chaining.
405
+ */
406
+ @ NonNull
407
+ public Builder <D > setMessage (@ NonNull Spanned message ) {
408
+ return setMessage (message , TextAlignment .CENTER );
409
+ }
410
+
411
+ /**
412
+ * @param message Sets the spanned text Message of Material Dialog.
413
+ * @param alignment Sets the Alignment for the message.
414
+ * @return this, for chaining.
415
+ */
416
+ @ NonNull
417
+ public Builder <D > setMessage (@ NonNull Spanned message , @ NonNull TextAlignment alignment ) {
418
+ this .message = DialogMessage .spanned (message , alignment );
404
419
return this ;
405
420
}
406
421
0 commit comments