use of org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData in project Signal-Android by WhisperSystems.
the class ConversationActivity method addAttachmentContactInfo.
private void addAttachmentContactInfo(Uri contactUri) {
ContactAccessor contactDataList = ContactAccessor.getInstance();
ContactData contactData = contactDataList.getContactData(this, contactUri);
if (contactData.numbers.size() == 1)
composeText.append(contactData.numbers.get(0).number);
else if (contactData.numbers.size() > 1)
selectContactInfo(contactData);
}
use of org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData in project Signal-Android by signalapp.
the class MultiDeviceContactUpdateJob method generateFullContactUpdate.
private void generateFullContactUpdate() throws IOException, UntrustedIdentityException, NetworkException {
if (!Permissions.hasAny(context, Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS)) {
Log.w(TAG, "No contact permissions, skipping multi-device contact update...");
return;
}
File contactDataFile = createTempFile("multidevice-contact-update");
try {
DeviceContactsOutputStream out = new DeviceContactsOutputStream(new FileOutputStream(contactDataFile));
Collection<ContactData> contacts = ContactAccessor.getInstance().getContactsWithPush(context);
for (ContactData contactData : contacts) {
Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactData.id));
Address address = Address.fromExternal(context, contactData.numbers.get(0).number);
Recipient recipient = Recipient.from(context, address, false);
Optional<IdentityDatabase.IdentityRecord> identity = DatabaseFactory.getIdentityDatabase(context).getIdentity(address);
Optional<VerifiedMessage> verified = getVerifiedMessage(recipient, identity);
Optional<String> name = Optional.fromNullable(contactData.name);
Optional<String> color = Optional.of(recipient.getColor().serialize());
Optional<byte[]> profileKey = Optional.fromNullable(recipient.getProfileKey());
boolean blocked = recipient.isBlocked();
Optional<Integer> expireTimer = recipient.getExpireMessages() > 0 ? Optional.of(recipient.getExpireMessages()) : Optional.absent();
out.write(new DeviceContact(address.toPhoneString(), name, getAvatar(contactUri), color, verified, profileKey, blocked, expireTimer));
}
if (ProfileKeyUtil.hasProfileKey(context)) {
out.write(new DeviceContact(TextSecurePreferences.getLocalNumber(context), Optional.absent(), Optional.absent(), Optional.absent(), Optional.absent(), Optional.of(ProfileKeyUtil.getProfileKey(context)), false, Optional.absent()));
}
out.close();
sendUpdate(messageSender, contactDataFile, true);
} catch (InvalidNumberException e) {
Log.w(TAG, e);
} finally {
if (contactDataFile != null)
contactDataFile.delete();
}
}
use of org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData in project Signal-Android by signalapp.
the class ConversationActivity method addAttachmentContactInfo.
private void addAttachmentContactInfo(Uri contactUri) {
ContactAccessor contactDataList = ContactAccessor.getInstance();
ContactData contactData = contactDataList.getContactData(this, contactUri);
if (contactData.numbers.size() == 1)
composeText.append(contactData.numbers.get(0).number);
else if (contactData.numbers.size() > 1)
selectContactInfo(contactData);
}
use of org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData in project Signal-Android by WhisperSystems.
the class ConversationParentFragment method addAttachmentContactInfo.
private void addAttachmentContactInfo(Uri contactUri) {
ContactAccessor contactDataList = ContactAccessor.getInstance();
ContactData contactData = contactDataList.getContactData(requireContext(), contactUri);
if (contactData.numbers.size() == 1)
composeText.append(contactData.numbers.get(0).number);
else if (contactData.numbers.size() > 1)
selectContactInfo(contactData);
}
Aggregations