From fced4a454ebc724b30b42f3446dd555df7d772cb Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 13 Nov 2017 18:37:12 +0100 Subject: [PATCH] ConversationsAdapter: Do not show attachment icon + text if attachment is audio or location --- .../ui/adapter/ConversationAdapter.java | 42 ++++++++++++------- src/main/res/layout/conversation_list_row.xml | 12 +++--- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index c4949636e..94adce717 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -32,8 +32,7 @@ public class ConversationAdapter extends ArrayAdapter { private XmppActivity activity; - public ConversationAdapter(XmppActivity activity, - List conversations) { + public ConversationAdapter(XmppActivity activity, List conversations) { super(activity, 0, conversations); this.activity = activity; } @@ -89,11 +88,33 @@ public class ConversationAdapter extends ArrayAdapter { imagePreview.setVisibility(View.VISIBLE); activity.loadBitmap(message, imagePreview); } else { - Pair preview = UIHelper.getMessagePreview(activity,message); - mLastMessage.setVisibility(View.VISIBLE); - mLastMessageImage.setVisibility(View.VISIBLE); + + final boolean showPreviewText; + if (message.getFileParams().runtime > 0) { + showPreviewText = false; + mLastMessageImage.setImageResource(activity.getThemeResource(R.attr.ic_attach_record, R.drawable.ic_attach_record)); + mLastMessageImage.setVisibility(View.VISIBLE); + } else if (message.getType() == Message.TYPE_FILE) { + showPreviewText = true; + mLastMessageImage.setImageResource(activity.getThemeResource(R.attr.ic_attach_document, R.drawable.ic_attach_document)); + mLastMessageImage.setVisibility(View.VISIBLE); + } else if (message.isGeoUri()) { + showPreviewText = false; + mLastMessageImage.setImageResource(activity.getThemeResource(R.attr.ic_attach_location, R.drawable.ic_attach_location)); + mLastMessageImage.setVisibility(View.VISIBLE); + } else { + showPreviewText = true; + mLastMessageImage.setVisibility(View.GONE); + } + + final Pair preview = UIHelper.getMessagePreview(activity,message); + if (showPreviewText) { + mLastMessage.setText(preview.first); + } else { + mLastMessageImage.setContentDescription(preview.first); + } + mLastMessage.setVisibility(showPreviewText ? View.VISIBLE : View.GONE); imagePreview.setVisibility(View.GONE); - mLastMessage.setText(preview.first); if (preview.second) { if (conversation.isRead()) { mLastMessage.setTypeface(null, Typeface.ITALIC); @@ -124,15 +145,6 @@ public class ConversationAdapter extends ArrayAdapter { } else { mSenderName.setVisibility(View.GONE); } - if (message.getFileParams().runtime > 0) { - mLastMessageImage.setImageResource(activity.getThemeResource(R.attr.ic_attach_record, R.drawable.ic_attach_record)); - } else if (message.getType() == Message.TYPE_FILE) { - mLastMessageImage.setImageResource(activity.getThemeResource(R.attr.ic_attach_document, R.drawable.ic_attach_document)); - } else if (message.isGeoUri()) { - mLastMessageImage.setImageResource(activity.getThemeResource(R.attr.ic_attach_location, R.drawable.ic_attach_location)); - } else { - mLastMessageImage.setVisibility(View.GONE); - } } long muted_till = conversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0); diff --git a/src/main/res/layout/conversation_list_row.xml b/src/main/res/layout/conversation_list_row.xml index dfcec3d02..635df530e 100644 --- a/src/main/res/layout/conversation_list_row.xml +++ b/src/main/res/layout/conversation_list_row.xml @@ -44,8 +44,8 @@ android:layout_alignLeft="@+id/conversation_lastwrapper" android:layout_toLeftOf="@+id/conversation_lastupdate" android:paddingRight="4dp" - android:singleLine="true" - android:text="Awesome groupchat" + android:maxLines="1" + android:ellipsize="end" android:textColor="?attr/color_text_primary" android:textSize="?attr/TextSizeHeadline" android:typeface="sans"/> @@ -82,7 +82,8 @@ + android:layout_height="?attr/IconSize" + android:layout_marginRight="?attr/TextSeparation"/> @@ -138,7 +139,6 @@ android:layout_alignBaseline="@+id/conversation_name" android:layout_alignParentRight="true" android:gravity="right" - android:text="23:42" android:textColor="?attr/color_text_secondary" android:textSize="?attr/TextSizeInfo"/>