Merge branch 'profile-edition-design' of https://github.com/daycode/Tusky into daycode-profile-edition-design

This commit is contained in:
Vavassor 2017-05-01 21:52:11 -04:00
commit cfb0219536
7 changed files with 141 additions and 106 deletions

View file

@ -38,11 +38,14 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
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;
@ -73,14 +76,14 @@ public class EditProfileActivity extends BaseActivity {
HEADER
}
@BindView(R.id.edit_profile_display_name) EditText displayNameEditText;
@BindView(R.id.edit_profile_note) EditText noteEditText;
@BindView(R.id.edit_profile_avatar) Button avatarButton;
@BindView(R.id.edit_profile_avatar_preview) ImageView avatarPreview;
@BindView(R.id.edit_profile_avatar_progress) ProgressBar avatarProgress;
@BindView(R.id.edit_profile_header) Button headerButton;
@BindView(R.id.edit_profile_header) ImageButton headerButton;
@BindView(R.id.edit_profile_header_preview) ImageView headerPreview;
@BindView(R.id.edit_profile_header_progress) ProgressBar headerProgress;
@BindView(R.id.edit_profile_avatar) ImageButton avatarButton;
@BindView(R.id.edit_profile_avatar_preview) ImageView avatarPreview;
@BindView(R.id.edit_profile_avatar_progress) ProgressBar avatarProgress;
@BindView(R.id.edit_profile_display_name) EditText displayNameEditText;
@BindView(R.id.edit_profile_note) EditText noteEditText;
@BindView(R.id.edit_profile_save_progress) ProgressBar saveProgress;
private String priorDisplayName;
@ -100,7 +103,7 @@ public class EditProfileActivity extends BaseActivity {
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(null);
actionBar.setTitle(getString(R.string.title_edit_profile));
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
@ -121,6 +124,8 @@ public class EditProfileActivity extends BaseActivity {
headerBase64 = null;
}
avatarButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -138,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;
}
});
@ -146,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;
}
});
@ -161,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
@ -337,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;
}
}

View file

@ -0,0 +1,4 @@
<vector android:height="32dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M3,4L3,1h2v3h3v2L5,6v3L3,9L3,6L0,6L0,4h3zM6,10L6,7h3L9,4h7l1.83,2L21,6c1.1,0 2,0.9 2,2v12c0,1.1 -0.9,2 -2,2L5,22c-1.1,0 -2,-0.9 -2,-2L3,10h3zM13,19c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5 -5,2.24 -5,5 2.24,5 5,5zM9.8,14c0,1.77 1.43,3.2 3.2,3.2s3.2,-1.43 3.2,-3.2 -1.43,-3.2 -3.2,-3.2 -3.2,1.43 -3.2,3.2z"/>
</vector>

View file

@ -0,0 +1,4 @@
<vector android:height="32dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
</vector>

View file

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

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -14,105 +16,18 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
android:background="?attr/toolbar_background_color"
android:elevation="4dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/edit_profile_display_name"
android:hint="@string/hint_display_name"
android:maxLength="30"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/edit_profile_note"
android:hint="@string/hint_note"
android:maxLength="160"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_avatar"
android:labelFor="@+id/edit_profile_avatar"
android:layout_marginRight="8dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@id/edit_profile_avatar"
android:text="@string/action_photo_pick"
android:textColor="@color/text_color_primary_dark" />
</LinearLayout>
<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="80dp"
android:layout_height="80dp"
android:id="@+id/edit_profile_avatar_preview"
android:contentDescription="@null"
android:visibility="gone" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/edit_profile_avatar_progress"
android:layout_centerInParent="true"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_header"
android:labelFor="@+id/edit_profile_header"
android:layout_marginRight="8dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@id/edit_profile_header"
android:text="@string/action_photo_pick"
android:textColor="@color/text_color_primary_dark" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp">
<ImageView
android:layout_width="167.2dp"
android:layout_height="80dp"
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"
@ -122,8 +37,96 @@
android:indeterminate="true"
android:visibility="gone" />
<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="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:layout_marginTop="-40dp">
<com.pkmmte.view.CircularImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/edit_profile_avatar_preview"
android:contentDescription="@null" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/edit_profile_avatar_progress"
android:layout_centerInParent="true"
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="30dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edit_profile_display_name"
android:hint="@string/hint_display_name"
android:maxLength="30"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/layout_edit_profile_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edit_profile_note"
android:hint="@string/hint_note"
android:maxLength="160"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<ProgressBar

View file

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_save"
android:icon="@drawable/ic_check_in_box_24dp"
android:icon="@drawable/ic_check_32dp"
android:title="@string/action_save"
app:showAsAction="always" />
</menu>

View file

@ -31,6 +31,7 @@
<string name="title_mutes">Muted users</string>
<string name="title_blocks">Blocked users</string>
<string name="title_follow_requests">Follow Requests</string>
<string name="title_edit_profile">Edit your profile</string>
<string name="status_username_format">\@%s</string>
<string name="status_boosted_format">%s boosted</string>