Search in sources :

Example 21 with VCard

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());
    });
}
Also used : Uid(ezvcard.property.Uid) FormattedName(ezvcard.property.FormattedName) Photo(ezvcard.property.Photo) ByteArrayOutputStream(java.io.ByteArrayOutputStream) VCard(ezvcard.VCard)

Example 22 with VCard

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());
}
Also used : Uid(ezvcard.property.Uid) FormattedName(ezvcard.property.FormattedName) VCard(ezvcard.VCard)

Example 23 with VCard

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;
}
Also used : VCard(ezvcard.VCard) File(java.io.File)

Example 24 with 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"));
}
Also used : FormattedName(ezvcard.property.FormattedName) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 25 with VCard

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();
}
Also used : TrustRequest(cx.ring.model.TrustRequest) VCard(ezvcard.VCard)

Aggregations

VCard (ezvcard.VCard)189 Test (org.junit.Test)134 StringWriter (java.io.StringWriter)29 StructuredName (ezvcard.property.StructuredName)23 Person (com.google.api.services.people.v1.model.Person)22 Telephone (ezvcard.property.Telephone)21 Photo (ezvcard.property.Photo)17 Email (ezvcard.property.Email)16 List (java.util.List)16 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)15 Document (org.w3c.dom.Document)15 VCardVersion (ezvcard.VCardVersion)14 XCardDocumentStreamWriter (ezvcard.io.xml.XCardDocument.XCardDocumentStreamWriter)14 Address (ezvcard.property.Address)14 PhoneNumber (com.google.api.services.people.v1.model.PhoneNumber)13 Collectors (java.util.stream.Collectors)12 Name (com.google.api.services.people.v1.model.Name)11 File (java.io.File)11 Truth.assertThat (com.google.common.truth.Truth.assertThat)10 Pair (com.google.gdata.util.common.base.Pair)10