Skip to content

Commit 04d03e3

Browse files
author
Salvatore Ranieri
committed
final list fix
1 parent 51e5aa7 commit 04d03e3

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

HtmlSpanner/src/main/java/com/sysdata/htmlspanner/HtmlSpanner.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ public class HtmlSpanner {
167167
*/
168168
public HtmlSpanner(int textColor,float textSize) {
169169
this(createHtmlCleaner(), new SystemFontResolver(),textColor,textSize);
170-
Paint paint = new Paint();
171-
paint.setTextSize(textSize);
172-
NUMBER_WIDTH = Math.round(paint.measureText("4."));
173-
BULLET_WIDTH = Math.round(paint.measureText("\u2022"));
174-
BLANK_WIDTH = Math.round(paint.measureText(" "));
175170
}
176171

177172
/**
@@ -184,9 +179,15 @@ public HtmlSpanner(int textColor,float textSize) {
184179
public HtmlSpanner(HtmlCleaner cleaner, FontResolver fontResolver,int textColor, float textSize) {
185180
this.htmlCleaner = cleaner;
186181
this.fontResolver = fontResolver;
187-
this.handlers = new HashMap<String, TagNodeHandler>();
182+
this.handlers = new HashMap<>();
188183
this.textColor=textColor;
189184
this.textSize=textSize;
185+
Paint paint = new Paint();
186+
paint.setTextSize(textSize);
187+
NUMBER_WIDTH = Math.round(paint.measureText("4."));
188+
if(NUMBER_WIDTH <= 0)
189+
BULLET_WIDTH = Math.round(paint.measureText("\u2022"));
190+
BLANK_WIDTH = Math.round(paint.measureText(" "));
190191
registerBuiltInHandlers();
191192
}
192193

app/src/main/java/com/sysdata/kt/sdhtmltextview/MainActivity.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ class MainActivity : AppCompatActivity() {
99
override fun onCreate(savedInstanceState: Bundle?) {
1010
super.onCreate(savedInstanceState)
1111
setContentView(R.layout.activity_main)
12-
textView.htmlText="<h1>That's a header 1</h1><h2>That's a header 2</h2><h3>That's a header 3</h3><h4>That's a header 4</h4><h5>That's a header 5</h5><h6>That's a header 6</h6>NomeCognome<br />MarioRossi<div style=\"line-height:30px\">Some text displayed in center position into a paragraph <span style=\"background-color:blue; color:white\">other text</span> (<code>span</code> markup used);<br /><big>big thing</big> (<code>big</code> markup used)<br /><small>this is not that important</small> (<code>small</code> markup used)<br />this is <em>very</em> simple (<code>em</code> markup used for emphasizing a word)<br /><cite>Origin of Species</cite> (a book title;<code>cite</code> markup used)<br /><em>Homo sapiens</em> (should appear in italics; <code>i</code> markup used)<br /><br /><strong>bolded</strong> (<code>b</code> markup used - just bolding with unspecified semantics)<div style=\"line-height:24px\"><br />&nbsp;</div><tt>text in monospace font</tt> (<code>tt</code> markup used)<br /><u>underlined</u> text (<code>u</code> markup used)<br /><strong>bolded</strong> (<code>strong</code> markup used)<ul><li>Test: <span>large size</span> (<code>font size=30px</code> markup used)</li><li>Test: <span style=\"color:red\">red text</span> (<code>font color=red</code> markup used)</li></ul>a<sub>B</sub> (<code>sub</code> markup used)<br />a<sup>C</sup> (<code>sup</code> markup used)</div><ol style=\"list-style-position:inside;\"><li>list element 1</li><li>list element 2</li></ol><div style=\"line-height:50px\">that's a div body and a line-height<br />with a <code>br</code> inside and a font styling<br /><span style=\"font-size:30px\">large size</span> (<code>style=&quot;font-size:30px&quot;</code> markup used)<br /><span style=\"font-family:Courier\">Courier font</span> (<code>style=&quot;font-family:Courier&quot;</code> markup used)<br /><span style=\"color:red\">red text</span> (<code>style=&quot;color:red&quot;</code> markup used)<br /><em>italic text</em> (<code>style=&quot;font-style:italic&quot;</code> markup used)<p style=\"text-align:left\">left text</p><p style=\"text-align:center\">centered text</p><p style=\"text-align:right\">right text</p>deleted text</div>"
12+
textView.htmlText="<div style=\"background-color: #272822\"><span style=\"color: #272822\">_</span><span style=\"color: #f8f8f2\">SDRootValidatorConfig</span> <span style=\"color: #f8f8f2\">config</span> <span style=\"color: #f92672\">=</span> <span style=\"color: #f8f8f2\">SDRootValidatorConfig</span>\n<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">newBuilder</span><span style=\"color: #f92672\">(</span><span style=\"color: #f8f8f2\">getContext</span><span style=\"color: #f92672\">())</span>\n" +
13+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">isRootCheckEnabled</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
14+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">checkForBinaryBusybox</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
15+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">checkForBinarySu</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
16+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">checkForDangerousProps</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
17+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">checkForMagiskBinary</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
18+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">checkForRootNative</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
19+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">checkForRWPaths</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
20+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">checkSuExists</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
21+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">detectPotentiallyDangerousApps</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
22+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">detectRootManagementApps</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
23+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">detectTestKeys</span><span style=\"color: #f92672\">(</span><span style=\"color: #66d9ef\">true</span><span style=\"color: #f92672\">)</span>\n" +
24+
"<span style=\"color: #272822\">_</span><span style=\"color: #f92672\">.</span><span style=\"color: #a6e22e\">build</span><span style=\"color: #f92672\">();</span>\n" +
25+
"</div>\n"
1326
}
1427
}

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
app:layout_constraintBottom_toBottomOf="parent"
1414
app:layout_constraintLeft_toLeftOf="parent"
1515
app:layout_constraintRight_toRightOf="parent"
16-
app:layout_constraintTop_toTopOf="parent"
17-
android:padding="25dp"/>
16+
app:layout_constraintTop_toTopOf="parent"/>
1817

1918
</android.support.constraint.ConstraintLayout>

0 commit comments

Comments
 (0)