mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-26 12:44:38 +00:00
Respect the phoneNumberSharing setting on the profile.
This commit is contained in:
committed by
Clark Chen
parent
624f863da4
commit
bb30535afb
@@ -146,7 +146,8 @@ object RecipientDatabaseTestUtils {
|
||||
badges = badges,
|
||||
needsPniSignature = false,
|
||||
hiddenState = Recipient.HiddenState.NOT_HIDDEN,
|
||||
callLinkRoomId = null
|
||||
callLinkRoomId = null,
|
||||
phoneNumberSharing = RecipientTable.PhoneNumberSharingState.UNKNOWN
|
||||
),
|
||||
participantIds = participants,
|
||||
isReleaseChannel = isReleaseChannel,
|
||||
|
||||
@@ -37,6 +37,19 @@ public final class RecipientExporterTest {
|
||||
assertNull(intent.getStringExtra(EMAIL));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asAddContactIntent_with_phone_number_should_not_show_number() {
|
||||
Recipient recipient = givenPhoneRecipient(ProfileName.fromParts("Alice", null), "+1555123456", false);
|
||||
|
||||
Intent intent = RecipientExporter.export(recipient).asAddContactIntent();
|
||||
|
||||
assertEquals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction());
|
||||
assertEquals(ContactsContract.Contacts.CONTENT_ITEM_TYPE, intent.getType());
|
||||
assertEquals("Alice", intent.getStringExtra(NAME));
|
||||
assertNull(intent.getStringExtra(PHONE));
|
||||
assertNull(intent.getStringExtra(EMAIL));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asAddContactIntent_with_email() {
|
||||
Recipient recipient = givenEmailRecipient(ProfileName.fromParts("Bob", null), "bob@signal.org");
|
||||
@@ -50,13 +63,19 @@ public final class RecipientExporterTest {
|
||||
assertNull(intent.getStringExtra(PHONE));
|
||||
}
|
||||
|
||||
|
||||
private Recipient givenPhoneRecipient(ProfileName profileName, String phone) {
|
||||
return givenPhoneRecipient(profileName, phone, true);
|
||||
}
|
||||
|
||||
private Recipient givenPhoneRecipient(ProfileName profileName, String phone, boolean shouldShowPhoneNumber) {
|
||||
Recipient recipient = mock(Recipient.class);
|
||||
when(recipient.getProfileName()).thenReturn(profileName);
|
||||
|
||||
when(recipient.requireE164()).thenReturn(phone);
|
||||
when(recipient.getE164()).thenAnswer(i -> Optional.of(phone));
|
||||
when(recipient.getEmail()).thenAnswer(i -> Optional.empty());
|
||||
when(recipient.shouldShowE164()).thenAnswer(i -> shouldShowPhoneNumber);
|
||||
|
||||
return recipient;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user