mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-16 13:43:07 +00:00
Better UX handling on identity key mismatches.
1) Migrate from GSON to Jackson everywhere. 2) Add support for storing identity key conflicts on message rows. 3) Add limited support for surfacing identity key conflicts in UI.
This commit is contained in:
@@ -17,17 +17,9 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.provider.Contacts.Intents;
|
||||
import android.provider.ContactsContract.QuickContact;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -39,6 +31,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.util.DateUtils;
|
||||
import org.thoughtcrime.securesms.util.Emoji;
|
||||
import org.thoughtcrime.securesms.util.RecipientViewUtil;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -66,7 +59,6 @@ public class ConversationListItem extends RelativeLayout
|
||||
private TextView subjectView;
|
||||
private TextView fromView;
|
||||
private TextView dateView;
|
||||
private long count;
|
||||
private boolean read;
|
||||
private ImageView contactPhotoImage;
|
||||
|
||||
@@ -98,12 +90,11 @@ public class ConversationListItem extends RelativeLayout
|
||||
this.selectedThreads = selectedThreads;
|
||||
this.recipients = thread.getRecipients();
|
||||
this.threadId = thread.getThreadId();
|
||||
this.count = thread.getCount();
|
||||
this.read = thread.isRead();
|
||||
this.distributionType = thread.getDistributionType();
|
||||
|
||||
this.recipients.addListener(this);
|
||||
this.fromView.setText(formatFrom(recipients, count, read));
|
||||
this.fromView.setText(RecipientViewUtil.formatFrom(context, recipients, read));
|
||||
|
||||
this.subjectView.setText(Emoji.getInstance(context).emojify(thread.getDisplayBody(),
|
||||
Emoji.EMOJI_SMALL,
|
||||
@@ -118,7 +109,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
}
|
||||
|
||||
setBackground(read, batchMode);
|
||||
setContactPhoto(this.recipients.getPrimaryRecipient());
|
||||
RecipientViewUtil.setContactPhoto(context, contactPhotoImage, recipients.getPrimaryRecipient(), true);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
@@ -130,28 +121,6 @@ public class ConversationListItem extends RelativeLayout
|
||||
contactPhotoImage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void setContactPhoto(final Recipient recipient) {
|
||||
if (recipient == null) return;
|
||||
|
||||
contactPhotoImage.setImageBitmap(recipient.getContactPhoto());
|
||||
|
||||
if (!recipient.isGroupRecipient()) {
|
||||
contactPhotoImage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (recipient.getContactUri() != null) {
|
||||
QuickContact.showQuickContact(context, contactPhotoImage, recipient.getContactUri(), QuickContact.MODE_LARGE, null);
|
||||
} else {
|
||||
Intent intent = new Intent(Intents.SHOW_OR_CREATE_CONTACT, Uri.fromParts("tel", recipient.getNumber(), null));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
contactPhotoImage.setOnClickListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackground(boolean read, boolean batch) {
|
||||
int[] attributes = new int[]{R.attr.conversation_list_item_background_selected,
|
||||
R.attr.conversation_list_item_background_read,
|
||||
@@ -170,38 +139,6 @@ public class ConversationListItem extends RelativeLayout
|
||||
drawables.recycle();
|
||||
}
|
||||
|
||||
private CharSequence formatFrom(Recipients from, long count, boolean read) {
|
||||
int attributes[] = new int[] {R.attr.conversation_list_item_count_color};
|
||||
TypedArray colors = context.obtainStyledAttributes(attributes);
|
||||
|
||||
final String fromString;
|
||||
final boolean isUnnamedGroup = from.isGroupRecipient() && TextUtils.isEmpty(from.getPrimaryRecipient().getName());
|
||||
if (isUnnamedGroup) {
|
||||
fromString = context.getString(R.string.ConversationActivity_unnamed_group);
|
||||
} else {
|
||||
fromString = from.toShortString();
|
||||
}
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder(fromString);
|
||||
|
||||
|
||||
final int typeface;
|
||||
if (isUnnamedGroup) {
|
||||
if (!read) typeface = Typeface.BOLD_ITALIC;
|
||||
else typeface = Typeface.ITALIC;
|
||||
} else if (!read) {
|
||||
typeface = Typeface.BOLD;
|
||||
} else {
|
||||
typeface = Typeface.NORMAL;
|
||||
}
|
||||
|
||||
builder.setSpan(new StyleSpan(typeface), 0, builder.length(),
|
||||
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
||||
|
||||
colors.recycle();
|
||||
return builder;
|
||||
}
|
||||
|
||||
public Recipients getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
@@ -219,8 +156,8 @@ public class ConversationListItem extends RelativeLayout
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ConversationListItem.this.fromView.setText(formatFrom(recipients, count, read));
|
||||
setContactPhoto(ConversationListItem.this.recipients.getPrimaryRecipient());
|
||||
ConversationListItem.this.fromView.setText(RecipientViewUtil.formatFrom(context, recipients, read));
|
||||
RecipientViewUtil.setContactPhoto(context, contactPhotoImage, recipients.getPrimaryRecipient(), true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user