2012-07-19 14:22:03 -07:00
|
|
|
/**
|
|
|
|
* Copyright (C) 2011 Whisper Systems
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
|
2013-06-18 14:43:27 -07:00
|
|
|
import android.content.ActivityNotFoundException;
|
2013-03-05 19:32:15 -08:00
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.AsyncTask;
|
|
|
|
import android.os.Bundle;
|
2013-10-17 02:28:36 +02:00
|
|
|
import android.provider.ContactsContract;
|
2014-12-15 12:25:55 -08:00
|
|
|
import android.support.annotation.NonNull;
|
2013-03-05 19:32:15 -08:00
|
|
|
import android.telephony.PhoneNumberUtils;
|
|
|
|
import android.text.Editable;
|
2013-06-29 15:34:43 -07:00
|
|
|
import android.text.InputType;
|
2014-02-17 21:42:30 -08:00
|
|
|
import android.text.TextUtils;
|
2013-03-05 19:32:15 -08:00
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.KeyEvent;
|
2014-06-28 20:40:57 -07:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
import android.view.MenuItem;
|
2013-03-05 19:32:15 -08:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.View.OnClickListener;
|
2014-05-28 20:53:34 -07:00
|
|
|
import android.view.View.OnFocusChangeListener;
|
2013-03-05 19:32:15 -08:00
|
|
|
import android.view.View.OnKeyListener;
|
2015-05-29 10:54:59 -07:00
|
|
|
import android.view.ViewStub;
|
2013-03-05 19:32:15 -08:00
|
|
|
import android.view.inputmethod.EditorInfo;
|
2013-06-27 20:57:27 -07:00
|
|
|
import android.view.inputmethod.InputMethodManager;
|
2015-05-18 10:26:32 -07:00
|
|
|
import android.widget.ImageButton;
|
2013-03-05 19:32:15 -08:00
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2015-03-24 13:44:22 +01:00
|
|
|
import com.afollestad.materialdialogs.AlertDialogWrapper;
|
2014-02-22 10:54:43 -08:00
|
|
|
import com.google.protobuf.ByteString;
|
2013-11-25 17:00:20 -08:00
|
|
|
|
2015-02-16 02:38:09 -08:00
|
|
|
import org.thoughtcrime.securesms.TransportOptions.OnTransportChangedListener;
|
2015-05-18 10:26:32 -07:00
|
|
|
import org.thoughtcrime.securesms.components.AnimatingToggle;
|
2015-03-11 14:23:45 -07:00
|
|
|
import org.thoughtcrime.securesms.components.ComposeText;
|
2015-05-06 13:53:55 -07:00
|
|
|
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer;
|
|
|
|
import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
|
2014-07-18 19:31:03 -07:00
|
|
|
import org.thoughtcrime.securesms.components.SendButton;
|
2013-10-17 02:28:36 +02:00
|
|
|
import org.thoughtcrime.securesms.contacts.ContactAccessor;
|
|
|
|
import org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData;
|
2014-11-08 11:35:58 -08:00
|
|
|
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
2014-11-03 15:16:04 -08:00
|
|
|
import org.thoughtcrime.securesms.crypto.SecurityEvent;
|
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 12:22:04 -07:00
|
|
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
|
|
import org.thoughtcrime.securesms.database.DraftDatabase;
|
|
|
|
import org.thoughtcrime.securesms.database.DraftDatabase.Draft;
|
2014-12-11 17:13:01 -08:00
|
|
|
import org.thoughtcrime.securesms.database.DraftDatabase.Drafts;
|
2014-02-22 10:54:43 -08:00
|
|
|
import org.thoughtcrime.securesms.database.GroupDatabase;
|
2014-12-11 17:13:01 -08:00
|
|
|
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
|
2013-04-25 18:59:49 -07:00
|
|
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
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 12:22:04 -07:00
|
|
|
import org.thoughtcrime.securesms.mms.AttachmentManager;
|
|
|
|
import org.thoughtcrime.securesms.mms.AttachmentTypeSelectorAdapter;
|
|
|
|
import org.thoughtcrime.securesms.mms.MediaTooLargeException;
|
2015-01-02 15:43:28 -08:00
|
|
|
import org.thoughtcrime.securesms.mms.MmsMediaConstraints;
|
2014-02-22 10:54:43 -08:00
|
|
|
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
|
2014-02-24 00:19:54 -08:00
|
|
|
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
|
|
|
import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage;
|
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 12:22:04 -07:00
|
|
|
import org.thoughtcrime.securesms.mms.Slide;
|
|
|
|
import org.thoughtcrime.securesms.mms.SlideDeck;
|
|
|
|
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
2014-02-20 15:41:52 -08:00
|
|
|
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
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 12:22:04 -07:00
|
|
|
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
|
|
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
|
|
|
import org.thoughtcrime.securesms.sms.MessageSender;
|
|
|
|
import org.thoughtcrime.securesms.sms.OutgoingEncryptedMessage;
|
2014-02-19 13:46:49 -08:00
|
|
|
import org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage;
|
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 12:22:04 -07:00
|
|
|
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
2013-05-21 10:32:48 -07:00
|
|
|
import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
2015-02-16 02:38:09 -08:00
|
|
|
import org.thoughtcrime.securesms.util.CharacterCalculator.CharacterState;
|
2014-03-01 01:32:00 +01:00
|
|
|
import org.thoughtcrime.securesms.util.Dialogs;
|
2014-03-26 14:49:40 -07:00
|
|
|
import org.thoughtcrime.securesms.util.DirectoryHelper;
|
2013-06-29 18:03:55 -07:00
|
|
|
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
2013-06-21 11:56:59 -07:00
|
|
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
2014-02-22 10:54:43 -08:00
|
|
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
2013-07-09 18:26:18 -07:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
2014-11-12 11:15:05 -08:00
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
2014-04-21 08:40:19 -07:00
|
|
|
import org.whispersystems.libaxolotl.InvalidMessageException;
|
2015-03-09 15:13:13 -07:00
|
|
|
import org.whispersystems.libaxolotl.util.guava.Optional;
|
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 12:22:04 -07:00
|
|
|
|
|
|
|
import java.io.IOException;
|
2014-12-12 18:31:20 -08:00
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
import java.security.SecureRandom;
|
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 12:22:04 -07:00
|
|
|
import java.util.List;
|
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
import static org.thoughtcrime.securesms.TransportOption.Type;
|
2014-02-22 10:54:43 -08:00
|
|
|
import static org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
2014-02-24 00:19:54 -08:00
|
|
|
import static org.thoughtcrime.securesms.recipients.Recipient.RecipientModifiedListener;
|
2014-11-12 11:35:54 -08:00
|
|
|
import static org.whispersystems.textsecure.internal.push.PushMessageProtos.PushMessageContent.GroupContext;
|
2014-02-22 10:54:43 -08:00
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
/**
|
|
|
|
* Activity for displaying a message thread, as well as
|
|
|
|
* composing/sending a new message into that thread.
|
|
|
|
*
|
|
|
|
* @author Moxie Marlinspike
|
|
|
|
*
|
|
|
|
*/
|
2014-06-28 20:40:57 -07:00
|
|
|
public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
2014-04-15 12:43:14 +02:00
|
|
|
implements ConversationFragment.ConversationFragmentListener,
|
2015-02-10 03:15:50 -08:00
|
|
|
AttachmentManager.AttachmentListener,
|
|
|
|
RecipientModifiedListener
|
2013-04-25 18:59:49 -07:00
|
|
|
{
|
2014-02-18 16:28:54 -08:00
|
|
|
private static final String TAG = ConversationActivity.class.getSimpleName();
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2013-04-25 18:59:49 -07:00
|
|
|
public static final String RECIPIENTS_EXTRA = "recipients";
|
|
|
|
public static final String THREAD_ID_EXTRA = "thread_id";
|
|
|
|
public static final String DRAFT_TEXT_EXTRA = "draft_text";
|
|
|
|
public static final String DRAFT_IMAGE_EXTRA = "draft_image";
|
|
|
|
public static final String DRAFT_AUDIO_EXTRA = "draft_audio";
|
2014-03-03 11:55:34 -05:00
|
|
|
public static final String DRAFT_VIDEO_EXTRA = "draft_video";
|
2013-04-25 18:59:49 -07:00
|
|
|
public static final String DISTRIBUTION_TYPE_EXTRA = "distribution_type";
|
2013-02-02 20:37:40 -08:00
|
|
|
|
2014-02-27 22:44:02 -08:00
|
|
|
private static final int PICK_IMAGE = 1;
|
|
|
|
private static final int PICK_VIDEO = 2;
|
|
|
|
private static final int PICK_AUDIO = 3;
|
|
|
|
private static final int PICK_CONTACT_INFO = 4;
|
|
|
|
private static final int GROUP_EDIT = 5;
|
2015-05-18 10:26:32 -07:00
|
|
|
private static final int CAPTURE_PHOTO = 6;
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2014-12-15 12:25:55 -08:00
|
|
|
private MasterSecret masterSecret;
|
|
|
|
private ComposeText composeText;
|
2015-05-18 10:26:32 -07:00
|
|
|
private AnimatingToggle buttonToggle;
|
2014-12-15 12:25:55 -08:00
|
|
|
private SendButton sendButton;
|
2015-05-18 10:26:32 -07:00
|
|
|
private ImageButton attachButton;
|
2014-12-15 12:25:55 -08:00
|
|
|
private TextView charactersLeft;
|
|
|
|
private ConversationFragment fragment;
|
2012-07-19 14:22:03 -07:00
|
|
|
|
|
|
|
private AttachmentTypeSelectorAdapter attachmentAdapter;
|
2014-02-17 20:25:40 -08:00
|
|
|
private AttachmentManager attachmentManager;
|
|
|
|
private BroadcastReceiver securityUpdateReceiver;
|
2014-02-24 00:19:54 -08:00
|
|
|
private BroadcastReceiver groupUpdateReceiver;
|
2015-05-29 10:54:59 -07:00
|
|
|
private Optional<EmojiDrawer> emojiDrawer = Optional.absent();
|
2014-02-17 20:25:40 -08:00
|
|
|
private EmojiToggle emojiToggle;
|
2012-07-19 14:22:03 -07:00
|
|
|
|
|
|
|
private Recipients recipients;
|
2014-02-17 20:25:40 -08:00
|
|
|
private long threadId;
|
|
|
|
private int distributionType;
|
|
|
|
private boolean isEncryptedConversation;
|
|
|
|
private boolean isMmsEnabled = true;
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
private DynamicTheme dynamicTheme = new DynamicTheme();
|
|
|
|
private DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
2012-07-19 14:22:03 -07:00
|
|
|
|
|
|
|
@Override
|
2014-12-15 12:25:55 -08:00
|
|
|
protected void onPreCreate() {
|
2013-06-21 11:56:59 -07:00
|
|
|
dynamicTheme.onCreate(this);
|
2013-06-29 18:03:55 -07:00
|
|
|
dynamicLanguage.onCreate(this);
|
2014-12-15 12:25:55 -08:00
|
|
|
overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle state, @NonNull MasterSecret masterSecret) {
|
|
|
|
this.masterSecret = masterSecret;
|
2012-07-19 14:22:03 -07:00
|
|
|
|
|
|
|
setContentView(R.layout.conversation_activity);
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
2015-03-19 13:08:48 -07:00
|
|
|
fragment = initFragment(R.id.fragment_content, new ConversationFragment(), masterSecret, dynamicLanguage.getCurrentLocale());
|
2012-07-19 14:22:03 -07:00
|
|
|
|
|
|
|
initializeReceivers();
|
2014-12-24 18:32:51 -08:00
|
|
|
initializeViews();
|
2012-07-19 14:22:03 -07:00
|
|
|
initializeResources();
|
2014-12-24 18:32:51 -08:00
|
|
|
initializeDraft();
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
2013-02-03 18:41:34 -08:00
|
|
|
@Override
|
2014-12-24 18:32:51 -08:00
|
|
|
protected void onNewIntent(Intent intent) {
|
2014-12-15 12:25:55 -08:00
|
|
|
Log.w(TAG, "onNewIntent()");
|
|
|
|
|
2014-12-24 18:32:51 -08:00
|
|
|
if (!Util.isEmpty(composeText) || attachmentManager.isAttachmentPresent()) {
|
|
|
|
saveDraft();
|
|
|
|
attachmentManager.clear();
|
|
|
|
composeText.setText("");
|
|
|
|
}
|
|
|
|
|
|
|
|
setIntent(intent);
|
|
|
|
initializeResources();
|
2014-10-08 21:11:02 +03:00
|
|
|
initializeDraft();
|
|
|
|
|
2014-12-24 18:32:51 -08:00
|
|
|
if (fragment != null) {
|
|
|
|
fragment.onNewIntent();
|
|
|
|
}
|
2013-02-03 18:41:34 -08:00
|
|
|
}
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
super.onResume();
|
2013-06-21 11:56:59 -07:00
|
|
|
dynamicTheme.onResume(this);
|
2013-06-29 18:03:55 -07:00
|
|
|
dynamicLanguage.onResume(this);
|
2013-06-21 11:56:59 -07:00
|
|
|
|
2012-08-01 17:39:36 -07:00
|
|
|
initializeSecurity();
|
2012-07-19 14:22:03 -07:00
|
|
|
initializeTitleBar();
|
2014-02-22 10:54:43 -08:00
|
|
|
initializeEnabledCheck();
|
2013-03-04 17:43:04 -08:00
|
|
|
initializeMmsEnabledCheck();
|
2013-06-29 15:34:43 -07:00
|
|
|
initializeIme();
|
2012-07-19 14:22:03 -07:00
|
|
|
calculateCharactersRemaining();
|
2013-02-03 18:41:34 -08:00
|
|
|
|
|
|
|
MessageNotifier.setVisibleThread(threadId);
|
|
|
|
markThreadAsRead();
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-03-04 17:43:04 -08:00
|
|
|
protected void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
MessageNotifier.setVisibleThread(-1L);
|
2014-04-08 10:45:55 -07:00
|
|
|
if (isFinishing()) overridePendingTransition(R.anim.fade_scale_in, R.anim.slide_to_right);
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDestroy() {
|
2014-12-24 18:32:51 -08:00
|
|
|
saveDraft();
|
2014-12-15 12:25:55 -08:00
|
|
|
if (recipients != null) recipients.removeListener(this);
|
|
|
|
if (securityUpdateReceiver != null) unregisterReceiver(securityUpdateReceiver);
|
|
|
|
if (groupUpdateReceiver != null) unregisterReceiver(groupUpdateReceiver);
|
2012-07-19 14:22:03 -07:00
|
|
|
super.onDestroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onActivityResult(int reqCode, int resultCode, Intent data) {
|
2014-02-23 21:18:08 -08:00
|
|
|
Log.w(TAG, "onActivityResult called: " + reqCode + ", " + resultCode + " , " + data);
|
2012-07-19 14:22:03 -07:00
|
|
|
super.onActivityResult(reqCode, resultCode, data);
|
|
|
|
|
2015-05-18 10:26:32 -07:00
|
|
|
if ((data == null && reqCode != CAPTURE_PHOTO) || resultCode != RESULT_OK) return;
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
switch (reqCode) {
|
|
|
|
case PICK_IMAGE:
|
2014-02-17 15:47:58 -08:00
|
|
|
addAttachmentImage(data.getData());
|
2012-07-19 14:22:03 -07:00
|
|
|
break;
|
|
|
|
case PICK_VIDEO:
|
2014-02-17 15:47:58 -08:00
|
|
|
addAttachmentVideo(data.getData());
|
2012-07-19 14:22:03 -07:00
|
|
|
break;
|
|
|
|
case PICK_AUDIO:
|
2014-02-17 15:47:58 -08:00
|
|
|
addAttachmentAudio(data.getData());
|
2012-07-19 14:22:03 -07:00
|
|
|
break;
|
2013-10-17 02:28:36 +02:00
|
|
|
case PICK_CONTACT_INFO:
|
2014-06-04 01:24:44 +02:00
|
|
|
addAttachmentContactInfo(data.getData());
|
2013-10-17 02:28:36 +02:00
|
|
|
break;
|
2015-05-18 10:26:32 -07:00
|
|
|
case CAPTURE_PHOTO:
|
|
|
|
if (attachmentManager.getCaptureFile() != null) {
|
|
|
|
addAttachmentImage(Uri.fromFile(attachmentManager.getCaptureFile()));
|
|
|
|
}
|
|
|
|
break;
|
2014-02-20 15:41:52 -08:00
|
|
|
case GROUP_EDIT:
|
2014-12-17 18:14:19 -08:00
|
|
|
this.recipients = RecipientFactory.getRecipientsForIds(this, data.getLongArrayExtra(GroupCreateActivity.GROUP_RECIPIENT_EXTRA), true);
|
2014-02-20 15:41:52 -08:00
|
|
|
initializeTitleBar();
|
|
|
|
break;
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
2014-06-28 20:40:57 -07:00
|
|
|
MenuInflater inflater = this.getMenuInflater();
|
2012-07-19 14:22:03 -07:00
|
|
|
menu.clear();
|
|
|
|
|
2014-02-17 20:25:40 -08:00
|
|
|
if (isSingleConversation() && isEncryptedConversation) {
|
2014-04-09 20:02:46 -07:00
|
|
|
inflater.inflate(R.menu.conversation_secure_identity, menu);
|
2014-02-25 17:38:55 -08:00
|
|
|
inflater.inflate(R.menu.conversation_secure_sms, menu.findItem(R.id.menu_security).getSubMenu());
|
2014-12-12 18:31:20 -08:00
|
|
|
} else if (isSingleConversation()) {
|
2012-07-19 14:22:03 -07:00
|
|
|
inflater.inflate(R.menu.conversation_insecure, menu);
|
|
|
|
}
|
|
|
|
|
2012-08-07 19:03:28 -07:00
|
|
|
if (isSingleConversation()) {
|
|
|
|
inflater.inflate(R.menu.conversation_callable, menu);
|
2012-10-21 14:34:09 -07:00
|
|
|
} else if (isGroupConversation()) {
|
|
|
|
inflater.inflate(R.menu.conversation_group_options, menu);
|
2013-04-25 18:59:49 -07:00
|
|
|
|
2014-02-17 20:25:40 -08:00
|
|
|
if (!isPushGroupConversation()) {
|
|
|
|
inflater.inflate(R.menu.conversation_mms_group_options, menu);
|
|
|
|
if (distributionType == ThreadDatabase.DistributionTypes.BROADCAST) {
|
|
|
|
menu.findItem(R.id.menu_distribution_broadcast).setChecked(true);
|
|
|
|
} else {
|
|
|
|
menu.findItem(R.id.menu_distribution_conversation).setChecked(true);
|
|
|
|
}
|
2014-02-22 10:54:43 -08:00
|
|
|
} else if (isActiveGroup()) {
|
2014-02-20 15:41:52 -08:00
|
|
|
inflater.inflate(R.menu.conversation_push_group_options, menu);
|
2013-04-25 18:59:49 -07:00
|
|
|
}
|
2012-08-07 19:03:28 -07:00
|
|
|
}
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
inflater.inflate(R.menu.conversation, menu);
|
2014-06-04 01:24:44 +02:00
|
|
|
|
|
|
|
if (isSingleConversation() && getRecipients().getPrimaryRecipient().getContactUri() == null) {
|
|
|
|
inflater.inflate(R.menu.conversation_add_to_contacts, menu);
|
|
|
|
}
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
super.onPrepareOptionsMenu(menu);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
super.onOptionsItemSelected(item);
|
|
|
|
switch (item.getItemId()) {
|
2013-04-25 18:59:49 -07:00
|
|
|
case R.id.menu_call: handleDial(getRecipients().getPrimaryRecipient()); return true;
|
|
|
|
case R.id.menu_delete_thread: handleDeleteThread(); return true;
|
|
|
|
case R.id.menu_add_attachment: handleAddAttachment(); return true;
|
2015-01-18 16:11:30 -10:00
|
|
|
case R.id.menu_view_media: handleViewMedia(); return true;
|
2014-06-04 01:24:44 +02:00
|
|
|
case R.id.menu_add_to_contacts: handleAddToContacts(); return true;
|
2013-04-25 18:59:49 -07:00
|
|
|
case R.id.menu_abort_session: handleAbortSecureSession(); return true;
|
2014-03-04 09:55:45 -05:00
|
|
|
case R.id.menu_verify_identity: handleVerifyIdentity(); return true;
|
2013-04-25 18:59:49 -07:00
|
|
|
case R.id.menu_group_recipients: handleDisplayGroupRecipients(); return true;
|
|
|
|
case R.id.menu_distribution_broadcast: handleDistributionBroadcastEnabled(item); return true;
|
|
|
|
case R.id.menu_distribution_conversation: handleDistributionConversationEnabled(item); return true;
|
2014-02-20 15:41:52 -08:00
|
|
|
case R.id.menu_edit_group: handleEditPushGroup(); return true;
|
|
|
|
case R.id.menu_leave: handleLeavePushGroup(); return true;
|
2014-12-12 18:31:20 -08:00
|
|
|
case R.id.menu_invite: handleInviteLink(); return true;
|
2013-04-25 18:59:49 -07:00
|
|
|
case android.R.id.home: handleReturnToConversationList(); return true;
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-27 20:57:27 -07:00
|
|
|
@Override
|
|
|
|
public void onBackPressed() {
|
2015-05-06 13:53:55 -07:00
|
|
|
if (isEmojiDrawerOpen()) {
|
|
|
|
getEmojiDrawer().hide();
|
2013-06-27 20:57:27 -07:00
|
|
|
emojiToggle.toggle();
|
|
|
|
} else {
|
|
|
|
super.onBackPressed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
//////// Event Handlers
|
|
|
|
|
2013-02-17 11:42:30 -08:00
|
|
|
private void handleReturnToConversationList() {
|
|
|
|
Intent intent = new Intent(this, ConversationListActivity.class);
|
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
startActivity(intent);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
2014-12-12 18:31:20 -08:00
|
|
|
private void handleInviteLink() {
|
|
|
|
try {
|
|
|
|
boolean a = SecureRandom.getInstance("SHA1PRNG").nextBoolean();
|
2015-03-25 10:49:12 -07:00
|
|
|
if (a) composeText.appendInvite(getString(R.string.ConversationActivity_get_with_it, "http://sgnl.link/1IvurmD"));
|
2015-03-25 11:18:38 -07:00
|
|
|
else composeText.appendInvite(getString(R.string.ConversationActivity_lets_use_this_to_chat, "http://sgnl.link/1CYCQQN"));
|
2014-12-12 18:31:20 -08:00
|
|
|
} catch (NoSuchAlgorithmException e) {
|
|
|
|
throw new AssertionError(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-04 09:55:45 -05:00
|
|
|
private void handleVerifyIdentity() {
|
2012-07-19 14:22:03 -07:00
|
|
|
Intent verifyIdentityIntent = new Intent(this, VerifyIdentityActivity.class);
|
2014-12-17 18:14:19 -08:00
|
|
|
verifyIdentityIntent.putExtra("recipient", getRecipients().getPrimaryRecipient().getRecipientId());
|
2012-07-19 14:22:03 -07:00
|
|
|
startActivity(verifyIdentityIntent);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleAbortSecureSession() {
|
2015-03-24 13:44:22 +01:00
|
|
|
AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(this);
|
2012-09-19 19:56:04 -07:00
|
|
|
builder.setTitle(R.string.ConversationActivity_abort_secure_session_confirmation);
|
2015-03-24 13:44:22 +01:00
|
|
|
builder.setIconAttribute(R.attr.dialog_alert_icon);
|
2012-07-19 14:22:03 -07:00
|
|
|
builder.setCancelable(true);
|
2012-09-19 19:56:04 -07:00
|
|
|
builder.setMessage(R.string.ConversationActivity_are_you_sure_that_you_want_to_abort_this_secure_session_question);
|
2012-07-19 14:22:03 -07:00
|
|
|
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2012-08-01 17:39:36 -07:00
|
|
|
if (isSingleConversation()) {
|
2014-11-08 11:35:58 -08:00
|
|
|
final Context context = getApplicationContext();
|
2014-04-22 14:33:29 -07:00
|
|
|
|
|
|
|
OutgoingEndSessionMessage endSessionMessage =
|
|
|
|
new OutgoingEndSessionMessage(new OutgoingTextMessage(getRecipients(), "TERMINATE"));
|
|
|
|
|
2014-11-08 11:35:58 -08:00
|
|
|
new AsyncTask<OutgoingEndSessionMessage, Void, Long>() {
|
|
|
|
@Override
|
|
|
|
protected Long doInBackground(OutgoingEndSessionMessage... messages) {
|
|
|
|
return MessageSender.send(context, masterSecret, messages[0], threadId, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPostExecute(Long result) {
|
|
|
|
sendComplete(result);
|
|
|
|
}
|
|
|
|
}.execute(endSessionMessage);
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.no, null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2015-01-18 16:11:30 -10:00
|
|
|
private void handleViewMedia() {
|
|
|
|
Intent intent = new Intent(this, MediaOverviewActivity.class);
|
|
|
|
intent.putExtra(MediaOverviewActivity.THREAD_ID_EXTRA, threadId);
|
|
|
|
intent.putExtra(MediaOverviewActivity.RECIPIENT_EXTRA, recipients.getPrimaryRecipient().getRecipientId());
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
2014-02-22 10:54:43 -08:00
|
|
|
private void handleLeavePushGroup() {
|
|
|
|
if (getRecipients() == null) {
|
|
|
|
Toast.makeText(this, getString(R.string.ConversationActivity_invalid_recipient),
|
|
|
|
Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-24 13:44:22 +01:00
|
|
|
AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(this);
|
2014-02-22 10:54:43 -08:00
|
|
|
builder.setTitle(getString(R.string.ConversationActivity_leave_group));
|
2015-03-24 13:44:22 +01:00
|
|
|
builder.setIconAttribute(R.attr.dialog_info_icon);
|
2014-02-22 10:54:43 -08:00
|
|
|
builder.setCancelable(true);
|
|
|
|
builder.setMessage(getString(R.string.ConversationActivity_are_you_sure_you_want_to_leave_this_group));
|
|
|
|
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2014-12-15 09:44:41 -05:00
|
|
|
Context self = ConversationActivity.this;
|
2014-02-22 10:54:43 -08:00
|
|
|
try {
|
2014-12-29 14:01:02 -08:00
|
|
|
byte[] groupId = GroupUtil.getDecodedId(getRecipients().getPrimaryRecipient().getNumber());
|
2014-02-22 10:54:43 -08:00
|
|
|
DatabaseFactory.getGroupDatabase(self).setActive(groupId, false);
|
|
|
|
|
|
|
|
GroupContext context = GroupContext.newBuilder()
|
|
|
|
.setId(ByteString.copyFrom(groupId))
|
|
|
|
.setType(GroupContext.Type.QUIT)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(self, getRecipients(),
|
|
|
|
context, null);
|
2014-06-11 15:31:59 -07:00
|
|
|
MessageSender.send(self, masterSecret, outgoingMessage, threadId, false);
|
2014-04-11 14:33:55 +02:00
|
|
|
DatabaseFactory.getGroupDatabase(self).remove(groupId, TextSecurePreferences.getLocalNumber(self));
|
2014-02-22 10:54:43 -08:00
|
|
|
initializeEnabledCheck();
|
|
|
|
} catch (IOException e) {
|
|
|
|
Log.w(TAG, e);
|
2014-12-15 09:44:41 -05:00
|
|
|
Toast.makeText(self, R.string.ConversationActivity_error_leaving_group, Toast.LENGTH_LONG).show();
|
2014-02-22 10:54:43 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
builder.setNegativeButton(R.string.no, null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleEditPushGroup() {
|
|
|
|
Intent intent = new Intent(ConversationActivity.this, GroupCreateActivity.class);
|
2014-12-29 12:57:30 -08:00
|
|
|
intent.putExtra(GroupCreateActivity.GROUP_RECIPIENT_EXTRA, recipients.getPrimaryRecipient().getRecipientId());
|
2014-02-22 10:54:43 -08:00
|
|
|
startActivityForResult(intent, GROUP_EDIT);
|
|
|
|
}
|
|
|
|
|
2013-04-25 18:59:49 -07:00
|
|
|
private void handleDistributionBroadcastEnabled(MenuItem item) {
|
|
|
|
distributionType = ThreadDatabase.DistributionTypes.BROADCAST;
|
|
|
|
item.setChecked(true);
|
|
|
|
|
|
|
|
if (threadId != -1) {
|
|
|
|
new AsyncTask<Void, Void, Void>() {
|
|
|
|
@Override
|
|
|
|
protected Void doInBackground(Void... params) {
|
|
|
|
DatabaseFactory.getThreadDatabase(ConversationActivity.this)
|
|
|
|
.setDistributionType(threadId, ThreadDatabase.DistributionTypes.BROADCAST);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}.execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleDistributionConversationEnabled(MenuItem item) {
|
|
|
|
distributionType = ThreadDatabase.DistributionTypes.CONVERSATION;
|
|
|
|
item.setChecked(true);
|
|
|
|
|
|
|
|
if (threadId != -1) {
|
|
|
|
new AsyncTask<Void, Void, Void>() {
|
|
|
|
@Override
|
|
|
|
protected Void doInBackground(Void... params) {
|
|
|
|
DatabaseFactory.getThreadDatabase(ConversationActivity.this)
|
|
|
|
.setDistributionType(threadId, ThreadDatabase.DistributionTypes.CONVERSATION);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}.execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
private void handleDial(Recipient recipient) {
|
2013-06-18 14:43:27 -07:00
|
|
|
try {
|
|
|
|
if (recipient == null) return;
|
|
|
|
|
|
|
|
Intent dialIntent = new Intent(Intent.ACTION_DIAL,
|
|
|
|
Uri.parse("tel:" + recipient.getNumber()));
|
|
|
|
startActivity(dialIntent);
|
|
|
|
} catch (ActivityNotFoundException anfe) {
|
2014-02-17 20:25:40 -08:00
|
|
|
Log.w(TAG, anfe);
|
2014-03-01 01:32:00 +01:00
|
|
|
Dialogs.showAlertDialog(this,
|
2013-06-18 14:43:27 -07:00
|
|
|
getString(R.string.ConversationActivity_calls_not_supported),
|
|
|
|
getString(R.string.ConversationActivity_this_device_does_not_appear_to_support_dial_actions));
|
|
|
|
}
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
2012-10-21 14:34:09 -07:00
|
|
|
private void handleDisplayGroupRecipients() {
|
2014-02-15 11:28:07 -08:00
|
|
|
new GroupMembersDialog(this, getRecipients()).display();
|
2012-10-21 14:34:09 -07:00
|
|
|
}
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
private void handleDeleteThread() {
|
2015-03-24 13:44:22 +01:00
|
|
|
AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(this);
|
2012-09-19 19:56:04 -07:00
|
|
|
builder.setTitle(R.string.ConversationActivity_delete_thread_confirmation);
|
2015-03-24 13:44:22 +01:00
|
|
|
builder.setIconAttribute(R.attr.dialog_alert_icon);
|
2012-07-19 14:22:03 -07:00
|
|
|
builder.setCancelable(true);
|
2012-09-19 19:56:04 -07:00
|
|
|
builder.setMessage(R.string.ConversationActivity_are_you_sure_that_you_want_to_permanently_delete_this_conversation_question);
|
2012-07-19 14:22:03 -07:00
|
|
|
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
if (threadId > 0) {
|
|
|
|
DatabaseFactory.getThreadDatabase(ConversationActivity.this).deleteConversation(threadId);
|
|
|
|
}
|
2015-05-07 15:39:21 -07:00
|
|
|
composeText.getText().clear();
|
|
|
|
threadId = -1;
|
|
|
|
finish();
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
builder.setNegativeButton(R.string.no, null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2014-06-04 01:24:44 +02:00
|
|
|
private void handleAddToContacts() {
|
|
|
|
final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
|
|
|
|
intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipients.getPrimaryRecipient().getNumber());
|
|
|
|
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
|
|
|
|
startActivity(intent);
|
2013-10-17 02:28:36 +02:00
|
|
|
}
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
private void handleAddAttachment() {
|
2014-03-26 14:49:40 -07:00
|
|
|
if (this.isMmsEnabled || DirectoryHelper.isPushDestination(this, getRecipients())) {
|
2015-05-20 15:41:29 -07:00
|
|
|
new AlertDialogWrapper.Builder(this).setAdapter(attachmentAdapter, new AttachmentTypeListener())
|
|
|
|
.show();
|
2013-03-04 17:43:04 -08:00
|
|
|
} else {
|
2013-09-16 00:55:01 -07:00
|
|
|
handleManualMmsRequired();
|
2013-03-04 17:43:04 -08:00
|
|
|
}
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
2013-09-16 00:55:01 -07:00
|
|
|
private void handleManualMmsRequired() {
|
|
|
|
Toast.makeText(this, R.string.MmsDownloader_error_reading_mms_settings, Toast.LENGTH_LONG).show();
|
|
|
|
|
|
|
|
Intent intent = new Intent(this, PromptMmsActivity.class);
|
|
|
|
intent.putExtras(getIntent().getExtras());
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
///// Initializers
|
|
|
|
|
|
|
|
private void initializeTitleBar() {
|
2015-01-04 13:14:09 -08:00
|
|
|
final String title;
|
|
|
|
final String subtitle;
|
|
|
|
final Recipient recipient = getRecipients().getPrimaryRecipient();
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2012-08-01 17:39:36 -07:00
|
|
|
if (isSingleConversation()) {
|
2015-01-04 13:14:09 -08:00
|
|
|
if (TextUtils.isEmpty(recipient.getName())) {
|
|
|
|
title = recipient.getNumber();
|
|
|
|
subtitle = null;
|
2012-07-19 14:22:03 -07:00
|
|
|
} else {
|
2015-01-04 13:14:09 -08:00
|
|
|
title = recipient.getName();
|
|
|
|
subtitle = PhoneNumberUtils.formatNumber(recipient.getNumber());
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
2012-10-21 14:34:09 -07:00
|
|
|
} else if (isGroupConversation()) {
|
2014-02-17 20:25:40 -08:00
|
|
|
if (isPushGroupConversation()) {
|
2015-01-04 13:14:09 -08:00
|
|
|
final String groupName = recipient.getName();
|
|
|
|
|
|
|
|
title = (!TextUtils.isEmpty(groupName)) ? groupName : getString(R.string.ConversationActivity_unnamed_group);
|
|
|
|
subtitle = null;
|
2014-02-18 16:28:54 -08:00
|
|
|
} else {
|
2015-01-04 13:14:09 -08:00
|
|
|
final int size = getRecipients().getRecipientsList().size();
|
|
|
|
|
|
|
|
title = getString(R.string.ConversationActivity_group_conversation);
|
2014-02-23 23:58:16 -08:00
|
|
|
subtitle = (size == 1) ? getString(R.string.ConversationActivity_d_recipients_in_group_singular)
|
2015-01-04 13:14:09 -08:00
|
|
|
: String.format(getString(R.string.ConversationActivity_d_recipients_in_group), size);
|
2014-02-17 20:25:40 -08:00
|
|
|
}
|
2012-07-19 14:22:03 -07:00
|
|
|
} else {
|
2012-09-19 19:56:04 -07:00
|
|
|
title = getString(R.string.ConversationActivity_compose_message);
|
2015-01-04 13:14:09 -08:00
|
|
|
subtitle = null;
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
2015-01-04 13:14:09 -08:00
|
|
|
getSupportActionBar().setTitle(title);
|
|
|
|
getSupportActionBar().setSubtitle(subtitle);
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2015-01-04 13:14:09 -08:00
|
|
|
getWindow().getDecorView().setContentDescription(getString(R.string.conversation_activity__window_description, title));
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2014-06-28 20:40:57 -07:00
|
|
|
this.supportInvalidateOptionsMenu();
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
2013-02-02 20:37:40 -08:00
|
|
|
private void initializeDraft() {
|
|
|
|
String draftText = getIntent().getStringExtra(DRAFT_TEXT_EXTRA);
|
|
|
|
Uri draftImage = getIntent().getParcelableExtra(DRAFT_IMAGE_EXTRA);
|
|
|
|
Uri draftAudio = getIntent().getParcelableExtra(DRAFT_AUDIO_EXTRA);
|
2014-03-03 11:55:34 -05:00
|
|
|
Uri draftVideo = getIntent().getParcelableExtra(DRAFT_VIDEO_EXTRA);
|
2013-02-02 20:37:40 -08:00
|
|
|
|
|
|
|
if (draftText != null) composeText.setText(draftText);
|
|
|
|
if (draftImage != null) addAttachmentImage(draftImage);
|
|
|
|
if (draftAudio != null) addAttachmentAudio(draftAudio);
|
2014-03-03 11:55:34 -05:00
|
|
|
if (draftVideo != null) addAttachmentVideo(draftVideo);
|
2013-02-04 00:13:07 -08:00
|
|
|
|
2014-03-03 11:55:34 -05:00
|
|
|
if (draftText == null && draftImage == null && draftAudio == null && draftVideo == null) {
|
2013-02-04 00:13:07 -08:00
|
|
|
initializeDraftFromDatabase();
|
2015-05-18 10:26:32 -07:00
|
|
|
} else {
|
|
|
|
updateToggleButtonState();
|
2013-02-04 00:13:07 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 10:54:43 -08:00
|
|
|
private void initializeEnabledCheck() {
|
2014-02-23 14:37:41 -08:00
|
|
|
boolean enabled = !(isPushGroupConversation() && !isActiveGroup());
|
2014-02-22 10:54:43 -08:00
|
|
|
composeText.setEnabled(enabled);
|
|
|
|
sendButton.setEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
2013-02-04 00:13:07 -08:00
|
|
|
private void initializeDraftFromDatabase() {
|
|
|
|
new AsyncTask<Void, Void, List<Draft>>() {
|
|
|
|
@Override
|
|
|
|
protected List<Draft> doInBackground(Void... params) {
|
|
|
|
MasterCipher masterCipher = new MasterCipher(masterSecret);
|
|
|
|
DraftDatabase draftDatabase = DatabaseFactory.getDraftDatabase(ConversationActivity.this);
|
|
|
|
List<Draft> results = draftDatabase.getDrafts(masterCipher, threadId);
|
|
|
|
|
|
|
|
draftDatabase.clearDrafts(threadId);
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPostExecute(List<Draft> drafts) {
|
|
|
|
for (Draft draft : drafts) {
|
2015-05-06 13:53:55 -07:00
|
|
|
if (draft.getType().equals(Draft.TEXT)) {
|
2014-05-22 23:00:53 +02:00
|
|
|
composeText.setText(draft.getValue());
|
|
|
|
} else if (draft.getType().equals(Draft.IMAGE)) {
|
|
|
|
addAttachmentImage(Uri.parse(draft.getValue()));
|
|
|
|
} else if (draft.getType().equals(Draft.AUDIO)) {
|
|
|
|
addAttachmentAudio(Uri.parse(draft.getValue()));
|
|
|
|
} else if (draft.getType().equals(Draft.VIDEO)) {
|
|
|
|
addAttachmentVideo(Uri.parse(draft.getValue()));
|
|
|
|
}
|
2013-02-04 00:13:07 -08:00
|
|
|
}
|
2015-05-18 10:26:32 -07:00
|
|
|
|
|
|
|
updateToggleButtonState();
|
2013-02-04 00:13:07 -08:00
|
|
|
}
|
|
|
|
}.execute();
|
2013-02-02 20:37:40 -08:00
|
|
|
}
|
|
|
|
|
2012-08-01 17:39:36 -07:00
|
|
|
private void initializeSecurity() {
|
2015-03-11 14:23:45 -07:00
|
|
|
boolean isMediaMessage = !recipients.isSingleRecipient() || attachmentManager.isAttachmentPresent();
|
|
|
|
this.isEncryptedConversation = DirectoryHelper.isPushDestination(this, getRecipients());
|
2014-04-15 12:43:14 +02:00
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
sendButton.resetAvailableTransports(isMediaMessage);
|
2014-07-18 19:31:03 -07:00
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
if (!isEncryptedConversation) sendButton.disableTransport(Type.TEXTSECURE);
|
|
|
|
if (recipients.isGroupRecipient()) sendButton.disableTransport(Type.SMS);
|
|
|
|
|
|
|
|
if (isEncryptedConversation) sendButton.setDefaultTransport(Type.TEXTSECURE);
|
|
|
|
else sendButton.setDefaultTransport(Type.SMS);
|
2014-03-20 00:54:05 -07:00
|
|
|
|
|
|
|
calculateCharactersRemaining();
|
2014-04-15 12:43:14 +02:00
|
|
|
}
|
2014-04-14 03:55:20 +03:00
|
|
|
|
2013-03-04 17:43:04 -08:00
|
|
|
private void initializeMmsEnabledCheck() {
|
|
|
|
new AsyncTask<Void, Void, Boolean>() {
|
|
|
|
@Override
|
|
|
|
protected Boolean doInBackground(Void... params) {
|
2014-12-29 14:01:02 -08:00
|
|
|
return Util.isMmsCapable(ConversationActivity.this);
|
2013-03-04 17:43:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPostExecute(Boolean isMmsEnabled) {
|
|
|
|
ConversationActivity.this.isMmsEnabled = isMmsEnabled;
|
|
|
|
}
|
|
|
|
}.execute();
|
|
|
|
}
|
|
|
|
|
2013-06-29 15:34:43 -07:00
|
|
|
private void initializeIme() {
|
2015-01-05 16:44:56 -08:00
|
|
|
if (TextSecurePreferences.isEnterSendsEnabled(this)) {
|
|
|
|
composeText.setInputType (composeText.getInputType() & ~InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
|
|
|
composeText.setImeOptions(composeText.getImeOptions() & ~EditorInfo.IME_FLAG_NO_ENTER_ACTION);
|
2013-06-29 15:34:43 -07:00
|
|
|
} else {
|
2015-01-05 16:44:56 -08:00
|
|
|
composeText.setInputType (composeText.getInputType() | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
|
|
|
composeText.setImeOptions(composeText.getImeOptions() | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
|
2013-06-29 15:34:43 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-24 18:32:51 -08:00
|
|
|
private void initializeViews() {
|
2015-05-18 10:26:32 -07:00
|
|
|
buttonToggle = (AnimatingToggle)findViewById(R.id.button_toggle);
|
2015-03-11 14:23:45 -07:00
|
|
|
sendButton = (SendButton) findViewById(R.id.send_button);
|
2015-05-18 10:26:32 -07:00
|
|
|
attachButton = (ImageButton) findViewById(R.id.attach_button);
|
2015-03-11 14:23:45 -07:00
|
|
|
composeText = (ComposeText) findViewById(R.id.embedded_text_editor);
|
|
|
|
charactersLeft = (TextView) findViewById(R.id.space_left);
|
2014-12-24 18:32:51 -08:00
|
|
|
emojiToggle = (EmojiToggle) findViewById(R.id.emoji_toggle);
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2014-12-24 18:32:51 -08:00
|
|
|
attachmentAdapter = new AttachmentTypeSelectorAdapter(this);
|
|
|
|
attachmentManager = new AttachmentManager(this, this);
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2013-06-27 20:57:27 -07:00
|
|
|
SendButtonListener sendButtonListener = new SendButtonListener();
|
|
|
|
ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2015-05-18 10:26:32 -07:00
|
|
|
attachButton.setOnClickListener(new AttachButtonListener());
|
2012-07-19 14:22:03 -07:00
|
|
|
sendButton.setOnClickListener(sendButtonListener);
|
2013-03-13 17:45:32 -07:00
|
|
|
sendButton.setEnabled(true);
|
2015-02-16 02:38:09 -08:00
|
|
|
sendButton.addOnTransportChangedListener(new OnTransportChangedListener() {
|
|
|
|
@Override
|
|
|
|
public void onChange(TransportOption newTransport) {
|
|
|
|
calculateCharactersRemaining();
|
2015-03-11 14:23:45 -07:00
|
|
|
composeText.setHint(newTransport.getComposeHint());
|
2015-02-16 02:38:09 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-06-27 20:57:27 -07:00
|
|
|
composeText.setOnKeyListener(composeKeyPressedListener);
|
|
|
|
composeText.addTextChangedListener(composeKeyPressedListener);
|
2012-07-19 14:22:03 -07:00
|
|
|
composeText.setOnEditorActionListener(sendButtonListener);
|
2013-06-27 20:57:27 -07:00
|
|
|
composeText.setOnClickListener(composeKeyPressedListener);
|
2014-05-28 20:53:34 -07:00
|
|
|
composeText.setOnFocusChangeListener(composeKeyPressedListener);
|
2013-06-27 20:57:27 -07:00
|
|
|
emojiToggle.setOnClickListener(new EmojiToggleListener());
|
2014-12-24 18:32:51 -08:00
|
|
|
}
|
|
|
|
|
2015-05-06 13:53:55 -07:00
|
|
|
private EmojiDrawer getEmojiDrawer() {
|
|
|
|
if (emojiDrawer.isPresent()) return emojiDrawer.get();
|
2015-05-29 10:54:59 -07:00
|
|
|
EmojiDrawer emojiDrawer = (EmojiDrawer)((ViewStub)findViewById(R.id.emoji_drawer_stub)).inflate();
|
|
|
|
emojiDrawer.setComposeEditText(composeText);
|
|
|
|
this.emojiDrawer = Optional.of(emojiDrawer);
|
|
|
|
return emojiDrawer;
|
2015-05-06 13:53:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isEmojiDrawerOpen() {
|
|
|
|
return emojiDrawer.isPresent() && emojiDrawer.get().isOpen();
|
2015-03-09 15:13:13 -07:00
|
|
|
}
|
|
|
|
|
2014-12-24 18:32:51 -08:00
|
|
|
private void initializeResources() {
|
|
|
|
recipients = RecipientFactory.getRecipientsForIds(this, getIntent().getLongArrayExtra(RECIPIENTS_EXTRA), true);
|
|
|
|
threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1);
|
|
|
|
distributionType = getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2015-02-10 03:15:50 -08:00
|
|
|
recipients.addListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onModified(Recipient recipient) {
|
|
|
|
initializeTitleBar();
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
2014-02-15 18:40:08 -08:00
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
private void initializeReceivers() {
|
|
|
|
securityUpdateReceiver = new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
2015-03-11 14:23:45 -07:00
|
|
|
long eventThreadId = intent.getLongExtra("thread_id", -1);
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
if (eventThreadId == threadId || eventThreadId == -2) {
|
2012-08-01 17:39:36 -07:00
|
|
|
initializeSecurity();
|
2012-07-19 14:22:03 -07:00
|
|
|
initializeTitleBar();
|
|
|
|
calculateCharactersRemaining();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-24 00:19:54 -08:00
|
|
|
groupUpdateReceiver = new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
Log.w("ConversationActivity", "Group update received...");
|
|
|
|
if (recipients != null) {
|
2014-12-17 18:14:19 -08:00
|
|
|
long[] ids = recipients.getIds();
|
2014-02-24 00:19:54 -08:00
|
|
|
Log.w("ConversationActivity", "Looking up new recipients...");
|
2014-02-24 00:37:11 -08:00
|
|
|
recipients = RecipientFactory.getRecipientsForIds(context, ids, false);
|
|
|
|
initializeTitleBar();
|
2014-02-24 00:19:54 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
registerReceiver(securityUpdateReceiver,
|
2014-11-03 15:16:04 -08:00
|
|
|
new IntentFilter(SecurityEvent.SECURITY_UPDATE_EVENT),
|
2012-07-19 14:22:03 -07:00
|
|
|
KeyCachingService.KEY_PERMISSION, null);
|
2014-02-24 00:19:54 -08:00
|
|
|
|
|
|
|
registerReceiver(groupUpdateReceiver,
|
|
|
|
new IntentFilter(GroupDatabase.DATABASE_UPDATE_ACTION));
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//////// Helper Methods
|
|
|
|
|
|
|
|
private void addAttachment(int type) {
|
|
|
|
Log.w("ComposeMessageActivity", "Selected: " + type);
|
|
|
|
switch (type) {
|
2015-05-18 10:26:32 -07:00
|
|
|
case AttachmentTypeSelectorAdapter.TAKE_PHOTO:
|
|
|
|
attachmentManager.capturePhoto(this, CAPTURE_PHOTO); break;
|
2012-07-19 14:22:03 -07:00
|
|
|
case AttachmentTypeSelectorAdapter.ADD_IMAGE:
|
|
|
|
AttachmentManager.selectImage(this, PICK_IMAGE); break;
|
|
|
|
case AttachmentTypeSelectorAdapter.ADD_VIDEO:
|
|
|
|
AttachmentManager.selectVideo(this, PICK_VIDEO); break;
|
|
|
|
case AttachmentTypeSelectorAdapter.ADD_SOUND:
|
|
|
|
AttachmentManager.selectAudio(this, PICK_AUDIO); break;
|
2014-06-04 01:24:44 +02:00
|
|
|
case AttachmentTypeSelectorAdapter.ADD_CONTACT_INFO:
|
|
|
|
AttachmentManager.selectContactInfo(this, PICK_CONTACT_INFO); break;
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addAttachmentImage(Uri imageUri) {
|
|
|
|
try {
|
2014-12-22 16:25:51 -08:00
|
|
|
attachmentManager.setImage(imageUri);
|
2014-11-08 11:35:58 -08:00
|
|
|
} catch (IOException | BitmapDecodingException e) {
|
2014-02-17 20:25:40 -08:00
|
|
|
Log.w(TAG, e);
|
2012-07-19 14:22:03 -07:00
|
|
|
attachmentManager.clear();
|
2012-09-19 19:56:04 -07:00
|
|
|
Toast.makeText(this, R.string.ConversationActivity_sorry_there_was_an_error_setting_your_attachment,
|
2012-07-19 14:22:03 -07:00
|
|
|
Toast.LENGTH_LONG).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addAttachmentVideo(Uri videoUri) {
|
|
|
|
try {
|
|
|
|
attachmentManager.setVideo(videoUri);
|
|
|
|
} catch (IOException e) {
|
|
|
|
attachmentManager.clear();
|
2012-09-19 19:56:04 -07:00
|
|
|
Toast.makeText(this, R.string.ConversationActivity_sorry_there_was_an_error_setting_your_attachment,
|
2012-07-19 14:22:03 -07:00
|
|
|
Toast.LENGTH_LONG).show();
|
|
|
|
Log.w("ComposeMessageActivity", e);
|
|
|
|
} catch (MediaTooLargeException e) {
|
|
|
|
attachmentManager.clear();
|
2015-01-02 15:43:28 -08:00
|
|
|
|
2014-12-01 21:06:17 -08:00
|
|
|
Toast.makeText(this, getString(R.string.ConversationActivity_sorry_the_selected_video_exceeds_message_size_restrictions,
|
2015-01-02 15:43:28 -08:00
|
|
|
(MmsMediaConstraints.MAX_MESSAGE_SIZE/1024)),
|
2012-07-19 14:22:03 -07:00
|
|
|
Toast.LENGTH_LONG).show();
|
|
|
|
Log.w("ComposeMessageActivity", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addAttachmentAudio(Uri audioUri) {
|
|
|
|
try {
|
|
|
|
attachmentManager.setAudio(audioUri);
|
|
|
|
} catch (IOException e) {
|
|
|
|
attachmentManager.clear();
|
2012-09-19 19:56:04 -07:00
|
|
|
Toast.makeText(this, R.string.ConversationActivity_sorry_there_was_an_error_setting_your_attachment,
|
2012-07-19 14:22:03 -07:00
|
|
|
Toast.LENGTH_LONG).show();
|
|
|
|
Log.w("ComposeMessageActivity", e);
|
|
|
|
} catch (MediaTooLargeException e) {
|
|
|
|
attachmentManager.clear();
|
2014-12-01 21:06:17 -08:00
|
|
|
Toast.makeText(this, getString(R.string.ConversationActivity_sorry_the_selected_audio_exceeds_message_size_restrictions,
|
2015-01-02 15:43:28 -08:00
|
|
|
(MmsMediaConstraints.MAX_MESSAGE_SIZE/1024)),
|
2012-07-19 14:22:03 -07:00
|
|
|
Toast.LENGTH_LONG).show();
|
|
|
|
Log.w("ComposeMessageActivity", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-04 01:24:44 +02:00
|
|
|
private void addAttachmentContactInfo(Uri contactUri) {
|
2013-10-17 02:28:36 +02:00
|
|
|
ContactAccessor contactDataList = ContactAccessor.getInstance();
|
|
|
|
ContactData contactData = contactDataList.getContactData(this, contactUri);
|
|
|
|
|
|
|
|
if (contactData.numbers.size() == 1) composeText.append(contactData.numbers.get(0).number);
|
|
|
|
else if (contactData.numbers.size() > 1) selectContactInfo(contactData);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void selectContactInfo(ContactData contactData) {
|
2014-12-12 18:31:20 -08:00
|
|
|
final CharSequence[] numbers = new CharSequence[contactData.numbers.size()];
|
2013-10-17 02:28:36 +02:00
|
|
|
final CharSequence[] numberItems = new CharSequence[contactData.numbers.size()];
|
2014-12-12 18:31:20 -08:00
|
|
|
|
2013-10-17 02:28:36 +02:00
|
|
|
for (int i = 0; i < contactData.numbers.size(); i++) {
|
2014-12-12 18:31:20 -08:00
|
|
|
numbers[i] = contactData.numbers.get(i).number;
|
2013-10-17 02:28:36 +02:00
|
|
|
numberItems[i] = contactData.numbers.get(i).type + ": " + contactData.numbers.get(i).number;
|
|
|
|
}
|
|
|
|
|
2015-03-24 13:44:22 +01:00
|
|
|
AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(this);
|
|
|
|
builder.setIconAttribute(R.attr.conversation_attach_contact_info);
|
2013-10-17 02:28:36 +02:00
|
|
|
builder.setTitle(R.string.ConversationActivity_select_contact_info);
|
|
|
|
|
|
|
|
builder.setItems(numberItems, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
composeText.append(numbers[which]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2014-12-11 17:13:01 -08:00
|
|
|
private Drafts getDraftsForCurrentState() {
|
|
|
|
Drafts drafts = new Drafts();
|
2013-02-04 00:13:07 -08:00
|
|
|
|
|
|
|
if (!Util.isEmpty(composeText)) {
|
|
|
|
drafts.add(new Draft(Draft.TEXT, composeText.getText().toString()));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Slide slide : attachmentManager.getSlideDeck().getSlides()) {
|
2014-12-14 19:57:57 +01:00
|
|
|
if (slide.hasAudio()) drafts.add(new Draft(Draft.AUDIO, slide.getUri().toString()));
|
2013-02-04 00:13:07 -08:00
|
|
|
else if (slide.hasVideo()) drafts.add(new Draft(Draft.VIDEO, slide.getUri().toString()));
|
2014-12-14 19:57:57 +01:00
|
|
|
else if (slide.hasImage()) drafts.add(new Draft(Draft.IMAGE, slide.getUri().toString()));
|
2013-02-04 00:13:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return drafts;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void saveDraft() {
|
2015-01-04 00:25:35 +01:00
|
|
|
if (this.recipients == null || this.recipients.isEmpty())
|
2013-02-04 00:13:07 -08:00
|
|
|
return;
|
|
|
|
|
2015-01-04 00:25:35 +01:00
|
|
|
final Drafts drafts = getDraftsForCurrentState();
|
|
|
|
final long thisThreadId = this.threadId;
|
|
|
|
final MasterSecret thisMasterSecret = this.masterSecret.parcelClone();
|
|
|
|
final int thisDistributionType = this.distributionType;
|
2013-02-04 00:13:07 -08:00
|
|
|
|
2015-01-04 00:25:35 +01:00
|
|
|
new AsyncTask<Long, Void, Void>() {
|
2013-02-04 00:13:07 -08:00
|
|
|
@Override
|
2015-01-04 00:25:35 +01:00
|
|
|
protected Void doInBackground(Long... params) {
|
2014-12-11 17:13:01 -08:00
|
|
|
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(ConversationActivity.this);
|
2015-01-04 00:25:35 +01:00
|
|
|
DraftDatabase draftDatabase = DatabaseFactory.getDraftDatabase(ConversationActivity.this);
|
|
|
|
long threadId = params[0];
|
|
|
|
|
2014-12-11 17:13:01 -08:00
|
|
|
if (drafts.size() > 0) {
|
2015-01-04 00:25:35 +01:00
|
|
|
if (threadId == -1) threadId = threadDatabase.getThreadIdFor(getRecipients(), thisDistributionType);
|
|
|
|
|
|
|
|
draftDatabase.insertDrafts(new MasterCipher(thisMasterSecret), threadId, drafts);
|
2015-04-06 13:44:18 -07:00
|
|
|
threadDatabase.updateSnippet(threadId, drafts.getSnippet(ConversationActivity.this), System.currentTimeMillis(), Types.BASE_DRAFT_TYPE);
|
2015-01-04 00:25:35 +01:00
|
|
|
} else if (threadId > 0) {
|
|
|
|
threadDatabase.update(threadId);
|
2014-12-11 17:13:01 -08:00
|
|
|
}
|
2013-02-04 00:13:07 -08:00
|
|
|
return null;
|
|
|
|
}
|
2015-01-04 00:25:35 +01:00
|
|
|
}.execute(thisThreadId);
|
2013-02-04 00:13:07 -08:00
|
|
|
}
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
private void calculateCharactersRemaining() {
|
2015-02-16 02:38:09 -08:00
|
|
|
int charactersSpent = composeText.getText().toString().length();
|
2015-03-07 09:02:10 -08:00
|
|
|
TransportOption transportOption = sendButton.getSelectedTransport();
|
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
CharacterState characterState = transportOption.calculateCharacters(charactersSpent);
|
2015-03-07 09:02:10 -08:00
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
if (characterState.charactersRemaining <= 15 || characterState.messagesSpent > 1) {
|
|
|
|
charactersLeft.setText(characterState.charactersRemaining + "/" + characterState.maxMessageSize
|
|
|
|
+ " (" + characterState.messagesSpent + ")");
|
|
|
|
charactersLeft.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
charactersLeft.setVisibility(View.GONE);
|
2014-01-08 12:29:05 -10:00
|
|
|
}
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
2012-08-01 17:39:36 -07:00
|
|
|
private boolean isSingleConversation() {
|
2014-02-14 15:59:57 -08:00
|
|
|
return getRecipients() != null && getRecipients().isSingleRecipient() && !getRecipients().isGroupRecipient();
|
2012-10-21 14:34:09 -07:00
|
|
|
}
|
|
|
|
|
2014-02-22 10:54:43 -08:00
|
|
|
private boolean isActiveGroup() {
|
|
|
|
if (!isGroupConversation()) return false;
|
|
|
|
|
|
|
|
try {
|
|
|
|
byte[] groupId = GroupUtil.getDecodedId(getRecipients().getPrimaryRecipient().getNumber());
|
|
|
|
GroupRecord record = DatabaseFactory.getGroupDatabase(this).getGroup(groupId);
|
|
|
|
|
2014-02-23 21:18:08 -08:00
|
|
|
return record != null && record.isActive();
|
2014-02-22 10:54:43 -08:00
|
|
|
} catch (IOException e) {
|
|
|
|
Log.w("ConversationActivity", e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-21 14:34:09 -07:00
|
|
|
private boolean isGroupConversation() {
|
2014-02-14 15:59:57 -08:00
|
|
|
return getRecipients() != null &&
|
|
|
|
(!getRecipients().isSingleRecipient() || getRecipients().isGroupRecipient());
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
2014-02-17 20:25:40 -08:00
|
|
|
private boolean isPushGroupConversation() {
|
2014-02-24 00:19:54 -08:00
|
|
|
return getRecipients() != null && getRecipients().isGroupRecipient();
|
2014-02-17 20:25:40 -08:00
|
|
|
}
|
|
|
|
|
2012-08-01 17:39:36 -07:00
|
|
|
private Recipients getRecipients() {
|
2014-02-27 22:44:02 -08:00
|
|
|
return this.recipients;
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private String getMessage() throws InvalidMessageException {
|
2012-09-07 21:21:12 -07:00
|
|
|
String rawText = composeText.getText().toString();
|
2012-07-19 14:22:03 -07:00
|
|
|
|
|
|
|
if (rawText.length() < 1 && !attachmentManager.isAttachmentPresent())
|
2012-09-19 19:56:04 -07:00
|
|
|
throw new InvalidMessageException(getString(R.string.ConversationActivity_message_is_empty_exclamation));
|
2012-07-19 14:22:03 -07:00
|
|
|
|
|
|
|
return rawText;
|
|
|
|
}
|
|
|
|
|
2013-02-03 18:41:34 -08:00
|
|
|
private void markThreadAsRead() {
|
|
|
|
new AsyncTask<Long, Void, Void>() {
|
|
|
|
@Override
|
|
|
|
protected Void doInBackground(Long... params) {
|
|
|
|
DatabaseFactory.getThreadDatabase(ConversationActivity.this).setRead(params[0]);
|
2013-02-08 11:57:54 -08:00
|
|
|
MessageNotifier.updateNotification(ConversationActivity.this, masterSecret);
|
2013-02-03 18:41:34 -08:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}.execute(threadId);
|
|
|
|
}
|
|
|
|
|
2014-11-08 11:35:58 -08:00
|
|
|
private void sendComplete(long threadId) {
|
|
|
|
boolean refreshFragment = (threadId != this.threadId);
|
|
|
|
this.threadId = threadId;
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2015-04-08 17:43:14 -07:00
|
|
|
if (fragment == null || !fragment.isVisible() || isFinishing()) {
|
2014-11-24 22:48:50 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-17 15:47:58 -08:00
|
|
|
if (refreshFragment) {
|
2012-07-31 16:27:58 -07:00
|
|
|
fragment.reload(recipients, threadId);
|
2012-07-19 14:22:03 -07:00
|
|
|
|
|
|
|
initializeTitleBar();
|
2012-08-01 17:39:36 -07:00
|
|
|
initializeSecurity();
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
2014-11-08 11:35:58 -08:00
|
|
|
|
2014-03-26 15:11:56 -07:00
|
|
|
fragment.scrollToBottom();
|
2015-05-18 10:26:32 -07:00
|
|
|
attachmentManager.cleanup();
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
2014-07-18 19:31:03 -07:00
|
|
|
private void sendMessage() {
|
2012-07-19 14:22:03 -07:00
|
|
|
try {
|
2015-03-11 14:23:45 -07:00
|
|
|
Recipients recipients = getRecipients();
|
|
|
|
boolean forceSms = sendButton.isManualSelection() && sendButton.getSelectedTransport().isSms();
|
|
|
|
|
|
|
|
Log.w(TAG, "isManual Selection: " + sendButton.isManualSelection());
|
|
|
|
Log.w(TAG, "forceSms: " + forceSms);
|
2012-08-01 17:39:36 -07:00
|
|
|
|
2014-07-18 19:31:03 -07:00
|
|
|
if (recipients == null) {
|
2012-08-01 17:39:36 -07:00
|
|
|
throw new RecipientFormattingException("Badly formatted");
|
2014-07-18 19:31:03 -07:00
|
|
|
}
|
2012-08-01 17:39:36 -07:00
|
|
|
|
2013-09-16 00:55:01 -07:00
|
|
|
if ((!recipients.isSingleRecipient() || recipients.isEmailRecipient()) && !isMmsEnabled) {
|
|
|
|
handleManualMmsRequired();
|
2014-06-03 12:35:56 -07:00
|
|
|
} else if (attachmentManager.isAttachmentPresent() || !recipients.isSingleRecipient() || recipients.isGroupRecipient() || recipients.isEmailRecipient()) {
|
2015-03-11 14:23:45 -07:00
|
|
|
sendMediaMessage(forceSms);
|
2012-07-19 14:22:03 -07:00
|
|
|
} else {
|
2015-03-11 14:23:45 -07:00
|
|
|
sendTextMessage(forceSms);
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
} catch (RecipientFormattingException ex) {
|
2012-09-07 20:03:23 -07:00
|
|
|
Toast.makeText(ConversationActivity.this,
|
2012-09-19 19:56:04 -07:00
|
|
|
R.string.ConversationActivity_recipient_is_not_a_valid_sms_or_email_address_exclamation,
|
2012-09-07 20:03:23 -07:00
|
|
|
Toast.LENGTH_LONG).show();
|
2014-02-17 20:25:40 -08:00
|
|
|
Log.w(TAG, ex);
|
2012-07-19 14:22:03 -07:00
|
|
|
} catch (InvalidMessageException ex) {
|
2012-09-19 19:56:04 -07:00
|
|
|
Toast.makeText(ConversationActivity.this, R.string.ConversationActivity_message_is_empty_exclamation,
|
2012-09-07 20:03:23 -07:00
|
|
|
Toast.LENGTH_SHORT).show();
|
2014-02-17 20:25:40 -08:00
|
|
|
Log.w(TAG, ex);
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
private void sendMediaMessage(final boolean forceSms)
|
2014-11-08 11:35:58 -08:00
|
|
|
throws InvalidMessageException
|
2014-06-11 15:31:59 -07:00
|
|
|
{
|
2014-11-08 11:35:58 -08:00
|
|
|
final Context context = getApplicationContext();
|
2014-06-11 15:31:59 -07:00
|
|
|
SlideDeck slideDeck;
|
|
|
|
|
2014-11-08 11:35:58 -08:00
|
|
|
if (attachmentManager.isAttachmentPresent()) slideDeck = new SlideDeck(attachmentManager.getSlideDeck());
|
2014-06-11 15:31:59 -07:00
|
|
|
else slideDeck = new SlideDeck();
|
|
|
|
|
|
|
|
OutgoingMediaMessage outgoingMessage = new OutgoingMediaMessage(this, recipients, slideDeck,
|
|
|
|
getMessage(), distributionType);
|
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
if (isEncryptedConversation && !forceSms) {
|
2014-06-11 15:31:59 -07:00
|
|
|
outgoingMessage = new OutgoingSecureMediaMessage(outgoingMessage);
|
|
|
|
}
|
|
|
|
|
2014-11-08 11:35:58 -08:00
|
|
|
attachmentManager.clear();
|
|
|
|
composeText.setText("");
|
|
|
|
|
|
|
|
new AsyncTask<OutgoingMediaMessage, Void, Long>() {
|
|
|
|
@Override
|
|
|
|
protected Long doInBackground(OutgoingMediaMessage... messages) {
|
|
|
|
return MessageSender.send(context, masterSecret, messages[0], threadId, forceSms);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPostExecute(Long result) {
|
|
|
|
sendComplete(result);
|
|
|
|
}
|
|
|
|
}.execute(outgoingMessage);
|
2014-06-11 15:31:59 -07:00
|
|
|
}
|
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
private void sendTextMessage(final boolean forceSms)
|
2014-06-11 15:31:59 -07:00
|
|
|
throws InvalidMessageException
|
|
|
|
{
|
2014-11-08 11:35:58 -08:00
|
|
|
final Context context = getApplicationContext();
|
2014-06-11 15:31:59 -07:00
|
|
|
OutgoingTextMessage message;
|
|
|
|
|
2015-03-11 14:23:45 -07:00
|
|
|
if (isEncryptedConversation && !forceSms) {
|
2014-06-11 15:31:59 -07:00
|
|
|
message = new OutgoingEncryptedMessage(recipients, getMessage());
|
|
|
|
} else {
|
|
|
|
message = new OutgoingTextMessage(recipients, getMessage());
|
|
|
|
}
|
|
|
|
|
2014-11-08 11:35:58 -08:00
|
|
|
this.composeText.setText("");
|
2014-06-11 15:31:59 -07:00
|
|
|
|
2014-11-08 11:35:58 -08:00
|
|
|
new AsyncTask<OutgoingTextMessage, Void, Long>() {
|
|
|
|
@Override
|
|
|
|
protected Long doInBackground(OutgoingTextMessage... messages) {
|
|
|
|
return MessageSender.send(context, masterSecret, messages[0], threadId, forceSms);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPostExecute(Long result) {
|
|
|
|
sendComplete(result);
|
|
|
|
}
|
|
|
|
}.execute(message);
|
2014-06-11 15:31:59 -07:00
|
|
|
}
|
|
|
|
|
2015-05-18 10:26:32 -07:00
|
|
|
private void updateToggleButtonState() {
|
|
|
|
if (composeText.getText().length() == 0 && !attachmentManager.isAttachmentPresent()) {
|
|
|
|
buttonToggle.display(attachButton);
|
|
|
|
} else {
|
|
|
|
buttonToggle.display(sendButton);
|
|
|
|
}
|
|
|
|
}
|
2014-06-11 15:31:59 -07:00
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
// Listeners
|
|
|
|
|
|
|
|
private class AttachmentTypeListener implements DialogInterface.OnClickListener {
|
2013-02-02 20:37:40 -08:00
|
|
|
@Override
|
2012-07-19 14:22:03 -07:00
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
addAttachment(attachmentAdapter.buttonToCommand(which));
|
2015-03-24 13:44:22 +01:00
|
|
|
dialog.dismiss();
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-27 20:57:27 -07:00
|
|
|
private class EmojiToggleListener implements OnClickListener {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
InputMethodManager input = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
2015-05-06 13:53:55 -07:00
|
|
|
if (isEmojiDrawerOpen()) {
|
2013-06-27 20:57:27 -07:00
|
|
|
input.showSoftInput(composeText, 0);
|
2015-05-06 13:53:55 -07:00
|
|
|
getEmojiDrawer().hide();
|
2013-06-27 20:57:27 -07:00
|
|
|
} else {
|
|
|
|
input.hideSoftInputFromWindow(composeText.getWindowToken(), 0);
|
2014-05-28 20:53:34 -07:00
|
|
|
|
2015-05-06 13:53:55 -07:00
|
|
|
getEmojiDrawer().show();
|
2013-06-27 20:57:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-19 14:22:03 -07:00
|
|
|
private class SendButtonListener implements OnClickListener, TextView.OnEditorActionListener {
|
2013-02-02 20:37:40 -08:00
|
|
|
@Override
|
2012-07-19 14:22:03 -07:00
|
|
|
public void onClick(View v) {
|
2014-07-18 19:31:03 -07:00
|
|
|
sendMessage();
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
|
|
|
|
2013-02-02 20:37:40 -08:00
|
|
|
@Override
|
2012-07-19 14:22:03 -07:00
|
|
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
|
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
|
|
|
sendButton.performClick();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-25 18:59:49 -07:00
|
|
|
}
|
2012-07-19 14:22:03 -07:00
|
|
|
|
2015-05-18 10:26:32 -07:00
|
|
|
private class AttachButtonListener implements OnClickListener {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
handleAddAttachment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 20:53:34 -07:00
|
|
|
private class ComposeKeyPressedListener implements OnKeyListener, OnClickListener, TextWatcher, OnFocusChangeListener {
|
2015-05-18 10:26:32 -07:00
|
|
|
|
|
|
|
int beforeLength;
|
|
|
|
|
2013-06-27 20:57:27 -07:00
|
|
|
@Override
|
|
|
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
|
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
2013-07-09 18:26:18 -07:00
|
|
|
if (TextSecurePreferences.isEnterSendsEnabled(ConversationActivity.this)) {
|
2013-06-27 20:57:27 -07:00
|
|
|
sendButton.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
|
|
|
|
sendButton.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-05-06 13:53:55 -07:00
|
|
|
if (isEmojiDrawerOpen()) {
|
2013-06-27 20:57:27 -07:00
|
|
|
emojiToggle.performClick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-18 10:26:32 -07:00
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count,int after) {
|
|
|
|
beforeLength = composeText.getText().length();
|
|
|
|
}
|
|
|
|
|
2013-02-02 20:37:40 -08:00
|
|
|
@Override
|
2012-07-19 14:22:03 -07:00
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
calculateCharactersRemaining();
|
2015-05-18 10:26:32 -07:00
|
|
|
|
|
|
|
if (composeText.getText().length() == 0 || beforeLength == 0) {
|
2015-05-22 13:30:34 -07:00
|
|
|
composeText.postDelayed(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
updateToggleButtonState();
|
|
|
|
}
|
|
|
|
}, 50);
|
2015-05-18 10:26:32 -07:00
|
|
|
}
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
2015-05-18 10:26:32 -07:00
|
|
|
|
2013-02-02 20:37:40 -08:00
|
|
|
@Override
|
2012-07-19 14:22:03 -07:00
|
|
|
public void onTextChanged(CharSequence s, int start, int before,int count) {}
|
2014-05-28 20:53:34 -07:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFocusChange(View v, boolean hasFocus) {
|
2015-05-06 13:53:55 -07:00
|
|
|
if (hasFocus && isEmojiDrawerOpen()) {
|
2014-05-28 20:53:34 -07:00
|
|
|
emojiToggle.performClick();
|
|
|
|
}
|
|
|
|
}
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|
2012-08-03 17:34:09 -07:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setComposeText(String text) {
|
|
|
|
this.composeText.setText(text);
|
|
|
|
}
|
2013-06-27 20:57:27 -07:00
|
|
|
|
2015-03-31 13:36:04 -07:00
|
|
|
@Override
|
|
|
|
public void setThreadId(long threadId) {
|
|
|
|
this.threadId = threadId;
|
|
|
|
}
|
|
|
|
|
2014-04-15 12:43:14 +02:00
|
|
|
@Override
|
|
|
|
public void onAttachmentChanged() {
|
|
|
|
initializeSecurity();
|
2015-05-18 10:26:32 -07:00
|
|
|
updateToggleButtonState();
|
2014-04-15 12:43:14 +02:00
|
|
|
}
|
2012-07-19 14:22:03 -07:00
|
|
|
}
|