ConversationsAdapter: Do not show attachment icon + text if attachment is audio or location

This commit is contained in:
Daniel Gultsch 2017-11-13 18:37:12 +01:00
parent 8e4df80619
commit fced4a454e
2 changed files with 33 additions and 21 deletions

View File

@ -32,8 +32,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
private XmppActivity activity;
public ConversationAdapter(XmppActivity activity,
List<Conversation> conversations) {
public ConversationAdapter(XmppActivity activity, List<Conversation> conversations) {
super(activity, 0, conversations);
this.activity = activity;
}
@ -89,11 +88,33 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
imagePreview.setVisibility(View.VISIBLE);
activity.loadBitmap(message, imagePreview);
} else {
Pair<String,Boolean> 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<String,Boolean> 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<Conversation> {
} 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);

View File

@ -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 @@
<ImageView
android:id="@+id/conversation_lastmsg_img"
android:layout_width="?attr/IconSize"
android:layout_height="?attr/IconSize" />
android:layout_height="?attr/IconSize"
android:layout_marginRight="?attr/TextSeparation"/>
<android.support.text.emoji.widget.EmojiTextView
android:id="@+id/conversation_lastmsg"
@ -91,8 +92,8 @@
android:minHeight="?attr/IconSize"
android:gravity="center_vertical"
android:scrollHorizontally="false"
android:singleLine="true"
android:text="This is a placeholder text to show the last messages"
android:maxLines="1"
android:ellipsize="end"
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeBody"/>
@ -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"/>
</RelativeLayout>