Show "Update" action button on profile name change.

This commit is contained in:
Nicholas Tinsley
2024-07-01 15:05:53 -04:00
committed by Cody Henthorne
parent a966812bfc
commit b113eec940
6 changed files with 32 additions and 1 deletions

View File

@@ -290,6 +290,8 @@ class V2ConversationItemShapeTest {
override fun onChangeNumberUpdateContact(recipient: Recipient) = Unit
override fun onChangeProfileNameUpdateContact(recipient: Recipient) = Unit
override fun onCallToAction(action: String) = Unit
override fun onDonateClicked() = Unit

View File

@@ -231,6 +231,10 @@ class InternalConversationTestFragment : Fragment(R.layout.conversation_test_fra
Toast.makeText(requireContext(), "Can't touch this.", Toast.LENGTH_SHORT).show()
}
override fun onChangeProfileNameUpdateContact(recipient: Recipient) {
Toast.makeText(requireContext(), "Can't touch this.", Toast.LENGTH_SHORT).show()
}
override fun onCallToAction(action: String) {
Toast.makeText(requireContext(), "Can't touch this.", Toast.LENGTH_SHORT).show()
}

View File

@@ -112,6 +112,7 @@ public interface BindableConversationItem extends Unbindable, GiphyMp4Playable,
void onInMemoryMessageClicked(@NonNull InMemoryMessageRecord messageRecord);
void onViewGroupDescriptionChange(@Nullable GroupId groupId, @NonNull String description, boolean isMessageRequestAccepted);
void onChangeNumberUpdateContact(@NonNull Recipient recipient);
void onChangeProfileNameUpdateContact(@NonNull Recipient recipient);
void onCallToAction(@NonNull String action);
void onDonateClicked();
void onBlockJoinRequest(@NonNull Recipient recipient);

View File

@@ -580,6 +580,14 @@ public final class ConversationUpdateItem extends FrameLayout
eventListener.onReportSpamLearnMoreClicked();
}
});
} else if (conversationMessage.getMessageRecord().isProfileChange() && !conversationMessage.getMessageRecord().getFromRecipient().isSelf()) {
actionButton.setText(R.string.ConversationUpdateItem_update);
actionButton.setVisibility(VISIBLE);
actionButton.setOnClickListener(v -> {
if (batchSelected.isEmpty() && eventListener != null) {
eventListener.onChangeProfileNameUpdateContact(conversationMessage.getMessageRecord().getFromRecipient());
}
});
} else if (conversationMessage.getMessageRecord().isMessageRequestAccepted()) {
actionButton.setText(R.string.ConversationUpdateItem_options);
actionButton.setVisibility(VISIBLE);
@@ -588,7 +596,7 @@ public final class ConversationUpdateItem extends FrameLayout
eventListener.onMessageRequestAcceptOptionsClicked();
}
});
} else{
} else {
actionButton.setVisibility(GONE);
actionButton.setOnClickListener(null);
}

View File

@@ -22,6 +22,7 @@ import android.graphics.Rect
import android.net.Uri
import android.os.Bundle
import android.provider.Browser
import android.provider.ContactsContract
import android.provider.Settings
import android.text.Editable
import android.text.TextWatcher
@@ -259,6 +260,7 @@ import org.thoughtcrime.securesms.mms.SlideDeck
import org.thoughtcrime.securesms.mms.SlideFactory
import org.thoughtcrime.securesms.mms.StickerSlide
import org.thoughtcrime.securesms.mms.VideoSlide
import org.thoughtcrime.securesms.nicknames.NicknameActivity
import org.thoughtcrime.securesms.notifications.v2.ConversationId
import org.thoughtcrime.securesms.payments.preferences.PaymentsActivity
import org.thoughtcrime.securesms.permissions.Permissions
@@ -2919,6 +2921,18 @@ class ConversationFragment :
startActivity(RecipientExporter.export(recipient).asAddContactIntent())
}
override fun onChangeProfileNameUpdateContact(recipient: Recipient) {
if (recipient.isSystemContact) {
startActivity(
Intent(Intent.ACTION_EDIT).apply {
setDataAndType(recipient.contactUri, ContactsContract.Contacts.CONTENT_ITEM_TYPE)
}
)
} else {
registerForActivityResult(NicknameActivity.Contract()) {}.launch(NicknameActivity.Args(recipientId = recipient.id, focusNoteFirst = false))
}
}
override fun onCallToAction(action: String) {
if ("gift_badge" == action) {
startActivity(CheckoutFlowActivity.createIntent(requireContext(), InAppPaymentType.ONE_TIME_GIFT))

View File

@@ -2955,6 +2955,8 @@
<string name="ConversationUpdateItem_hidden_contact_message_to_add_back">You have removed this person, messaging them again will add them back to your list.</string>
<!-- Update item button text shown for the accepted message request update message -->
<string name="ConversationUpdateItem_options">Options</string>
<!-- Update item button text shown for a profile name change. -->
<string name="ConversationUpdateItem_update">Update</string>
<!-- audio_view -->
<string name="audio_view__play_pause_accessibility_description">Play … Pause</string>