UI changes in EditProfileActivity.

This commit is contained in:
Alex Ning 2021-11-11 20:37:28 +08:00
parent 4bd6ae0c4c
commit d6d6ed5407
3 changed files with 46 additions and 42 deletions

View File

@ -143,22 +143,26 @@ public class EditProfileActivity extends BaseActivity {
new ViewModelProvider(this, userViewModelFactory).get(UserViewModel.class); new ViewModelProvider(this, userViewModelFactory).get(UserViewModel.class);
userViewModel.getUserLiveData().observe(this, userData -> { userViewModel.getUserLiveData().observe(this, userData -> {
if (userData == null) return;// if (userData == null) {
return;
}
// BANNER // BANNER
final String userBanner = userData.getBanner(); final String userBanner = userData.getBanner();
LayoutParams cBannerLp = (LayoutParams) changeBanner.getLayoutParams(); LayoutParams cBannerLp = (LayoutParams) changeBanner.getLayoutParams();
if (userBanner == null || userBanner.isEmpty()) { if (userBanner == null || userBanner.isEmpty()) {
changeBanner.setLongClickable(false); changeBanner.setLongClickable(false);
changeBanner.setImageResource(R.drawable.ic_add_day_night_24dp); cBannerLp.gravity = Gravity.CENTER;
changeBanner.setLayoutParams(new LayoutParams(cBannerLp.width, cBannerLp.height, Gravity.CENTER)); changeBanner.setLayoutParams(cBannerLp);
changeBanner.setOnLongClickListener(v -> false); changeBanner.setOnLongClickListener(v -> false);
} else { } else {
changeBanner.setLongClickable(true); changeBanner.setLongClickable(true);
changeBanner.setImageResource(R.drawable.ic_outline_add_a_photo_day_night_24dp); cBannerLp.gravity = Gravity.END | Gravity.BOTTOM;
changeBanner.setLayoutParams(new LayoutParams(cBannerLp.width, cBannerLp.height, Gravity.END | Gravity.BOTTOM)); changeBanner.setLayoutParams(cBannerLp);
glide.load(userBanner).into(bannerImageView); glide.load(userBanner).into(bannerImageView);
changeBanner.setOnLongClickListener(view -> { changeBanner.setOnLongClickListener(view -> {
if (mAccessToken == null) return false; if (mAccessToken == null) {
return false;
}
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.remove_banner) .setTitle(R.string.remove_banner)
.setMessage(R.string.are_you_sure) .setMessage(R.string.are_you_sure)
@ -195,15 +199,13 @@ public class EditProfileActivity extends BaseActivity {
LayoutParams cAvatarLp = (LayoutParams) changeAvatar.getLayoutParams(); LayoutParams cAvatarLp = (LayoutParams) changeAvatar.getLayoutParams();
if (userAvatar.contains("avatar_default_")) { if (userAvatar.contains("avatar_default_")) {
changeAvatar.setLongClickable(false); changeAvatar.setLongClickable(false);
changeAvatar.setImageResource(R.drawable.ic_add_day_night_24dp);
changeAvatar.setLayoutParams(new LayoutParams(cAvatarLp.width, cAvatarLp.height, Gravity.CENTER));
changeAvatar.setOnLongClickListener(v -> false); changeAvatar.setOnLongClickListener(v -> false);
} else { } else {
changeAvatar.setLongClickable(true); changeAvatar.setLongClickable(true);
changeAvatar.setImageResource(R.drawable.ic_outline_add_a_photo_day_night_24dp);
changeAvatar.setLayoutParams(new LayoutParams(cAvatarLp.width, cAvatarLp.height, Gravity.END | Gravity.BOTTOM));
changeAvatar.setOnLongClickListener(view -> { changeAvatar.setOnLongClickListener(view -> {
if (mAccessToken == null) return false; if (mAccessToken == null) {
return false;
}
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.remove_avatar) .setTitle(R.string.remove_avatar)
.setMessage(R.string.are_you_sure) .setMessage(R.string.are_you_sure)

View File

@ -62,23 +62,22 @@
<ImageView <ImageView
android:id="@+id/image_view_change_banner_edit_profile_activity" android:id="@+id/image_view_change_banner_edit_profile_activity"
android:layout_width="32dp" android:layout_width="wrap_content"
android:layout_height="32dp" android:layout_height="wrap_content"
android:layout_gravity="end|bottom" android:layout_gravity="end|bottom"
android:layout_margin="4dp" android:layout_margin="8dp"
android:padding="8dp"
android:background="@drawable/ic_dot_outline" android:background="@drawable/ic_dot_outline"
android:contentDescription="@null"
android:padding="4dp"
app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" /> app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" />
</FrameLayout> </FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/frame_layout_view_avatar_edit_profile_activity" android:id="@+id/frame_layout_view_avatar_edit_profile_activity"
android:layout_width="72dp" android:layout_width="wrap_content"
android:layout_height="72dp" android:layout_height="wrap_content"
android:layout_marginStart="24dp" android:layout_marginStart="16dp"
android:layout_marginTop="143dp" android:layout_marginTop="144dp"
android:elevation="4dp"> android:elevation="4dp">
<pl.droidsonroids.gif.GifImageView <pl.droidsonroids.gif.GifImageView
@ -89,13 +88,11 @@
<ImageView <ImageView
android:id="@+id/image_view_change_avatar_edit_profile_activity" android:id="@+id/image_view_change_avatar_edit_profile_activity"
android:layout_width="32dp" android:layout_width="wrap_content"
android:layout_height="32dp" android:layout_height="wrap_content"
android:layout_gravity="end|bottom" android:layout_gravity="center"
android:layout_margin="4dp" android:padding="8dp"
android:background="@drawable/ic_dot_outline" android:background="@drawable/ic_dot_outline"
android:contentDescription="@null"
android:padding="4dp"
app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" /> app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" />
</FrameLayout> </FrameLayout>
@ -113,17 +110,18 @@
android:paddingTop="48dp" android:paddingTop="48dp"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:fontFamily="?attr/font_family"
android:text="@string/display_name_text" android:text="@string/display_name_text"
android:textSize="?attr/font_18" /> android:textSize="?attr/font_18"
android:fontFamily="?attr/font_family" />
<EditText <EditText
android:id="@+id/edit_text_display_name_edit_profile_activity" android:id="@+id/edit_text_display_name_edit_profile_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp" android:padding="16dp"
android:gravity="top"
android:background="#00000000" android:background="#00000000"
android:textSize="?attr/font_16"
android:fontFamily="?attr/font_family"
android:hint="@string/display_name_hint" android:hint="@string/display_name_hint"
android:importantForAutofill="no" android:importantForAutofill="no"
android:inputType="textCapSentences" android:inputType="textCapSentences"
@ -134,7 +132,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:text="@string/display_name_description" /> android:text="@string/display_name_description"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family" />
</LinearLayout> </LinearLayout>
@ -149,9 +149,9 @@
android:paddingTop="48dp" android:paddingTop="48dp"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:fontFamily="?attr/font_family"
android:text="@string/about_you_text" android:text="@string/about_you_text"
android:textSize="?attr/font_18" /> android:textSize="?attr/font_18"
android:fontFamily="?attr/font_family" />
<EditText <EditText
android:id="@+id/edit_text_about_you_edit_profile_activity" android:id="@+id/edit_text_about_you_edit_profile_activity"
@ -160,6 +160,8 @@
android:padding="16dp" android:padding="16dp"
android:gravity="top" android:gravity="top"
android:background="#00000000" android:background="#00000000"
android:textSize="?attr/font_16"
android:fontFamily="?attr/font_family"
android:hint="@string/about_you_hint" android:hint="@string/about_you_hint"
android:importantForAutofill="no" android:importantForAutofill="no"
android:inputType="textCapSentences|textMultiLine" android:inputType="textCapSentences|textMultiLine"

View File

@ -1230,15 +1230,15 @@
<string name="display_name_description">This will be displayed to viewers of your profile page and does not change your username.</string> <string name="display_name_description">This will be displayed to viewers of your profile page and does not change your username.</string>
<string name="about_you_text">About You</string> <string name="about_you_text">About You</string>
<string name="about_you_hint">A little description of yourself</string> <string name="about_you_hint">A little description of yourself</string>
<string name="message_remove_avatar_success">Success remove Avatar</string> <string name="message_remove_avatar_success">Remove avatar successfully</string>
<string name="message_remove_avatar_failed_fmt">Failed remove Avatar %s</string> <string name="message_remove_avatar_failed_fmt">Failed to remove avatar %s</string>
<string name="message_remove_banner_success">Success remove Banner</string> <string name="message_remove_banner_success">Remove banner successfully</string>
<string name="message_remove_banner_failed_fmt">Failed remove Banner %s</string> <string name="message_remove_banner_failed_fmt">Failed to remove banner %s</string>
<string name="message_change_avatar_success">Success changing Avatar</string> <string name="message_change_avatar_success">Change avatar successfully</string>
<string name="message_change_avatar_failed_fmt">Failed changing Avatar %s</string> <string name="message_change_avatar_failed_fmt">Failed to change avatar %s</string>
<string name="message_change_banner_success">Success changing Banner</string> <string name="message_change_banner_success">Changing banner successfully</string>
<string name="message_change_banner_failed_fmt">Failed changing Banner %s</string> <string name="message_change_banner_failed_fmt">Failed to change banner %s</string>
<string name="message_save_profile_success">Success save profile</string> <string name="message_save_profile_success">Save profile successfully</string>
<string name="message_save_profile_failed_fmt">Failed save profile %s</string> <string name="message_save_profile_failed_fmt">Failed to save profile %s</string>
</resources> </resources>