Show the follower's bio/note in a "followed you" notification (#3281)
This makes the notification view for a follow request contain more info about the new follower, and makes the layout (of their name / username) consistent with other notifications that show names/usernames.
This commit is contained in:
		
					parent
					
						
							
								af2727b633
							
						
					
				
			
			
				commit
				
					
						f1b3faf85f
					
				
			
		
					 10 changed files with 35 additions and 7 deletions
				
			
		|  | @ -29,7 +29,7 @@ | |||
| 
 | ||||
|          Disable these for the time being. --> | ||||
|     <issue id="UnusedIds" severity="ignore" /> | ||||
|      | ||||
| 
 | ||||
|     <!-- Ensure we are warned about errors in the baseline --> | ||||
|     <issue id="LintBaseline" severity="warning" /> | ||||
| 
 | ||||
|  |  | |||
|  | @ -64,6 +64,7 @@ data class ConversationAccountEntity( | |||
|             localUsername = localUsername, | ||||
|             username = username, | ||||
|             displayName = displayName, | ||||
|             note = "", | ||||
|             url = "", | ||||
|             avatar = avatar, | ||||
|             emojis = emojis | ||||
|  |  | |||
|  | @ -25,6 +25,7 @@ import com.keylesspalace.tusky.entity.TimelineAccount | |||
| import com.keylesspalace.tusky.util.StatusDisplayOptions | ||||
| import com.keylesspalace.tusky.util.emojify | ||||
| import com.keylesspalace.tusky.util.loadAvatar | ||||
| import com.keylesspalace.tusky.util.parseAsMastodonHtml | ||||
| import com.keylesspalace.tusky.util.unicodeWrap | ||||
| import com.keylesspalace.tusky.viewdata.NotificationViewData | ||||
| 
 | ||||
|  | @ -92,6 +93,12 @@ class FollowViewHolder( | |||
|             avatarRadius42dp, | ||||
|             animateAvatars | ||||
|         ) | ||||
| 
 | ||||
|         binding.notificationAccountNote.text = account.note.parseAsMastodonHtml().emojify( | ||||
|             account.emojis, | ||||
|             binding.notificationAccountNote, | ||||
|             animateEmojis | ||||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     private fun setupButtons(listener: NotificationActionListener, accountId: String) { | ||||
|  |  | |||
|  | @ -63,6 +63,7 @@ fun TimelineAccountEntity.toAccount(gson: Gson): TimelineAccount { | |||
|         localUsername = localUsername, | ||||
|         username = username, | ||||
|         displayName = displayName, | ||||
|         note = "", | ||||
|         url = url, | ||||
|         avatar = avatar, | ||||
|         bot = bot, | ||||
|  |  | |||
|  | @ -28,6 +28,7 @@ data class TimelineAccount( | |||
|     @SerializedName("display_name") val displayName: String?, // should never be null per Api definition, but some servers break the contract | ||||
|     val url: String, | ||||
|     val avatar: String, | ||||
|     val note: String, | ||||
|     val bot: Boolean = false, | ||||
|     val emojis: List<Emoji>? = emptyList() // nullable for backward compatibility | ||||
| ) { | ||||
|  |  | |||
|  | @ -47,12 +47,14 @@ | |||
|         android:layout_marginTop="6dp" | ||||
|         android:ellipsize="end" | ||||
|         android:maxLines="1" | ||||
|         android:paddingEnd="@dimen/status_display_name_padding_end" | ||||
|         android:textColor="?android:textColorPrimary" | ||||
|         android:textSize="?attr/status_text_medium" | ||||
|         android:textStyle="normal|bold" | ||||
|         app:layout_constraintStart_toEndOf="@id/notification_avatar" | ||||
|         app:layout_constraintTop_toBottomOf="@+id/notification_text" | ||||
|         tools:text="Test User" /> | ||||
|         tools:text="Test User" | ||||
|         tools:ignore="RtlSymmetry" /> | ||||
| 
 | ||||
|     <TextView | ||||
|         android:id="@+id/notification_username" | ||||
|  | @ -62,8 +64,22 @@ | |||
|         android:maxLines="1" | ||||
|         android:textColor="?android:textColorSecondary" | ||||
|         android:textSize="?attr/status_text_medium" | ||||
|         app:layout_constraintStart_toStartOf="@+id/notification_display_name" | ||||
|         app:layout_constraintTop_toBottomOf="@id/notification_display_name" | ||||
|         app:layout_constraintStart_toEndOf="@+id/notification_display_name" | ||||
|         app:layout_constraintTop_toTopOf="@+id/notification_display_name" | ||||
|         tools:text="\@testuser" /> | ||||
| 
 | ||||
|     <TextView | ||||
|         android:id="@+id/notification_account_note" | ||||
|         android:layout_width="0dp" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_marginTop="7dp" | ||||
|         android:hyphenationFrequency="full" | ||||
|         android:textSize="?attr/status_text_medium" | ||||
|         android:textIsSelectable="true" | ||||
|         app:layout_constrainedWidth="true" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="@+id/notification_display_name" | ||||
|         app:layout_constraintTop_toBottomOf="@+id/notification_display_name" | ||||
|         tools:text="Account note" /> | ||||
| 
 | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|  |  | |||
|  | @ -56,6 +56,7 @@ class BottomSheetActivityTest { | |||
|         localUsername = "admin", | ||||
|         username = "admin", | ||||
|         displayName = "Ad Min", | ||||
|         note = "This is their bio", | ||||
|         url = "http://mastodon.foo.bar/@User", | ||||
|         avatar = "" | ||||
|     ) | ||||
|  |  | |||
|  | @ -100,6 +100,7 @@ class MainActivityTest { | |||
|                         localUsername = "connyduck", | ||||
|                         username = "connyduck@mastodon.example", | ||||
|                         displayName = "Conny Duck", | ||||
|                         note = "This is their bio", | ||||
|                         url = "https://mastodon.example/@ConnyDuck", | ||||
|                         avatar = "https://mastodon.example/system/accounts/avatars/000/150/486/original/ab27d7ddd18a10ea.jpg" | ||||
|                     ), | ||||
|  |  | |||
|  | @ -33,8 +33,8 @@ class StatusComparisonTest { | |||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     fun `accounts with different notes in json - should be equal because notes are not relevant for timelines`() { | ||||
|         assertEquals(createStatus(note = "Test"), createStatus(note = "Test 123456")) | ||||
|     fun `accounts with different notes in json - should not be equal`() { | ||||
|         assertNotEquals(createStatus(note = "Test"), createStatus(note = "Test 123456")) | ||||
|     } | ||||
| 
 | ||||
|     private val gson = Gson() | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ import com.keylesspalace.tusky.db.TimelineStatusWithAccount | |||
| import com.keylesspalace.tusky.entity.Status | ||||
| import com.keylesspalace.tusky.entity.TimelineAccount | ||||
| import com.keylesspalace.tusky.viewdata.StatusViewData | ||||
| import java.util.ArrayList | ||||
| import java.util.Date | ||||
| 
 | ||||
| private val fixedDate = Date(1638889052000) | ||||
|  | @ -26,6 +25,7 @@ fun mockStatus( | |||
|         localUsername = "connyduck", | ||||
|         username = "connyduck@mastodon.example", | ||||
|         displayName = "Conny Duck", | ||||
|         note = "This is their bio", | ||||
|         url = "https://mastodon.example/@ConnyDuck", | ||||
|         avatar = "https://mastodon.example/system/accounts/avatars/000/150/486/original/ab27d7ddd18a10ea.jpg" | ||||
|     ), | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue