process intents
This commit is contained in:
parent
4c8cbfe966
commit
e68fe13a22
|
@ -182,7 +182,7 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
||||||
} else {
|
} else {
|
||||||
mainNeedsRefresh = true;
|
mainNeedsRefresh = true;
|
||||||
}
|
}
|
||||||
conversationFragment.reInit(conversation);
|
conversationFragment.reInit(conversation, extras);
|
||||||
if (mainNeedsRefresh) {
|
if (mainNeedsRefresh) {
|
||||||
refreshFragment(R.id.main_fragment);
|
refreshFragment(R.id.main_fragment);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -95,6 +95,7 @@ import eu.siacs.conversations.utils.StylingHelper;
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
import static eu.siacs.conversations.ui.XmppActivity.EXTRA_ACCOUNT;
|
import static eu.siacs.conversations.ui.XmppActivity.EXTRA_ACCOUNT;
|
||||||
|
@ -128,6 +129,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
final protected List<Message> messageList = new ArrayList<>();
|
final protected List<Message> messageList = new ArrayList<>();
|
||||||
private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
|
private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
|
||||||
private final PendingItem<String> pendingConversationsUuid = new PendingItem<>();
|
private final PendingItem<String> pendingConversationsUuid = new PendingItem<>();
|
||||||
|
private final PendingItem<Bundle> pendingExtras = new PendingItem<>();
|
||||||
public Uri mPendingEditorContent = null;
|
public Uri mPendingEditorContent = null;
|
||||||
protected MessageAdapter messageListAdapter;
|
protected MessageAdapter messageListAdapter;
|
||||||
private Conversation conversation;
|
private Conversation conversation;
|
||||||
|
@ -1485,7 +1487,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
conversation.getAccount().getPgpDecryptionService().decrypt(message, false);
|
conversation.getAccount().getPgpDecryptionService().decrypt(message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void privateMessageWith(final Jid counterpart) {
|
private void privateMessageWith(final Jid counterpart) {
|
||||||
if (conversation.setOutgoingChatState(Config.DEFAULT_CHATSTATE)) {
|
if (conversation.setOutgoingChatState(Config.DEFAULT_CHATSTATE)) {
|
||||||
activity.xmppConnectionService.sendChatState(conversation);
|
activity.xmppConnectionService.sendChatState(conversation);
|
||||||
}
|
}
|
||||||
|
@ -1508,7 +1510,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();
|
final Editable editable = this.binding.textinput.getText();
|
||||||
String oldString = editable.toString().trim();
|
String oldString = editable.toString().trim();
|
||||||
final int pos = this.binding.textinput.getSelectionStart();
|
final int pos = this.binding.textinput.getSelectionStart();
|
||||||
|
@ -1545,7 +1547,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
Log.d(Config.LOGTAG,"ConversationFragment.onActivityCreated()");
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -1560,6 +1561,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
reInit(conversation);
|
reInit(conversation);
|
||||||
|
final Bundle extras = pendingExtras.pop();
|
||||||
|
if (extras != null) {
|
||||||
|
processExtras(extras);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1586,7 +1591,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()");
|
Log.d(Config.LOGTAG, "reInit()");
|
||||||
if (conversation == null) {
|
if (conversation == null) {
|
||||||
Log.d(Config.LOGTAG, "conversation was null :(");
|
Log.d(Config.LOGTAG, "conversation was null :(");
|
||||||
|
@ -1645,6 +1661,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) {
|
private boolean showBlockSubmenu(View view) {
|
||||||
final Jid jid = conversation.getJid();
|
final Jid jid = conversation.getJid();
|
||||||
if (jid.isDomainJid()) {
|
if (jid.isDomainJid()) {
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class ConversationLegacyActivity extends XmppActivity
|
||||||
if (getSelectedConversation() != conversationList.get(position)) {
|
if (getSelectedConversation() != conversationList.get(position)) {
|
||||||
ConversationLegacyActivity.this.mConversationFragment.stopScrolling();
|
ConversationLegacyActivity.this.mConversationFragment.stopScrolling();
|
||||||
setSelectedConversation(conversationList.get(position));
|
setSelectedConversation(conversationList.get(position));
|
||||||
ConversationLegacyActivity.this.mConversationFragment.reInit(getSelectedConversation());
|
//ConversationLegacyActivity.this.mConversationFragment.reInit(getSelectedConversation());
|
||||||
conversationWasSelectedByKeyboard = false;
|
conversationWasSelectedByKeyboard = false;
|
||||||
}
|
}
|
||||||
hideConversationsOverview();
|
hideConversationsOverview();
|
||||||
|
@ -206,8 +206,7 @@ public class ConversationLegacyActivity extends XmppActivity
|
||||||
return null;
|
return null;
|
||||||
} else if (formerlySelected) {
|
} else if (formerlySelected) {
|
||||||
setSelectedConversation(listAdapter.getItem(0));
|
setSelectedConversation(listAdapter.getItem(0));
|
||||||
ConversationLegacyActivity.this.mConversationFragment
|
//ConversationLegacyActivity.this.mConversationFragment.reInit(getSelectedConversation());
|
||||||
.reInit(getSelectedConversation());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EnhancedListView.Undoable() {
|
return new EnhancedListView.Undoable() {
|
||||||
|
@ -217,8 +216,7 @@ public class ConversationLegacyActivity extends XmppActivity
|
||||||
listAdapter.insert(swipedConversation, position);
|
listAdapter.insert(swipedConversation, position);
|
||||||
if (formerlySelected) {
|
if (formerlySelected) {
|
||||||
setSelectedConversation(swipedConversation);
|
setSelectedConversation(swipedConversation);
|
||||||
ConversationLegacyActivity.this.mConversationFragment
|
//ConversationLegacyActivity.this.mConversationFragment.reInit(getSelectedConversation());
|
||||||
.reInit(getSelectedConversation());
|
|
||||||
}
|
}
|
||||||
swipedConversation = null;
|
swipedConversation = null;
|
||||||
listView.setSelectionFromTop(index + (listView.getChildCount() < position ? 1 : 0), top);
|
listView.setSelectionFromTop(index + (listView.getChildCount() < position ? 1 : 0), top);
|
||||||
|
@ -294,7 +292,7 @@ public class ConversationLegacyActivity extends XmppActivity
|
||||||
public void switchToConversation(Conversation conversation) {
|
public void switchToConversation(Conversation conversation) {
|
||||||
setSelectedConversation(conversation);
|
setSelectedConversation(conversation);
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
ConversationLegacyActivity.this.mConversationFragment.reInit(getSelectedConversation());
|
//ConversationLegacyActivity.this.mConversationFragment.reInit(getSelectedConversation());
|
||||||
openConversation();
|
openConversation();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -373,7 +371,7 @@ public class ConversationLegacyActivity extends XmppActivity
|
||||||
if (reinit) {
|
if (reinit) {
|
||||||
if (conversationList.size() > 0) {
|
if (conversationList.size() > 0) {
|
||||||
setSelectedConversation(conversationList.get(0));
|
setSelectedConversation(conversationList.get(0));
|
||||||
this.mConversationFragment.reInit(getSelectedConversation());
|
//this.mConversationFragment.reInit(getSelectedConversation());
|
||||||
} else {
|
} else {
|
||||||
setSelectedConversation(null);
|
setSelectedConversation(null);
|
||||||
if (mRedirected.compareAndSet(false, true)) {
|
if (mRedirected.compareAndSet(false, true)) {
|
||||||
|
@ -497,7 +495,7 @@ public class ConversationLegacyActivity extends XmppActivity
|
||||||
this.conversationWasSelectedByKeyboard = true;
|
this.conversationWasSelectedByKeyboard = true;
|
||||||
this.mConversationFragment.stopScrolling();
|
this.mConversationFragment.stopScrolling();
|
||||||
setSelectedConversation(this.conversationList.get(index));
|
setSelectedConversation(this.conversationList.get(index));
|
||||||
this.mConversationFragment.reInit(getSelectedConversation());
|
//this.mConversationFragment.reInit(getSelectedConversation());
|
||||||
if (index > listView.getLastVisiblePosition() - 1 || index < listView.getFirstVisiblePosition() + 1) {
|
if (index > listView.getLastVisiblePosition() - 1 || index < listView.getFirstVisiblePosition() + 1) {
|
||||||
this.listView.setSelection(index);
|
this.listView.setSelection(index);
|
||||||
}
|
}
|
||||||
|
@ -686,7 +684,7 @@ public class ConversationLegacyActivity extends XmppActivity
|
||||||
showConversationsOverview();
|
showConversationsOverview();
|
||||||
clearPending();
|
clearPending();
|
||||||
setSelectedConversation(conversationList.get(0));
|
setSelectedConversation(conversationList.get(0));
|
||||||
this.mConversationFragment.reInit(getSelectedConversation());
|
//this.mConversationFragment.reInit(getSelectedConversation());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleViewConversationIntent(final Intent intent) {
|
private void handleViewConversationIntent(final Intent intent) {
|
||||||
|
@ -697,7 +695,7 @@ public class ConversationLegacyActivity extends XmppActivity
|
||||||
final boolean pm = intent.getBooleanExtra(PRIVATE_MESSAGE, false);
|
final boolean pm = intent.getBooleanExtra(PRIVATE_MESSAGE, false);
|
||||||
this.mConversationFragment.stopScrolling();
|
this.mConversationFragment.stopScrolling();
|
||||||
if (selectConversationByUuid(uuid)) {
|
if (selectConversationByUuid(uuid)) {
|
||||||
this.mConversationFragment.reInit(getSelectedConversation());
|
/*this.mConversationFragment.reInit(getSelectedConversation());
|
||||||
if (nick != null) {
|
if (nick != null) {
|
||||||
if (pm) {
|
if (pm) {
|
||||||
Jid jid = getSelectedConversation().getJid();
|
Jid jid = getSelectedConversation().getJid();
|
||||||
|
@ -724,7 +722,7 @@ public class ConversationLegacyActivity extends XmppActivity
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
//startDownloadable(message);
|
//startDownloadable(message);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
} else {
|
} else {
|
||||||
mUnprocessedNewIntent = false;
|
mUnprocessedNewIntent = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue