2014-02-28 17:46:01 +00:00
|
|
|
package eu.siacs.conversations.ui;
|
2014-01-24 01:04:05 +00:00
|
|
|
|
2015-07-19 16:36:28 +00:00
|
|
|
import android.app.Activity;
|
2014-02-16 15:32:15 +00:00
|
|
|
import android.app.AlertDialog;
|
2014-01-24 01:04:05 +00:00
|
|
|
import android.app.Fragment;
|
2014-05-01 20:33:49 +00:00
|
|
|
import android.app.PendingIntent;
|
2015-07-12 18:17:12 +00:00
|
|
|
import android.content.ActivityNotFoundException;
|
2014-07-31 11:26:05 +00:00
|
|
|
import android.content.Context;
|
2014-02-16 15:32:15 +00:00
|
|
|
import android.content.DialogInterface;
|
2014-03-04 01:51:01 +00:00
|
|
|
import android.content.Intent;
|
2014-02-27 23:22:56 +00:00
|
|
|
import android.content.IntentSender.SendIntentException;
|
2014-01-24 01:04:05 +00:00
|
|
|
import android.os.Bundle;
|
2016-05-12 08:39:04 +00:00
|
|
|
import android.os.Handler;
|
2015-10-15 22:21:47 +00:00
|
|
|
import android.support.annotation.Nullable;
|
2015-01-14 20:28:27 +00:00
|
|
|
import android.text.InputType;
|
2014-10-23 19:27:41 +00:00
|
|
|
import android.view.ContextMenu;
|
|
|
|
import android.view.ContextMenu.ContextMenuInfo;
|
2014-06-01 16:52:27 +00:00
|
|
|
import android.view.Gravity;
|
2014-07-31 11:26:05 +00:00
|
|
|
import android.view.KeyEvent;
|
2014-01-24 01:04:05 +00:00
|
|
|
import android.view.LayoutInflater;
|
2014-10-23 19:27:41 +00:00
|
|
|
import android.view.MenuItem;
|
2014-01-24 01:04:05 +00:00
|
|
|
import android.view.View;
|
2014-01-26 02:27:55 +00:00
|
|
|
import android.view.View.OnClickListener;
|
2014-01-24 01:04:05 +00:00
|
|
|
import android.view.ViewGroup;
|
2014-07-31 11:26:05 +00:00
|
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
|
import android.view.inputmethod.InputMethodManager;
|
2014-06-14 14:59:07 +00:00
|
|
|
import android.widget.AbsListView;
|
2014-11-04 17:52:29 +00:00
|
|
|
import android.widget.AbsListView.OnScrollListener;
|
2014-10-23 19:27:41 +00:00
|
|
|
import android.widget.AdapterView;
|
|
|
|
import android.widget.AdapterView.AdapterContextMenuInfo;
|
2014-01-26 02:27:55 +00:00
|
|
|
import android.widget.ImageButton;
|
2014-11-04 17:52:29 +00:00
|
|
|
import android.widget.ListView;
|
2014-07-09 19:45:03 +00:00
|
|
|
import android.widget.RelativeLayout;
|
2014-01-26 02:27:55 +00:00
|
|
|
import android.widget.TextView;
|
2014-11-04 17:52:29 +00:00
|
|
|
import android.widget.TextView.OnEditorActionListener;
|
2014-03-04 03:09:15 +00:00
|
|
|
import android.widget.Toast;
|
2014-01-24 01:04:05 +00:00
|
|
|
|
2014-11-04 17:52:29 +00:00
|
|
|
import net.java.otr4j.session.SessionStatus;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2015-09-27 17:17:44 +00:00
|
|
|
import java.util.Collections;
|
2014-11-04 17:52:29 +00:00
|
|
|
import java.util.List;
|
2016-02-15 22:15:04 +00:00
|
|
|
import java.util.UUID;
|
2014-11-04 17:52:29 +00:00
|
|
|
|
2015-02-21 10:06:52 +00:00
|
|
|
import eu.siacs.conversations.Config;
|
2014-11-04 17:52:29 +00:00
|
|
|
import eu.siacs.conversations.R;
|
2015-10-31 21:55:04 +00:00
|
|
|
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
2014-11-04 17:52:29 +00:00
|
|
|
import eu.siacs.conversations.entities.Account;
|
|
|
|
import eu.siacs.conversations.entities.Contact;
|
|
|
|
import eu.siacs.conversations.entities.Conversation;
|
2014-11-15 14:16:40 +00:00
|
|
|
import eu.siacs.conversations.entities.DownloadableFile;
|
2014-11-04 17:52:29 +00:00
|
|
|
import eu.siacs.conversations.entities.Message;
|
|
|
|
import eu.siacs.conversations.entities.MucOptions;
|
2016-01-17 21:28:38 +00:00
|
|
|
import eu.siacs.conversations.entities.Presence;
|
2015-07-20 12:26:29 +00:00
|
|
|
import eu.siacs.conversations.entities.Transferable;
|
|
|
|
import eu.siacs.conversations.entities.TransferablePlaceholder;
|
2016-03-04 10:24:40 +00:00
|
|
|
import eu.siacs.conversations.http.HttpDownloadConnection;
|
2016-02-21 16:32:46 +00:00
|
|
|
import eu.siacs.conversations.services.MessageArchiveService;
|
2014-11-04 17:52:29 +00:00
|
|
|
import eu.siacs.conversations.services.XmppConnectionService;
|
|
|
|
import eu.siacs.conversations.ui.XmppActivity.OnPresenceSelected;
|
|
|
|
import eu.siacs.conversations.ui.XmppActivity.OnValueEdited;
|
|
|
|
import eu.siacs.conversations.ui.adapter.MessageAdapter;
|
|
|
|
import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureClicked;
|
|
|
|
import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureLongClicked;
|
2015-03-11 14:48:43 +00:00
|
|
|
import eu.siacs.conversations.utils.GeoHelper;
|
2015-05-13 14:23:20 +00:00
|
|
|
import eu.siacs.conversations.utils.UIHelper;
|
2016-02-14 22:53:17 +00:00
|
|
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
2015-02-21 10:06:52 +00:00
|
|
|
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
2014-11-06 19:33:13 +00:00
|
|
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
2014-11-04 17:52:29 +00:00
|
|
|
|
2015-02-21 10:06:52 +00:00
|
|
|
public class ConversationFragment extends Fragment implements EditMessage.KeyboardListener {
|
2014-02-16 15:32:15 +00:00
|
|
|
|
2014-01-27 19:40:42 +00:00
|
|
|
protected Conversation conversation;
|
2014-07-18 10:44:33 +00:00
|
|
|
private OnClickListener leaveMuc = new OnClickListener() {
|
2014-07-18 17:36:29 +00:00
|
|
|
|
2014-07-18 10:44:33 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
activity.endConversation(conversation);
|
|
|
|
}
|
|
|
|
};
|
2014-10-06 11:34:19 +00:00
|
|
|
private OnClickListener joinMuc = new OnClickListener() {
|
2014-10-07 13:18:09 +00:00
|
|
|
|
2014-10-06 11:34:19 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
activity.xmppConnectionService.joinMuc(conversation);
|
|
|
|
}
|
|
|
|
};
|
2014-09-03 17:35:45 +00:00
|
|
|
private OnClickListener enterPassword = new OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
MucOptions muc = conversation.getMucOptions();
|
|
|
|
String password = muc.getPassword();
|
2014-09-08 18:29:57 +00:00
|
|
|
if (password == null) {
|
2014-09-03 17:35:45 +00:00
|
|
|
password = "";
|
|
|
|
}
|
2014-09-04 09:46:13 +00:00
|
|
|
activity.quickPasswordEdit(password, new OnValueEdited() {
|
2014-09-08 18:29:57 +00:00
|
|
|
|
2014-09-03 17:35:45 +00:00
|
|
|
@Override
|
|
|
|
public void onValueEdited(String value) {
|
2014-09-08 18:29:57 +00:00
|
|
|
activity.xmppConnectionService.providePasswordForMuc(
|
|
|
|
conversation, value);
|
2014-09-03 17:35:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2014-11-07 14:38:20 +00:00
|
|
|
protected ListView messagesView;
|
2014-11-18 02:10:59 +00:00
|
|
|
final protected List<Message> messageList = new ArrayList<>();
|
2014-11-07 14:38:20 +00:00
|
|
|
protected MessageAdapter messageListAdapter;
|
|
|
|
private EditMessage mEditMessage;
|
|
|
|
private ImageButton mSendButton;
|
|
|
|
private RelativeLayout snackbar;
|
|
|
|
private TextView snackbarMessage;
|
|
|
|
private TextView snackbarAction;
|
2014-12-17 09:50:51 +00:00
|
|
|
private boolean messagesLoaded = true;
|
2014-12-17 08:32:51 +00:00
|
|
|
private Toast messageLoaderToast;
|
2014-12-15 22:06:29 +00:00
|
|
|
|
2014-06-14 14:59:07 +00:00
|
|
|
private OnScrollListener mOnScrollListener = new OnScrollListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onScroll(AbsListView view, int firstVisibleItem,
|
2015-05-02 09:38:56 +00:00
|
|
|
int visibleItemCount, int totalItemCount) {
|
2014-11-18 13:43:15 +00:00
|
|
|
synchronized (ConversationFragment.this.messageList) {
|
2014-12-17 09:50:51 +00:00
|
|
|
if (firstVisibleItem < 5 && messagesLoaded && messageList.size() > 0) {
|
2016-02-04 15:29:17 +00:00
|
|
|
long timestamp;
|
|
|
|
if (messageList.get(0).getType() == Message.TYPE_STATUS && messageList.size() >= 2) {
|
|
|
|
timestamp = messageList.get(1).getTimeSent();
|
|
|
|
} else {
|
|
|
|
timestamp = messageList.get(0).getTimeSent();
|
|
|
|
}
|
2014-11-18 13:43:15 +00:00
|
|
|
messagesLoaded = false;
|
2014-12-15 22:06:29 +00:00
|
|
|
activity.xmppConnectionService.loadMoreMessages(conversation, timestamp, new XmppConnectionService.OnMoreMessagesLoaded() {
|
|
|
|
@Override
|
2015-05-11 05:57:52 +00:00
|
|
|
public void onMoreMessagesLoaded(final int c, Conversation conversation) {
|
2014-12-15 22:06:29 +00:00
|
|
|
if (ConversationFragment.this.conversation != conversation) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2014-12-17 09:50:51 +00:00
|
|
|
final int oldPosition = messagesView.getFirstVisiblePosition();
|
2016-03-03 10:14:59 +00:00
|
|
|
final Message message;
|
|
|
|
if (oldPosition < messageList.size()) {
|
|
|
|
message = messageList.get(oldPosition);
|
|
|
|
} else {
|
|
|
|
message = null;
|
|
|
|
}
|
2015-05-11 05:57:52 +00:00
|
|
|
String uuid = message != null ? message.getUuid() : null;
|
2014-12-17 09:50:51 +00:00
|
|
|
View v = messagesView.getChildAt(0);
|
|
|
|
final int pxOffset = (v == null) ? 0 : v.getTop();
|
2014-12-15 22:06:29 +00:00
|
|
|
ConversationFragment.this.conversation.populateWithMessages(ConversationFragment.this.messageList);
|
|
|
|
updateStatusMessages();
|
|
|
|
messageListAdapter.notifyDataSetChanged();
|
2015-05-11 05:57:52 +00:00
|
|
|
int pos = getIndexOf(uuid,messageList);
|
|
|
|
messagesView.setSelectionFromTop(pos, pxOffset);
|
|
|
|
messagesLoaded = true;
|
|
|
|
if (messageLoaderToast != null) {
|
|
|
|
messageLoaderToast.cancel();
|
2014-12-15 22:06:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-12-17 08:32:51 +00:00
|
|
|
|
|
|
|
@Override
|
2014-12-17 09:50:51 +00:00
|
|
|
public void informUser(final int resId) {
|
|
|
|
|
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (messageLoaderToast != null) {
|
|
|
|
messageLoaderToast.cancel();
|
|
|
|
}
|
|
|
|
if (ConversationFragment.this.conversation != conversation) {
|
|
|
|
return;
|
|
|
|
}
|
2015-05-02 09:38:56 +00:00
|
|
|
messageLoaderToast = Toast.makeText(activity, resId, Toast.LENGTH_LONG);
|
2014-12-17 09:50:51 +00:00
|
|
|
messageLoaderToast.show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-12-17 08:32:51 +00:00
|
|
|
}
|
2014-12-15 22:06:29 +00:00
|
|
|
});
|
|
|
|
|
2014-06-14 14:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2016-05-22 15:52:27 +00:00
|
|
|
|
|
|
|
private int getIndexOf(String uuid, List<Message> messages) {
|
|
|
|
if (uuid == null) {
|
|
|
|
return messages.size() - 1;
|
|
|
|
}
|
|
|
|
for(int i = 0; i < messages.size(); ++i) {
|
|
|
|
if (uuid.equals(messages.get(i).getUuid())) {
|
|
|
|
return i;
|
|
|
|
} else {
|
|
|
|
Message next = messages.get(i);
|
|
|
|
while(next != null && next.wasMergedIntoPrevious()) {
|
|
|
|
if (uuid.equals(next.getUuid())) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
next = next.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-15 22:21:47 +00:00
|
|
|
private final int KEYCHAIN_UNLOCK_NOT_REQUIRED = 0;
|
|
|
|
private final int KEYCHAIN_UNLOCK_REQUIRED = 1;
|
|
|
|
private final int KEYCHAIN_UNLOCK_PENDING = 2;
|
|
|
|
private int keychainUnlock = KEYCHAIN_UNLOCK_NOT_REQUIRED;
|
2014-11-07 14:38:20 +00:00
|
|
|
protected OnClickListener clickToDecryptListener = new OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-10-15 22:21:47 +00:00
|
|
|
if (keychainUnlock == KEYCHAIN_UNLOCK_REQUIRED
|
|
|
|
&& activity.hasPgp() && !conversation.getAccount().getPgpDecryptionService().isRunning()) {
|
|
|
|
keychainUnlock = KEYCHAIN_UNLOCK_PENDING;
|
|
|
|
updateSnackBar(conversation);
|
|
|
|
Message message = getLastPgpDecryptableMessage();
|
|
|
|
if (message != null) {
|
|
|
|
activity.xmppConnectionService.getPgpEngine().decrypt(message, new UiCallback<Message>() {
|
|
|
|
@Override
|
|
|
|
public void success(Message object) {
|
|
|
|
conversation.getAccount().getPgpDecryptionService().onKeychainUnlocked();
|
|
|
|
keychainUnlock = KEYCHAIN_UNLOCK_NOT_REQUIRED;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void error(int errorCode, Message object) {
|
|
|
|
keychainUnlock = KEYCHAIN_UNLOCK_NOT_REQUIRED;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void userInputRequried(PendingIntent pi, Message object) {
|
|
|
|
try {
|
|
|
|
activity.startIntentSenderForResult(pi.getIntentSender(),
|
|
|
|
ConversationActivity.REQUEST_DECRYPT_PGP, null, 0, 0, 0);
|
|
|
|
} catch (SendIntentException e) {
|
|
|
|
keychainUnlock = KEYCHAIN_UNLOCK_NOT_REQUIRED;
|
|
|
|
updatePgpMessages();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-11-07 14:38:20 +00:00
|
|
|
}
|
2015-10-15 22:21:47 +00:00
|
|
|
} else {
|
|
|
|
keychainUnlock = KEYCHAIN_UNLOCK_NOT_REQUIRED;
|
|
|
|
updatePgpMessages();
|
2014-11-07 14:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2014-11-10 21:03:23 +00:00
|
|
|
protected OnClickListener clickToVerify = new OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-05-02 09:38:56 +00:00
|
|
|
activity.verifyOtrSessionDialog(conversation, v);
|
2014-11-10 21:03:23 +00:00
|
|
|
}
|
|
|
|
};
|
2014-11-07 14:38:20 +00:00
|
|
|
private OnEditorActionListener mEditorActionListener = new OnEditorActionListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
|
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
|
|
|
InputMethodManager imm = (InputMethodManager) v.getContext()
|
2015-05-02 09:38:56 +00:00
|
|
|
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
2015-09-04 16:02:53 +00:00
|
|
|
if (imm.isFullscreenMode()) {
|
|
|
|
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
|
|
|
|
}
|
2014-11-07 14:38:20 +00:00
|
|
|
sendMessage();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
private OnClickListener mSendButtonListener = new OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-05-02 09:38:56 +00:00
|
|
|
Object tag = v.getTag();
|
|
|
|
if (tag instanceof SendButtonAction) {
|
|
|
|
SendButtonAction action = (SendButtonAction) tag;
|
|
|
|
switch (action) {
|
|
|
|
case TAKE_PHOTO:
|
|
|
|
activity.attachFile(ConversationActivity.ATTACHMENT_CHOICE_TAKE_PHOTO);
|
|
|
|
break;
|
|
|
|
case SEND_LOCATION:
|
|
|
|
activity.attachFile(ConversationActivity.ATTACHMENT_CHOICE_LOCATION);
|
|
|
|
break;
|
|
|
|
case RECORD_VOICE:
|
|
|
|
activity.attachFile(ConversationActivity.ATTACHMENT_CHOICE_RECORD_VOICE);
|
|
|
|
break;
|
2015-05-26 03:34:58 +00:00
|
|
|
case CHOOSE_PICTURE:
|
|
|
|
activity.attachFile(ConversationActivity.ATTACHMENT_CHOICE_CHOOSE_IMAGE);
|
|
|
|
break;
|
2015-05-03 07:30:30 +00:00
|
|
|
case CANCEL:
|
2016-02-15 22:15:04 +00:00
|
|
|
if (conversation != null) {
|
|
|
|
if (conversation.getCorrectingMessage() != null) {
|
|
|
|
conversation.setCorrectingMessage(null);
|
|
|
|
mEditMessage.getEditableText().clear();
|
|
|
|
}
|
|
|
|
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
|
|
|
conversation.setNextCounterpart(null);
|
|
|
|
}
|
2015-05-03 07:30:30 +00:00
|
|
|
updateChatMsgHint();
|
|
|
|
updateSendButton();
|
|
|
|
}
|
|
|
|
break;
|
2015-05-02 09:38:56 +00:00
|
|
|
default:
|
|
|
|
sendMessage();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
sendMessage();
|
|
|
|
}
|
2014-11-07 14:38:20 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
private OnClickListener clickToMuc = new OnClickListener() {
|
2014-06-14 14:59:07 +00:00
|
|
|
|
2014-11-07 14:38:20 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-05-03 07:30:30 +00:00
|
|
|
Intent intent = new Intent(getActivity(), ConferenceDetailsActivity.class);
|
2014-11-07 14:38:20 +00:00
|
|
|
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
|
|
|
|
intent.putExtra("uuid", conversation.getUuid());
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
};
|
2014-03-28 11:22:09 +00:00
|
|
|
private ConversationActivity activity;
|
2014-10-23 19:27:41 +00:00
|
|
|
private Message selectedMessage;
|
2014-08-25 13:43:50 +00:00
|
|
|
|
2016-02-04 13:39:16 +00:00
|
|
|
public void setMessagesLoaded() {
|
|
|
|
this.messagesLoaded = true;
|
|
|
|
}
|
|
|
|
|
2014-07-31 11:26:05 +00:00
|
|
|
private void sendMessage() {
|
2015-05-20 06:25:00 +00:00
|
|
|
final String body = mEditMessage.getText().toString();
|
|
|
|
if (body.length() == 0 || this.conversation == null) {
|
2014-09-06 22:09:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-02-15 22:15:04 +00:00
|
|
|
final Message message;
|
|
|
|
if (conversation.getCorrectingMessage() == null) {
|
|
|
|
message = new Message(conversation, body, conversation.getNextEncryption());
|
|
|
|
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
|
|
|
if (conversation.getNextCounterpart() != null) {
|
|
|
|
message.setCounterpart(conversation.getNextCounterpart());
|
|
|
|
message.setType(Message.TYPE_PRIVATE);
|
|
|
|
}
|
2014-08-10 13:27:44 +00:00
|
|
|
}
|
2016-02-15 22:15:04 +00:00
|
|
|
} else {
|
|
|
|
message = conversation.getCorrectingMessage();
|
|
|
|
message.setBody(body);
|
|
|
|
message.setEdited(message.getUuid());
|
|
|
|
message.setUuid(UUID.randomUUID().toString());
|
|
|
|
conversation.setCorrectingMessage(null);
|
2014-08-10 13:27:44 +00:00
|
|
|
}
|
2015-07-30 22:52:46 +00:00
|
|
|
switch (conversation.getNextEncryption()) {
|
|
|
|
case Message.ENCRYPTION_OTR:
|
|
|
|
sendOtrMessage(message);
|
|
|
|
break;
|
|
|
|
case Message.ENCRYPTION_PGP:
|
|
|
|
sendPgpMessage(message);
|
|
|
|
break;
|
|
|
|
case Message.ENCRYPTION_AXOLOTL:
|
|
|
|
if(!activity.trustKeysIfNeeded(ConversationActivity.REQUEST_TRUST_KEYS_TEXT)) {
|
|
|
|
sendAxolotlMessage(message);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sendPlainTextMessage(message);
|
2014-07-31 11:26:05 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-13 02:52:41 +00:00
|
|
|
|
2014-02-16 15:32:15 +00:00
|
|
|
public void updateChatMsgHint() {
|
2015-09-13 15:13:46 +00:00
|
|
|
final boolean multi = conversation.getMode() == Conversation.MODE_MULTI;
|
2016-02-15 22:15:04 +00:00
|
|
|
if (conversation.getCorrectingMessage() != null) {
|
|
|
|
this.mEditMessage.setHint(R.string.send_corrected_message);
|
|
|
|
} else if (multi && conversation.getNextCounterpart() != null) {
|
2014-08-25 13:43:50 +00:00
|
|
|
this.mEditMessage.setHint(getString(
|
2015-05-02 09:38:56 +00:00
|
|
|
R.string.send_private_message_to,
|
|
|
|
conversation.getNextCounterpart().getResourcepart()));
|
2015-09-13 15:13:46 +00:00
|
|
|
} else if (multi && !conversation.getMucOptions().participating()) {
|
|
|
|
this.mEditMessage.setHint(R.string.you_are_not_participating);
|
2014-08-22 11:22:07 +00:00
|
|
|
} else {
|
2015-07-30 22:52:46 +00:00
|
|
|
switch (conversation.getNextEncryption()) {
|
2014-11-04 17:52:29 +00:00
|
|
|
case Message.ENCRYPTION_NONE:
|
|
|
|
mEditMessage
|
2015-08-24 19:15:47 +00:00
|
|
|
.setHint(getString(R.string.send_unencrypted_message));
|
2014-11-04 17:52:29 +00:00
|
|
|
break;
|
|
|
|
case Message.ENCRYPTION_OTR:
|
|
|
|
mEditMessage.setHint(getString(R.string.send_otr_message));
|
|
|
|
break;
|
2015-07-08 16:14:28 +00:00
|
|
|
case Message.ENCRYPTION_AXOLOTL:
|
2015-10-31 21:55:04 +00:00
|
|
|
AxolotlService axolotlService = conversation.getAccount().getAxolotlService();
|
2015-12-04 14:35:22 +00:00
|
|
|
if (axolotlService != null && axolotlService.trustedSessionVerified(conversation)) {
|
2015-10-31 21:55:04 +00:00
|
|
|
mEditMessage.setHint(getString(R.string.send_omemo_x509_message));
|
|
|
|
} else {
|
|
|
|
mEditMessage.setHint(getString(R.string.send_omemo_message));
|
|
|
|
}
|
2015-07-08 16:14:28 +00:00
|
|
|
break;
|
2014-11-04 17:52:29 +00:00
|
|
|
case Message.ENCRYPTION_PGP:
|
|
|
|
mEditMessage.setHint(getString(R.string.send_pgp_message));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-08-22 11:22:07 +00:00
|
|
|
}
|
2015-01-25 12:07:31 +00:00
|
|
|
getActivity().invalidateOptionsMenu();
|
2014-02-16 15:32:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-04 12:48:00 +00:00
|
|
|
public void setupIme() {
|
2015-09-07 11:31:24 +00:00
|
|
|
if (activity == null) {
|
|
|
|
return;
|
|
|
|
} else if (activity.usingEnterKey() && activity.enterIsSend()) {
|
2015-09-04 12:48:00 +00:00
|
|
|
mEditMessage.setInputType(mEditMessage.getInputType() & (~InputType.TYPE_TEXT_FLAG_MULTI_LINE));
|
|
|
|
mEditMessage.setInputType(mEditMessage.getInputType() & (~InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE));
|
|
|
|
} else if (activity.usingEnterKey()) {
|
|
|
|
mEditMessage.setInputType(mEditMessage.getInputType() | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
2015-01-14 20:28:27 +00:00
|
|
|
mEditMessage.setInputType(mEditMessage.getInputType() & (~InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE));
|
|
|
|
} else {
|
2015-09-04 12:48:00 +00:00
|
|
|
mEditMessage.setInputType(mEditMessage.getInputType() | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
2015-01-14 20:28:27 +00:00
|
|
|
mEditMessage.setInputType(mEditMessage.getInputType() | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-27 19:40:42 +00:00
|
|
|
@Override
|
2015-09-04 12:48:00 +00:00
|
|
|
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
2015-05-02 09:38:56 +00:00
|
|
|
final View view = inflater.inflate(R.layout.fragment_conversation, container, false);
|
2015-04-20 09:39:38 +00:00
|
|
|
view.setOnClickListener(null);
|
2014-07-31 11:26:05 +00:00
|
|
|
mEditMessage = (EditMessage) view.findViewById(R.id.textinput);
|
|
|
|
mEditMessage.setOnClickListener(new OnClickListener() {
|
2014-07-18 17:36:29 +00:00
|
|
|
|
2014-07-15 18:41:32 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-02-18 12:11:41 +00:00
|
|
|
if (activity != null) {
|
|
|
|
activity.hideConversationsOverview();
|
|
|
|
}
|
2014-07-15 18:41:32 +00:00
|
|
|
}
|
|
|
|
});
|
2014-07-31 11:26:05 +00:00
|
|
|
mEditMessage.setOnEditorActionListener(mEditorActionListener);
|
2014-08-25 13:43:50 +00:00
|
|
|
|
2014-09-10 15:59:57 +00:00
|
|
|
mSendButton = (ImageButton) view.findViewById(R.id.textSendButton);
|
|
|
|
mSendButton.setOnClickListener(this.mSendButtonListener);
|
2014-03-13 02:52:41 +00:00
|
|
|
|
2014-07-09 19:45:03 +00:00
|
|
|
snackbar = (RelativeLayout) view.findViewById(R.id.snackbar);
|
|
|
|
snackbarMessage = (TextView) view.findViewById(R.id.snackbar_message);
|
|
|
|
snackbarAction = (TextView) view.findViewById(R.id.snackbar_action);
|
2014-03-13 02:52:41 +00:00
|
|
|
|
2014-02-27 23:22:56 +00:00
|
|
|
messagesView = (ListView) view.findViewById(R.id.messages_view);
|
2014-06-14 14:59:07 +00:00
|
|
|
messagesView.setOnScrollListener(mOnScrollListener);
|
2014-06-10 15:01:19 +00:00
|
|
|
messagesView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
|
2014-11-18 13:43:15 +00:00
|
|
|
messageListAdapter = new MessageAdapter((ConversationActivity) getActivity(), this.messageList);
|
|
|
|
messageListAdapter.setOnContactPictureClicked(new OnContactPictureClicked() {
|
2014-08-25 13:43:50 +00:00
|
|
|
|
2014-12-21 20:43:58 +00:00
|
|
|
@Override
|
|
|
|
public void onContactPictureClicked(Message message) {
|
|
|
|
if (message.getStatus() <= Message.STATUS_RECEIVED) {
|
|
|
|
if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
|
2016-05-16 12:10:40 +00:00
|
|
|
Jid user = message.getCounterpart();
|
|
|
|
if (user != null && !user.isBareJid()) {
|
2015-07-22 13:57:17 +00:00
|
|
|
if (!message.getConversation().getMucOptions().isUserInRoom(user)) {
|
2016-05-16 12:10:40 +00:00
|
|
|
Toast.makeText(activity,activity.getString(R.string.user_has_left_conference,user.getResourcepart()),Toast.LENGTH_SHORT).show();
|
2014-08-25 13:43:50 +00:00
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
highlightInConference(user.getResourcepart());
|
2014-12-21 20:43:58 +00:00
|
|
|
}
|
|
|
|
} else {
|
2016-04-09 08:59:54 +00:00
|
|
|
if (!message.getContact().isSelf()) {
|
|
|
|
activity.switchToContactDetails(message.getContact(), message.getFingerprint());
|
|
|
|
}
|
2014-08-10 13:27:44 +00:00
|
|
|
}
|
2014-12-21 20:43:58 +00:00
|
|
|
} else {
|
|
|
|
Account account = message.getConversation().getAccount();
|
2016-04-22 19:25:06 +00:00
|
|
|
Intent intent;
|
|
|
|
if (activity.manuallyChangePresence()) {
|
|
|
|
intent = new Intent(activity, SetPresenceActivity.class);
|
|
|
|
intent.putExtra(SetPresenceActivity.EXTRA_ACCOUNT, account.getJid().toBareJid().toString());
|
|
|
|
} else {
|
|
|
|
intent = new Intent(activity, EditAccountActivity.class);
|
|
|
|
intent.putExtra("jid", account.getJid().toBareJid().toString());
|
|
|
|
intent.putExtra("fingerprint", message.getFingerprint());
|
|
|
|
}
|
2014-12-21 20:43:58 +00:00
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-08-25 13:43:50 +00:00
|
|
|
messageListAdapter
|
2015-05-02 09:38:56 +00:00
|
|
|
.setOnContactPictureLongClicked(new OnContactPictureLongClicked() {
|
2014-12-21 20:43:58 +00:00
|
|
|
|
2015-05-02 09:38:56 +00:00
|
|
|
@Override
|
|
|
|
public void onContactPictureLongClicked(Message message) {
|
|
|
|
if (message.getStatus() <= Message.STATUS_RECEIVED) {
|
|
|
|
if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
|
2016-05-16 12:10:40 +00:00
|
|
|
Jid user = message.getCounterpart();
|
|
|
|
if (user != null && !user.isBareJid()) {
|
|
|
|
if (message.getConversation().getMucOptions().isUserInRoom(user)) {
|
|
|
|
privateMessageWith(user);
|
|
|
|
} else {
|
|
|
|
Toast.makeText(activity, activity.getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show();
|
2015-07-22 13:57:17 +00:00
|
|
|
}
|
2015-05-02 09:38:56 +00:00
|
|
|
}
|
2014-08-25 13:43:50 +00:00
|
|
|
}
|
2015-05-02 09:38:56 +00:00
|
|
|
} else {
|
|
|
|
activity.showQrCode();
|
2014-08-25 13:43:50 +00:00
|
|
|
}
|
2014-08-10 13:27:44 +00:00
|
|
|
}
|
2015-05-02 09:38:56 +00:00
|
|
|
});
|
2014-02-02 15:33:34 +00:00
|
|
|
messagesView.setAdapter(messageListAdapter);
|
2014-01-26 02:27:55 +00:00
|
|
|
|
2014-10-23 19:27:41 +00:00
|
|
|
registerForContextMenu(messagesView);
|
|
|
|
|
2014-01-26 02:27:55 +00:00
|
|
|
return view;
|
|
|
|
}
|
2014-08-25 13:43:50 +00:00
|
|
|
|
2014-10-23 19:27:41 +00:00
|
|
|
@Override
|
2016-02-15 22:15:04 +00:00
|
|
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
2014-11-18 13:43:15 +00:00
|
|
|
synchronized (this.messageList) {
|
|
|
|
super.onCreateContextMenu(menu, v, menuInfo);
|
|
|
|
AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
|
|
|
|
this.selectedMessage = this.messageList.get(acmi.position);
|
|
|
|
populateContextMenu(menu);
|
|
|
|
}
|
2014-10-23 19:27:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void populateContextMenu(ContextMenu menu) {
|
2015-01-02 13:27:49 +00:00
|
|
|
final Message m = this.selectedMessage;
|
2016-03-04 10:24:40 +00:00
|
|
|
final Transferable t = m.getTransferable();
|
2016-02-17 15:51:36 +00:00
|
|
|
Message relevantForCorrection = m;
|
|
|
|
while(relevantForCorrection.mergeable(relevantForCorrection.next())) {
|
|
|
|
relevantForCorrection = relevantForCorrection.next();
|
|
|
|
}
|
2015-01-02 13:27:49 +00:00
|
|
|
if (m.getType() != Message.TYPE_STATUS) {
|
2016-03-23 18:23:22 +00:00
|
|
|
final boolean treatAsFile = m.getType() != Message.TYPE_TEXT
|
|
|
|
&& m.getType() != Message.TYPE_PRIVATE
|
|
|
|
&& t == null;
|
2014-10-23 19:27:41 +00:00
|
|
|
activity.getMenuInflater().inflate(R.menu.message_context, menu);
|
|
|
|
menu.setHeaderTitle(R.string.message_options);
|
|
|
|
MenuItem copyText = menu.findItem(R.id.copy_text);
|
2016-02-23 14:30:41 +00:00
|
|
|
MenuItem retryDecryption = menu.findItem(R.id.retry_decryption);
|
2016-02-15 22:15:04 +00:00
|
|
|
MenuItem correctMessage = menu.findItem(R.id.correct_message);
|
2015-01-12 15:42:20 +00:00
|
|
|
MenuItem shareWith = menu.findItem(R.id.share_with);
|
2014-10-23 19:27:41 +00:00
|
|
|
MenuItem sendAgain = menu.findItem(R.id.send_again);
|
|
|
|
MenuItem copyUrl = menu.findItem(R.id.copy_url);
|
2015-07-02 21:13:00 +00:00
|
|
|
MenuItem downloadFile = menu.findItem(R.id.download_file);
|
2014-11-15 11:37:09 +00:00
|
|
|
MenuItem cancelTransmission = menu.findItem(R.id.cancel_transmission);
|
2016-03-23 18:23:22 +00:00
|
|
|
MenuItem deleteFile = menu.findItem(R.id.delete_file);
|
|
|
|
if (!treatAsFile
|
2015-07-02 21:13:00 +00:00
|
|
|
&& !GeoHelper.isGeoUri(m.getBody())
|
|
|
|
&& m.treatAsDownloadable() != Message.Decision.MUST) {
|
|
|
|
copyText.setVisible(true);
|
2015-01-02 13:27:49 +00:00
|
|
|
}
|
2016-02-23 14:30:41 +00:00
|
|
|
if (m.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
|
|
|
|
retryDecryption.setVisible(true);
|
|
|
|
}
|
2016-02-17 15:51:36 +00:00
|
|
|
if (relevantForCorrection.getType() == Message.TYPE_TEXT
|
|
|
|
&& relevantForCorrection.isLastCorrectableMessage()) {
|
2016-02-15 22:15:04 +00:00
|
|
|
correctMessage.setVisible(true);
|
|
|
|
}
|
2016-03-23 18:23:22 +00:00
|
|
|
if (treatAsFile || (GeoHelper.isGeoUri(m.getBody()))) {
|
2015-07-02 21:13:00 +00:00
|
|
|
shareWith.setVisible(true);
|
2015-03-11 14:48:43 +00:00
|
|
|
}
|
2015-07-02 21:13:00 +00:00
|
|
|
if (m.getStatus() == Message.STATUS_SEND_FAILED) {
|
|
|
|
sendAgain.setVisible(true);
|
2014-10-23 19:27:41 +00:00
|
|
|
}
|
2015-07-02 21:13:00 +00:00
|
|
|
if (m.hasFileOnRemoteHost()
|
|
|
|
|| GeoHelper.isGeoUri(m.getBody())
|
2016-03-04 10:24:40 +00:00
|
|
|
|| m.treatAsDownloadable() == Message.Decision.MUST
|
|
|
|
|| (t != null && t instanceof HttpDownloadConnection)) {
|
2015-07-02 21:13:00 +00:00
|
|
|
copyUrl.setVisible(true);
|
2015-05-02 09:38:56 +00:00
|
|
|
}
|
2016-03-04 10:24:40 +00:00
|
|
|
if ((m.getType() == Message.TYPE_TEXT && t == null && m.treatAsDownloadable() != Message.Decision.NEVER)
|
|
|
|
|| (m.isFileOrImage() && t instanceof TransferablePlaceholder && m.hasFileOnRemoteHost())){
|
2015-07-02 21:13:00 +00:00
|
|
|
downloadFile.setVisible(true);
|
|
|
|
downloadFile.setTitle(activity.getString(R.string.download_x_file,UIHelper.getFileDescriptionString(activity, m)));
|
2015-05-02 09:38:56 +00:00
|
|
|
}
|
2016-03-04 10:24:40 +00:00
|
|
|
if ((t != null && !(t instanceof TransferablePlaceholder))
|
2015-05-02 09:38:56 +00:00
|
|
|
|| (m.isFileOrImage() && (m.getStatus() == Message.STATUS_WAITING
|
2015-07-02 21:13:00 +00:00
|
|
|
|| m.getStatus() == Message.STATUS_OFFERED))) {
|
|
|
|
cancelTransmission.setVisible(true);
|
2015-05-02 09:38:56 +00:00
|
|
|
}
|
2016-03-23 18:23:22 +00:00
|
|
|
if (treatAsFile) {
|
|
|
|
deleteFile.setVisible(true);
|
|
|
|
deleteFile.setTitle(activity.getString(R.string.delete_x_file,UIHelper.getFileDescriptionString(activity, m)));
|
|
|
|
}
|
2014-10-23 19:27:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onContextItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
2015-01-12 15:42:20 +00:00
|
|
|
case R.id.share_with:
|
|
|
|
shareWith(selectedMessage);
|
2014-11-04 17:52:29 +00:00
|
|
|
return true;
|
|
|
|
case R.id.copy_text:
|
|
|
|
copyText(selectedMessage);
|
|
|
|
return true;
|
2016-02-15 22:15:04 +00:00
|
|
|
case R.id.correct_message:
|
|
|
|
correctMessage(selectedMessage);
|
|
|
|
return true;
|
2014-11-04 17:52:29 +00:00
|
|
|
case R.id.send_again:
|
|
|
|
resendMessage(selectedMessage);
|
|
|
|
return true;
|
|
|
|
case R.id.copy_url:
|
|
|
|
copyUrl(selectedMessage);
|
|
|
|
return true;
|
2015-07-02 21:13:00 +00:00
|
|
|
case R.id.download_file:
|
|
|
|
downloadFile(selectedMessage);
|
2014-11-04 17:52:29 +00:00
|
|
|
return true;
|
2014-11-15 11:37:09 +00:00
|
|
|
case R.id.cancel_transmission:
|
|
|
|
cancelTransmission(selectedMessage);
|
|
|
|
return true;
|
2016-02-23 14:30:41 +00:00
|
|
|
case R.id.retry_decryption:
|
|
|
|
retryDecryption(selectedMessage);
|
|
|
|
return true;
|
2016-03-23 18:23:22 +00:00
|
|
|
case R.id.delete_file:
|
|
|
|
deleteFile(selectedMessage);
|
|
|
|
return true;
|
2014-11-04 17:52:29 +00:00
|
|
|
default:
|
|
|
|
return super.onContextItemSelected(item);
|
2014-10-23 19:27:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-12 15:42:20 +00:00
|
|
|
private void shareWith(Message message) {
|
2014-10-23 19:27:41 +00:00
|
|
|
Intent shareIntent = new Intent();
|
|
|
|
shareIntent.setAction(Intent.ACTION_SEND);
|
2015-03-11 14:48:43 +00:00
|
|
|
if (GeoHelper.isGeoUri(message.getBody())) {
|
|
|
|
shareIntent.putExtra(Intent.EXTRA_TEXT, message.getBody());
|
|
|
|
shareIntent.setType("text/plain");
|
|
|
|
} else {
|
|
|
|
shareIntent.putExtra(Intent.EXTRA_STREAM,
|
|
|
|
activity.xmppConnectionService.getFileBackend()
|
|
|
|
.getJingleFileUri(message));
|
|
|
|
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
2015-07-01 14:01:18 +00:00
|
|
|
String mime = message.getMimeType();
|
2015-03-11 14:48:43 +00:00
|
|
|
if (mime == null) {
|
2015-10-20 15:41:07 +00:00
|
|
|
mime = "*/*";
|
2015-03-11 14:48:43 +00:00
|
|
|
}
|
|
|
|
shareIntent.setType(mime);
|
2015-01-12 15:42:20 +00:00
|
|
|
}
|
2015-07-12 18:17:12 +00:00
|
|
|
try {
|
|
|
|
activity.startActivity(Intent.createChooser(shareIntent, getText(R.string.share_with)));
|
|
|
|
} catch (ActivityNotFoundException e) {
|
|
|
|
//This should happen only on faulty androids because normally chooser is always available
|
|
|
|
Toast.makeText(activity,R.string.no_application_found_to_open_file,Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
2014-10-23 19:27:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void copyText(Message message) {
|
|
|
|
if (activity.copyTextToClipboard(message.getMergedBody(),
|
2015-05-02 09:38:56 +00:00
|
|
|
R.string.message_text)) {
|
2014-10-23 19:27:41 +00:00
|
|
|
Toast.makeText(activity, R.string.message_copied_to_clipboard,
|
|
|
|
Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-23 18:23:22 +00:00
|
|
|
private void deleteFile(Message message) {
|
|
|
|
if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) {
|
|
|
|
message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
|
|
|
|
activity.updateConversationList();
|
|
|
|
updateMessages();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-23 19:27:41 +00:00
|
|
|
private void resendMessage(Message message) {
|
2014-11-15 14:16:40 +00:00
|
|
|
if (message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) {
|
|
|
|
DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
|
|
|
|
if (!file.exists()) {
|
2015-05-02 09:38:56 +00:00
|
|
|
Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show();
|
2015-07-10 13:11:03 +00:00
|
|
|
message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
|
2016-03-23 18:23:22 +00:00
|
|
|
activity.updateConversationList();
|
|
|
|
updateMessages();
|
2014-11-15 14:16:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2014-10-23 19:27:41 +00:00
|
|
|
activity.xmppConnectionService.resendFailedMessages(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void copyUrl(Message message) {
|
2015-03-11 14:48:43 +00:00
|
|
|
final String url;
|
|
|
|
final int resId;
|
|
|
|
if (GeoHelper.isGeoUri(message.getBody())) {
|
|
|
|
resId = R.string.location;
|
|
|
|
url = message.getBody();
|
2015-07-02 21:13:00 +00:00
|
|
|
} else if (message.hasFileOnRemoteHost()) {
|
|
|
|
resId = R.string.file_url;
|
2015-06-30 15:15:02 +00:00
|
|
|
url = message.getFileParams().url.toString();
|
2015-07-02 21:13:00 +00:00
|
|
|
} else {
|
|
|
|
url = message.getBody().trim();
|
|
|
|
resId = R.string.file_url;
|
2015-03-11 14:48:43 +00:00
|
|
|
}
|
|
|
|
if (activity.copyTextToClipboard(url, resId)) {
|
2014-10-23 19:27:41 +00:00
|
|
|
Toast.makeText(activity, R.string.url_copied_to_clipboard,
|
|
|
|
Toast.LENGTH_SHORT).show();
|
2015-05-02 09:38:56 +00:00
|
|
|
}
|
2014-10-23 19:27:41 +00:00
|
|
|
}
|
|
|
|
|
2015-07-02 21:13:00 +00:00
|
|
|
private void downloadFile(Message message) {
|
2014-10-24 17:30:03 +00:00
|
|
|
activity.xmppConnectionService.getHttpConnectionManager()
|
2015-07-22 10:15:09 +00:00
|
|
|
.createNewDownloadConnection(message,true);
|
2014-10-24 17:30:03 +00:00
|
|
|
}
|
|
|
|
|
2014-11-15 11:37:09 +00:00
|
|
|
private void cancelTransmission(Message message) {
|
2015-07-10 13:11:03 +00:00
|
|
|
Transferable transferable = message.getTransferable();
|
|
|
|
if (transferable != null) {
|
|
|
|
transferable.cancel();
|
2015-01-02 13:27:49 +00:00
|
|
|
} else {
|
2015-05-02 09:38:56 +00:00
|
|
|
activity.xmppConnectionService.markMessage(message, Message.STATUS_SEND_FAILED);
|
2014-11-15 11:37:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-23 14:30:41 +00:00
|
|
|
private void retryDecryption(Message message) {
|
|
|
|
message.setEncryption(Message.ENCRYPTION_PGP);
|
2016-03-23 18:23:22 +00:00
|
|
|
activity.updateConversationList();
|
|
|
|
updateMessages();
|
2016-02-23 14:30:41 +00:00
|
|
|
conversation.getAccount().getPgpDecryptionService().add(message);
|
|
|
|
}
|
|
|
|
|
2014-11-06 19:33:13 +00:00
|
|
|
protected void privateMessageWith(final Jid counterpart) {
|
2014-08-10 13:27:44 +00:00
|
|
|
this.mEditMessage.setText("");
|
2014-11-09 15:21:13 +00:00
|
|
|
this.conversation.setNextCounterpart(counterpart);
|
2014-08-22 11:22:07 +00:00
|
|
|
updateChatMsgHint();
|
2015-05-03 07:30:30 +00:00
|
|
|
updateSendButton();
|
2014-08-10 13:27:44 +00:00
|
|
|
}
|
2014-01-24 22:58:51 +00:00
|
|
|
|
2016-02-15 22:15:04 +00:00
|
|
|
private void correctMessage(Message message) {
|
|
|
|
while(message.mergeable(message.next())) {
|
|
|
|
message = message.next();
|
|
|
|
}
|
|
|
|
this.conversation.setCorrectingMessage(message);
|
|
|
|
this.mEditMessage.getEditableText().clear();
|
|
|
|
this.mEditMessage.getEditableText().append(message.getBody());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-20 09:44:43 +00:00
|
|
|
protected void highlightInConference(String nick) {
|
2014-07-31 11:26:05 +00:00
|
|
|
String oldString = mEditMessage.getText().toString().trim();
|
2014-08-31 15:24:52 +00:00
|
|
|
if (oldString.isEmpty() || mEditMessage.getSelectionStart() == 0) {
|
|
|
|
mEditMessage.getText().insert(0, nick + ": ");
|
2014-05-20 09:44:43 +00:00
|
|
|
} else {
|
2014-09-03 17:35:45 +00:00
|
|
|
if (mEditMessage.getText().charAt(
|
2015-05-02 09:38:56 +00:00
|
|
|
mEditMessage.getSelectionStart() - 1) != ' ') {
|
2014-09-03 17:35:45 +00:00
|
|
|
nick = " " + nick;
|
2015-05-02 09:38:56 +00:00
|
|
|
}
|
2014-09-03 17:35:45 +00:00
|
|
|
mEditMessage.getText().insert(mEditMessage.getSelectionStart(),
|
|
|
|
nick + " ");
|
2014-05-20 09:44:43 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-01 17:29:57 +00:00
|
|
|
|
2014-05-07 10:59:15 +00:00
|
|
|
@Override
|
|
|
|
public void onStop() {
|
|
|
|
super.onStop();
|
2014-05-19 13:39:50 +00:00
|
|
|
if (this.conversation != null) {
|
2015-02-21 10:06:52 +00:00
|
|
|
final String msg = mEditMessage.getText().toString();
|
|
|
|
this.conversation.setNextMessage(msg);
|
2015-05-02 09:38:56 +00:00
|
|
|
updateChatState(this.conversation, msg);
|
2015-02-21 10:06:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateChatState(final Conversation conversation, final String msg) {
|
|
|
|
ChatState state = msg.length() == 0 ? Config.DEFAULT_CHATSTATE : ChatState.PAUSED;
|
|
|
|
Account.State status = conversation.getAccount().getStatus();
|
|
|
|
if (status == Account.State.ONLINE && conversation.setOutgoingChatState(state)) {
|
|
|
|
activity.xmppConnectionService.sendChatState(conversation);
|
2014-05-09 18:46:43 +00:00
|
|
|
}
|
2014-05-07 10:59:15 +00:00
|
|
|
}
|
|
|
|
|
2014-11-07 14:38:20 +00:00
|
|
|
public void reInit(Conversation conversation) {
|
2014-11-17 19:02:46 +00:00
|
|
|
if (conversation == null) {
|
|
|
|
return;
|
|
|
|
}
|
2015-02-21 10:06:52 +00:00
|
|
|
this.activity = (ConversationActivity) getActivity();
|
2015-09-04 12:48:00 +00:00
|
|
|
setupIme();
|
2014-11-07 14:38:20 +00:00
|
|
|
if (this.conversation != null) {
|
2015-02-21 10:06:52 +00:00
|
|
|
final String msg = mEditMessage.getText().toString();
|
|
|
|
this.conversation.setNextMessage(msg);
|
|
|
|
if (this.conversation != conversation) {
|
2015-05-02 09:38:56 +00:00
|
|
|
updateChatState(this.conversation, msg);
|
2015-02-21 10:06:52 +00:00
|
|
|
}
|
2014-12-17 20:05:47 +00:00
|
|
|
this.conversation.trim();
|
2014-01-28 18:21:54 +00:00
|
|
|
}
|
2015-02-21 10:06:52 +00:00
|
|
|
|
2015-10-15 22:21:47 +00:00
|
|
|
this.keychainUnlock = KEYCHAIN_UNLOCK_NOT_REQUIRED;
|
2014-11-07 14:38:20 +00:00
|
|
|
this.conversation = conversation;
|
2015-09-13 15:13:46 +00:00
|
|
|
boolean canWrite = this.conversation.getMode() == Conversation.MODE_SINGLE || this.conversation.getMucOptions().participating();
|
|
|
|
this.mEditMessage.setEnabled(canWrite);
|
|
|
|
this.mSendButton.setEnabled(canWrite);
|
2015-02-21 10:06:52 +00:00
|
|
|
this.mEditMessage.setKeyboardListener(null);
|
2014-11-07 14:38:20 +00:00
|
|
|
this.mEditMessage.setText("");
|
|
|
|
this.mEditMessage.append(this.conversation.getNextMessage());
|
2015-02-21 10:06:52 +00:00
|
|
|
this.mEditMessage.setKeyboardListener(this);
|
2015-08-24 18:56:25 +00:00
|
|
|
messageListAdapter.updatePreferences();
|
2015-02-17 08:53:16 +00:00
|
|
|
this.messagesView.setAdapter(messageListAdapter);
|
2014-08-22 11:22:07 +00:00
|
|
|
updateMessages();
|
2014-12-17 09:50:51 +00:00
|
|
|
this.messagesLoaded = true;
|
2016-05-22 15:52:27 +00:00
|
|
|
synchronized (this.messageList) {
|
|
|
|
final Message first = conversation.getFirstUnreadMessage();
|
|
|
|
final int pos;
|
|
|
|
if (first == null) {
|
|
|
|
pos = Math.max(0,this.messageList.size() - 1);
|
|
|
|
} else {
|
|
|
|
pos = getIndexOf(first.getUuid(), this.messageList);
|
|
|
|
}
|
|
|
|
messagesView.setSelection(pos);
|
2014-12-17 09:50:51 +00:00
|
|
|
}
|
2014-01-24 22:58:51 +00:00
|
|
|
}
|
2014-05-07 10:59:15 +00:00
|
|
|
|
2016-03-06 11:16:29 +00:00
|
|
|
private OnClickListener mEnableAccountListener = new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
final Account account = conversation == null ? null : conversation.getAccount();
|
|
|
|
if (account != null) {
|
|
|
|
account.setOption(Account.OPTION_DISABLED, false);
|
|
|
|
activity.xmppConnectionService.updateAccount(account);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-07 11:17:03 +00:00
|
|
|
private OnClickListener mUnblockClickListener = new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(final View v) {
|
|
|
|
v.post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
v.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (conversation.isDomainBlocked()) {
|
|
|
|
BlockContactDialog.show(activity, activity.xmppConnectionService, conversation);
|
|
|
|
} else {
|
|
|
|
activity.unblockConversation(conversation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
private OnClickListener mAddBackClickListener = new OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-05-02 09:38:56 +00:00
|
|
|
final Contact contact = conversation == null ? null : conversation.getContact();
|
2015-02-07 11:17:03 +00:00
|
|
|
if (contact != null) {
|
|
|
|
activity.xmppConnectionService.createContact(contact);
|
|
|
|
activity.switchToContactDetails(contact);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
private OnClickListener mAnswerSmpClickListener = new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
Intent intent = new Intent(activity, VerifyOTRActivity.class);
|
|
|
|
intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT);
|
|
|
|
intent.putExtra("contact", conversation.getContact().getJid().toBareJid().toString());
|
2016-01-22 19:46:24 +00:00
|
|
|
intent.putExtra(VerifyOTRActivity.EXTRA_ACCOUNT, conversation.getAccount().getJid().toBareJid().toString());
|
2015-05-02 09:38:56 +00:00
|
|
|
intent.putExtra("mode", VerifyOTRActivity.MODE_ANSWER_QUESTION);
|
2015-02-07 11:17:03 +00:00
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
private void updateSnackBar(final Conversation conversation) {
|
|
|
|
final Account account = conversation.getAccount();
|
|
|
|
final Contact contact = conversation.getContact();
|
|
|
|
final int mode = conversation.getMode();
|
2016-03-06 11:16:29 +00:00
|
|
|
if (account.getStatus() == Account.State.DISABLED) {
|
|
|
|
showSnackbar(R.string.this_account_is_disabled, R.string.enable, this.mEnableAccountListener);
|
|
|
|
} else if (conversation.isBlocked()) {
|
2015-05-02 09:38:56 +00:00
|
|
|
showSnackbar(R.string.contact_blocked, R.string.unblock, this.mUnblockClickListener);
|
2015-02-07 11:17:03 +00:00
|
|
|
} else if (!contact.showInRoster() && contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
2015-05-02 09:38:56 +00:00
|
|
|
showSnackbar(R.string.contact_added_you, R.string.add_back, this.mAddBackClickListener);
|
2015-02-07 11:17:03 +00:00
|
|
|
} else if (mode == Conversation.MODE_MULTI
|
2015-05-02 09:38:56 +00:00
|
|
|
&& !conversation.getMucOptions().online()
|
2015-02-07 11:17:03 +00:00
|
|
|
&& account.getStatus() == Account.State.ONLINE) {
|
|
|
|
switch (conversation.getMucOptions().getError()) {
|
2016-02-22 19:19:58 +00:00
|
|
|
case NICK_IN_USE:
|
2015-02-07 11:17:03 +00:00
|
|
|
showSnackbar(R.string.nick_in_use, R.string.edit, clickToMuc);
|
|
|
|
break;
|
2016-02-22 19:19:58 +00:00
|
|
|
case NO_RESPONSE:
|
|
|
|
showSnackbar(R.string.joining_conference, 0, null);
|
2015-02-07 11:17:03 +00:00
|
|
|
break;
|
2016-02-22 19:19:58 +00:00
|
|
|
case PASSWORD_REQUIRED:
|
2015-02-07 11:17:03 +00:00
|
|
|
showSnackbar(R.string.conference_requires_password, R.string.enter_password, enterPassword);
|
|
|
|
break;
|
2016-02-22 19:19:58 +00:00
|
|
|
case BANNED:
|
2015-02-07 11:17:03 +00:00
|
|
|
showSnackbar(R.string.conference_banned, R.string.leave, leaveMuc);
|
|
|
|
break;
|
2016-02-22 19:19:58 +00:00
|
|
|
case MEMBERS_ONLY:
|
2015-02-07 11:17:03 +00:00
|
|
|
showSnackbar(R.string.conference_members_only, R.string.leave, leaveMuc);
|
|
|
|
break;
|
2016-02-22 19:19:58 +00:00
|
|
|
case KICKED:
|
2015-02-07 11:17:03 +00:00
|
|
|
showSnackbar(R.string.conference_kicked, R.string.join, joinMuc);
|
|
|
|
break;
|
2016-02-22 19:19:58 +00:00
|
|
|
case UNKNOWN:
|
|
|
|
showSnackbar(R.string.conference_unknown_error, R.string.join, joinMuc);
|
|
|
|
break;
|
|
|
|
case SHUTDOWN:
|
|
|
|
showSnackbar(R.string.conference_shutdown, R.string.join, joinMuc);
|
2016-02-01 11:11:40 +00:00
|
|
|
break;
|
2015-02-07 11:17:03 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-10-15 22:21:47 +00:00
|
|
|
} else if (keychainUnlock == KEYCHAIN_UNLOCK_REQUIRED) {
|
2015-05-02 09:38:56 +00:00
|
|
|
showSnackbar(R.string.openpgp_messages_found, R.string.decrypt, clickToDecryptListener);
|
2015-02-07 11:17:03 +00:00
|
|
|
} else if (mode == Conversation.MODE_SINGLE
|
|
|
|
&& conversation.smpRequested()) {
|
2015-05-02 09:38:56 +00:00
|
|
|
showSnackbar(R.string.smp_requested, R.string.verify, this.mAnswerSmpClickListener);
|
2015-02-07 11:17:03 +00:00
|
|
|
} else if (mode == Conversation.MODE_SINGLE
|
2015-05-02 09:38:56 +00:00
|
|
|
&& conversation.hasValidOtrSession()
|
2015-02-07 11:17:03 +00:00
|
|
|
&& (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED)
|
|
|
|
&& (!conversation.isOtrFingerprintVerified())) {
|
|
|
|
showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify, clickToVerify);
|
|
|
|
} else {
|
|
|
|
hideSnackbar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-02 15:33:34 +00:00
|
|
|
public void updateMessages() {
|
2014-11-18 13:43:15 +00:00
|
|
|
synchronized (this.messageList) {
|
|
|
|
if (getView() == null) {
|
|
|
|
return;
|
2014-07-21 14:16:09 +00:00
|
|
|
}
|
2014-11-18 13:43:15 +00:00
|
|
|
final ConversationActivity activity = (ConversationActivity) getActivity();
|
|
|
|
if (this.conversation != null) {
|
2014-12-14 17:10:46 +00:00
|
|
|
conversation.populateWithMessages(ConversationFragment.this.messageList);
|
2015-10-15 22:21:47 +00:00
|
|
|
updatePgpMessages();
|
|
|
|
updateSnackBar(conversation);
|
2014-12-14 17:10:46 +00:00
|
|
|
updateStatusMessages();
|
2014-11-18 13:43:15 +00:00
|
|
|
this.messageListAdapter.notifyDataSetChanged();
|
|
|
|
updateChatMsgHint();
|
|
|
|
if (!activity.isConversationsOverviewVisable() || !activity.isConversationsOverviewHideable()) {
|
2015-01-02 11:04:33 +00:00
|
|
|
activity.sendReadMarkerIfNecessary(conversation);
|
2014-11-18 13:43:15 +00:00
|
|
|
}
|
|
|
|
this.updateSendButton();
|
2014-03-03 04:01:02 +00:00
|
|
|
}
|
2014-02-10 22:12:11 +00:00
|
|
|
}
|
2014-02-02 15:33:34 +00:00
|
|
|
}
|
2014-06-06 09:39:17 +00:00
|
|
|
|
2015-10-15 22:21:47 +00:00
|
|
|
public void updatePgpMessages() {
|
|
|
|
if (keychainUnlock != KEYCHAIN_UNLOCK_PENDING) {
|
|
|
|
if (getLastPgpDecryptableMessage() != null
|
|
|
|
&& !conversation.getAccount().getPgpDecryptionService().isRunning()) {
|
|
|
|
keychainUnlock = KEYCHAIN_UNLOCK_REQUIRED;
|
|
|
|
} else {
|
|
|
|
keychainUnlock = KEYCHAIN_UNLOCK_NOT_REQUIRED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-01 10:18:55 +00:00
|
|
|
|
2015-10-15 22:21:47 +00:00
|
|
|
@Nullable
|
|
|
|
private Message getLastPgpDecryptableMessage() {
|
|
|
|
for (final Message message : this.messageList) {
|
|
|
|
if (message.getEncryption() == Message.ENCRYPTION_PGP
|
|
|
|
&& (message.getStatus() == Message.STATUS_RECEIVED || message.getStatus() >= Message.STATUS_SEND)
|
|
|
|
&& message.getTransferable() == null) {
|
|
|
|
return message;
|
|
|
|
}
|
2014-10-15 00:09:20 +00:00
|
|
|
}
|
2015-10-15 22:21:47 +00:00
|
|
|
return null;
|
2014-10-15 00:09:20 +00:00
|
|
|
}
|
2014-10-15 17:32:12 +00:00
|
|
|
|
2014-06-10 15:01:19 +00:00
|
|
|
private void messageSent() {
|
2014-07-31 11:26:05 +00:00
|
|
|
mEditMessage.setText("");
|
2014-08-10 13:27:44 +00:00
|
|
|
updateChatMsgHint();
|
2016-05-12 08:39:04 +00:00
|
|
|
new Handler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
int size = messageList.size();
|
|
|
|
messagesView.setSelection(size - 1);
|
|
|
|
}
|
|
|
|
});
|
2014-06-10 15:01:19 +00:00
|
|
|
}
|
2014-06-14 14:59:07 +00:00
|
|
|
|
2015-09-07 13:46:22 +00:00
|
|
|
public void setFocusOnInputField() {
|
|
|
|
mEditMessage.requestFocus();
|
|
|
|
}
|
|
|
|
|
2015-05-26 03:34:58 +00:00
|
|
|
enum SendButtonAction {TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE}
|
2015-05-02 09:38:56 +00:00
|
|
|
|
2016-01-17 21:28:38 +00:00
|
|
|
private int getSendButtonImageResource(SendButtonAction action, Presence.Status status) {
|
2015-05-02 09:38:56 +00:00
|
|
|
switch (action) {
|
|
|
|
case TEXT:
|
|
|
|
switch (status) {
|
2016-01-17 21:28:38 +00:00
|
|
|
case CHAT:
|
|
|
|
case ONLINE:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_text_online;
|
2016-01-17 21:28:38 +00:00
|
|
|
case AWAY:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_text_away;
|
2016-01-17 21:28:38 +00:00
|
|
|
case XA:
|
|
|
|
case DND:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_text_dnd;
|
|
|
|
default:
|
|
|
|
return R.drawable.ic_send_text_offline;
|
|
|
|
}
|
|
|
|
case TAKE_PHOTO:
|
|
|
|
switch (status) {
|
2016-01-17 21:28:38 +00:00
|
|
|
case CHAT:
|
|
|
|
case ONLINE:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_photo_online;
|
2016-01-17 21:28:38 +00:00
|
|
|
case AWAY:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_photo_away;
|
2016-01-17 21:28:38 +00:00
|
|
|
case XA:
|
|
|
|
case DND:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_photo_dnd;
|
|
|
|
default:
|
|
|
|
return R.drawable.ic_send_photo_offline;
|
|
|
|
}
|
|
|
|
case RECORD_VOICE:
|
|
|
|
switch (status) {
|
2016-01-17 21:28:38 +00:00
|
|
|
case CHAT:
|
|
|
|
case ONLINE:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_voice_online;
|
2016-01-17 21:28:38 +00:00
|
|
|
case AWAY:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_voice_away;
|
2016-01-17 21:28:38 +00:00
|
|
|
case XA:
|
|
|
|
case DND:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_voice_dnd;
|
|
|
|
default:
|
|
|
|
return R.drawable.ic_send_voice_offline;
|
|
|
|
}
|
|
|
|
case SEND_LOCATION:
|
|
|
|
switch (status) {
|
2016-01-17 21:28:38 +00:00
|
|
|
case CHAT:
|
|
|
|
case ONLINE:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_location_online;
|
2016-01-17 21:28:38 +00:00
|
|
|
case AWAY:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_location_away;
|
2016-01-17 21:28:38 +00:00
|
|
|
case XA:
|
|
|
|
case DND:
|
2015-05-02 09:38:56 +00:00
|
|
|
return R.drawable.ic_send_location_dnd;
|
|
|
|
default:
|
|
|
|
return R.drawable.ic_send_location_offline;
|
|
|
|
}
|
2015-05-03 07:30:30 +00:00
|
|
|
case CANCEL:
|
|
|
|
switch (status) {
|
2016-01-17 21:28:38 +00:00
|
|
|
case CHAT:
|
|
|
|
case ONLINE:
|
2015-05-03 07:30:30 +00:00
|
|
|
return R.drawable.ic_send_cancel_online;
|
2016-01-17 21:28:38 +00:00
|
|
|
case AWAY:
|
2015-05-03 07:30:30 +00:00
|
|
|
return R.drawable.ic_send_cancel_away;
|
2016-01-17 21:28:38 +00:00
|
|
|
case XA:
|
|
|
|
case DND:
|
2015-05-03 07:30:30 +00:00
|
|
|
return R.drawable.ic_send_cancel_dnd;
|
|
|
|
default:
|
|
|
|
return R.drawable.ic_send_cancel_offline;
|
|
|
|
}
|
2015-05-26 03:34:58 +00:00
|
|
|
case CHOOSE_PICTURE:
|
|
|
|
switch (status) {
|
2016-01-17 21:28:38 +00:00
|
|
|
case CHAT:
|
|
|
|
case ONLINE:
|
2015-05-26 03:34:58 +00:00
|
|
|
return R.drawable.ic_send_picture_online;
|
2016-01-17 21:28:38 +00:00
|
|
|
case AWAY:
|
2015-05-26 03:34:58 +00:00
|
|
|
return R.drawable.ic_send_picture_away;
|
2016-01-17 21:28:38 +00:00
|
|
|
case XA:
|
|
|
|
case DND:
|
2015-05-26 03:34:58 +00:00
|
|
|
return R.drawable.ic_send_picture_dnd;
|
|
|
|
default:
|
|
|
|
return R.drawable.ic_send_picture_offline;
|
|
|
|
}
|
2015-05-02 09:38:56 +00:00
|
|
|
}
|
|
|
|
return R.drawable.ic_send_text_offline;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateSendButton() {
|
|
|
|
final Conversation c = this.conversation;
|
|
|
|
final SendButtonAction action;
|
2016-01-17 21:28:38 +00:00
|
|
|
final Presence.Status status;
|
2016-02-15 22:15:04 +00:00
|
|
|
final String text = this.mEditMessage == null ? "" : this.mEditMessage.getText().toString();
|
|
|
|
final boolean empty = text.length() == 0;
|
2015-06-28 22:14:37 +00:00
|
|
|
final boolean conference = c.getMode() == Conversation.MODE_MULTI;
|
2016-02-15 22:15:04 +00:00
|
|
|
if (c.getCorrectingMessage() != null && (empty || text.equals(c.getCorrectingMessage().getBody()))) {
|
|
|
|
action = SendButtonAction.CANCEL;
|
|
|
|
} else if (conference && !c.getAccount().httpUploadAvailable()) {
|
2015-05-03 07:30:30 +00:00
|
|
|
if (empty && c.getNextCounterpart() != null) {
|
|
|
|
action = SendButtonAction.CANCEL;
|
|
|
|
} else {
|
|
|
|
action = SendButtonAction.TEXT;
|
|
|
|
}
|
2015-05-02 09:38:56 +00:00
|
|
|
} else {
|
2015-05-03 07:30:30 +00:00
|
|
|
if (empty) {
|
2015-06-28 22:14:37 +00:00
|
|
|
if (conference && c.getNextCounterpart() != null) {
|
|
|
|
action = SendButtonAction.CANCEL;
|
|
|
|
} else {
|
|
|
|
String setting = activity.getPreferences().getString("quick_action", "recent");
|
|
|
|
if (!setting.equals("none") && UIHelper.receivedLocationQuestion(conversation.getLatestMessage())) {
|
|
|
|
setting = "location";
|
|
|
|
} else if (setting.equals("recent")) {
|
|
|
|
setting = activity.getPreferences().getString("recently_used_quick_action", "text");
|
|
|
|
}
|
|
|
|
switch (setting) {
|
|
|
|
case "photo":
|
|
|
|
action = SendButtonAction.TAKE_PHOTO;
|
|
|
|
break;
|
|
|
|
case "location":
|
|
|
|
action = SendButtonAction.SEND_LOCATION;
|
|
|
|
break;
|
|
|
|
case "voice":
|
|
|
|
action = SendButtonAction.RECORD_VOICE;
|
|
|
|
break;
|
|
|
|
case "picture":
|
|
|
|
action = SendButtonAction.CHOOSE_PICTURE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
action = SendButtonAction.TEXT;
|
|
|
|
break;
|
|
|
|
}
|
2014-09-10 15:59:57 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-05-02 09:38:56 +00:00
|
|
|
action = SendButtonAction.TEXT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (activity.useSendButtonToIndicateStatus() && c != null
|
|
|
|
&& c.getAccount().getStatus() == Account.State.ONLINE) {
|
|
|
|
if (c.getMode() == Conversation.MODE_SINGLE) {
|
|
|
|
status = c.getContact().getMostAvailableStatus();
|
|
|
|
} else {
|
2016-01-17 21:28:38 +00:00
|
|
|
status = c.getMucOptions().online() ? Presence.Status.ONLINE : Presence.Status.OFFLINE;
|
2014-09-10 15:59:57 +00:00
|
|
|
}
|
|
|
|
} else {
|
2016-01-17 21:28:38 +00:00
|
|
|
status = Presence.Status.OFFLINE;
|
2014-09-10 15:59:57 +00:00
|
|
|
}
|
2015-05-02 09:38:56 +00:00
|
|
|
this.mSendButton.setTag(action);
|
|
|
|
this.mSendButton.setImageResource(getSendButtonImageResource(action, status));
|
2014-09-10 15:59:57 +00:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:40:17 +00:00
|
|
|
protected void updateStatusMessages() {
|
2014-11-18 13:43:15 +00:00
|
|
|
synchronized (this.messageList) {
|
2016-02-21 16:32:46 +00:00
|
|
|
if (showLoadMoreMessages(conversation)) {
|
2016-02-04 13:39:16 +00:00
|
|
|
this.messageList.add(0, Message.createLoadMoreMessage(conversation));
|
|
|
|
}
|
2014-11-18 13:43:15 +00:00
|
|
|
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
2015-02-21 10:06:52 +00:00
|
|
|
ChatState state = conversation.getIncomingChatState();
|
|
|
|
if (state == ChatState.COMPOSING) {
|
|
|
|
this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_is_typing, conversation.getName())));
|
|
|
|
} else if (state == ChatState.PAUSED) {
|
|
|
|
this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_has_stopped_typing, conversation.getName())));
|
|
|
|
} else {
|
|
|
|
for (int i = this.messageList.size() - 1; i >= 0; --i) {
|
|
|
|
if (this.messageList.get(i).getStatus() == Message.STATUS_RECEIVED) {
|
2014-11-18 13:43:15 +00:00
|
|
|
return;
|
2015-02-21 10:06:52 +00:00
|
|
|
} else {
|
|
|
|
if (this.messageList.get(i).getStatus() == Message.STATUS_SEND_DISPLAYED) {
|
|
|
|
this.messageList.add(i + 1,
|
|
|
|
Message.createStatusMessage(conversation, getString(R.string.contact_has_read_up_to_this_point, conversation.getName())));
|
|
|
|
return;
|
|
|
|
}
|
2014-11-18 13:43:15 +00:00
|
|
|
}
|
2014-06-04 19:40:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-02-16 15:32:15 +00:00
|
|
|
|
2016-02-21 16:32:46 +00:00
|
|
|
private boolean showLoadMoreMessages(final Conversation c) {
|
2016-02-22 19:28:58 +00:00
|
|
|
final boolean mam = hasMamSupport(c);
|
2016-02-21 16:32:46 +00:00
|
|
|
final MessageArchiveService service = activity.xmppConnectionService.getMessageArchiveService();
|
|
|
|
return mam && (c.getLastClearHistory() != 0 || (c.countMessages() == 0 && c.hasMessagesLeftOnServer() && !service.queryInProgress(c)));
|
|
|
|
}
|
|
|
|
|
2016-02-22 19:28:58 +00:00
|
|
|
private boolean hasMamSupport(final Conversation c) {
|
|
|
|
if (c.getMode() == Conversation.MODE_SINGLE) {
|
|
|
|
final XmppConnection connection = c.getAccount().getXmppConnection();
|
|
|
|
return connection != null && connection.getFeatures().mam();
|
|
|
|
} else {
|
|
|
|
return c.getMucOptions().mamSupport();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-21 16:32:46 +00:00
|
|
|
protected void showSnackbar(final int message, final int action, final OnClickListener clickListener) {
|
2014-07-09 19:45:03 +00:00
|
|
|
snackbar.setVisibility(View.VISIBLE);
|
2014-08-12 21:23:25 +00:00
|
|
|
snackbar.setOnClickListener(null);
|
2014-07-09 19:45:03 +00:00
|
|
|
snackbarMessage.setText(message);
|
2014-08-12 21:23:25 +00:00
|
|
|
snackbarMessage.setOnClickListener(null);
|
2016-02-22 19:19:58 +00:00
|
|
|
snackbarAction.setVisibility(clickListener == null ? View.GONE : View.VISIBLE);
|
|
|
|
if (action != 0) {
|
|
|
|
snackbarAction.setText(action);
|
|
|
|
}
|
2014-07-09 19:45:03 +00:00
|
|
|
snackbarAction.setOnClickListener(clickListener);
|
|
|
|
}
|
2014-07-18 17:36:29 +00:00
|
|
|
|
2014-07-09 19:45:03 +00:00
|
|
|
protected void hideSnackbar() {
|
|
|
|
snackbar.setVisibility(View.GONE);
|
|
|
|
}
|
2014-02-16 18:30:22 +00:00
|
|
|
|
|
|
|
protected void sendPlainTextMessage(Message message) {
|
|
|
|
ConversationActivity activity = (ConversationActivity) getActivity();
|
2014-06-11 19:53:25 +00:00
|
|
|
activity.xmppConnectionService.sendMessage(message);
|
2014-06-10 15:01:19 +00:00
|
|
|
messageSent();
|
2014-02-16 18:30:22 +00:00
|
|
|
}
|
2014-02-19 00:35:23 +00:00
|
|
|
|
2014-02-27 23:22:56 +00:00
|
|
|
protected void sendPgpMessage(final Message message) {
|
2014-05-06 19:34:30 +00:00
|
|
|
final ConversationActivity activity = (ConversationActivity) getActivity();
|
2014-02-27 23:22:56 +00:00
|
|
|
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
2014-05-01 20:33:49 +00:00
|
|
|
final Contact contact = message.getConversation().getContact();
|
2015-12-02 15:43:55 +00:00
|
|
|
if (!activity.hasPgp()) {
|
|
|
|
activity.showInstallPgpDialog();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (conversation.getAccount().getPgpSignature() == null) {
|
2016-05-05 11:17:04 +00:00
|
|
|
activity.announcePgp(conversation.getAccount(), conversation, activity.onOpenPGPKeyPublished);
|
2015-12-02 15:43:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
|
|
|
if (contact.getPgpKeyId() != 0) {
|
|
|
|
xmppService.getPgpEngine().hasKey(contact,
|
|
|
|
new UiCallback<Contact>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void userInputRequried(PendingIntent pi,
|
|
|
|
Contact contact) {
|
|
|
|
activity.runIntent(
|
|
|
|
pi,
|
|
|
|
ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
|
|
|
|
}
|
2014-06-01 17:29:57 +00:00
|
|
|
|
2015-12-02 15:43:55 +00:00
|
|
|
@Override
|
|
|
|
public void success(Contact contact) {
|
|
|
|
messageSent();
|
|
|
|
activity.encryptTextMessage(message);
|
|
|
|
}
|
2014-06-01 17:29:57 +00:00
|
|
|
|
2015-12-02 15:43:55 +00:00
|
|
|
@Override
|
|
|
|
public void error(int error, Contact contact) {
|
|
|
|
System.out.println();
|
|
|
|
}
|
|
|
|
});
|
2014-06-01 17:29:57 +00:00
|
|
|
|
2014-03-03 15:39:19 +00:00
|
|
|
} else {
|
2015-12-02 15:43:55 +00:00
|
|
|
showNoPGPKeyDialog(false,
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog,
|
|
|
|
int which) {
|
|
|
|
conversation
|
|
|
|
.setNextEncryption(Message.ENCRYPTION_NONE);
|
|
|
|
xmppService.databaseBackend
|
|
|
|
.updateConversation(conversation);
|
|
|
|
message.setEncryption(Message.ENCRYPTION_NONE);
|
|
|
|
xmppService.sendMessage(message);
|
|
|
|
messageSent();
|
|
|
|
}
|
|
|
|
});
|
2014-03-03 15:39:19 +00:00
|
|
|
}
|
2014-06-09 19:25:01 +00:00
|
|
|
} else {
|
2015-12-02 15:43:55 +00:00
|
|
|
if (conversation.getMucOptions().pgpKeysInUse()) {
|
|
|
|
if (!conversation.getMucOptions().everybodyHasKeys()) {
|
|
|
|
Toast warning = Toast
|
|
|
|
.makeText(getActivity(),
|
|
|
|
R.string.missing_public_keys,
|
|
|
|
Toast.LENGTH_LONG);
|
|
|
|
warning.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
|
|
|
|
warning.show();
|
|
|
|
}
|
|
|
|
activity.encryptTextMessage(message);
|
|
|
|
messageSent();
|
|
|
|
} else {
|
|
|
|
showNoPGPKeyDialog(true,
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog,
|
|
|
|
int which) {
|
|
|
|
conversation
|
|
|
|
.setNextEncryption(Message.ENCRYPTION_NONE);
|
|
|
|
message.setEncryption(Message.ENCRYPTION_NONE);
|
|
|
|
xmppService.databaseBackend
|
|
|
|
.updateConversation(conversation);
|
|
|
|
xmppService.sendMessage(message);
|
|
|
|
messageSent();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-02-27 23:22:56 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-19 13:39:50 +00:00
|
|
|
|
2014-06-01 17:29:57 +00:00
|
|
|
public void showNoPGPKeyDialog(boolean plural,
|
2015-05-02 09:38:56 +00:00
|
|
|
DialogInterface.OnClickListener listener) {
|
2014-05-19 13:39:50 +00:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
2014-05-08 12:23:09 +00:00
|
|
|
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
2014-06-01 09:24:35 +00:00
|
|
|
if (plural) {
|
|
|
|
builder.setTitle(getString(R.string.no_pgp_keys));
|
|
|
|
builder.setMessage(getText(R.string.contacts_have_no_pgp_keys));
|
|
|
|
} else {
|
|
|
|
builder.setTitle(getString(R.string.no_pgp_key));
|
|
|
|
builder.setMessage(getText(R.string.contact_has_no_pgp_key));
|
|
|
|
}
|
2014-05-08 12:23:09 +00:00
|
|
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
2014-05-19 13:39:50 +00:00
|
|
|
builder.setPositiveButton(getString(R.string.send_unencrypted),
|
|
|
|
listener);
|
2014-05-08 12:23:09 +00:00
|
|
|
builder.create().show();
|
|
|
|
}
|
2014-03-13 02:52:41 +00:00
|
|
|
|
2015-06-25 15:01:42 +00:00
|
|
|
protected void sendAxolotlMessage(final Message message) {
|
|
|
|
final ConversationActivity activity = (ConversationActivity) getActivity();
|
|
|
|
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
|
|
|
xmppService.sendMessage(message);
|
|
|
|
messageSent();
|
|
|
|
}
|
|
|
|
|
2014-02-16 18:30:22 +00:00
|
|
|
protected void sendOtrMessage(final Message message) {
|
2014-06-12 21:04:28 +00:00
|
|
|
final ConversationActivity activity = (ConversationActivity) getActivity();
|
2014-02-16 18:30:22 +00:00
|
|
|
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
2014-11-10 00:24:35 +00:00
|
|
|
activity.selectPresence(message.getConversation(),
|
2014-11-10 21:03:23 +00:00
|
|
|
new OnPresenceSelected() {
|
2014-02-19 00:35:23 +00:00
|
|
|
|
2014-11-10 21:03:23 +00:00
|
|
|
@Override
|
|
|
|
public void onPresenceSelected() {
|
|
|
|
message.setCounterpart(conversation.getNextCounterpart());
|
|
|
|
xmppService.sendMessage(message);
|
|
|
|
messageSent();
|
|
|
|
}
|
|
|
|
});
|
2014-02-16 18:30:22 +00:00
|
|
|
}
|
2014-02-19 00:35:23 +00:00
|
|
|
|
2014-11-07 14:38:20 +00:00
|
|
|
public void appendText(String text) {
|
2015-04-19 17:11:32 +00:00
|
|
|
if (text == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-11-07 14:38:20 +00:00
|
|
|
String previous = this.mEditMessage.getText().toString();
|
|
|
|
if (previous.length() != 0 && !previous.endsWith(" ")) {
|
|
|
|
text = " " + text;
|
|
|
|
}
|
|
|
|
this.mEditMessage.append(text);
|
2014-03-13 20:37:27 +00:00
|
|
|
}
|
2014-05-08 15:31:53 +00:00
|
|
|
|
2015-02-21 10:06:52 +00:00
|
|
|
@Override
|
2015-03-06 21:22:50 +00:00
|
|
|
public boolean onEnterPressed() {
|
|
|
|
if (activity.enterIsSend()) {
|
|
|
|
sendMessage();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2015-02-21 10:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTypingStarted() {
|
|
|
|
Account.State status = conversation.getAccount().getStatus();
|
|
|
|
if (status == Account.State.ONLINE && conversation.setOutgoingChatState(ChatState.COMPOSING)) {
|
|
|
|
activity.xmppConnectionService.sendChatState(conversation);
|
|
|
|
}
|
2015-09-09 21:28:37 +00:00
|
|
|
activity.hideConversationsOverview();
|
2015-05-02 09:38:56 +00:00
|
|
|
updateSendButton();
|
2015-02-21 10:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTypingStopped() {
|
|
|
|
Account.State status = conversation.getAccount().getStatus();
|
|
|
|
if (status == Account.State.ONLINE && conversation.setOutgoingChatState(ChatState.PAUSED)) {
|
|
|
|
activity.xmppConnectionService.sendChatState(conversation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextDeleted() {
|
|
|
|
Account.State status = conversation.getAccount().getStatus();
|
|
|
|
if (status == Account.State.ONLINE && conversation.setOutgoingChatState(Config.DEFAULT_CHATSTATE)) {
|
|
|
|
activity.xmppConnectionService.sendChatState(conversation);
|
|
|
|
}
|
2015-05-02 09:38:56 +00:00
|
|
|
updateSendButton();
|
2015-02-21 10:06:52 +00:00
|
|
|
}
|
|
|
|
|
2016-02-15 22:15:04 +00:00
|
|
|
@Override
|
|
|
|
public void onTextChanged() {
|
|
|
|
if (conversation != null && conversation.getCorrectingMessage() != null) {
|
|
|
|
updateSendButton();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-27 17:17:44 +00:00
|
|
|
private int completionIndex = 0;
|
|
|
|
private int lastCompletionLength = 0;
|
|
|
|
private String incomplete;
|
|
|
|
private int lastCompletionCursor;
|
|
|
|
private boolean firstWord = false;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTabPressed(boolean repeated) {
|
|
|
|
if (conversation == null || conversation.getMode() == Conversation.MODE_SINGLE) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (repeated) {
|
|
|
|
completionIndex++;
|
|
|
|
} else {
|
|
|
|
lastCompletionLength = 0;
|
|
|
|
completionIndex = 0;
|
|
|
|
final String content = mEditMessage.getText().toString();
|
|
|
|
lastCompletionCursor = mEditMessage.getSelectionEnd();
|
|
|
|
int start = lastCompletionCursor > 0 ? content.lastIndexOf(" ",lastCompletionCursor-1) + 1 : 0;
|
|
|
|
firstWord = start == 0;
|
|
|
|
incomplete = content.substring(start,lastCompletionCursor);
|
|
|
|
}
|
|
|
|
List<String> completions = new ArrayList<>();
|
|
|
|
for(MucOptions.User user : conversation.getMucOptions().getUsers()) {
|
|
|
|
if (user.getName().startsWith(incomplete)) {
|
|
|
|
completions.add(user.getName()+(firstWord ? ": " : " "));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Collections.sort(completions);
|
|
|
|
if (completions.size() > completionIndex) {
|
|
|
|
String completion = completions.get(completionIndex).substring(incomplete.length());
|
|
|
|
mEditMessage.getEditableText().delete(lastCompletionCursor,lastCompletionCursor + lastCompletionLength);
|
|
|
|
mEditMessage.getEditableText().insert(lastCompletionCursor, completion);
|
|
|
|
lastCompletionLength = completion.length();
|
|
|
|
} else {
|
|
|
|
completionIndex = -1;
|
|
|
|
mEditMessage.getEditableText().delete(lastCompletionCursor,lastCompletionCursor + lastCompletionLength);
|
|
|
|
lastCompletionLength = 0;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-19 16:36:28 +00:00
|
|
|
@Override
|
|
|
|
public void onActivityResult(int requestCode, int resultCode,
|
|
|
|
final Intent data) {
|
|
|
|
if (resultCode == Activity.RESULT_OK) {
|
2015-10-15 22:21:47 +00:00
|
|
|
if (requestCode == ConversationActivity.REQUEST_DECRYPT_PGP) {
|
|
|
|
activity.getSelectedConversation().getAccount().getPgpDecryptionService().onKeychainUnlocked();
|
|
|
|
keychainUnlock = KEYCHAIN_UNLOCK_NOT_REQUIRED;
|
|
|
|
updatePgpMessages();
|
|
|
|
} else if (requestCode == ConversationActivity.REQUEST_TRUST_KEYS_TEXT) {
|
2015-07-19 16:36:28 +00:00
|
|
|
final String body = mEditMessage.getText().toString();
|
2015-07-30 22:52:46 +00:00
|
|
|
Message message = new Message(conversation, body, conversation.getNextEncryption());
|
2015-07-19 16:36:28 +00:00
|
|
|
sendAxolotlMessage(message);
|
|
|
|
} else if (requestCode == ConversationActivity.REQUEST_TRUST_KEYS_MENU) {
|
|
|
|
int choice = data.getIntExtra("choice", ConversationActivity.ATTACHMENT_CHOICE_INVALID);
|
2015-07-30 22:52:46 +00:00
|
|
|
activity.selectPresenceToAttachFile(choice, conversation.getNextEncryption());
|
2015-07-19 16:36:28 +00:00
|
|
|
}
|
2015-10-15 22:21:47 +00:00
|
|
|
} else {
|
|
|
|
if (requestCode == ConversationActivity.REQUEST_DECRYPT_PGP) {
|
|
|
|
keychainUnlock = KEYCHAIN_UNLOCK_NOT_REQUIRED;
|
|
|
|
updatePgpMessages();
|
|
|
|
}
|
2015-07-19 16:36:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-24 01:04:05 +00:00
|
|
|
}
|