summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstom79 <tschneider.ac@gmail.com>2018-04-22 13:21:31 +0200
committerstom79 <tschneider.ac@gmail.com>2018-04-22 13:21:31 +0200
commit37086e1c9b8db475a76ca28b79f2fd7e3658fe09 (patch)
treec9facb62753be409ebb54c0f0ef853c56d0c6908
parentbbea68eb6673ff96535f452d88633b2dfe736977 (diff)
Put Image as a preview
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java
index 85fc185db..b43bcd458 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java
@@ -454,6 +454,16 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
return;
}
+ try {
+ InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(data.getData());
+ assert inputStream != null;
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
+ Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream);
+ profile_header_bmp = Bitmap.createScaledBitmap(bmp, 700, 335, true);
+ set_header_picture.setImageBitmap(profile_header_bmp);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
ByteArrayInputStream bs = Helper.compressImage(EditProfileActivity.this, data.getData(), Helper.MediaType.MEDIA);
assert bs != null;
int n = bs.available();
@@ -476,6 +486,17 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
return;
}
+
+ try {
+ InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(data.getData());
+ assert inputStream != null;
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
+ Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream);
+ profile_picture_bmp = Bitmap.createScaledBitmap(bmp, 400, 400, true);
+ set_profile_picture.setImageBitmap(profile_picture_bmp);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
ByteArrayInputStream bs = Helper.compressImage(EditProfileActivity.this, data.getData(), Helper.MediaType.MEDIA);
assert bs != null;
int n = bs.available();
@@ -485,7 +506,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
String s;
ContentResolver cr = getContentResolver();
String mime = cr.getType(data.getData());
- set_profile_picture.setImageBitmap(profile_picture_bmp);
+
try {
s = new String(bytes, "UTF-8");
profile_picture = "data:"+mime+";base64, " + s;