forked from mirror/monocles_chat_clean
Fix disappearing messages with reactions + code clean up
This commit is contained in:
parent
0aea687411
commit
f83157bcbb
7 changed files with 33 additions and 31 deletions
4
proguard-rules.pro
vendored
4
proguard-rules.pro
vendored
|
@ -7,6 +7,10 @@
|
||||||
|
|
||||||
-keep class com.kyleduo.switchbutton.Configuration
|
-keep class com.kyleduo.switchbutton.Configuration
|
||||||
|
|
||||||
|
-keep class com.google.gson.reflect.TypeToken
|
||||||
|
-keep class * extends com.google.gson.reflect.TypeToken
|
||||||
|
-keep public class * implements java.lang.reflect.Type
|
||||||
|
|
||||||
-keep class com.soundcloud.android.crop.**
|
-keep class com.soundcloud.android.crop.**
|
||||||
|
|
||||||
-keep class com.google.android.gms.**
|
-keep class com.google.android.gms.**
|
||||||
|
|
|
@ -691,7 +691,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOccupantId() {
|
public String getOccupantId() {
|
||||||
return occupantId;
|
return this.occupantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMucUser(MucOptions.User user) {
|
public void setMucUser(MucOptions.User user) {
|
||||||
|
|
|
@ -887,7 +887,7 @@ public class MucOptions {
|
||||||
private final MucOptions options;
|
private final MucOptions options;
|
||||||
private ChatState chatState = Config.DEFAULT_CHAT_STATE;
|
private ChatState chatState = Config.DEFAULT_CHAT_STATE;
|
||||||
protected Set<Hat> hats;
|
protected Set<Hat> hats;
|
||||||
protected String occupantId;
|
private String occupantId;
|
||||||
protected boolean online = true;
|
protected boolean online = true;
|
||||||
|
|
||||||
public User(MucOptions options, Jid fullJid, final String occupantId, final String nick, final Set<Hat> hats) {
|
public User(MucOptions options, Jid fullJid, final String occupantId, final String nick, final Set<Hat> hats) {
|
||||||
|
@ -924,7 +924,7 @@ public class MucOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOccupantId() {
|
public String getOccupantId() {
|
||||||
return occupantId;
|
return this.occupantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNick() {
|
public String getNick() {
|
||||||
|
|
|
@ -5,12 +5,11 @@ import androidx.annotation.NonNull;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Multimaps;
|
import com.google.common.collect.Multimaps;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
@ -22,6 +21,7 @@ import com.google.gson.stream.JsonWriter;
|
||||||
import eu.siacs.conversations.xmpp.Jid;
|
import eu.siacs.conversations.xmpp.Jid;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -76,7 +76,8 @@ public class Reaction {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return GSON.fromJson(asString, new TypeToken<ArrayList<Reaction>>() {}.getType());
|
Type type = new TypeToken<ArrayList<Reaction>>() {}.getType();
|
||||||
|
return GSON.fromJson(asString, type);
|
||||||
} catch (final JsonSyntaxException e) {
|
} catch (final JsonSyntaxException e) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ public abstract class AbstractParser {
|
||||||
fullJid = null;
|
fullJid = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Jid realJid = item.getAttributeAsJid("jid");
|
final Jid realJid = item.getAttributeAsJid("jid");
|
||||||
if (fullJid != null) nick = fullJid.getResource();
|
if (fullJid != null) nick = fullJid.getResource();
|
||||||
String nickname = null;
|
String nickname = null;
|
||||||
if (nick != null && nicknameIn != null) nickname = nick.equals(nicknameIn) ? nick : null;
|
if (nick != null && nicknameIn != null) nickname = nick.equals(nicknameIn) ? nick : null;
|
||||||
|
|
|
@ -575,6 +575,8 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
|
||||||
if (timestamp == null) {
|
if (timestamp == null) {
|
||||||
timestamp = AbstractParser.parseTimestamp(original, AbstractParser.parseTimestamp(packet));
|
timestamp = AbstractParser.parseTimestamp(original, AbstractParser.parseTimestamp(packet));
|
||||||
}
|
}
|
||||||
|
Reactions reactions = packet.getExtension(Reactions.class);
|
||||||
|
LocalizedContent body = packet.getBody();
|
||||||
final Element mucUserElement = packet.findChild("x", Namespace.MUC_USER);
|
final Element mucUserElement = packet.findChild("x", Namespace.MUC_USER);
|
||||||
final String pgpEncrypted = packet.findChildContent("x", "jabber:x:encrypted");
|
final String pgpEncrypted = packet.findChildContent("x", "jabber:x:encrypted");
|
||||||
Element replaceElement = packet.findChild("replace", "urn:xmpp:message-correct:0");
|
Element replaceElement = packet.findChild("replace", "urn:xmpp:message-correct:0");
|
||||||
|
@ -608,10 +610,7 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
|
||||||
packet.setBody(reason == null ? "" : reason);
|
packet.setBody(reason == null ? "" : reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LocalizedContent body = packet.getBody();
|
|
||||||
|
|
||||||
var appendReactions = false;
|
var appendReactions = false;
|
||||||
var reactions = packet.getExtension(Reactions.class);
|
|
||||||
final var reply = packet.findChild("reply", "urn:xmpp:reply:0");
|
final var reply = packet.findChild("reply", "urn:xmpp:reply:0");
|
||||||
if (reactions == null && reply != null && reply.getAttribute("id") != null && body != null) {
|
if (reactions == null && reply != null && reply.getAttribute("id") != null && body != null) {
|
||||||
StringBuilder bodyB = new StringBuilder(body.content);
|
StringBuilder bodyB = new StringBuilder(body.content);
|
||||||
|
|
|
@ -1988,24 +1988,24 @@ public class ConversationFragment extends XmppFragment
|
||||||
activity.getMenuInflater().inflate(R.menu.message_context, menu);
|
activity.getMenuInflater().inflate(R.menu.message_context, menu);
|
||||||
final MenuItem reportAndBlock = menu.findItem(R.id.action_report_and_block);
|
final MenuItem reportAndBlock = menu.findItem(R.id.action_report_and_block);
|
||||||
final MenuItem addReaction = menu.findItem(R.id.action_add_reaction);
|
final MenuItem addReaction = menu.findItem(R.id.action_add_reaction);
|
||||||
MenuItem openWith = menu.findItem(R.id.open_with);
|
final MenuItem openWith = menu.findItem(R.id.open_with);
|
||||||
MenuItem copyMessage = menu.findItem(R.id.copy_message);
|
final MenuItem copyMessage = menu.findItem(R.id.copy_message);
|
||||||
MenuItem quoteMessage = menu.findItem(R.id.quote_message);
|
final MenuItem quoteMessage = menu.findItem(R.id.quote_message);
|
||||||
MenuItem retryDecryption = menu.findItem(R.id.retry_decryption);
|
final MenuItem retryDecryption = menu.findItem(R.id.retry_decryption);
|
||||||
MenuItem correctMessage = menu.findItem(R.id.correct_message);
|
final MenuItem correctMessage = menu.findItem(R.id.correct_message);
|
||||||
MenuItem retractMessage = menu.findItem(R.id.retract_message);
|
final MenuItem retractMessage = menu.findItem(R.id.retract_message);
|
||||||
MenuItem moderateMessage = menu.findItem(R.id.moderate_message);
|
final MenuItem moderateMessage = menu.findItem(R.id.moderate_message);
|
||||||
MenuItem onlyThisThread = menu.findItem(R.id.only_this_thread);
|
final MenuItem onlyThisThread = menu.findItem(R.id.only_this_thread);
|
||||||
MenuItem shareWith = menu.findItem(R.id.share_with);
|
final MenuItem shareWith = menu.findItem(R.id.share_with);
|
||||||
MenuItem sendAgain = menu.findItem(R.id.send_again);
|
final MenuItem sendAgain = menu.findItem(R.id.send_again);
|
||||||
MenuItem copyUrl = menu.findItem(R.id.copy_url);
|
final MenuItem copyUrl = menu.findItem(R.id.copy_url);
|
||||||
MenuItem saveToDownloads = menu.findItem(R.id.save_to_downloads);
|
final MenuItem saveToDownloads = menu.findItem(R.id.save_to_downloads);
|
||||||
MenuItem saveAsSticker = menu.findItem(R.id.save_as_sticker);
|
final MenuItem saveAsSticker = menu.findItem(R.id.save_as_sticker);
|
||||||
MenuItem downloadFile = menu.findItem(R.id.download_file);
|
final MenuItem downloadFile = menu.findItem(R.id.download_file);
|
||||||
MenuItem cancelTransmission = menu.findItem(R.id.cancel_transmission);
|
final MenuItem cancelTransmission = menu.findItem(R.id.cancel_transmission);
|
||||||
MenuItem blockMedia = menu.findItem(R.id.block_media);
|
final MenuItem blockMedia = menu.findItem(R.id.block_media);
|
||||||
MenuItem deleteFile = menu.findItem(R.id.delete_file);
|
final MenuItem deleteFile = menu.findItem(R.id.delete_file);
|
||||||
MenuItem showErrorMessage = menu.findItem(R.id.show_error_message);
|
final MenuItem showErrorMessage = menu.findItem(R.id.show_error_message);
|
||||||
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 =
|
final boolean showError =
|
||||||
|
@ -2023,9 +2023,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
reportAndBlock.setVisible(true);
|
reportAndBlock.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!encrypted && !m.getBody().equals("")) {
|
addReaction.setVisible(!showError && !m.isDeleted());
|
||||||
addReaction.setVisible(!showError && !m.isDeleted());
|
|
||||||
}
|
|
||||||
if (!m.isFileOrImage()
|
if (!m.isFileOrImage()
|
||||||
&& !encrypted
|
&& !encrypted
|
||||||
&& !m.isGeoUri()
|
&& !m.isGeoUri()
|
||||||
|
|
Loading…
Reference in a new issue