mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Convert Recipient to kotlin.
This commit is contained in:
@@ -33,7 +33,7 @@ class ContactsManagementRepository(context: Context) {
|
||||
error("Cannot hide groups, self, or distribution lists.")
|
||||
}
|
||||
|
||||
val rotateProfileKey = !recipient.hasGroupsInCommon()
|
||||
val rotateProfileKey = !recipient.hasGroupsInCommon
|
||||
SignalDatabase.recipients.markHidden(recipient.id, rotateProfileKey, false)
|
||||
if (rotateProfileKey) {
|
||||
ApplicationDependencies.getJobManager().add(RotateProfileKeyJob())
|
||||
|
||||
@@ -309,9 +309,8 @@ open class ContactSearchAdapter(
|
||||
}
|
||||
|
||||
private class MyStoryFallbackPhotoProvider(private val name: String, private val targetSize: Int) : Recipient.FallbackPhotoProvider() {
|
||||
override fun getPhotoForLocalNumber(): FallbackContactPhoto {
|
||||
return GeneratedContactPhoto(name, R.drawable.symbol_person_40, targetSize)
|
||||
}
|
||||
override val photoForLocalNumber: FallbackContactPhoto
|
||||
get() = GeneratedContactPhoto(name, R.drawable.symbol_person_40, targetSize)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
@@ -461,7 +460,7 @@ open class ContactSearchAdapter(
|
||||
} else if (displayOptions.displaySecondaryInformation == DisplaySecondaryInformation.ALWAYS && recipient.combinedAboutAndEmoji != null) {
|
||||
number.text = recipient.combinedAboutAndEmoji
|
||||
number.visible = true
|
||||
} else if (displayOptions.displaySecondaryInformation == DisplaySecondaryInformation.ALWAYS && recipient.hasE164()) {
|
||||
} else if (displayOptions.displaySecondaryInformation == DisplaySecondaryInformation.ALWAYS && recipient.hasE164) {
|
||||
number.visible = false
|
||||
} else {
|
||||
super.bindNumberField(model)
|
||||
@@ -527,7 +526,7 @@ open class ContactSearchAdapter(
|
||||
}
|
||||
|
||||
val recipient = getRecipient(model)
|
||||
val suffix: CharSequence? = if (recipient.isSystemContact && !recipient.showVerified()) {
|
||||
val suffix: CharSequence? = if (recipient.isSystemContact && !recipient.showVerified) {
|
||||
SpannableStringBuilder().apply {
|
||||
val drawable = ContextUtil.requireDrawable(context, R.drawable.symbol_person_circle_24).apply {
|
||||
setTint(ContextCompat.getColor(context, R.color.signal_colorOnSurface))
|
||||
|
||||
@@ -45,7 +45,7 @@ class SafetyNumberRepository(
|
||||
stopwatch.split("recipient-ids")
|
||||
|
||||
val recentIds = recentlyFetched.filter { (_, timestamp) -> (now - timestamp) < RECENT_TIME_WINDOW }.keys
|
||||
val recipients = Recipient.resolvedList(recipientIds - recentIds).filter { it.hasServiceId() }
|
||||
val recipients = Recipient.resolvedList(recipientIds - recentIds).filter { it.hasServiceId }
|
||||
stopwatch.split("recipient-resolve")
|
||||
|
||||
if (recipients.isNotEmpty()) {
|
||||
|
||||
@@ -207,7 +207,7 @@ object ContactDiscovery {
|
||||
if (!SignalStore.settings().isNotifyWhenContactJoinsSignal) return
|
||||
|
||||
Recipient.resolvedList(newUserIds)
|
||||
.filter { !it.isSelf && it.hasAUserSetDisplayName(context) && !hasSession(it.id) && it.hasE164() }
|
||||
.filter { !it.isSelf && it.hasAUserSetDisplayName(context) && !hasSession(it.id) && it.hasE164 }
|
||||
.map {
|
||||
Log.i(TAG, "Inserting 'contact joined' message for ${it.id}. E164: ${it.e164}")
|
||||
val message = IncomingMessage.contactJoined(it.id, System.currentTimeMillis())
|
||||
@@ -295,7 +295,7 @@ object ContactDiscovery {
|
||||
private fun hasSession(id: RecipientId): Boolean {
|
||||
val recipient = Recipient.resolved(id)
|
||||
|
||||
if (!recipient.hasServiceId()) {
|
||||
if (!recipient.hasServiceId) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ object ContactDiscoveryRefreshV2 {
|
||||
|
||||
private fun hasCommunicatedWith(recipient: Recipient): Boolean {
|
||||
val localAci = SignalStore.account().requireAci()
|
||||
return SignalDatabase.threads.hasActiveThread(recipient.id) || (recipient.hasServiceId() && SignalDatabase.sessions.hasSessionFor(localAci, recipient.requireServiceId().toString()))
|
||||
return SignalDatabase.threads.hasActiveThread(recipient.id) || (recipient.hasServiceId && SignalDatabase.sessions.hasSessionFor(localAci, recipient.requireServiceId().toString()))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +241,7 @@ object ContactDiscoveryRefreshV2 {
|
||||
val selfId = Recipient.self().id
|
||||
return this - Recipient.resolvedList(this)
|
||||
.filter {
|
||||
(it.hasServiceId() && hasCommunicatedWith(it)) || it.id == selfId
|
||||
(it.hasServiceId && hasCommunicatedWith(it)) || it.id == selfId
|
||||
}
|
||||
.map { it.id }
|
||||
.toSet()
|
||||
|
||||
Reference in New Issue
Block a user