aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-04-05 22:01:30 +0200
committerChristian Schneppe <christian@pix-art.de>2017-04-05 22:21:41 +0200
commitebefdd1873c924ffcefe6be3d3d72234de420eb0 (patch)
treebfd6ed45fcab1075db1a03f7f0a6d5cab3ce7cac
parentacc23261c687d7a66d772b3a92c69002e7001b94 (diff)
Show colored presence status for contacts in overview and contact list
* online, free for chat = green * away = yellow * dnd, xa = red
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java22
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java5
-rw-r--r--src/main/res/values/colors.xml4
3 files changed, 31 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
index 476d3034d..f36aa6f39 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
@@ -7,6 +7,7 @@ import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
+import android.support.v4.content.ContextCompat;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
@@ -180,6 +181,27 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
ImageView profilePicture = (ImageView) view.findViewById(R.id.conversation_image);
loadAvatar(conversation, profilePicture);
+ if (conversation.getMode() == Conversation.MODE_SINGLE) {
+ switch (conversation.getContact().getPresences().getShownStatus()) {
+ case CHAT:
+ case ONLINE:
+ convName.setTextColor(ContextCompat.getColor(activity, R.color.online));
+ break;
+ case AWAY:
+ convName.setTextColor(ContextCompat.getColor(activity, R.color.away));
+ break;
+ case XA:
+ case DND:
+ convName.setTextColor(ContextCompat.getColor(activity, R.color.notavailable));
+ break;
+ default:
+ convName.setTextColor(ContextCompat.getColor(activity, R.color.black87));
+ break;
+ }
+ } else {
+ convName.setTextColor(ContextCompat.getColor(activity, R.color.black87));
+ }
+
if (activity.xmppConnectionService.indicateReceived()) {
switch (message.getMergedStatus()) {
case Message.STATUS_SEND_RECEIVED:
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java
index 4e8336181..0f8dbfee9 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java
@@ -8,6 +8,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
+import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -32,6 +33,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
private static final float ACTIVE_ALPHA = 1.0f;
protected XmppActivity activity;
protected boolean showDynamicTags = false;
+ protected int color = 0;
protected boolean offline = false;
private View.OnClickListener onTagTvClick = new View.OnClickListener() {
@Override
@@ -91,14 +93,17 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
if (tags.size() != 0) {
for (ListItem.Tag tag : tags) {
offline = tag.getOffline() == 1;
+ color = tag.getColor();
}
}
if (offline) {
+ tvName.setTextColor(ContextCompat.getColor(activity, R.color.black87));
tvName.setAlpha(INACTIVE_ALPHA);
tvJid.setAlpha(INACTIVE_ALPHA);
picture.setAlpha(INACTIVE_ALPHA);
tagLayout.setAlpha(INACTIVE_ALPHA);
} else {
+ tvName.setTextColor(color);
tvName.setAlpha(ACTIVE_ALPHA);
tvJid.setAlpha(ACTIVE_ALPHA);
picture.setAlpha(ACTIVE_ALPHA);
diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml
index 33d047d4c..880a61357 100644
--- a/src/main/res/values/colors.xml
+++ b/src/main/res/values/colors.xml
@@ -22,4 +22,8 @@
<color name="lightblue">#ffc7d1e8</color>
<color name="lightred">#ffd55555</color>
<color name="lightgreen">#ffb0ecaf</color>
+ <color name="online">#ff259b24</color>
+ <color name="away">#ffff9800</color>
+ <color name="notavailable">#fff44336</color>
+ <color name="offline">#ff808080</color>
</resources>