Add support for setting an optional last name in profiles.

This commit is contained in:
Alex Hart
2019-12-20 16:12:22 -04:00
committed by Greyson Parrelli
parent f2b9bf0b8c
commit 3907ec8b51
57 changed files with 1641 additions and 1847 deletions

View File

@@ -22,7 +22,6 @@ import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
import org.thoughtcrime.securesms.contacts.avatars.SystemContactPhoto;
import org.thoughtcrime.securesms.contacts.avatars.TransparentContactPhoto;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.IdentityDatabase;
import org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus;
import org.thoughtcrime.securesms.database.RecipientDatabase;
import org.thoughtcrime.securesms.database.RecipientDatabase.RegisteredState;
@@ -34,9 +33,9 @@ import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.notifications.NotificationChannels;
import org.thoughtcrime.securesms.phonenumbers.NumberUtil;
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
import org.thoughtcrime.securesms.profiles.ProfileName;
import org.thoughtcrime.securesms.util.FeatureFlags;
import org.thoughtcrime.securesms.util.GroupUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.libsignal.util.guava.Preconditions;
@@ -83,7 +82,7 @@ public class Recipient {
private final Uri systemContactPhoto;
private final String customLabel;
private final Uri contactUri;
private final String profileName;
private final ProfileName profileName;
private final String profileAvatar;
private final boolean profileSharing;
private final String notificationChannel;
@@ -295,7 +294,7 @@ public class Recipient {
this.systemContactPhoto = null;
this.customLabel = null;
this.contactUri = null;
this.profileName = null;
this.profileName = ProfileName.EMPTY;
this.profileAvatar = null;
this.profileSharing = false;
this.notificationChannel = null;
@@ -383,7 +382,7 @@ public class Recipient {
public @NonNull String getDisplayName(@NonNull Context context) {
return Util.getFirstNonEmpty(getName(context),
getProfileName(),
getProfileName().toString(),
getDisplayUsername(),
e164,
email,
@@ -518,7 +517,7 @@ public class Recipient {
return defaultSubscriptionId;
}
public @Nullable String getProfileName() {
public @NonNull ProfileName getProfileName() {
return profileName;
}

View File

@@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
import org.thoughtcrime.securesms.database.RecipientDatabase.RegisteredState;
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
import org.thoughtcrime.securesms.profiles.ProfileName;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libsignal.util.guava.Optional;
@@ -43,7 +44,7 @@ public class RecipientDetails {
final boolean blocked;
final int expireMessages;
final List<Recipient> participants;
final String profileName;
final ProfileName profileName;
final Optional<Integer> defaultSubscriptionId;
final RegisteredState registered;
final byte[] profileKey;

View File

@@ -21,7 +21,8 @@ public final class RecipientExporter {
public Intent asAddContactIntent() {
Intent intent = new Intent(ACTION_INSERT_OR_EDIT);
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
addNameToIntent(intent, recipient.getProfileName());
addNameToIntent(intent, recipient.getProfileName().toString());
addAddressToIntent(intent, recipient);
return intent;
}