implements FS#277: Remove 'Message merge'
This commit is contained in:
parent
abde267e5c
commit
811f3b0926
8 changed files with 16 additions and 78 deletions
|
@ -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
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue