mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
tweak code
This commit is contained in:
@@ -67,15 +67,6 @@ public class DcChat {
|
||||
return getType() == DC_CHAT_TYPE_OUT_BROADCAST;
|
||||
}
|
||||
|
||||
public boolean isSelfInChat(DcContext dcContext) {
|
||||
for (int contactId : dcContext.getChatContacts(getId())) {
|
||||
if (contactId == DcContact.DC_CONTACT_ID_SELF) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// working with raw c-data
|
||||
|
||||
private long chatCPtr; // CAVE: the name is referenced in the JNI
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.thoughtcrime.securesms.components.AvatarView;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
public class ConversationTitleView extends RelativeLayout {
|
||||
@@ -73,7 +74,7 @@ public class ConversationTitleView extends RelativeLayout {
|
||||
} else if (dcChat.isOutBroadcast()) {
|
||||
subtitleStr = context.getResources().getQuantityString(R.plurals.n_recipients, chatContacts.length, chatContacts.length);
|
||||
} else if( dcChat.isMultiUser() ) {
|
||||
if (dcChat.isSelfInChat(dcContext)) {
|
||||
if (chatContacts.length > 1 || Util.contains(chatContacts, DcContact.DC_CONTACT_ID_SELF)) {
|
||||
subtitleStr = context.getResources().getQuantityString(R.plurals.n_members, chatContacts.length, chatContacts.length);
|
||||
} else {
|
||||
subtitleStr = "…";
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ProfileAdapter extends RecyclerView.Adapter
|
||||
private DcChatlist itemDataSharedChats;
|
||||
private String itemDataStatusText;
|
||||
private boolean isOutBroadcast;
|
||||
private int memberCount;
|
||||
private int[] memberList;
|
||||
private final Set<Integer> selectedMembers;
|
||||
|
||||
private final LayoutInflater layoutInflater;
|
||||
@@ -205,7 +205,7 @@ public class ProfileAdapter extends RecyclerView.Adapter
|
||||
else if(holder.itemView instanceof ProfileAvatarItem) {
|
||||
ProfileAvatarItem item = (ProfileAvatarItem) holder.itemView;
|
||||
item.setAvatarClickListener(view -> clickListener.onAvatarClicked());
|
||||
item.set(glideRequests, dcChat, dcContact, memberCount);
|
||||
item.set(glideRequests, dcChat, dcContact, memberList);
|
||||
}
|
||||
else if(holder.itemView instanceof ProfileTextItem) {
|
||||
ProfileTextItem item = (ProfileTextItem) holder.itemView;
|
||||
@@ -281,7 +281,7 @@ public class ProfileAdapter extends RecyclerView.Adapter
|
||||
boolean isInBroadcast = dcChat != null && dcChat.isInBroadcast();
|
||||
boolean isSelfTalk = dcChat != null && dcChat.isSelfTalk();
|
||||
boolean isDeviceTalk = dcChat != null && dcChat.isDeviceTalk();
|
||||
memberCount = memberList!=null ? memberList.length : 0;
|
||||
this.memberList = memberList;
|
||||
|
||||
itemData.add(new ItemData(ITEM_AVATAR, null, 0));
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.b44t.messenger.DcChat;
|
||||
import com.b44t.messenger.DcContact;
|
||||
|
||||
import org.thoughtcrime.securesms.components.AvatarView;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
|
||||
@@ -47,8 +46,9 @@ public class ProfileAvatarItem extends LinearLayout implements RecipientModified
|
||||
ViewUtil.setTextViewGravityStart(nameView, getContext());
|
||||
}
|
||||
|
||||
public void set(@NonNull GlideRequests glideRequests, @Nullable DcChat dcChat, @Nullable DcContact dcContact, int memberCount) {
|
||||
public void set(@NonNull GlideRequests glideRequests, @Nullable DcChat dcChat, @Nullable DcContact dcContact, @Nullable int[] members) {
|
||||
this.glideRequests = glideRequests;
|
||||
int memberCount = members != null ? members.length : 0;
|
||||
|
||||
String name = "";
|
||||
String subtitle = null;
|
||||
@@ -61,7 +61,7 @@ public class ProfileAvatarItem extends LinearLayout implements RecipientModified
|
||||
} else if (dcChat.isOutBroadcast()) {
|
||||
subtitle = getContext().getResources().getQuantityString(R.plurals.n_recipients, memberCount, memberCount);
|
||||
} else if (dcChat.getType() == DcChat.DC_CHAT_TYPE_GROUP) {
|
||||
if (dcChat.isSelfInChat(DcHelper.getContext(getContext()))) {
|
||||
if (memberCount > 1 || Util.contains(members, DcContact.DC_CONTACT_ID_SELF)) {
|
||||
subtitle = getContext().getResources().getQuantityString(R.plurals.n_members, memberCount, memberCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,18 @@ public class Util {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean contains(@Nullable int[] array, int val) {
|
||||
if (array == null) {
|
||||
return false;
|
||||
}
|
||||
for (int element : array) {
|
||||
if (element == val) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void wait(Object lock, long timeout) {
|
||||
try {
|
||||
lock.wait(timeout);
|
||||
|
||||
Reference in New Issue
Block a user