mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 07:49:28 +00:00
Conversation list displayed correctly.
This commit is contained in:
parent
9b08184b1f
commit
32757d3f35
@ -55,7 +55,7 @@
|
|||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
package org.communiquons.android.comunic.client.data;
|
package org.communiquons.android.comunic.client.data;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
|
|
||||||
|
import org.communiquons.android.comunic.client.R;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -219,8 +222,47 @@ public class Utilities {
|
|||||||
* @return Generated string
|
* @return Generated string
|
||||||
*/
|
*/
|
||||||
public String timeToString(int time){
|
public String timeToString(int time){
|
||||||
//TODO : implement seconds to string function
|
|
||||||
return null;
|
Resources res = mContext.getResources();
|
||||||
|
|
||||||
|
//Check if the time is inferior to 1 => now
|
||||||
|
if(time < 1)
|
||||||
|
return res.getString(R.string.date_now);
|
||||||
|
|
||||||
|
//Less than one minute
|
||||||
|
else if (time < 60){
|
||||||
|
return time + res.getString(R.string.date_s);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Less than one hour
|
||||||
|
else if (time < 3600){
|
||||||
|
int secs = (int) Math.floor(time / 60);
|
||||||
|
return secs + res.getString(R.string.date_m);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Less than a day
|
||||||
|
else if (time < 86400){
|
||||||
|
int hours = (int) Math.floor(time / 3600);
|
||||||
|
return hours + res.getString(R.string.date_h);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Less than a month
|
||||||
|
else if (time < 2678400){
|
||||||
|
int days = (int) Math.floor(time / 86400);
|
||||||
|
return days + res.getString(days > 1 ? R.string.date_days : R.string.date_day);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Less than a year
|
||||||
|
else if (time < 31536000){
|
||||||
|
int months = (int) Math.floor(time / 2678400);
|
||||||
|
return months + res.getString(months > 1 ? R.string.date_months : R.string.date_month);
|
||||||
|
}
|
||||||
|
|
||||||
|
//A several amount of years
|
||||||
|
else {
|
||||||
|
int years = (int) Math.floor(31536000);
|
||||||
|
return years + res.getString(years > 1 ? R.string.date_years : R.string.date_year);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.R;
|
import org.communiquons.android.comunic.client.R;
|
||||||
|
import org.communiquons.android.comunic.client.data.Utilities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.zip.Inflater;
|
import java.util.zip.Inflater;
|
||||||
@ -29,6 +30,8 @@ import static android.R.id.list;
|
|||||||
|
|
||||||
public class ConversationsListAdapter extends ArrayAdapter<ConversationsInfo> {
|
public class ConversationsListAdapter extends ArrayAdapter<ConversationsInfo> {
|
||||||
|
|
||||||
|
private Utilities utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
@ -37,6 +40,8 @@ public class ConversationsListAdapter extends ArrayAdapter<ConversationsInfo> {
|
|||||||
*/
|
*/
|
||||||
public ConversationsListAdapter(Context context, ArrayList<ConversationsInfo> list){
|
public ConversationsListAdapter(Context context, ArrayList<ConversationsInfo> list){
|
||||||
super(context, 0, list);
|
super(context, 0, list);
|
||||||
|
|
||||||
|
utils = new Utilities(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +94,13 @@ public class ConversationsListAdapter extends ArrayAdapter<ConversationsInfo> {
|
|||||||
.getString(R.string.conversations_members_number), infos.countMembers());
|
.getString(R.string.conversations_members_number), infos.countMembers());
|
||||||
number_members.setText(members_text);
|
number_members.setText(members_text);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Update the last activity time of the conversation
|
||||||
|
TextView last_activity = convertView.
|
||||||
|
findViewById(R.id.fragment_conversationslist_item_lastactive);
|
||||||
|
last_activity.setText(utils.timeToString(Utilities.time() - infos.getLast_active()));
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
android:src="@android:drawable/ic_menu_my_calendar"/>
|
android:src="@android:drawable/ic_menu_my_calendar"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/fragment_conversationslist_item_lastactive"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:text="1min" />
|
tools:text="1min" />
|
||||||
|
@ -40,6 +40,12 @@
|
|||||||
<string name="date_minutes">minutes</string>
|
<string name="date_minutes">minutes</string>
|
||||||
<string name="date_min">min</string>
|
<string name="date_min">min</string>
|
||||||
<string name="date_sec">sec</string>
|
<string name="date_sec">sec</string>
|
||||||
|
<string name="date_day">day</string>
|
||||||
|
<string name="date_days">days</string>
|
||||||
|
<string name="date_month">month</string>
|
||||||
|
<string name="date_months">months</string>
|
||||||
|
<string name="date_year">year</string>
|
||||||
|
<string name="date_years">years</string>
|
||||||
<string name="date_h">h</string>
|
<string name="date_h">h</string>
|
||||||
<string name="date_m">m</string>
|
<string name="date_m">m</string>
|
||||||
<string name="date_s">s</string>
|
<string name="date_s">s</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user