~singpolyma/cheogram-android

c336fc2f4c78d0613b31a0c6a70a7e9f1a6c646b — Stephen Paul Weber 11 months ago 45a3e61
Consider subject and thread part of the correctable content of a message
M src/main/java/eu/siacs/conversations/entities/Message.java => src/main/java/eu/siacs/conversations/entities/Message.java +6 -1
@@ 54,6 54,7 @@ import eu.siacs.conversations.utils.Emoticons;
import eu.siacs.conversations.utils.GeoHelper;
import eu.siacs.conversations.utils.MessageUtils;
import eu.siacs.conversations.utils.MimeUtils;
import eu.siacs.conversations.utils.StringUtils;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.Jid;
import eu.siacs.conversations.xml.Element;


@@ 329,7 330,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable 
        values.put(UUID, uuid);
        values.put("subject", subject);
        values.put("fileParams", fileParams == null ? null : fileParams.toString());
        if (fileParams != null) {
        if (fileParams != null && !fileParams.isEmpty()) {
            List<Element> sims = getSims();
            if (sims.isEmpty()) {
                addPayload(fileParams.toSims());


@@ 1315,6 1316,10 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable 
            }
        }

        public boolean isEmpty() {
            return StringUtils.nullOnEmpty(toString()) == null && StringUtils.nullOnEmpty(toSims().getContent()) == null;
        }

        public long getSize() {
            return size == null ? 0 : size;
        }

M src/main/java/eu/siacs/conversations/parser/MessageParser.java => src/main/java/eu/siacs/conversations/parser/MessageParser.java +2 -0
@@ 745,6 745,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
                            final String uuid = replacedMessage.getUuid();
                            replacedMessage.setUuid(UUID.randomUUID().toString());
                            replacedMessage.setBody(message.getBody());
                            replacedMessage.setSubject(message.getSubject());
                            replacedMessage.setThread(message.getThread());
                            replacedMessage.putEdited(replacedMessage.getRemoteMsgId(), replacedMessage.getServerMsgId());
                            replacedMessage.setRemoteMsgId(remoteMsgId);
                            if (replaceElement != null && !replaceElement.getName().equals("replace")) {

M src/main/java/eu/siacs/conversations/ui/ConversationFragment.java => src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +5 -1
@@ 564,6 564,7 @@ public class ConversationFragment extends XmppFragment
                                break;
                            case CANCEL:
                                if (conversation != null) {
                                    conversation.setUserSelectedThread(false);
                                    if (conversation.setCorrectingMessage(null)) {
                                        binding.textinput.setText("");
                                        binding.textinput.append(conversation.getDraftMessage());


@@ 882,7 883,6 @@ public class ConversationFragment extends XmppFragment
    }

    private void sendMessage() {
        conversation.setUserSelectedThread(false);
        if (mediaPreviewAdapter.hasAttachments()) {
            commitAttachments();
            return;


@@ 922,6 922,7 @@ public class ConversationFragment extends XmppFragment
        } else {
            message = conversation.getCorrectingMessage();
            message.setBody(body);
            message.setThread(conversation.getThread());
            message.putEdited(message.getUuid(), message.getServerMsgId());
            message.setServerMsgId(null);
            message.setUuid(UUID.randomUUID().toString());


@@ 2608,6 2609,8 @@ public class ConversationFragment extends XmppFragment
        while (message.mergeable(message.next())) {
            message = message.next();
        }
        setThread(message.getThread());
        conversation.setUserSelectedThread(true);
        this.conversation.setCorrectingMessage(message);
        final Editable editable = binding.textinput.getText();
        this.conversation.setDraftMessage(editable.toString());


@@ 3298,6 3301,7 @@ public class ConversationFragment extends XmppFragment
    }

    protected void messageSent() {
        conversation.setUserSelectedThread(false);
        mSendingPgpMessage.set(false);
        this.binding.textinput.setText("");
        if (conversation.setCorrectingMessage(null)) {

M src/main/java/eu/siacs/conversations/ui/util/SendButtonTool.java => src/main/java/eu/siacs/conversations/ui/util/SendButtonTool.java +1 -1
@@ 49,7 49,7 @@ public class SendButtonTool {
		final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
		final boolean empty = text.length() == 0;
		final boolean conference = c.getMode() == Conversation.MODE_MULTI;
		if (c.getCorrectingMessage() != null && (empty || text.equals(c.getCorrectingMessage().getBody()))) {
		if (c.getCorrectingMessage() != null && (empty || (text.equals(c.getCorrectingMessage().getBody()) && (c.getThread() == c.getCorrectingMessage().getThread() || (c.getThread() != null && c.getThread().equals(c.getCorrectingMessage().getThread())))))) {
			return SendButtonAction.CANCEL;
		} else if (conference && !c.getAccount().httpUploadAvailable()) {
			if (empty && c.getNextCounterpart() != null) {