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;
}
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();
}
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();
}
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());
}
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);
});
}
Aggregations