mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Format-neutral compare numbers in MMS group with local device.
Closes #1018
This commit is contained in:
parent
b855a1805f
commit
0b4fe84a41
@ -22,9 +22,12 @@ import android.database.Cursor;
|
|||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
|
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
|
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
|
||||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||||
@ -205,7 +208,8 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (encodedToList != null && (encodedToList.length > 1 || group.size() > 1)) {
|
if (encodedToList != null && (encodedToList.length > 1 || group.size() > 1)) {
|
||||||
String localNumber = Util.getDeviceE164Number(context);
|
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
String localNumber = telephonyManager.getLine1Number();
|
||||||
|
|
||||||
if (localNumber == null) {
|
if (localNumber == null) {
|
||||||
localNumber = TextSecurePreferences.getLocalNumber(context);
|
localNumber = TextSecurePreferences.getLocalNumber(context);
|
||||||
@ -214,8 +218,14 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
|||||||
for (EncodedStringValue encodedTo : encodedToList) {
|
for (EncodedStringValue encodedTo : encodedToList) {
|
||||||
String to = new String(encodedTo.getTextString(), CharacterSets.MIMENAME_ISO_8859_1);
|
String to = new String(encodedTo.getTextString(), CharacterSets.MIMENAME_ISO_8859_1);
|
||||||
|
|
||||||
/// TODO format numbers before comparing.
|
PhoneNumberUtil.MatchType match;
|
||||||
if (localNumber == null || !localNumber.equals(to)) {
|
|
||||||
|
if (localNumber == null) match = PhoneNumberUtil.MatchType.NO_MATCH;
|
||||||
|
else match = PhoneNumberUtil.getInstance().isNumberMatch(localNumber, to);
|
||||||
|
|
||||||
|
if (match == PhoneNumberUtil.MatchType.NO_MATCH ||
|
||||||
|
match == PhoneNumberUtil.MatchType.NOT_A_NUMBER)
|
||||||
|
{
|
||||||
group.add(to);
|
group.add(to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,9 @@ public class MmsDownloader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void process(MasterSecret masterSecret, Intent intent) {
|
public void process(MasterSecret masterSecret, Intent intent) {
|
||||||
if (intent.getAction().equals(SendReceiveService.DOWNLOAD_MMS_ACTION)) {
|
if (SendReceiveService.DOWNLOAD_MMS_ACTION.equals(intent.getAction())) {
|
||||||
handleDownloadMms(masterSecret, intent);
|
handleDownloadMms(masterSecret, intent);
|
||||||
} else if (intent.getAction().equals(SendReceiveService.DOWNLOAD_MMS_PENDING_APN_ACTION)) {
|
} else if (SendReceiveService.DOWNLOAD_MMS_PENDING_APN_ACTION.equals(intent.getAction())) {
|
||||||
handleMmsPendingApnDownloads(masterSecret);
|
handleMmsPendingApnDownloads(masterSecret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user