diff --git a/src/org/kde/kdeconnect/Helpers/SMSHelper.java b/src/org/kde/kdeconnect/Helpers/SMSHelper.java index a9437df8..477128bb 100644 --- a/src/org/kde/kdeconnect/Helpers/SMSHelper.java +++ b/src/org/kde/kdeconnect/Helpers/SMSHelper.java @@ -46,6 +46,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -536,6 +537,8 @@ public class SMSHelper { * Get the address(es) of an MMS message * Original implementation from https://stackoverflow.com/a/6446831/3723163 * + * The message at the first position of the list should be the sender of the message + * * @param messageID ID of this message in the MMS database for looking up the remaining info * @param userPhoneNumbers List of phone numbers which should be removed from the list of addresses */ @@ -555,7 +558,8 @@ public class SMSHelper { String selection = Telephony.Mms.Addr.MSG_ID + " = ?"; String[] selectionArgs = {messageID.toString()}; - List
addresses = new ArrayList<>(); + // Keep an ordered set rather than a list because Android sometimes throws duplicates at us + Set addresses = new LinkedHashSet<>(); try (Cursor addrCursor = context.getContentResolver().query( uri, @@ -704,6 +708,11 @@ public class SMSHelper { } return false; } + + @Override + public int hashCode() { + return this.address.hashCode(); + } } /**