mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-29 13:16:01 +01:00
Convert Recipient to kotlin.
This commit is contained in:
@@ -191,36 +191,36 @@ public final class LiveRecipient {
|
||||
}
|
||||
|
||||
private @NonNull Recipient fetchAndCacheRecipientFromDisk(@NonNull RecipientId id) {
|
||||
RecipientRecord record = recipientTable.getRecord(id);
|
||||
RecipientDetails details;
|
||||
RecipientRecord record = recipientTable.getRecord(id);
|
||||
|
||||
Recipient recipient;
|
||||
if (record.getGroupId() != null) {
|
||||
details = getGroupRecipientDetails(record);
|
||||
recipient = getGroupRecipientDetails(record);
|
||||
} else if (record.getDistributionListId() != null) {
|
||||
details = getDistributionListRecipientDetails(record);
|
||||
recipient = getDistributionListRecipientDetails(record);
|
||||
} else if (record.getCallLinkRoomId() != null) {
|
||||
details = getCallLinkRecipientDetails(record);
|
||||
}else {
|
||||
details = RecipientDetails.forIndividual(context, record);
|
||||
recipient = getCallLinkRecipientDetails(record);
|
||||
} else {
|
||||
recipient = RecipientCreator.forIndividual(context, record);
|
||||
}
|
||||
|
||||
Recipient recipient = new Recipient(record.getId(), details, true);
|
||||
RecipientIdCache.INSTANCE.put(recipient);
|
||||
return recipient;
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private @NonNull RecipientDetails getGroupRecipientDetails(@NonNull RecipientRecord record) {
|
||||
private @NonNull Recipient getGroupRecipientDetails(@NonNull RecipientRecord record) {
|
||||
Optional<GroupRecord> groupRecord = groupDatabase.getGroup(record.getId());
|
||||
|
||||
if (groupRecord.isPresent()) {
|
||||
return RecipientDetails.forGroup(groupRecord.get(), record);
|
||||
return RecipientCreator.forGroup(groupRecord.get(), record);
|
||||
} else {
|
||||
return RecipientDetails.forUnknown();
|
||||
return RecipientCreator.forUnknown();
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private @NonNull RecipientDetails getDistributionListRecipientDetails(@NonNull RecipientRecord record) {
|
||||
private @NonNull Recipient getDistributionListRecipientDetails(@NonNull RecipientRecord record) {
|
||||
DistributionListRecord groupRecord = distributionListTables.getList(Objects.requireNonNull(record.getDistributionListId()));
|
||||
|
||||
// TODO [stories] We'll have to see what the perf is like for very large distribution lists. We may not be able to support fetching all the members.
|
||||
@@ -228,23 +228,23 @@ public final class LiveRecipient {
|
||||
String title = groupRecord.isUnknown() ? null : groupRecord.getName();
|
||||
List<RecipientId> members = Stream.of(groupRecord.getMembers()).filterNot(RecipientId::isUnknown).toList();
|
||||
|
||||
return RecipientDetails.forDistributionList(title, members, record);
|
||||
return RecipientCreator.forDistributionList(title, members, record);
|
||||
}
|
||||
|
||||
return RecipientDetails.forDistributionList(null, null, record);
|
||||
return RecipientCreator.forDistributionList(null, null, record);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private @NonNull RecipientDetails getCallLinkRecipientDetails(@NonNull RecipientRecord record) {
|
||||
private @NonNull Recipient getCallLinkRecipientDetails(@NonNull RecipientRecord record) {
|
||||
CallLinkTable.CallLink callLink = SignalDatabase.callLinks().getCallLinkByRoomId(Objects.requireNonNull(record.getCallLinkRoomId()));
|
||||
|
||||
if (callLink != null) {
|
||||
String name = callLink.getState().getName();
|
||||
|
||||
return RecipientDetails.forCallLink(name, record, callLink.getAvatarColor());
|
||||
return RecipientCreator.forCallLink(name, record, callLink.getAvatarColor());
|
||||
}
|
||||
|
||||
return RecipientDetails.forCallLink(null, record, AvatarColor.UNKNOWN);
|
||||
return RecipientCreator.forCallLink(null, record, AvatarColor.UNKNOWN);
|
||||
}
|
||||
|
||||
synchronized void set(@NonNull Recipient recipient) {
|
||||
|
||||
@@ -74,7 +74,7 @@ public final class LiveRecipientCache {
|
||||
live = recipients.get(id);
|
||||
|
||||
if (live == null) {
|
||||
live = new LiveRecipient(context, new Recipient(id));
|
||||
live = new LiveRecipient(context, RecipientCreator.forId(id));
|
||||
recipients.put(id, live);
|
||||
needsResolve = true;
|
||||
} else {
|
||||
@@ -266,6 +266,6 @@ public final class LiveRecipientCache {
|
||||
}
|
||||
|
||||
private boolean isValidForCache(@NonNull Recipient recipient) {
|
||||
return !recipient.getId().isUnknown() && (recipient.hasServiceId() || recipient.getGroupId().isPresent() || recipient.hasSmsAddress());
|
||||
return !recipient.getId().isUnknown() && (recipient.getHasServiceId() || recipient.getGroupId().isPresent() || recipient.getHasSmsAddress());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1081
app/src/main/java/org/thoughtcrime/securesms/recipients/Recipient.kt
Normal file
1081
app/src/main/java/org/thoughtcrime/securesms/recipients/Recipient.kt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,179 @@
|
||||
package org.thoughtcrime.securesms.recipients
|
||||
|
||||
import android.content.Context
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import org.thoughtcrime.securesms.conversation.colors.AvatarColor
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.RegisteredState
|
||||
import org.thoughtcrime.securesms.database.model.GroupRecord
|
||||
import org.thoughtcrime.securesms.database.model.RecipientRecord
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import java.util.LinkedList
|
||||
import java.util.Optional
|
||||
|
||||
/**
|
||||
* [Recipient] is a very large class with a lot of fields. This class distributes some of the burden in creating that object.
|
||||
* It's also helpful for java-kotlin interop, since there's so many optional fields.
|
||||
*/
|
||||
object RecipientCreator {
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun forId(recipientId: RecipientId, resolved: Boolean = false): Recipient {
|
||||
return Recipient(recipientId, isResolving = !resolved)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun forIndividual(context: Context, record: RecipientRecord): Recipient {
|
||||
val isSelf = record.e164 != null && record.e164 == SignalStore.account().e164 || record.aci != null && record.aci == SignalStore.account().aci
|
||||
val isReleaseChannel = record.id == SignalStore.releaseChannelValues().releaseChannelRecipientId
|
||||
var registeredState = record.registered
|
||||
|
||||
if (isSelf) {
|
||||
registeredState = if (SignalStore.account().isRegistered && !TextSecurePreferences.isUnauthorizedReceived(context)) {
|
||||
RegisteredState.REGISTERED
|
||||
} else {
|
||||
RegisteredState.NOT_REGISTERED
|
||||
}
|
||||
}
|
||||
|
||||
return create(
|
||||
resolved = true,
|
||||
groupName = null,
|
||||
systemContactName = record.systemDisplayName,
|
||||
isSelf = isSelf,
|
||||
registeredState = registeredState,
|
||||
record = record,
|
||||
participantIds = null,
|
||||
isReleaseChannel = isReleaseChannel,
|
||||
avatarColor = null,
|
||||
groupRecord = Optional.empty()
|
||||
)
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun forGroup(groupRecord: GroupRecord, recipientRecord: RecipientRecord, resolved: Boolean = true): Recipient {
|
||||
return create(
|
||||
resolved = resolved,
|
||||
groupName = groupRecord.title,
|
||||
systemContactName = null,
|
||||
isSelf = false,
|
||||
registeredState = recipientRecord.registered,
|
||||
record = recipientRecord,
|
||||
participantIds = groupRecord.members,
|
||||
isReleaseChannel = false,
|
||||
avatarColor = null,
|
||||
groupRecord = Optional.of(groupRecord)
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun forDistributionList(title: String?, members: List<RecipientId>?, record: RecipientRecord): Recipient {
|
||||
return create(
|
||||
resolved = true,
|
||||
groupName = title,
|
||||
systemContactName = null,
|
||||
isSelf = false,
|
||||
registeredState = record.registered,
|
||||
record = record,
|
||||
participantIds = members,
|
||||
isReleaseChannel = false,
|
||||
avatarColor = null,
|
||||
groupRecord = Optional.empty()
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun forCallLink(name: String?, record: RecipientRecord, avatarColor: AvatarColor): Recipient {
|
||||
return create(
|
||||
resolved = true,
|
||||
groupName = name,
|
||||
systemContactName = null,
|
||||
isSelf = false,
|
||||
registeredState = record.registered,
|
||||
record = record,
|
||||
participantIds = emptyList(),
|
||||
isReleaseChannel = false,
|
||||
avatarColor = avatarColor,
|
||||
groupRecord = Optional.empty()
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun forUnknown(): Recipient {
|
||||
return Recipient.UNKNOWN
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
fun create(
|
||||
resolved: Boolean,
|
||||
groupName: String?,
|
||||
systemContactName: String?,
|
||||
isSelf: Boolean,
|
||||
registeredState: RegisteredState,
|
||||
record: RecipientRecord,
|
||||
participantIds: List<RecipientId>?,
|
||||
isReleaseChannel: Boolean,
|
||||
avatarColor: AvatarColor?,
|
||||
groupRecord: Optional<GroupRecord>
|
||||
): Recipient {
|
||||
return Recipient(
|
||||
id = record.id,
|
||||
isResolving = !resolved,
|
||||
groupAvatarId = groupRecord.map { if (it.hasAvatar()) it.avatarId else null },
|
||||
systemContactPhoto = Util.uri(record.systemContactPhotoUri),
|
||||
customLabel = record.systemPhoneLabel,
|
||||
contactUri = Util.uri(record.systemContactUri),
|
||||
aciValue = record.aci,
|
||||
pniValue = record.pni,
|
||||
usernameValue = record.username,
|
||||
e164Value = record.e164,
|
||||
emailValue = record.email,
|
||||
groupIdValue = record.groupId,
|
||||
distributionListIdValue = record.distributionListId,
|
||||
messageRingtoneUri = record.messageRingtone,
|
||||
callRingtoneUri = record.callRingtone,
|
||||
muteUntil = record.muteUntil,
|
||||
messageVibrate = record.messageVibrateState,
|
||||
callVibrate = record.callVibrateState,
|
||||
isBlocked = record.isBlocked,
|
||||
expiresInSeconds = record.expireMessages,
|
||||
participantIdsValue = participantIds ?: LinkedList(),
|
||||
isActiveGroup = groupRecord.map { it.isActive }.orElse(false),
|
||||
profileName = record.signalProfileName,
|
||||
registeredValue = registeredState,
|
||||
profileKey = record.profileKey,
|
||||
expiringProfileKeyCredential = record.expiringProfileKeyCredential,
|
||||
profileAvatar = record.signalProfileAvatar,
|
||||
profileAvatarFileDetails = record.profileAvatarFileDetails,
|
||||
isProfileSharing = record.profileSharing,
|
||||
hiddenState = record.hiddenState,
|
||||
lastProfileFetchTime = record.lastProfileFetch,
|
||||
isSelf = isSelf,
|
||||
notificationChannelValue = record.notificationChannel,
|
||||
unidentifiedAccessModeValue = record.unidentifiedAccessMode,
|
||||
capabilities = record.capabilities,
|
||||
storageId = record.storageId,
|
||||
mentionSetting = record.mentionSetting,
|
||||
wallpaperValue = record.wallpaper,
|
||||
chatColorsValue = record.chatColors,
|
||||
avatarColor = avatarColor ?: record.avatarColor,
|
||||
about = record.about,
|
||||
aboutEmoji = record.aboutEmoji,
|
||||
systemProfileName = record.systemProfileName,
|
||||
groupName = groupName,
|
||||
systemContactName = systemContactName,
|
||||
extras = Optional.ofNullable(record.extras),
|
||||
hasGroupsInCommon = record.hasGroupsInCommon,
|
||||
badges = record.badges,
|
||||
isReleaseNotes = isReleaseChannel,
|
||||
needsPniSignature = record.needsPniSignature,
|
||||
callLinkRoomId = record.callLinkRoomId,
|
||||
groupRecord = groupRecord,
|
||||
phoneNumberSharing = record.phoneNumberSharing,
|
||||
nickname = record.nickname,
|
||||
note = record.note
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
package org.thoughtcrime.securesms.recipients
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import org.signal.libsignal.zkgroup.profiles.ExpiringProfileKeyCredential
|
||||
import org.thoughtcrime.securesms.badges.models.Badge
|
||||
import org.thoughtcrime.securesms.conversation.colors.AvatarColor
|
||||
import org.thoughtcrime.securesms.conversation.colors.ChatColors
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.MentionSetting
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.PhoneNumberSharingState
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.RegisteredState
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.UnidentifiedAccessMode
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.VibrateState
|
||||
import org.thoughtcrime.securesms.database.model.DistributionListId
|
||||
import org.thoughtcrime.securesms.database.model.GroupRecord
|
||||
import org.thoughtcrime.securesms.database.model.ProfileAvatarFileDetails
|
||||
import org.thoughtcrime.securesms.database.model.RecipientRecord
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName
|
||||
import org.thoughtcrime.securesms.recipients.Recipient.HiddenState
|
||||
import org.thoughtcrime.securesms.service.webrtc.links.CallLinkRoomId
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.PNI
|
||||
import java.util.LinkedList
|
||||
import java.util.Optional
|
||||
|
||||
class RecipientDetails private constructor(
|
||||
@JvmField val aci: ACI?,
|
||||
@JvmField val pni: PNI?,
|
||||
@JvmField val username: String?,
|
||||
@JvmField val e164: String?,
|
||||
@JvmField val email: String?,
|
||||
@JvmField val groupId: GroupId?,
|
||||
@JvmField val distributionListId: DistributionListId?,
|
||||
/** Used for groups, dlists, and call links */
|
||||
@JvmField val groupName: String?,
|
||||
@JvmField val systemContactName: String?,
|
||||
@JvmField val customLabel: String?,
|
||||
@JvmField val systemContactPhoto: Uri?,
|
||||
@JvmField val contactUri: Uri?,
|
||||
@JvmField val groupAvatarId: Optional<Long>,
|
||||
@JvmField val messageRingtone: Uri?,
|
||||
@JvmField val callRingtone: Uri?,
|
||||
@JvmField val mutedUntil: Long,
|
||||
@JvmField val messageVibrateState: VibrateState,
|
||||
@JvmField val callVibrateState: VibrateState,
|
||||
@JvmField val blocked: Boolean,
|
||||
@JvmField val expireMessages: Int,
|
||||
@JvmField val participantIds: List<RecipientId>,
|
||||
@JvmField val profileName: ProfileName,
|
||||
@JvmField val registered: RegisteredState,
|
||||
@JvmField val profileKey: ByteArray?,
|
||||
@JvmField val expiringProfileKeyCredential: ExpiringProfileKeyCredential?,
|
||||
@JvmField val profileAvatar: String?,
|
||||
@JvmField val profileAvatarFileDetails: ProfileAvatarFileDetails,
|
||||
@JvmField val profileSharing: Boolean,
|
||||
@JvmField val hiddenState: HiddenState,
|
||||
@JvmField val isActiveGroup: Boolean,
|
||||
@JvmField val lastProfileFetch: Long,
|
||||
@JvmField val isSelf: Boolean,
|
||||
@JvmField val notificationChannel: String?,
|
||||
@JvmField val unidentifiedAccessMode: UnidentifiedAccessMode,
|
||||
@JvmField val capabilities: RecipientRecord.Capabilities,
|
||||
@JvmField val storageId: ByteArray?,
|
||||
@JvmField val mentionSetting: MentionSetting,
|
||||
@JvmField val wallpaper: ChatWallpaper?,
|
||||
@JvmField val chatColors: ChatColors?,
|
||||
@JvmField val avatarColor: AvatarColor,
|
||||
@JvmField val about: String?,
|
||||
@JvmField val aboutEmoji: String?,
|
||||
@JvmField val systemProfileName: ProfileName,
|
||||
@JvmField val extras: Optional<Recipient.Extras>,
|
||||
@JvmField val hasGroupsInCommon: Boolean,
|
||||
@JvmField val badges: List<Badge>,
|
||||
@JvmField val isReleaseChannel: Boolean,
|
||||
@JvmField val needsPniSignature: Boolean,
|
||||
@JvmField val callLinkRoomId: CallLinkRoomId?,
|
||||
@JvmField val groupRecord: Optional<GroupRecord>,
|
||||
@JvmField val phoneNumberSharing: PhoneNumberSharingState,
|
||||
@JvmField val nickname: ProfileName,
|
||||
@JvmField val note: String?
|
||||
) {
|
||||
|
||||
@VisibleForTesting
|
||||
constructor(
|
||||
groupName: String?,
|
||||
systemContactName: String?,
|
||||
isSelf: Boolean,
|
||||
registeredState: RegisteredState,
|
||||
record: RecipientRecord,
|
||||
participantIds: List<RecipientId>?,
|
||||
isReleaseChannel: Boolean,
|
||||
avatarColor: AvatarColor?,
|
||||
groupRecord: Optional<GroupRecord>
|
||||
) : this(
|
||||
groupAvatarId = groupRecord.map { if (it.hasAvatar()) it.avatarId else null },
|
||||
systemContactPhoto = Util.uri(record.systemContactPhotoUri),
|
||||
customLabel = record.systemPhoneLabel,
|
||||
contactUri = Util.uri(record.systemContactUri),
|
||||
aci = record.aci,
|
||||
pni = record.pni,
|
||||
username = record.username,
|
||||
e164 = record.e164,
|
||||
email = record.email,
|
||||
groupId = record.groupId,
|
||||
distributionListId = record.distributionListId,
|
||||
messageRingtone = record.messageRingtone,
|
||||
callRingtone = record.callRingtone,
|
||||
mutedUntil = record.muteUntil,
|
||||
messageVibrateState = record.messageVibrateState,
|
||||
callVibrateState = record.callVibrateState,
|
||||
blocked = record.isBlocked,
|
||||
expireMessages = record.expireMessages,
|
||||
participantIds = participantIds ?: LinkedList(),
|
||||
isActiveGroup = groupRecord.map { it.isActive }.orElse(false),
|
||||
profileName = record.signalProfileName,
|
||||
registered = registeredState,
|
||||
profileKey = record.profileKey,
|
||||
expiringProfileKeyCredential = record.expiringProfileKeyCredential,
|
||||
profileAvatar = record.signalProfileAvatar,
|
||||
profileAvatarFileDetails = record.profileAvatarFileDetails,
|
||||
profileSharing = record.profileSharing,
|
||||
hiddenState = record.hiddenState,
|
||||
lastProfileFetch = record.lastProfileFetch,
|
||||
isSelf = isSelf,
|
||||
notificationChannel = record.notificationChannel,
|
||||
unidentifiedAccessMode = record.unidentifiedAccessMode,
|
||||
capabilities = record.capabilities,
|
||||
storageId = record.storageId,
|
||||
mentionSetting = record.mentionSetting,
|
||||
wallpaper = record.wallpaper,
|
||||
chatColors = record.chatColors,
|
||||
avatarColor = avatarColor ?: record.avatarColor,
|
||||
about = record.about,
|
||||
aboutEmoji = record.aboutEmoji,
|
||||
systemProfileName = record.systemProfileName,
|
||||
groupName = groupName,
|
||||
systemContactName = systemContactName,
|
||||
extras = Optional.ofNullable(record.extras),
|
||||
hasGroupsInCommon = record.hasGroupsInCommon,
|
||||
badges = record.badges,
|
||||
isReleaseChannel = isReleaseChannel,
|
||||
needsPniSignature = record.needsPniSignature,
|
||||
callLinkRoomId = record.callLinkRoomId,
|
||||
groupRecord = groupRecord,
|
||||
phoneNumberSharing = record.phoneNumberSharing,
|
||||
nickname = record.nickname,
|
||||
note = record.note
|
||||
)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun forIndividual(context: Context, record: RecipientRecord): RecipientDetails {
|
||||
val isSelf = record.e164 != null && record.e164 == SignalStore.account().e164 || record.aci != null && record.aci == SignalStore.account().aci
|
||||
val isReleaseChannel = record.id == SignalStore.releaseChannelValues().releaseChannelRecipientId
|
||||
var registeredState = record.registered
|
||||
|
||||
if (isSelf) {
|
||||
registeredState = if (SignalStore.account().isRegistered && !TextSecurePreferences.isUnauthorizedReceived(context)) {
|
||||
RegisteredState.REGISTERED
|
||||
} else {
|
||||
RegisteredState.NOT_REGISTERED
|
||||
}
|
||||
}
|
||||
|
||||
return RecipientDetails(
|
||||
groupName = null,
|
||||
systemContactName = record.systemDisplayName,
|
||||
isSelf = isSelf,
|
||||
registeredState = registeredState,
|
||||
record = record,
|
||||
participantIds = null,
|
||||
isReleaseChannel = isReleaseChannel,
|
||||
avatarColor = null,
|
||||
groupRecord = Optional.empty()
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun forGroup(groupRecord: GroupRecord, recipientRecord: RecipientRecord): RecipientDetails {
|
||||
return RecipientDetails(
|
||||
groupName = groupRecord.title,
|
||||
systemContactName = null,
|
||||
isSelf = false,
|
||||
registeredState = recipientRecord.registered,
|
||||
record = recipientRecord,
|
||||
participantIds = groupRecord.members,
|
||||
isReleaseChannel = false,
|
||||
avatarColor = null,
|
||||
groupRecord = Optional.of(groupRecord)
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun forDistributionList(title: String?, members: List<RecipientId>?, record: RecipientRecord): RecipientDetails {
|
||||
return RecipientDetails(
|
||||
groupName = title,
|
||||
systemContactName = null,
|
||||
isSelf = false,
|
||||
registeredState = record.registered,
|
||||
record = record,
|
||||
participantIds = members,
|
||||
isReleaseChannel = false,
|
||||
avatarColor = null,
|
||||
groupRecord = Optional.empty()
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun forCallLink(name: String?, record: RecipientRecord, avatarColor: AvatarColor): RecipientDetails {
|
||||
return RecipientDetails(
|
||||
groupName = name,
|
||||
systemContactName = null,
|
||||
isSelf = false,
|
||||
registeredState = record.registered,
|
||||
record = record,
|
||||
participantIds = emptyList(),
|
||||
isReleaseChannel = false,
|
||||
avatarColor = avatarColor,
|
||||
groupRecord = Optional.empty()
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun forUnknown(): RecipientDetails {
|
||||
return RecipientDetails(
|
||||
groupAvatarId = Optional.empty(),
|
||||
systemContactPhoto = null,
|
||||
customLabel = null,
|
||||
contactUri = null,
|
||||
aci = null,
|
||||
pni = null,
|
||||
username = null,
|
||||
e164 = null,
|
||||
email = null,
|
||||
groupId = null,
|
||||
distributionListId = null,
|
||||
messageRingtone = null,
|
||||
callRingtone = null,
|
||||
mutedUntil = 0,
|
||||
messageVibrateState = VibrateState.DEFAULT,
|
||||
callVibrateState = VibrateState.DEFAULT,
|
||||
blocked = false,
|
||||
expireMessages = 0,
|
||||
participantIds = LinkedList(),
|
||||
profileName = ProfileName.EMPTY,
|
||||
registered = RegisteredState.UNKNOWN,
|
||||
profileKey = null,
|
||||
expiringProfileKeyCredential = null,
|
||||
profileAvatar = null,
|
||||
profileAvatarFileDetails = ProfileAvatarFileDetails.NO_DETAILS,
|
||||
profileSharing = false,
|
||||
hiddenState = HiddenState.NOT_HIDDEN,
|
||||
lastProfileFetch = 0,
|
||||
isSelf = false,
|
||||
notificationChannel = null,
|
||||
unidentifiedAccessMode = UnidentifiedAccessMode.UNKNOWN,
|
||||
groupName = null,
|
||||
capabilities = RecipientRecord.Capabilities.UNKNOWN,
|
||||
storageId = null,
|
||||
mentionSetting = MentionSetting.ALWAYS_NOTIFY,
|
||||
wallpaper = null,
|
||||
chatColors = null,
|
||||
avatarColor = AvatarColor.UNKNOWN,
|
||||
about = null,
|
||||
aboutEmoji = null,
|
||||
systemProfileName = ProfileName.EMPTY,
|
||||
systemContactName = null,
|
||||
extras = Optional.empty(),
|
||||
hasGroupsInCommon = false,
|
||||
badges = emptyList(),
|
||||
isReleaseChannel = false,
|
||||
needsPniSignature = false,
|
||||
isActiveGroup = false,
|
||||
callLinkRoomId = null,
|
||||
groupRecord = Optional.empty(),
|
||||
phoneNumberSharing = PhoneNumberSharingState.UNKNOWN,
|
||||
nickname = ProfileName.EMPTY,
|
||||
note = ""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public final class RecipientExporter {
|
||||
}
|
||||
|
||||
private static void addAddressToIntent(Intent intent, Recipient recipient) {
|
||||
if (recipient.getE164().isPresent() && recipient.shouldShowE164()) {
|
||||
if (recipient.getE164().isPresent() && recipient.getShouldShowE164()) {
|
||||
intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipient.requireE164());
|
||||
} else if (recipient.getEmail().isPresent()) {
|
||||
intent.putExtra(ContactsContract.Intents.Insert.EMAIL, recipient.requireEmail());
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RecipientUtil {
|
||||
Log.i(TAG, "Successfully performed a UUID fetch for " + recipient.getId() + ". Registered: " + state);
|
||||
}
|
||||
|
||||
if (recipient.hasServiceId()) {
|
||||
if (recipient.getHasServiceId()) {
|
||||
return new SignalServiceAddress(recipient.requireServiceId(), Optional.ofNullable(recipient.resolve().getE164().orElse(null)));
|
||||
} else {
|
||||
throw new NotFoundException(recipient.getId() + " is not registered!");
|
||||
@@ -105,7 +105,7 @@ public class RecipientUtil {
|
||||
{
|
||||
List<Recipient> recipientsWithoutUuids = Stream.of(recipients)
|
||||
.map(Recipient::resolve)
|
||||
.filterNot(Recipient::hasServiceId)
|
||||
.filterNot(Recipient::getHasServiceId)
|
||||
.toList();
|
||||
|
||||
if (recipientsWithoutUuids.size() > 0) {
|
||||
|
||||
@@ -100,7 +100,7 @@ class AboutSheet : ComposeBottomSheetDialogFragment() {
|
||||
verified = verified,
|
||||
hasAvatar = recipient.get().profileAvatarFileDetails.hasFile(),
|
||||
recipientForAvatar = recipient.get(),
|
||||
formattedE164 = if (recipient.get().hasE164() && recipient.get().shouldShowE164()) {
|
||||
formattedE164 = if (recipient.get().hasE164 && recipient.get().shouldShowE164) {
|
||||
PhoneNumberFormatter.get(requireContext()).prettyPrintFormat(recipient.get().requireE164())
|
||||
} else {
|
||||
null
|
||||
|
||||
@@ -192,7 +192,7 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF
|
||||
: recipient.getDisplayName(requireContext());
|
||||
fullName.setVisibility(TextUtils.isEmpty(name) ? View.GONE : View.VISIBLE);
|
||||
SpannableStringBuilder nameBuilder = new SpannableStringBuilder(name);
|
||||
if (recipient.showVerified()) {
|
||||
if (recipient.getShowVerified()) {
|
||||
SpanUtil.appendSpacer(nameBuilder, 8);
|
||||
SpanUtil.appendCenteredImageSpanWithoutSpace(nameBuilder, ContextUtil.requireDrawable(requireContext(), R.drawable.ic_official_28), 28, 28);
|
||||
} else if (recipient.isSystemContact()) {
|
||||
@@ -303,7 +303,7 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF
|
||||
buttonStrip.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (recipient.isSystemContact() || recipient.isGroup() || recipient.isSelf() || recipient.isBlocked() || recipient.isReleaseNotes() || !recipient.hasE164() || !recipient.shouldShowE164()) {
|
||||
if (recipient.isSystemContact() || recipient.isGroup() || recipient.isSelf() || recipient.isBlocked() || recipient.isReleaseNotes() || !recipient.getHasE164() || !recipient.getShouldShowE164()) {
|
||||
addContactButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
addContactButton.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -152,7 +152,7 @@ final class RecipientDialogViewModel extends ViewModel {
|
||||
} else {
|
||||
activity.startActivity(StoryViewerActivity.createIntent(
|
||||
activity,
|
||||
new StoryViewerArgs.Builder(recipientDialogRepository.getRecipientId(), recipient.getValue().shouldHideStory())
|
||||
new StoryViewerArgs.Builder(recipientDialogRepository.getRecipientId(), recipient.getValue().getShouldHideStory())
|
||||
.isFromQuote(true)
|
||||
.build()));
|
||||
}
|
||||
@@ -192,7 +192,7 @@ final class RecipientDialogViewModel extends ViewModel {
|
||||
} else {
|
||||
activity.startActivity(StoryViewerActivity.createIntent(
|
||||
activity,
|
||||
new StoryViewerArgs.Builder(recipientDialogRepository.getRecipientId(), recipient.getValue().shouldHideStory())
|
||||
new StoryViewerArgs.Builder(recipientDialogRepository.getRecipientId(), recipient.getValue().getShouldHideStory())
|
||||
.isFromQuote(true)
|
||||
.build()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user