Convert Recipient to kotlin.

This commit is contained in:
Greyson Parrelli
2024-04-03 12:23:55 -04:00
parent b50eab230d
commit 3ba2b46bb0
100 changed files with 1513 additions and 2020 deletions

View File

@@ -65,7 +65,7 @@ public class ConversationHeaderView extends ConstraintLayout {
public void setAvatar(@NonNull RequestManager requestManager, @Nullable Recipient recipient) {
binding.messageRequestAvatar.setAvatar(requestManager, recipient, false);
if (recipient != null && recipient.shouldBlurAvatar() && recipient.getContactPhoto() != null) {
if (recipient != null && recipient.getShouldBlurAvatar() && recipient.getContactPhoto() != null) {
binding.messageRequestAvatarTapToView.setVisibility(VISIBLE);
binding.messageRequestAvatarTapToView.setOnClickListener(v -> {
SignalExecutors.BOUNDED.execute(() -> SignalDatabase.recipients().manuallyShowAvatar(recipient.getId()));
@@ -78,7 +78,7 @@ public class ConversationHeaderView extends ConstraintLayout {
public String setTitle(@NonNull Recipient recipient, @NonNull Runnable onTitleClicked) {
SpannableStringBuilder title = new SpannableStringBuilder(recipient.isSelf() ? getContext().getString(R.string.note_to_self) : recipient.getDisplayName(getContext()));
if (recipient.showVerified()) {
if (recipient.getShowVerified()) {
SpanUtil.appendCenteredImageSpan(title, ContextUtil.requireDrawable(getContext(), R.drawable.ic_official_28), 28, 28);
}

View File

@@ -647,10 +647,10 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
}
if (conversationRecipient.getId().equals(modified.getId())) {
setBubbleState(messageRecord, modified, modified.hasWallpaper(), colorizer);
setBubbleState(messageRecord, modified, modified.getHasWallpaper(), colorizer);
if (quoteView != null) {
quoteView.setWallpaperEnabled(modified.hasWallpaper());
quoteView.setWallpaperEnabled(modified.getHasWallpaper());
}
if (audioViewStub.resolved()) {

View File

@@ -138,7 +138,7 @@ internal object ConversationOptionsMenu {
if (recipient.isMuted) menuInflater.inflate(R.menu.conversation_muted, menu) else menuInflater.inflate(R.menu.conversation_unmuted, menu)
if (!recipient.isGroup && recipient.contactUri == null && !recipient.isReleaseNotes && !recipient.isSelf && recipient.hasE164() && recipient.shouldShowE164()) {
if (!recipient.isGroup && recipient.contactUri == null && !recipient.isReleaseNotes && !recipient.isSelf && recipient.hasE164 && recipient.shouldShowE164) {
menuInflater.inflate(R.menu.conversation_add_to_contacts, menu)
}

View File

@@ -77,14 +77,14 @@ public class ConversationRepository {
if (group.isPresent()) {
List<Recipient> recipients = Recipient.resolvedList(group.get().getMembers());
for (Recipient recipient : recipients) {
if ((recipient.isProfileSharing() || recipient.hasGroupsInCommon()) && !recipient.isSelf()) {
if ((recipient.isProfileSharing() || recipient.getHasGroupsInCommon()) && !recipient.isSelf()) {
recipientIsKnownOrHasGroupsInCommon = true;
break;
}
}
}
isGroup = true;
} else if (conversationRecipient.hasGroupsInCommon()) {
} else if (conversationRecipient.getHasGroupsInCommon()) {
recipientIsKnownOrHasGroupsInCommon = true;
}
messageRequestData = new ConversationData.MessageRequestData(isMessageRequestAccepted, isConversationHidden, recipientIsKnownOrHasGroupsInCommon, isGroup);

View File

@@ -137,7 +137,7 @@ public class ConversationTitleView extends ConstraintLayout {
endDrawable = DrawableUtil.tint(endDrawable, ContextCompat.getColor(getContext(), R.color.signal_inverse_transparent_80));
}
if (recipient != null && recipient.showVerified()) {
if (recipient != null && recipient.getShowVerified()) {
endDrawable = ContextUtil.requireDrawable(getContext(), R.drawable.ic_official_24);
}

View File

@@ -356,7 +356,7 @@ public final class ConversationUpdateItem extends FrameLayout
Set<UUID> members = liveFullMembers.getValue();
if (members != null) {
return recipient.hasAci() && members.contains(recipient.requireAci().getRawUuid());
return recipient.getHasAci() && members.contains(recipient.requireAci().getRawUuid());
}
return false;
}
@@ -591,7 +591,7 @@ public final class ConversationUpdateItem extends FrameLayout
private boolean shouldShowBlockRequestAction(MessageRecord messageRecord) {
Recipient toBlock = messageRecord.getFromRecipient();
if (!toBlock.hasServiceId() || !groupData.isSelfAdmin() || groupData.isBanned(toBlock) || groupData.isFullMember(toBlock)) {
if (!toBlock.getHasServiceId() || !groupData.isSelfAdmin() || groupData.isBanned(toBlock) || groupData.isFullMember(toBlock)) {
return false;
}

View File

@@ -91,7 +91,7 @@ class ScheduledMessagesBottomSheet : FixedRoundedCornerBottomSheetDialogFragment
val colorizer = Colorizer()
messageAdapter = ConversationAdapter(requireContext(), viewLifecycleOwner, Glide.with(this), Locale.getDefault(), ConversationAdapterListener(), conversationRecipient.hasWallpaper(), colorizer).apply {
messageAdapter = ConversationAdapter(requireContext(), viewLifecycleOwner, Glide.with(this), Locale.getDefault(), ConversationAdapterListener(), conversationRecipient.hasWallpaper, colorizer).apply {
setCondensedMode(ConversationItemDisplayMode.Condensed(scheduleMessageMode = true))
}

View File

@@ -100,7 +100,7 @@ class Colorizer {
groupSenderColors[recipient.id] = color
return color.getColor(context)
} else {
getIncomingBodyTextColor(context, recipient.hasWallpaper())
getIncomingBodyTextColor(context, recipient.hasWallpaper)
}
}
}

View File

@@ -73,7 +73,7 @@ class MessageQuotesBottomSheet : FixedRoundedCornerBottomSheetDialogFragment() {
val colorizer = Colorizer()
messageAdapter = ConversationAdapter(requireContext(), viewLifecycleOwner, Glide.with(this), Locale.getDefault(), ConversationAdapterListener(), conversationRecipient.hasWallpaper(), colorizer).apply {
messageAdapter = ConversationAdapter(requireContext(), viewLifecycleOwner, Glide.with(this), Locale.getDefault(), ConversationAdapterListener(), conversationRecipient.hasWallpaper, colorizer).apply {
setCondensedMode(ConversationItemDisplayMode.Condensed(scheduleMessageMode = false))
}

View File

@@ -88,7 +88,7 @@ class EditMessageHistoryDialog : FixedRoundedCornerBottomSheetDialogFragment() {
Glide.with(this),
Locale.getDefault(),
ConversationAdapterListener(),
conversationRecipient.hasWallpaper(),
conversationRecipient.hasWallpaper,
colorizer
).apply {
setCondensedMode(ConversationItemDisplayMode.EditHistory)

View File

@@ -43,17 +43,17 @@ class PaymentMessageView @JvmOverloads constructor(
setTextColor(colorizer.getOutgoingFooterTextColor(context))
} else {
text = context.getString(R.string.PaymentMessageView_s_sent_you, recipient.getShortDisplayName(context))
setTextColor(colorizer.getIncomingFooterTextColor(context, recipient.hasWallpaper()))
setTextColor(colorizer.getIncomingFooterTextColor(context, recipient.hasWallpaper))
}
}
binding.paymentNote.apply {
text = payment.note
visible = payment.note.isNotEmpty()
setTextColor(if (outgoing) colorizer.getOutgoingBodyTextColor(context) else colorizer.getIncomingBodyTextColor(context, recipient.hasWallpaper()))
setTextColor(if (outgoing) colorizer.getOutgoingBodyTextColor(context) else colorizer.getIncomingBodyTextColor(context, recipient.hasWallpaper))
}
val quoteViewColorTheme = QuoteViewColorTheme.resolveTheme(outgoing, false, recipient.hasWallpaper())
val quoteViewColorTheme = QuoteViewColorTheme.resolveTheme(outgoing, false, recipient.hasWallpaper)
if (payment.state.isInProgress) {
binding.paymentAmount.visible = false

View File

@@ -572,7 +572,7 @@ class ConversationAdapterV2(
val isSelf = recipient.id == Recipient.self().id
conversationBanner.setAvatar(requestManager, recipient)
conversationBanner.showBackgroundBubble(recipient.hasWallpaper())
conversationBanner.showBackgroundBubble(recipient.hasWallpaper)
val title: String = conversationBanner.setTitle(recipient) {
displayDialogFragment(AboutSheet.create(recipient))
}
@@ -590,7 +590,7 @@ class ConversationAdapterV2(
} else if (isSelf) {
conversationBanner.setSubtitle(context.getString(R.string.ConversationFragment__you_can_add_notes_for_yourself_in_this_conversation), R.drawable.symbol_note_light_24)
} else {
val subtitle: String? = recipient.takeIf { it.shouldShowE164() }?.e164?.map { e164: String? -> PhoneNumberFormatter.prettyPrint(e164!!) }?.orElse(null)
val subtitle: String? = recipient.takeIf { it.shouldShowE164 }?.e164?.map { e164: String? -> PhoneNumberFormatter.prettyPrint(e164!!) }?.orElse(null)
if (subtitle == null || subtitle == title) {
conversationBanner.hideSubtitle()
} else {

View File

@@ -1106,7 +1106,7 @@ class ConversationFragment :
ConversationTypingIndicatorAdapter.State(
typists = it.typists,
isGroupThread = recipient.isGroup,
hasWallpaper = recipient.hasWallpaper(),
hasWallpaper = recipient.hasWallpaper,
isReplacedByIncomingMessage = it.isReplacedByIncomingMessage
)
)
@@ -1124,7 +1124,7 @@ class ConversationFragment :
binding.conversationTitleView.conversationTitleView.setOnStoryRingClickListener {
val recipient: Recipient = viewModel.recipientSnapshot ?: return@setOnStoryRingClickListener
val args = StoryViewerArgs.Builder(recipient.id, recipient.shouldHideStory())
val args = StoryViewerArgs.Builder(recipient.id, recipient.shouldHideStory)
.isFromQuote(true)
.build()
@@ -1889,7 +1889,7 @@ class ConversationFragment :
private fun handleRecentSafetyNumberChange(changedRecords: List<IdentityRecord>) {
val recipient = viewModel.recipientSnapshot ?: return
SafetyNumberBottomSheet
.forIdentityRecordsAndDestination(changedRecords, RecipientSearchKey(recipient.getId(), false))
.forIdentityRecordsAndDestination(changedRecords, RecipientSearchKey(recipient.id, false))
.show(childFragmentManager)
}
@@ -2607,7 +2607,7 @@ class ConversationFragment :
startActivity(
StoryViewerActivity.createIntent(
requireContext(),
StoryViewerArgs.Builder(quote.author, Recipient.resolved(quote.author).shouldHideStory())
StoryViewerArgs.Builder(quote.author, Recipient.resolved(quote.author).shouldHideStory)
.withStoryId(parentStoryId.asMessageId().id)
.isFromQuote(true)
.build()

View File

@@ -80,7 +80,7 @@ class DisabledInputView @JvmOverloads constructor(
create = { MessageRequestsBottomView(context) },
bind = {
setMessageRequestData(recipient, messageRequestState)
setWallpaperEnabled(recipient.hasWallpaper())
setWallpaperEnabled(recipient.hasWallpaper)
setAcceptOnClickListener { listener?.onAcceptMessageRequestClicked() }
setDeleteOnClickListener { listener?.onDeleteClicked() }

View File

@@ -77,7 +77,7 @@ class AttachmentKeyboardFragment : LoggingFragment(R.layout.attachment_keyboard_
.recipient
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy {
attachmentKeyboardView.setWallpaperEnabled(it.hasWallpaper())
attachmentKeyboardView.setWallpaperEnabled(it.hasWallpaper)
updatePaymentsAvailable(it)
}
.addTo(lifecycleDisposable)