(Context context, Address[] address)
| 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 | } |
no test coverage detected