More consistent, remove useless method

This commit is contained in:
Matthieu 2021-10-07 23:04:12 +02:00
parent f6e4804c77
commit 53f5a151ba
7 changed files with 9 additions and 17 deletions

View File

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

View File

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

View File

@ -27,7 +27,7 @@ class FollowsActivity : BaseActivity() {
val user = db.userDao().getActiveUser()!!
startFragment(user.user_id, user.username, followers)
} else {
startFragment(account.id!!, account.getusername(), followers)
startFragment(account.id!!, account.username.orEmpty(), followers)
}
}

View File

@ -157,9 +157,10 @@ class ProfileActivity : BaseActivity() {
val displayName = account.getDisplayName()
supportActionBar?.title = displayName
supportActionBar?.title = "@${account.acct}"
if(displayName != "@${account.acct}") {
supportActionBar?.subtitle = "@${account.acct}"
supportActionBar?.subtitle = displayName
}
binding.nbPostsTextView.text = resources.getQuantityString(

View File

@ -74,12 +74,6 @@ data class Account(
else -> display_name.orEmpty()
}
fun getusername() : String = when {
username.isNullOrBlank() && display_name.isNullOrBlank() -> ""
username.isNullOrBlank() -> "@$display_name"
else -> username.orEmpty()
}
fun anyAvatar(): String? = avatar_static ?: avatar
/**

View File

@ -215,9 +215,9 @@ For more info about Pixelfed, you can check here: https://pixelfed.org"</string>
<string name="license_info">PixelDroid is free and open source software, licensed under the GNU General Public License (version 3 or later)</string>
<string name="about">About</string>
<string name="post_title">%1$s\'s post</string>
<string name="followers_title">%1$s\'s followers</string>
<string name="followers_title">\@%1$s\'s followers</string>
<string name="hashtag_title">#%1$s</string>
<string name="follows_title">%1$s\'s follows</string>
<string name="follows_title">\@%1$s\'s follows</string>
<string name="search_empty_error">Search query can\'t be empty</string>
<string name="status_more_options">More options</string>
<string name="report">Report</string>

View File

@ -33,9 +33,6 @@ class PostUnitTest {
@Test
fun getProfilePicUrlReturnsAValidURL() = Assert.assertNotNull(status.getProfilePicUrl())
@Test
fun getUsernameReturnsACorrectName() = Assert.assertEquals(status.account!!.username, status.account!!.getusername())
/*@Test
fun getUsernameReturnsOtherNameIfUsernameIsNull() {
val emptyDescStatus = status.copy(account = status.account!!.copy(username = ""))