aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-01-20 22:42:53 +0100
committersteckbrief <steckbrief@chefmail.de>2015-01-20 22:42:53 +0100
commit46bbf1ce5f5d6adbf21674c0b6f38243cb8d9fc7 (patch)
treea9629270cb551f0a1e0d764ef3b31295fc2223b1 /src/main/java/eu/siacs/conversations/ui
parente8ca2a1ae3259c66991f69d62c470ca611ee4659 (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')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/SettingsActivity.java33
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java4
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java28
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java6
4 files changed, 50 insertions, 21 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
index c6e7ab33..352652de 100644
--- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
+import de.tzur.conversations.Settings;
import eu.siacs.conversations.entities.Account;
import android.content.SharedPreferences;
@@ -58,20 +59,24 @@ public class SettingsActivity extends XmppActivity implements
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences,
String name) {
- if (name.equals("resource")) {
- String resource = preferences.getString("resource", "mobile")
- .toLowerCase(Locale.US);
- if (xmppConnectionServiceBound) {
- for (Account account : xmppConnectionService.getAccounts()) {
- account.setResource(resource);
- if (!account.isOptionSet(Account.OPTION_DISABLED)) {
- xmppConnectionService.reconnectAccount(account, false);
- }
- }
- }
- } else if (name.equals("keep_foreground_service")) {
- xmppConnectionService.toggleForegroundService();
- }
+ switch (name) {
+ case "resource":
+ String resource = preferences.getString("resource", "mobile")
+ .toLowerCase(Locale.US);
+ if (xmppConnectionServiceBound) {
+ for (Account account : xmppConnectionService.getAccounts()) {
+ account.setResource(resource);
+ if (!account.isOptionSet(Account.OPTION_DISABLED)) {
+ xmppConnectionService.reconnectAccount(account, false);
+ }
+ }
+ }
+ break;
+ case "keep_foreground_service":
+ xmppConnectionService.toggleForegroundService();
+ break;
+ }
+ Settings.synchronizeSettingsClassWithPreferences(getPreferences(), name);
}
}
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 69dd47e7..535aa6a5 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -60,6 +60,7 @@ import java.util.Hashtable;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
+import de.tzur.conversations.Settings;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
@@ -304,7 +305,8 @@ public abstract class XmppActivity extends Activity {
this.mTheme = findTheme();
setTheme(this.mTheme);
mUseSubject = getPreferences().getBoolean("use_subject", true);
- }
+ Settings.initSettingsClassWithPreferences(getPreferences());
+ }
protected SharedPreferences getPreferences() {
return PreferenceManager
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 {