Skip to content

Commit da1a290

Browse files
committed
Minor refactoring, comments.
1 parent 7215206 commit da1a290

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,6 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
480480
styles.getBoolean(R.styleable.AztecText_taskListStrikethroughChecked, false),
481481
styles.getColor(R.styleable.AztecText_taskListCheckedTextColor, 0))
482482

483-
val textSizeModifier = styles.getDimensionPixelSize(R.styleable.AztecText_textSizeModifier, 0)
484-
485483
blockFormatter = BlockFormatter(editor = this,
486484
listStyle = listStyle,
487485
listItemStyle = listItemStyle,
@@ -498,32 +496,32 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
498496
headerStyle = BlockFormatter.HeaderStyles(verticalHeadingMargin, mapOf(
499497
AztecHeadingSpan.Heading.H1 to BlockFormatter.HeaderStyles.HeadingStyle(
500498
styles.getDimensionPixelSize(R.styleable.AztecText_headingOneFontSize, 0),
501-
textSizeModifier,
499+
0,
502500
styles.getColor(R.styleable.AztecText_headingOneFontColor, 0)
503501
),
504502
AztecHeadingSpan.Heading.H2 to BlockFormatter.HeaderStyles.HeadingStyle(
505503
styles.getDimensionPixelSize(R.styleable.AztecText_headingTwoFontSize, 0),
506-
textSizeModifier,
504+
0,
507505
styles.getColor(R.styleable.AztecText_headingTwoFontColor, 0)
508506
),
509507
AztecHeadingSpan.Heading.H3 to BlockFormatter.HeaderStyles.HeadingStyle(
510508
styles.getDimensionPixelSize(R.styleable.AztecText_headingThreeFontSize, 0),
511-
textSizeModifier,
509+
0,
512510
styles.getColor(R.styleable.AztecText_headingThreeFontColor, 0)
513511
),
514512
AztecHeadingSpan.Heading.H4 to BlockFormatter.HeaderStyles.HeadingStyle(
515513
styles.getDimensionPixelSize(R.styleable.AztecText_headingFourFontSize, 0),
516-
textSizeModifier,
514+
0,
517515
styles.getColor(R.styleable.AztecText_headingFourFontColor, 0)
518516
),
519517
AztecHeadingSpan.Heading.H5 to BlockFormatter.HeaderStyles.HeadingStyle(
520518
styles.getDimensionPixelSize(R.styleable.AztecText_headingFiveFontSize, 0),
521-
textSizeModifier,
519+
0,
522520
styles.getColor(R.styleable.AztecText_headingFiveFontColor, 0)
523521
),
524522
AztecHeadingSpan.Heading.H6 to BlockFormatter.HeaderStyles.HeadingStyle(
525523
styles.getDimensionPixelSize(R.styleable.AztecText_headingSixFontSize, 0),
526-
textSizeModifier,
524+
0,
527525
styles.getColor(R.styleable.AztecText_headingSixFontColor, 0)
528526
)
529527
)),
@@ -537,7 +535,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
537535
styles.getColor(R.styleable.AztecText_preformatBorderColor, 0),
538536
styles.getDimensionPixelSize(R.styleable.AztecText_preformatBorderRadius, 0),
539537
styles.getDimensionPixelSize(R.styleable.AztecText_preformatBorderThickness, 0),
540-
styles.getDimensionPixelSize(R.styleable.AztecText_preformatTextSize, textSize.toInt()) + textSizeModifier
538+
styles.getDimensionPixelSize(R.styleable.AztecText_preformatTextSize, textSize.toInt())
541539
),
542540
alignmentRendering = alignmentRendering,
543541
exclusiveBlockStyles = BlockFormatter.ExclusiveBlockStyles(styles.getBoolean(R.styleable.AztecText_exclusiveBlocks, false), verticalParagraphPadding),
@@ -623,15 +621,15 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
623621

624622
enableTextChangedListener()
625623

626-
if (textSize + textSizeModifier >= 0) {
627-
setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize + textSizeModifier)
628-
} else {
629-
setTextSize(TypedValue.COMPLEX_UNIT_PX, 0f)
630-
}
631-
632624
isViewInitialized = true
633625
}
634626

627+
/**
628+
Sets the modifier that will be added to the base text size.
629+
This is useful for situations where you have specified heading font size, instead or relying on default scaling.
630+
631+
Params: – textSizeModifierPx: the modifier in pixels
632+
*/
635633
fun setTextSizeModifier(textSizeModifierPx: Int) {
636634
blockFormatter.setTextSizeModifier(textSizeModifierPx)
637635
if (textSize + textSizeModifierPx >= 0) {

0 commit comments

Comments
 (0)