fix timestamp being hidden for long usernames

closes sk22#772
This commit is contained in:
sk 2023-08-27 14:12:23 +02:00
parent 91bf1b277f
commit ef3f96ba74
3 changed files with 52 additions and 17 deletions

View File

@ -139,7 +139,9 @@ public class CustomWelcomeFragment extends InstanceCatalogFragment {
headerView.findViewById(R.id.more).setVisibility(View.GONE); headerView.findViewById(R.id.more).setVisibility(View.GONE);
headerView.findViewById(R.id.visibility).setVisibility(View.GONE); headerView.findViewById(R.id.visibility).setVisibility(View.GONE);
headerView.findViewById(R.id.unread_indicator).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); ((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)); ((ImageView) headerView.findViewById(R.id.avatar)).setImageDrawable(getActivity().getDrawable(R.mipmap.ic_launcher));
((FragmentStackActivity) getActivity()).invalidateSystemBarColors(this); ((FragmentStackActivity) getActivity()).invalidateSystemBarColors(this);

View File

@ -132,8 +132,8 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
} }
public static class Holder extends StatusDisplayItem.Holder<HeaderStatusDisplayItem> implements ImageLoaderViewHolder{ public static class Holder extends StatusDisplayItem.Holder<HeaderStatusDisplayItem> implements ImageLoaderViewHolder{
private final TextView name, timeAndUsername, extraText, pronouns; private final TextView name, time, username, extraText, pronouns;
private final View collapseBtn; private final View collapseBtn, timeUsernameSeparator;
private final ImageView avatar, more, visibility, deleteNotification, unreadIndicator, markAsRead, collapseBtnIcon; private final ImageView avatar, more, visibility, deleteNotification, unreadIndicator, markAsRead, collapseBtnIcon;
private final PopupMenu optionsMenu; private final PopupMenu optionsMenu;
private Relationship relationship; private Relationship relationship;
@ -146,7 +146,9 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
protected Holder(Activity activity, @LayoutRes int layout, ViewGroup parent){ protected Holder(Activity activity, @LayoutRes int layout, ViewGroup parent){
super(activity, layout, parent); super(activity, layout, parent);
name=findViewById(R.id.name); 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); avatar=findViewById(R.id.avatar);
more=findViewById(R.id.more); more=findViewById(R.id.more);
visibility=findViewById(R.id.visibility); visibility=findViewById(R.id.visibility);
@ -315,10 +317,10 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
else if (item.status != null && item.status.editedAt != null) else if (item.status != null && item.status.editedAt != null)
time=item.parentFragment.getString(R.string.edited_timestamp, UiUtils.formatRelativeTimestamp(itemView.getContext(), item.status.editedAt)); time=item.parentFragment.getString(R.string.edited_timestamp, UiUtils.formatRelativeTimestamp(itemView.getContext(), item.status.editedAt));
String sepp = item.parentFragment.getString(R.string.sk_separator); this.username.setText("@" + item.user.acct);
String username = "@" + item.user.acct; this.timeUsernameSeparator.setVisibility(time==null ? View.GONE : View.VISIBLE);
timeAndUsername.setText(time == null ? username : this.time.setVisibility(time==null ? View.GONE : View.VISIBLE);
username + " " + sepp + " " + time); if(time!=null) this.time.setText(time);
deleteNotification.setVisibility(GlobalUserPreferences.enableDeleteNotifications && item.notification!=null && !item.inset ? View.VISIBLE : View.GONE); deleteNotification.setVisibility(GlobalUserPreferences.enableDeleteNotifications && item.notification!=null && !item.inset ? View.VISIBLE : View.GONE);
if (item.hasVisibilityToggle){ if (item.hasVisibilityToggle){

View File

@ -152,20 +152,51 @@
</org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout> </org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout>
<TextView <org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout
android:id="@+id/time_and_username"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/time_and_username"
android:layout_alignBottom="@id/avatar" android:layout_alignBottom="@id/avatar"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_toStartOf="@id/buttons" android:layout_toStartOf="@id/buttons"
android:layout_toEndOf="@id/avatar" android:layout_toEndOf="@id/avatar"
android:layout_marginBottom="3sp" android:layout_marginBottom="3sp">
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:singleLine="true" android:singleLine="true"
android:ellipsize="end" android:ellipsize="end"
android:textAppearance="@style/m3_body_medium" android:textAppearance="@style/m3_body_medium"
android:textColor="?colorM3OnSurfaceVariant" android:textColor="?colorM3OnSurfaceVariant"
tools:text="9h ago · \@Gargron@mastodon.social"/> tools:text="\@Gargron@mastodon.social"/>
<TextView
android:id="@+id/separator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4sp"
android:textAlignment="viewStart"
android:importantForAccessibility="no"
android:singleLine="true"
android:textAppearance="@style/m3_body_medium"
android:textColor="?colorM3OnSurfaceVariant"
android:text="@string/sk_separator"/>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:singleLine="true"
android:ellipsize="end"
android:textAppearance="@style/m3_body_medium"
android:textColor="?colorM3OnSurfaceVariant"
tools:text="9h ago"/>
</org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout>
</RelativeLayout> </RelativeLayout>