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