From ef3f96ba74566b4661561ffa21c64f7a84a3647c Mon Sep 17 00:00:00 2001 From: sk Date: Sun, 27 Aug 2023 14:12:23 +0200 Subject: [PATCH] fix timestamp being hidden for long usernames closes sk22#772 --- .../onboarding/CustomWelcomeFragment.java | 4 +- .../displayitems/HeaderStatusDisplayItem.java | 16 +++--- .../main/res/layout/display_item_header.xml | 49 +++++++++++++++---- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/CustomWelcomeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/CustomWelcomeFragment.java index 2301feb46..0b77feaf3 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/CustomWelcomeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/CustomWelcomeFragment.java @@ -139,7 +139,9 @@ public class CustomWelcomeFragment extends InstanceCatalogFragment { headerView.findViewById(R.id.more).setVisibility(View.GONE); headerView.findViewById(R.id.visibility).setVisibility(View.GONE); headerView.findViewById(R.id.unread_indicator).setVisibility(View.GONE); - ((TextView) headerView.findViewById(R.id.time_and_username)).setText(R.string.sk_app_username); + headerView.findViewById(R.id.separator).setVisibility(View.GONE); + headerView.findViewById(R.id.time).setVisibility(View.GONE); + ((TextView) headerView.findViewById(R.id.username)).setText(R.string.sk_app_username); ((TextView) headerView.findViewById(R.id.name)).setText(R.string.sk_app_name); ((ImageView) headerView.findViewById(R.id.avatar)).setImageDrawable(getActivity().getDrawable(R.mipmap.ic_launcher)); ((FragmentStackActivity) getActivity()).invalidateSystemBarColors(this); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index 9b2c3caca..d47b756ee 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -132,8 +132,8 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ } public static class Holder extends StatusDisplayItem.Holder implements ImageLoaderViewHolder{ - private final TextView name, timeAndUsername, extraText, pronouns; - private final View collapseBtn; + private final TextView name, time, username, extraText, pronouns; + private final View collapseBtn, timeUsernameSeparator; private final ImageView avatar, more, visibility, deleteNotification, unreadIndicator, markAsRead, collapseBtnIcon; private final PopupMenu optionsMenu; private Relationship relationship; @@ -146,7 +146,9 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ protected Holder(Activity activity, @LayoutRes int layout, ViewGroup parent){ super(activity, layout, parent); name=findViewById(R.id.name); - timeAndUsername=findViewById(R.id.time_and_username); + time=findViewById(R.id.time); + username=findViewById(R.id.username); + timeUsernameSeparator=findViewById(R.id.separator); avatar=findViewById(R.id.avatar); more=findViewById(R.id.more); visibility=findViewById(R.id.visibility); @@ -315,10 +317,10 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ else if (item.status != null && item.status.editedAt != null) time=item.parentFragment.getString(R.string.edited_timestamp, UiUtils.formatRelativeTimestamp(itemView.getContext(), item.status.editedAt)); - String sepp = item.parentFragment.getString(R.string.sk_separator); - String username = "@" + item.user.acct; - timeAndUsername.setText(time == null ? username : - username + " " + sepp + " " + time); + this.username.setText("@" + item.user.acct); + this.timeUsernameSeparator.setVisibility(time==null ? View.GONE : View.VISIBLE); + this.time.setVisibility(time==null ? View.GONE : View.VISIBLE); + if(time!=null) this.time.setText(time); deleteNotification.setVisibility(GlobalUserPreferences.enableDeleteNotifications && item.notification!=null && !item.inset ? View.VISIBLE : View.GONE); if (item.hasVisibilityToggle){ diff --git a/mastodon/src/main/res/layout/display_item_header.xml b/mastodon/src/main/res/layout/display_item_header.xml index 57752e2db..abf47a7bb 100644 --- a/mastodon/src/main/res/layout/display_item_header.xml +++ b/mastodon/src/main/res/layout/display_item_header.xml @@ -152,20 +152,51 @@ - + android:layout_marginBottom="3sp"> + + + + + + + + + \ No newline at end of file