mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 20:59:54 +01:00
Show attachment icon if newest message in group is not plain text.
This commit is contained in:
@@ -17,6 +17,7 @@ import net.sf.briar.android.widgets.HorizontalSpace;
|
|||||||
import net.sf.briar.api.Rating;
|
import net.sf.briar.api.Rating;
|
||||||
import net.sf.briar.api.db.GroupMessageHeader;
|
import net.sf.briar.api.db.GroupMessageHeader;
|
||||||
import net.sf.briar.api.messaging.Author;
|
import net.sf.briar.api.messaging.Author;
|
||||||
|
import net.sf.briar.util.StringUtils;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
@@ -82,13 +83,15 @@ class GroupAdapter extends ArrayAdapter<GroupMessageHeader> {
|
|||||||
innerLayout.addView(authorLayout);
|
innerLayout.addView(authorLayout);
|
||||||
|
|
||||||
if(item.getContentType().equals("text/plain")) {
|
if(item.getContentType().equals("text/plain")) {
|
||||||
TextView subject = new TextView(ctx);
|
if(!StringUtils.isNullOrEmpty(item.getSubject())) {
|
||||||
subject.setTextSize(14);
|
TextView subject = new TextView(ctx);
|
||||||
subject.setMaxLines(2);
|
subject.setTextSize(14);
|
||||||
subject.setPadding(10, 0, 10, 10);
|
subject.setMaxLines(2);
|
||||||
if(!item.isRead()) subject.setTypeface(null, BOLD);
|
subject.setPadding(10, 0, 10, 10);
|
||||||
subject.setText(item.getSubject());
|
if(!item.isRead()) subject.setTypeface(null, BOLD);
|
||||||
innerLayout.addView(subject);
|
subject.setText(item.getSubject());
|
||||||
|
innerLayout.addView(subject);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
LinearLayout attachmentLayout = new LinearLayout(ctx);
|
LinearLayout attachmentLayout = new LinearLayout(ctx);
|
||||||
attachmentLayout.setOrientation(HORIZONTAL);
|
attachmentLayout.setOrientation(HORIZONTAL);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.sf.briar.android.groups;
|
package net.sf.briar.android.groups;
|
||||||
|
|
||||||
import static android.graphics.Typeface.BOLD;
|
import static android.graphics.Typeface.BOLD;
|
||||||
import static android.view.Gravity.LEFT;
|
|
||||||
import static android.widget.LinearLayout.HORIZONTAL;
|
import static android.widget.LinearLayout.HORIZONTAL;
|
||||||
import static android.widget.LinearLayout.VERTICAL;
|
import static android.widget.LinearLayout.VERTICAL;
|
||||||
import static java.text.DateFormat.SHORT;
|
import static java.text.DateFormat.SHORT;
|
||||||
@@ -10,6 +9,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import net.sf.briar.R;
|
import net.sf.briar.R;
|
||||||
import net.sf.briar.android.widgets.CommonLayoutParams;
|
import net.sf.briar.android.widgets.CommonLayoutParams;
|
||||||
|
import net.sf.briar.android.widgets.HorizontalSpace;
|
||||||
import net.sf.briar.util.StringUtils;
|
import net.sf.briar.util.StringUtils;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -20,6 +20,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -46,7 +47,6 @@ implements OnItemClickListener {
|
|||||||
// Give me all the unused width
|
// Give me all the unused width
|
||||||
innerLayout.setLayoutParams(CommonLayoutParams.WRAP_WRAP_1);
|
innerLayout.setLayoutParams(CommonLayoutParams.WRAP_WRAP_1);
|
||||||
innerLayout.setOrientation(VERTICAL);
|
innerLayout.setOrientation(VERTICAL);
|
||||||
innerLayout.setGravity(LEFT);
|
|
||||||
|
|
||||||
TextView name = new TextView(ctx);
|
TextView name = new TextView(ctx);
|
||||||
name.setTextSize(18);
|
name.setTextSize(18);
|
||||||
@@ -57,14 +57,25 @@ implements OnItemClickListener {
|
|||||||
else name.setText(item.getGroupName());
|
else name.setText(item.getGroupName());
|
||||||
innerLayout.addView(name);
|
innerLayout.addView(name);
|
||||||
|
|
||||||
if(!StringUtils.isNullOrEmpty(item.getSubject())) {
|
if(item.getContentType().equals("text/plain")) {
|
||||||
TextView subject = new TextView(ctx);
|
if(!StringUtils.isNullOrEmpty(item.getSubject())) {
|
||||||
subject.setTextSize(14);
|
TextView subject = new TextView(ctx);
|
||||||
subject.setMaxLines(2);
|
subject.setTextSize(14);
|
||||||
subject.setPadding(10, 0, 10, 10);
|
subject.setMaxLines(2);
|
||||||
if(unread > 0) subject.setTypeface(null, BOLD);
|
subject.setPadding(10, 0, 10, 10);
|
||||||
subject.setText(item.getSubject());
|
if(item.getUnreadCount() > 0) subject.setTypeface(null, BOLD);
|
||||||
innerLayout.addView(subject);
|
subject.setText(item.getSubject());
|
||||||
|
innerLayout.addView(subject);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LinearLayout attachmentLayout = new LinearLayout(ctx);
|
||||||
|
attachmentLayout.setOrientation(HORIZONTAL);
|
||||||
|
ImageView attachment = new ImageView(ctx);
|
||||||
|
attachment.setPadding(10, 0, 10, 10);
|
||||||
|
attachment.setImageResource(R.drawable.content_attachment);
|
||||||
|
attachmentLayout.addView(attachment);
|
||||||
|
attachmentLayout.addView(new HorizontalSpace(ctx));
|
||||||
|
innerLayout.addView(attachmentLayout);
|
||||||
}
|
}
|
||||||
layout.addView(innerLayout);
|
layout.addView(innerLayout);
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import net.sf.briar.api.messaging.GroupId;
|
|||||||
class GroupListItem {
|
class GroupListItem {
|
||||||
|
|
||||||
private final Group group;
|
private final Group group;
|
||||||
private final String authorName, subject;
|
private final String authorName, contentType, subject;
|
||||||
private final long timestamp;
|
private final long timestamp;
|
||||||
private final int unread;
|
private final int unread;
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ class GroupListItem {
|
|||||||
Author a = newest.getAuthor();
|
Author a = newest.getAuthor();
|
||||||
if(a == null) authorName = null;
|
if(a == null) authorName = null;
|
||||||
else authorName = a.getName();
|
else authorName = a.getName();
|
||||||
|
contentType = newest.getContentType();
|
||||||
subject = newest.getSubject();
|
subject = newest.getSubject();
|
||||||
timestamp = newest.getTimestamp();
|
timestamp = newest.getTimestamp();
|
||||||
int unread = 0;
|
int unread = 0;
|
||||||
@@ -43,6 +44,10 @@ class GroupListItem {
|
|||||||
return authorName;
|
return authorName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getContentType() {
|
||||||
|
return contentType;
|
||||||
|
}
|
||||||
|
|
||||||
String getSubject() {
|
String getSubject() {
|
||||||
return subject;
|
return subject;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user