parent
201be3e041
commit
be44ef9c0a
5 changed files with 18 additions and 15 deletions
|
@ -43,7 +43,7 @@ public class Contact implements Parcelable {
|
|||
@JsonProperty
|
||||
private final Avatar avatar;
|
||||
|
||||
public Contact(@JsonProperty("name") @NonNull Name name,
|
||||
public Contact(@JsonProperty("name") @Nullable Name name,
|
||||
@JsonProperty("organization") @Nullable String organization,
|
||||
@JsonProperty("phoneNumbers") @NonNull List<Phone> phoneNumbers,
|
||||
@JsonProperty("emails") @NonNull List<Email> emails,
|
||||
|
@ -77,7 +77,7 @@ public class Contact implements Parcelable {
|
|||
}
|
||||
|
||||
public @NonNull Name getName() {
|
||||
return name;
|
||||
return name == null ? Name.EMPTY_NAME : name;
|
||||
}
|
||||
|
||||
public @Nullable String getOrganization() {
|
||||
|
@ -228,6 +228,8 @@ public class Contact implements Parcelable {
|
|||
dest.writeString(nickname);
|
||||
}
|
||||
|
||||
public static Name EMPTY_NAME = new Name("","","","","","");
|
||||
|
||||
public static final Creator<Name> CREATOR = new Creator<Name>() {
|
||||
@Override
|
||||
public Name createFromParcel(Parcel in) {
|
||||
|
|
|
@ -65,7 +65,6 @@ class ContactShareEditViewModel extends ViewModel {
|
|||
|
||||
void updateContactName(int contactPosition, @NonNull Name name) {
|
||||
if (name.isEmpty()) {
|
||||
events.postValue(Event.BAD_CONTACT);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public final class ContactUtil {
|
|||
return contact.getName().getNickname();
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(contact.getName().getGivenName())) {
|
||||
if (!TextUtils.isEmpty(contact.getName().getGivenName()) || !TextUtils.isEmpty(contact.getName().getFamilyName())) {
|
||||
return ProfileName.fromParts(contact.getName().getGivenName(), contact.getName().getFamilyName()).toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||
import org.signal.contacts.SystemContactsRepository;
|
||||
import org.signal.contacts.SystemContactsRepository.NameDetails;
|
||||
import org.signal.contacts.SystemContactsRepository.PhoneDetails;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||
import org.thoughtcrime.securesms.contactshare.Contact.Email;
|
||||
import org.thoughtcrime.securesms.contactshare.Contact.Name;
|
||||
import org.thoughtcrime.securesms.contactshare.Contact.Phone;
|
||||
|
@ -72,17 +72,19 @@ public class SharedContactRepository {
|
|||
|
||||
@WorkerThread
|
||||
private @Nullable Contact getContactFromSystemContacts(long contactId) {
|
||||
Name name = getName(contactId);
|
||||
if (name == null) {
|
||||
Log.w(TAG, "Couldn't find a name associated with the provided contact ID.");
|
||||
List<Phone> phoneNumbers = getPhoneNumbers(contactId);
|
||||
List<Email> emails = getEmails(contactId);
|
||||
|
||||
if (phoneNumbers.isEmpty() && emails.isEmpty()) {
|
||||
Log.w(TAG, "Couldn't find a phone number or email address associated with the provided contact ID.");
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Phone> phoneNumbers = getPhoneNumbers(contactId);
|
||||
AvatarInfo avatarInfo = getAvatarInfo(contactId, phoneNumbers);
|
||||
Avatar avatar = avatarInfo != null ? new Avatar(avatarInfo.uri, avatarInfo.isProfile) : null;
|
||||
Name name = getName(contactId);
|
||||
AvatarInfo avatarInfo = getAvatarInfo(contactId, phoneNumbers);
|
||||
Avatar avatar = avatarInfo != null ? new Avatar(avatarInfo.uri, avatarInfo.isProfile) : null;
|
||||
|
||||
return new Contact(name, null, phoneNumbers, getEmails(contactId), getPostalAddresses(contactId), avatar);
|
||||
return new Contact(name, null, phoneNumbers, emails, getPostalAddresses(contactId), avatar);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
@ -223,7 +225,7 @@ public class SharedContactRepository {
|
|||
private final boolean isProfile;
|
||||
|
||||
private AvatarInfo(Uri uri, boolean isProfile) {
|
||||
this.uri = uri;
|
||||
this.uri = uri;
|
||||
this.isProfile = isProfile;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/signal_m3_toolbar_height"
|
||||
android:minHeight="@dimen/signal_m3_toolbar_height"
|
||||
app:navigationIcon="@drawable/ic_x_tinted"
|
||||
app:navigationIcon="@drawable/ic_check_28_tinted"
|
||||
app:title="@string/ContactShareEditActivity__edit_name"
|
||||
app:titleTextAppearance="@style/Signal.Text.TitleLarge" />
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue