diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/ConversationFragment.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 7b52a1c2d..84af05329 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -109,6 +109,7 @@ import de.pixart.messenger.utils.StylingHelper; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.xmpp.XmppConnection; import de.pixart.messenger.xmpp.chatstate.ChatState; +import de.pixart.messenger.xmpp.jid.InvalidJidException; import de.pixart.messenger.xmpp.jid.Jid; import static de.pixart.messenger.ui.XmppActivity.EXTRA_ACCOUNT; @@ -142,6 +143,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public Uri mPendingEditorContent = null; private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>(); private final PendingItem<String> pendingConversationsUuid = new PendingItem<>(); + private final PendingItem<Bundle> pendingExtras = new PendingItem<>(); protected MessageAdapter messageListAdapter; private Conversation conversation; public FragmentConversationBinding binding; @@ -1721,7 +1723,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke conversation.getAccount().getPgpDecryptionService().decrypt(message, false); } - protected void privateMessageWith(final Jid counterpart) { + private void privateMessageWith(final Jid counterpart) { if (conversation.setOutgoingChatState(Config.DEFAULT_CHATSTATE)) { activity.xmppConnectionService.sendChatState(conversation); } @@ -1744,7 +1746,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } - protected void highlightInConference(String nick) { + private void highlightInConference(String nick) { final Editable editable = this.binding.textinput.getText(); String oldString = editable.toString().trim(); final int pos = this.binding.textinput.getSelectionStart(); @@ -1780,7 +1782,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke @Override public void onActivityCreated(Bundle savedInstanceState) { - Log.d(Config.LOGTAG, "ConversationFragment.onActivityCreated()"); super.onActivityCreated(savedInstanceState); if (savedInstanceState == null) { return; @@ -1795,6 +1796,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public void onStart() { super.onStart(); reInit(conversation); + final Bundle extras = pendingExtras.pop(); + if (extras != null) { + processExtras(extras); + } } @Override @@ -1821,7 +1826,18 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } - public void reInit(Conversation conversation) { + public void reInit(Conversation conversation, Bundle extras) { + this.reInit(conversation); + if (extras != null) { + if (activity != null) { + processExtras(extras); + } else { + pendingExtras.push(extras); + } + } + } + + private void reInit(Conversation conversation) { Log.d(Config.LOGTAG, "reInit()"); if (conversation == null) { Log.d(Config.LOGTAG, "conversation was null :("); @@ -1886,6 +1902,32 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } + private void processExtras(Bundle extras) { + final String downloadUuid = extras.getString(ConversationActivity.EXTRA_DOWNLOAD_UUID); + final String text = extras.getString(ConversationActivity.EXTRA_TEXT); + final String nick = extras.getString(ConversationActivity.EXTRA_NICK); + final boolean pm = extras.getBoolean(ConversationActivity.EXTRA_IS_PRIVATE_MESSAGE, false); + if (nick != null) { + if (pm) { + Jid jid = conversation.getJid(); + try { + Jid next = Jid.fromParts(jid.getLocalpart(), jid.getDomainpart(), nick); + privateMessageWith(next); + } catch (final InvalidJidException ignored) { + //do nothing + } + } else { + highlightInConference(nick); + } + } else { + appendText(text); + } + final Message message = downloadUuid == null ? null : conversation.findMessageWithFileAndUuid(downloadUuid); + if (message != null) { + startDownloadable(message); + } + } + private boolean showBlockSubmenu(View view) { final Jid jid = conversation.getJid(); if (jid.isDomainJid()) { |