Skip to content
Snippets Groups Projects
Commit 06f01c17 authored by Thibault Wittemberg's avatar Thibault Wittemberg
Browse files

vcard: Avatar is now saved before cropping it

Change-Id: I1f56df2580b79d35576e8f56c7440f5ef546ec13
Tuleap: #1125
parent 1fa8c062
No related branches found
No related tags found
No related merge requests found
......@@ -591,7 +591,6 @@ public class HomeActivity extends AppCompatActivity implements LocalService.Call
case REQUEST_CODE_PHOTO:
if(resultCode == RESULT_OK && data != null){
fMenuHead.updatePhoto((Bitmap) data.getExtras().get("data"));
}
break;
case REQUEST_CODE_GALLERY:
......
......@@ -27,7 +27,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
......@@ -91,6 +90,7 @@ public class MenuHeaderView extends FrameLayout {
@BindView(R.id.user_name)
TextView mUserName;
private Bitmap mSourcePhoto;
private ImageView mProfilePhoto;
private VCard mVCardProfile;
......@@ -158,8 +158,8 @@ public class MenuHeaderView extends FrameLayout {
}
public void updatePhoto(Bitmap image) {
image = CropImageUtils.cropImageToCircle(image);
mProfilePhoto.setImageBitmap(image);
mSourcePhoto = image;
mProfilePhoto.setImageBitmap(CropImageUtils.cropImageToCircle(image));
}
private void initViews() {
......@@ -249,10 +249,9 @@ public class MenuHeaderView extends FrameLayout {
}
mVCardProfile.setFormattedName(new FormattedName(username));
if (mProfilePhoto.getDrawable() != ResourcesCompat.getDrawable(getResources(), R.drawable.ic_contact_picture, null)) {
Bitmap bmp = ((BitmapDrawable) mProfilePhoto.getDrawable()).getBitmap();
if (mSourcePhoto != null && mProfilePhoto.getDrawable() != ResourcesCompat.getDrawable(getResources(), R.drawable.ic_contact_picture, null)) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
mSourcePhoto.compress(Bitmap.CompressFormat.PNG, 100, stream);
Photo photo = new Photo(stream.toByteArray(), ImageType.PNG);
mVCardProfile.removeProperties(Photo.class);
mVCardProfile.addPhoto(photo);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment