Search in sources :

Example 96 with VCard

use of ezvcard.VCard 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 97 with VCard

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

the class RingNavigationPresenter method saveVCardFormattedName.

public void saveVCardFormattedName(String username) {
    String accountId = mAccountService.getCurrentAccount().getAccountID();
    File filesDir = mDeviceRuntimeService.provideFilesDir();
    VCard vcard = VCardUtils.loadLocalProfileFromDisk(filesDir, accountId);
    vcard.setFormattedName(username);
    vcard.removeProperties(RawProperty.class);
    VCardUtils.saveLocalProfileToDisk(vcard, accountId, filesDir);
    updateUser();
}
Also used : File(java.io.File) VCard(ezvcard.VCard)

Example 98 with VCard

use of ezvcard.VCard 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)

Example 99 with VCard

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

the class TVProfileEditingFragment method showViewModel.

@Override
public void showViewModel(RingNavigationViewModel viewModel) {
    // displays account available info
    VCard vcard = viewModel.getVcard(getActivity().getFilesDir());
    Account account = viewModel.getAccount();
    if (account == null) {
        Log.e(TAG, "Not able to get current account");
        return;
    }
    if (!this.actions.isEmpty() && this.actions.get(0).getId() == USER_NAME) {
        this.actions.get(0).setEditDescription(account.getAlias());
    }
    if (vcard == null || vcard.getPhotos().isEmpty()) {
        getGuidanceStylist().getIconView().setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_contact_picture_fallback));
        return;
    }
    Drawable contactPicture = AvatarFactory.getAvatar(getActivity(), vcard.getPhotos().get(0).getData(), account.getDisplayUsername(), account.getUri());
    Glide.with(getActivity()).load(contactPicture).apply(AvatarFactory.getGlideOptions(true, false)).transition(DrawableTransitionOptions.withCrossFade()).into(getGuidanceStylist().getIconView());
}
Also used : Account(cx.ring.model.Account) Drawable(android.graphics.drawable.Drawable) VCard(ezvcard.VCard)

Example 100 with VCard

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

the class MainFragment method displayAccountInfos.

@Override
public void displayAccountInfos(final String address, final RingNavigationViewModel viewModel) {
    getActivity().runOnUiThread(() -> {
        if (getActivity() == null) {
            Log.e(TAG, "displayAccountInfos: Not able to get activity");
            return;
        }
        VCard vcard = viewModel.getVcard(getActivity().getFilesDir());
        if (vcard == null) {
            Log.e(TAG, "displayAccountInfos: Not able to get vcard");
            return;
        }
        String formattedName = vcard.getFormattedName().getValue();
        if (formattedName != null && !formattedName.isEmpty()) {
            titleView.setAlias(formattedName);
            if (address != null) {
                setTitle(address);
            } else {
                setTitle("");
            }
        } else {
            titleView.setAlias(address);
        }
        byte[] data = null;
        List<Photo> photos = vcard.getPhotos();
        if (!photos.isEmpty() && photos.get(0) != null) {
            data = photos.get(0).getData();
        }
        Drawable contactPicture = AvatarFactory.getAvatar(getActivity(), data, viewModel.getAccount().getDisplayUsername(), address);
        titleView.setCurrentAccountPhoto(contactPicture);
    });
}
Also used : Drawable(android.graphics.drawable.Drawable) Photo(ezvcard.property.Photo) VCard(ezvcard.VCard)

Aggregations

VCard (ezvcard.VCard)191 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