use of ezvcard.VCard in project ring-client-android by savoirfairelinux.
the class AccountWizardActivity method saveProfile.
@Override
public void saveProfile(final String accountID, final RingAccountViewModel ringAccountViewModel) {
runOnUiThread(() -> {
RingAccountViewModelImpl ringAccountViewModelImpl = (RingAccountViewModelImpl) ringAccountViewModel;
VCard vcard = new VCard();
vcard.setFormattedName(new FormattedName(ringAccountViewModelImpl.getFullName()));
vcard.setUid(new Uid(ringAccountViewModelImpl.getUsername()));
ByteArrayOutputStream stream = new ByteArrayOutputStream();
if (ringAccountViewModelImpl.getPhoto() != null) {
ringAccountViewModelImpl.getPhoto().compress(Bitmap.CompressFormat.PNG, 100, stream);
Photo photoVCard = new Photo(stream.toByteArray(), ImageType.PNG);
vcard.removeProperties(Photo.class);
vcard.addPhoto(photoVCard);
}
vcard.removeProperties(RawProperty.class);
VCardUtils.saveLocalProfileToDisk(vcard, accountID, getFilesDir());
});
}
use of ezvcard.VCard in project ring-client-android by savoirfairelinux.
the class SIPCreationPresenter method saveProfile.
private void saveProfile(String accountID) {
VCard vcard = new VCard();
String formattedName = mAccount.getUsername();
if (formattedName.isEmpty()) {
formattedName = mAccount.getAlias();
}
vcard.setFormattedName(new FormattedName(formattedName));
String vcardUid = formattedName + accountID;
vcard.setUid(new Uid(vcardUid));
vcard.removeProperties(RawProperty.class);
VCardUtils.saveLocalProfileToDisk(vcard, accountID, mDeviceService.provideFilesDir());
}
use of ezvcard.VCard in project ring-client-android by savoirfairelinux.
the class VCardUtils method loadLocalProfileFromDisk.
public static VCard loadLocalProfileFromDisk(File filesDir, String accountId) {
VCard vcard = null;
String path = localProfilePath(filesDir);
if (!"".equals(path)) {
File vcardPath = new File(path + File.separator + accountId + ".vcf");
if (vcardPath.exists()) {
vcard = loadFromDisk(vcardPath.getAbsolutePath());
}
}
if (vcard == null) {
Log.d(TAG, "load default profile");
vcard = setupDefaultProfile(filesDir, accountId);
}
return vcard;
}
use of ezvcard.VCard in project ring-client-android by savoirfairelinux.
the class VCardUtilsTest method testVCardToString.
@Test
public void testVCardToString() {
VCard vcard = new VCard();
vcard.addFormattedName(new FormattedName("SFL Test"));
String result = VCardUtils.vcardToString(vcard);
assertTrue(result.contentEquals("BEGIN:VCARD\r\n" + "VERSION:2.1\r\n" + "X-PRODID:ez-vcard 0.10.2\r\n" + "FN:SFL Test\r\n" + "END:VCARD\r\n"));
}
use of ezvcard.VCard in project ring-client-android by savoirfairelinux.
the class ConversationPresenter method onAcceptIncomingContactRequest.
public void onAcceptIncomingContactRequest() {
String currentAccountId = mAccountId == null ? mAccountService.getCurrentAccount().getAccountID() : mAccountId;
mAccountService.acceptTrustRequest(currentAccountId, mContactRingId.getHost());
mPreferencesService.removeRequestPreferences(mAccountId, mContactRingId.getHost());
for (Iterator<TrustRequest> it = mAccountService.getCurrentAccount().getRequests().iterator(); it.hasNext(); ) {
TrustRequest request = it.next();
if (mAccountId.equals(request.getAccountId()) && mAccountId.equals(request.getContactId())) {
VCard vCard = request.getVCard();
if (vCard != null) {
VCardUtils.savePeerProfileToDisk(vCard, mContactRingId.getHost() + ".vcf", mDeviceRuntimeService.provideFilesDir());
}
it.remove();
}
}
getView().switchToConversationView();
}
Aggregations