From efa62f7619ca675c101f2b44feca429177696bf2 Mon Sep 17 00:00:00 2001 From: akwizgran <akwizgran@users.sourceforge.net> Date: Sat, 8 Feb 2014 18:21:21 +0000 Subject: [PATCH] Show paperclip icon for non-text messages. --- .../android/contact/ConversationAdapter.java | 19 ++++++++--------- .../android/groups/GroupAdapter.java | 21 +++++++++---------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java b/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java index a48ed35b83..ff514ef239 100644 --- a/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java +++ b/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java @@ -22,8 +22,8 @@ import android.text.format.DateUtils; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.ImageButton; import android.widget.LinearLayout; -import android.widget.ProgressBar; import android.widget.TextView; class ConversationAdapter extends ArrayAdapter<ConversationItem> { @@ -64,7 +64,7 @@ class ConversationAdapter extends ArrayAdapter<ConversationItem> { date.setText(DateUtils.formatSameDayTime(then, now, SHORT, SHORT)); headerLayout.addView(date); - if(!item.isExpanded()) return headerLayout; + if(!item.isExpanded() || item.getBody() == null) return headerLayout; LinearLayout expanded = new LinearLayout(ctx); expanded.setOrientation(VERTICAL); @@ -72,18 +72,17 @@ class ConversationAdapter extends ArrayAdapter<ConversationItem> { expanded.setBackgroundColor(background); expanded.addView(headerLayout); - byte[] body = item.getBody(); - if(body == null) { - ProgressBar progress = new ProgressBar(ctx); - progress.setPadding(pad, 0, pad, pad); - progress.setIndeterminate(true); - expanded.addView(progress); - } else if(header.getContentType().equals("text/plain")) { + if(header.getContentType().equals("text/plain")) { TextView text = new TextView(ctx); text.setPadding(pad, 0, pad, pad); text.setBackgroundColor(background); - text.setText(StringUtils.fromUtf8(body)); + text.setText(StringUtils.fromUtf8(item.getBody())); expanded.addView(text); + } else { + ImageButton attachment = new ImageButton(ctx); + attachment.setPadding(pad, 0, pad, pad); + attachment.setImageResource(R.drawable.content_attachment); + expanded.addView(attachment); } return expanded; diff --git a/briar-android/src/org/briarproject/android/groups/GroupAdapter.java b/briar-android/src/org/briarproject/android/groups/GroupAdapter.java index 1953666774..72de5bee56 100644 --- a/briar-android/src/org/briarproject/android/groups/GroupAdapter.java +++ b/briar-android/src/org/briarproject/android/groups/GroupAdapter.java @@ -22,8 +22,8 @@ import android.text.format.DateUtils; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.ImageButton; import android.widget.LinearLayout; -import android.widget.ProgressBar; import android.widget.TextView; class GroupAdapter extends ArrayAdapter<GroupItem> { @@ -66,7 +66,7 @@ class GroupAdapter extends ArrayAdapter<GroupItem> { date.setText(DateUtils.formatSameDayTime(then, now, SHORT, SHORT)); headerLayout.addView(date); - if(!item.isExpanded()) return headerLayout; + if(!item.isExpanded() || item.getBody() == null) return headerLayout; LinearLayout expanded = new LinearLayout(ctx); expanded.setOrientation(VERTICAL); @@ -74,20 +74,19 @@ class GroupAdapter extends ArrayAdapter<GroupItem> { expanded.setBackgroundColor(background); expanded.addView(headerLayout); - byte[] body = item.getBody(); - if(body == null) { - ProgressBar progress = new ProgressBar(ctx); - progress.setPadding(pad, 0, pad, pad); - progress.setIndeterminate(true); - expanded.addView(progress); - } else if(header.getContentType().equals("text/plain")) { + if(header.getContentType().equals("text/plain")) { TextView text = new TextView(ctx); text.setPadding(pad, 0, pad, pad); text.setBackgroundColor(background); - text.setText(StringUtils.fromUtf8(body)); + text.setText(StringUtils.fromUtf8(item.getBody())); expanded.addView(text); + } else { + ImageButton attachment = new ImageButton(ctx); + attachment.setPadding(pad, 0, pad, pad); + attachment.setImageResource(R.drawable.content_attachment); + expanded.addView(attachment); } return expanded; } -} +} \ No newline at end of file -- GitLab