mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-08 15:36:12 +00:00
Small improvements
This commit is contained in:
parent
1db2a69265
commit
ba16b871e3
1 changed files with 15 additions and 9 deletions
|
@ -20,8 +20,6 @@ package eu.faircode.email;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -74,13 +72,13 @@ public class StructuredEmail {
|
||||||
continue;
|
continue;
|
||||||
Object v = (jobject.isNull(key) ? "" : jobject.get(key));
|
Object v = (jobject.isNull(key) ? "" : jobject.get(key));
|
||||||
if (v instanceof JSONObject || v instanceof JSONArray) {
|
if (v instanceof JSONObject || v instanceof JSONArray) {
|
||||||
sb.append(split(key))
|
sb.append(unCamelCase(key))
|
||||||
.append(':')
|
.append(':')
|
||||||
.append('\n');
|
.append('\n');
|
||||||
getHtml(v, indent + 1, sb);
|
getHtml(v, indent + 1, sb);
|
||||||
} else {
|
} else {
|
||||||
sb.append(indent(indent))
|
sb.append(indent(indent))
|
||||||
.append(split(key))
|
.append(unCamelCase(key))
|
||||||
.append(": ")
|
.append(": ")
|
||||||
.append(v)
|
.append(v)
|
||||||
.append('\n');
|
.append('\n');
|
||||||
|
@ -97,19 +95,27 @@ public class StructuredEmail {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String split(String key) {
|
private static String unCamelCase(String key) {
|
||||||
|
boolean split = false;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < key.length(); i++) {
|
for (int i = 0; i < key.length(); i++) {
|
||||||
char kar = key.charAt(i);
|
char kar = key.charAt(i);
|
||||||
if (Character.isUpperCase(kar))
|
if (Character.isUpperCase(kar)) {
|
||||||
sb.append(' ').append(Character.toLowerCase(kar));
|
if (split)
|
||||||
else
|
sb.append(kar);
|
||||||
|
else {
|
||||||
|
split = true;
|
||||||
|
sb.append(' ').append(Character.toLowerCase(kar));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
split = false;
|
||||||
sb.append(kar);
|
sb.append(kar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String indent(int count) {
|
private static String indent(int count) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
|
Loading…
Reference in a new issue