forked from mirror/monocles_chat
Correct thread is needed to sync WebXDCs
This commit is contained in:
parent
7812877f32
commit
e73245e6e8
3 changed files with 20 additions and 59 deletions
|
@ -751,10 +751,8 @@ public class XmppConnectionService extends Service {
|
||||||
encryption = Message.ENCRYPTION_DECRYPTED;
|
encryption = Message.ENCRYPTION_DECRYPTED;
|
||||||
}
|
}
|
||||||
Message message = new Message(conversation, uri.toString(), encryption);
|
Message message = new Message(conversation, uri.toString(), encryption);
|
||||||
if (subject != null && subject.length() > 0) message.setSubject(subject);
|
if (subject != null && !subject.isEmpty()) message.setSubject(subject);
|
||||||
if (getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
message.setThread(conversation.getThread());
|
||||||
message.setThread(conversation.getThread());
|
|
||||||
}
|
|
||||||
Message.configurePrivateMessage(message);
|
Message.configurePrivateMessage(message);
|
||||||
if (encryption == Message.ENCRYPTION_DECRYPTED) {
|
if (encryption == Message.ENCRYPTION_DECRYPTED) {
|
||||||
getPgpEngine().encrypt(message, callback);
|
getPgpEngine().encrypt(message, callback);
|
||||||
|
@ -775,10 +773,8 @@ public class XmppConnectionService extends Service {
|
||||||
if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
|
if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
||||||
}
|
}
|
||||||
if (subject != null && subject.length() > 0) message.setSubject(subject);
|
if (subject != null && !subject.isEmpty()) message.setSubject(subject);
|
||||||
if (getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
message.setThread(conversation.getThread());
|
||||||
message.setThread(conversation.getThread());
|
|
||||||
}
|
|
||||||
if (!Message.configurePrivateFileMessage(message)) {
|
if (!Message.configurePrivateFileMessage(message)) {
|
||||||
message.setCounterpart(conversation.getNextCounterpart());
|
message.setCounterpart(conversation.getNextCounterpart());
|
||||||
message.setType(Message.TYPE_FILE);
|
message.setType(Message.TYPE_FILE);
|
||||||
|
@ -824,10 +820,8 @@ public class XmppConnectionService extends Service {
|
||||||
if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
|
if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
||||||
}
|
}
|
||||||
if (subject != null && subject.length() > 0) message.setSubject(subject);
|
if (subject != null && !subject.isEmpty()) message.setSubject(subject);
|
||||||
if (getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
message.setThread(conversation.getThread());
|
||||||
message.setThread(conversation.getThread());
|
|
||||||
}
|
|
||||||
if (!Message.configurePrivateFileMessage(message)) {
|
if (!Message.configurePrivateFileMessage(message)) {
|
||||||
message.setCounterpart(conversation.getNextCounterpart());
|
message.setCounterpart(conversation.getNextCounterpart());
|
||||||
message.setType(Message.TYPE_IMAGE);
|
message.setType(Message.TYPE_IMAGE);
|
||||||
|
|
|
@ -482,9 +482,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||||
if (AbsListView.OnScrollListener.SCROLL_STATE_IDLE == scrollState) {
|
if (AbsListView.OnScrollListener.SCROLL_STATE_IDLE == scrollState) {
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
updateThreadFromLastMessage();
|
||||||
updateThreadFromLastMessage();
|
|
||||||
}
|
|
||||||
fireReadEvent();
|
fireReadEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1031,9 +1029,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
conversation.setUserSelectedThread(false);
|
conversation.setUserSelectedThread(false);
|
||||||
setThread(null);
|
setThread(null);
|
||||||
refresh();
|
refresh();
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
updateThreadFromLastMessage();
|
||||||
updateThreadFromLastMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1460,9 +1456,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasSubject) message.setSubject(binding.textinputSubject.getText().toString());
|
if (hasSubject) message.setSubject(binding.textinputSubject.getText().toString());
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
message.setThread(conversation.getThread());
|
||||||
message.setThread(conversation.getThread());
|
|
||||||
}
|
|
||||||
if (attention) {
|
if (attention) {
|
||||||
message.addPayload(new Element("attention", "urn:xmpp:attention:0"));
|
message.addPayload(new Element("attention", "urn:xmpp:attention:0"));
|
||||||
}
|
}
|
||||||
|
@ -1470,9 +1464,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
} else {
|
} else {
|
||||||
message = conversation.getCorrectingMessage();
|
message = conversation.getCorrectingMessage();
|
||||||
if (hasSubject) message.setSubject(binding.textinputSubject.getText().toString());
|
if (hasSubject) message.setSubject(binding.textinputSubject.getText().toString());
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
message.setThread(conversation.getThread());
|
||||||
message.setThread(conversation.getThread());
|
|
||||||
}
|
|
||||||
if (conversation.getReplyTo() != null) {
|
if (conversation.getReplyTo() != null) {
|
||||||
if (Emoticons.isEmoji(body.toString().replaceAll("\\s", ""))) {
|
if (Emoticons.isEmoji(body.toString().replaceAll("\\s", ""))) {
|
||||||
message.updateReaction(conversation.getReplyTo(), body.toString().replaceAll("\\s", ""));
|
message.updateReaction(conversation.getReplyTo(), body.toString().replaceAll("\\s", ""));
|
||||||
|
@ -1980,9 +1972,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
setThread(null);
|
setThread(null);
|
||||||
conversation.setUserSelectedThread(false);
|
conversation.setUserSelectedThread(false);
|
||||||
refresh();
|
refresh();
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
updateThreadFromLastMessage();
|
||||||
updateThreadFromLastMessage();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
newThread();
|
newThread();
|
||||||
conversation.setUserSelectedThread(true);
|
conversation.setUserSelectedThread(true);
|
||||||
|
@ -2221,9 +2211,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setThread(Element thread) {
|
private void setThread(Element thread) {
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
this.conversation.setThread(thread);
|
||||||
this.conversation.setThread(thread);
|
|
||||||
}
|
|
||||||
binding.threadIdenticon.setAlpha(0f);
|
binding.threadIdenticon.setAlpha(0f);
|
||||||
binding.threadIdenticonLock.setVisibility(this.conversation.getLockThread() ? View.VISIBLE : GONE);
|
binding.threadIdenticonLock.setVisibility(this.conversation.getLockThread() ? View.VISIBLE : GONE);
|
||||||
if (thread != null) {
|
if (thread != null) {
|
||||||
|
@ -2337,9 +2325,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
MenuItem showLog = menu.findItem(R.id.show_edit_log);
|
MenuItem showLog = menu.findItem(R.id.show_edit_log);
|
||||||
MenuItem showErrorMessage = menu.findItem(R.id.show_error_message);
|
MenuItem showErrorMessage = menu.findItem(R.id.show_error_message);
|
||||||
MenuItem saveFile = menu.findItem(R.id.save_file);
|
MenuItem saveFile = menu.findItem(R.id.save_file);
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
onlyThisThread.setVisible(!conversation.getLockThread() && m.getThread() != null);
|
||||||
onlyThisThread.setVisible(!conversation.getLockThread() && m.getThread() != null);
|
|
||||||
}
|
|
||||||
final boolean unInitiatedButKnownSize = MessageUtils.unInitiatedButKnownSize(m);
|
final boolean unInitiatedButKnownSize = MessageUtils.unInitiatedButKnownSize(m);
|
||||||
final boolean showError = m.getStatus() == Message.STATUS_SEND_FAILED && m.getErrorMessage() != null && !Message.ERROR_MESSAGE_CANCELLED.equals(m.getErrorMessage());
|
final boolean showError = m.getStatus() == Message.STATUS_SEND_FAILED && m.getErrorMessage() != null && !Message.ERROR_MESSAGE_CANCELLED.equals(m.getErrorMessage());
|
||||||
final Conversational conversational = m.getConversation();
|
final Conversational conversational = m.getConversation();
|
||||||
|
@ -2582,13 +2568,9 @@ public class ConversationFragment extends XmppFragment
|
||||||
} else if (itemId == R.id.only_this_thread) {
|
} else if (itemId == R.id.only_this_thread) {
|
||||||
conversation.setLockThread(true);
|
conversation.setLockThread(true);
|
||||||
backPressedLeaveSingleThread.setEnabled(true);
|
backPressedLeaveSingleThread.setEnabled(true);
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
setThread(selectedMessage.getThread());
|
||||||
setThread(selectedMessage.getThread());
|
|
||||||
}
|
|
||||||
refresh();
|
refresh();
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
setThread(selectedMessage.getThread());
|
||||||
setThread(selectedMessage.getThread());
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.message_reaction) {
|
} else if (itemId == R.id.message_reaction) {
|
||||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||||
|
@ -2718,9 +2700,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
setThread(null);
|
setThread(null);
|
||||||
conversation.setUserSelectedThread(false);
|
conversation.setUserSelectedThread(false);
|
||||||
refresh();
|
refresh();
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
updateThreadFromLastMessage();
|
||||||
updateThreadFromLastMessage();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (binding.emojisStickerLayout.getHeight() > 100){
|
if (binding.emojisStickerLayout.getHeight() > 100){
|
||||||
|
@ -3700,9 +3680,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
private void newThread() {
|
private void newThread() {
|
||||||
Element thread = new Element("thread", "jabber:client");
|
Element thread = new Element("thread", "jabber:client");
|
||||||
thread.setContent(UUID.randomUUID().toString());
|
thread.setContent(UUID.randomUUID().toString());
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
setThread(thread);
|
||||||
setThread(thread);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateThreadFromLastMessage() {
|
private void updateThreadFromLastMessage() {
|
||||||
|
@ -4077,9 +4055,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
while (message.mergeable(message.next())) {
|
while (message.mergeable(message.next())) {
|
||||||
message = message.next();
|
message = message.next();
|
||||||
}
|
}
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
setThread(message.getThread());
|
||||||
setThread(message.getThread());
|
|
||||||
}
|
|
||||||
conversation.setUserSelectedThread(true);
|
conversation.setUserSelectedThread(true);
|
||||||
this.conversation.setCorrectingMessage(message);
|
this.conversation.setCorrectingMessage(message);
|
||||||
final Editable editable = binding.textinput.getText();
|
final Editable editable = binding.textinput.getText();
|
||||||
|
@ -4341,9 +4317,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
activity.onConversationArchived(this.conversation);
|
activity.onConversationArchived(this.conversation);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
setThread(conversation.getThread());
|
||||||
setThread(conversation.getThread());
|
|
||||||
}
|
|
||||||
setupReply(conversation.getReplyTo());
|
setupReply(conversation.getReplyTo());
|
||||||
|
|
||||||
stopScrolling();
|
stopScrolling();
|
||||||
|
|
|
@ -1447,9 +1447,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
viewHolder.transfer = view.findViewById(R.id.transfer);
|
viewHolder.transfer = view.findViewById(R.id.transfer);
|
||||||
viewHolder.progressBar = view.findViewById(R.id.progressBar);
|
viewHolder.progressBar = view.findViewById(R.id.progressBar);
|
||||||
viewHolder.cancel_transfer = view.findViewById(R.id.cancel_transfer);
|
viewHolder.cancel_transfer = view.findViewById(R.id.cancel_transfer);
|
||||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
viewHolder.thread_identicon = view.findViewById(R.id.thread_identicon);
|
||||||
viewHolder.thread_identicon = view.findViewById(R.id.thread_identicon);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case RECEIVED:
|
case RECEIVED:
|
||||||
view = activity.getLayoutInflater().inflate(R.layout.message_received, parent, false);
|
view = activity.getLayoutInflater().inflate(R.layout.message_received, parent, false);
|
||||||
|
@ -1753,11 +1751,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
} else if (message.getFileParams().runtime > 0 && (message.getFileParams().width == 0 && message.getFileParams().height == 0)) {
|
} else if (message.getFileParams().runtime > 0 && (message.getFileParams().width == 0 && message.getFileParams().height == 0)) {
|
||||||
displayAudioMessage(viewHolder, message, darkBackground, type);
|
displayAudioMessage(viewHolder, message, darkBackground, type);
|
||||||
} else if ("application/xdc+zip".equals(message.getFileParams().getMediaType()) && message.getConversation() instanceof Conversation && !message.getFileParams().getCids().isEmpty()) {
|
} else if ("application/xdc+zip".equals(message.getFileParams().getMediaType()) && message.getConversation() instanceof Conversation && !message.getFileParams().getCids().isEmpty()) {
|
||||||
if (message.getThread() == null) {
|
|
||||||
Element thread = new Element("thread", "jabber:client");
|
|
||||||
thread.setContent(UUID.randomUUID().toString());
|
|
||||||
message.setThread(thread);
|
|
||||||
}
|
|
||||||
displayWebxdcMessage(viewHolder, message, darkBackground, type);
|
displayWebxdcMessage(viewHolder, message, darkBackground, type);
|
||||||
} else {
|
} else {
|
||||||
displayOpenableMessage(viewHolder, message, darkBackground, type);
|
displayOpenableMessage(viewHolder, message, darkBackground, type);
|
||||||
|
|
Loading…
Add table
Reference in a new issue