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;
|
|
|
|
import android.os.Build;
|
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-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;
|
2015-06-29 15:49:32 +00:00
|
|
|
import android.view.LayoutInflater;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.view.View;
|
2015-06-29 15:49:32 +00:00
|
|
|
import android.view.ViewGroup;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.widget.Button;
|
|
|
|
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
|
|
|
|
2015-03-24 12:44:22 +00:00
|
|
|
import com.afollestad.materialdialogs.AlertDialogWrapper;
|
|
|
|
|
2015-05-04 18:36:18 +00:00
|
|
|
import org.thoughtcrime.securesms.components.AvatarImageView;
|
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;
|
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;
|
2015-10-13 01:25:05 +00:00
|
|
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
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;
|
|
|
|
import org.thoughtcrime.securesms.database.model.NotificationMmsMessageRecord;
|
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;
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
2014-02-20 05:06:54 +00:00
|
|
|
import org.thoughtcrime.securesms.util.DateUtils;
|
2015-09-17 00:31:24 +00:00
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
2012-07-20 02:23:49 +00:00
|
|
|
|
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
|
|
|
|
implements Recipient.RecipientModifiedListener, BindableConversationItem
|
|
|
|
{
|
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
|
|
|
|
2015-01-30 06:37:01 +00:00
|
|
|
private View bodyBubble;
|
|
|
|
private TextView bodyText;
|
|
|
|
private TextView dateText;
|
|
|
|
private TextView indicatorText;
|
|
|
|
private TextView groupStatusText;
|
|
|
|
private ImageView secureImage;
|
2015-05-04 18:36:18 +00:00
|
|
|
private AvatarImageView contactPhoto;
|
2015-06-29 15:49:32 +00:00
|
|
|
private ImageView failedIndicator;
|
|
|
|
private ImageView deliveredIndicator;
|
|
|
|
private ImageView sentIndicator;
|
|
|
|
private View pendingIndicator;
|
|
|
|
private ImageView pendingApprovalIndicator;
|
2015-01-30 06:37:01 +00:00
|
|
|
|
2015-09-15 22:28:27 +00:00
|
|
|
private StatusManager statusManager;
|
|
|
|
private Set<MessageRecord> batchSelected;
|
|
|
|
private ThumbnailView mediaThumbnail;
|
|
|
|
private Button mmsDownloadButton;
|
|
|
|
private TextView mmsDownloadingLabel;
|
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
|
|
|
|
2014-12-14 02:10:59 +00:00
|
|
|
private final MmsDownloadClickListener mmsDownloadClickListener = new MmsDownloadClickListener();
|
2013-09-16 07:55:01 +00:00
|
|
|
private final MmsPreferencesClickListener mmsPreferencesClickListener = new MmsPreferencesClickListener();
|
2015-01-30 06:37:01 +00:00
|
|
|
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 23:03:02 +00:00
|
|
|
ViewGroup pendingIndicatorStub = (ViewGroup) findViewById(R.id.pending_indicator_stub);
|
2015-06-29 15:49:32 +00:00
|
|
|
|
2015-06-29 23:03:02 +00:00
|
|
|
if (pendingIndicatorStub != null) {
|
2015-09-15 22:28:27 +00:00
|
|
|
LayoutInflater inflater = LayoutInflater.from(context);
|
2015-06-29 23:03:02 +00:00
|
|
|
if (Build.VERSION.SDK_INT >= 11) inflater.inflate(R.layout.conversation_item_pending_v11, pendingIndicatorStub, true);
|
|
|
|
else inflater.inflate(R.layout.conversation_item_pending, pendingIndicatorStub, true);
|
|
|
|
}
|
2015-06-29 15:49:32 +00:00
|
|
|
|
|
|
|
this.bodyText = (TextView) findViewById(R.id.conversation_item_body);
|
|
|
|
this.dateText = (TextView) findViewById(R.id.conversation_item_date);
|
|
|
|
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.failedIndicator = (ImageView) findViewById(R.id.sms_failed_indicator);
|
|
|
|
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.deliveredIndicator = (ImageView) findViewById(R.id.delivered_indicator);
|
|
|
|
this.sentIndicator = (ImageView) findViewById(R.id.sent_indicator);
|
|
|
|
this.bodyBubble = findViewById(R.id.body_bubble);
|
|
|
|
this.pendingApprovalIndicator = (ImageView) findViewById(R.id.pending_approval_indicator);
|
|
|
|
this.pendingIndicator = findViewById(R.id.pending_indicator);
|
|
|
|
this.mediaThumbnail = (ThumbnailView) findViewById(R.id.image_view);
|
|
|
|
this.statusManager = new StatusManager(pendingIndicator, sentIndicator, deliveredIndicator, failedIndicator, pendingApprovalIndicator);
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2015-09-24 00:19:24 +00:00
|
|
|
setOnClickListener(new ClickListener(null));
|
2015-09-15 22:28:27 +00:00
|
|
|
PassthroughClickListener passthroughClickListener = new PassthroughClickListener();
|
2014-02-17 01:44:51 +00:00
|
|
|
if (mmsDownloadButton != null) mmsDownloadButton.setOnClickListener(mmsDownloadClickListener);
|
2015-09-15 22:28:27 +00:00
|
|
|
mediaThumbnail.setThumbnailClickListener(new ThumbnailClickListener());
|
|
|
|
mediaThumbnail.setDownloadClickListener(new ThumbnailDownloadClickListener());
|
|
|
|
mediaThumbnail.setOnLongClickListener(passthroughClickListener);
|
2015-09-24 23:46:57 +00:00
|
|
|
mediaThumbnail.setOnClickListener(passthroughClickListener);
|
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-09-22 00:41:27 +00:00
|
|
|
boolean groupThread)
|
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;
|
|
|
|
this.groupThread = groupThread;
|
2015-07-23 00:47:38 +00:00
|
|
|
this.recipient = messageRecord.getIndividualRecipient();
|
|
|
|
|
|
|
|
this.recipient.addListener(this);
|
2014-12-14 02:10:59 +00:00
|
|
|
|
2015-09-24 00:19:24 +00:00
|
|
|
setInteractionState(messageRecord);
|
2012-10-28 23:04:24 +00:00
|
|
|
setBodyText(messageRecord);
|
2015-09-17 00:31:24 +00:00
|
|
|
setBubbleState(messageRecord, recipient);
|
|
|
|
setStatusIcons(messageRecord);
|
|
|
|
setContactPhoto(recipient);
|
|
|
|
setGroupMessageStatus(messageRecord, recipient);
|
|
|
|
setMinimumWidth();
|
|
|
|
setMediaAttributes(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);
|
|
|
|
}
|
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);
|
2015-07-15 20:42:59 +00:00
|
|
|
mediaThumbnail.setBackgroundColorHint(defaultBubbleColor);
|
2015-06-29 22:33:36 +00:00
|
|
|
} else {
|
2015-07-15 20:42:59 +00:00
|
|
|
int color = recipient.getColor().toConversationColor(context);
|
|
|
|
bodyBubble.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
|
|
|
|
mediaThumbnail.setBackgroundColorHint(color);
|
2015-06-29 22:33:36 +00:00
|
|
|
}
|
2015-05-18 15:38:48 +00:00
|
|
|
}
|
2014-02-26 08:30:29 +00:00
|
|
|
|
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));
|
2015-09-24 23:46:57 +00:00
|
|
|
mediaThumbnail.setFocusable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
|
|
|
|
mediaThumbnail.setClickable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
|
2015-09-15 22:28:27 +00:00
|
|
|
mediaThumbnail.setLongClickable(batchSelected.isEmpty());
|
|
|
|
bodyText.setAutoLinkMask(batchSelected.isEmpty() ? Linkify.ALL : 0);
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean hasMedia(MessageRecord messageRecord) {
|
2015-03-15 00:53:07 +00:00
|
|
|
return messageRecord.isMms() &&
|
|
|
|
!messageRecord.isMmsNotification() &&
|
2015-10-21 22:32:19 +00:00
|
|
|
((MediaMmsMessageRecord)messageRecord).getSlideDeck().getThumbnailSlide() != null;
|
2015-01-30 06:37:01 +00:00
|
|
|
}
|
|
|
|
|
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);
|
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) {
|
|
|
|
if (messageRecord.isMmsNotification()) {
|
2015-06-29 15:49:32 +00:00
|
|
|
mediaThumbnail.setVisibility(View.GONE);
|
|
|
|
bodyText.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
2015-01-30 06:37:01 +00:00
|
|
|
setNotificationMmsAttributes((NotificationMmsMessageRecord) messageRecord);
|
2015-06-29 15:49:32 +00:00
|
|
|
} else if (hasMedia(messageRecord)) {
|
|
|
|
mediaThumbnail.setVisibility(View.VISIBLE);
|
2015-10-21 22:32:19 +00:00
|
|
|
//noinspection ConstantConditions
|
2015-10-13 01:25:05 +00:00
|
|
|
mediaThumbnail.setImageResource(masterSecret,
|
2015-10-21 22:32:19 +00:00
|
|
|
((MediaMmsMessageRecord)messageRecord).getSlideDeck().getThumbnailSlide(),
|
2015-10-13 01:25:05 +00:00
|
|
|
!messageRecord.isFailed() && (!messageRecord.isOutgoing() || messageRecord.isPending()),
|
|
|
|
false);
|
2015-06-29 15:49:32 +00:00
|
|
|
bodyText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
|
|
|
} else {
|
|
|
|
mediaThumbnail.setVisibility(View.GONE);
|
|
|
|
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) {
|
|
|
|
mmsDownloadButton.setVisibility(View.GONE);
|
|
|
|
mmsDownloadingLabel.setVisibility(View.GONE);
|
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-01-15 21:35:35 +00:00
|
|
|
|
|
|
|
final long timestamp;
|
2015-06-29 15:49:32 +00:00
|
|
|
|
2015-01-15 21:35:35 +00:00
|
|
|
if (messageRecord.isPush()) timestamp = messageRecord.getDateSent();
|
|
|
|
else timestamp = messageRecord.getDateReceived();
|
2014-01-08 22:29:05 +00:00
|
|
|
|
2015-03-19 20:08:48 +00:00
|
|
|
dateText.setText(DateUtils.getExtendedRelativeTimeSpanString(getContext(), locale, timestamp));
|
2015-06-29 15:49:32 +00:00
|
|
|
|
|
|
|
if (messageRecord.isFailed()) setFailedStatusIcons();
|
|
|
|
else if (messageRecord.isPendingInsecureSmsFallback()) setFallbackStatusIcons();
|
|
|
|
else if (messageRecord.isPending()) statusManager.displayPending();
|
|
|
|
else if (messageRecord.isDelivered()) statusManager.displayDelivered();
|
|
|
|
else statusManager.displaySent();
|
2015-01-15 21:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void setFailedStatusIcons() {
|
2015-06-29 15:49:32 +00:00
|
|
|
statusManager.displayFailed();
|
2015-01-15 21:35:35 +00:00
|
|
|
dateText.setText(R.string.ConversationItem_error_not_delivered);
|
2015-03-27 17:37:59 +00:00
|
|
|
if (indicatorText != null) {
|
|
|
|
indicatorText.setText(R.string.ConversationItem_click_for_details);
|
|
|
|
indicatorText.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2015-01-15 21:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void setFallbackStatusIcons() {
|
2015-06-29 15:49:32 +00:00
|
|
|
statusManager.displayPendingApproval();
|
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() {
|
|
|
|
if (indicatorText != null && 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
|
|
|
private void setNotificationMmsAttributes(NotificationMmsMessageRecord messageRecord) {
|
2014-02-19 06:08:24 +00:00
|
|
|
String messageSize = String.format(context.getString(R.string.ConversationItem_message_size_d_kb),
|
2012-09-08 03:03:23 +00:00
|
|
|
messageRecord.getMessageSize());
|
2014-02-19 06:08:24 +00:00
|
|
|
String expires = String.format(context.getString(R.string.ConversationItem_expires_s),
|
2012-09-08 03:03:23 +00:00
|
|
|
DateUtils.getRelativeTimeSpanString(getContext(),
|
|
|
|
messageRecord.getExpiration(),
|
|
|
|
false));
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
dateText.setText(messageSize + "\n" + expires);
|
2012-07-20 02:23:49 +00:00
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
if (MmsDatabase.Status.isDisplayDownloadButton(messageRecord.getStatus())) {
|
2011-12-20 18:20:44 +00:00
|
|
|
mmsDownloadButton.setVisibility(View.VISIBLE);
|
|
|
|
mmsDownloadingLabel.setVisibility(View.GONE);
|
|
|
|
} else {
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
mmsDownloadingLabel.setText(MmsDatabase.Status.getLabelForStatus(context, messageRecord.getStatus()));
|
2011-12-20 18:20:44 +00:00
|
|
|
mmsDownloadButton.setVisibility(View.GONE);
|
|
|
|
mmsDownloadingLabel.setVisibility(View.VISIBLE);
|
2013-09-16 07:55:01 +00:00
|
|
|
|
|
|
|
if (MmsDatabase.Status.isHardError(messageRecord.getStatus()) && !messageRecord.isOutgoing())
|
|
|
|
setOnClickListener(mmsDownloadClickListener);
|
|
|
|
else if (MmsDatabase.Status.DOWNLOAD_APN_UNAVAILABLE == messageRecord.getStatus() && !messageRecord.isOutgoing())
|
|
|
|
setOnClickListener(mmsPreferencesClickListener);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-20 02:23:49 +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-08-24 22:24:31 +00:00
|
|
|
private class ThumbnailDownloadClickListener implements ThumbnailView.ThumbnailClickListener {
|
2015-09-15 22:28:27 +00:00
|
|
|
@Override public void onClick(View v, final Slide slide) {
|
2015-10-13 01:25:05 +00:00
|
|
|
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-03-31 22:44:41 +00:00
|
|
|
private class ThumbnailClickListener implements ThumbnailView.ThumbnailClickListener {
|
|
|
|
private void fireIntent(Slide slide) {
|
2014-03-28 02:46:27 +00:00
|
|
|
Log.w(TAG, "Clicked: " + slide.getUri() + " , " + slide.getContentType());
|
2011-12-20 18:20:44 +00:00
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
|
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
2015-10-13 01:25:05 +00:00
|
|
|
intent.setDataAndType(PartAuthority.getAttachmentPublicUri(slide.getUri()), slide.getContentType());
|
2014-10-16 05:26:55 +00:00
|
|
|
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();
|
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
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();
|
|
|
|
} else if (MediaPreviewActivity.isContentTypeSupported(slide.getContentType()) &&
|
|
|
|
slide.getThumbnailUri() != null)
|
2015-06-12 19:02:41 +00:00
|
|
|
{
|
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());
|
2014-08-12 19:11:23 +00:00
|
|
|
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, messageRecord.getDateReceived());
|
2015-01-30 06:37:01 +00:00
|
|
|
|
2015-03-13 18:23:01 +00:00
|
|
|
context.startActivity(intent);
|
2015-06-16 15:18:35 +00:00
|
|
|
} else {
|
2015-03-24 12:44:22 +00:00
|
|
|
AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(context);
|
2014-08-12 19:11:23 +00:00
|
|
|
builder.setTitle(R.string.ConversationItem_view_secure_media_question);
|
2015-03-24 12:44:22 +00:00
|
|
|
builder.setIconAttribute(R.attr.dialog_alert_icon);
|
2014-08-12 19:11:23 +00:00
|
|
|
builder.setCancelable(true);
|
|
|
|
builder.setMessage(R.string.ConversationItem_this_media_has_been_stored_in_an_encrypted_database_external_viewer_warning);
|
|
|
|
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2015-03-31 22:44:41 +00:00
|
|
|
fireIntent(slide);
|
2014-08-12 19:11:23 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.no, null);
|
|
|
|
builder.show();
|
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
private class MmsDownloadClickListener implements View.OnClickListener {
|
|
|
|
public void onClick(View v) {
|
2012-10-28 23:04:24 +00:00
|
|
|
NotificationMmsMessageRecord notificationRecord = (NotificationMmsMessageRecord)messageRecord;
|
2015-01-15 21:35:35 +00:00
|
|
|
Log.w(TAG, "Content location: " + new String(notificationRecord.getContentLocation()));
|
2011-12-20 18:20:44 +00:00
|
|
|
mmsDownloadButton.setVisibility(View.GONE);
|
|
|
|
mmsDownloadingLabel.setVisibility(View.VISIBLE);
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2014-11-03 23:16:04 +00:00
|
|
|
ApplicationContext.getInstance(context)
|
|
|
|
.getJobManager()
|
|
|
|
.add(new MmsDownloadJob(context, messageRecord.getId(),
|
|
|
|
messageRecord.getThreadId(), false));
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2013-09-16 07:55:01 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
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());
|
|
|
|
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-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-03-24 12:44:22 +00:00
|
|
|
AlertDialogWrapper.Builder builder = new AlertDialogWrapper.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
|
|
|
|
|
|
|
private static class StatusManager {
|
|
|
|
|
|
|
|
private final View pendingIndicator;
|
|
|
|
private final View sentIndicator;
|
|
|
|
private final View deliveredIndicator;
|
|
|
|
|
|
|
|
private final View failedIndicator;
|
|
|
|
private final View approvalIndicator;
|
|
|
|
|
|
|
|
|
|
|
|
public StatusManager(View pendingIndicator, View sentIndicator,
|
|
|
|
View deliveredIndicator, View failedIndicator,
|
|
|
|
View approvalIndicator)
|
|
|
|
{
|
|
|
|
this.pendingIndicator = pendingIndicator;
|
|
|
|
this.sentIndicator = sentIndicator;
|
|
|
|
this.deliveredIndicator = deliveredIndicator;
|
|
|
|
this.failedIndicator = failedIndicator;
|
|
|
|
this.approvalIndicator = approvalIndicator;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void displayFailed() {
|
|
|
|
pendingIndicator.setVisibility(View.GONE);
|
|
|
|
sentIndicator.setVisibility(View.GONE);
|
|
|
|
deliveredIndicator.setVisibility(View.GONE);
|
|
|
|
approvalIndicator.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
failedIndicator.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void displayPendingApproval() {
|
|
|
|
pendingIndicator.setVisibility(View.GONE);
|
|
|
|
sentIndicator.setVisibility(View.GONE);
|
|
|
|
deliveredIndicator.setVisibility(View.GONE);
|
|
|
|
failedIndicator.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
approvalIndicator.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void displayPending() {
|
|
|
|
sentIndicator.setVisibility(View.GONE);
|
|
|
|
deliveredIndicator.setVisibility(View.GONE);
|
|
|
|
failedIndicator.setVisibility(View.GONE);
|
|
|
|
approvalIndicator.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
pendingIndicator.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void displaySent() {
|
|
|
|
pendingIndicator.setVisibility(View.GONE);
|
|
|
|
deliveredIndicator.setVisibility(View.GONE);
|
|
|
|
failedIndicator.setVisibility(View.GONE);
|
|
|
|
approvalIndicator.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
sentIndicator.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void displayDelivered() {
|
|
|
|
pendingIndicator.setVisibility(View.GONE);
|
|
|
|
failedIndicator.setVisibility(View.GONE);
|
|
|
|
approvalIndicator.setVisibility(View.GONE);
|
|
|
|
sentIndicator.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
deliveredIndicator.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|