From b6584dfd0b3a7347c7788143fda486f18a1518ee Mon Sep 17 00:00:00 2001 From: steckbrief Date: Tue, 26 May 2015 22:28:31 +0200 Subject: Status color added to "create conversation" (refers to ticket #22 in flyspray) --- .../thedevstack/conversationsplus/entities/Bookmark.java | 7 +++++++ .../thedevstack/conversationsplus/entities/Contact.java | 6 ++++++ .../thedevstack/conversationsplus/entities/ListItem.java | 2 ++ .../conversationsplus/ui/adapter/ListItemAdapter.java | 4 ++++ .../de/thedevstack/conversationsplus/utils/UIHelper.java | 15 +++++++++++++++ 5 files changed, 34 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Bookmark.java b/src/main/java/de/thedevstack/conversationsplus/entities/Bookmark.java index ea7df2f2..8a6b1405 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/Bookmark.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/Bookmark.java @@ -1,5 +1,7 @@ package de.thedevstack.conversationsplus.entities; +import android.graphics.Color; + import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -74,6 +76,11 @@ public class Bookmark extends Element implements ListItem { return tags; } + @Override + public int getStatusColor() { + return Color.parseColor("#259B23"); + } + public String getNick() { Element nick = this.findChild("nick"); if (nick != null) { diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Contact.java b/src/main/java/de/thedevstack/conversationsplus/entities/Contact.java index 07d42d28..c4f1c9eb 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/Contact.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/Contact.java @@ -2,6 +2,7 @@ package de.thedevstack.conversationsplus.entities; import android.content.ContentValues; import android.database.Cursor; +import android.graphics.Color; import org.json.JSONArray; import org.json.JSONException; @@ -147,6 +148,11 @@ public class Contact implements ListItem, Blockable { return tags; } + @Override + public int getStatusColor() { + return Color.parseColor(UIHelper.getStatusColor(getMostAvailableStatus())); + } + public boolean match(String needle) { if (needle == null || needle.isEmpty()) { return true; diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/ListItem.java b/src/main/java/de/thedevstack/conversationsplus/entities/ListItem.java index 825eb481..9daf90d1 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/ListItem.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/ListItem.java @@ -11,6 +11,8 @@ public interface ListItem extends Comparable { public List getTags(); + public int getStatusColor(); + public final class Tag { private final String name; private final int color; diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ListItemAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ListItemAdapter.java index e78d7f5c..c453416a 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ListItemAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ListItemAdapter.java @@ -57,6 +57,10 @@ public class ListItemAdapter extends ArrayAdapter { if (view == null) { view = inflater.inflate(R.layout.contact, parent, false); } + + TextView tvStatus = (TextView) view.findViewById(R.id.contact_status); + tvStatus.setBackgroundColor(item.getStatusColor()); + TextView tvName = (TextView) view.findViewById(R.id.contact_display_name); TextView tvJid = (TextView) view.findViewById(R.id.contact_jid); ImageView picture = (ImageView) view.findViewById(R.id.contact_photo); diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java index bda3f770..3edaad0d 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java @@ -15,6 +15,7 @@ import de.thedevstack.conversationsplus.entities.Contact; import de.thedevstack.conversationsplus.entities.Conversation; import de.thedevstack.conversationsplus.entities.Downloadable; import de.thedevstack.conversationsplus.entities.Message; +import de.thedevstack.conversationsplus.entities.Presences; import de.thedevstack.conversationsplus.xmpp.jid.Jid; import android.content.Context; @@ -354,6 +355,20 @@ public class UIHelper { } } + public static String getStatusColor(int status) { + switch (status) { + case Presences.ONLINE: + case Presences.CHAT: + return "#259B23"; + case Presences.AWAY: + case Presences.XA: + return "#FF9800"; + case Presences.DND: + return "#E51C23"; + } + return "#CCCCCC"; + } + private static String getDisplayedMucCounterpart(final Jid counterpart) { if (counterpart==null) { return ""; -- cgit v1.2.3