parent
5aeed63844
commit
b3a3f2b930
|
@ -1496,6 +1496,7 @@ public class FileBackend {
|
||||||
DownloadableFile file = getFile(message);
|
DownloadableFile file = getFile(message);
|
||||||
final String mime = file.getMimeType();
|
final String mime = file.getMimeType();
|
||||||
final boolean privateMessage = message.isPrivateMessage();
|
final boolean privateMessage = message.isPrivateMessage();
|
||||||
|
final boolean ambiguous = MimeUtils.AMBIGUOUS_CONTAINER_FORMATS.contains(mime);
|
||||||
final boolean image =
|
final boolean image =
|
||||||
message.getType() == Message.TYPE_IMAGE
|
message.getType() == Message.TYPE_IMAGE
|
||||||
|| (mime != null && mime.startsWith("image/"));
|
|| (mime != null && mime.startsWith("image/"));
|
||||||
|
@ -1507,7 +1508,21 @@ public class FileBackend {
|
||||||
body.append(url);
|
body.append(url);
|
||||||
}
|
}
|
||||||
body.append('|').append(file.getSize());
|
body.append('|').append(file.getSize());
|
||||||
if (image || video || pdf) {
|
if (ambiguous) {
|
||||||
|
try {
|
||||||
|
final Dimensions dimensions = getVideoDimensions(file);
|
||||||
|
if (dimensions.valid()) {
|
||||||
|
Log.d(Config.LOGTAG,"ambiguous file "+mime+" is video");
|
||||||
|
body.append('|').append(dimensions.width).append('|').append(dimensions.height);
|
||||||
|
} else {
|
||||||
|
Log.d(Config.LOGTAG,"ambiguous file "+mime+" is audio");
|
||||||
|
body.append("|0|0|").append(getMediaRuntime(file));
|
||||||
|
}
|
||||||
|
} catch (final NotAVideoFile e) {
|
||||||
|
Log.d(Config.LOGTAG,"ambiguous file "+mime+" is audio");
|
||||||
|
body.append("|0|0|").append(getMediaRuntime(file));
|
||||||
|
}
|
||||||
|
} else if (image || video || pdf) {
|
||||||
try {
|
try {
|
||||||
final Dimensions dimensions;
|
final Dimensions dimensions;
|
||||||
if (video) {
|
if (video) {
|
||||||
|
@ -1537,14 +1552,16 @@ public class FileBackend {
|
||||||
: (image ? Message.TYPE_IMAGE : Message.TYPE_FILE));
|
: (image ? Message.TYPE_IMAGE : Message.TYPE_FILE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMediaRuntime(File file) {
|
private int getMediaRuntime(final File file) {
|
||||||
try {
|
try {
|
||||||
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
|
final MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
|
||||||
mediaMetadataRetriever.setDataSource(file.toString());
|
mediaMetadataRetriever.setDataSource(file.toString());
|
||||||
return Integer.parseInt(
|
final String value = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
|
||||||
mediaMetadataRetriever.extractMetadata(
|
if (Strings.isNullOrEmpty(value)) {
|
||||||
MediaMetadataRetriever.METADATA_KEY_DURATION));
|
return 0;
|
||||||
} catch (RuntimeException e) {
|
}
|
||||||
|
return Integer.parseInt(value);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1384,6 +1384,7 @@ public class XmppConnectionService extends Service {
|
||||||
final Intent intent = new Intent(this, EventReceiver.class);
|
final Intent intent = new Intent(this, EventReceiver.class);
|
||||||
intent.setAction(ACTION_POST_CONNECTIVITY_CHANGE);
|
intent.setAction(ACTION_POST_CONNECTIVITY_CHANGE);
|
||||||
try {
|
try {
|
||||||
|
//TODO add immutable flag
|
||||||
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1, intent, 0);
|
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1, intent, 0);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtMillis, pendingIntent);
|
alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtMillis, pendingIntent);
|
||||||
|
@ -1430,7 +1431,8 @@ public class XmppConnectionService extends Service {
|
||||||
final Intent intent = new Intent(this, EventReceiver.class);
|
final Intent intent = new Intent(this, EventReceiver.class);
|
||||||
intent.setAction(ACTION_IDLE_PING);
|
intent.setAction(ACTION_IDLE_PING);
|
||||||
try {
|
try {
|
||||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
|
//TODO add immutable flag
|
||||||
|
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
|
||||||
alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, timeToWake, pendingIntent);
|
alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, timeToWake, pendingIntent);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
Log.d(Config.LOGTAG, "unable to schedule alarm for idle ping", e);
|
Log.d(Config.LOGTAG, "unable to schedule alarm for idle ping", e);
|
||||||
|
@ -1443,7 +1445,7 @@ public class XmppConnectionService extends Service {
|
||||||
connection.setOnStatusChangedListener(this.statusListener);
|
connection.setOnStatusChangedListener(this.statusListener);
|
||||||
connection.setOnPresencePacketReceivedListener(this.mPresenceParser);
|
connection.setOnPresencePacketReceivedListener(this.mPresenceParser);
|
||||||
connection.setOnUnregisteredIqPacketReceivedListener(this.mIqParser);
|
connection.setOnUnregisteredIqPacketReceivedListener(this.mIqParser);
|
||||||
connection.setOnJinglePacketReceivedListener(((a, jp) -> mJingleConnectionManager.deliverPacket(a, jp)));
|
connection.setOnJinglePacketReceivedListener((mJingleConnectionManager::deliverPacket));
|
||||||
connection.setOnBindListener(this.mOnBindListener);
|
connection.setOnBindListener(this.mOnBindListener);
|
||||||
connection.setOnMessageAcknowledgeListener(this.mOnMessageAcknowledgedListener);
|
connection.setOnMessageAcknowledgeListener(this.mOnMessageAcknowledgedListener);
|
||||||
connection.addOnAdvancedStreamFeaturesAvailableListener(this.mMessageArchiveService);
|
connection.addOnAdvancedStreamFeaturesAvailableListener(this.mMessageArchiveService);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import androidx.databinding.DataBindingUtil;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -24,11 +25,13 @@ import eu.siacs.conversations.ui.XmppActivity;
|
||||||
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
|
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
|
||||||
import eu.siacs.conversations.ui.util.StyledAttributes;
|
import eu.siacs.conversations.ui.util.StyledAttributes;
|
||||||
import eu.siacs.conversations.utils.IrregularUnicodeDetector;
|
import eu.siacs.conversations.utils.IrregularUnicodeDetector;
|
||||||
|
import eu.siacs.conversations.utils.MimeUtils;
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xmpp.Jid;
|
import eu.siacs.conversations.xmpp.Jid;
|
||||||
import eu.siacs.conversations.xmpp.jingle.OngoingRtpSession;
|
import eu.siacs.conversations.xmpp.jingle.OngoingRtpSession;
|
||||||
|
|
||||||
public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapter.ConversationViewHolder> {
|
public class ConversationAdapter
|
||||||
|
extends RecyclerView.Adapter<ConversationAdapter.ConversationViewHolder> {
|
||||||
|
|
||||||
private final XmppActivity activity;
|
private final XmppActivity activity;
|
||||||
private final List<Conversation> conversations;
|
private final List<Conversation> conversations;
|
||||||
|
@ -39,11 +42,15 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
|
||||||
this.conversations = conversations;
|
this.conversations = conversations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ConversationViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public ConversationViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
return new ConversationViewHolder(DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.conversation_list_row, parent, false));
|
return new ConversationViewHolder(
|
||||||
|
DataBindingUtil.inflate(
|
||||||
|
LayoutInflater.from(parent.getContext()),
|
||||||
|
R.layout.conversation_list_row,
|
||||||
|
parent,
|
||||||
|
false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,15 +61,18 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
|
||||||
}
|
}
|
||||||
CharSequence name = conversation.getName();
|
CharSequence name = conversation.getName();
|
||||||
if (name instanceof Jid) {
|
if (name instanceof Jid) {
|
||||||
viewHolder.binding.conversationName.setText(IrregularUnicodeDetector.style(activity, (Jid) name));
|
viewHolder.binding.conversationName.setText(
|
||||||
|
IrregularUnicodeDetector.style(activity, (Jid) name));
|
||||||
} else {
|
} else {
|
||||||
viewHolder.binding.conversationName.setText(name);
|
viewHolder.binding.conversationName.setText(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conversation == ConversationFragment.getConversation(activity)) {
|
if (conversation == ConversationFragment.getConversation(activity)) {
|
||||||
viewHolder.binding.frame.setBackgroundColor(StyledAttributes.getColor(activity, R.attr.color_background_tertiary));
|
viewHolder.binding.frame.setBackgroundColor(
|
||||||
|
StyledAttributes.getColor(activity, R.attr.color_background_tertiary));
|
||||||
} else {
|
} else {
|
||||||
viewHolder.binding.frame.setBackgroundColor(StyledAttributes.getColor(activity, R.attr.color_background_primary));
|
viewHolder.binding.frame.setBackgroundColor(
|
||||||
|
StyledAttributes.getColor(activity, R.attr.color_background_primary));
|
||||||
}
|
}
|
||||||
|
|
||||||
Message message = conversation.getLatestMessage();
|
Message message = conversation.getLatestMessage();
|
||||||
|
@ -92,46 +102,90 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
|
||||||
} else {
|
} else {
|
||||||
final boolean fileAvailable = !message.isDeleted();
|
final boolean fileAvailable = !message.isDeleted();
|
||||||
final boolean showPreviewText;
|
final boolean showPreviewText;
|
||||||
if (fileAvailable && (message.isFileOrImage() || message.treatAsDownloadable() || message.isGeoUri())) {
|
if (fileAvailable
|
||||||
|
&& (message.isFileOrImage()
|
||||||
|
|| message.treatAsDownloadable()
|
||||||
|
|| message.isGeoUri())) {
|
||||||
final int imageResource;
|
final int imageResource;
|
||||||
if (message.isGeoUri()) {
|
if (message.isGeoUri()) {
|
||||||
imageResource = activity.getThemeResource(R.attr.ic_attach_location, R.drawable.ic_attach_location);
|
imageResource =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.ic_attach_location, R.drawable.ic_attach_location);
|
||||||
showPreviewText = false;
|
showPreviewText = false;
|
||||||
} else {
|
} else {
|
||||||
//TODO move this into static MediaPreview method and use same icons as in MediaAdapter
|
// TODO move this into static MediaPreview method and use same icons as in
|
||||||
|
// MediaAdapter
|
||||||
final String mime = message.getMimeType();
|
final String mime = message.getMimeType();
|
||||||
switch (mime == null ? "" : mime.split("/")[0]) {
|
if (MimeUtils.AMBIGUOUS_CONTAINER_FORMATS.contains(mime)) {
|
||||||
|
final Message.FileParams fileParams = message.getFileParams();
|
||||||
|
if (fileParams.width > 0 && fileParams.height > 0) {
|
||||||
|
imageResource =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.ic_attach_videocam,
|
||||||
|
R.drawable.ic_attach_videocam);
|
||||||
|
showPreviewText = false;
|
||||||
|
} else if (fileParams.runtime > 0) {
|
||||||
|
imageResource =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.ic_attach_record, R.drawable.ic_attach_record);
|
||||||
|
showPreviewText = false;
|
||||||
|
} else {
|
||||||
|
imageResource =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.ic_attach_document,
|
||||||
|
R.drawable.ic_attach_document);
|
||||||
|
showPreviewText = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (Strings.nullToEmpty(mime).split("/")[0]) {
|
||||||
case "image":
|
case "image":
|
||||||
imageResource = activity.getThemeResource(R.attr.ic_attach_photo, R.drawable.ic_attach_photo);
|
imageResource =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.ic_attach_photo, R.drawable.ic_attach_photo);
|
||||||
showPreviewText = false;
|
showPreviewText = false;
|
||||||
break;
|
break;
|
||||||
case "video":
|
case "video":
|
||||||
imageResource = activity.getThemeResource(R.attr.ic_attach_videocam, R.drawable.ic_attach_videocam);
|
imageResource =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.ic_attach_videocam,
|
||||||
|
R.drawable.ic_attach_videocam);
|
||||||
showPreviewText = false;
|
showPreviewText = false;
|
||||||
break;
|
break;
|
||||||
case "audio":
|
case "audio":
|
||||||
imageResource = activity.getThemeResource(R.attr.ic_attach_record, R.drawable.ic_attach_record);
|
imageResource =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.ic_attach_record,
|
||||||
|
R.drawable.ic_attach_record);
|
||||||
showPreviewText = false;
|
showPreviewText = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
imageResource = activity.getThemeResource(R.attr.ic_attach_document, R.drawable.ic_attach_document);
|
imageResource =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.ic_attach_document,
|
||||||
|
R.drawable.ic_attach_document);
|
||||||
showPreviewText = true;
|
showPreviewText = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
viewHolder.binding.conversationLastmsgImg.setImageResource(imageResource);
|
viewHolder.binding.conversationLastmsgImg.setImageResource(imageResource);
|
||||||
viewHolder.binding.conversationLastmsgImg.setVisibility(View.VISIBLE);
|
viewHolder.binding.conversationLastmsgImg.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
viewHolder.binding.conversationLastmsgImg.setVisibility(View.GONE);
|
viewHolder.binding.conversationLastmsgImg.setVisibility(View.GONE);
|
||||||
showPreviewText = true;
|
showPreviewText = true;
|
||||||
}
|
}
|
||||||
final Pair<CharSequence, Boolean> preview = UIHelper.getMessagePreview(activity, message, viewHolder.binding.conversationLastmsg.getCurrentTextColor());
|
final Pair<CharSequence, Boolean> preview =
|
||||||
|
UIHelper.getMessagePreview(
|
||||||
|
activity,
|
||||||
|
message,
|
||||||
|
viewHolder.binding.conversationLastmsg.getCurrentTextColor());
|
||||||
if (showPreviewText) {
|
if (showPreviewText) {
|
||||||
viewHolder.binding.conversationLastmsg.setText(UIHelper.shorten(preview.first));
|
viewHolder.binding.conversationLastmsg.setText(UIHelper.shorten(preview.first));
|
||||||
} else {
|
} else {
|
||||||
viewHolder.binding.conversationLastmsgImg.setContentDescription(preview.first);
|
viewHolder.binding.conversationLastmsgImg.setContentDescription(preview.first);
|
||||||
}
|
}
|
||||||
viewHolder.binding.conversationLastmsg.setVisibility(showPreviewText ? View.VISIBLE : View.GONE);
|
viewHolder.binding.conversationLastmsg.setVisibility(
|
||||||
|
showPreviewText ? View.VISIBLE : View.GONE);
|
||||||
if (preview.second) {
|
if (preview.second) {
|
||||||
if (isRead) {
|
if (isRead) {
|
||||||
viewHolder.binding.conversationLastmsg.setTypeface(null, Typeface.ITALIC);
|
viewHolder.binding.conversationLastmsg.setTypeface(null, Typeface.ITALIC);
|
||||||
|
@ -152,7 +206,8 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
|
||||||
if (message.getStatus() == Message.STATUS_RECEIVED) {
|
if (message.getStatus() == Message.STATUS_RECEIVED) {
|
||||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||||
viewHolder.binding.senderName.setVisibility(View.VISIBLE);
|
viewHolder.binding.senderName.setVisibility(View.VISIBLE);
|
||||||
viewHolder.binding.senderName.setText(UIHelper.getMessageDisplayName(message).split("\\s+")[0] + ':');
|
viewHolder.binding.senderName.setText(
|
||||||
|
UIHelper.getMessageDisplayName(message).split("\\s+")[0] + ':');
|
||||||
} else {
|
} else {
|
||||||
viewHolder.binding.senderName.setVisibility(View.GONE);
|
viewHolder.binding.senderName.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -164,33 +219,47 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final Optional<OngoingRtpSession> ongoingCall;
|
final Optional<OngoingRtpSession> ongoingCall;
|
||||||
if (conversation.getMode() == Conversational.MODE_MULTI) {
|
if (conversation.getMode() == Conversational.MODE_MULTI) {
|
||||||
ongoingCall = Optional.absent();
|
ongoingCall = Optional.absent();
|
||||||
} else {
|
} else {
|
||||||
ongoingCall = activity.xmppConnectionService.getJingleConnectionManager().getOngoingRtpConnection(conversation.getContact());
|
ongoingCall =
|
||||||
|
activity.xmppConnectionService
|
||||||
|
.getJingleConnectionManager()
|
||||||
|
.getOngoingRtpConnection(conversation.getContact());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ongoingCall.isPresent()) {
|
if (ongoingCall.isPresent()) {
|
||||||
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
|
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
|
||||||
final int ic_ongoing_call = activity.getThemeResource(R.attr.ic_ongoing_call_hint, R.drawable.ic_phone_in_talk_black_18dp);
|
final int ic_ongoing_call =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.ic_ongoing_call_hint, R.drawable.ic_phone_in_talk_black_18dp);
|
||||||
viewHolder.binding.notificationStatus.setImageResource(ic_ongoing_call);
|
viewHolder.binding.notificationStatus.setImageResource(ic_ongoing_call);
|
||||||
} else {
|
} else {
|
||||||
final long muted_till = conversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL, 0);
|
final long muted_till =
|
||||||
|
conversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL, 0);
|
||||||
if (muted_till == Long.MAX_VALUE) {
|
if (muted_till == Long.MAX_VALUE) {
|
||||||
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
|
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
|
||||||
int ic_notifications_off = activity.getThemeResource(R.attr.icon_notifications_off, R.drawable.ic_notifications_off_black_24dp);
|
int ic_notifications_off =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.icon_notifications_off,
|
||||||
|
R.drawable.ic_notifications_off_black_24dp);
|
||||||
viewHolder.binding.notificationStatus.setImageResource(ic_notifications_off);
|
viewHolder.binding.notificationStatus.setImageResource(ic_notifications_off);
|
||||||
} else if (muted_till >= System.currentTimeMillis()) {
|
} else if (muted_till >= System.currentTimeMillis()) {
|
||||||
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
|
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
|
||||||
int ic_notifications_paused = activity.getThemeResource(R.attr.icon_notifications_paused, R.drawable.ic_notifications_paused_black_24dp);
|
int ic_notifications_paused =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.icon_notifications_paused,
|
||||||
|
R.drawable.ic_notifications_paused_black_24dp);
|
||||||
viewHolder.binding.notificationStatus.setImageResource(ic_notifications_paused);
|
viewHolder.binding.notificationStatus.setImageResource(ic_notifications_paused);
|
||||||
} else if (conversation.alwaysNotify()) {
|
} else if (conversation.alwaysNotify()) {
|
||||||
viewHolder.binding.notificationStatus.setVisibility(View.GONE);
|
viewHolder.binding.notificationStatus.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
|
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
|
||||||
int ic_notifications_none = activity.getThemeResource(R.attr.icon_notifications_none, R.drawable.ic_notifications_none_black_24dp);
|
int ic_notifications_none =
|
||||||
|
activity.getThemeResource(
|
||||||
|
R.attr.icon_notifications_none,
|
||||||
|
R.drawable.ic_notifications_none_black_24dp);
|
||||||
viewHolder.binding.notificationStatus.setImageResource(ic_notifications_none);
|
viewHolder.binding.notificationStatus.setImageResource(ic_notifications_none);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,9 +270,16 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
|
||||||
} else {
|
} else {
|
||||||
timestamp = conversation.getLatestMessage().getTimeSent();
|
timestamp = conversation.getLatestMessage().getTimeSent();
|
||||||
}
|
}
|
||||||
viewHolder.binding.pinnedOnTop.setVisibility(conversation.getBooleanAttribute(Conversation.ATTRIBUTE_PINNED_ON_TOP,false) ? View.VISIBLE : View.GONE);
|
viewHolder.binding.pinnedOnTop.setVisibility(
|
||||||
viewHolder.binding.conversationLastupdate.setText(UIHelper.readableTimeDifference(activity, timestamp));
|
conversation.getBooleanAttribute(Conversation.ATTRIBUTE_PINNED_ON_TOP, false)
|
||||||
AvatarWorkerTask.loadAvatar(conversation, viewHolder.binding.conversationImage, R.dimen.avatar_on_conversation_overview);
|
? View.VISIBLE
|
||||||
|
: View.GONE);
|
||||||
|
viewHolder.binding.conversationLastupdate.setText(
|
||||||
|
UIHelper.readableTimeDifference(activity, timestamp));
|
||||||
|
AvatarWorkerTask.loadAvatar(
|
||||||
|
conversation,
|
||||||
|
viewHolder.binding.conversationImage,
|
||||||
|
R.dimen.avatar_on_conversation_overview);
|
||||||
viewHolder.itemView.setOnClickListener(v -> listener.onConversationClick(v, conversation));
|
viewHolder.itemView.setOnClickListener(v -> listener.onConversationClick(v, conversation));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +292,6 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void insert(Conversation c, int position) {
|
public void insert(Conversation c, int position) {
|
||||||
conversations.add(position, c);
|
conversations.add(position, c);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
|
@ -238,7 +313,5 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
|
||||||
super(binding.getRoot());
|
super(binding.getRoot());
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,14 @@ import android.provider.OpenableColumns;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -40,6 +42,13 @@ import eu.siacs.conversations.services.ExportBackupService;
|
||||||
* Used to implement java.net.URLConnection and android.webkit.MimeTypeMap.
|
* Used to implement java.net.URLConnection and android.webkit.MimeTypeMap.
|
||||||
*/
|
*/
|
||||||
public final class MimeUtils {
|
public final class MimeUtils {
|
||||||
|
|
||||||
|
public static final List<String> AMBIGUOUS_CONTAINER_FORMATS = ImmutableList.of(
|
||||||
|
"application/ogg",
|
||||||
|
"video/3gpp", // .3gp files can contain audio, video or both
|
||||||
|
"video/3gpp2"
|
||||||
|
);
|
||||||
|
|
||||||
private static final Map<String, String> mimeTypeToExtensionMap = new HashMap<>();
|
private static final Map<String, String> mimeTypeToExtensionMap = new HashMap<>();
|
||||||
private static final Map<String, String> extensionToMimeTypeMap = new HashMap<>();
|
private static final Map<String, String> extensionToMimeTypeMap = new HashMap<>();
|
||||||
|
|
||||||
|
@ -225,7 +234,12 @@ public final class MimeUtils {
|
||||||
add("application/x-xcf", "xcf");
|
add("application/x-xcf", "xcf");
|
||||||
add("application/x-xfig", "fig");
|
add("application/x-xfig", "fig");
|
||||||
add("application/xhtml+xml", "xhtml");
|
add("application/xhtml+xml", "xhtml");
|
||||||
|
add("video/3gpp", "3gpp");
|
||||||
|
add("video/3gpp", "3gp");
|
||||||
|
add("video/3gpp2", "3gpp2");
|
||||||
|
add("video/3gpp2", "3g2");
|
||||||
add("audio/3gpp", "3gpp");
|
add("audio/3gpp", "3gpp");
|
||||||
|
add("audio/3gpp", "3gp");
|
||||||
add("audio/aac", "aac");
|
add("audio/aac", "aac");
|
||||||
add("audio/aac-adts", "aac");
|
add("audio/aac-adts", "aac");
|
||||||
add("audio/amr", "amr");
|
add("audio/amr", "amr");
|
||||||
|
@ -365,10 +379,6 @@ public final class MimeUtils {
|
||||||
add("text/x-tex", "cls");
|
add("text/x-tex", "cls");
|
||||||
add("text/x-vcalendar", "vcs");
|
add("text/x-vcalendar", "vcs");
|
||||||
add("text/x-vcard", "vcf");
|
add("text/x-vcard", "vcf");
|
||||||
add("video/3gpp", "3gpp");
|
|
||||||
add("video/3gpp", "3gp");
|
|
||||||
add("video/3gpp2", "3gpp2");
|
|
||||||
add("video/3gpp2", "3g2");
|
|
||||||
add("video/avi", "avi");
|
add("video/avi", "avi");
|
||||||
add("video/dl", "dl");
|
add("video/dl", "dl");
|
||||||
add("video/dv", "dif");
|
add("video/dv", "dif");
|
||||||
|
|
|
@ -477,8 +477,10 @@ public class UIHelper {
|
||||||
|
|
||||||
public static String getFileDescriptionString(final Context context, final Message message) {
|
public static String getFileDescriptionString(final Context context, final Message message) {
|
||||||
final String mime = message.getMimeType();
|
final String mime = message.getMimeType();
|
||||||
if (mime == null) {
|
if (Strings.isNullOrEmpty(mime)) {
|
||||||
return context.getString(R.string.file);
|
return context.getString(R.string.file);
|
||||||
|
} else if (MimeUtils.AMBIGUOUS_CONTAINER_FORMATS.contains(mime)) {
|
||||||
|
return context.getString(R.string.multimedia_file);
|
||||||
} else if (mime.startsWith("audio/")) {
|
} else if (mime.startsWith("audio/")) {
|
||||||
return context.getString(R.string.audio);
|
return context.getString(R.string.audio);
|
||||||
} else if (mime.startsWith("video/")) {
|
} else if (mime.startsWith("video/")) {
|
||||||
|
|
|
@ -415,6 +415,7 @@
|
||||||
<string name="video">video</string>
|
<string name="video">video</string>
|
||||||
<string name="image">image</string>
|
<string name="image">image</string>
|
||||||
<string name="vector_graphic">vector graphic</string>
|
<string name="vector_graphic">vector graphic</string>
|
||||||
|
<string name="multimedia_file">multimedia file</string>
|
||||||
<string name="pdf_document">PDF document</string>
|
<string name="pdf_document">PDF document</string>
|
||||||
<string name="apk">Android App</string>
|
<string name="apk">Android App</string>
|
||||||
<string name="vcard">Contact</string>
|
<string name="vcard">Contact</string>
|
||||||
|
|
Loading…
Reference in a new issue