Always show private messages expanded in conversation view. Bug #32.

This give a simple and usable interface; we can worry about collapsing
blocks of read messages later.
This commit is contained in:
akwizgran
2014-02-09 11:46:42 +00:00
parent 9de96553e3
commit 4178353c02
3 changed files with 32 additions and 57 deletions

View File

@@ -43,48 +43,48 @@ class ConversationAdapter extends ArrayAdapter<ConversationItem> {
Context ctx = getContext();
Resources res = ctx.getResources();
LinearLayout headerLayout = new LinearLayout(ctx);
headerLayout.setOrientation(HORIZONTAL);
headerLayout.setGravity(CENTER_VERTICAL);
LinearLayout layout = new LinearLayout(ctx);
layout.setOrientation(VERTICAL);
layout.setGravity(CENTER_HORIZONTAL);
int background;
if(header.isRead()) background = res.getColor(R.color.read_background);
else background = res.getColor(R.color.unread_background);
headerLayout.setBackgroundColor(background);
layout.setBackgroundColor(background);
LinearLayout headerLayout = new LinearLayout(ctx);
headerLayout.setOrientation(HORIZONTAL);
headerLayout.setGravity(CENTER_VERTICAL);
AuthorView authorView = new AuthorView(ctx);
authorView.setLayoutParams(WRAP_WRAP_1);
authorView.init(header.getAuthor().getName(), VERIFIED);
headerLayout.addView(authorView);
// FIXME: Factor this out into a TimestampView
TextView date = new TextView(ctx);
date.setTextSize(14);
date.setPadding(0, pad, pad, pad);
long then = header.getTimestamp(), now = System.currentTimeMillis();
date.setText(DateUtils.formatSameDayTime(then, now, SHORT, SHORT));
headerLayout.addView(date);
layout.addView(headerLayout);
if(!item.isExpanded() || item.getBody() == null) return headerLayout;
LinearLayout expanded = new LinearLayout(ctx);
expanded.setOrientation(VERTICAL);
expanded.setGravity(CENTER_HORIZONTAL);
expanded.setBackgroundColor(background);
expanded.addView(headerLayout);
if(header.getContentType().equals("text/plain")) {
if(item.getBody() == null) {
TextView ellipsis = new TextView(ctx);
ellipsis.setPadding(pad, 0, pad, pad);
ellipsis.setText("\u2026");
layout.addView(ellipsis);
} else if(header.getContentType().equals("text/plain")) {
TextView text = new TextView(ctx);
text.setPadding(pad, 0, pad, pad);
text.setBackgroundColor(background);
text.setText(StringUtils.fromUtf8(item.getBody()));
expanded.addView(text);
layout.addView(text);
} else {
ImageButton attachment = new ImageButton(ctx);
attachment.setPadding(pad, 0, pad, pad);
attachment.setImageResource(R.drawable.content_attachment);
expanded.addView(attachment);
layout.addView(attachment);
}
return expanded;
return layout;
}
}