Post header tap area thing (AND-160)

This commit is contained in:
Grishka 2024-04-20 06:51:30 +03:00
parent 2bd13eb3ba
commit 873711939d
4 changed files with 35 additions and 8 deletions

View File

@ -119,6 +119,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
private final TextView name, timeAndUsername, extraText; private final TextView name, timeAndUsername, extraText;
private final ImageView avatar, more; private final ImageView avatar, more;
private final PopupMenu optionsMenu; private final PopupMenu optionsMenu;
private final View clickableThing;
public Holder(Activity activity, ViewGroup parent){ public Holder(Activity activity, ViewGroup parent){
this(activity, R.layout.display_item_header, parent); this(activity, R.layout.display_item_header, parent);
@ -131,7 +132,8 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
avatar=findViewById(R.id.avatar); avatar=findViewById(R.id.avatar);
more=findViewById(R.id.more); more=findViewById(R.id.more);
extraText=findViewById(R.id.extra_text); extraText=findViewById(R.id.extra_text);
avatar.setOnClickListener(this::onAvaClick); clickableThing=findViewById(R.id.clickable_thing);
clickableThing.setOnClickListener(this::onAvaClick);
avatar.setOutlineProvider(OutlineProviders.roundedRect(10)); avatar.setOutlineProvider(OutlineProviders.roundedRect(10));
avatar.setClipToOutline(true); avatar.setClipToOutline(true);
more.setOnClickListener(this::onMoreClick); more.setOnClickListener(this::onMoreClick);
@ -262,7 +264,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
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));
timeAndUsername.setText(time+" · @"+item.user.acct); timeAndUsername.setText(time+" · @"+item.user.acct);
itemView.setPadding(itemView.getPaddingLeft(), itemView.getPaddingTop(), itemView.getPaddingRight(), item.needBottomPadding ? V.dp(16) : 0); itemView.setPadding(itemView.getPaddingLeft(), itemView.getPaddingTop(), itemView.getPaddingRight(), item.needBottomPadding ? V.dp(16) : V.dp(4));
if(TextUtils.isEmpty(item.extraText)){ if(TextUtils.isEmpty(item.extraText)){
extraText.setVisibility(View.GONE); extraText.setVisibility(View.GONE);
}else{ }else{
@ -270,8 +272,8 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
extraText.setText(item.extraText); extraText.setText(item.extraText);
} }
more.setVisibility(item.inset ? View.GONE : View.VISIBLE); more.setVisibility(item.inset ? View.GONE : View.VISIBLE);
avatar.setClickable(!item.inset); clickableThing.setClickable(!item.inset);
avatar.setContentDescription(item.parentFragment.getString(R.string.avatar_description, item.user.acct)); clickableThing.setContentDescription(item.parentFragment.getString(R.string.avatar_description, item.user.acct));
} }
@Override @Override

View File

@ -94,7 +94,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
text.setTextIsSelectable(item.textSelectable); text.setTextIsSelectable(item.textSelectable);
text.setInvalidateOnEveryFrame(false); text.setInvalidateOnEveryFrame(false);
itemView.setClickable(false); itemView.setClickable(false);
text.setPadding(text.getPaddingLeft(), item.reduceTopPadding ? V.dp(8) : V.dp(16), text.getPaddingRight(), text.getPaddingBottom()); text.setPadding(text.getPaddingLeft(), item.reduceTopPadding ? V.dp(8) : V.dp(12), text.getPaddingRight(), text.getPaddingBottom());
text.setTextColor(UiUtils.getThemeColor(text.getContext(), item.inset ? R.attr.colorM3OnSurfaceVariant : R.attr.colorM3OnSurface)); text.setTextColor(UiUtils.getThemeColor(text.getContext(), item.inset ? R.attr.colorM3OnSurfaceVariant : R.attr.colorM3OnSurface));
updateTranslation(false); updateTranslation(false);
} }

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/m3_primary_overlay">
<item android:id="@android:id/mask">
<shape>
<solid android:color="#000"/>
<corners android:radius="14dp"/>
</shape>
</item>
</ripple>

View File

@ -4,8 +4,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="16dp" android:paddingTop="16dp"
android:paddingRight="16dp" android:paddingHorizontal="16dp"
android:paddingLeft="16dp"> android:paddingBottom="4dp"
android:clipToPadding="false">
<ImageView <ImageView
android:id="@+id/more" android:id="@+id/more"
@ -21,6 +22,18 @@
android:contentDescription="@string/more_options" android:contentDescription="@string/more_options"
android:src="@drawable/ic_more_vert_20px" /> android:src="@drawable/ic_more_vert_20px" />
<View
android:id="@+id/clickable_thing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="-4dp"
android:layout_marginVertical="-4dp"
android:layout_alignLeft="@id/avatar"
android:layout_alignRight="@id/time_and_username"
android:layout_alignTop="@id/avatar"
android:layout_alignBottom="@id/avatar"
android:background="@drawable/bg_status_header"/>
<ImageView <ImageView
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="40dp" android:layout_width="40dp"
@ -28,7 +41,8 @@
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:layout_marginEnd="8dp" /> android:layout_marginEnd="8dp"
android:importantForAccessibility="no"/>
<org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout <org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout
android:id="@+id/name_wrap" android:id="@+id/name_wrap"
@ -70,6 +84,8 @@
android:layout_height="20dp" android:layout_height="20dp"
android:layout_below="@id/name_wrap" android:layout_below="@id/name_wrap"
android:layout_toEndOf="@id/avatar" android:layout_toEndOf="@id/avatar"
android:layout_toStartOf="@id/more"
android:layout_marginEnd="8dp"
android:singleLine="true" android:singleLine="true"
android:ellipsize="end" android:ellipsize="end"
android:textAppearance="@style/m3_body_medium" android:textAppearance="@style/m3_body_medium"