Show the requester's bio in a "wants to follow you" notification (#3284)

This commit is contained in:
Nik Clayton 2023-05-04 16:00:30 +02:00 committed by GitHub
parent 1040358f3c
commit 7ce5048752
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 19 deletions

View file

@ -27,7 +27,9 @@ import com.keylesspalace.tusky.entity.TimelineAccount
import com.keylesspalace.tusky.interfaces.AccountActionListener import com.keylesspalace.tusky.interfaces.AccountActionListener
import com.keylesspalace.tusky.util.StatusDisplayOptions import com.keylesspalace.tusky.util.StatusDisplayOptions
import com.keylesspalace.tusky.util.emojify import com.keylesspalace.tusky.util.emojify
import com.keylesspalace.tusky.util.hide
import com.keylesspalace.tusky.util.loadAvatar import com.keylesspalace.tusky.util.loadAvatar
import com.keylesspalace.tusky.util.parseAsMastodonHtml
import com.keylesspalace.tusky.util.unicodeWrap import com.keylesspalace.tusky.util.unicodeWrap
import com.keylesspalace.tusky.util.visible import com.keylesspalace.tusky.util.visible
import com.keylesspalace.tusky.viewdata.NotificationViewData import com.keylesspalace.tusky.viewdata.NotificationViewData
@ -87,9 +89,14 @@ class FollowRequestViewHolder(
binding.notificationTextView.visible(showHeader) binding.notificationTextView.visible(showHeader)
val formattedUsername = itemView.context.getString(R.string.post_username_format, account.username) val formattedUsername = itemView.context.getString(R.string.post_username_format, account.username)
binding.usernameTextView.text = formattedUsername binding.usernameTextView.text = formattedUsername
val avatarRadius = binding.avatar.context.resources.getDimensionPixelSize( if (account.note.isEmpty()) {
R.dimen.avatar_radius_48dp binding.accountNote.hide()
) } else {
binding.accountNote.text =
account.note.parseAsMastodonHtml()
.emojify(account.emojis, binding.accountNote, animateEmojis)
}
val avatarRadius = binding.avatar.context.resources.getDimensionPixelSize(R.dimen.avatar_radius_48dp)
loadAvatar(account.avatar, binding.avatar, avatarRadius, animateAvatar) loadAvatar(account.avatar, binding.avatar, avatarRadius, animateAvatar)
binding.avatarBadge.visible(showBotOverlay && account.bot) binding.avatarBadge.visible(showBotOverlay && account.bot)
} }

View file

@ -74,6 +74,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="7dp" android:layout_marginTop="7dp"
android:hyphenationFrequency="full" android:hyphenationFrequency="full"
android:lineSpacingMultiplier="1.1"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
android:textIsSelectable="true" android:textIsSelectable="true"
app:layout_constrainedWidth="true" app:layout_constrainedWidth="true"

View file

@ -4,8 +4,9 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="16dp" android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingBottom="10dp"> android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingBottom="8dp">
<TextView <TextView
android:id="@+id/notificationTextView" android:id="@+id/notificationTextView"
@ -22,13 +23,14 @@
app:drawableStartCompat="@drawable/ic_person_add_24dp" app:drawableStartCompat="@drawable/ic_person_add_24dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:text="Someone requested to follow you" /> tools:text="Someone requested to follow you"
tools:ignore="RtlSymmetry" />
<ImageView <ImageView
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_centerVertical="true" android:layout_centerVertical="false"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:contentDescription="@string/action_view_profile" android:contentDescription="@string/action_view_profile"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -49,15 +51,15 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="14dp" android:layout_marginStart="14dp"
android:layout_marginTop="6dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textSize="?attr/status_text_large" android:textSize="?attr/status_text_medium"
android:textStyle="normal|bold" android:textStyle="normal|bold"
app:layout_constraintBottom_toTopOf="@id/usernameTextView"
app:layout_constraintEnd_toStartOf="@id/rejectButton" app:layout_constraintEnd_toStartOf="@id/rejectButton"
app:layout_constraintStart_toEndOf="@id/avatar" app:layout_constraintStart_toEndOf="@+id/avatar"
app:layout_constraintTop_toTopOf="@id/avatar" app:layout_constraintTop_toBottomOf="@id/notificationTextView"
tools:text="Display name" /> tools:text="Display name" />
<TextView <TextView
@ -69,8 +71,7 @@
android:maxLines="1" android:maxLines="1"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
app:layout_constraintBottom_toBottomOf="@id/avatar" app:layout_constraintEnd_toStartOf="@+id/rejectButton"
app:layout_constraintEnd_toStartOf="@id/rejectButton"
app:layout_constraintStart_toEndOf="@id/avatar" app:layout_constraintStart_toEndOf="@id/avatar"
app:layout_constraintTop_toBottomOf="@id/displayNameTextView" app:layout_constraintTop_toBottomOf="@id/displayNameTextView"
tools:text="\@username" /> tools:text="\@username" />
@ -80,7 +81,6 @@
style="@style/TuskyImageButton" style="@style/TuskyImageButton"
android:layout_width="52dp" android:layout_width="52dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_centerVertical="true"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/action_reject" android:contentDescription="@string/action_reject"
@ -88,7 +88,7 @@
app:layout_constraintBottom_toBottomOf="@id/avatar" app:layout_constraintBottom_toBottomOf="@id/avatar"
app:layout_constraintEnd_toStartOf="@id/acceptButton" app:layout_constraintEnd_toStartOf="@id/acceptButton"
app:layout_constraintStart_toEndOf="@id/displayNameTextView" app:layout_constraintStart_toEndOf="@id/displayNameTextView"
app:layout_constraintTop_toTopOf="@id/avatar" app:layout_constraintTop_toBottomOf="@+id/notificationTextView"
app:srcCompat="@drawable/ic_reject_24dp" /> app:srcCompat="@drawable/ic_reject_24dp" />
<ImageButton <ImageButton
@ -96,15 +96,26 @@
style="@style/TuskyImageButton" style="@style/TuskyImageButton"
android:layout_width="52dp" android:layout_width="52dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_centerVertical="true"
android:layout_marginStart="12dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/action_accept" android:contentDescription="@string/action_accept"
android:padding="4dp" android:padding="4dp"
app:layout_constraintBottom_toBottomOf="@id/avatar"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/avatar" app:layout_constraintTop_toTopOf="@+id/rejectButton"
app:srcCompat="@drawable/ic_check_24dp" /> app:srcCompat="@drawable/ic_check_24dp" />
<TextView
android:id="@+id/account_note"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textSize="?attr/status_text_medium"
android:textIsSelectable="true"
android:hyphenationFrequency="full"
android:lineSpacingMultiplier="1.1"
app:layout_constraintEnd_toEndOf="@+id/acceptButton"
app:layout_constraintStart_toStartOf="@+id/usernameTextView"
app:layout_constraintTop_toBottomOf="@+id/rejectButton"
tools:text="Account note" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>