diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-06-17 00:14:53 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-06-17 00:14:53 +0200 |
commit | 436fca0b406fddcf9af1f4b15e55ee5c4c307870 (patch) | |
tree | ec0ac13d695a8da8cb49bcf6e2f15f4511b9c9cc /src/main | |
parent | 0d297def28a9e1e848a0020ae140f304957114ca (diff) |
do not include read only chats in contact chooser
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/de/pixart/messenger/entities/Conversation.java | 2 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java index 05d0292a3..81c3c1d95 100644 --- a/src/main/java/de/pixart/messenger/entities/Conversation.java +++ b/src/main/java/de/pixart/messenger/entities/Conversation.java @@ -1089,7 +1089,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl return count; } - private int sentMessagesCount() { + public int sentMessagesCount() { int count = 0; synchronized (this.messages) { for (Message message : messages) { diff --git a/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java b/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java index e05c719dc..5d6469bae 100644 --- a/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java +++ b/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java @@ -44,14 +44,19 @@ public class ContactChooserTargetService extends ChooserTargetService implements mXmppConnectionService.populateWithOrderedConversations(conversations, false); final ComponentName componentName = new ComponentName(this, ShareWithActivity.class); final int pixel = (int) (48 * getResources().getDisplayMetrics().density); - for (int i = 0; i < Math.min(conversations.size(), MAX_TARGETS); ++i) { - final Conversation conversation = conversations.get(i); + for (Conversation conversation : conversations) { + if (conversation.sentMessagesCount() == 0) { + continue; + } final String name = conversation.getName().toString(); final Icon icon = Icon.createWithBitmap(mXmppConnectionService.getAvatarService().get(conversation, pixel)); - final float score = 1 - (1.0f / MAX_TARGETS) * i; + final float score = 1 - (1.0f / MAX_TARGETS) * chooserTargets.size(); final Bundle extras = new Bundle(); extras.putString("uuid", conversation.getUuid()); chooserTargets.add(new ChooserTarget(name, icon, score, componentName, extras)); + if (chooserTargets.size() >= MAX_TARGETS) { + break; + } } } catch (InterruptedException e) { } |