2012-07-20 02:23:49 +00:00
|
|
|
/**
|
2011-12-20 18:20:44 +00:00
|
|
|
* Copyright (C) 2011 Whisper Systems
|
2012-07-20 02:23:49 +00:00
|
|
|
*
|
2011-12-20 18:20:44 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2012-07-20 02:23:49 +00:00
|
|
|
*
|
2011-12-20 18:20:44 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
2014-10-16 05:26:55 +00:00
|
|
|
import android.content.ActivityNotFoundException;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
2014-02-23 21:59:12 +00:00
|
|
|
import android.content.res.TypedArray;
|
2015-06-30 16:16:05 +00:00
|
|
|
import android.graphics.Color;
|
2015-06-29 15:49:32 +00:00
|
|
|
import android.graphics.PorterDuff;
|
2017-03-28 19:05:30 +00:00
|
|
|
import android.net.Uri;
|
2016-08-16 03:23:56 +00:00
|
|
|
import android.os.AsyncTask;
|
2015-03-08 18:37:18 +00:00
|
|
|
import android.support.annotation.NonNull;
|
2015-09-24 00:19:24 +00:00
|
|
|
import android.support.annotation.Nullable;
|
2015-05-20 21:36:30 +00:00
|
|
|
import android.support.v7.app.AlertDialog;
|
2015-01-30 06:37:01 +00:00
|
|
|
import android.text.TextUtils;
|
2015-09-15 22:28:27 +00:00
|
|
|
import android.text.util.Linkify;
|
2012-07-20 02:23:49 +00:00
|
|
|
import android.util.AttributeSet;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.util.Log;
|
2017-04-15 05:59:30 +00:00
|
|
|
import android.util.TypedValue;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.view.View;
|
2015-06-29 15:49:32 +00:00
|
|
|
import android.view.ViewGroup;
|
2017-01-20 17:11:40 +00:00
|
|
|
import android.view.ViewStub;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.TextView;
|
2014-10-16 05:26:55 +00:00
|
|
|
import android.widget.Toast;
|
2011-12-20 18:20:44 +00:00
|
|
|
|
2016-08-14 05:55:43 +00:00
|
|
|
import org.thoughtcrime.securesms.components.AlertView;
|
2015-10-21 22:32:29 +00:00
|
|
|
import org.thoughtcrime.securesms.components.AudioView;
|
2015-05-04 18:36:18 +00:00
|
|
|
import org.thoughtcrime.securesms.components.AvatarImageView;
|
2015-11-24 15:06:41 +00:00
|
|
|
import org.thoughtcrime.securesms.components.DeliveryStatusView;
|
2017-03-28 19:05:30 +00:00
|
|
|
import org.thoughtcrime.securesms.components.DocumentView;
|
2016-08-16 03:23:56 +00:00
|
|
|
import org.thoughtcrime.securesms.components.ExpirationTimerView;
|
2015-03-31 22:44:41 +00:00
|
|
|
import org.thoughtcrime.securesms.components.ThumbnailView;
|
2014-11-03 23:16:04 +00:00
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
2015-10-21 22:32:29 +00:00
|
|
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
2014-03-01 22:17:55 +00:00
|
|
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
2012-07-20 02:23:49 +00:00
|
|
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
2015-01-15 21:35:35 +00:00
|
|
|
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
2014-03-01 22:17:55 +00:00
|
|
|
import org.thoughtcrime.securesms.database.SmsDatabase;
|
2015-05-21 17:13:03 +00:00
|
|
|
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
2012-10-28 23:04:24 +00:00
|
|
|
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
|
|
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
2017-01-20 23:26:17 +00:00
|
|
|
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
2014-11-03 23:16:04 +00:00
|
|
|
import org.thoughtcrime.securesms.jobs.MmsDownloadJob;
|
2014-11-08 19:35:58 +00:00
|
|
|
import org.thoughtcrime.securesms.jobs.MmsSendJob;
|
|
|
|
import org.thoughtcrime.securesms.jobs.SmsSendJob;
|
2014-12-12 09:03:24 +00:00
|
|
|
import org.thoughtcrime.securesms.mms.PartAuthority;
|
2012-07-20 02:23:49 +00:00
|
|
|
import org.thoughtcrime.securesms.mms.Slide;
|
2015-10-21 22:32:29 +00:00
|
|
|
import org.thoughtcrime.securesms.mms.SlideClickListener;
|
2012-07-20 02:23:49 +00:00
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
2015-10-21 22:32:29 +00:00
|
|
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
2016-08-16 03:23:56 +00:00
|
|
|
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
2014-02-20 05:06:54 +00:00
|
|
|
import org.thoughtcrime.securesms.util.DateUtils;
|
2015-11-07 01:48:37 +00:00
|
|
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
2015-09-17 00:31:24 +00:00
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
2016-02-06 00:10:33 +00:00
|
|
|
import org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat;
|
|
|
|
import org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat;
|
2017-01-20 17:11:40 +00:00
|
|
|
import org.thoughtcrime.securesms.util.views.Stub;
|
2016-03-23 17:34:41 +00:00
|
|
|
import org.whispersystems.libsignal.util.guava.Optional;
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-10-21 22:32:29 +00:00
|
|
|
import java.util.HashSet;
|
2015-05-26 20:12:11 +00:00
|
|
|
import java.util.List;
|
2015-03-19 20:08:48 +00:00
|
|
|
import java.util.Locale;
|
2014-12-14 02:10:59 +00:00
|
|
|
import java.util.Set;
|
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
/**
|
|
|
|
* A view that displays an individual conversation item within a conversation
|
|
|
|
* thread. Used by ComposeMessageActivity's ListActivity via a ConversationAdapter.
|
2012-07-20 02:23:49 +00:00
|
|
|
*
|
2011-12-20 18:20:44 +00:00
|
|
|
* @author Moxie Marlinspike
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-09-15 22:28:27 +00:00
|
|
|
public class ConversationItem extends LinearLayout
|
2015-10-21 22:32:29 +00:00
|
|
|
implements Recipient.RecipientModifiedListener, Recipients.RecipientsModifiedListener, BindableConversationItem
|
2015-09-15 22:28:27 +00:00
|
|
|
{
|
2014-02-23 21:59:12 +00:00
|
|
|
private final static String TAG = ConversationItem.class.getSimpleName();
|
2011-12-20 18:20:44 +00:00
|
|
|
|
|
|
|
private MessageRecord messageRecord;
|
|
|
|
private MasterSecret masterSecret;
|
2015-03-19 20:08:48 +00:00
|
|
|
private Locale locale;
|
2013-05-05 19:51:36 +00:00
|
|
|
private boolean groupThread;
|
2015-07-23 00:47:38 +00:00
|
|
|
private Recipient recipient;
|
2011-12-20 18:20:44 +00:00
|
|
|
|
2017-01-20 17:11:40 +00:00
|
|
|
protected View bodyBubble;
|
2015-11-24 15:06:41 +00:00
|
|
|
private TextView bodyText;
|
|
|
|
private TextView dateText;
|
2016-02-06 00:10:33 +00:00
|
|
|
private TextView simInfoText;
|
2015-11-24 15:06:41 +00:00
|
|
|
private TextView indicatorText;
|
|
|
|
private TextView groupStatusText;
|
|
|
|
private ImageView secureImage;
|
|
|
|
private AvatarImageView contactPhoto;
|
|
|
|
private DeliveryStatusView deliveryStatusIndicator;
|
|
|
|
private AlertView alertView;
|
2015-01-30 06:37:01 +00:00
|
|
|
|
2015-10-21 22:32:29 +00:00
|
|
|
private @NonNull Set<MessageRecord> batchSelected = new HashSet<>();
|
|
|
|
private @Nullable Recipients conversationRecipients;
|
2017-01-20 17:30:08 +00:00
|
|
|
private @NonNull Stub<ThumbnailView> mediaThumbnailStub;
|
2017-01-20 17:11:40 +00:00
|
|
|
private @NonNull Stub<AudioView> audioViewStub;
|
2017-03-28 19:05:30 +00:00
|
|
|
private @NonNull Stub<DocumentView> documentViewStub;
|
2016-08-16 03:23:56 +00:00
|
|
|
private @NonNull ExpirationTimerView expirationTimer;
|
2015-01-30 06:37:01 +00:00
|
|
|
|
2015-09-15 22:28:27 +00:00
|
|
|
private int defaultBubbleColor;
|
2015-07-20 20:40:57 +00:00
|
|
|
|
2017-01-20 17:11:40 +00:00
|
|
|
private final PassthroughClickListener passthroughClickListener = new PassthroughClickListener();
|
|
|
|
private final AttachmentDownloadClickListener downloadClickListener = new AttachmentDownloadClickListener();
|
|
|
|
|
|
|
|
private final Context context;
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
public ConversationItem(Context context) {
|
2015-09-15 22:28:27 +00:00
|
|
|
this(context, null);
|
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
|
|
|
public ConversationItem(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
this.context = context;
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:19:24 +00:00
|
|
|
@Override
|
|
|
|
public void setOnClickListener(OnClickListener l) {
|
|
|
|
super.setOnClickListener(new ClickListener(l));
|
|
|
|
}
|
|
|
|
|
2012-07-20 02:23:49 +00:00
|
|
|
@Override
|
|
|
|
protected void onFinishInflate() {
|
|
|
|
super.onFinishInflate();
|
|
|
|
|
2015-07-20 20:40:57 +00:00
|
|
|
initializeAttributes();
|
2015-06-29 15:49:32 +00:00
|
|
|
|
2015-11-24 15:06:41 +00:00
|
|
|
this.bodyText = (TextView) findViewById(R.id.conversation_item_body);
|
|
|
|
this.dateText = (TextView) findViewById(R.id.conversation_item_date);
|
2016-02-06 00:10:33 +00:00
|
|
|
this.simInfoText = (TextView) findViewById(R.id.sim_info);
|
2015-11-24 15:06:41 +00:00
|
|
|
this.indicatorText = (TextView) findViewById(R.id.indicator_text);
|
|
|
|
this.groupStatusText = (TextView) findViewById(R.id.group_message_status);
|
|
|
|
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.contactPhoto = (AvatarImageView) findViewById(R.id.contact_photo);
|
|
|
|
this.bodyBubble = findViewById(R.id.body_bubble);
|
2017-01-20 17:30:08 +00:00
|
|
|
this.mediaThumbnailStub = new Stub<>((ViewStub) findViewById(R.id.image_view_stub));
|
2017-01-20 17:11:40 +00:00
|
|
|
this.audioViewStub = new Stub<>((ViewStub) findViewById(R.id.audio_view_stub));
|
2017-03-28 19:05:30 +00:00
|
|
|
this.documentViewStub = new Stub<>((ViewStub) findViewById(R.id.document_view_stub));
|
2016-08-16 03:23:56 +00:00
|
|
|
this.expirationTimer = (ExpirationTimerView) findViewById(R.id.expiration_indicator);
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-09-24 00:19:24 +00:00
|
|
|
setOnClickListener(new ClickListener(null));
|
2015-10-21 22:32:29 +00:00
|
|
|
|
2015-09-15 22:28:27 +00:00
|
|
|
bodyText.setOnLongClickListener(passthroughClickListener);
|
|
|
|
bodyText.setOnClickListener(passthroughClickListener);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-09-15 22:28:27 +00:00
|
|
|
@Override
|
|
|
|
public void bind(@NonNull MasterSecret masterSecret,
|
|
|
|
@NonNull MessageRecord messageRecord,
|
|
|
|
@NonNull Locale locale,
|
|
|
|
@NonNull Set<MessageRecord> batchSelected,
|
2015-10-21 22:32:29 +00:00
|
|
|
@NonNull Recipients conversationRecipients)
|
2011-12-20 18:20:44 +00:00
|
|
|
{
|
2014-12-14 02:10:59 +00:00
|
|
|
this.masterSecret = masterSecret;
|
|
|
|
this.messageRecord = messageRecord;
|
2015-03-19 20:08:48 +00:00
|
|
|
this.locale = locale;
|
2014-12-14 02:10:59 +00:00
|
|
|
this.batchSelected = batchSelected;
|
2015-10-21 22:32:29 +00:00
|
|
|
this.conversationRecipients = conversationRecipients;
|
|
|
|
this.groupThread = !conversationRecipients.isSingleRecipient() || conversationRecipients.isGroupRecipient();
|
2015-07-23 00:47:38 +00:00
|
|
|
this.recipient = messageRecord.getIndividualRecipient();
|
|
|
|
|
|
|
|
this.recipient.addListener(this);
|
2015-10-21 22:32:29 +00:00
|
|
|
this.conversationRecipients.addListener(this);
|
2014-12-14 02:10:59 +00:00
|
|
|
|
2017-01-20 17:11:40 +00:00
|
|
|
setMediaAttributes(messageRecord);
|
2017-01-20 17:30:08 +00:00
|
|
|
setInteractionState(messageRecord);
|
2017-01-27 00:26:57 +00:00
|
|
|
setBodyText(messageRecord);
|
2015-09-17 00:31:24 +00:00
|
|
|
setBubbleState(messageRecord, recipient);
|
|
|
|
setStatusIcons(messageRecord);
|
|
|
|
setContactPhoto(recipient);
|
|
|
|
setGroupMessageStatus(messageRecord, recipient);
|
|
|
|
setMinimumWidth();
|
2016-02-06 00:10:33 +00:00
|
|
|
setSimInfo(messageRecord);
|
2016-08-16 03:23:56 +00:00
|
|
|
setExpiration(messageRecord);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-07-20 20:40:57 +00:00
|
|
|
private void initializeAttributes() {
|
|
|
|
final int[] attributes = new int[] {R.attr.conversation_item_bubble_background,
|
|
|
|
R.attr.conversation_list_item_background_selected,
|
|
|
|
R.attr.conversation_item_background};
|
|
|
|
final TypedArray attrs = context.obtainStyledAttributes(attributes);
|
|
|
|
|
|
|
|
defaultBubbleColor = attrs.getColor(0, Color.WHITE);
|
|
|
|
attrs.recycle();
|
|
|
|
}
|
|
|
|
|
2015-09-17 00:31:24 +00:00
|
|
|
@Override
|
2013-04-26 18:23:43 +00:00
|
|
|
public void unbind() {
|
2015-07-23 00:47:38 +00:00
|
|
|
if (recipient != null) {
|
|
|
|
recipient.removeListener(this);
|
|
|
|
}
|
2016-08-16 03:23:56 +00:00
|
|
|
|
|
|
|
this.expirationTimer.stopAnimation();
|
2013-04-26 18:23:43 +00:00
|
|
|
}
|
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
public MessageRecord getMessageRecord() {
|
|
|
|
return messageRecord;
|
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2012-10-28 23:04:24 +00:00
|
|
|
/// MessageRecord Attribute Parsers
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-07-23 00:47:38 +00:00
|
|
|
private void setBubbleState(MessageRecord messageRecord, Recipient recipient) {
|
2015-06-29 22:33:36 +00:00
|
|
|
if (messageRecord.isOutgoing()) {
|
2015-07-20 20:40:57 +00:00
|
|
|
bodyBubble.getBackground().setColorFilter(defaultBubbleColor, PorterDuff.Mode.MULTIPLY);
|
2017-01-20 17:30:08 +00:00
|
|
|
if (mediaThumbnailStub.resolved()) mediaThumbnailStub.get().setBackgroundColorHint(defaultBubbleColor);
|
2016-08-14 05:55:43 +00:00
|
|
|
} else {
|
|
|
|
int color = recipient.getColor().toConversationColor(context);
|
|
|
|
bodyBubble.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
|
2017-01-20 17:30:08 +00:00
|
|
|
if (mediaThumbnailStub.resolved()) mediaThumbnailStub.get().setBackgroundColorHint(color);
|
2016-08-14 05:55:43 +00:00
|
|
|
}
|
2016-11-22 02:58:10 +00:00
|
|
|
|
2017-01-20 17:11:40 +00:00
|
|
|
if (audioViewStub.resolved()) {
|
|
|
|
setAudioViewTint(messageRecord, conversationRecipients);
|
|
|
|
}
|
2017-03-28 19:05:30 +00:00
|
|
|
|
|
|
|
if (documentViewStub.resolved()) {
|
|
|
|
setDocumentViewTint(messageRecord, conversationRecipients);
|
|
|
|
}
|
2016-08-14 05:55:43 +00:00
|
|
|
}
|
2015-11-07 01:48:37 +00:00
|
|
|
|
2016-08-14 05:55:43 +00:00
|
|
|
private void setAudioViewTint(MessageRecord messageRecord, Recipients recipients) {
|
|
|
|
if (messageRecord.isOutgoing()) {
|
2015-11-07 01:48:37 +00:00
|
|
|
if (DynamicTheme.LIGHT.equals(TextSecurePreferences.getTheme(context))) {
|
2017-01-20 17:11:40 +00:00
|
|
|
audioViewStub.get().setTint(recipients.getColor().toConversationColor(context), defaultBubbleColor);
|
2015-11-07 01:48:37 +00:00
|
|
|
} else {
|
2017-01-20 17:11:40 +00:00
|
|
|
audioViewStub.get().setTint(Color.WHITE, defaultBubbleColor);
|
2015-11-07 01:48:37 +00:00
|
|
|
}
|
2016-11-22 02:58:10 +00:00
|
|
|
} else {
|
2017-01-20 17:11:40 +00:00
|
|
|
audioViewStub.get().setTint(Color.WHITE, recipients.getColor().toConversationColor(context));
|
2015-06-29 22:33:36 +00:00
|
|
|
}
|
2015-05-18 15:38:48 +00:00
|
|
|
}
|
2014-02-26 08:30:29 +00:00
|
|
|
|
2017-03-28 19:05:30 +00:00
|
|
|
private void setDocumentViewTint(MessageRecord messageRecord, Recipients recipients) {
|
|
|
|
if (messageRecord.isOutgoing()) {
|
|
|
|
if (DynamicTheme.LIGHT.equals(TextSecurePreferences.getTheme(context))) {
|
|
|
|
documentViewStub.get().setTint(recipients.getColor().toConversationColor(context), defaultBubbleColor);
|
|
|
|
} else {
|
|
|
|
documentViewStub.get().setTint(Color.WHITE, defaultBubbleColor);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
documentViewStub.get().setTint(Color.WHITE, recipients.getColor().toConversationColor(context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:19:24 +00:00
|
|
|
private void setInteractionState(MessageRecord messageRecord) {
|
2015-09-15 22:28:27 +00:00
|
|
|
setSelected(batchSelected.contains(messageRecord));
|
|
|
|
bodyText.setAutoLinkMask(batchSelected.isEmpty() ? Linkify.ALL : 0);
|
2017-01-20 17:30:08 +00:00
|
|
|
|
|
|
|
if (mediaThumbnailStub.resolved()) {
|
|
|
|
mediaThumbnailStub.get().setFocusable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
|
|
|
|
mediaThumbnailStub.get().setClickable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
|
|
|
|
mediaThumbnailStub.get().setLongClickable(batchSelected.isEmpty());
|
|
|
|
}
|
2017-01-13 02:13:28 +00:00
|
|
|
|
|
|
|
if (audioViewStub.resolved()) {
|
|
|
|
audioViewStub.get().setFocusable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
|
|
|
|
audioViewStub.get().setClickable(batchSelected.isEmpty());
|
|
|
|
audioViewStub.get().setEnabled(batchSelected.isEmpty());
|
|
|
|
}
|
2017-03-28 19:05:30 +00:00
|
|
|
|
|
|
|
if (documentViewStub.resolved()) {
|
|
|
|
documentViewStub.get().setFocusable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
|
|
|
|
documentViewStub.get().setClickable(batchSelected.isEmpty());
|
|
|
|
}
|
2014-12-14 02:10:59 +00:00
|
|
|
}
|
|
|
|
|
2015-01-30 06:37:01 +00:00
|
|
|
private boolean isCaptionlessMms(MessageRecord messageRecord) {
|
|
|
|
return TextUtils.isEmpty(messageRecord.getDisplayBody()) && messageRecord.isMms();
|
|
|
|
}
|
|
|
|
|
2015-10-21 22:32:29 +00:00
|
|
|
private boolean hasAudio(MessageRecord messageRecord) {
|
2017-01-20 23:26:17 +00:00
|
|
|
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getAudioSlide() != null;
|
2015-10-21 22:32:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private boolean hasThumbnail(MessageRecord messageRecord) {
|
2017-01-20 23:26:17 +00:00
|
|
|
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getThumbnailSlide() != null;
|
2015-01-30 06:37:01 +00:00
|
|
|
}
|
|
|
|
|
2017-03-28 19:05:30 +00:00
|
|
|
private boolean hasDocument(MessageRecord messageRecord) {
|
|
|
|
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getDocumentSlide() != null;
|
|
|
|
}
|
|
|
|
|
2014-02-26 08:30:29 +00:00
|
|
|
private void setBodyText(MessageRecord messageRecord) {
|
2014-12-14 02:10:59 +00:00
|
|
|
bodyText.setClickable(false);
|
|
|
|
bodyText.setFocusable(false);
|
2017-04-15 05:59:30 +00:00
|
|
|
bodyText.setTextSize(TypedValue.COMPLEX_UNIT_SP, TextSecurePreferences.getMessageBodyTextSize(context));
|
2015-01-30 06:37:01 +00:00
|
|
|
|
|
|
|
if (isCaptionlessMms(messageRecord)) {
|
|
|
|
bodyText.setVisibility(View.GONE);
|
|
|
|
} else {
|
2015-05-06 20:53:55 +00:00
|
|
|
bodyText.setText(messageRecord.getDisplayBody());
|
2015-01-30 06:37:01 +00:00
|
|
|
bodyText.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-01-30 06:37:01 +00:00
|
|
|
private void setMediaAttributes(MessageRecord messageRecord) {
|
2015-10-21 22:32:29 +00:00
|
|
|
boolean showControls = !messageRecord.isFailed() && (!messageRecord.isOutgoing() || messageRecord.isPending());
|
|
|
|
|
2017-01-20 23:26:17 +00:00
|
|
|
if (hasAudio(messageRecord)) {
|
2017-01-20 17:11:40 +00:00
|
|
|
audioViewStub.get().setVisibility(View.VISIBLE);
|
2017-01-20 17:30:08 +00:00
|
|
|
if (mediaThumbnailStub.resolved()) mediaThumbnailStub.get().setVisibility(View.GONE);
|
2017-03-28 19:05:30 +00:00
|
|
|
if (documentViewStub.resolved()) documentViewStub.get().setVisibility(View.GONE);
|
2015-10-21 22:32:29 +00:00
|
|
|
|
|
|
|
//noinspection ConstantConditions
|
2017-01-20 17:11:40 +00:00
|
|
|
audioViewStub.get().setAudio(masterSecret, ((MediaMmsMessageRecord) messageRecord).getSlideDeck().getAudioSlide(), showControls);
|
|
|
|
audioViewStub.get().setDownloadClickListener(downloadClickListener);
|
|
|
|
audioViewStub.get().setOnLongClickListener(passthroughClickListener);
|
|
|
|
|
2015-10-21 22:32:29 +00:00
|
|
|
bodyText.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
2017-03-28 19:05:30 +00:00
|
|
|
} else if (hasDocument(messageRecord)) {
|
|
|
|
documentViewStub.get().setVisibility(View.VISIBLE);
|
|
|
|
if (mediaThumbnailStub.resolved()) mediaThumbnailStub.get().setVisibility(View.GONE);
|
|
|
|
if (audioViewStub.resolved()) audioViewStub.get().setVisibility(View.GONE);
|
|
|
|
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
documentViewStub.get().setDocument(((MediaMmsMessageRecord)messageRecord).getSlideDeck().getDocumentSlide(), showControls);
|
|
|
|
documentViewStub.get().setDocumentClickListener(new ThumbnailClickListener());
|
|
|
|
documentViewStub.get().setDownloadClickListener(downloadClickListener);
|
|
|
|
documentViewStub.get().setOnLongClickListener(passthroughClickListener);
|
|
|
|
|
2017-03-31 23:52:50 +00:00
|
|
|
bodyText.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
2015-10-21 22:32:29 +00:00
|
|
|
} else if (hasThumbnail(messageRecord)) {
|
2017-01-20 17:30:08 +00:00
|
|
|
mediaThumbnailStub.get().setVisibility(View.VISIBLE);
|
2017-03-28 19:05:30 +00:00
|
|
|
if (audioViewStub.resolved()) audioViewStub.get().setVisibility(View.GONE);
|
|
|
|
if (documentViewStub.resolved()) documentViewStub.get().setVisibility(View.GONE);
|
2015-10-21 22:32:29 +00:00
|
|
|
|
2015-10-21 22:32:19 +00:00
|
|
|
//noinspection ConstantConditions
|
2017-01-20 17:30:08 +00:00
|
|
|
mediaThumbnailStub.get().setImageResource(masterSecret,
|
2017-01-20 23:26:17 +00:00
|
|
|
((MmsMessageRecord)messageRecord).getSlideDeck().getThumbnailSlide(),
|
2017-01-20 17:30:08 +00:00
|
|
|
showControls);
|
|
|
|
mediaThumbnailStub.get().setThumbnailClickListener(new ThumbnailClickListener());
|
|
|
|
mediaThumbnailStub.get().setDownloadClickListener(downloadClickListener);
|
|
|
|
mediaThumbnailStub.get().setOnLongClickListener(passthroughClickListener);
|
|
|
|
mediaThumbnailStub.get().setOnClickListener(passthroughClickListener);
|
|
|
|
|
2015-06-29 15:49:32 +00:00
|
|
|
bodyText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
|
|
|
} else {
|
2017-01-20 17:30:08 +00:00
|
|
|
if (mediaThumbnailStub.resolved()) mediaThumbnailStub.get().setVisibility(View.GONE);
|
|
|
|
if (audioViewStub.resolved()) audioViewStub.get().setVisibility(View.GONE);
|
2017-03-28 19:05:30 +00:00
|
|
|
if (documentViewStub.resolved()) documentViewStub.get().setVisibility(View.GONE);
|
2015-06-29 15:49:32 +00:00
|
|
|
bodyText.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
2015-01-30 06:37:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-23 00:47:38 +00:00
|
|
|
private void setContactPhoto(Recipient recipient) {
|
2014-01-08 22:29:05 +00:00
|
|
|
if (! messageRecord.isOutgoing()) {
|
2015-07-23 00:47:38 +00:00
|
|
|
setContactPhotoForRecipient(recipient);
|
2012-10-28 23:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setStatusIcons(MessageRecord messageRecord) {
|
2015-06-29 15:49:32 +00:00
|
|
|
indicatorText.setVisibility(View.GONE);
|
2012-10-28 23:04:24 +00:00
|
|
|
|
2015-06-29 15:49:32 +00:00
|
|
|
secureImage.setVisibility(messageRecord.isSecure() ? View.VISIBLE : View.GONE);
|
|
|
|
bodyText.setCompoundDrawablesWithIntrinsicBounds(0, 0, messageRecord.isKeyExchange() ? R.drawable.ic_menu_login : 0, 0);
|
2015-07-06 22:14:57 +00:00
|
|
|
dateText.setText(DateUtils.getExtendedRelativeTimeSpanString(getContext(), locale, messageRecord.getTimestamp()));
|
2015-06-29 15:49:32 +00:00
|
|
|
|
2015-11-24 15:06:41 +00:00
|
|
|
if (messageRecord.isFailed()) {
|
|
|
|
setFailedStatusIcons();
|
|
|
|
} else if (messageRecord.isPendingInsecureSmsFallback()) {
|
|
|
|
setFallbackStatusIcons();
|
|
|
|
} else {
|
|
|
|
alertView.setNone();
|
|
|
|
|
|
|
|
if (!messageRecord.isOutgoing()) deliveryStatusIndicator.setNone();
|
|
|
|
else if (messageRecord.isPending()) deliveryStatusIndicator.setPending();
|
|
|
|
else if (messageRecord.isDelivered()) deliveryStatusIndicator.setDelivered();
|
|
|
|
else deliveryStatusIndicator.setSent();
|
|
|
|
}
|
2015-01-15 21:35:35 +00:00
|
|
|
}
|
|
|
|
|
2016-02-06 00:10:33 +00:00
|
|
|
private void setSimInfo(MessageRecord messageRecord) {
|
2016-02-11 01:50:23 +00:00
|
|
|
SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(context);
|
|
|
|
|
|
|
|
if (messageRecord.getSubscriptionId() == -1 || subscriptionManager.getActiveSubscriptionInfoList().size() < 2) {
|
2016-02-06 00:10:33 +00:00
|
|
|
simInfoText.setVisibility(View.GONE);
|
|
|
|
} else {
|
2016-02-11 01:50:23 +00:00
|
|
|
Optional<SubscriptionInfoCompat> subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId());
|
2016-02-06 00:10:33 +00:00
|
|
|
|
|
|
|
if (subscriptionInfo.isPresent() && messageRecord.isOutgoing()) {
|
|
|
|
simInfoText.setText(getContext().getString(R.string.ConversationItem_from_s, subscriptionInfo.get().getDisplayName()));
|
|
|
|
simInfoText.setVisibility(View.VISIBLE);
|
|
|
|
} else if (subscriptionInfo.isPresent()) {
|
|
|
|
simInfoText.setText(getContext().getString(R.string.ConversationItem_to_s, subscriptionInfo.get().getDisplayName()));
|
|
|
|
simInfoText.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
simInfoText.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-16 03:23:56 +00:00
|
|
|
private void setExpiration(final MessageRecord messageRecord) {
|
|
|
|
if (messageRecord.getExpiresIn() > 0) {
|
|
|
|
this.expirationTimer.setVisibility(View.VISIBLE);
|
|
|
|
this.expirationTimer.setPercentage(0);
|
|
|
|
|
|
|
|
if (messageRecord.getExpireStarted() > 0) {
|
|
|
|
this.expirationTimer.setExpirationTime(messageRecord.getExpireStarted(),
|
|
|
|
messageRecord.getExpiresIn());
|
|
|
|
this.expirationTimer.startAnimation();
|
|
|
|
} else if (!messageRecord.isOutgoing() && !messageRecord.isMediaPending()) {
|
|
|
|
new AsyncTask<Void, Void, Void>() {
|
|
|
|
@Override
|
|
|
|
protected Void doInBackground(Void... params) {
|
|
|
|
ExpiringMessageManager expirationManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
|
|
|
|
long id = messageRecord.getId();
|
|
|
|
boolean mms = messageRecord.isMms();
|
|
|
|
|
|
|
|
if (mms) DatabaseFactory.getMmsDatabase(context).markExpireStarted(id);
|
|
|
|
else DatabaseFactory.getSmsDatabase(context).markExpireStarted(id);
|
|
|
|
|
|
|
|
expirationManager.scheduleDeletion(id, mms, messageRecord.getExpiresIn());
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}.execute();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.expirationTimer.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-15 21:35:35 +00:00
|
|
|
private void setFailedStatusIcons() {
|
2015-11-24 15:06:41 +00:00
|
|
|
alertView.setFailed();
|
|
|
|
deliveryStatusIndicator.setNone();
|
2015-01-15 21:35:35 +00:00
|
|
|
dateText.setText(R.string.ConversationItem_error_not_delivered);
|
2015-11-24 15:06:41 +00:00
|
|
|
|
2015-10-30 23:59:01 +00:00
|
|
|
if (messageRecord.isOutgoing()) {
|
2015-03-27 17:37:59 +00:00
|
|
|
indicatorText.setText(R.string.ConversationItem_click_for_details);
|
|
|
|
indicatorText.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2015-01-15 21:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void setFallbackStatusIcons() {
|
2015-11-24 15:06:41 +00:00
|
|
|
alertView.setPendingApproval();
|
|
|
|
deliveryStatusIndicator.setNone();
|
2015-01-15 21:35:35 +00:00
|
|
|
indicatorText.setVisibility(View.VISIBLE);
|
2015-03-11 21:23:45 +00:00
|
|
|
indicatorText.setText(R.string.ConversationItem_click_to_approve_unencrypted);
|
2012-10-28 23:04:24 +00:00
|
|
|
}
|
|
|
|
|
2014-03-01 22:17:55 +00:00
|
|
|
private void setMinimumWidth() {
|
2015-10-30 23:59:01 +00:00
|
|
|
if (indicatorText.getVisibility() == View.VISIBLE && indicatorText.getText() != null) {
|
2014-04-01 01:47:24 +00:00
|
|
|
final float density = getResources().getDisplayMetrics().density;
|
2015-06-29 15:49:32 +00:00
|
|
|
bodyBubble.setMinimumWidth(indicatorText.getText().length() * (int) (6.5 * density) + (int) (22.0 * density));
|
2014-03-01 22:17:55 +00:00
|
|
|
} else {
|
2015-01-30 06:37:01 +00:00
|
|
|
bodyBubble.setMinimumWidth(0);
|
2014-03-01 22:17:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:19:24 +00:00
|
|
|
private boolean shouldInterceptClicks(MessageRecord messageRecord) {
|
|
|
|
return batchSelected.isEmpty() &&
|
2015-10-01 06:02:50 +00:00
|
|
|
((messageRecord.isFailed() && !messageRecord.isMmsNotification()) ||
|
2015-09-24 00:19:24 +00:00
|
|
|
messageRecord.isPendingInsecureSmsFallback() ||
|
|
|
|
messageRecord.isBundleKeyExchange());
|
2012-10-28 23:04:24 +00:00
|
|
|
}
|
|
|
|
|
2015-07-23 00:47:38 +00:00
|
|
|
private void setGroupMessageStatus(MessageRecord messageRecord, Recipient recipient) {
|
2013-05-05 19:51:36 +00:00
|
|
|
if (groupThread && !messageRecord.isOutgoing()) {
|
2015-07-23 00:47:38 +00:00
|
|
|
this.groupStatusText.setText(recipient.toShortString());
|
2013-05-05 19:51:36 +00:00
|
|
|
this.groupStatusText.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
2012-10-29 23:51:42 +00:00
|
|
|
this.groupStatusText.setVisibility(View.GONE);
|
2013-05-05 19:51:36 +00:00
|
|
|
}
|
2012-10-29 23:51:42 +00:00
|
|
|
}
|
|
|
|
|
2012-10-28 23:04:24 +00:00
|
|
|
/// Helper Methods
|
|
|
|
|
|
|
|
private void setContactPhotoForRecipient(final Recipient recipient) {
|
2014-03-28 02:46:27 +00:00
|
|
|
if (contactPhoto == null) return;
|
2014-03-06 23:58:26 +00:00
|
|
|
|
2015-05-04 18:36:18 +00:00
|
|
|
contactPhoto.setAvatar(recipient, true);
|
2012-10-28 23:04:24 +00:00
|
|
|
contactPhoto.setVisibility(View.VISIBLE);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2015-06-27 03:14:51 +00:00
|
|
|
|
2015-05-26 20:12:11 +00:00
|
|
|
/// Event handlers
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-05-26 20:12:11 +00:00
|
|
|
private void handleApproveIdentity() {
|
|
|
|
List<IdentityKeyMismatch> mismatches = messageRecord.getIdentityKeyMismatches();
|
2015-05-21 17:13:03 +00:00
|
|
|
|
2015-05-26 20:12:11 +00:00
|
|
|
if (mismatches.size() != 1) {
|
|
|
|
throw new AssertionError("Identity mismatch count: " + mismatches.size());
|
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-05-26 20:12:11 +00:00
|
|
|
new ConfirmIdentityDialog(context, masterSecret, messageRecord, mismatches.get(0)).show();
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-07-23 00:47:38 +00:00
|
|
|
@Override
|
2015-09-17 00:31:24 +00:00
|
|
|
public void onModified(final Recipient recipient) {
|
|
|
|
Util.runOnMain(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
setBubbleState(messageRecord, recipient);
|
|
|
|
setContactPhoto(recipient);
|
|
|
|
setGroupMessageStatus(messageRecord, recipient);
|
|
|
|
}
|
|
|
|
});
|
2015-07-23 00:47:38 +00:00
|
|
|
}
|
|
|
|
|
2015-10-21 22:32:29 +00:00
|
|
|
@Override
|
2016-08-14 05:55:43 +00:00
|
|
|
public void onModified(final Recipients recipients) {
|
|
|
|
Util.runOnMain(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
setAudioViewTint(messageRecord, recipients);
|
|
|
|
}
|
|
|
|
});
|
2015-10-21 22:32:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private class AttachmentDownloadClickListener implements SlideClickListener {
|
2017-01-20 23:26:17 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(View v, final Slide slide) {
|
|
|
|
if (messageRecord.isMmsNotification()) {
|
|
|
|
ApplicationContext.getInstance(context)
|
|
|
|
.getJobManager()
|
|
|
|
.add(new MmsDownloadJob(context, messageRecord.getId(),
|
|
|
|
messageRecord.getThreadId(), false));
|
|
|
|
} else {
|
|
|
|
DatabaseFactory.getAttachmentDatabase(context).setTransferState(messageRecord.getId(),
|
|
|
|
slide.asAttachment(),
|
|
|
|
AttachmentDatabase.TRANSFER_PROGRESS_STARTED);
|
|
|
|
}
|
2015-08-24 22:24:31 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-17 00:31:24 +00:00
|
|
|
|
2015-10-21 22:32:29 +00:00
|
|
|
private class ThumbnailClickListener implements SlideClickListener {
|
2015-03-31 22:44:41 +00:00
|
|
|
public void onClick(final View v, final Slide slide) {
|
2015-09-24 23:46:57 +00:00
|
|
|
if (shouldInterceptClicks(messageRecord) || !batchSelected.isEmpty()) {
|
|
|
|
performClick();
|
2016-11-26 20:10:14 +00:00
|
|
|
} else if (MediaPreviewActivity.isContentTypeSupported(slide.getContentType()) && slide.getUri() != null) {
|
2014-08-12 19:11:23 +00:00
|
|
|
Intent intent = new Intent(context, MediaPreviewActivity.class);
|
|
|
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
|
|
intent.setDataAndType(slide.getUri(), slide.getContentType());
|
2015-07-23 00:47:38 +00:00
|
|
|
if (!messageRecord.isOutgoing()) intent.putExtra(MediaPreviewActivity.RECIPIENT_EXTRA, recipient.getRecipientId());
|
2015-07-06 22:14:57 +00:00
|
|
|
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, messageRecord.getTimestamp());
|
2016-11-26 20:10:14 +00:00
|
|
|
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, slide.asAttachment().getSize());
|
2016-09-20 16:53:44 +00:00
|
|
|
intent.putExtra(MediaPreviewActivity.THREAD_ID_EXTRA, messageRecord.getThreadId());
|
2015-01-30 06:37:01 +00:00
|
|
|
|
2015-03-13 18:23:01 +00:00
|
|
|
context.startActivity(intent);
|
2016-12-11 21:37:27 +00:00
|
|
|
} else if (slide.getUri() != null) {
|
2017-03-28 19:05:30 +00:00
|
|
|
Log.w(TAG, "Clicked: " + slide.getUri() + " , " + slide.getContentType());
|
|
|
|
Uri publicUri = PartAuthority.getAttachmentPublicUri(slide.getUri());
|
|
|
|
Log.w(TAG, "Public URI: " + publicUri);
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
|
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
|
|
intent.setDataAndType(PartAuthority.getAttachmentPublicUri(slide.getUri()), slide.getContentType());
|
|
|
|
try {
|
|
|
|
context.startActivity(intent);
|
|
|
|
} catch (ActivityNotFoundException anfe) {
|
|
|
|
Log.w(TAG, "No activity existed to view the media.");
|
|
|
|
Toast.makeText(context, R.string.ConversationItem_unable_to_open_media, Toast.LENGTH_LONG).show();
|
|
|
|
}
|
2014-08-12 19:11:23 +00:00
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-09-15 22:28:27 +00:00
|
|
|
private class PassthroughClickListener implements View.OnLongClickListener, View.OnClickListener {
|
|
|
|
|
2015-09-24 23:46:57 +00:00
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
2015-09-15 22:28:27 +00:00
|
|
|
performLongClick();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-24 23:46:57 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-09-15 22:28:27 +00:00
|
|
|
performClick();
|
|
|
|
}
|
|
|
|
}
|
2017-03-28 19:05:30 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
private class ClickListener implements View.OnClickListener {
|
2015-09-24 00:19:24 +00:00
|
|
|
private OnClickListener parent;
|
2015-09-15 22:28:27 +00:00
|
|
|
|
2015-09-24 00:19:24 +00:00
|
|
|
public ClickListener(@Nullable OnClickListener parent) {
|
|
|
|
this.parent = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
if (!shouldInterceptClicks(messageRecord) && parent != null) {
|
|
|
|
parent.onClick(v);
|
|
|
|
} else if (messageRecord.isFailed()) {
|
2015-01-15 21:35:35 +00:00
|
|
|
Intent intent = new Intent(context, MessageDetailsActivity.class);
|
|
|
|
intent.putExtra(MessageDetailsActivity.MASTER_SECRET_EXTRA, masterSecret);
|
|
|
|
intent.putExtra(MessageDetailsActivity.MESSAGE_ID_EXTRA, messageRecord.getId());
|
2015-08-15 12:00:08 +00:00
|
|
|
intent.putExtra(MessageDetailsActivity.THREAD_ID_EXTRA, messageRecord.getThreadId());
|
2015-01-15 21:35:35 +00:00
|
|
|
intent.putExtra(MessageDetailsActivity.TYPE_EXTRA, messageRecord.isMms() ? MmsSmsDatabase.MMS_TRANSPORT : MmsSmsDatabase.SMS_TRANSPORT);
|
2015-09-22 00:41:27 +00:00
|
|
|
intent.putExtra(MessageDetailsActivity.IS_PUSH_GROUP_EXTRA, groupThread && messageRecord.isPush());
|
2015-11-05 16:47:29 +00:00
|
|
|
intent.putExtra(MessageDetailsActivity.RECIPIENTS_IDS_EXTRA, conversationRecipients.getIds());
|
2015-01-15 21:35:35 +00:00
|
|
|
context.startActivity(intent);
|
2015-05-26 20:12:11 +00:00
|
|
|
} else if (!messageRecord.isOutgoing() && messageRecord.isIdentityMismatchFailure()) {
|
|
|
|
handleApproveIdentity();
|
2015-03-11 21:23:45 +00:00
|
|
|
} else if (messageRecord.isPendingInsecureSmsFallback()) {
|
2014-03-01 22:17:55 +00:00
|
|
|
handleMessageApproval();
|
2015-01-15 21:35:35 +00:00
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
|
|
|
|
2014-03-01 22:17:55 +00:00
|
|
|
private void handleMessageApproval() {
|
2014-04-01 01:47:24 +00:00
|
|
|
final int title;
|
|
|
|
final int message;
|
2014-06-14 00:39:29 +00:00
|
|
|
|
2015-03-11 21:23:45 +00:00
|
|
|
if (messageRecord.isMms()) title = R.string.ConversationItem_click_to_approve_unencrypted_mms_dialog_title;
|
|
|
|
else title = R.string.ConversationItem_click_to_approve_unencrypted_sms_dialog_title;
|
2014-06-14 00:39:29 +00:00
|
|
|
|
2015-03-11 21:23:45 +00:00
|
|
|
message = R.string.ConversationItem_click_to_approve_unencrypted_dialog_message;
|
2014-04-01 01:47:24 +00:00
|
|
|
|
2015-05-20 21:36:30 +00:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
2014-04-01 01:47:24 +00:00
|
|
|
builder.setTitle(title);
|
2014-06-14 00:39:29 +00:00
|
|
|
|
2014-04-01 01:47:24 +00:00
|
|
|
if (message > -1) builder.setMessage(message);
|
2014-06-14 00:39:29 +00:00
|
|
|
|
2014-03-01 22:17:55 +00:00
|
|
|
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
if (messageRecord.isMms()) {
|
|
|
|
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
2015-03-11 21:23:45 +00:00
|
|
|
database.markAsInsecure(messageRecord.getId());
|
2014-03-01 22:17:55 +00:00
|
|
|
database.markAsOutbox(messageRecord.getId());
|
|
|
|
database.markAsForcedSms(messageRecord.getId());
|
2014-11-08 19:35:58 +00:00
|
|
|
|
|
|
|
ApplicationContext.getInstance(context)
|
|
|
|
.getJobManager()
|
|
|
|
.add(new MmsSendJob(context, messageRecord.getId()));
|
2014-03-01 22:17:55 +00:00
|
|
|
} else {
|
|
|
|
SmsDatabase database = DatabaseFactory.getSmsDatabase(context);
|
2015-03-11 21:23:45 +00:00
|
|
|
database.markAsInsecure(messageRecord.getId());
|
2014-03-01 22:17:55 +00:00
|
|
|
database.markAsOutbox(messageRecord.getId());
|
|
|
|
database.markAsForcedSms(messageRecord.getId());
|
2014-06-14 00:39:29 +00:00
|
|
|
|
2014-11-08 19:35:58 +00:00
|
|
|
ApplicationContext.getInstance(context)
|
|
|
|
.getJobManager()
|
|
|
|
.add(new SmsSendJob(context, messageRecord.getId(),
|
|
|
|
messageRecord.getIndividualRecipient().getNumber()));
|
|
|
|
}
|
2014-03-01 22:17:55 +00:00
|
|
|
}
|
|
|
|
});
|
2014-06-14 00:39:29 +00:00
|
|
|
|
2014-03-01 22:17:55 +00:00
|
|
|
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
2014-04-01 01:47:24 +00:00
|
|
|
if (messageRecord.isMms()) {
|
|
|
|
DatabaseFactory.getMmsDatabase(context).markAsSentFailed(messageRecord.getId());
|
|
|
|
} else {
|
|
|
|
DatabaseFactory.getSmsDatabase(context).markAsSentFailed(messageRecord.getId());
|
|
|
|
}
|
2014-03-01 22:17:55 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
}
|
2015-06-29 15:49:32 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|