From 6e07258fc72e1049a0f9b867e9749ae2af768588 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Tue, 23 Oct 2018 07:04:15 +0200 Subject: [PATCH] make deaddrop-background compatible to selection-background --- .../securesms/ConversationListAdapter.java | 6 +++- .../securesms/ConversationListItem.java | 30 +++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationListAdapter.java b/src/org/thoughtcrime/securesms/ConversationListAdapter.java index 83dcd8f7a..d9eb72410 100644 --- a/src/org/thoughtcrime/securesms/ConversationListAdapter.java +++ b/src/org/thoughtcrime/securesms/ConversationListAdapter.java @@ -48,6 +48,7 @@ class ConversationListAdapter extends RecyclerView.Adapter { private static final int MESSAGE_TYPE_SWITCH_ARCHIVE = 1; private static final int MESSAGE_TYPE_THREAD = 2; private static final int MESSAGE_TYPE_INBOX_ZERO = 3; + private static final int MESSAGE_TYPE_DEADDROP = 4; // DEADDROP is modified on construction so it cannot be reused as THREAD private final @NonNull ApplicationDcContext dcContext; private @NonNull DcChatlist dcChatlist; @@ -138,7 +139,10 @@ class ConversationListAdapter extends RecyclerView.Adapter { public int getItemViewType(int i) { int chatId = dcChatlist.getChatId(i); - if (chatId == DcChat.DC_CHAT_ID_ARCHIVED_LINK) { + if (chatId==DcChat.DC_CHAT_ID_DEADDROP) { + return MESSAGE_TYPE_DEADDROP; + } + else if (chatId == DcChat.DC_CHAT_ID_ARCHIVED_LINK) { return MESSAGE_TYPE_SWITCH_ARCHIVE; } else if(chatId == DcChat.DC_CHAT_ID_ALLDONE_HINT) { return MESSAGE_TYPE_INBOX_ZERO; diff --git a/src/org/thoughtcrime/securesms/ConversationListItem.java b/src/org/thoughtcrime/securesms/ConversationListItem.java index 972fe147c..d4f167217 100644 --- a/src/org/thoughtcrime/securesms/ConversationListItem.java +++ b/src/org/thoughtcrime/securesms/ConversationListItem.java @@ -32,6 +32,7 @@ import android.text.Spanned; import android.text.TextUtils; import android.text.style.StyleSpan; import android.util.AttributeSet; +import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; @@ -305,21 +306,20 @@ public class ConversationListItem extends RelativeLayout private void setRippleColor(Recipient recipient) { if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { -// TODO: a different backgroupd for the deaddrop would be nice, however the following code collades with the selected state and should be fixex - -// if(threadId==DcChat.DC_CHAT_ID_DEADDROP) { -// TypedArray ta = getContext().obtainStyledAttributes(new int[] { R.attr.conversation_list_deaddrop_bg_color}); -// setBackgroundColor(ta.getColor(0, 0xffffffff)); -// ta.recycle(); -// } -// else { -// TypedArray ta = getContext().obtainStyledAttributes(new int[] { R.attr.conversation_list_item_background}); -// setBackground(ta.getDrawable(0)); -// ta.recycle(); - - ((RippleDrawable)(getBackground()).mutate()) - .setColor(ColorStateList.valueOf(recipient.getColor().toConversationColor(getContext()))); -// } + if(threadId==DcChat.DC_CHAT_ID_DEADDROP) { + TypedArray ta = getContext().obtainStyledAttributes(new int[] { R.attr.conversation_list_deaddrop_bg_color}); + setBackgroundColor(ta.getColor(0, 0xffffffff)); + ta.recycle(); + } + else { + try { + ((RippleDrawable) (getBackground()).mutate()) + .setColor(ColorStateList.valueOf(recipient.getColor().toConversationColor(getContext()))); + } + catch (Exception e) { + Log.i(TAG, "Item was converted to Deaddrop-Item with a colored background, this is not undoable"); + } + } } }