diff options
Diffstat (limited to 'src/main/java/de')
5 files changed, 50 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Bookmark.java b/src/main/java/de/pixart/messenger/entities/Bookmark.java index c2e31039b..29f7a3c26 100644 --- a/src/main/java/de/pixart/messenger/entities/Bookmark.java +++ b/src/main/java/de/pixart/messenger/entities/Bookmark.java @@ -72,6 +72,11 @@ public class Bookmark extends Element implements ListItem { } @Override + public int getOffline() { + return 0; + } + + @Override public Jid getJid() { return this.getAttributeAsJid("jid"); } @@ -82,7 +87,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))); + tags.add(new Tag(group, UIHelper.getColorForName(group), 0)); } } 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 7da8d423e..38808a1d7 100644 --- a/src/main/java/de/pixart/messenger/entities/Contact.java +++ b/src/main/java/de/pixart/messenger/entities/Contact.java @@ -136,6 +136,11 @@ public class Contact implements ListItem, Blockable { } } + @Override + public int getOffline() { + return 0; + } + public String getProfilePhoto() { return this.photoUri; } @@ -148,14 +153,12 @@ public class Contact implements ListItem, Blockable { public List<Tag> getTags(Context context) { final ArrayList<Tag> tags = new ArrayList<>(); for (final String group : getGroups()) { - tags.add(new Tag(group, UIHelper.getColorForName(group))); + tags.add(new Tag(group, UIHelper.getColorForName(group), 0)); } Presence.Status status = getShownStatus(); - if (status != Presence.Status.OFFLINE) { - tags.add(UIHelper.getTagForStatus(context, status)); - } + tags.add(UIHelper.getTagForStatus(context, status)); if (isBlocked()) { - tags.add(new Tag("blocked", 0xff2e2f3b)); + tags.add(new Tag("blocked", 0xff2e2f3b, 0)); } 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 7fbd37200..3b27c1baa 100644 --- a/src/main/java/de/pixart/messenger/entities/ListItem.java +++ b/src/main/java/de/pixart/messenger/entities/ListItem.java @@ -11,6 +11,8 @@ public interface ListItem extends Comparable<ListItem> { String getDisplayJid(); + int getOffline(); + Jid getJid(); List<Tag> getTags(Context context); @@ -18,10 +20,12 @@ public interface ListItem extends Comparable<ListItem> { final class Tag { private final String name; private final int color; + private final int offline; - public Tag(final String name, final int color) { + public Tag(final String name, final int color, final int offline) { this.name = name; this.color = color; + this.offline = offline; } public int getColor() { @@ -31,6 +35,10 @@ public interface ListItem extends Comparable<ListItem> { public String getName() { return this.name; } + + public int getOffline() { + return this.offline; + } } boolean match(Context context, final String needle); 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 1502b187d..4e8336181 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java @@ -28,8 +28,11 @@ import de.pixart.messenger.utils.UIHelper; 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; + protected boolean offline = false; private View.OnClickListener onTagTvClick = new View.OnClickListener() { @Override public void onClick(View view) { @@ -63,6 +66,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> { FlowLayout tagLayout = (FlowLayout) view.findViewById(R.id.tags); List<ListItem.Tag> tags = item.getTags(activity); + if (tags.size() == 0 || !this.showDynamicTags) { tagLayout.setVisibility(View.GONE); } else { @@ -84,6 +88,22 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> { tvJid.setVisibility(View.GONE); } tvName.setText(item.getDisplayName()); + if (tags.size() != 0) { + for (ListItem.Tag tag : tags) { + offline = tag.getOffline() == 1; + } + } + if (offline) { + tvName.setAlpha(INACTIVE_ALPHA); + tvJid.setAlpha(INACTIVE_ALPHA); + picture.setAlpha(INACTIVE_ALPHA); + tagLayout.setAlpha(INACTIVE_ALPHA); + } else { + tvName.setAlpha(ACTIVE_ALPHA); + tvJid.setAlpha(ACTIVE_ALPHA); + picture.setAlpha(ACTIVE_ALPHA); + tagLayout.setAlpha(ACTIVE_ALPHA); + } loadAvatar(item, picture); return view; } diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java index 02d8f5789..05d6c2706 100644 --- a/src/main/java/de/pixart/messenger/utils/UIHelper.java +++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java @@ -365,15 +365,17 @@ public class UIHelper { public static ListItem.Tag getTagForStatus(Context context, Presence.Status status) { switch (status) { case CHAT: - return new ListItem.Tag(context.getString(R.string.presence_chat), 0xff259b24); + return new ListItem.Tag(context.getString(R.string.presence_chat), 0xff259b24, 0); case AWAY: - return new ListItem.Tag(context.getString(R.string.presence_away), 0xffff9800); + return new ListItem.Tag(context.getString(R.string.presence_away), 0xffff9800, 0); case XA: - return new ListItem.Tag(context.getString(R.string.presence_xa), 0xfff44336); + return new ListItem.Tag(context.getString(R.string.presence_xa), 0xfff44336, 0); case DND: - return new ListItem.Tag(context.getString(R.string.presence_dnd), 0xfff44336); + return new ListItem.Tag(context.getString(R.string.presence_dnd), 0xfff44336, 0); + case OFFLINE: + return new ListItem.Tag(context.getString(R.string.presence_offline), 0xff808080, 1); default: - return new ListItem.Tag(context.getString(R.string.presence_online), 0xff259b24); + return new ListItem.Tag(context.getString(R.string.presence_online), 0xff259b24, 0); } } |