WIP display/username

This commit is contained in:
mjaillot 2021-04-09 17:58:10 +02:00
parent 2816c232c0
commit 4b6003816b
6 changed files with 13 additions and 7 deletions

View File

@ -48,7 +48,7 @@ class PostActivity : BaseActivity() {
accessToken = user?.accessToken.orEmpty()
supportActionBar?.title = getString(R.string.post_title).format(status.account?.getDisplayName())
supportActionBar?.title = getString(R.string.post_title).format(status.account?.getusername())
val holder = StatusViewHolder(binding.postFragmentSingle)

View File

@ -86,13 +86,13 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
) {
//Setup username as a button that opens the profile
binding.username.apply {
text = status?.account?.getDisplayName() ?: ""
text = status?.account?.getusername() ?: ""
setTypeface(null, Typeface.BOLD)
setOnClickListener { status?.account?.openProfile(binding.root.context) }
}
binding.usernameDesc.apply {
text = status?.account?.getDisplayName() ?: ""
text = status?.account?.getusername() ?: ""
setTypeface(null, Typeface.BOLD)
}

View File

@ -25,9 +25,9 @@ class FollowsActivity : BaseActivity() {
if(account == null) {
val user = db.userDao().getActiveUser()!!
startFragment(user.user_id, user.display_name, followers)
startFragment(user.user_id, user.username, followers)
} else {
startFragment(account.id!!, account.getDisplayName(), followers)
startFragment(account.id!!, account.getusername(), followers)
}
}

View File

@ -167,7 +167,7 @@ class ProfileActivity : BaseActivity() {
lifecycleScope
)
val displayName = account.getDisplayName()
val displayName = account.getusername()
binding.accountNameTextView.text = displayName

View File

@ -79,6 +79,12 @@ data class Account(
else -> display_name.orEmpty()
}
fun getusername() : String = when {
username.isNullOrBlank() && display_name.isNullOrBlank() -> ""
username.isNullOrBlank() -> "@$display_name"
else -> username.orEmpty()
}
/**
* @brief Open profile activity with given account
*/

View File

@ -34,7 +34,7 @@ class PostUnitTest {
fun getProfilePicUrlReturnsAValidURL() = Assert.assertNotNull(status.getProfilePicUrl())
@Test
fun getUsernameReturnsACorrectName() = Assert.assertEquals(status.account!!.display_name, status.account!!.getDisplayName())
fun getUsernameReturnsACorrectName() = Assert.assertEquals(status.account!!.display_name, status.account!!.getusername())
/*@Test
fun getUsernameReturnsOtherNameIfUsernameIsNull() {