aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-05-26 22:28:31 +0200
committerlookshe <github@lookshe.org>2015-06-19 09:47:04 +0200
commitb6584dfd0b3a7347c7788143fda486f18a1518ee (patch)
treeed68c90ec852a0173b435e9160ccbdf16c779a5d
parent7382e3af9769f76fe4e19934a59e45a3f9858332 (diff)
Status color added to "create conversation" (refers to ticket #22 in flyspray)
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/Bookmark.java7
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/Contact.java6
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/ListItem.java2
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/adapter/ListItemAdapter.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java15
-rw-r--r--src/main/res/layout/contact.xml11
6 files changed, 43 insertions, 2 deletions
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<ListItem> {
public List<Tag> 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<ListItem> {
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 "";
diff --git a/src/main/res/layout/contact.xml b/src/main/res/layout/contact.xml
index 69545c25..f0ef5d94 100644
--- a/src/main/res/layout/contact.xml
+++ b/src/main/res/layout/contact.xml
@@ -11,8 +11,15 @@
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:scaleType="centerCrop"
- android:src="@drawable/ic_profile" >
- </ImageView>
+ android:src="@drawable/ic_profile" />
+ <TextView
+ android:layout_width="48dp"
+ android:layout_height="4dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:id="@+id/contact_status"
+ android:layout_below="@+id/contact_photo"
+ android:paddingTop="8dp"
+ android:paddingRight="8dp"/>
<LinearLayout
android:layout_width="wrap_content"