Make sure recipients are fully resolved, limit size of results

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-01-12 09:52:24 -08:00
parent a125fcb8fa
commit 7b928476a2

View File

@ -19,6 +19,8 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.ThreadDatabase; import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.database.model.ThreadRecord; import org.thoughtcrime.securesms.database.model.ThreadRecord;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.BitmapUtil;
import java.util.LinkedList; import java.util.LinkedList;
@ -45,16 +47,15 @@ public class DirectShareService extends ChooserTargetService {
ThreadDatabase.Reader reader = threadDatabase.readerFor(cursor, new MasterCipher(masterSecret)); ThreadDatabase.Reader reader = threadDatabase.readerFor(cursor, new MasterCipher(masterSecret));
ThreadRecord record; ThreadRecord record;
while ((record = reader.getNext()) != null) { while ((record = reader.getNext()) != null && results.size() < 10) {
String name = record.getRecipients().toShortString(); Recipients recipients = RecipientFactory.getRecipientsForIds(this, record.getRecipients().getIds(), false);
Drawable drawable = record.getRecipients().getContactPhoto() String name = recipients.toShortString();
.asDrawable(this, record.getRecipients().getColor() Drawable drawable = recipients.getContactPhoto().asDrawable(this, recipients.getColor().toConversationColor(this));
.toConversationColor(this)); Bitmap avatar = BitmapUtil.createFromDrawable(drawable, 500, 500);
Bitmap avatar = BitmapUtil.createFromDrawable(drawable, 500, 500);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putLong(ShareActivity.EXTRA_THREAD_ID, record.getThreadId()); 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()); bundle.putInt(ShareActivity.EXTRA_DISTRIBUTION_TYPE, record.getDistributionType());
results.add(new ChooserTarget(name, Icon.createWithBitmap(avatar), 1.0f, componentName, bundle)); results.add(new ChooserTarget(name, Icon.createWithBitmap(avatar), 1.0f, componentName, bundle));