FormatManager¶
-
public class
FormatManager
implements ListenableEditText.onSelectionChangedListener¶ Created by Drew Gregory on 3/26/18. This class provides a little decomposition from CreatePost/SpeciticPostActivity in that it handles all the formatting involved in writing posts/post replies. The supported formatting is: - bold - italic - links This formatting is embedded in the SpannableStrings that EditTexts can produce and maintain. This manager will also handle the tedious tasks of updating the toggle icons and maintaining state. When the user is done formatting and wants to publish their post/post reply, call the toString(), which will convert the spannable to a string with the proper tags as specified by Ian Nottage: Bold text Italic text Link text
Constructors¶
FormatManager¶
-
FormatManager
(ListenableEditText content, IconUpdateListener listener, int boldIcon, int italicIcon, int linkIcon)¶
Methods¶
abbreviateNumber¶
-
public static String
abbreviateNumber
(long number)¶ In the interest of screen space and accessibility, we will format the number to have a magnitude suffix instead of the exact number.
Parameters: - number – exact number, in floating point if necessary.
Returns: Formatted String representing number magnitude (e.x. 100K)
fromHtml¶
-
public static Spanned
fromHtml
(String html)¶ Different Android versions use different fromHtml method signatures. Sourced from https://stackoverflow.com/questions/37904739/html-fromhtml-deprecated-in-android-n
Parameters: - html –
parseText¶
-
public static Spanned
parseText
(String formattedText, String colorString)¶ This function converts the CultureMesh tags into a spannable string for textview.
Parameters: - formattedText – should only have
<b></b>, <link></link>, <i></i> or [b][/b][link][/link][i][/i]
- colorString – the link color in RGB. Some text has different color backgrounds.
Returns: Spannable to be passed to TextView.
- formattedText – should only have