Commit 3ed94802 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Merge branch 'develop' into iss321

parents dc5b10e2 8d3adfa4
...@@ -69,8 +69,11 @@ object UserAvatarHelper { ...@@ -69,8 +69,11 @@ object UserAvatarHelper {
} }
val splitUsername = username.split(".") val splitUsername = username.split(".")
if (splitUsername.size > 1) { val splitCount = splitUsername.size
return (splitUsername[0].substring(0, 1) + splitUsername[splitUsername.size - 1].substring(0, 1)).toUpperCase() if (splitCount > 1 && splitUsername[0].isNotEmpty() && splitUsername[1].isNotEmpty()) {
val firstInitial = splitUsername[0].substring(0, 1)
val secondInitial = splitUsername[1].substring(0, 1)
return (firstInitial + secondInitial).toUpperCase()
} else { } else {
if (username.length > 1) { if (username.length > 1) {
return username.substring(0, 2).toUpperCase() return username.substring(0, 2).toUpperCase()
......
...@@ -18,5 +18,9 @@ class UserAvatarHelperTest { ...@@ -18,5 +18,9 @@ class UserAvatarHelperTest {
assert(UserAvatarHelper.getUsernameInitials("Foo.bar") == "FB") assert(UserAvatarHelper.getUsernameInitials("Foo.bar") == "FB")
assert(UserAvatarHelper.getUsernameInitials("Foobar.bar") == "FB") assert(UserAvatarHelper.getUsernameInitials("Foobar.bar") == "FB")
assert(UserAvatarHelper.getUsernameInitials("Foobar.bar.zab") == "FZ") assert(UserAvatarHelper.getUsernameInitials("Foobar.bar.zab") == "FZ")
assert(UserAvatarHelper.getUsernameInitials("..") == "..")
assert(UserAvatarHelper.getUsernameInitials("...") == "..")
assert(UserAvatarHelper.getUsernameInitials(".Foo.") == ".F")
assert(UserAvatarHelper.getUsernameInitials("Foo..") == "FO")
} }
} }
\ No newline at end of file
Markdown is supported
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