From 9b08184b1fb524941a8990476ca917e9b8550509 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 10 Dec 2017 18:25:06 +0100 Subject: [PATCH] Conversation names and members number are displayed in the list --- .idea/misc.xml | 2 +- .../comunic/client/data/Utilities.java | 13 ++++ .../ConversationsListAdapter.java | 25 ++++++++ .../fragment_conversationslist_item.xml | 61 +++++++++++++++++-- app/src/main/res/values/colors.xml | 2 + app/src/main/res/values/dimens.xml | 4 +- app/src/main/res/values/strings.xml | 10 +++ 7 files changed, 110 insertions(+), 7 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 33952c6..503aca7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -55,7 +55,7 @@ - + diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/Utilities.java b/app/src/main/java/org/communiquons/android/comunic/client/data/Utilities.java index 31b0018..1550901 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/Utilities.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/Utilities.java @@ -211,4 +211,17 @@ public class Utilities { Date date = new Date(); return (int) Math.ceil(date.getTime()/1000); } + + /** + * Transform an amount of seconds into a string like "3min" or "10hours"s + * + * @param time The Time to convert + * @return Generated string + */ + public String timeToString(int time){ + //TODO : implement seconds to string function + return null; + } + + } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/conversations/ConversationsListAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/data/conversations/ConversationsListAdapter.java index 1ac70e3..3e4b842 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/conversations/ConversationsListAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/conversations/ConversationsListAdapter.java @@ -1,6 +1,8 @@ package org.communiquons.android.comunic.client.data.conversations; import android.content.Context; +import android.graphics.Typeface; +import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.LayoutInflater; @@ -64,6 +66,29 @@ 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); + + + //Update the number of members of the conversation + TextView number_members = convertView + .findViewById(R.id.fragment_conversationslist_item_number_members); + String members_text = String.format(getContext().getResources() + .getString(R.string.conversations_members_number), infos.countMembers()); + number_members.setText(members_text); + return convertView; } diff --git a/app/src/main/res/layout/fragment_conversationslist_item.xml b/app/src/main/res/layout/fragment_conversationslist_item.xml index 48f7f57..1716213 100644 --- a/app/src/main/res/layout/fragment_conversationslist_item.xml +++ b/app/src/main/res/layout/fragment_conversationslist_item.xml @@ -1,14 +1,65 @@ + android:orientation="horizontal" + android:paddingBottom="8dp" + android:paddingEnd="8dp" + android:paddingStart="8dp" + android:paddingTop="8dp"> - + + + + android:layout_height="wrap_content" + android:textSize="16sp" + android:textStyle="bold" + tools:text="Conversation name" /> + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 1eb00e8..2b15758 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -6,4 +6,6 @@ #ff669900 #aaa + #5b5b5b + #303F9F diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index b216897..a8f336c 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -3,5 +3,7 @@ 64dp 64dp - + + 20dp + 20dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 96f8152..c4fd8e6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -34,4 +34,14 @@ Respond to the request Do you want to accept or deny this friendship request ? An error occurred while retrieving conversations list ! + %d members + now + seconds + minutes + min + sec + h + m + s + date_hours