improve report notification layout

This commit is contained in:
Conny Duck 2024-04-11 20:24:49 +02:00
parent ad9b7a27eb
commit 55af4a3f03
No known key found for this signature in database
2 changed files with 26 additions and 25 deletions

View File

@ -46,17 +46,10 @@ class ReportNotificationViewHolder(
val reporterName = reporter.name.unicodeWrap().emojify(reporter.emojis, itemView, statusDisplayOptions.animateEmojis)
val reporteeName = report.targetAccount.name.unicodeWrap().emojify(report.targetAccount.emojis, itemView, statusDisplayOptions.animateEmojis)
val icon = ContextCompat.getDrawable(itemView.context, R.drawable.ic_flag_24dp)
binding.notificationTopText.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null)
binding.notificationTopText.text = itemView.context.getString(R.string.notification_header_report_format, reporterName, reporteeName)
binding.notificationSummary.text = itemView.context.getString(R.string.notification_summary_report_format, getRelativeTimeSpanString(itemView.context, report.createdAt.time, System.currentTimeMillis()), report.statusIds?.size ?: 0)
binding.notificationCategory.text = getTranslatedCategory(itemView.context, report.category)
// Fancy avatar inset
val padding = Utils.dpToPx(binding.notificationReporteeAvatar.context, 12)
binding.notificationReporteeAvatar.setPaddingRelative(0, 0, padding, padding)
loadAvatar(
report.targetAccount.avatar,
binding.notificationReporteeAvatar,

View File

@ -1,20 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/notification_report"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="14dp"
android:paddingRight="14dp">
android:paddingRight="14dp"
android:paddingBottom="14dp">
<TextView
android:id="@+id/notification_top_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="8dp"
android:drawablePadding="10dp"
android:ellipsize="end"
@ -23,19 +22,23 @@
android:paddingStart="28dp"
android:textColor="?android:textColorSecondary"
android:textSize="?attr/status_text_medium"
app:drawableStartCompat="@drawable/ic_flag_24dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Someone reported someone else" />
<ImageView
android:id="@+id/notification_reportee_avatar"
android:layout_width="48dp"
android:layout_height="48dp"
app:layout_constraintTop_toBottomOf="@id/notification_top_text"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="10dp"
android:layout_marginEnd="14dp"
android:layout_marginBottom="14dp"
android:contentDescription="@string/action_view_profile"
android:paddingEnd="12dp"
android:paddingBottom="12dp"
android:scaleType="centerCrop"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/notification_top_text"
tools:ignore="RtlHardcoded,RtlSymmetry"
tools:src="@drawable/avatar_default" />
@ -44,40 +47,45 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="@string/action_view_profile"
app:layout_constraintRight_toRightOf="@id/notification_reportee_avatar"
app:layout_constraintBottom_toBottomOf="@id/notification_reportee_avatar"
/>
app:layout_constraintRight_toRightOf="@id/notification_reportee_avatar"
tools:src="@drawable/avatar_default" />
<TextView
android:id="@+id/notification_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:layout_marginStart="14dp"
app:layout_constraintTop_toTopOf="@id/notification_reportee_avatar"
app:layout_constraintLeft_toRightOf="@id/notification_reporter_avatar"
android:importantForAccessibility="no"
android:layout_marginTop="-4dp"
android:hyphenationFrequency="full"
android:importantForAccessibility="no"
android:lineSpacingMultiplier="1.1"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
app:layout_constraintLeft_toRightOf="@id/notification_reporter_avatar"
app:layout_constraintTop_toTopOf="@id/notification_reportee_avatar"
tools:ignore="NegativeMargin"
tools:text="30 minutes ago - 2 posts" />
tools:text="30 minutes ago · 2 posts attached" />
<TextView
android:id="@+id/notification_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
app:layout_constraintTop_toBottomOf="@id/notification_summary"
app:layout_constraintLeft_toRightOf="@id/notification_reporter_avatar"
android:importantForAccessibility="no"
android:hyphenationFrequency="full"
android:importantForAccessibility="no"
android:lineSpacingMultiplier="1.1"
android:paddingBottom="10dp"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@id/notification_reporter_avatar"
app:layout_constraintTop_toBottomOf="@id/notification_summary"
tools:text="Spam" />
<androidx.constraintlayout.widget.Barrier
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="notification_reporter_avatar, notification_category" />
</androidx.constraintlayout.widget.ConstraintLayout>