@@ -33,18 +33,42 @@ import android.text.style.LineHeightSpan
3333import android.text.style.QuoteSpan
3434import android.text.style.UpdateLayout
3535import androidx.collection.ArrayMap
36+ import org.wordpress.aztec.AlignmentApproach
3637import org.wordpress.aztec.AztecAttributes
3738import org.wordpress.aztec.formatting.BlockFormatter
3839import java.util.Locale
3940
40- class AztecQuoteSpan (
41+ fun createAztecQuoteSpan (
42+ nestingLevel : Int ,
43+ attributes : AztecAttributes = AztecAttributes (),
44+ alignmentApproach : AlignmentApproach ,
45+ quoteStyle : BlockFormatter .QuoteStyle = BlockFormatter .QuoteStyle (0, 0, 0f, 0, 0, 0, 0)
46+ ) = when (alignmentApproach) {
47+ AlignmentApproach .SPAN_LEVEL -> AztecQuoteSpanAligned (nestingLevel, attributes, quoteStyle, null )
48+ AlignmentApproach .VIEW_LEVEL -> AztecQuoteSpan (nestingLevel, attributes, quoteStyle)
49+ }
50+
51+ /* *
52+ * We need to have two classes for handling alignment at either the Span-level (AztecQuoteSpanAligned)
53+ * or the View-level (AztecQuoteSpan). IAztecAlignment implements AlignmentSpan, which has a
54+ * getAlignment method that returns a non-null Layout.Alignment. The Android system checks for
55+ * AlignmentSpans and, if present, overrides the view's gravity with their value. Having a class
56+ * that does not implement AlignmentSpan allows the view's gravity to control. These classes should
57+ * be created using the createAztecQuoteSpan(...) methods.
58+ */
59+ class AztecQuoteSpanAligned (
60+ nestingLevel : Int ,
61+ attributes : AztecAttributes ,
62+ quoteStyle : BlockFormatter .QuoteStyle ,
63+ override var align : Layout .Alignment ?
64+ ) : AztecQuoteSpan(nestingLevel, attributes, quoteStyle), IAztecAlignmentSpan
65+
66+ open class AztecQuoteSpan (
4167 override var nestingLevel : Int ,
42- override var attributes : AztecAttributes = AztecAttributes (),
43- var quoteStyle : BlockFormatter .QuoteStyle = BlockFormatter .QuoteStyle (0, 0, 0f, 0, 0, 0, 0),
44- override var align : Layout .Alignment ? = null
68+ override var attributes : AztecAttributes ,
69+ var quoteStyle : BlockFormatter .QuoteStyle
4570 ) : QuoteSpan(),
4671 LineBackgroundSpan ,
47- IAztecAlignmentSpan ,
4872 IAztecBlockSpan ,
4973 LineHeightSpan ,
5074 UpdateLayout
0 commit comments