aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2019-07-07 22:42:06 +0200
committersteckbrief <steckbrief@chefmail.de>2019-07-07 22:42:06 +0200
commit811f3b092608b7c17982823b28c950489d0345e0 (patch)
treeaac22cd7b960082752aa1b6a01fe793bf5dfb695
parentabde267e5c1abc02ef1130f5ffd058199582926d (diff)
implements FS#277: Remove 'Message merge'
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java5
-rw-r--r--src/main/java/de/pixart/messenger/entities/Message.java49
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java8
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java17
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/ShareUtil.java6
-rw-r--r--src/main/java/de/pixart/messenger/utils/MessageUtils.java2
-rw-r--r--src/main/java/de/pixart/messenger/utils/StylingHelper.java5
8 files changed, 16 insertions, 78 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index b3e92fba2..77cf2dea8 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -418,11 +418,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
messages.clear();
messages.addAll(this.messages);
}
- for (Iterator<Message> iterator = messages.iterator(); iterator.hasNext(); ) {
- if (iterator.next().wasMergedIntoPrevious()) {
- iterator.remove();
- }
- }
}
@Override
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java
index e280d2527..bef1920d5 100644
--- a/src/main/java/de/pixart/messenger/entities/Message.java
+++ b/src/main/java/de/pixart/messenger/entities/Message.java
@@ -640,59 +640,10 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
}
}
- public static class MergeSeparator {
- }
-
- public SpannableStringBuilder getMergedBody() {
- SpannableStringBuilder body = new SpannableStringBuilder(MessageUtils.filterLtrRtl(this.body).trim());
- Message current = this;
- while (current.mergeable(current.next())) {
- current = current.next();
- if (current == null) {
- break;
- }
- body.append("\n\n");
- body.setSpan(new MergeSeparator(), body.length() - 2, body.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
- body.append(MessageUtils.filterLtrRtl(current.getBody()).trim());
- }
- return body;
- }
-
public boolean hasMeCommand() {
return this.body.trim().startsWith(ME_COMMAND);
}
- public int getMergedStatus() {
- int status = this.status;
- Message current = this;
- while (current.mergeable(current.next())) {
- current = current.next();
- if (current == null) {
- break;
- }
- status = current.status;
- }
- return status;
- }
-
- public long getMergedTimeSent() {
- long time = this.timeSent;
- Message current = this;
- while (current.mergeable(current.next())) {
- current = current.next();
- if (current == null) {
- break;
- }
- time = current.timeSent;
- }
- return time;
- }
-
- public boolean wasMergedIntoPrevious() {
- Message prev = this.prev();
- return prev != null && prev.mergeable(this);
- }
-
public boolean trusted() {
Contact contact = this.getContact();
return status > STATUS_RECEIVED || (contact != null && (contact.showInContactList() || contact.isSelf()));
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index bd127d443..18cbefec3 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -662,7 +662,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return i;
} else {
Message next = messages.get(i);
- while (next != null && next.wasMergedIntoPrevious()) {
+ while (next != null) {
if (uuid.equals(next.getUuid())) {
return i;
}
@@ -1259,7 +1259,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
if (!m.isFileOrImage() && !encrypted && !m.isGeoUri() && !m.treatAsDownloadable()) {
copyMessage.setVisible(true);
quoteMessage.setVisible(!showError && MessageUtils.prepareQuote(m).length() > 0);
- String body = m.getMergedBody().toString();
+ String body = m.getBody();
if (ShareUtil.containsXmppUri(body)) {
copyLink.setTitle(R.string.copy_jabber_id);
copyLink.setVisible(true);
@@ -1796,7 +1796,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
if (message != null) {
- while (message.next() != null && message.next().wasMergedIntoPrevious()) {
+ while (message.next() != null) {
message = message.next();
}
return message.getUuid();
@@ -2949,7 +2949,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
private boolean messageContainsQuery(Message m, String q) {
- return m != null && m.getMergedBody().toString().toLowerCase().contains(q.toLowerCase());
+ return m != null && m.getBody().toLowerCase().contains(q.toLowerCase());
}
private void startPendingIntent(PendingIntent pendingIntent, int requestCode) {
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
index 15efb7921..b7e08addf 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
@@ -232,7 +232,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
}
if (activity.xmppConnectionService.indicateReceived()) {
- switch (message.getMergedStatus()) {
+ switch (message.getStatus()) {
case Message.STATUS_SEND_RECEIVED:
viewHolder.binding.indicatorReceived.setVisibility(View.VISIBLE);
break;
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index 4cdefccc3..f67ad887c 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -77,6 +77,7 @@ import de.pixart.messenger.utils.CryptoHelper;
import de.pixart.messenger.utils.EmojiWrapper;
import de.pixart.messenger.utils.Emoticons;
import de.pixart.messenger.utils.GeoHelper;
+import de.pixart.messenger.utils.MessageUtils;
import de.pixart.messenger.utils.RichPreview;
import de.pixart.messenger.utils.StylingHelper;
import de.pixart.messenger.utils.UIHelper;
@@ -222,7 +223,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
final Transferable transferable = message.getTransferable();
boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI
- && message.getMergedStatus() <= Message.STATUS_RECEIVED;
+ && message.getStatus() <= Message.STATUS_RECEIVED;
if (message.isFileOrImage() || transferable != null) {
FileParams params = message.getFileParams();
filesize = params.size > 0 ? UIHelper.filesizeToString(params.size) : null;
@@ -230,7 +231,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
error = true;
}
}
- switch (message.getMergedStatus()) {
+ switch (message.getStatus()) {
case Message.STATUS_WAITING:
info = getContext().getString(R.string.waiting);
break;
@@ -350,7 +351,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.indicator.setVisibility(View.VISIBLE);
}
- String formatedTime = UIHelper.readableTimeDifferenceFull(getContext(), message.getMergedTimeSent());
+ String formatedTime = UIHelper.readableTimeDifferenceFull(getContext(), message.getTimeSent());
if (message.getStatus() <= Message.STATUS_RECEIVED) {
if ((filesize != null) && (info != null)) {
viewHolder.time.setText(formatedTime + " \u00B7 " + filesize + " \u00B7 " + info);
@@ -532,7 +533,9 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
if (message.getBody() != null) {
final String nick = UIHelper.getMessageDisplayName(message);
- SpannableStringBuilder body = message.getMergedBody();
+ String messageBody = message.getBody();
+ SpannableStringBuilder body = new SpannableStringBuilder(MessageUtils.filterLtrRtl(messageBody).trim());
+
boolean hasMeCommand = message.hasMeCommand();
if (hasMeCommand) {
body = body.replace(0, Message.ME_COMMAND.length(), nick);
@@ -541,12 +544,6 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
body = new SpannableStringBuilder(body, 0, Config.MAX_DISPLAY_MESSAGE_CHARS);
body.append("\u2026");
}
- Message.MergeSeparator[] mergeSeparators = body.getSpans(0, body.length(), Message.MergeSeparator.class);
- for (Message.MergeSeparator mergeSeparator : mergeSeparators) {
- int start = body.getSpanStart(mergeSeparator);
- int end = body.getSpanEnd(mergeSeparator);
- body.setSpan(new DividerSpan(true), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
boolean startsWithQuote = handleTextQuotes(body, darkBackground);
if (!message.isPrivateMessage()) {
if (hasMeCommand) {
diff --git a/src/main/java/de/pixart/messenger/ui/util/ShareUtil.java b/src/main/java/de/pixart/messenger/ui/util/ShareUtil.java
index 1f53a4c72..9657c61a7 100644
--- a/src/main/java/de/pixart/messenger/ui/util/ShareUtil.java
+++ b/src/main/java/de/pixart/messenger/ui/util/ShareUtil.java
@@ -53,7 +53,7 @@ public class ShareUtil {
shareIntent.putExtra(Intent.EXTRA_TEXT, message.getBody());
shareIntent.setType("text/plain");
} else if (!message.isFileOrImage()) {
- shareIntent.putExtra(Intent.EXTRA_TEXT, message.getMergedBody().toString());
+ shareIntent.putExtra(Intent.EXTRA_TEXT, message.getBody());
shareIntent.setType("text/plain");
} else {
final DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
@@ -80,7 +80,7 @@ public class ShareUtil {
}
public static void copyToClipboard(XmppActivity activity, Message message) {
- if (activity.copyTextToClipboard(message.getMergedBody().toString(), R.string.message)) {
+ if (activity.copyTextToClipboard(message.getBody(), R.string.message)) {
Toast.makeText(activity, R.string.message_copied_to_clipboard, Toast.LENGTH_SHORT).show();
}
}
@@ -104,7 +104,7 @@ public class ShareUtil {
}
public static void copyLinkToClipboard(XmppActivity activity, Message message) {
- String body = message.getMergedBody().toString();
+ String body = message.getBody();
Matcher xmppPatternMatcher = Patterns.XMPP_PATTERN.matcher(body);
if (xmppPatternMatcher.find()) {
try {
diff --git a/src/main/java/de/pixart/messenger/utils/MessageUtils.java b/src/main/java/de/pixart/messenger/utils/MessageUtils.java
index 4ad0e84a5..dad01fdf3 100644
--- a/src/main/java/de/pixart/messenger/utils/MessageUtils.java
+++ b/src/main/java/de/pixart/messenger/utils/MessageUtils.java
@@ -43,7 +43,7 @@ public class MessageUtils {
private static final String EMPTY_STRING = "";
public static String prepareQuote(Message message) {
final StringBuilder builder = new StringBuilder();
- final String body = message.getMergedBody().toString();
+ final String body = message.getBody();
for (String line : body.split("\n")) {
if (line.length() <= 0) {
continue;
diff --git a/src/main/java/de/pixart/messenger/utils/StylingHelper.java b/src/main/java/de/pixart/messenger/utils/StylingHelper.java
index be430e584..a906b734f 100644
--- a/src/main/java/de/pixart/messenger/utils/StylingHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/StylingHelper.java
@@ -85,11 +85,6 @@ public class StylingHelper {
public static void format(final Editable editable, @ColorInt int textColor) {
int end = 0;
- Message.MergeSeparator[] spans = editable.getSpans(0, editable.length() - 1, Message.MergeSeparator.class);
- for (Message.MergeSeparator span : spans) {
- format(editable, end, editable.getSpanStart(span), textColor);
- end = editable.getSpanEnd(span);
- }
format(editable, end, editable.length() - 1, textColor);
}