ConversationsAdapter: Do not show image preview. Show pictogram instead
This commit is contained in:
parent
9869310699
commit
614372dcbb
|
@ -74,70 +74,75 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean fileAvailable = message.getTransferable() == null || message.getTransferable().getStatus() != Transferable.STATUS_DELETED;
|
final boolean fileAvailable = message.getTransferable() == null || message.getTransferable().getStatus() != Transferable.STATUS_DELETED;
|
||||||
if (message.getFileParams().width > 0 && fileAvailable) {
|
final boolean showPreviewText;
|
||||||
viewHolder.sender.setVisibility(View.GONE);
|
if (fileAvailable && (message.isFileOrImage() || message.treatAsDownloadable() || message.isGeoUri())) {
|
||||||
viewHolder.lastMessage.setVisibility(View.GONE);
|
final int imageResource;
|
||||||
viewHolder.lastMessageIcon.setVisibility(View.GONE);
|
if (message.isGeoUri()) {
|
||||||
viewHolder.lastImage.setVisibility(View.VISIBLE);
|
imageResource = activity.getThemeResource(R.attr.ic_attach_location, R.drawable.ic_attach_location);
|
||||||
activity.loadBitmap(message, viewHolder.lastImage);
|
|
||||||
} else {
|
|
||||||
final boolean showPreviewText;
|
|
||||||
if (message.getType() == Message.TYPE_FILE && fileAvailable) {
|
|
||||||
if (message.getFileParams().runtime > 0) {
|
|
||||||
showPreviewText = false;
|
|
||||||
viewHolder.lastMessageIcon.setImageResource(activity.getThemeResource(R.attr.ic_attach_record, R.drawable.ic_attach_record));
|
|
||||||
} else {
|
|
||||||
showPreviewText = true;
|
|
||||||
viewHolder.lastMessageIcon.setImageResource(activity.getThemeResource(R.attr.ic_attach_document, R.drawable.ic_attach_document));
|
|
||||||
}
|
|
||||||
viewHolder.lastMessageIcon.setVisibility(View.VISIBLE);
|
|
||||||
} else if (message.isGeoUri()) {
|
|
||||||
showPreviewText = false;
|
showPreviewText = false;
|
||||||
viewHolder.lastMessageIcon.setImageResource(activity.getThemeResource(R.attr.ic_attach_location, R.drawable.ic_attach_location));
|
|
||||||
viewHolder.lastMessageIcon.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
} else {
|
||||||
showPreviewText = true;
|
final String mime = message.getMimeType();
|
||||||
viewHolder.lastMessageIcon.setVisibility(View.GONE);
|
switch (mime == null ? "" : mime.split("/")[0]) {
|
||||||
}
|
case "image":
|
||||||
|
imageResource = activity.getThemeResource(R.attr.ic_attach_photo, R.drawable.ic_attach_photo);
|
||||||
final Pair<String,Boolean> preview = UIHelper.getMessagePreview(activity,message);
|
showPreviewText = false;
|
||||||
if (showPreviewText) {
|
break;
|
||||||
viewHolder.lastMessage.setText(EmojiWrapper.transform(preview.first));
|
case "video":
|
||||||
} else {
|
imageResource = activity.getThemeResource(R.attr.ic_attach_videocam, R.drawable.ic_attach_videocam);
|
||||||
viewHolder.lastMessageIcon.setContentDescription(preview.first);
|
showPreviewText = false;
|
||||||
}
|
break;
|
||||||
viewHolder.lastMessage.setVisibility(showPreviewText ? View.VISIBLE : View.GONE);
|
case "audio":
|
||||||
viewHolder.lastImage.setVisibility(View.GONE);
|
imageResource = activity.getThemeResource(R.attr.ic_attach_record, R.drawable.ic_attach_record);
|
||||||
if (preview.second) {
|
showPreviewText = false;
|
||||||
if (conversation.isRead()) {
|
break;
|
||||||
viewHolder.lastMessage.setTypeface(null, Typeface.ITALIC);
|
default:
|
||||||
viewHolder.sender.setTypeface(null, Typeface.NORMAL);
|
imageResource = activity.getThemeResource(R.attr.ic_attach_document, R.drawable.ic_attach_document);
|
||||||
} else {
|
showPreviewText = true;
|
||||||
viewHolder.lastMessage.setTypeface(null,Typeface.BOLD_ITALIC);
|
break;
|
||||||
viewHolder.sender.setTypeface(null,Typeface.BOLD);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (conversation.isRead()) {
|
|
||||||
viewHolder.lastMessage.setTypeface(null,Typeface.NORMAL);
|
|
||||||
viewHolder.sender.setTypeface(null,Typeface.NORMAL);
|
|
||||||
} else {
|
|
||||||
viewHolder.lastMessage.setTypeface(null,Typeface.BOLD);
|
|
||||||
viewHolder.sender.setTypeface(null,Typeface.BOLD);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (message.getStatus() == Message.STATUS_RECEIVED) {
|
viewHolder.lastMessageIcon.setImageResource(imageResource);
|
||||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
viewHolder.lastMessageIcon.setVisibility(View.VISIBLE);
|
||||||
viewHolder.sender.setVisibility(View.VISIBLE);
|
} else {
|
||||||
viewHolder.sender.setText(UIHelper.getMessageDisplayName(message).split("\\s+")[0]+':');
|
viewHolder.lastMessageIcon.setVisibility(View.GONE);
|
||||||
} else {
|
showPreviewText = true;
|
||||||
viewHolder.sender.setVisibility(View.GONE);
|
}
|
||||||
}
|
final Pair<String,Boolean> preview = UIHelper.getMessagePreview(activity,message);
|
||||||
} else if (message.getType() != Message.TYPE_STATUS) {
|
if (showPreviewText) {
|
||||||
|
viewHolder.lastMessage.setText(EmojiWrapper.transform(preview.first));
|
||||||
|
} else {
|
||||||
|
viewHolder.lastMessageIcon.setContentDescription(preview.first);
|
||||||
|
}
|
||||||
|
viewHolder.lastMessage.setVisibility(showPreviewText ? View.VISIBLE : View.GONE);
|
||||||
|
if (preview.second) {
|
||||||
|
if (conversation.isRead()) {
|
||||||
|
viewHolder.lastMessage.setTypeface(null, Typeface.ITALIC);
|
||||||
|
viewHolder.sender.setTypeface(null, Typeface.NORMAL);
|
||||||
|
} else {
|
||||||
|
viewHolder.lastMessage.setTypeface(null,Typeface.BOLD_ITALIC);
|
||||||
|
viewHolder.sender.setTypeface(null,Typeface.BOLD);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (conversation.isRead()) {
|
||||||
|
viewHolder.lastMessage.setTypeface(null,Typeface.NORMAL);
|
||||||
|
viewHolder.sender.setTypeface(null,Typeface.NORMAL);
|
||||||
|
} else {
|
||||||
|
viewHolder.lastMessage.setTypeface(null,Typeface.BOLD);
|
||||||
|
viewHolder.sender.setTypeface(null,Typeface.BOLD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (message.getStatus() == Message.STATUS_RECEIVED) {
|
||||||
|
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||||
viewHolder.sender.setVisibility(View.VISIBLE);
|
viewHolder.sender.setVisibility(View.VISIBLE);
|
||||||
viewHolder.sender.setText(activity.getString(R.string.me)+':');
|
viewHolder.sender.setText(UIHelper.getMessageDisplayName(message).split("\\s+")[0]+':');
|
||||||
} else {
|
} else {
|
||||||
viewHolder.sender.setVisibility(View.GONE);
|
viewHolder.sender.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
} else if (message.getType() != Message.TYPE_STATUS) {
|
||||||
|
viewHolder.sender.setVisibility(View.VISIBLE);
|
||||||
|
viewHolder.sender.setText(activity.getString(R.string.me)+':');
|
||||||
|
} else {
|
||||||
|
viewHolder.sender.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
long muted_till = conversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0);
|
long muted_till = conversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0);
|
||||||
|
@ -169,7 +174,6 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
||||||
private ImageView lastMessageIcon;
|
private ImageView lastMessageIcon;
|
||||||
private TextView sender;
|
private TextView sender;
|
||||||
private TextView timestamp;
|
private TextView timestamp;
|
||||||
private ImageView lastImage;
|
|
||||||
private ImageView notificationIcon;
|
private ImageView notificationIcon;
|
||||||
private UnreadCountCustomView unreadCount;
|
private UnreadCountCustomView unreadCount;
|
||||||
private ImageView avatar;
|
private ImageView avatar;
|
||||||
|
@ -187,7 +191,6 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
||||||
viewHolder.lastMessageIcon = layout.findViewById(R.id.conversation_lastmsg_img);
|
viewHolder.lastMessageIcon = layout.findViewById(R.id.conversation_lastmsg_img);
|
||||||
viewHolder.timestamp = layout.findViewById(R.id.conversation_lastupdate);
|
viewHolder.timestamp = layout.findViewById(R.id.conversation_lastupdate);
|
||||||
viewHolder.sender = layout.findViewById(R.id.sender_name);
|
viewHolder.sender = layout.findViewById(R.id.sender_name);
|
||||||
viewHolder.lastImage = layout.findViewById(R.id.conversation_lastimage);
|
|
||||||
viewHolder.notificationIcon = layout.findViewById(R.id.notification_status);
|
viewHolder.notificationIcon = layout.findViewById(R.id.notification_status);
|
||||||
viewHolder.unreadCount = layout.findViewById(R.id.unread_count);
|
viewHolder.unreadCount = layout.findViewById(R.id.unread_count);
|
||||||
viewHolder.avatar = layout.findViewById(R.id.conversation_image);
|
viewHolder.avatar = layout.findViewById(R.id.conversation_image);
|
||||||
|
|
|
@ -96,15 +96,6 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textColor="?attr/color_text_primary"
|
android:textColor="?attr/color_text_primary"
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
android:textSize="?attr/TextSizeBody"/>
|
||||||
|
|
||||||
<com.makeramen.roundedimageview.RoundedImageView
|
|
||||||
android:id="@+id/conversation_lastimage"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:background="@color/black87"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:riv_corner_radius="2dp"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
|
|
Loading…
Reference in New Issue