Commit b586b4f2 authored by Moxie Marlinspike's avatar Moxie Marlinspike Committed by Bastien Le Querrec

Remove dedicated MMS download controls

// FREEBIE

Upstream commit: https://github.com/signalapp/Signal-Android/commit/235a8472d985498ade58e57c957f8f883348578e
parent 4f6d9e36
Pipeline #174 passed with stages
in 9 minutes and 2 seconds
......@@ -72,29 +72,6 @@
android:textSize="@dimen/conversation_item_body_text_size"
android:linksClickable="true" />
<LinearLayout android:id="@+id/mms_download_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="@+id/mms_download_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/conversation_item_received__download"
android:visibility="gone" />
<TextView android:id="@+id/mms_label_downloading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center"
android:text="@string/conversation_item_received__downloading"
android:visibility="gone" />
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="2dip"
......
......@@ -63,29 +63,6 @@
android:textSize="@dimen/conversation_item_body_text_size"
tools:text="Mango pickle lorem ipsum" />
<LinearLayout android:id="@+id/mms_download_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="@+id/mms_download_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/conversation_item_sent__download"
android:visibility="gone" />
<TextView android:id="@+id/mms_label_downloading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center"
android:text="@string/conversation_item_sent__downloading"
android:visibility="gone" />
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
......
......@@ -307,6 +307,8 @@
<!-- NotificationMmsMessageRecord -->
<string name="NotificationMmsMessageRecord_multimedia_message">Multimedia message</string>
<string name="NotificationMmsMessageRecord_downloading_mms_message">Downloading MMS message</string>
<string name="NotificationMmsMessageRecord_error_downloading_mms_message">Error downloading MMS message, tap to retry</string>
<!-- MessageRecord -->
<string name="MessageRecord_message_encrypted_with_a_legacy_protocol_version_that_is_no_longer_supported">Received a message encrypted using an old version of Silence that is no longer supported. Please ask the sender to upgrade to the most recent version and resend the message.</string>
......
......@@ -39,8 +39,8 @@ import org.smssecure.smssecure.database.DatabaseFactory;
import org.smssecure.smssecure.database.MmsSmsColumns;
import org.smssecure.smssecure.database.MmsSmsDatabase;
import org.smssecure.smssecure.database.SmsDatabase;
import org.smssecure.smssecure.database.model.MediaMmsMessageRecord;
import org.smssecure.smssecure.database.model.MessageRecord;
import org.smssecure.smssecure.database.model.MmsMessageRecord;
import org.smssecure.smssecure.recipients.Recipients;
import org.smssecure.smssecure.util.DateUtils;
import org.smssecure.smssecure.util.LRUCache;
......@@ -76,6 +76,7 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
{
private static final int MAX_CACHE_SIZE = 40;
private static final String TAG = ConversationAdapter.class.getName();
private final Map<String,SoftReference<MessageRecord>> messageRecordCache =
Collections.synchronizedMap(new LRUCache<String, SoftReference<MessageRecord>>(MAX_CACHE_SIZE));
......@@ -184,10 +185,12 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
MessageRecord messageRecord = getMessageRecord(cursor);
viewHolder.getView().bind(masterSecret, messageRecord, locale, batchSelected, recipients);
Log.w(TAG, "Bind time: " + (System.currentTimeMillis() - start));
}
@Override
public ViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {
long start = System.currentTimeMillis();
final V itemView = ViewUtil.inflate(inflater, parent, getLayoutForViewType(viewType));
if (viewType == MESSAGE_TYPE_INCOMING || viewType == MESSAGE_TYPE_OUTGOING) {
itemView.setOnClickListener(new OnClickListener() {
......@@ -204,7 +207,7 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
}
});
}
Log.w(TAG, "Inflate time: " + (System.currentTimeMillis() - start));
return new ViewHolder(itemView);
}
......@@ -300,9 +303,7 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
}
private boolean hasAudio(MessageRecord messageRecord) {
return messageRecord.isMms() &&
!messageRecord.isMmsNotification() &&
((MediaMmsMessageRecord)messageRecord).getSlideDeck().getAudioSlide() != null;
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getAudioSlide() != null;
}
@Override
......
......@@ -35,7 +35,6 @@ import android.util.Patterns;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
......@@ -56,7 +55,7 @@ import org.smssecure.smssecure.database.SmsDatabase;
import org.smssecure.smssecure.database.documents.IdentityKeyMismatch;
import org.smssecure.smssecure.database.model.MediaMmsMessageRecord;
import org.smssecure.smssecure.database.model.MessageRecord;
import org.smssecure.smssecure.database.model.NotificationMmsMessageRecord;
import org.smssecure.smssecure.database.model.MmsMessageRecord;
import org.smssecure.smssecure.jobs.MmsDownloadJob;
import org.smssecure.smssecure.jobs.MmsSendJob;
import org.smssecure.smssecure.jobs.SmsSendJob;
......@@ -118,13 +117,9 @@ public class ConversationItem extends LinearLayout
private @Nullable Recipients conversationRecipients;
private @NonNull Stub<ThumbnailView> mediaThumbnailStub;
private @NonNull Stub<AudioView> audioViewStub;
private @NonNull Button mmsDownloadButton;
private @NonNull TextView mmsDownloadingLabel;
private int defaultBubbleColor;
private final MmsDownloadClickListener mmsDownloadClickListener = new MmsDownloadClickListener();
private final MmsPreferencesClickListener mmsPreferencesClickListener = new MmsPreferencesClickListener();
private final PassthroughClickListener passthroughClickListener = new PassthroughClickListener();
private final AttachmentDownloadClickListener downloadClickListener = new AttachmentDownloadClickListener();
......@@ -178,8 +173,6 @@ public class ConversationItem extends LinearLayout
this.secureImage = (ImageView) findViewById(R.id.secure_indicator);
this.deliveryStatusIndicator = (DeliveryStatusView) findViewById(R.id.delivery_status);
this.alertView = (AlertView) findViewById(R.id.indicators_parent);
this.mmsDownloadButton = (Button) findViewById(R.id.mms_download_button);
this.mmsDownloadingLabel = (TextView) findViewById(R.id.mms_label_downloading);
this.contactPhoto = (AvatarImageView) findViewById(R.id.contact_photo);
this.bodyBubble = findViewById(R.id.body_bubble);
this.mediaThumbnailStub = new Stub<>((ViewStub) findViewById(R.id.image_view_stub));
......@@ -187,7 +180,6 @@ public class ConversationItem extends LinearLayout
setOnClickListener(new ClickListener(null));
mmsDownloadButton.setOnClickListener(mmsDownloadClickListener);
bodyText.setOnLongClickListener(passthroughClickListener);
bodyText.setOnClickListener(passthroughClickListener);
}
......@@ -293,15 +285,11 @@ public class ConversationItem extends LinearLayout
}
private boolean hasAudio(MessageRecord messageRecord) {
return messageRecord.isMms() &&
!messageRecord.isMmsNotification() &&
((MediaMmsMessageRecord)messageRecord).getSlideDeck().getAudioSlide() != null;
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getAudioSlide() != null;
}
private boolean hasThumbnail(MessageRecord messageRecord) {
return messageRecord.isMms() &&
!messageRecord.isMmsNotification() &&
((MediaMmsMessageRecord)messageRecord).getSlideDeck().getThumbnailSlide() != null;
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getThumbnailSlide() != null;
}
private void setBodyText(MessageRecord messageRecord) {
......@@ -338,18 +326,12 @@ public class ConversationItem extends LinearLayout
private void setMediaAttributes(MessageRecord messageRecord) {
boolean showControls = !messageRecord.isFailed() && (!messageRecord.isOutgoing() || messageRecord.isPending());
if (messageRecord.isMmsNotification()) {
if (mediaThumbnailStub.resolved()) mediaThumbnailStub.get().setVisibility(View.GONE);
if (audioViewStub.resolved()) audioViewStub.get().setVisibility(View.GONE);
bodyText.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
setNotificationMmsAttributes((NotificationMmsMessageRecord) messageRecord);
} else if (hasAudio(messageRecord)) {
if (hasAudio(messageRecord)) {
audioViewStub.get().setVisibility(View.VISIBLE);
if (mediaThumbnailStub.resolved()) mediaThumbnailStub.get().setVisibility(View.GONE);
//noinspection ConstantConditions
audioViewStub.get().setAudio(masterSecret, ((MediaMmsMessageRecord) messageRecord).getSlideDeck().getAudioSlide(), showControls);
audioViewStub.get().setAudio(masterSecret, ((MmsMessageRecord) messageRecord).getSlideDeck().getAudioSlide(), showControls);
audioViewStub.get().setDownloadClickListener(downloadClickListener);
audioViewStub.get().setOnLongClickListener(passthroughClickListener);
......@@ -360,7 +342,7 @@ public class ConversationItem extends LinearLayout
//noinspection ConstantConditions
mediaThumbnailStub.get().setImageResource(masterSecret,
((MediaMmsMessageRecord)messageRecord).getSlideDeck().getThumbnailSlide(),
((MmsMessageRecord)messageRecord).getSlideDeck().getThumbnailSlide(),
showControls);
mediaThumbnailStub.get().setThumbnailClickListener(new ThumbnailClickListener());
mediaThumbnailStub.get().setDownloadClickListener(downloadClickListener);
......@@ -382,8 +364,6 @@ public class ConversationItem extends LinearLayout
}
private void setStatusIcons(MessageRecord messageRecord) {
mmsDownloadButton.setVisibility(View.GONE);
mmsDownloadingLabel.setVisibility(View.GONE);
indicatorText.setVisibility(View.GONE);
secureImage.setVisibility(messageRecord.isSecure() ? View.VISIBLE : View.GONE);
......@@ -464,31 +444,6 @@ public class ConversationItem extends LinearLayout
}
}
private void setNotificationMmsAttributes(NotificationMmsMessageRecord messageRecord) {
String messageSize = String.format(context.getString(R.string.ConversationItem_message_size_d_kb),
messageRecord.getMessageSize());
String expires = String.format(context.getString(R.string.ConversationItem_expires_s),
DateUtils.getRelativeTimeSpanString(getContext(),
messageRecord.getExpiration(),
false));
dateText.setText(messageSize + "\n" + expires);
if (MmsDatabase.Status.isDisplayDownloadButton(context, messageRecord.getStatus())) {
mmsDownloadButton.setVisibility(View.VISIBLE);
mmsDownloadingLabel.setVisibility(View.GONE);
} else {
mmsDownloadingLabel.setText(MmsDatabase.Status.getLabelForStatus(context, messageRecord.getStatus()));
mmsDownloadButton.setVisibility(View.GONE);
mmsDownloadingLabel.setVisibility(View.VISIBLE);
if (MmsDatabase.Status.isHardError(messageRecord.getStatus()) && !messageRecord.isOutgoing())
setOnClickListener(mmsDownloadClickListener);
else if (MmsDatabase.Status.DOWNLOAD_APN_UNAVAILABLE == messageRecord.getStatus() && !messageRecord.isOutgoing())
setOnClickListener(mmsPreferencesClickListener);
}
}
/// Helper Methods
private void checkForAutoInitiate(MessageRecord messageRecord) {
......@@ -641,30 +596,6 @@ public class ConversationItem extends LinearLayout
}
}
private class MmsDownloadClickListener implements View.OnClickListener {
public void onClick(View v) {
NotificationMmsMessageRecord notificationRecord = (NotificationMmsMessageRecord)messageRecord;
Log.w(TAG, "Content location: " + new String(notificationRecord.getContentLocation()));
mmsDownloadButton.setVisibility(View.GONE);
mmsDownloadingLabel.setVisibility(View.VISIBLE);
ApplicationContext.getInstance(context)
.getJobManager()
.add(new MmsDownloadJob(context, messageRecord.getId(),
messageRecord.getThreadId(), false));
}
}
private class MmsPreferencesClickListener implements View.OnClickListener {
public void onClick(View v) {
Intent intent = new Intent(context, PromptMmsActivity.class);
intent.putExtra("message_id", messageRecord.getId());
intent.putExtra("thread_id", messageRecord.getThreadId());
intent.putExtra("automatic", true);
context.startActivity(intent);
}
}
private class PassthroughClickListener implements View.OnLongClickListener, View.OnClickListener {
@Override
......
package org.smssecure.smssecure.attachments;
import android.net.Uri;
import android.support.annotation.Nullable;
import org.smssecure.smssecure.database.AttachmentDatabase;
import org.smssecure.smssecure.database.MmsDatabase;
public class MmsNotificationAttachment extends Attachment {
public MmsNotificationAttachment(int status, long size) {
super("application/mms", getTransferStateFromStatus(status), size, null, null, null);
}
@Nullable
@Override
public Uri getDataUri() {
return null;
}
@Nullable
@Override
public Uri getThumbnailUri() {
return null;
}
private static int getTransferStateFromStatus(int status) {
if (status == MmsDatabase.Status.DOWNLOAD_INITIALIZED ||
status == MmsDatabase.Status.DOWNLOAD_NO_CONNECTIVITY)
{
return AttachmentDatabase.TRANSFER_PROGRESS_AUTO_PENDING;
} else if (status == MmsDatabase.Status.DOWNLOAD_CONNECTING) {
return AttachmentDatabase.TRANSFER_PROGRESS_STARTED;
} else {
return AttachmentDatabase.TRANSFER_PROGRESS_FAILED;
}
}
}
......@@ -37,6 +37,7 @@ import org.smssecure.smssecure.ApplicationContext;
import org.smssecure.smssecure.R;
import org.smssecure.smssecure.attachments.Attachment;
import org.smssecure.smssecure.attachments.DatabaseAttachment;
import org.smssecure.smssecure.attachments.MmsNotificationAttachment;
import org.smssecure.smssecure.crypto.MasterCipher;
import org.smssecure.smssecure.crypto.MasterSecret;
import org.smssecure.smssecure.database.documents.IdentityKeyMismatch;
......@@ -829,29 +830,6 @@ public class MmsDatabase extends MessagingDatabase {
public static final int DOWNLOAD_SOFT_FAILURE = 4;
public static final int DOWNLOAD_HARD_FAILURE = 5;
public static final int DOWNLOAD_APN_UNAVAILABLE = 6;
public static boolean isDisplayDownloadButton(Context context, int status) {
return
status == DOWNLOAD_INITIALIZED ||
status == DOWNLOAD_NO_CONNECTIVITY ||
status == DOWNLOAD_SOFT_FAILURE ||
(status == DOWNLOAD_APN_UNAVAILABLE && SilencePreferences.seenManualMmsSettings(context));
}
public static String getLabelForStatus(Context context, int status) {
switch (status) {
case DOWNLOAD_CONNECTING: return context.getString(R.string.MmsDatabase_connecting_to_mms_server);
case DOWNLOAD_INITIALIZED: return context.getString(R.string.MmsDatabase_downloading_mms);
case DOWNLOAD_HARD_FAILURE: return context.getString(R.string.MmsDatabase_mms_download_failed);
case DOWNLOAD_APN_UNAVAILABLE: return context.getString(R.string.MmsDatabase_mms_pending_download);
}
return context.getString(R.string.MmsDatabase_downloading);
}
public static boolean isHardError(int status) {
return status == DOWNLOAD_HARD_FAILURE;
}
}
public static class MmsNotificationInfo {
......@@ -936,11 +914,12 @@ public class MmsDatabase extends MessagingDatabase {
if (!TextUtils.isEmpty(transactionId))
transactionIdBytes = org.smssecure.smssecure.util.Util.toIsoBytes(transactionId);
SlideDeck slideDeck = new SlideDeck(context, new MmsNotificationAttachment(status, messageSize));
return new NotificationMmsMessageRecord(context, id, recipients, recipients.getPrimaryRecipient(),
addressDeviceId, dateSent, dateReceived, dateDeliveryReceived, threadId,
contentLocationBytes, messageSize, expiry, status,
transactionIdBytes, mailbox, subscriptionId);
transactionIdBytes, mailbox, subscriptionId, slideDeck);
}
private MediaMmsMessageRecord getMediaMmsMessageRecord(Cursor cursor) {
......
......@@ -25,6 +25,7 @@ import org.smssecure.smssecure.database.MmsDatabase;
import org.smssecure.smssecure.database.SmsDatabase.Status;
import org.smssecure.smssecure.database.documents.IdentityKeyMismatch;
import org.smssecure.smssecure.database.documents.NetworkFailure;
import org.smssecure.smssecure.mms.Slide;
import org.smssecure.smssecure.mms.SlideDeck;
import org.smssecure.smssecure.recipients.Recipient;
import org.smssecure.smssecure.recipients.Recipients;
......@@ -40,12 +41,11 @@ import java.util.List;
*
*/
public class MediaMmsMessageRecord extends MessageRecord {
public class MediaMmsMessageRecord extends MmsMessageRecord {
private final static String TAG = MediaMmsMessageRecord.class.getSimpleName();
private final Context context;
private final int partCount;
private final @NonNull SlideDeck slideDeck;
private final int partCount;
public MediaMmsMessageRecord(Context context, long id, Recipients recipients,
Recipient individualRecipient, int recipientDeviceId,
......@@ -57,19 +57,11 @@ public class MediaMmsMessageRecord extends MessageRecord {
List<NetworkFailure> failures, int subscriptionId)
{
super(context, id, body, recipients, individualRecipient, recipientDeviceId, dateSent,
dateReceived, threadId, Status.STATUS_NONE, dateDeliveryReceived, mailbox, mismatches, failures, subscriptionId);
dateReceived, threadId, Status.STATUS_NONE, dateDeliveryReceived, mailbox, mismatches, failures,
subscriptionId, slideDeck);
this.context = context.getApplicationContext();
this.partCount = partCount;
this.slideDeck = slideDeck;
}
public @NonNull SlideDeck getSlideDeck() {
return slideDeck;
}
public boolean containsMediaSlide() {
return slideDeck.containsMediaSlide();
}
public int getPartCount() {
......@@ -77,12 +69,18 @@ public class MediaMmsMessageRecord extends MessageRecord {
}
@Override
public boolean isMms() {
return true;
public boolean isMmsNotification() {
return false;
}
@Override
public boolean isMmsNotification() {
public boolean isMediaPending() {
for (Slide slide : getSlideDeck().getSlides()) {
if (slide.isInProgress() || slide.isPendingDownload()) {
return true;
}
}
return false;
}
......
......@@ -151,6 +151,10 @@ public abstract class MessageRecord extends DisplayRecord {
return SmsDatabase.Types.isXmppExchangeType(type);
}
public boolean isMediaPending() {
return false;
}
public Recipient getIndividualRecipient() {
return individualRecipient;
}
......
package org.smssecure.smssecure.database.model;
import android.content.Context;
import android.support.annotation.NonNull;
import org.smssecure.smssecure.database.documents.IdentityKeyMismatch;
import org.smssecure.smssecure.database.documents.NetworkFailure;
import org.smssecure.smssecure.mms.Slide;
import org.smssecure.smssecure.mms.SlideDeck;
import org.smssecure.smssecure.recipients.Recipient;
import org.smssecure.smssecure.recipients.Recipients;
import java.util.List;
public abstract class MmsMessageRecord extends MessageRecord {
private final @NonNull SlideDeck slideDeck;
MmsMessageRecord(Context context, long id, Body body, Recipients recipients,
Recipient individualRecipient, int recipientDeviceId, long dateSent,
long dateReceived, long threadId, int deliveryStatus, long dateDeliveryReceived,
long type, List<IdentityKeyMismatch> mismatches,
List<NetworkFailure> networkFailures, int subscriptionId, @NonNull SlideDeck slideDeck)
{
super(context, id, body, recipients, individualRecipient, recipientDeviceId, dateSent, dateReceived, threadId, deliveryStatus, dateDeliveryReceived, type, mismatches, networkFailures, subscriptionId);
this.slideDeck = slideDeck;
}
@Override
public boolean isMms() {
return true;
}
@NonNull
public SlideDeck getSlideDeck() {
return slideDeck;
}
@Override
public boolean isMediaPending() {
for (Slide slide : getSlideDeck().getSlides()) {
if (slide.isInProgress() || slide.isPendingDownload()) {
return true;
}
}
return false;
}
public boolean containsMediaSlide() {
return slideDeck.containsMediaSlide();
}
}
......@@ -24,6 +24,7 @@ import org.smssecure.smssecure.database.SmsDatabase.Status;
import org.smssecure.smssecure.database.MmsDatabase;
import org.smssecure.smssecure.database.documents.NetworkFailure;
import org.smssecure.smssecure.database.documents.IdentityKeyMismatch;
import org.smssecure.smssecure.mms.SlideDeck;
import org.smssecure.smssecure.recipients.Recipient;
import org.smssecure.smssecure.recipients.Recipients;
......@@ -37,12 +38,12 @@ import java.util.LinkedList;
*
*/
public class NotificationMmsMessageRecord extends MessageRecord {
public class NotificationMmsMessageRecord extends MmsMessageRecord {
private final byte[] contentLocation;
private final long messageSize;
private final long expiry;
private final int status;
private final long messageSize;
private final long expiry;
private final int status;
private final byte[] transactionId;
public NotificationMmsMessageRecord(Context context, long id, Recipients recipients,
......@@ -50,11 +51,12 @@ public class NotificationMmsMessageRecord extends MessageRecord {
long dateSent, long dateReceived, long dateDeliveryReceived,
long threadId, byte[] contentLocation, long messageSize,
long expiry, int status, byte[] transactionId, long mailbox,
int subscriptionId)
int subscriptionId, SlideDeck slideDeck)
{
super(context, id, new Body("", true), recipients, individualRecipient, recipientDeviceId,
dateSent, dateReceived, threadId, Status.STATUS_NONE, dateDeliveryReceived, mailbox,
new LinkedList<IdentityKeyMismatch>(), new LinkedList<NetworkFailure>(), subscriptionId);
new LinkedList<IdentityKeyMismatch>(), new LinkedList<NetworkFailure>(), subscriptionId,
slideDeck);
this.contentLocation = contentLocation;
this.messageSize = messageSize;
......@@ -88,11 +90,6 @@ public class NotificationMmsMessageRecord extends MessageRecord {
return false;
}
@Override
public boolean isFailed() {
return MmsDatabase.Status.isHardError(status);
}
@Override
public boolean isSecure() {
return false;
......@@ -104,17 +101,23 @@ public class NotificationMmsMessageRecord extends MessageRecord {
}
@Override
public boolean isMms() {
public boolean isMmsNotification() {
return true;
}
@Override
public boolean isMmsNotification() {
public boolean isMediaPending() {
return true;
}
@Override
public SpannableString getDisplayBody() {
return emphasisAdded(context.getString(R.string.NotificationMmsMessageRecord_multimedia_message));
if (status == MmsDatabase.Status.DOWNLOAD_INITIALIZED) {
return emphasisAdded(context.getString(R.string.NotificationMmsMessageRecord_multimedia_message));
} else if (status == MmsDatabase.Status.DOWNLOAD_CONNECTING) {
return emphasisAdded(context.getString(R.string.NotificationMmsMessageRecord_downloading_mms_message));
} else {
return emphasisAdded(context.getString(R.string.NotificationMmsMessageRecord_error_downloading_mms_message));
}
}
}
package org.smssecure.smssecure.mms;
import android.content.Context;
import android.support.annotation.NonNull;
import org.smssecure.smssecure.attachments.Attachment;
public class MmsSlide extends ImageSlide {
public MmsSlide(@NonNull Context context, @NonNull Attachment attachment) {
super(context, attachment);
}
@NonNull
@Override
public String getContentDescription() {
return "MMS";
}
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ import org.smssecure.smssecure.mms.AudioSlide;
import org.smssecure.smssecure.mms.DecryptableStreamUriLoader.DecryptableUri;
import org.smssecure.smssecure.mms.GifSlide;
import org.smssecure.smssecure.mms.ImageSlide;
import org.smssecure.smssecure.mms.MmsSlide;
import org.smssecure.smssecure.mms.PartAuthority;
import org.smssecure.smssecure.mms.Slide;
import org.smssecure.smssecure.mms.VideoSlide;
......@@ -83,6 +84,8 @@ public class MediaUtil {
slide = new VideoSlide(context, attachment);
} else if (isAudioType(attachment.getContentType())) {
slide = new AudioSlide(context, attachment);
} else if (isMms(attachment.getContentType())) {
slide = new MmsSlide(context, attachment);
}
return slide;
......@@ -148,6 +151,10 @@ public class MediaUtil {
return isVideoType(attachment.getContentType());
}
public static boolean isMms(String contentType) {
return !TextUtils.isEmpty(contentType) && contentType.trim().equals("application/mms");
}
public static boolean isGif(String contentType) {
return !TextUtils.isEmpty(contentType) && contentType.trim().equals("image/gif");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment