Search in sources :

Example 1 with Uid

use of ezvcard.property.Uid 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 2 with Uid

use of ezvcard.property.Uid 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 3 with Uid

use of ezvcard.property.Uid in project ring-client-android by savoirfairelinux.

the class TVAccountWizard 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) {
            Bitmap reduced = BitmapUtils.reduceBitmap(ringAccountViewModelImpl.getPhoto(), VCardUtils.VCARD_PHOTO_SIZE);
            reduced.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) Bitmap(android.graphics.Bitmap) FormattedName(ezvcard.property.FormattedName) Photo(ezvcard.property.Photo) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RingAccountViewModelImpl(cx.ring.account.RingAccountViewModelImpl) VCard(ezvcard.VCard)

Example 4 with Uid

use of ezvcard.property.Uid in project ring-client-android by savoirfairelinux.

the class VCardUtils method setupDefaultProfile.

private static VCard setupDefaultProfile(File filesDir, String accountId) {
    VCard vcard = new VCard();
    vcard.setUid(new Uid(accountId));
    saveLocalProfileToDisk(vcard, accountId, filesDir);
    return vcard;
}
Also used : Uid(ezvcard.property.Uid) VCard(ezvcard.VCard)

Example 5 with Uid

use of ezvcard.property.Uid in project ring-client-android by savoirfairelinux.

the class RingNavigationPresenter method saveVCardPhoto.

public void saveVCardPhoto(Photo photo) {
    String accountId = mAccountService.getCurrentAccount().getAccountID();
    String ringId = mAccountService.getCurrentAccount().getUsername();
    File filesDir = mDeviceRuntimeService.provideFilesDir();
    VCard vcard = VCardUtils.loadLocalProfileFromDisk(filesDir, accountId);
    vcard.setUid(new Uid(ringId));
    vcard.removeProperties(Photo.class);
    vcard.addPhoto(photo);
    vcard.removeProperties(RawProperty.class);
    VCardUtils.saveLocalProfileToDisk(vcard, accountId, filesDir);
    updateUser();
}
Also used : Uid(ezvcard.property.Uid) File(java.io.File) VCard(ezvcard.VCard)

Aggregations

VCard (ezvcard.VCard)6 Uid (ezvcard.property.Uid)6 FormattedName (ezvcard.property.FormattedName)3 Photo (ezvcard.property.Photo)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Bitmap (android.graphics.Bitmap)1 RingAccountViewModelImpl (cx.ring.account.RingAccountViewModelImpl)1 Address (ezvcard.property.Address)1 Birthday (ezvcard.property.Birthday)1 Sound (ezvcard.property.Sound)1 StructuredName (ezvcard.property.StructuredName)1 Telephone (ezvcard.property.Telephone)1 Timezone (ezvcard.property.Timezone)1 TelUri (ezvcard.util.TelUri)1 UtcOffset (ezvcard.util.UtcOffset)1 File (java.io.File)1 InputStream (java.io.InputStream)1