Highlight header names

This commit is contained in:
M66B 2018-12-27 17:35:26 +00:00
parent 0ee99f20dc
commit f22bdd4e80
1 changed files with 16 additions and 1 deletions

View File

@ -51,6 +51,7 @@ import android.text.format.DateUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ImageSpan;
import android.text.style.QuoteSpan;
import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.view.LayoutInflater;
import android.view.Menu;
@ -523,7 +524,21 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvKeywords.setText(TextUtils.join(" ", message.keywords));
tvKeywords.setVisibility(message.keywords.length > 0 ? View.VISIBLE : View.GONE);
tvHeaders.setText(show_headers ? message.headers : null);
if (show_headers && message.headers != null) {
SpannableStringBuilder ssb = new SpannableStringBuilder(message.headers);
int index = 0;
for (String line : message.headers.split("\n")) {
if (!Character.isWhitespace(line.charAt(0))) {
int colon = line.indexOf(':');
if (colon > 0)
ssb.setSpan(new StyleSpan(Typeface.BOLD), index, index + colon, 0);
}
index += line.length() + 1;
}
tvHeaders.setText(ssb);
} else
tvHeaders.setText(null);
for (int i = 0; i < bnvActions.getMenu().size(); i++)
bnvActions.getMenu().getItem(i).setVisible(false);