Add gestion of avatar and header

main
daycode 8 years ago
parent 1fbd987ac0
commit 8df5e4f9e2
  1. 20
      app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java
  2. 8
      app/src/main/res/drawable/round_button.xml
  3. 90
      app/src/main/res/layout/activity_edit_profile.xml

@ -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;
}
}

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#66000000" />
<size
android:width="80dp"
android:height="80dp"/>
</shape>

@ -19,32 +19,15 @@
android:background="?attr/toolbar_background_color"
android:elevation="4dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_header"
android:labelFor="@+id/edit_profile_header"
android:visibility="gone"/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="125dp"
android:id="@id/edit_profile_header"
app:srcCompat="@drawable/ic_add_a_photo_32dp"
android:text="@string/action_photo_pick"
android:textColor="@color/text_color_primary_dark" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp">
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="125dp"
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/edit_profile_header_preview"
android:contentDescription="@null"
android:visibility="gone" />
android:contentDescription="@null" />
<ProgressBar
android:layout_width="wrap_content"
@ -54,39 +37,34 @@
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_header"
android:labelFor="@+id/edit_profile_header"
android:visibility="gone"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_avatar"
android:labelFor="@+id/edit_profile_avatar"
android:layout_marginLeft="16dp"
android:visibility="gone"/>
<ImageButton
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@id/edit_profile_avatar"
app:srcCompat="@drawable/ic_add_a_photo_32dp"
android:text="@string/action_photo_pick"
android:textColor="@color/text_color_primary_dark"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="-40dp"
android:elevation="10dp"/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@id/edit_profile_header"
app:srcCompat="@drawable/ic_add_a_photo_32dp"
android:text="@string/action_photo_pick"
android:textColor="@color/text_color_primary_dark"
android:background="#66000000"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp">
android:paddingLeft="16dp"
android:layout_marginTop="-40dp">
<ImageView
<com.pkmmte.view.CircularImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/edit_profile_avatar_preview"
android:contentDescription="@null"
android:visibility="gone" />
android:contentDescription="@null" />
<ProgressBar
android:layout_width="wrap_content"
@ -96,13 +74,29 @@
android:indeterminate="true"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_avatar"
android:labelFor="@+id/edit_profile_avatar"
android:visibility="gone"/>
<ImageButton
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@id/edit_profile_avatar"
app:srcCompat="@drawable/ic_add_a_photo_32dp"
android:text="@string/action_photo_pick"
android:textColor="@color/text_color_primary_dark"
android:elevation="4dp"
android:background="@drawable/round_button"/>
</RelativeLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/layout_edit_profile_display_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp">
android:layout_marginTop="30dp">
<EditText
android:layout_width="match_parent"
@ -119,7 +113,7 @@
android:id="@+id/layout_edit_profile_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp">
android:layout_marginTop="30dp">
<EditText
android:layout_width="match_parent"

Loading…
Cancel
Save