Added render debugging

This commit is contained in:
M66B 2020-04-25 10:11:01 +02:00
parent e0bcd1764a
commit 02332b93b7
2 changed files with 18 additions and 2 deletions

View File

@ -245,6 +245,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean authentication;
private boolean language_detection;
private static boolean debug;
private boolean experiments;
private boolean gotoTop = false;
private boolean firstClick = false;
@ -1913,7 +1914,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
// Add debug info
if (debug) {
if (debug && !experiments) {
document.outputSettings().prettyPrint(true).outline(true).indentAmount(1);
String[] lines = document.html().split("\\r?\\n");
for (int i = 0; i < lines.length; i++)
@ -4646,6 +4647,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.language_detection = prefs.getBoolean("language_detection", false);
debug = prefs.getBoolean("debug", false);
this.experiments = prefs.getBoolean("experiments", false);
DiffUtil.ItemCallback<TupleMessageEx> callback = new DiffUtil.ItemCallback<TupleMessageEx>() {
@Override

View File

@ -1771,6 +1771,7 @@ public class HtmlHelper {
static Spanned fromDocument(Context context, @NonNull Document document, @Nullable Html.ImageGetter imageGetter, @Nullable Html.TagHandler tagHandler) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean experiments = prefs.getBoolean("experiments", false);
boolean debug = prefs.getBoolean("debug", false);
int colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
int dp3 = Helper.dp2pixels(context, 3);
int dp6 = Helper.dp2pixels(context, 6);
@ -1838,7 +1839,16 @@ public class HtmlHelper {
while (text.endsWith(" "))
text = text.substring(0, text.length() - 1);
tnode.text(text);
if (debug) {
if (i == 0)
tnode.text("<" + text);
else if (i == block.size() - 1)
tnode.text(text + ">");
else
tnode.text(text);
} else
tnode.text(text);
}
}
}, document.body());
@ -1855,6 +1865,8 @@ public class HtmlHelper {
if (node instanceof Element) {
element = (Element) node;
element.attr("start-index", Integer.toString(ssb.length()));
if (debug)
ssb.append("[" + element.tagName() + "]");
} else if (node instanceof TextNode) {
tnode = (TextNode) node;
ssb.append(tnode.text());
@ -1866,6 +1878,8 @@ public class HtmlHelper {
if (node instanceof Element) {
element = (Element) node;
int start = Integer.parseInt(element.attr("start-index"));
if (debug)
ssb.append("[/" + element.tagName() + "]");
switch (element.tagName()) {
case "a":
String href = element.attr("href");