diff options
author | steckbrief <steckbrief@chefmail.de> | 2015-01-20 22:42:53 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2015-01-20 22:42:53 +0100 |
commit | 46bbf1ce5f5d6adbf21674c0b6f38243cb8d9fc7 (patch) | |
tree | a9629270cb551f0a1e0d764ef3b31295fc2223b1 /src/main/java/eu/siacs/conversations/ui/adapter | |
parent | e8ca2a1ae3259c66991f69d62c470ca611ee4659 (diff) |
- Avoiding accessing shared preferences to know if emoticons should be parsed for every single message
- Adding support to show online status in Conversations overview (configurable via the setting "send_button_status")
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/adapter')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java | 28 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java | 6 |
2 files changed, 28 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 6758acb6..22f6b662 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -2,12 +2,14 @@ package eu.siacs.conversations.ui.adapter; import java.util.List; +import de.tzur.conversations.Settings; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Downloadable; import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.entities.Message; +import eu.siacs.conversations.entities.Presences; import eu.siacs.conversations.ui.ConversationActivity; import eu.siacs.conversations.ui.XmppActivity; import eu.siacs.conversations.utils.UIHelper; @@ -15,6 +17,7 @@ import android.content.Context; import android.graphics.Color; import android.graphics.Typeface; import android.preference.PreferenceManager; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -69,6 +72,26 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> { ImageView imagePreview = (ImageView) view .findViewById(R.id.conversation_lastimage); + if (Settings.SHOW_ONLINE_STATUS) { + TextView status = (TextView) view.findViewById(R.id.status); + + String color = "#000000"; + switch (conversation.getContact().getMostAvailableStatus()) { + case Presences.ONLINE: + case Presences.CHAT: + color = "#259B23"; + break; + case Presences.AWAY: + case Presences.XA: + color = "#FF9800"; + break; + case Presences.DND: + color = "#E51C23"; + break; + } + status.setBackgroundColor(Color.parseColor(color)); + } + Message message = conversation.getLatestMessage(); if (!conversation.isRead()) { @@ -140,9 +163,8 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> { } else { if ((message.getEncryption() != Message.ENCRYPTION_PGP) && (message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) { - boolean parseEmoticons = PreferenceManager - .getDefaultSharedPreferences(activity).getBoolean("parse_emoticons", true); - mLastMessage.setText(parseEmoticons ? UIHelper + boolean parseEmoticons = Settings.PARSE_EMOTICONS; + mLastMessage.setText(parseEmoticons ? UIHelper .transformAsciiEmoticons(getContext(), message.getBody()) : message .getBody()); } else { diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 88c5c93d..2771c4de 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -24,6 +24,7 @@ import android.widget.Toast; import java.util.List; +import de.tzur.conversations.Settings; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; @@ -226,9 +227,8 @@ public class MessageAdapter extends ArrayAdapter<Message> { viewHolder.messageBody.setVisibility(View.VISIBLE); if (message.getBody() != null) { if (message.getType() != Message.TYPE_PRIVATE) { - boolean parseEmoticons = PreferenceManager - .getDefaultSharedPreferences(getContext()).getBoolean("parse_emoticons", true); - viewHolder.messageBody.setText(parseEmoticons ? UIHelper + boolean parseEmoticons = Settings.PARSE_EMOTICONS; + viewHolder.messageBody.setText(parseEmoticons ? UIHelper .transformAsciiEmoticons(getContext(), message.getMergedBody()) : message.getMergedBody()); } else { |