package Ġcom . extensions . spanner Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . graphics . Bitmap Ċ import Ġandroid . graphics . Color Ċ import Ġandroid . graphics . Mask Filter Ċ import Ġandroid . graphics . Type face Ċ import Ġandroid . graphics . drawable . Drawable Ċ import Ġandroid . net . Uri Ċ import Ġandroid . support . annotation . Font Res Ċ import Ġandroid . support . v 4 . content . res . Resources Compat Ċ import Ġandroid . text . Layout Ċ import Ġandroid . text . Sp ann able Ċ import Ġandroid . text . Sp ann able StringBuilder Ċ import Ġandroid . text . Sp anned Ċ import Ġandroid . text . style . Absolute Size Span Ċ import Ġandroid . text . style . Alignment Span Ċ import Ġandroid . text . style . BackgroundColor Span Ċ import Ġandroid . text . style . Bullet Span Ċ import Ġandroid . text . style . Clickable Span Ċ import Ġandroid . text . style . Drawable Margin Span Ċ import Ġandroid . text . style . Dynamic Drawable Span Ċ import Ġandroid . text . style . ForegroundColor Span Ċ import Ġandroid . text . style . Icon Margin Span Ċ import Ġandroid . text . style . Image Span Ċ import Ġandroid . text . style . Leading Margin Span Ċ import Ġandroid . text . style . Mask Filter Span Ċ import Ġandroid . text . style . Quote Span Ċ import Ġandroid . text . style . Relative Size Span Ċ import Ġandroid . text . style . Scale X Span Ċ import Ġandroid . text . style . Stri ke through Span Ċ import Ġandroid . text . style . Style Span Ċ import Ġandroid . text . style . Sub script Span Ċ import Ġandroid . text . style . Sup erscript Span Ċ import Ġandroid . text . style . TextAppearance Span Ċ import Ġandroid . text . style . Type face Span Ċ import Ġandroid . text . style . URL Span Ċ import Ġandroid . text . style . Underline Span Ċ import Ġandroid . view . View Ċ import Ġjava . util . ArrayList Ċ Ċ open Ġclass ĠSpan Builder Ġ{ ĊĠĠĠ Ġprivate Ġval Ġspans Ġ= ĠArrayList < Span Builder >() ĊĠĠĠ Ġopen Ġfun Ġbuild ( builder Ġ: Sp ann able StringBuilder Ġ= ĠSp ann able StringBuilder ()) Ġ: Sp ann able Ġ{ ĊĠĠĠĠĠĠĠ Ġspans . forEach Ġ{ span Ġ-> Ġspan . build ( builder )} ĊĠĠĠĠĠĠĠ Ġreturn Ġbuilder ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġspan ( what Ġ: Any , Ġinit Ġ: Node . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchild Ġ= ĠNode ( what ) ĊĠĠĠĠĠĠĠ Ġchild . init () ĊĠĠĠĠĠĠĠ Ġspans . add ( child ) ĊĠĠĠĠĠĠĠ Ġreturn Ġthis ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġtext ( content Ġ: String ) Ġ: Span Builder Ġ{ ĊĠĠĠĠĠĠĠ Ġspans . add ( Leaf ( content )) ĊĠĠĠĠĠĠĠ Ġreturn Ġthis ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoperator Ġfun ĠString . unary Plus () Ġ= Ġtext ( this ) ĊĠĠĠ Ġfun Ġstyle ( style Ġ: Int , Ġspan Ġ: Style Span Ġ= ĠStyle Span ( style ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġnormal ( span Ġ: Style Span Ġ= ĠStyle Span ( Type face . NORMAL ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġbold ( span Ġ: Style Span Ġ= ĠStyle Span ( Type face . BOLD ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġitalic ( span Ġ: Style Span Ġ= ĠStyle Span ( Type face . ITAL IC ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġbold Italic ( span Ġ: Style Span Ġ= ĠStyle Span ( Type face . BOLD _ ITAL IC ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġunderline ( span Ġ: Underline Span Ġ= ĠUnder line Span (), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġfont face ( context Ġ: Context , Ġ@ Font Res Ġfamily Ġ: Int , Ġspan Ġ: Custom Type face Span Ġ= ĠCustom Type face Span ( Resources Compat . getFont ( context , Ġfamily ) !! ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġtype face ( family Ġ: String , Ġspan Ġ: Type face Span Ġ= ĠType face Span ( family ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġsans Ser if ( span Ġ: Type face Span Ġ= ĠType face Span (" sans - serif "), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġserif ( span Ġ: Type face Span Ġ= ĠType face Span (" serif "), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġmonospace ( span Ġ: Type face Span Ġ= ĠType face Span (" mono space "), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġappearance ( context Ġ: Context , Ġappearance Ġ: Int , Ġspan Ġ: TextAppearance Span Ġ= ĠText Appearance Span ( context , Ġappearance ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġsup erscript ( span Ġ: Sup erscript Span Ġ= ĠSup erscript Span (), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġsub script ( span Ġ: Sub script Span Ġ= ĠSub script Span (), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġstrike through ( span Ġ: Stri ke through Span Ġ= ĠStri ke through Span (), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġscale X ( pro portion Ġ: Float , Ġspan Ġ: Scale X Span Ġ= ĠScale X Span ( pro portion ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġrelative Size ( pro portion Ġ: Float , Ġspan Ġ: Relative Size Span Ġ= ĠRelative Size Span ( pro portion ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġabsolute Size ( size Ġ: Int , Ġdip Ġ: Boolean Ġ= Ġfalse , Ġspan Ġ: Absolute Size Span Ġ= ĠAbsolute Size Span ( size , Ġdip ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġquote ( color Ġ: Int Ġ= ĠColor . BLACK , Ġspan Ġ: Quote Span Ġ= ĠQuote Span ( color ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġmask ( filter Ġ: Mask Filter , Ġspan Ġ: Mask Filter Span Ġ= ĠMask Filter Span ( filter ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġleading Margin ( every Ġ: Int Ġ= Ġ 0 , Ġspan Ġ: Leading Margin Span Ġ= ĠLead ing Margin Span . Standard ( every ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġleading Margin ( first Ġ: Int Ġ= Ġ 0 , Ġrest Ġ: Int Ġ= Ġ 0 , Ġspan Ġ: Leading Margin Span Ġ= ĠLead ing Margin Span . Standard ( first , Ġrest ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġforeground Color ( color Ġ: Int Ġ= ĠColor . BLACK , Ġspan Ġ: ForegroundColor Span Ġ= ĠFore ground Color Span ( color ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun ĠbackgroundColor ( color Ġ: Int Ġ= ĠColor . BLACK , Ġspan Ġ: BackgroundColor Span Ġ= ĠBackground Color Span ( color ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġbullet ( gap Width Ġ: Int Ġ= Ġ 0 , Ġcolor Ġ: Int Ġ= ĠColor . BLACK , Ġspan Ġ: Bullet Span Ġ= ĠBullet Span ( gap Width , Ġcolor ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġalign ( align Ġ: Layout . Alignment Ġ= ĠLayout . Alignment . ALIGN _ NORMAL , Ġspan Ġ: Alignment Span . Standard Ġ= ĠAlignment Span . Standard ( align ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġdrawable Margin ( drawable Ġ: Drawable , Ġpadding Ġ: Int Ġ= Ġ 0 , Ġspan Ġ: Drawable Margin Span Ġ= ĠDrawable Margin Span ( drawable , Ġpadding ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġicon Margin ( bitmap Ġ: Bitmap , Ġpadding Ġ: Int Ġ= Ġ 0 , Ġspan Ġ: Icon Margin Span Ġ= ĠIcon Margin Span ( bitmap , Ġpadding ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġimage ( context Ġ: Context , Ġbitmap Ġ: Bitmap , Ġvertical Alignment Ġ: Int Ġ= ĠDynamic Drawable Span . ALIGN _ BOTTOM , Ġspan Ġ: Image Span Ġ= ĠImage Span ( context , Ġbitmap , Ġvertical Alignment ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġimage ( drawable Ġ: Drawable , Ġvertical Alignment Ġ: Int Ġ= ĠDynamic Drawable Span . ALIGN _ BOTTOM , Ġspan Ġ: Image Span Ġ= ĠImage Span ( drawable , Ġvertical Alignment ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġimage ( context Ġ: Context , Ġuri Ġ: Uri , Ġvertical Alignment Ġ: Int Ġ= ĠDynamic Drawable Span . ALIGN _ BOTTOM , Ġspan Ġ: Image Span Ġ= ĠImage Span ( context , Ġuri , Ġvertical Alignment ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġimage ( context Ġ: Context , Ġresource Id Ġ: Int , Ġvertical Alignment Ġ: Int Ġ= ĠDynamic Drawable Span . ALIGN _ BOTTOM , Ġspan Ġ: Image Span Ġ= ĠImage Span ( context , Ġresource Id , Ġvertical Alignment ), Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĠĠĠ Ġfun Ġclick able ( onClick Ġ:( Clickable Span ) Ġ-> ĠUnit , Ġspan Ġ: Clickable Span Ġ= Ġobject Ġ: Clickable Span () Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun ĠonClick ( view Ġ: View ?) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠonClick ( this ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}, Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĊĠĠĠ Ġfun Ġurl ( url Ġ: String , ĠonClick Ġ:( URL Span ) Ġ-> ĠBoolean , Ġspan Ġ: URL Span Ġ= Ġobject Ġ: URL Span ( url ) Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun ĠonClick ( widget Ġ: View ?) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif ( onClick ( this )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsuper . onClick ( widget ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}, Ġinit Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ= Ġspan ( span , Ġinit ) ĊĊĠĠĠ Ġclass ĠNode ( val Ġspan Ġ: Any ) Ġ: Span Builder () Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġbuild ( builder Ġ: Sp ann able StringBuilder ) Ġ: Sp ann able Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġstart Ġ= Ġbuilder . length ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsuper . build ( builder ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbuilder . set Span ( span , Ġstart , Ġbuilder . length , ĠSp anned . SPAN _ INCL USIVE _ EXCL USIVE ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġbuilder ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġclass ĠLeaf ( val Ġcontent Ġ: Any ) Ġ: Span Builder () Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġbuild ( builder Ġ: Sp ann able StringBuilder ) Ġ: Sp ann able Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbuilder . append ( content . toString ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġbuilder ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun Ġspan ( init Ġ: Span Builder . () Ġ-> ĠUnit ) Ġ: Span Builder Ġ{ ĊĠĠĠ Ġval Ġspan With Children Ġ= ĠSpan Builder () ĊĠĠĠ Ġspan With Children . init () ĊĠĠĠ Ġreturn Ġspan With Children Ċ }