diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
4 files changed, 71 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 5bf3cdab..136108ef 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,28 +59,33 @@ 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); + 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; + case "confirm_messages": + if (xmppConnectionServiceBound) { + for (Account account : xmppConnectionService.getAccounts()) { + if (!account.isOptionSet(Account.OPTION_DISABLED)) { + xmppConnectionService.sendPresence(account); + } } } - } - } else if (name.equals("keep_foreground_service")) { - xmppConnectionService.toggleForegroundService(); - } else if (name.equals("confirm_messages")) { - if (xmppConnectionServiceBound) { - for (Account account : xmppConnectionService.getAccounts()) { - if (!account.isOptionSet(Account.OPTION_DISABLED)) { - xmppConnectionService.sendPresence(account); - } - } - } - } + 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 bf247787..1f1af09c 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -61,6 +61,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; @@ -306,6 +307,9 @@ public abstract class XmppActivity extends Activity { setTheme(this.mTheme); this.mUsingEnterKey = usingEnterKey(); mUseSubject = getPreferences().getBoolean("use_subject", true); + + Settings.initSettingsClassWithPreferences(getPreferences()); + final ActionBar ab = getActionBar(); if (ab!=null) { ab.setDisplayHomeAsUpEnabled(true); 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 38c321d0..e62aaf96 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -13,14 +13,28 @@ import android.widget.TextView; 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; +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; +import android.widget.ArrayAdapter; +import android.widget.ImageView; +import android.widget.TextView; public class ConversationAdapter extends ArrayAdapter<Conversation> { @@ -62,6 +76,26 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> { TextView mTimestamp = (TextView) view.findViewById(R.id.conversation_lastupdate); 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()) { @@ -102,4 +136,4 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> { return view; } -}
\ No newline at end of file +} 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 442c6ecf..7fa05050 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -5,6 +5,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.graphics.Typeface; import android.net.Uri; +import android.preference.PreferenceManager; import android.text.Spannable; import android.text.SpannableString; import android.text.style.ForegroundColorSpan; @@ -24,6 +25,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; @@ -223,6 +225,10 @@ public class MessageAdapter extends ArrayAdapter<Message> { final String formattedBody = message.getMergedBody().replaceAll("^" + Message.ME_COMMAND, nick + " "); if (message.getType() != Message.TYPE_PRIVATE) { + boolean parseEmoticons = Settings.PARSE_EMOTICONS; + viewHolder.messageBody.setText(parseEmoticons ? UIHelper + .transformAsciiEmoticons(getContext(), message.getMergedBody()) + : message.getMergedBody()); if (message.hasMeCommand()) { final Spannable span = new SpannableString(formattedBody); span.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 0, nick.length(), |