From 8df5e4f9e29143dcc2c1f0bbefbdcb94bb02b62c Mon Sep 17 00:00:00 2001 From: daycode Date: Mon, 1 May 2017 15:23:34 +0200 Subject: [PATCH] Add gestion of avatar and header --- .../tusky/EditProfileActivity.java | 20 ++++- app/src/main/res/drawable/round_button.xml | 8 ++ .../main/res/layout/activity_edit_profile.xml | 90 +++++++++---------- 3 files changed, 66 insertions(+), 52 deletions(-) create mode 100644 app/src/main/res/drawable/round_button.xml diff --git a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java index 313adfca..ddb53808 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java @@ -44,6 +44,8 @@ import android.widget.ProgressBar; import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.entity.Profile; +import com.pkmmte.view.CircularImageView; +import com.squareup.picasso.Picasso; import com.theartofdev.edmodo.cropper.CropImage; import java.io.ByteArrayOutputStream; @@ -141,7 +143,7 @@ public class EditProfileActivity extends BaseActivity { @Override public void onClick(View v) { avatarPreview.setImageBitmap(null); - avatarPreview.setVisibility(View.GONE); + avatarPreview.setVisibility(View.INVISIBLE); avatarBase64 = null; } }); @@ -149,7 +151,7 @@ public class EditProfileActivity extends BaseActivity { @Override public void onClick(View v) { headerPreview.setImageBitmap(null); - headerPreview.setVisibility(View.GONE); + headerPreview.setVisibility(View.INVISIBLE); headerBase64 = null; } }); @@ -164,8 +166,20 @@ public class EditProfileActivity extends BaseActivity { Account me = response.body(); priorDisplayName = me.getDisplayName(); priorNote = me.note.toString(); + CircularImageView avatar = (CircularImageView) findViewById(R.id.edit_profile_avatar_preview); + ImageView header = (ImageView) findViewById(R.id.edit_profile_header_preview); + displayNameEditText.setText(priorDisplayName); noteEditText.setText(priorNote); + Picasso.with(avatar.getContext()) + .load(me.avatar) + .placeholder(R.drawable.avatar_default) + .error(R.drawable.avatar_error) + .into(avatar); + Picasso.with(header.getContext()) + .load(me.header) + .placeholder(R.drawable.account_header_missing) + .into(header); } @Override @@ -340,12 +354,10 @@ public class EditProfileActivity extends BaseActivity { switch (currentlyPicking) { case AVATAR: { avatarProgress.setVisibility(View.GONE); - avatarPreview.setVisibility(View.GONE); break; } case HEADER: { headerProgress.setVisibility(View.GONE); - headerPreview.setVisibility(View.GONE); break; } } diff --git a/app/src/main/res/drawable/round_button.xml b/app/src/main/res/drawable/round_button.xml new file mode 100644 index 00000000..cdcac515 --- /dev/null +++ b/app/src/main/res/drawable/round_button.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_edit_profile.xml b/app/src/main/res/layout/activity_edit_profile.xml index 3ca28224..cf83cb16 100644 --- a/app/src/main/res/layout/activity_edit_profile.xml +++ b/app/src/main/res/layout/activity_edit_profile.xml @@ -19,32 +19,15 @@ android:background="?attr/toolbar_background_color" android:elevation="4dp" /> - - - - + android:layout_width="match_parent" + android:layout_height="wrap_content"> + android:contentDescription="@null" /> - + - - - + + + android:paddingLeft="16dp" + android:layout_marginTop="-40dp"> - + android:contentDescription="@null" /> + + + + android:layout_marginTop="30dp"> + android:layout_marginTop="30dp">