mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Convert Recipient to kotlin.
This commit is contained in:
@@ -176,7 +176,7 @@ public final class AvatarImageView extends AppCompatImageView {
|
||||
new ProfileContactPhoto(Recipient.self()))
|
||||
: new RecipientContactPhoto(recipient);
|
||||
|
||||
boolean shouldBlur = recipient.shouldBlurAvatar();
|
||||
boolean shouldBlur = recipient.getShouldBlurAvatar();
|
||||
ChatColors chatColors = recipient.getChatColors();
|
||||
|
||||
if (!photo.equals(recipientContactPhoto) || shouldBlur != blurred || !Objects.equals(chatColors, this.chatColors)) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FromTextView extends SimpleEmojiTextView {
|
||||
builder.append(suffix);
|
||||
}
|
||||
|
||||
if (asThread && recipient.showVerified()) {
|
||||
if (asThread && recipient.getShowVerified()) {
|
||||
Drawable official = ContextUtil.requireDrawable(getContext(), R.drawable.ic_official_20);
|
||||
official.setBounds(0, 0, ViewUtil.dpToPx(20), ViewUtil.dpToPx(20));
|
||||
|
||||
|
||||
@@ -215,15 +215,15 @@ class ChangeNumberRepository(
|
||||
|
||||
@WorkerThread
|
||||
fun changeLocalNumber(e164: String, pni: PNI): Single<Unit> {
|
||||
val oldStorageId: ByteArray? = Recipient.self().storageServiceId
|
||||
val oldStorageId: ByteArray? = Recipient.self().storageId
|
||||
SignalDatabase.recipients.updateSelfE164(e164, pni)
|
||||
val newStorageId: ByteArray? = Recipient.self().storageServiceId
|
||||
val newStorageId: ByteArray? = Recipient.self().storageId
|
||||
|
||||
if (e164 != SignalStore.account().requireE164() && MessageDigest.isEqual(oldStorageId, newStorageId)) {
|
||||
Log.w(TAG, "Self storage id was not rotated, attempting to rotate again")
|
||||
SignalDatabase.recipients.rotateStorageId(Recipient.self().id)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
val secondAttemptStorageId: ByteArray? = Recipient.self().storageServiceId
|
||||
val secondAttemptStorageId: ByteArray? = Recipient.self().storageId
|
||||
if (MessageDigest.isEqual(oldStorageId, secondAttemptStorageId)) {
|
||||
Log.w(TAG, "Second attempt also failed to rotate storage id")
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||
requireContext(),
|
||||
StoryViewerArgs(
|
||||
recipientId = state.recipient.id,
|
||||
isInHiddenStoryMode = state.recipient.shouldHideStory(),
|
||||
isInHiddenStoryMode = state.recipient.shouldHideStory,
|
||||
isFromQuote = true
|
||||
)
|
||||
)
|
||||
|
||||
@@ -180,7 +180,7 @@ sealed class ConversationSettingsViewModel(
|
||||
contactLinkState = when {
|
||||
recipient.isSelf || recipient.isReleaseNotes || recipient.isBlocked -> ContactLinkState.NONE
|
||||
recipient.isSystemContact -> ContactLinkState.OPEN
|
||||
recipient.hasE164() && recipient.shouldShowE164() -> ContactLinkState.ADD
|
||||
recipient.hasE164 && recipient.shouldShowE164 -> ContactLinkState.ADD
|
||||
else -> ContactLinkState.NONE
|
||||
}
|
||||
)
|
||||
|
||||
@@ -174,10 +174,10 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||
.setTitle("Are you sure?")
|
||||
.setNegativeButton(android.R.string.cancel) { d, _ -> d.dismiss() }
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
if (recipient.hasAci()) {
|
||||
if (recipient.hasAci) {
|
||||
SignalDatabase.sessions.deleteAllFor(serviceId = SignalStore.account().requireAci(), addressName = recipient.requireAci().toString())
|
||||
}
|
||||
if (recipient.hasPni()) {
|
||||
if (recipient.hasPni) {
|
||||
SignalDatabase.sessions.deleteAllFor(serviceId = SignalStore.account().requireAci(), addressName = recipient.requirePni().toString())
|
||||
}
|
||||
}
|
||||
@@ -196,18 +196,18 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
SignalDatabase.threads.deleteConversation(SignalDatabase.threads.getThreadIdIfExistsFor(recipient.id))
|
||||
|
||||
if (recipient.hasServiceId()) {
|
||||
if (recipient.hasServiceId) {
|
||||
SignalDatabase.recipients.debugClearServiceIds(recipient.id)
|
||||
SignalDatabase.recipients.debugClearProfileData(recipient.id)
|
||||
}
|
||||
|
||||
if (recipient.hasAci()) {
|
||||
if (recipient.hasAci) {
|
||||
SignalDatabase.sessions.deleteAllFor(serviceId = SignalStore.account().requireAci(), addressName = recipient.requireAci().toString())
|
||||
SignalDatabase.sessions.deleteAllFor(serviceId = SignalStore.account().requirePni(), addressName = recipient.requireAci().toString())
|
||||
ApplicationDependencies.getProtocolStore().aci().identities().delete(recipient.requireAci().toString())
|
||||
}
|
||||
|
||||
if (recipient.hasPni()) {
|
||||
if (recipient.hasPni) {
|
||||
SignalDatabase.sessions.deleteAllFor(serviceId = SignalStore.account().requireAci(), addressName = recipient.requirePni().toString())
|
||||
SignalDatabase.sessions.deleteAllFor(serviceId = SignalStore.account().requirePni(), addressName = recipient.requirePni().toString())
|
||||
ApplicationDependencies.getProtocolStore().aci().identities().delete(recipient.requirePni().toString())
|
||||
@@ -252,7 +252,7 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||
.setTitle("Are you sure?")
|
||||
.setNegativeButton(android.R.string.cancel) { d, _ -> d.dismiss() }
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
if (!recipient.hasE164()) {
|
||||
if (!recipient.hasE164) {
|
||||
Toast.makeText(context, "Recipient doesn't have an E164! Can't split.", Toast.LENGTH_SHORT).show()
|
||||
return@setPositiveButton
|
||||
}
|
||||
|
||||
@@ -75,8 +75,7 @@ object AvatarPreference {
|
||||
}
|
||||
|
||||
private class AvatarPreferenceFallbackPhotoProvider : Recipient.FallbackPhotoProvider() {
|
||||
override fun getPhotoForGroup(): FallbackContactPhoto {
|
||||
return FallbackPhoto(R.drawable.ic_group_outline_40, ViewUtil.dpToPx(8))
|
||||
}
|
||||
override val photoForGroup: FallbackContactPhoto
|
||||
get() = FallbackPhoto(R.drawable.ic_group_outline_40, ViewUtil.dpToPx(8))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,12 +48,12 @@ object BioTextPreference {
|
||||
recipient.getDisplayName(context)
|
||||
}
|
||||
|
||||
if (!recipient.showVerified() && !recipient.isIndividual) {
|
||||
if (!recipient.showVerified && !recipient.isIndividual) {
|
||||
return name
|
||||
}
|
||||
|
||||
return SpannableStringBuilder(name).apply {
|
||||
if (recipient.showVerified()) {
|
||||
if (recipient.showVerified) {
|
||||
SpanUtil.appendSpacer(this, 8)
|
||||
SpanUtil.appendCenteredImageSpanWithoutSpace(this, ContextUtil.requireDrawable(context, R.drawable.ic_official_28), 28, 28)
|
||||
} else if (recipient.isSystemContact) {
|
||||
|
||||
@@ -151,7 +151,7 @@ data class CallParticipantsState(
|
||||
fun getIncomingRingingGroupDescription(context: Context): String? {
|
||||
if (callState == WebRtcViewModel.State.CALL_INCOMING &&
|
||||
groupCallState == WebRtcViewModel.GroupCallState.RINGING &&
|
||||
ringerRecipient.hasServiceId()
|
||||
ringerRecipient.hasServiceId
|
||||
) {
|
||||
val ringerName = ringerRecipient.getShortDisplayName(context)
|
||||
val membersWithoutYouOrRinger: List<GroupMemberEntry.FullMember> = groupMembers.filterNot { it.member.isSelf || ringerRecipient.requireServiceId() == it.member.serviceId.orElse(null) }
|
||||
|
||||
@@ -16,7 +16,7 @@ class CallLinkIncomingRequestRepository {
|
||||
|
||||
fun getGroupsInCommon(recipientId: RecipientId): Observable<GroupsInCommon> {
|
||||
return Recipient.observable(recipientId).flatMapSingle { recipient ->
|
||||
if (recipient.hasGroupsInCommon()) {
|
||||
if (recipient.hasGroupsInCommon) {
|
||||
Single.fromCallable {
|
||||
val groupsInCommon = SignalDatabase.groups.getGroupsContainingMember(recipient.id, true)
|
||||
val total = groupsInCommon.size
|
||||
|
||||
Reference in New Issue
Block a user