fixed regression of not highlighting current conversation in overview. fixes #3001

This commit is contained in:
Daniel Gultsch 2018-05-03 18:30:44 +02:00
parent 756c1a1004
commit 89f8b87582
2 changed files with 9 additions and 2 deletions

View file

@ -13,6 +13,7 @@ import android.util.Pair;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -24,7 +25,9 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Transferable; import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.ui.ConversationFragment;
import eu.siacs.conversations.ui.XmppActivity; import eu.siacs.conversations.ui.XmppActivity;
import eu.siacs.conversations.ui.util.Color;
import eu.siacs.conversations.ui.widget.UnreadCountCustomView; import eu.siacs.conversations.ui.widget.UnreadCountCustomView;
import eu.siacs.conversations.utils.EmojiWrapper; import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.IrregularUnicodeDetector; import eu.siacs.conversations.utils.IrregularUnicodeDetector;
@ -72,8 +75,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
public ConversationViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public ConversationViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.conversation_list_row, parent, false); View view = inflater.inflate(R.layout.conversation_list_row, parent, false);
ConversationViewHolder conversationViewHolder = ConversationViewHolder.get(view); return ConversationViewHolder.get(view);
return conversationViewHolder;
} }
@Override @Override
@ -93,6 +95,8 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
viewHolder.name.setText(conversation.getJid().asBareJid().toString()); viewHolder.name.setText(conversation.getJid().asBareJid().toString());
} }
viewHolder.frame.setBackgroundColor(Color.get(activity, conversation == ConversationFragment.getConversation(activity) ? R.attr.color_background_secondary : R.attr.color_background_primary));
Message message = conversation.getLatestMessage(); Message message = conversation.getLatestMessage();
final int unreadCount = conversation.unreadCount(); final int unreadCount = conversation.unreadCount();
final boolean isRead = conversation.isRead(); final boolean isRead = conversation.isRead();
@ -268,6 +272,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
private ImageView notificationIcon; private ImageView notificationIcon;
private UnreadCountCustomView unreadCount; private UnreadCountCustomView unreadCount;
private ImageView avatar; private ImageView avatar;
private FrameLayout frame;
private ConversationViewHolder(View view) { private ConversationViewHolder(View view) {
super(view); super(view);
@ -277,6 +282,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
ConversationViewHolder conversationViewHolder = (ConversationViewHolder) layout.getTag(); ConversationViewHolder conversationViewHolder = (ConversationViewHolder) layout.getTag();
if (conversationViewHolder == null) { if (conversationViewHolder == null) {
conversationViewHolder = new ConversationViewHolder(layout); conversationViewHolder = new ConversationViewHolder(layout);
conversationViewHolder.frame = layout.findViewById(R.id.frame);
conversationViewHolder.name = layout.findViewById(R.id.conversation_name); conversationViewHolder.name = layout.findViewById(R.id.conversation_name);
conversationViewHolder.lastMessage = layout.findViewById(R.id.conversation_lastmsg); conversationViewHolder.lastMessage = layout.findViewById(R.id.conversation_lastmsg);
conversationViewHolder.lastMessageIcon = layout.findViewById(R.id.conversation_lastmsg_img); conversationViewHolder.lastMessageIcon = layout.findViewById(R.id.conversation_lastmsg_img);

View file

@ -5,6 +5,7 @@
android:descendantFocusability="blocksDescendants"> android:descendantFocusability="blocksDescendants">
<FrameLayout <FrameLayout
android:id="@+id/frame"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/color_background_primary"> android:background="?attr/color_background_primary">