ConversationsAdapter: Do not show attachment icon + text if attachment is audio or location
This commit is contained in:
parent
8e4df80619
commit
fced4a454e
|
@ -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);
|
||||
|
||||
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);
|
||||
imagePreview.setVisibility(View.GONE);
|
||||
} 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);
|
||||
if (preview.second) {
|
||||
if (conversation.isRead()) {
|
||||
mLastMessage.setTypeface(null, Typeface.ITALIC);
|
||||
|
@ -123,15 +144,6 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
|||
mSenderName.setText(activity.getString(R.string.me)+':');
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue