mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
show number of views a channel message have
This commit is contained in:
@@ -18,10 +18,15 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.util.DateUtils;
|
||||
|
||||
import chat.delta.rpc.Rpc;
|
||||
import chat.delta.rpc.RpcException;
|
||||
|
||||
public class ConversationItemFooter extends LinearLayout {
|
||||
|
||||
private TextView dateView;
|
||||
private TextView editedView;
|
||||
private TextView viewsLabel;
|
||||
private ImageView viewsIcon;
|
||||
private ImageView bookmarkIndicatorView;
|
||||
private ImageView emailIndicatorView;
|
||||
private ImageView locationIndicatorView;
|
||||
@@ -29,6 +34,7 @@ public class ConversationItemFooter extends LinearLayout {
|
||||
private Integer textColor = null;
|
||||
private int callDuration = 0;
|
||||
private Context context;
|
||||
private Rpc rpc;
|
||||
|
||||
public ConversationItemFooter(Context context) {
|
||||
super(context);
|
||||
@@ -47,10 +53,13 @@ public class ConversationItemFooter extends LinearLayout {
|
||||
|
||||
private void init(Context context, @Nullable AttributeSet attrs) {
|
||||
this.context = context;
|
||||
this.rpc = DcHelper.getRpc(context);
|
||||
inflate(getContext(), R.layout.conversation_item_footer, this);
|
||||
|
||||
dateView = findViewById(R.id.footer_date);
|
||||
editedView = findViewById(R.id.footer_edited);
|
||||
viewsLabel = findViewById(R.id.footer_views);
|
||||
viewsIcon = findViewById(R.id.footer_views_icon);
|
||||
bookmarkIndicatorView = findViewById(R.id.footer_bookmark_indicator);
|
||||
emailIndicatorView = findViewById(R.id.footer_email_indicator);
|
||||
locationIndicatorView = findViewById(R.id.footer_location_indicator);
|
||||
@@ -82,13 +91,33 @@ public class ConversationItemFooter extends LinearLayout {
|
||||
}
|
||||
|
||||
locationIndicatorView.setVisibility(messageRecord.hasLocation() ? View.VISIBLE : View.GONE);
|
||||
presentDeliveryStatus(messageRecord);
|
||||
|
||||
boolean isOutChannel = DcHelper.getContext(context).getChat(messageRecord.getChatId()).isOutBroadcast();
|
||||
|
||||
if (isOutChannel && messageRecord.isOutgoing()) {
|
||||
try {
|
||||
int accId = rpc.getSelectedAccountId();
|
||||
int count = rpc.getMessageReadReceiptCount(accId, messageRecord.getId());
|
||||
viewsLabel.setText(String.format("%d", count));
|
||||
viewsLabel.setVisibility(View.VISIBLE);
|
||||
viewsIcon.setVisibility(View.VISIBLE);
|
||||
} catch (RpcException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
viewsLabel.setVisibility(View.GONE);
|
||||
viewsIcon.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
presentDeliveryStatus(messageRecord, isOutChannel);
|
||||
}
|
||||
|
||||
public void setTextColor(int color) {
|
||||
textColor = color;
|
||||
dateView.setTextColor(color);
|
||||
editedView.setTextColor(color);
|
||||
viewsLabel.setTextColor(color);
|
||||
viewsIcon.setColorFilter(color);
|
||||
bookmarkIndicatorView.setColorFilter(color);
|
||||
emailIndicatorView.setColorFilter(color);
|
||||
locationIndicatorView.setColorFilter(color);
|
||||
@@ -109,11 +138,7 @@ public class ConversationItemFooter extends LinearLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOutChannel(@NonNull DcMsg messageRecord) {
|
||||
return DcHelper.getContext(context).getChat(messageRecord.getChatId()).isOutBroadcast();
|
||||
}
|
||||
|
||||
private void presentDeliveryStatus(@NonNull DcMsg messageRecord) {
|
||||
private void presentDeliveryStatus(@NonNull DcMsg messageRecord, boolean isOutChannel) {
|
||||
// isDownloading is temporary and should be checked first.
|
||||
boolean isDownloading = messageRecord.getDownloadState() == DcMsg.DC_DOWNLOAD_IN_PROGRESS;
|
||||
boolean isCall = messageRecord.getType() == DcMsg.DC_MSG_CALL;
|
||||
@@ -121,7 +146,7 @@ public class ConversationItemFooter extends LinearLayout {
|
||||
if (isDownloading) deliveryStatusView.setDownloading();
|
||||
else if (messageRecord.isPending()) deliveryStatusView.setPending();
|
||||
else if (messageRecord.isFailed()) deliveryStatusView.setFailed();
|
||||
else if (!messageRecord.isOutgoing() || isCall || isOutChannel(messageRecord)) deliveryStatusView.setNone();
|
||||
else if (!messageRecord.isOutgoing() || isCall || isOutChannel) deliveryStatusView.setNone();
|
||||
else if (messageRecord.isRemoteRead()) deliveryStatusView.setRead();
|
||||
else if (messageRecord.isDelivered()) deliveryStatusView.setSent();
|
||||
else if (messageRecord.isPreparing()) deliveryStatusView.setPreparing();
|
||||
|
||||
Reference in New Issue
Block a user