mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 05:48:34 +00:00
Add feature flag to new Profile display.
This commit is contained in:
parent
d8714fe3b4
commit
f85c3bb1e6
@ -91,6 +91,20 @@
|
|||||||
tools:text="+14152222222"
|
tools:text="+14152222222"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/group_message_sender_profile"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="4sp"
|
||||||
|
android:paddingEnd="4sp"
|
||||||
|
style="@style/Signal.Text.Preview"
|
||||||
|
android:fontFamily="sans-serif-regular"
|
||||||
|
android:textColor="?conversation_item_received_text_primary_color"
|
||||||
|
android:textStyle="italic"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
tools:text="~Clement Duval"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.QuoteView
|
<org.thoughtcrime.securesms.components.QuoteView
|
||||||
|
@ -143,6 +143,12 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/group_message_sender_profile"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.ConversationItemFooter
|
<org.thoughtcrime.securesms.components.ConversationItemFooter
|
||||||
android:id="@+id/conversation_item_footer"
|
android:id="@+id/conversation_item_footer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -26,6 +26,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId;
|
|||||||
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||||
import org.thoughtcrime.securesms.util.Base64;
|
import org.thoughtcrime.securesms.util.Base64;
|
||||||
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
import org.thoughtcrime.securesms.util.VerifySpan;
|
import org.thoughtcrime.securesms.util.VerifySpan;
|
||||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
@ -49,7 +50,7 @@ public class ConfirmIdentityDialog extends AlertDialog {
|
|||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
Recipient recipient = Recipient.resolved(mismatch.getRecipientId(context));
|
Recipient recipient = Recipient.resolved(mismatch.getRecipientId(context));
|
||||||
String name = recipient.getDisplayName(context);
|
String name = recipient.toShortString(context);
|
||||||
String introduction = context.getString(R.string.ConfirmIdentityDialog_your_safety_number_with_s_has_changed, name, name);
|
String introduction = context.getString(R.string.ConfirmIdentityDialog_your_safety_number_with_s_has_changed, name, name);
|
||||||
SpannableString spannableString = new SpannableString(introduction + " " +
|
SpannableString spannableString = new SpannableString(introduction + " " +
|
||||||
context.getString(R.string.ConfirmIdentityDialog_you_may_wish_to_verify_your_safety_number_with_this_contact));
|
context.getString(R.string.ConfirmIdentityDialog_you_may_wish_to_verify_your_safety_number_with_this_contact));
|
||||||
|
@ -499,7 +499,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
if (failIfNotPush && !isPush) {
|
if (failIfNotPush && !isPush) {
|
||||||
results.add(new Result(null, false, activity.getString(R.string.GroupCreateActivity_cannot_add_non_push_to_existing_group,
|
results.add(new Result(null, false, activity.getString(R.string.GroupCreateActivity_cannot_add_non_push_to_existing_group,
|
||||||
recipient.getDisplayName(activity))));
|
recipient.toShortString(activity))));
|
||||||
} else if (TextUtils.equals(TextSecurePreferences.getLocalNumber(activity), recipient.getE164().or(""))) {
|
} else if (TextUtils.equals(TextSecurePreferences.getLocalNumber(activity), recipient.getE164().or(""))) {
|
||||||
results.add(new Result(null, false, activity.getString(R.string.GroupCreateActivity_youre_already_in_the_group)));
|
results.add(new Result(null, false, activity.getString(R.string.GroupCreateActivity_youre_already_in_the_group)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -10,6 +10,7 @@ import android.text.TextUtils;
|
|||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientExporter;
|
import org.thoughtcrime.securesms.recipients.RecipientExporter;
|
||||||
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -105,7 +106,7 @@ public class GroupMembersDialog extends AsyncTask<Void, Void, List<Recipient>> {
|
|||||||
if (recipient.isLocalNumber()) {
|
if (recipient.isLocalNumber()) {
|
||||||
recipientStrings.add(context.getString(R.string.GroupMembersDialog_me));
|
recipientStrings.add(context.getString(R.string.GroupMembersDialog_me));
|
||||||
} else {
|
} else {
|
||||||
String name = recipient.getDisplayName(context);
|
String name = getRecipientName(recipient);
|
||||||
recipientStrings.add(name);
|
recipientStrings.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,6 +114,18 @@ public class GroupMembersDialog extends AsyncTask<Void, Void, List<Recipient>> {
|
|||||||
return recipientStrings.toArray(new String[members.size()]);
|
return recipientStrings.toArray(new String[members.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getRecipientName(Recipient recipient) {
|
||||||
|
if (FeatureFlags.PROFILE_DISPLAY) return recipient.getDisplayName(context);
|
||||||
|
|
||||||
|
String name = recipient.toShortString(context);
|
||||||
|
|
||||||
|
if (recipient.getName(context) == null && !TextUtils.isEmpty(recipient.getProfileName())) {
|
||||||
|
name += " ~" + recipient.getProfileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public Recipient get(int index) {
|
public Recipient get(int index) {
|
||||||
return members.get(index);
|
return members.get(index);
|
||||||
}
|
}
|
||||||
|
@ -139,9 +139,9 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity {
|
|||||||
|
|
||||||
private void initializeToolbar() {
|
private void initializeToolbar() {
|
||||||
setSupportActionBar(this.toolbar);
|
setSupportActionBar(this.toolbar);
|
||||||
getSupportActionBar().setTitle(recipient.get().getDisplayName(this));
|
getSupportActionBar().setTitle(recipient.get().toShortString(this));
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
this.recipient.observe(this, recipient -> getSupportActionBar().setTitle(recipient.getDisplayName(this)));
|
this.recipient.observe(this, recipient -> getSupportActionBar().setTitle(recipient.toShortString(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnterMultiSelect() {
|
public void onEnterMultiSelect() {
|
||||||
|
@ -160,7 +160,7 @@ public final class MediaPreviewActivity extends PassphraseRequiredActionBarActiv
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mediaItem.outgoing) getSupportActionBar().setTitle(getString(R.string.MediaPreviewActivity_you));
|
if (mediaItem.outgoing) getSupportActionBar().setTitle(getString(R.string.MediaPreviewActivity_you));
|
||||||
else if (mediaItem.recipient != null) getSupportActionBar().setTitle(mediaItem.recipient.getDisplayName(this));
|
else if (mediaItem.recipient != null) getSupportActionBar().setTitle(mediaItem.recipient.toShortString(this));
|
||||||
else getSupportActionBar().setTitle("");
|
else getSupportActionBar().setTitle("");
|
||||||
|
|
||||||
getSupportActionBar().setSubtitle(relativeTimeSpan);
|
getSupportActionBar().setSubtitle(relativeTimeSpan);
|
||||||
|
@ -38,6 +38,8 @@ import org.thoughtcrime.securesms.database.GroupDatabase;
|
|||||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||||
import org.thoughtcrime.securesms.jobs.RotateProfileKeyJob;
|
import org.thoughtcrime.securesms.jobs.RotateProfileKeyJob;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
|
||||||
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -79,6 +81,7 @@ import org.thoughtcrime.securesms.util.Dialogs;
|
|||||||
import org.thoughtcrime.securesms.util.DynamicDarkToolbarTheme;
|
import org.thoughtcrime.securesms.util.DynamicDarkToolbarTheme;
|
||||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||||
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||||
import org.thoughtcrime.securesms.util.IdentityUtil;
|
import org.thoughtcrime.securesms.util.IdentityUtil;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
@ -225,7 +228,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
|||||||
else this.avatar.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
else this.avatar.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
|
|
||||||
this.avatar.setBackgroundColor(recipient.getColor().toActionBarColor(this));
|
this.avatar.setBackgroundColor(recipient.getColor().toActionBarColor(this));
|
||||||
this.toolbarLayout.setTitle(recipient.getDisplayName(this));
|
this.toolbarLayout.setTitle(recipient.toShortString(this));
|
||||||
this.toolbarLayout.setContentScrimColor(recipient.getColor().toActionBarColor(this));
|
this.toolbarLayout.setContentScrimColor(recipient.getColor().toActionBarColor(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,9 +423,14 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
|||||||
colorPreference.setColors(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(requireActivity()));
|
colorPreference.setColors(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(requireActivity()));
|
||||||
colorPreference.setColor(recipient.getColor().toActionBarColor(requireActivity()));
|
colorPreference.setColor(recipient.getColor().toActionBarColor(requireActivity()));
|
||||||
|
|
||||||
aboutPreference.setTitle(recipient.getDisplayName(requireContext()));
|
if (FeatureFlags.PROFILE_DISPLAY) {
|
||||||
|
aboutPreference.setTitle(recipient.getDisplayName(requireContext()));
|
||||||
|
aboutPreference.setSummary(recipient.resolve().getE164().or(""));
|
||||||
|
} else {
|
||||||
|
aboutPreference.setTitle(formatRecipient(recipient));
|
||||||
|
aboutPreference.setSummary(recipient.getCustomLabel());
|
||||||
|
}
|
||||||
|
|
||||||
aboutPreference.setSummary(recipient.resolve().getE164().or(""));
|
|
||||||
aboutPreference.setSecure(recipient.getRegistered() == RecipientDatabase.RegisteredState.REGISTERED);
|
aboutPreference.setSecure(recipient.getRegistered() == RecipientDatabase.RegisteredState.REGISTERED);
|
||||||
|
|
||||||
if (recipient.isBlocked()) blockPreference.setTitle(R.string.RecipientPreferenceActivity_unblock);
|
if (recipient.isBlocked()) blockPreference.setTitle(R.string.RecipientPreferenceActivity_unblock);
|
||||||
@ -450,6 +458,12 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private @NonNull String formatRecipient(@NonNull Recipient recipient) {
|
||||||
|
if (recipient.getE164().isPresent()) return PhoneNumberUtils.formatNumber(recipient.requireE164());
|
||||||
|
else if (recipient.getEmail().isPresent()) return recipient.requireEmail();
|
||||||
|
else return "";
|
||||||
|
}
|
||||||
|
|
||||||
private @NonNull String getRingtoneSummary(@NonNull Context context, @Nullable Uri ringtone) {
|
private @NonNull String getRingtoneSummary(@NonNull Context context, @Nullable Uri ringtone) {
|
||||||
if (ringtone == null) {
|
if (ringtone == null) {
|
||||||
return context.getString(R.string.preferences__default);
|
return context.getString(R.string.preferences__default);
|
||||||
|
@ -445,7 +445,7 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setRecipientText(Recipient recipient) {
|
private void setRecipientText(Recipient recipient) {
|
||||||
description.setText(Html.fromHtml(String.format(getActivity().getString(R.string.verify_display_fragment__if_you_wish_to_verify_the_security_of_your_end_to_end_encryption_with_s), recipient.getDisplayName(getContext()))));
|
description.setText(Html.fromHtml(String.format(getActivity().getString(R.string.verify_display_fragment__if_you_wish_to_verify_the_security_of_your_end_to_end_encryption_with_s), recipient.toShortString(getContext()))));
|
||||||
description.setMovementMethod(LinkMovementMethod.getInstance());
|
description.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ public class WebRtcCallActivity extends Activity {
|
|||||||
Permissions.with(this)
|
Permissions.with(this)
|
||||||
.request(Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)
|
.request(Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)
|
||||||
.ifNecessary()
|
.ifNecessary()
|
||||||
.withRationaleDialog(getString(R.string.WebRtcCallActivity_to_answer_the_call_from_s_give_signal_access_to_your_microphone, event.getRecipient().getDisplayName(this)),
|
.withRationaleDialog(getString(R.string.WebRtcCallActivity_to_answer_the_call_from_s_give_signal_access_to_your_microphone, event.getRecipient().toShortString(this)),
|
||||||
R.drawable.ic_mic_solid_24, R.drawable.ic_videocam_white_48dp)
|
R.drawable.ic_mic_solid_24, R.drawable.ic_videocam_white_48dp)
|
||||||
.withPermanentDenialDialog(getString(R.string.WebRtcCallActivity_signal_requires_microphone_and_camera_permissions_in_order_to_make_or_receive_calls))
|
.withPermanentDenialDialog(getString(R.string.WebRtcCallActivity_signal_requires_microphone_and_camera_permissions_in_order_to_make_or_receive_calls))
|
||||||
.onAllGranted(() -> {
|
.onAllGranted(() -> {
|
||||||
|
@ -19,6 +19,7 @@ import android.util.AttributeSet;
|
|||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiTextView;
|
import org.thoughtcrime.securesms.components.emoji.EmojiTextView;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
import org.thoughtcrime.securesms.util.ResUtil;
|
import org.thoughtcrime.securesms.util.ResUtil;
|
||||||
import org.thoughtcrime.securesms.util.spans.CenterAlignedRelativeSizeSpan;
|
import org.thoughtcrime.securesms.util.spans.CenterAlignedRelativeSizeSpan;
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ public class FromTextView extends EmojiTextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setText(Recipient recipient, boolean read, @Nullable String suffix) {
|
public void setText(Recipient recipient, boolean read, @Nullable String suffix) {
|
||||||
String fromString = recipient.getDisplayName(getContext());
|
String fromString = recipient.toShortString(getContext());
|
||||||
|
|
||||||
int typeface;
|
int typeface;
|
||||||
|
|
||||||
@ -62,6 +63,19 @@ public class FromTextView extends EmojiTextView {
|
|||||||
|
|
||||||
if (recipient.isLocalNumber()) {
|
if (recipient.isLocalNumber()) {
|
||||||
builder.append(getContext().getString(R.string.note_to_self));
|
builder.append(getContext().getString(R.string.note_to_self));
|
||||||
|
} else if (!FeatureFlags.PROFILE_DISPLAY && recipient.getName(getContext()) == null && !TextUtils.isEmpty(recipient.getProfileName())) {
|
||||||
|
SpannableString profileName = new SpannableString(" (~" + recipient.getProfileName() + ") ");
|
||||||
|
profileName.setSpan(new CenterAlignedRelativeSizeSpan(0.75f), 0, profileName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
profileName.setSpan(new TypefaceSpan("sans-serif-light"), 0, profileName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
profileName.setSpan(new ForegroundColorSpan(ResUtil.getColor(getContext(), R.attr.conversation_list_item_subject_color)), 0, profileName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
|
if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL){
|
||||||
|
builder.append(profileName);
|
||||||
|
builder.append(fromSpan);
|
||||||
|
} else {
|
||||||
|
builder.append(fromSpan);
|
||||||
|
builder.append(profileName);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
builder.append(fromSpan);
|
builder.append(fromSpan);
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver {
|
|||||||
boolean outgoing = messageType != MESSAGE_TYPE_INCOMING;
|
boolean outgoing = messageType != MESSAGE_TYPE_INCOMING;
|
||||||
|
|
||||||
authorView.setText(author.isLocalNumber() ? getContext().getString(R.string.QuoteView_you)
|
authorView.setText(author.isLocalNumber() ? getContext().getString(R.string.QuoteView_you)
|
||||||
: author.getDisplayName(getContext()));
|
: author.toShortString(getContext()));
|
||||||
|
|
||||||
// We use the raw color resource because Android 4.x was struggling with tints here
|
// We use the raw color resource because Android 4.x was struggling with tints here
|
||||||
quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing));
|
quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing));
|
||||||
|
@ -19,7 +19,7 @@ public class InviteReminder extends Reminder {
|
|||||||
final @NonNull Recipient recipient)
|
final @NonNull Recipient recipient)
|
||||||
{
|
{
|
||||||
super(context.getString(R.string.reminder_header_invite_title),
|
super(context.getString(R.string.reminder_header_invite_title),
|
||||||
context.getString(R.string.reminder_header_invite_text, recipient.getDisplayName(context)));
|
context.getString(R.string.reminder_header_invite_text, recipient.toShortString(context)));
|
||||||
|
|
||||||
setDismissListener(v -> SignalExecutors.BOUNDED.execute(() -> {
|
setDismissListener(v -> SignalExecutors.BOUNDED.execute(() -> {
|
||||||
DatabaseFactory.getRecipientDatabase(context).setSeenInviteReminder(recipient.getId(), true);
|
DatabaseFactory.getRecipientDatabase(context).setSeenInviteReminder(recipient.getId(), true);
|
||||||
|
@ -45,6 +45,7 @@ import org.thoughtcrime.securesms.recipients.LiveRecipient;
|
|||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver;
|
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver;
|
||||||
import org.thoughtcrime.securesms.ringrtc.CameraState;
|
import org.thoughtcrime.securesms.ringrtc.CameraState;
|
||||||
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
import org.thoughtcrime.securesms.util.VerifySpan;
|
import org.thoughtcrime.securesms.util.VerifySpan;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
import org.webrtc.SurfaceViewRenderer;
|
import org.webrtc.SurfaceViewRenderer;
|
||||||
@ -124,7 +125,7 @@ public class WebRtcCallScreen extends FrameLayout implements RecipientForeverObs
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setUntrustedIdentity(Recipient personInfo, IdentityKey untrustedIdentity) {
|
public void setUntrustedIdentity(Recipient personInfo, IdentityKey untrustedIdentity) {
|
||||||
String name = recipient.get().getDisplayName(getContext());
|
String name = recipient.get().toShortString(getContext());
|
||||||
String introduction = String.format(getContext().getString(R.string.WebRtcCallScreen_new_safety_numbers), name, name);
|
String introduction = String.format(getContext().getString(R.string.WebRtcCallScreen_new_safety_numbers), name, name);
|
||||||
SpannableString spannableString = new SpannableString(introduction + " " + getContext().getString(R.string.WebRtcCallScreen_you_may_wish_to_verify_this_contact));
|
SpannableString spannableString = new SpannableString(introduction + " " + getContext().getString(R.string.WebRtcCallScreen_you_may_wish_to_verify_this_contact));
|
||||||
|
|
||||||
@ -305,13 +306,23 @@ public class WebRtcCallScreen extends FrameLayout implements RecipientForeverObs
|
|||||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
.into(this.photo);
|
.into(this.photo);
|
||||||
|
|
||||||
this.name.setText(recipient.getDisplayName(getContext()));
|
if (FeatureFlags.PROFILE_DISPLAY) {
|
||||||
|
this.name.setText(recipient.getDisplayName(getContext()));
|
||||||
|
|
||||||
if (recipient.getE164().isPresent()) {
|
if (recipient.getE164().isPresent()) {
|
||||||
this.phoneNumber.setText(recipient.requireE164());
|
this.phoneNumber.setText(recipient.requireE164());
|
||||||
this.phoneNumber.setVisibility(View.VISIBLE);
|
this.phoneNumber.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
this.phoneNumber.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.phoneNumber.setVisibility(View.GONE);
|
this.name.setText(recipient.getName(getContext()));
|
||||||
|
|
||||||
|
if (recipient.getName(getContext()) == null && !TextUtils.isEmpty(recipient.getProfileName())) {
|
||||||
|
this.phoneNumber.setText(recipient.requireE164() + " (~" + recipient.getProfileName() + ")");
|
||||||
|
} else {
|
||||||
|
this.phoneNumber.setText(recipient.requireE164());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ public class ContactsCursorLoader extends CursorLoader {
|
|||||||
ThreadRecord threadRecord;
|
ThreadRecord threadRecord;
|
||||||
while ((threadRecord = reader.getNext()) != null) {
|
while ((threadRecord = reader.getNext()) != null) {
|
||||||
recentConversations.addRow(new Object[] { threadRecord.getRecipient().getId().serialize(),
|
recentConversations.addRow(new Object[] { threadRecord.getRecipient().getId().serialize(),
|
||||||
threadRecord.getRecipient().getDisplayName(getContext()),
|
threadRecord.getRecipient().toShortString(getContext()),
|
||||||
threadRecord.getRecipient().requireStringId(),
|
threadRecord.getRecipient().requireStringId(),
|
||||||
ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE,
|
ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE,
|
||||||
"",
|
"",
|
||||||
|
@ -2806,7 +2806,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
String[] unverifiedNames = new String[unverifiedIdentities.size()];
|
String[] unverifiedNames = new String[unverifiedIdentities.size()];
|
||||||
|
|
||||||
for (int i=0;i<unverifiedIdentities.size();i++) {
|
for (int i=0;i<unverifiedIdentities.size();i++) {
|
||||||
unverifiedNames[i] = Recipient.resolved(unverifiedIdentities.get(i).getRecipientId()).getDisplayName(ConversationActivity.this);
|
unverifiedNames[i] = Recipient.resolved(unverifiedIdentities.get(i).getRecipientId()).toShortString(ConversationActivity.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(ConversationActivity.this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(ConversationActivity.this);
|
||||||
|
@ -106,6 +106,7 @@ import org.thoughtcrime.securesms.revealable.ViewOnceUtil;
|
|||||||
import org.thoughtcrime.securesms.stickers.StickerUrl;
|
import org.thoughtcrime.securesms.stickers.StickerUrl;
|
||||||
import org.thoughtcrime.securesms.util.DateUtils;
|
import org.thoughtcrime.securesms.util.DateUtils;
|
||||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||||
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
import org.thoughtcrime.securesms.util.LongClickCopySpan;
|
import org.thoughtcrime.securesms.util.LongClickCopySpan;
|
||||||
import org.thoughtcrime.securesms.util.LongClickMovementMethod;
|
import org.thoughtcrime.securesms.util.LongClickMovementMethod;
|
||||||
import org.thoughtcrime.securesms.util.SearchUtil;
|
import org.thoughtcrime.securesms.util.SearchUtil;
|
||||||
@ -153,6 +154,7 @@ public class ConversationItem extends LinearLayout implements BindableConversati
|
|||||||
private ConversationItemFooter footer;
|
private ConversationItemFooter footer;
|
||||||
private ConversationItemFooter stickerFooter;
|
private ConversationItemFooter stickerFooter;
|
||||||
private TextView groupSender;
|
private TextView groupSender;
|
||||||
|
private TextView groupSenderProfileName;
|
||||||
private View groupSenderHolder;
|
private View groupSenderHolder;
|
||||||
private AvatarImageView contactPhoto;
|
private AvatarImageView contactPhoto;
|
||||||
private AlertView alertView;
|
private AlertView alertView;
|
||||||
@ -207,6 +209,7 @@ public class ConversationItem extends LinearLayout implements BindableConversati
|
|||||||
this.footer = findViewById(R.id.conversation_item_footer);
|
this.footer = findViewById(R.id.conversation_item_footer);
|
||||||
this.stickerFooter = findViewById(R.id.conversation_item_sticker_footer);
|
this.stickerFooter = findViewById(R.id.conversation_item_sticker_footer);
|
||||||
this.groupSender = findViewById(R.id.group_message_sender);
|
this.groupSender = findViewById(R.id.group_message_sender);
|
||||||
|
this.groupSenderProfileName = findViewById(R.id.group_message_sender_profile);
|
||||||
this.alertView = findViewById(R.id.indicators_parent);
|
this.alertView = findViewById(R.id.indicators_parent);
|
||||||
this.contactPhoto = findViewById(R.id.contact_photo);
|
this.contactPhoto = findViewById(R.id.contact_photo);
|
||||||
this.contactPhotoHolder = findViewById(R.id.contact_photo_container);
|
this.contactPhotoHolder = findViewById(R.id.contact_photo_container);
|
||||||
@ -942,17 +945,34 @@ public class ConversationItem extends LinearLayout implements BindableConversati
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
private void setGroupMessageStatus(MessageRecord messageRecord, Recipient recipient) {
|
private void setGroupMessageStatus(MessageRecord messageRecord, Recipient recipient) {
|
||||||
if (groupThread && !messageRecord.isOutgoing()) {
|
if (groupThread && !messageRecord.isOutgoing()) {
|
||||||
this.groupSender.setText(recipient.getDisplayName(getContext()));
|
|
||||||
|
if (FeatureFlags.PROFILE_DISPLAY) {
|
||||||
|
this.groupSender.setText(recipient.getDisplayName(getContext()));
|
||||||
|
this.groupSenderProfileName.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
this.groupSender.setText(recipient.toShortString(context));
|
||||||
|
|
||||||
|
if (recipient.getName(context) == null && !TextUtils.isEmpty(recipient.getProfileName())) {
|
||||||
|
this.groupSenderProfileName.setText("~" + recipient.getProfileName());
|
||||||
|
this.groupSenderProfileName.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
this.groupSenderProfileName.setText(null);
|
||||||
|
this.groupSenderProfileName.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setGroupAuthorColor(@NonNull MessageRecord messageRecord) {
|
private void setGroupAuthorColor(@NonNull MessageRecord messageRecord) {
|
||||||
if (shouldDrawBodyBubbleOutline(messageRecord)) {
|
if (shouldDrawBodyBubbleOutline(messageRecord)) {
|
||||||
groupSender.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_sticker_author_color));
|
groupSender.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_sticker_author_color));
|
||||||
|
groupSenderProfileName.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_sticker_author_color));
|
||||||
} else if (hasSticker(messageRecord)) {
|
} else if (hasSticker(messageRecord)) {
|
||||||
groupSender.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_sticker_author_color));
|
groupSender.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_sticker_author_color));
|
||||||
|
groupSenderProfileName.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_sticker_author_color));
|
||||||
} else {
|
} else {
|
||||||
groupSender.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_item_received_text_primary_color));
|
groupSender.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_item_received_text_primary_color));
|
||||||
|
groupSenderProfileName.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_item_received_text_primary_color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package org.thoughtcrime.securesms.conversation;
|
package org.thoughtcrime.securesms.conversation;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -17,9 +19,13 @@ import org.thoughtcrime.securesms.R;
|
|||||||
import org.thoughtcrime.securesms.components.AvatarImageView;
|
import org.thoughtcrime.securesms.components.AvatarImageView;
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ConversationTitleView extends RelativeLayout {
|
public class ConversationTitleView extends RelativeLayout {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ -104,18 +110,55 @@ public class ConversationTitleView extends RelativeLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setRecipientTitle(Recipient recipient) {
|
private void setRecipientTitle(Recipient recipient) {
|
||||||
if (recipient.isGroup()) setGroupRecipientTitle(recipient);
|
if (FeatureFlags.PROFILE_DISPLAY) {
|
||||||
else if (recipient.isLocalNumber()) setSelfTitle();
|
if (recipient.isGroup()) setGroupRecipientTitle(recipient);
|
||||||
else setIndividualRecipientTitle(recipient);
|
else if (recipient.isLocalNumber()) setSelfTitle();
|
||||||
|
else setIndividualRecipientTitle(recipient);
|
||||||
|
} else {
|
||||||
|
if (recipient.isGroup()) setGroupRecipientTitle(recipient);
|
||||||
|
else if (recipient.isLocalNumber()) setSelfTitle();
|
||||||
|
else if (TextUtils.isEmpty(recipient.getName(getContext()))) setNonContactRecipientTitle(recipient);
|
||||||
|
else setContactRecipientTitle(recipient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
private void setNonContactRecipientTitle(Recipient recipient) {
|
||||||
|
this.title.setText(Util.getFirstNonEmpty(recipient.getE164().orNull(), recipient.getUuid().transform(UUID::toString).orNull()));
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(recipient.getProfileName())) {
|
||||||
|
this.subtitle.setText(null);
|
||||||
|
this.subtitle.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
this.subtitle.setText("~" + recipient.getProfileName());
|
||||||
|
this.subtitle.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setContactRecipientTitle(Recipient recipient) {
|
||||||
|
this.title.setText(recipient.getName(getContext()));
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(recipient.getCustomLabel())) {
|
||||||
|
this.subtitle.setText(null);
|
||||||
|
this.subtitle.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
this.subtitle.setText(recipient.getCustomLabel());
|
||||||
|
this.subtitle.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setGroupRecipientTitle(Recipient recipient) {
|
private void setGroupRecipientTitle(Recipient recipient) {
|
||||||
String localNumber = TextSecurePreferences.getLocalNumber(getContext());
|
String localNumber = TextSecurePreferences.getLocalNumber(getContext());
|
||||||
|
|
||||||
this.title.setText(recipient.getDisplayName(getContext()));
|
if (FeatureFlags.PROFILE_DISPLAY) {
|
||||||
|
this.title.setText(recipient.getDisplayName(getContext()));
|
||||||
|
} else {
|
||||||
|
this.title.setText(recipient.getName(getContext()));
|
||||||
|
}
|
||||||
|
|
||||||
this.subtitle.setText(Stream.of(recipient.getParticipants())
|
this.subtitle.setText(Stream.of(recipient.getParticipants())
|
||||||
.filterNot(Recipient::isLocalNumber)
|
.filterNot(Recipient::isLocalNumber)
|
||||||
.map(r -> r.getDisplayName(getContext()))
|
.map(r -> r.toShortString(getContext()))
|
||||||
.collect(Collectors.joining(", ")));
|
.collect(Collectors.joining(", ")));
|
||||||
|
|
||||||
this.subtitle.setVisibility(View.VISIBLE);
|
this.subtitle.setVisibility(View.VISIBLE);
|
||||||
|
@ -96,32 +96,32 @@ public abstract class MessageRecord extends DisplayRecord {
|
|||||||
} else if (isGroupQuit() && isOutgoing()) {
|
} else if (isGroupQuit() && isOutgoing()) {
|
||||||
return new SpannableString(context.getString(R.string.MessageRecord_left_group));
|
return new SpannableString(context.getString(R.string.MessageRecord_left_group));
|
||||||
} else if (isGroupQuit()) {
|
} else if (isGroupQuit()) {
|
||||||
return new SpannableString(context.getString(R.string.ConversationItem_group_action_left, getIndividualRecipient().getDisplayName(context)));
|
return new SpannableString(context.getString(R.string.ConversationItem_group_action_left, getIndividualRecipient().toShortString(context)));
|
||||||
} else if (isIncomingCall()) {
|
} else if (isIncomingCall()) {
|
||||||
return new SpannableString(context.getString(R.string.MessageRecord_s_called_you, getIndividualRecipient().getDisplayName(context)));
|
return new SpannableString(context.getString(R.string.MessageRecord_s_called_you, getIndividualRecipient().toShortString(context)));
|
||||||
} else if (isOutgoingCall()) {
|
} else if (isOutgoingCall()) {
|
||||||
return new SpannableString(context.getString(R.string.MessageRecord_you_called));
|
return new SpannableString(context.getString(R.string.MessageRecord_you_called));
|
||||||
} else if (isMissedCall()) {
|
} else if (isMissedCall()) {
|
||||||
return new SpannableString(context.getString(R.string.MessageRecord_missed_call));
|
return new SpannableString(context.getString(R.string.MessageRecord_missed_call));
|
||||||
} else if (isJoined()) {
|
} else if (isJoined()) {
|
||||||
return new SpannableString(context.getString(R.string.MessageRecord_s_joined_signal, getIndividualRecipient().getDisplayName(context)));
|
return new SpannableString(context.getString(R.string.MessageRecord_s_joined_signal, getIndividualRecipient().toShortString(context)));
|
||||||
} else if (isExpirationTimerUpdate()) {
|
} else if (isExpirationTimerUpdate()) {
|
||||||
int seconds = (int)(getExpiresIn() / 1000);
|
int seconds = (int)(getExpiresIn() / 1000);
|
||||||
if (seconds <= 0) {
|
if (seconds <= 0) {
|
||||||
return isOutgoing() ? new SpannableString(context.getString(R.string.MessageRecord_you_disabled_disappearing_messages))
|
return isOutgoing() ? new SpannableString(context.getString(R.string.MessageRecord_you_disabled_disappearing_messages))
|
||||||
: new SpannableString(context.getString(R.string.MessageRecord_s_disabled_disappearing_messages, getIndividualRecipient().getDisplayName(context)));
|
: new SpannableString(context.getString(R.string.MessageRecord_s_disabled_disappearing_messages, getIndividualRecipient().toShortString(context)));
|
||||||
}
|
}
|
||||||
String time = ExpirationUtil.getExpirationDisplayValue(context, seconds);
|
String time = ExpirationUtil.getExpirationDisplayValue(context, seconds);
|
||||||
return isOutgoing() ? new SpannableString(context.getString(R.string.MessageRecord_you_set_disappearing_message_time_to_s, time))
|
return isOutgoing() ? new SpannableString(context.getString(R.string.MessageRecord_you_set_disappearing_message_time_to_s, time))
|
||||||
: new SpannableString(context.getString(R.string.MessageRecord_s_set_disappearing_message_time_to_s, getIndividualRecipient().getDisplayName(context), time));
|
: new SpannableString(context.getString(R.string.MessageRecord_s_set_disappearing_message_time_to_s, getIndividualRecipient().toShortString(context), time));
|
||||||
} else if (isIdentityUpdate()) {
|
} else if (isIdentityUpdate()) {
|
||||||
return new SpannableString(context.getString(R.string.MessageRecord_your_safety_number_with_s_has_changed, getIndividualRecipient().getDisplayName(context)));
|
return new SpannableString(context.getString(R.string.MessageRecord_your_safety_number_with_s_has_changed, getIndividualRecipient().toShortString(context)));
|
||||||
} else if (isIdentityVerified()) {
|
} else if (isIdentityVerified()) {
|
||||||
if (isOutgoing()) return new SpannableString(context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_verified, getIndividualRecipient().getDisplayName(context)));
|
if (isOutgoing()) return new SpannableString(context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_verified, getIndividualRecipient().toShortString(context)));
|
||||||
else return new SpannableString(context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_verified_from_another_device, getIndividualRecipient().getDisplayName(context)));
|
else return new SpannableString(context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_verified_from_another_device, getIndividualRecipient().toShortString(context)));
|
||||||
} else if (isIdentityDefault()) {
|
} else if (isIdentityDefault()) {
|
||||||
if (isOutgoing()) return new SpannableString(context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_unverified, getIndividualRecipient().getDisplayName(context)));
|
if (isOutgoing()) return new SpannableString(context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_unverified, getIndividualRecipient().toShortString(context)));
|
||||||
else return new SpannableString(context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_unverified_from_another_device, getIndividualRecipient().getDisplayName(context)));
|
else return new SpannableString(context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_unverified_from_another_device, getIndividualRecipient().toShortString(context)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SpannableString(getBody());
|
return new SpannableString(getBody());
|
||||||
|
@ -83,7 +83,7 @@ public class SmsMessageRecord extends MessageRecord {
|
|||||||
} else if (isEndSession() && isOutgoing()) {
|
} else if (isEndSession() && isOutgoing()) {
|
||||||
return emphasisAdded(context.getString(R.string.SmsMessageRecord_secure_session_reset));
|
return emphasisAdded(context.getString(R.string.SmsMessageRecord_secure_session_reset));
|
||||||
} else if (isEndSession()) {
|
} else if (isEndSession()) {
|
||||||
return emphasisAdded(context.getString(R.string.SmsMessageRecord_secure_session_reset_s, getIndividualRecipient().getDisplayName(context)));
|
return emphasisAdded(context.getString(R.string.SmsMessageRecord_secure_session_reset_s, getIndividualRecipient().toShortString(context)));
|
||||||
} else if (SmsDatabase.Types.isUnsupportedMessageType(type)) {
|
} else if (SmsDatabase.Types.isUnsupportedMessageType(type)) {
|
||||||
return emphasisAdded(context.getString(R.string.SmsMessageRecord_this_message_could_not_be_processed_because_it_was_sent_from_a_newer_version));
|
return emphasisAdded(context.getString(R.string.SmsMessageRecord_this_message_could_not_be_processed_because_it_was_sent_from_a_newer_version));
|
||||||
} else if (SmsDatabase.Types.isInvalidMessageType(type)) {
|
} else if (SmsDatabase.Types.isInvalidMessageType(type)) {
|
||||||
|
@ -101,7 +101,7 @@ public class ThreadRecord extends DisplayRecord {
|
|||||||
} else if (SmsDatabase.Types.isMissedCall(type)) {
|
} else if (SmsDatabase.Types.isMissedCall(type)) {
|
||||||
return emphasisAdded(context.getString(org.thoughtcrime.securesms.R.string.ThreadRecord_missed_call));
|
return emphasisAdded(context.getString(org.thoughtcrime.securesms.R.string.ThreadRecord_missed_call));
|
||||||
} else if (SmsDatabase.Types.isJoinedType(type)) {
|
} else if (SmsDatabase.Types.isJoinedType(type)) {
|
||||||
return emphasisAdded(context.getString(R.string.ThreadRecord_s_is_on_signal, getRecipient().getDisplayName(context)));
|
return emphasisAdded(context.getString(R.string.ThreadRecord_s_is_on_signal, getRecipient().toShortString(context)));
|
||||||
} else if (SmsDatabase.Types.isExpirationTimerUpdate(type)) {
|
} else if (SmsDatabase.Types.isExpirationTimerUpdate(type)) {
|
||||||
int seconds = (int)(getExpiresIn() / 1000);
|
int seconds = (int)(getExpiresIn() / 1000);
|
||||||
if (seconds <= 0) {
|
if (seconds <= 0) {
|
||||||
@ -111,7 +111,7 @@ public class ThreadRecord extends DisplayRecord {
|
|||||||
return emphasisAdded(context.getString(R.string.ThreadRecord_disappearing_message_time_updated_to_s, time));
|
return emphasisAdded(context.getString(R.string.ThreadRecord_disappearing_message_time_updated_to_s, time));
|
||||||
} else if (SmsDatabase.Types.isIdentityUpdate(type)) {
|
} else if (SmsDatabase.Types.isIdentityUpdate(type)) {
|
||||||
if (getRecipient().isGroup()) return emphasisAdded(context.getString(R.string.ThreadRecord_safety_number_changed));
|
if (getRecipient().isGroup()) return emphasisAdded(context.getString(R.string.ThreadRecord_safety_number_changed));
|
||||||
else return emphasisAdded(context.getString(R.string.ThreadRecord_your_safety_number_with_s_has_changed, getRecipient().getDisplayName(context)));
|
else return emphasisAdded(context.getString(R.string.ThreadRecord_your_safety_number_with_s_has_changed, getRecipient().toShortString(context)));
|
||||||
} else if (SmsDatabase.Types.isIdentityVerified(type)) {
|
} else if (SmsDatabase.Types.isIdentityVerified(type)) {
|
||||||
return emphasisAdded(context.getString(R.string.ThreadRecord_you_marked_verified));
|
return emphasisAdded(context.getString(R.string.ThreadRecord_you_marked_verified));
|
||||||
} else if (SmsDatabase.Types.isIdentityDefault(type)) {
|
} else if (SmsDatabase.Types.isIdentityDefault(type)) {
|
||||||
|
@ -39,7 +39,7 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
|
|||||||
|
|
||||||
protected CharSequence getStyledMessage(@NonNull Recipient recipient, @Nullable CharSequence message) {
|
protected CharSequence getStyledMessage(@NonNull Recipient recipient, @Nullable CharSequence message) {
|
||||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||||
builder.append(Util.getBoldedString(recipient.getDisplayName(context)));
|
builder.append(Util.getBoldedString(recipient.toShortString(context)));
|
||||||
builder.append(": ");
|
builder.append(": ");
|
||||||
builder.append(message == null ? "" : message);
|
builder.append(message == null ? "" : message);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
|
|||||||
public void setMostRecentSender(Recipient recipient) {
|
public void setMostRecentSender(Recipient recipient) {
|
||||||
if (privacy.isDisplayContact()) {
|
if (privacy.isDisplayContact()) {
|
||||||
setContentText(context.getString(R.string.MessageNotifier_most_recent_from_s,
|
setContentText(context.getString(R.string.MessageNotifier_most_recent_from_s,
|
||||||
recipient.getDisplayName(context)));
|
recipient.toShortString(context)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recipient.getNotificationChannel() != null) {
|
if (recipient.getNotificationChannel() != null) {
|
||||||
@ -67,7 +67,7 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
|
|||||||
if (privacy.isDisplayMessage()) {
|
if (privacy.isDisplayMessage()) {
|
||||||
messageBodies.add(getStyledMessage(sender, body));
|
messageBodies.add(getStyledMessage(sender, body));
|
||||||
} else if (privacy.isDisplayContact()) {
|
} else if (privacy.isDisplayContact()) {
|
||||||
messageBodies.add(Util.getBoldedString(sender.getDisplayName(context)));
|
messageBodies.add(Util.getBoldedString(sender.toShortString(context)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (privacy.isDisplayContact() && sender.getContactUri() != null) {
|
if (privacy.isDisplayContact() && sender.getContactUri() != null) {
|
||||||
|
@ -66,7 +66,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
setChannelId(channelId != null ? channelId : NotificationChannels.getMessagesChannel(context));
|
setChannelId(channelId != null ? channelId : NotificationChannels.getMessagesChannel(context));
|
||||||
|
|
||||||
if (privacy.isDisplayContact()) {
|
if (privacy.isDisplayContact()) {
|
||||||
setContentTitle(recipient.getDisplayName(context));
|
setContentTitle(recipient.toShortString(context));
|
||||||
|
|
||||||
if (recipient.getContactUri() != null) {
|
if (recipient.getContactUri() != null) {
|
||||||
addPerson(recipient.getContactUri().toString());
|
addPerson(recipient.getContactUri().toString());
|
||||||
@ -111,7 +111,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
||||||
|
|
||||||
if (privacy.isDisplayContact() && threadRecipients.isGroup()) {
|
if (privacy.isDisplayContact() && threadRecipients.isGroup()) {
|
||||||
stringBuilder.append(Util.getBoldedString(individualRecipient.getDisplayName(context) + ": "));
|
stringBuilder.append(Util.getBoldedString(individualRecipient.toShortString(context) + ": "));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (privacy.isDisplayMessage()) {
|
if (privacy.isDisplayMessage()) {
|
||||||
@ -203,7 +203,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
||||||
|
|
||||||
if (privacy.isDisplayContact() && threadRecipient.isGroup()) {
|
if (privacy.isDisplayContact() && threadRecipient.isGroup()) {
|
||||||
stringBuilder.append(Util.getBoldedString(individualRecipient.getDisplayName(context) + ": "));
|
stringBuilder.append(Util.getBoldedString(individualRecipient.toShortString(context) + ": "));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (privacy.isDisplayMessage()) {
|
if (privacy.isDisplayMessage()) {
|
||||||
|
@ -63,7 +63,7 @@ public class BlockedContactListItem extends RelativeLayout implements RecipientF
|
|||||||
final TextView nameView = this.nameView;
|
final TextView nameView = this.nameView;
|
||||||
|
|
||||||
contactPhotoImage.setAvatar(glideRequests, recipient, false);
|
contactPhotoImage.setAvatar(glideRequests, recipient, false);
|
||||||
nameView.setText(recipient.getDisplayName(getContext()));
|
nameView.setText(recipient.toShortString(getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Recipient getRecipient() {
|
public Recipient getRecipient() {
|
||||||
|
@ -40,7 +40,7 @@ public class UnknownSenderView extends FrameLayout {
|
|||||||
|
|
||||||
new AlertDialog.Builder(getContext())
|
new AlertDialog.Builder(getContext())
|
||||||
.setIconAttribute(R.attr.dialog_alert_icon)
|
.setIconAttribute(R.attr.dialog_alert_icon)
|
||||||
.setTitle(getContext().getString(R.string.UnknownSenderView_block_s, recipient.getDisplayName(context)))
|
.setTitle(getContext().getString(R.string.UnknownSenderView_block_s, recipient.toShortString(context)))
|
||||||
.setMessage(R.string.UnknownSenderView_blocked_contacts_will_no_longer_be_able_to_send_you_messages_or_call_you)
|
.setMessage(R.string.UnknownSenderView_blocked_contacts_will_no_longer_be_able_to_send_you_messages_or_call_you)
|
||||||
.setPositiveButton(R.string.UnknownSenderView_block, (dialog, which) -> {
|
.setPositiveButton(R.string.UnknownSenderView_block, (dialog, which) -> {
|
||||||
new AsyncTask<Void, Void, Void>() {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
@ -66,7 +66,7 @@ public class UnknownSenderView extends FrameLayout {
|
|||||||
|
|
||||||
new AlertDialog.Builder(getContext())
|
new AlertDialog.Builder(getContext())
|
||||||
.setIconAttribute(R.attr.dialog_info_icon)
|
.setIconAttribute(R.attr.dialog_info_icon)
|
||||||
.setTitle(getContext().getString(R.string.UnknownSenderView_share_profile_with_s, recipient.getDisplayName(context)))
|
.setTitle(getContext().getString(R.string.UnknownSenderView_share_profile_with_s, recipient.toShortString(context)))
|
||||||
.setMessage(R.string.UnknownSenderView_the_easiest_way_to_share_your_profile_information_is_to_add_the_sender_to_your_contacts)
|
.setMessage(R.string.UnknownSenderView_the_easiest_way_to_share_your_profile_information_is_to_add_the_sender_to_your_contacts)
|
||||||
.setPositiveButton(R.string.UnknownSenderView_share_profile, (dialog, which) -> {
|
.setPositiveButton(R.string.UnknownSenderView_share_profile, (dialog, which) -> {
|
||||||
new AsyncTask<Void, Void, Void>() {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
|
@ -300,7 +300,7 @@ public class Recipient {
|
|||||||
List<String> names = new LinkedList<>();
|
List<String> names = new LinkedList<>();
|
||||||
|
|
||||||
for (Recipient recipient : participants) {
|
for (Recipient recipient : participants) {
|
||||||
names.add(recipient.getDisplayName(context));
|
names.add(recipient.toShortString(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Util.join(names, ", ");
|
return Util.join(names, ", ");
|
||||||
@ -309,6 +309,15 @@ public class Recipient {
|
|||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO [UUID] -- Remove once UUID Feature Flag is removed
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public @NonNull String toShortString(@NonNull Context context) {
|
||||||
|
if (FeatureFlags.PROFILE_DISPLAY) return getDisplayName(context);
|
||||||
|
else return Optional.fromNullable(getName(context)).or(getSmsAddress()).or("");
|
||||||
|
}
|
||||||
|
|
||||||
public @NonNull String getDisplayName(@NonNull Context context) {
|
public @NonNull String getDisplayName(@NonNull Context context) {
|
||||||
return Util.getFirstNonEmpty(getName(context),
|
return Util.getFirstNonEmpty(getName(context),
|
||||||
getProfileName(),
|
getProfileName(),
|
||||||
@ -425,10 +434,6 @@ public class Recipient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable String getCustomLabel() {
|
|
||||||
return customLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A single string to represent the recipient, in order of precedence:
|
* @return A single string to represent the recipient, in order of precedence:
|
||||||
*
|
*
|
||||||
@ -454,6 +459,11 @@ public class Recipient {
|
|||||||
return profileName;
|
return profileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable String getCustomLabel() {
|
||||||
|
if (FeatureFlags.PROFILE_DISPLAY) throw new AssertionError("This method should never be called if PROFILE_DISPLAY is enabled.");
|
||||||
|
return customLabel;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable String getProfileAvatar() {
|
public @Nullable String getProfileAvatar() {
|
||||||
return profileAvatar;
|
return profileAvatar;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class DirectShareService extends ChooserTargetService {
|
|||||||
|
|
||||||
while ((record = reader.getNext()) != null) {
|
while ((record = reader.getNext()) != null) {
|
||||||
Recipient recipient = Recipient.resolved(record.getRecipient().getId());
|
Recipient recipient = Recipient.resolved(record.getRecipient().getId());
|
||||||
String name = recipient.getDisplayName(this);
|
String name = recipient.toShortString(this);
|
||||||
|
|
||||||
Bitmap avatar;
|
Bitmap avatar;
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ public class CommunicationActions {
|
|||||||
Permissions.with(activity)
|
Permissions.with(activity)
|
||||||
.request(Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)
|
.request(Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)
|
||||||
.ifNecessary()
|
.ifNecessary()
|
||||||
.withRationaleDialog(activity.getString(R.string.ConversationActivity_to_call_s_signal_needs_access_to_your_microphone_and_camera, recipient.getDisplayName(activity)),
|
.withRationaleDialog(activity.getString(R.string.ConversationActivity_to_call_s_signal_needs_access_to_your_microphone_and_camera, recipient.toShortString(activity)),
|
||||||
R.drawable.ic_mic_solid_24,
|
R.drawable.ic_mic_solid_24,
|
||||||
R.drawable.ic_videocam_white_48dp)
|
R.drawable.ic_videocam_white_48dp)
|
||||||
.withPermanentDenialDialog(activity.getString(R.string.ConversationActivity_signal_needs_the_microphone_and_camera_permissions_in_order_to_call_s, recipient.getDisplayName(activity)))
|
.withPermanentDenialDialog(activity.getString(R.string.ConversationActivity_signal_needs_the_microphone_and_camera_permissions_in_order_to_call_s, recipient.toShortString(activity)))
|
||||||
.onAllGranted(() -> {
|
.onAllGranted(() -> {
|
||||||
Intent intent = new Intent(activity, WebRtcCallService.class);
|
Intent intent = new Intent(activity, WebRtcCallService.class);
|
||||||
intent.setAction(WebRtcCallService.ACTION_OUTGOING_CALL);
|
intent.setAction(WebRtcCallService.ACTION_OUTGOING_CALL);
|
||||||
|
@ -13,4 +13,7 @@ public class FeatureFlags {
|
|||||||
|
|
||||||
/** Usernames. */
|
/** Usernames. */
|
||||||
public static final boolean USERNAMES = false;
|
public static final boolean USERNAMES = false;
|
||||||
|
|
||||||
|
/** New Profile Display */
|
||||||
|
public static final boolean PROFILE_DISPLAY = UUIDS;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public class GroupUtil {
|
|||||||
|
|
||||||
public String toString(Recipient sender) {
|
public String toString(Recipient sender) {
|
||||||
StringBuilder description = new StringBuilder();
|
StringBuilder description = new StringBuilder();
|
||||||
description.append(context.getString(R.string.MessageRecord_s_updated_group, sender.getDisplayName(context)));
|
description.append(context.getString(R.string.MessageRecord_s_updated_group, sender.toShortString(context)));
|
||||||
|
|
||||||
if (groupContext == null) {
|
if (groupContext == null) {
|
||||||
return description.toString();
|
return description.toString();
|
||||||
@ -160,7 +160,7 @@ public class GroupUtil {
|
|||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
for (int i=0;i<recipients.size();i++) {
|
for (int i=0;i<recipients.size();i++) {
|
||||||
result += recipients.get(i).getDisplayName(context);
|
result += recipients.get(i).toShortString(context);
|
||||||
|
|
||||||
if (i != recipients.size() -1 )
|
if (i != recipients.size() -1 )
|
||||||
result += ", ";
|
result += ", ";
|
||||||
|
@ -231,11 +231,11 @@ public class IdentityUtil {
|
|||||||
if (recipients.isEmpty()) return null;
|
if (recipients.isEmpty()) return null;
|
||||||
|
|
||||||
if (recipients.size() == 1) {
|
if (recipients.size() == 1) {
|
||||||
String name = recipients.get(0).getDisplayName(context);
|
String name = recipients.get(0).toShortString(context);
|
||||||
return context.getString(resourceOne, name);
|
return context.getString(resourceOne, name);
|
||||||
} else {
|
} else {
|
||||||
String firstName = recipients.get(0).getDisplayName(context);
|
String firstName = recipients.get(0).toShortString(context);
|
||||||
String secondName = recipients.get(1).getDisplayName(context);
|
String secondName = recipients.get(1).toShortString(context);
|
||||||
|
|
||||||
if (recipients.size() == 2) {
|
if (recipients.size() == 2) {
|
||||||
return context.getString(resourceTwo, firstName, secondName);
|
return context.getString(resourceTwo, firstName, secondName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user