Skip to content

Commit

Permalink
Make sure recipients are fully resolved, limit size of results
Browse files Browse the repository at this point in the history
// FREEBIE

Upstream commit: signalapp/Signal-Android@7b92847
  • Loading branch information
moxie0 authored and BLeQuerrec committed Feb 15, 2017
1 parent 7f02099 commit 52e2a50
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/org/smssecure/smssecure/service/DirectShareService.java
Expand Up @@ -19,6 +19,8 @@
import org.smssecure.smssecure.database.DatabaseFactory;
import org.smssecure.smssecure.database.ThreadDatabase;
import org.smssecure.smssecure.database.model.ThreadRecord;
import org.smssecure.smssecure.recipients.RecipientFactory;
import org.smssecure.smssecure.recipients.Recipients;
import org.smssecure.smssecure.util.BitmapUtil;

import java.util.LinkedList;
Expand All @@ -45,16 +47,15 @@ public List<ChooserTarget> onGetChooserTargets(ComponentName targetActivityName,
ThreadDatabase.Reader reader = threadDatabase.readerFor(cursor, new MasterCipher(masterSecret));
ThreadRecord record;

while ((record = reader.getNext()) != null) {
String name = record.getRecipients().toShortString();
Drawable drawable = record.getRecipients().getContactPhoto()
.asDrawable(this, record.getRecipients().getColor()
.toConversationColor(this));
Bitmap avatar = BitmapUtil.createFromDrawable(drawable, 500, 500);
while ((record = reader.getNext()) != null && results.size() < 10) {
Recipients recipients = RecipientFactory.getRecipientsForIds(this, record.getRecipients().getIds(), false);
String name = recipients.toShortString();
Drawable drawable = recipients.getContactPhoto().asDrawable(this, recipients.getColor().toConversationColor(this));
Bitmap avatar = BitmapUtil.createFromDrawable(drawable, 500, 500);

Bundle bundle = new Bundle();
bundle.putLong(ShareActivity.EXTRA_THREAD_ID, record.getThreadId());
bundle.putLongArray(ShareActivity.EXTRA_RECIPIENT_IDS, record.getRecipients().getIds());
bundle.putLongArray(ShareActivity.EXTRA_RECIPIENT_IDS, recipients.getIds());
bundle.putInt(ShareActivity.EXTRA_DISTRIBUTION_TYPE, record.getDistributionType());

results.add(new ChooserTarget(name, Icon.createWithBitmap(avatar), 1.0f, componentName, bundle));
Expand Down

0 comments on commit 52e2a50

Please sign in to comment.