fix reactions handling in case of missing reply stanza

This commit is contained in:
kosyak 2024-05-22 21:31:23 +02:00
parent 7b8a61e068
commit d42486c72c
4 changed files with 15 additions and 24 deletions

View file

@ -10,7 +10,6 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.telephony.PhoneNumberUtils;
@ -24,7 +23,6 @@ import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.util.Linkify;
import android.util.DisplayMetrics;
import android.util.LruCache;
import android.util.Pair;
import android.util.SparseArray;
import android.view.Gravity;
@ -81,7 +79,6 @@ import java.time.format.FormatStyle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Objects;
@ -110,7 +107,6 @@ import eu.siacs.conversations.databinding.CommandTextFieldBinding;
import eu.siacs.conversations.databinding.CommandUnknownBinding;
import eu.siacs.conversations.databinding.CommandWebviewBinding;
import eu.siacs.conversations.databinding.DialogQuickeditBinding;
import eu.siacs.conversations.http.HttpConnectionManager;
import eu.siacs.conversations.persistance.DatabaseBackend;
import eu.siacs.conversations.services.AvatarService;
import eu.siacs.conversations.services.QuickConversationsService;
@ -1343,7 +1339,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
private void actualizeReplyMessages(List<Message> mainList, List<Message> messages) {
for (Message m : mainList) {
if (m.isReplyRestoredFromDb()) {
Element reply = m.getReply();
Element reply = m.getReplyOrReaction();
if (reply == null) {
continue;

View file

@ -1,13 +1,9 @@
package eu.siacs.conversations.entities;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ImageSpan;
import android.util.Log;
import androidx.annotation.Nullable;
@ -19,7 +15,6 @@ import com.google.common.primitives.Longs;
import org.json.JSONException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@ -31,7 +26,6 @@ import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
import eu.siacs.conversations.http.URL;
@ -412,7 +406,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
return null;
}
public Element getReply() {
public Element getReplyOrReaction() {
if (this.payloads == null) return null;
for (Element el : this.payloads) {
@ -421,6 +415,12 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
}
}
for (Element el : this.payloads) {
if (el.getName().equals("reactions") && el.getNamespace().equals("urn:xmpp:reactions:0")) {
return el;
}
}
return null;
}

View file

@ -137,7 +137,6 @@ import eu.siacs.conversations.ui.interfaces.OnAvatarPublication;
import eu.siacs.conversations.ui.interfaces.OnMediaLoaded;
import eu.siacs.conversations.ui.interfaces.OnSearchResultsAvailable;
import eu.siacs.conversations.ui.util.ShareUtil;
import eu.siacs.conversations.utils.AccountUtils;
import eu.siacs.conversations.utils.Compatibility;
import eu.siacs.conversations.utils.ConversationsFileObserver;
import eu.siacs.conversations.utils.CryptoHelper;
@ -2324,7 +2323,7 @@ public class XmppConnectionService extends Service {
Map<String, ArrayList<Message>> notFoundReplies = null;
for (Message m : messages) {
Element reply = m.getReply();
Element reply = m.getReplyOrReaction();
if (reply == null) {
continue;

View file

@ -18,8 +18,6 @@ import android.app.FragmentManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -30,7 +28,6 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.SystemClock;
import android.os.VibrationEffect;
@ -38,7 +35,6 @@ import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.format.DateUtils;
@ -63,7 +59,6 @@ import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.TextView.OnEditorActionListener;
@ -75,7 +70,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.core.view.inputmethod.InputConnectionCompat;
import androidx.core.view.inputmethod.InputContentInfoCompat;
import androidx.databinding.DataBindingUtil;
@ -86,7 +80,6 @@ import com.google.common.collect.ImmutableList;
import org.jetbrains.annotations.NotNull;
import java.net.URL;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
@ -95,7 +88,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -129,7 +121,6 @@ import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.adapter.CommandAdapter;
import eu.siacs.conversations.ui.adapter.MediaPreviewAdapter;
import eu.siacs.conversations.ui.adapter.MessageAdapter;
import eu.siacs.conversations.ui.text.QuoteSpan;
import eu.siacs.conversations.ui.util.ActivityResult;
import eu.siacs.conversations.ui.util.Attachment;
import eu.siacs.conversations.ui.util.ConversationMenuConfigurator;
@ -1612,7 +1603,12 @@ public class ConversationFragment extends XmppFragment
}
private void scrollToReply(Message message) {
Element reply = message.getReply();
Element reply = message.getReplyOrReaction();
if (reply == null) {
previousClickedReply = null;
return;
}
String replyId = reply.getAttribute("id");
if (replyId != null) {