diff options
Diffstat (limited to 'src/main/java/de')
3 files changed, 54 insertions, 15 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index a6c135437..199f98b16 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -186,7 +186,7 @@ public class ConversationActivity extends XmppActivity implements OnConversation } else { mainNeedsRefresh = true; } - conversationFragment.reInit(conversation); + conversationFragment.reInit(conversation, extras); if (mainNeedsRefresh) { refreshFragment(R.id.main_fragment); } else { 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()) { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationLegacyActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationLegacyActivity.java index 9d7573dd2..e8d5381bc 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationLegacyActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationLegacyActivity.java @@ -68,7 +68,6 @@ import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.entities.Account; import de.pixart.messenger.entities.Conversation; -import de.pixart.messenger.entities.Message; import de.pixart.messenger.entities.MucOptions; import de.pixart.messenger.entities.Presence; import de.pixart.messenger.services.EmojiService; @@ -81,8 +80,6 @@ import de.pixart.messenger.ui.adapter.ConversationAdapter; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.xmpp.OnUpdateBlocklist; 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.SettingsActivity.USE_BUNDLED_EMOJIS; @@ -227,7 +224,7 @@ public class ConversationLegacyActivity extends XmppActivity if (getSelectedConversation() != conversationList.get(position)) { ConversationLegacyActivity.this.mConversationFragment.stopScrolling(); setSelectedConversation(conversationList.get(position)); - ConversationLegacyActivity.this.mConversationFragment.reInit(getSelectedConversation()); + //ConversationLegacyActivity.this.mConversationFragment.reInit(getSelectedConversation()); conversationWasSelectedByKeyboard = false; } hideConversationsOverview(); @@ -319,7 +316,7 @@ public class ConversationLegacyActivity extends XmppActivity public void switchToConversation(Conversation conversation) { setSelectedConversation(conversation); runOnUiThread(() -> { - ConversationLegacyActivity.this.mConversationFragment.reInit(getSelectedConversation()); + //ConversationLegacyActivity.this.mConversationFragment.reInit(getSelectedConversation()); openConversation(); }); } @@ -466,7 +463,7 @@ public class ConversationLegacyActivity extends XmppActivity if (reinit) { if (conversationList.size() > 0) { setSelectedConversation(conversationList.get(0)); - this.mConversationFragment.reInit(getSelectedConversation()); + //this.mConversationFragment.reInit(getSelectedConversation()); } else { setSelectedConversation(null); if (mRedirected.compareAndSet(false, true)) { @@ -591,7 +588,7 @@ public class ConversationLegacyActivity extends XmppActivity this.conversationWasSelectedByKeyboard = true; this.mConversationFragment.stopScrolling(); setSelectedConversation(this.conversationList.get(index)); - this.mConversationFragment.reInit(getSelectedConversation()); + //this.mConversationFragment.reInit(getSelectedConversation()); if (index > listView.getLastVisiblePosition() - 1 || index < listView.getFirstVisiblePosition() + 1) { this.listView.setSelection(index); } @@ -830,7 +827,7 @@ public class ConversationLegacyActivity extends XmppActivity showConversationsOverview(); clearPending(); setSelectedConversation(conversationList.get(0)); - this.mConversationFragment.reInit(getSelectedConversation()); + //this.mConversationFragment.reInit(getSelectedConversation()); } private void handleViewConversationIntent(final Intent intent) { @@ -841,7 +838,7 @@ public class ConversationLegacyActivity extends XmppActivity final boolean pm = intent.getBooleanExtra(PRIVATE_MESSAGE, false); this.mConversationFragment.stopScrolling(); if (selectConversationByUuid(uuid)) { - this.mConversationFragment.reInit(getSelectedConversation()); + /*this.mConversationFragment.reInit(getSelectedConversation()); if (nick != null) { if (pm) { Jid jid = getSelectedConversation().getJid(); @@ -868,7 +865,7 @@ public class ConversationLegacyActivity extends XmppActivity if (message != null) { //startDownloadable(message); } - } + }*/ } else { mUnprocessedNewIntent = false; |