mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-12 06:42:06 +00:00
Refactor "unnamed" group logic
// FREEBIE
This commit is contained in:
@@ -71,11 +71,7 @@ public class ConversationTitleView extends LinearLayout {
|
||||
this.subtitle.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
String groupName = (!TextUtils.isEmpty(recipient.getName())) ?
|
||||
recipient.getName() :
|
||||
getContext().getString(R.string.ConversationActivity_unnamed_group);
|
||||
|
||||
this.title.setText(groupName);
|
||||
this.title.setText(recipient.getName());
|
||||
this.subtitle.setText(null);
|
||||
this.subtitle.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@@ -3,13 +3,10 @@ package org.thoughtcrime.securesms.components;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiTextView;
|
||||
@@ -38,24 +35,13 @@ public class FromTextView extends EmojiTextView {
|
||||
}
|
||||
|
||||
public void setText(Recipients recipients, boolean read) {
|
||||
int attributes[] = new int[]{R.attr.conversation_list_item_count_color};
|
||||
TypedArray colors = getContext().obtainStyledAttributes(attributes);
|
||||
boolean isUnnamedGroup = recipients.isGroupRecipient() && TextUtils.isEmpty(recipients.getPrimaryRecipient().getName());
|
||||
|
||||
String fromString;
|
||||
|
||||
if (isUnnamedGroup) {
|
||||
fromString = getContext().getString(R.string.ConversationActivity_unnamed_group);
|
||||
} else {
|
||||
fromString = recipients.toShortString();
|
||||
}
|
||||
int attributes[] = new int[]{R.attr.conversation_list_item_count_color};
|
||||
TypedArray colors = getContext().obtainStyledAttributes(attributes);
|
||||
String fromString = recipients.toShortString();
|
||||
|
||||
int typeface;
|
||||
|
||||
if (isUnnamedGroup) {
|
||||
if (!read) typeface = Typeface.BOLD_ITALIC;
|
||||
else typeface = Typeface.ITALIC;
|
||||
} else if (!read) {
|
||||
if (!read) {
|
||||
typeface = Typeface.BOLD;
|
||||
} else {
|
||||
typeface = Typeface.NORMAL;
|
||||
|
||||
@@ -162,18 +162,24 @@ public class RecipientProvider {
|
||||
|
||||
private @NonNull RecipientDetails getGroupRecipientDetails(Context context, String groupId) {
|
||||
try {
|
||||
GroupDatabase.GroupRecord record = DatabaseFactory.getGroupDatabase(context)
|
||||
.getGroup(GroupUtil.getDecodedId(groupId));
|
||||
GroupDatabase.GroupRecord record = DatabaseFactory.getGroupDatabase(context)
|
||||
.getGroup(GroupUtil.getDecodedId(groupId));
|
||||
|
||||
if (record != null) {
|
||||
ContactPhoto contactPhoto = ContactPhotoFactory.getGroupContactPhoto(record.getAvatar());
|
||||
return new RecipientDetails(record.getTitle(), groupId, null, contactPhoto, null);
|
||||
String title = record.getTitle();
|
||||
|
||||
if (title == null) {
|
||||
title = context.getString(R.string.RecipientProvider_unnamed_group);;
|
||||
}
|
||||
|
||||
return new RecipientDetails(title, groupId, null, contactPhoto, null);
|
||||
}
|
||||
|
||||
return new RecipientDetails(null, groupId, null, ContactPhotoFactory.getDefaultGroupPhoto(), null);
|
||||
return new RecipientDetails(context.getString(R.string.RecipientProvider_unnamed_group), groupId, null, ContactPhotoFactory.getDefaultGroupPhoto(), null);
|
||||
} catch (IOException e) {
|
||||
Log.w("RecipientProvider", e);
|
||||
return new RecipientDetails(null, groupId, null, ContactPhotoFactory.getDefaultGroupPhoto(), null);
|
||||
return new RecipientDetails(context.getString(R.string.RecipientProvider_unnamed_group), groupId, null, ContactPhotoFactory.getDefaultGroupPhoto(), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user