From b5a7df3f3d6b867e8e4174dd395341b520683fa8 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 22 Aug 2018 17:35:53 +0200 Subject: [PATCH] Improved list appearance. --- .../ui/adapters/ConversationsListAdapter.java | 24 ++++----- .../fragment_conversationslist_item.xml | 50 ++++++++++--------- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/ConversationsListAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/ConversationsListAdapter.java index 37b7069..d9f5580 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/ConversationsListAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/ConversationsListAdapter.java @@ -1,7 +1,7 @@ package org.communiquons.android.comunic.client.ui.adapters; import android.content.Context; -import android.os.Build; +import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.LayoutInflater; @@ -13,6 +13,7 @@ import android.widget.TextView; import org.communiquons.android.comunic.client.R; import org.communiquons.android.comunic.client.data.models.ConversationsInfo; import org.communiquons.android.comunic.client.data.utils.Utilities; +import org.communiquons.android.comunic.client.ui.utils.UiUtils; import java.util.ArrayList; @@ -68,20 +69,13 @@ public class ConversationsListAdapter extends ArrayAdapter { .findViewById(R.id.fragment_conversationslist_item_name); conversationName.setText(infos.getDisplayName()); - //Retrieve colors - int blue, grey; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - grey = getContext().getResources().getColor(R.color.darker_darker_gray, - getContext().getTheme()); - blue = getContext().getResources().getColor(R.color.dark_blue, getContext().getTheme()); - } else { - grey = getContext().getResources().getColor(R.color.darker_darker_gray); - blue = getContext().getResources().getColor(R.color.dark_blue); - } - - - //Check whether the conversation has new messages or not and update conversation name color - conversationName.setTextColor(infos.hasSaw_last_message() ? grey : blue); + //Set drawable associated with TextView (if required = unread conversation) + Drawable drawable = UiUtils.getDrawable(getContext(), R.drawable.ic_circle); + drawable.setBounds(0, 0, 16, 16); + conversationName.setCompoundDrawables( + infos.hasSaw_last_message() ? null : + drawable, + null, null, null); //Update the number of members of the conversation diff --git a/app/src/main/res/layout/fragment_conversationslist_item.xml b/app/src/main/res/layout/fragment_conversationslist_item.xml index 371ec34..6dbb82c 100644 --- a/app/src/main/res/layout/fragment_conversationslist_item.xml +++ b/app/src/main/res/layout/fragment_conversationslist_item.xml @@ -17,31 +17,35 @@ + android:id="@+id/fragment_conversationslist_item_name" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="16sp" + android:textStyle="bold" + tools:text="Conversation name" + android:drawableStart="@drawable/ic_circle" + android:drawableTint="@color/colorPrimary" + android:drawablePadding="5dp"/> - - + + + + + + android:layout_height="match_parent" + tools:text="x Members" /> - - - - - + @@ -53,7 +57,7 @@ + android:src="@android:drawable/ic_menu_my_calendar" />