Improved list appearance.

This commit is contained in:
Pierre HUBERT 2018-08-22 17:35:53 +02:00
parent 0d619dc1bb
commit b5a7df3f3d
2 changed files with 36 additions and 38 deletions

View File

@ -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<ConversationsInfo> {
.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

View File

@ -17,31 +17,35 @@
<!-- Conversation name -->
<TextView
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: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"/>
<!-- Number of members -->
<LinearLayout
<!-- Number of members -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/fragment_conversations_list_icon_width"
android:layout_height="@dimen/fragment_conversations_list_icon_height"
android:layout_marginEnd="2dp"
android:src="@drawable/ic_friends" />
<TextView
android:id="@+id/fragment_conversationslist_item_number_members"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_height="match_parent"
tools:text="x Members" />
<ImageView
android:layout_width="@dimen/fragment_conversations_list_icon_width"
android:layout_height="@dimen/fragment_conversations_list_icon_height"
android:src="@drawable/ic_friends" />
<TextView
android:id="@+id/fragment_conversationslist_item_number_members"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:text="x Members" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@ -53,7 +57,7 @@
<ImageView
android:layout_width="@dimen/fragment_conversations_list_icon_width"
android:layout_height="@dimen/fragment_conversations_list_icon_height"
android:src="@android:drawable/ic_menu_my_calendar"/>
android:src="@android:drawable/ic_menu_my_calendar" />
<TextView
android:id="@+id/fragment_conversationslist_item_lastactive"