MCPcopy Create free account
hub / github.com/M66B/FairEmail / getData

Method getData

app/src/main/java/eu/faircode/email/EntityAnswer.java:120–262  ·  view source on GitHub ↗
(Context context, Address[] address)

Source from the content-addressed store, hash-verified

118 private static final String PREF_PLACEHOLDER = "answer.value.";
119
120 @NonNull
121 Data getData(Context context, Address[] address) {
122 Data result = new Data();
123
124 Document doc = JsoupEx.parse(text);
125 for (Element span : doc.select("span")) {
126 Node node = span.firstChild();
127 if (node instanceof TextNode) {
128 String text = ((TextNode) node).getWholeText().trim();
129 if (text.startsWith(ATTACHMENT_PREFIX) && text.endsWith(ATTACHMENT_SUFFIX)) {
130 String name = text.substring(ATTACHMENT_PREFIX.length(), text.length() - 1);
131 result.attachments.add(Uri.parse(name));
132
133 Element next = span.nextElementSibling();
134 span.remove();
135 if (next != null && "br".equals(next.nodeName()))
136 next.remove();
137 }
138 }
139 }
140
141 result.html = doc.html();
142
143 String fullName = null;
144 String email = null;
145 if (address != null && address.length > 0) {
146 fullName = ((InternetAddress) address[0]).getPersonal();
147 email = ((InternetAddress) address[0]).getAddress();
148 }
149
150 if (fullName != null) {
151 fullName = fullName.trim();
152 if (fullName.startsWith("\""))
153 fullName = fullName.substring(1);
154 if (fullName.endsWith("\""))
155 fullName = fullName.substring(0, fullName.length() - 1);
156 }
157
158 String first = fullName;
159 String last = null;
160 if (fullName != null) {
161 int c = fullName.lastIndexOf(',');
162 if (c > 0) {
163 last = fullName.substring(0, c).trim();
164 first = fullName.substring(c + 1).trim();
165 } else {
166 c = fullName.indexOf(' ');
167 if (c > 0) {
168 first = fullName.substring(0, c).trim();
169 last = fullName.substring(c + 1).trim();
170 } else {
171 c = fullName.indexOf('@');
172 if (c > 0) {
173 first = fullName.substring(0, c).trim();
174 last = null;
175 }
176 }
177 }

Callers 15

onExecuteMethod · 0.95
onExecuteMethod · 0.95
onItemClickMethod · 0.95
answerMethod · 0.95
getSummaryTextMethod · 0.95
onActivityResultMethod · 0.45
handleImportProvidersMethod · 0.45
onExecutedMethod · 0.45
onActivityResultMethod · 0.45
onActivityResultMethod · 0.45
loadMethod · 0.45

Calls 15

parseMethod · 0.95
trimMethod · 0.95
getEmailUserMethod · 0.95
parseIntMethod · 0.95
htmlMethod · 0.80
indexOfMethod · 0.80
escapeHtmlMethod · 0.80
getDateInstanceMethod · 0.80
joinMethod · 0.80
selectMethod · 0.65
lengthMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected