aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/adapter
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2020-01-31 20:51:04 +0100
committerChristian Schneppe <christian.schneppe@pix-art.de>2020-01-31 20:51:04 +0100
commit12c190c85d2d94dc887206da963ad0b3108472f1 (patch)
tree6f0d135f1d0607e5d3b86134f00f4a24b248df29 /src/main/java/de/pixart/messenger/ui/adapter
parentd01e3bb2038875814439600687678c1206296f96 (diff)
fix showing presence colored names
fixes #257
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/adapter')
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java37
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java16
2 files changed, 27 insertions, 26 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 142386699..7f52293e8 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
@@ -38,6 +38,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
private XmppActivity activity;
private List<Conversation> conversations;
private OnConversationClickListener listener;
+ private boolean hasInternetConnection = false;
public ConversationAdapter(XmppActivity activity, List<Conversation> conversations) {
this.activity = activity;
@@ -57,6 +58,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
return;
}
CharSequence name = conversation.getName();
+ hasInternetConnection = activity.xmppConnectionService.hasInternetConnection();
if (name instanceof Jid) {
viewHolder.binding.conversationName.setText(IrregularUnicodeDetector.style(activity, (Jid) name));
} else {
@@ -220,21 +222,26 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
viewHolder.itemView.setOnClickListener(v -> listener.onConversationClick(v, conversation));
if (conversation.getMode() == Conversation.MODE_SINGLE && ShowPresenceColoredNames()) {
- switch (conversation.getContact().getPresences().getShownStatus()) {
- case CHAT:
- case ONLINE:
- viewHolder.binding.conversationName.setTextColor(ContextCompat.getColor(activity, R.color.online));
- break;
- case AWAY:
- viewHolder.binding.conversationName.setTextColor(ContextCompat.getColor(activity, R.color.away));
- break;
- case XA:
- case DND:
- viewHolder.binding.conversationName.setTextColor(ContextCompat.getColor(activity, R.color.notavailable));
- break;
- default:
- viewHolder.binding.conversationName.setTextColor(StyledAttributes.getColor(activity, R.attr.text_Color_Main));
- break;
+ if (hasInternetConnection) {
+ switch (conversation.getContact().getPresences().getShownStatus()) {
+ case CHAT:
+ case ONLINE:
+ viewHolder.binding.conversationName.setTextColor(ContextCompat.getColor(activity, R.color.online));
+ break;
+ case AWAY:
+ viewHolder.binding.conversationName.setTextColor(ContextCompat.getColor(activity, R.color.away));
+ break;
+ case XA:
+ case DND:
+ viewHolder.binding.conversationName.setTextColor(ContextCompat.getColor(activity, R.color.notavailable));
+ break;
+ case OFFLINE:
+ default:
+ viewHolder.binding.conversationName.setTextColor(StyledAttributes.getColor(activity, R.attr.text_Color_Main));
+ break;
+ }
+ } else {
+ viewHolder.binding.conversationName.setTextColor(StyledAttributes.getColor(activity, R.attr.text_Color_Main));
}
} else {
viewHolder.binding.conversationName.setTextColor(StyledAttributes.getColor(activity, R.attr.text_Color_Main));
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 5bb562987..9f1824a86 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java
@@ -31,7 +31,8 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
private static final float INACTIVE_ALPHA = 0.4684f;
private static final float ACTIVE_ALPHA = 1.0f;
protected XmppActivity activity;
- protected boolean showDynamicTags = false;
+ private boolean showDynamicTags = false;
+ private boolean showPresenceColoredNames = false;
private OnTagClickedListener mOnTagClickedListener = null;
protected int color = 0;
protected boolean offline = false;
@@ -54,6 +55,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
public void refreshSettings() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
this.showDynamicTags = preferences.getBoolean(SettingsActivity.SHOW_DYNAMIC_TAGS, activity.getResources().getBoolean(R.bool.show_dynamic_tags));
+ this.showPresenceColoredNames = preferences.getBoolean("presence_colored_names", activity.getResources().getBoolean(R.bool.presence_colored_names));
}
@Override
@@ -103,14 +105,14 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
color = tag.getColor();
}
}
- if (offline) {
+ if (offline || !activity.xmppConnectionService.hasInternetConnection()) {
viewHolder.name.setTextColor(StyledAttributes.getColor(activity, R.attr.text_Color_Main));
viewHolder.name.setAlpha(INACTIVE_ALPHA);
viewHolder.jid.setAlpha(INACTIVE_ALPHA);
viewHolder.avatar.setAlpha(INACTIVE_ALPHA);
viewHolder.tags.setAlpha(INACTIVE_ALPHA);
} else {
- if (ShowPresenceColoredNames()) {
+ if (showPresenceColoredNames) {
viewHolder.name.setTextColor(color != 0 ? color : StyledAttributes.getColor(activity, R.attr.text_Color_Main));
} else {
viewHolder.name.setTextColor(StyledAttributes.getColor(activity, R.attr.text_Color_Main));
@@ -153,12 +155,4 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
return viewHolder;
}
}
-
- private boolean ShowPresenceColoredNames() {
- return getPreferences().getBoolean("presence_colored_names", activity.getResources().getBoolean(R.bool.presence_colored_names));
- }
-
- protected SharedPreferences getPreferences() {
- return PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext());
- }
}