Commit 53f5a151 authored by Matthieu's avatar Matthieu
Browse files

More consistent, remove useless method

parent f6e4804c
Pipeline #833 failed with stages
in 13 minutes and 32 seconds
......@@ -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)
......
......@@ -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)
}
......
......@@ -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)
}
}
......
......@@ -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(
......
......@@ -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
/**
......
......@@ -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>
......
......@@ -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 = ""))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment