diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-06-20 22:30:21 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-06-20 22:30:21 +0200 |
commit | 81c0944245b84824f1ba76ce225225ea996f57c1 (patch) | |
tree | 2920b34f4be4c972d4b7f3e4aebe97d06b03471d /src/main/java/de/pixart | |
parent | 53f93ae996a8d7478132b1f655830cf065d91177 (diff) |
show own account in chatlist/contacts/conferences if you are in multi account mode
Diffstat (limited to 'src/main/java/de/pixart')
8 files changed, 42 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Bookmark.java b/src/main/java/de/pixart/messenger/entities/Bookmark.java index 0d1f5781d..08c368b76 100644 --- a/src/main/java/de/pixart/messenger/entities/Bookmark.java +++ b/src/main/java/de/pixart/messenger/entities/Bookmark.java @@ -98,7 +98,7 @@ public class Bookmark extends Element implements ListItem { for (Element element : getChildren()) { if (element.getName().equals("group") && element.getContent() != null) { String group = element.getContent(); - tags.add(new Tag(group, UIHelper.getColorForName(group, true), 0)); + tags.add(new Tag(group, UIHelper.getColorForName(group, true), 0, account)); } } return tags; diff --git a/src/main/java/de/pixart/messenger/entities/Contact.java b/src/main/java/de/pixart/messenger/entities/Contact.java index ea7849520..7d9f100e2 100644 --- a/src/main/java/de/pixart/messenger/entities/Contact.java +++ b/src/main/java/de/pixart/messenger/entities/Contact.java @@ -20,7 +20,6 @@ import java.util.Locale; import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.android.AbstractPhoneContact; -import de.pixart.messenger.services.QuickConversationsService; import de.pixart.messenger.utils.JidHelper; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.xml.Element; @@ -159,12 +158,12 @@ public class Contact implements ListItem, Blockable { public List<Tag> getTags(Context context) { final ArrayList<Tag> tags = new ArrayList<>(); for (final String group : getGroups(true)) { - tags.add(new Tag(group, UIHelper.getColorForName(group), 0)); + tags.add(new Tag(group, UIHelper.getColorForName(group), 0, account)); } Presence.Status status = getShownStatus(); - tags.add(UIHelper.getTagForStatus(context, status)); + tags.add(UIHelper.getTagForStatus(context, status, account)); if (isBlocked()) { - tags.add(new Tag(context.getString(R.string.blocked), 0xff2e2f3b, 0)); + tags.add(new Tag(context.getString(R.string.blocked), 0xff2e2f3b, 0, account)); } return tags; } diff --git a/src/main/java/de/pixart/messenger/entities/ListItem.java b/src/main/java/de/pixart/messenger/entities/ListItem.java index fba37cc4c..e8907b588 100644 --- a/src/main/java/de/pixart/messenger/entities/ListItem.java +++ b/src/main/java/de/pixart/messenger/entities/ListItem.java @@ -14,17 +14,21 @@ public interface ListItem extends Comparable<ListItem>, AvatarService.Avatarable Jid getJid(); + Account getAccount(); + List<Tag> getTags(Context context); final class Tag { private final String name; private final int color; private final int offline; + private final Account account; - public Tag(final String name, final int color, final int offline) { + public Tag(final String name, final int color, final int offline, final Account account) { this.name = name; this.color = color; this.offline = offline; + this.account = account; } public int getColor() { @@ -38,6 +42,10 @@ public interface ListItem extends Comparable<ListItem>, AvatarService.Avatarable public int getOffline() { return this.offline; } + + public Account getAccount() { + return this.account; + } } boolean match(Context context, final String needle); diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 0dc298fd6..539f89553 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -168,6 +168,7 @@ import static de.pixart.messenger.ui.SettingsActivity.CHAT_STATES; import static de.pixart.messenger.ui.SettingsActivity.CONFIRM_MESSAGES; import static de.pixart.messenger.ui.SettingsActivity.ENABLE_MULTI_ACCOUNTS; import static de.pixart.messenger.ui.SettingsActivity.INDICATE_RECEIVED; +import static de.pixart.messenger.ui.SettingsActivity.SHOW_OWN_ACCOUNTS; public class XmppConnectionService extends Service { @@ -4021,6 +4022,10 @@ public class XmppConnectionService extends Service { return getBooleanPreference(ENABLE_MULTI_ACCOUNTS, R.bool.enable_multi_accounts); } + public boolean showOwnAccounts() { + return getBooleanPreference(SHOW_OWN_ACCOUNTS, R.bool.show_own_accounts); + } + public int unreadCount() { int count = 0; for (Conversation conversation : getConversations()) { diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java index e7beac1c6..fedd2b60d 100644 --- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java @@ -57,6 +57,7 @@ public class SettingsActivity extends XmppActivity implements public static final String SHOW_FOREGROUND_SERVICE = "show_foreground_service"; public static final String USE_BUNDLED_EMOJIS = "use_bundled_emoji"; public static final String ENABLE_MULTI_ACCOUNTS = "enable_multi_accounts"; + public static final String SHOW_OWN_ACCOUNTS = "show_own_accounts"; public static final String QUICK_SHARE_ATTACHMENT_CHOICE = "quick_share_attachment_choice"; public static final String NUMBER_OF_ACCOUNTS = "number_of_accounts"; public static final String PLAY_GIF_INSIDE = "play_gif_inside"; 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 27d623117..15efb7921 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java @@ -59,6 +59,13 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte viewHolder.binding.conversationName.setText(EmojiWrapper.transform(name)); } + if (activity.xmppConnectionService.multipleAccounts() && activity.xmppConnectionService.showOwnAccounts()) { + viewHolder.binding.account.setVisibility(View.VISIBLE); + viewHolder.binding.account.setText(conversation.getAccount().getJid().asBareJid()); + } else { + viewHolder.binding.account.setVisibility(View.GONE); + } + if (conversation == ConversationFragment.getConversation(activity)) { viewHolder.binding.frame.setBackgroundColor(StyledAttributes.getColor(activity, R.attr.color_background_tertiary)); } else { 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 93a822ea3..250dcc1cd 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java @@ -89,6 +89,12 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> { } else { viewHolder.jid.setVisibility(View.GONE); } + if (activity.xmppConnectionService.multipleAccounts() && activity.xmppConnectionService.showOwnAccounts()) { + viewHolder.account.setVisibility(View.VISIBLE); + viewHolder.account.setText(item.getAccount().getJid().asBareJid()); + } else { + viewHolder.account.setVisibility(View.GONE); + } viewHolder.name.setText(EmojiWrapper.transform(item.getDisplayName())); if (tags.size() != 0) { for (ListItem.Tag tag : tags) { @@ -128,6 +134,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> { private static class ViewHolder { private TextView name; private TextView jid; + private TextView account; private ImageView avatar; private FlowLayout tags; @@ -138,6 +145,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> { ViewHolder viewHolder = new ViewHolder(); viewHolder.name = binding.contactDisplayName; viewHolder.jid = binding.contactJid; + viewHolder.account = binding.account; viewHolder.avatar = binding.contactPhoto; viewHolder.tags = binding.tags; binding.getRoot().setTag(viewHolder); diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java index a2a536cea..b2e73fb46 100644 --- a/src/main/java/de/pixart/messenger/utils/UIHelper.java +++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java @@ -18,6 +18,7 @@ import java.util.Locale; import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.crypto.axolotl.AxolotlService; +import de.pixart.messenger.entities.Account; import de.pixart.messenger.entities.Contact; import de.pixart.messenger.entities.Conversation; import de.pixart.messenger.entities.Conversational; @@ -553,20 +554,20 @@ public class UIHelper { return LOCATION_QUESTIONS.contains(body); } - public static ListItem.Tag getTagForStatus(Context context, Presence.Status status) { + public static ListItem.Tag getTagForStatus(Context context, Presence.Status status, Account account) { switch (status) { case CHAT: - return new ListItem.Tag(context.getString(R.string.presence_chat), 0xff259b24, 0); + return new ListItem.Tag(context.getString(R.string.presence_chat), 0xff259b24, 0, account); case AWAY: - return new ListItem.Tag(context.getString(R.string.presence_away), 0xffff9800, 0); + return new ListItem.Tag(context.getString(R.string.presence_away), 0xffff9800, 0, account); case XA: - return new ListItem.Tag(context.getString(R.string.presence_xa), 0xfff44336, 0); + return new ListItem.Tag(context.getString(R.string.presence_xa), 0xfff44336, 0, account); case DND: - return new ListItem.Tag(context.getString(R.string.presence_dnd), 0xfff44336, 0); + return new ListItem.Tag(context.getString(R.string.presence_dnd), 0xfff44336, 0, account); case OFFLINE: - return new ListItem.Tag(context.getString(R.string.presence_offline), 0xff808080, 1); + return new ListItem.Tag(context.getString(R.string.presence_offline), 0xff808080, 1, account); default: - return new ListItem.Tag(context.getString(R.string.presence_online), 0xff259b24, 0); + return new ListItem.Tag(context.getString(R.string.presence_online), 0xff259b24, 0, account); } } |