Commit 5b4d6f1f authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update subUsername handling.

parent 297d60c5
...@@ -25,11 +25,12 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) { ...@@ -25,11 +25,12 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) {
rocketChatAvatarWidget.loadImage(message.avatar) rocketChatAvatarWidget.loadImage(message.avatar)
} else { } else {
val username: String? = message.user?.username val username: String? = message.user?.username
// Load user's avatar image from Rocket.Chat URI if username is not null.
if (username != null) { if (username != null) {
// Load user's avatar image from Rocket.Chat URI.
rocketChatAvatarWidget.loadImage(RocketChatUserAvatar(hostname, username).imageUri) rocketChatAvatarWidget.loadImage(RocketChatUserAvatar(hostname, username).imageUri)
userNotFoundAvatarImageView.visibility = View.GONE
rocketChatAvatarWidget.visibility = View.VISIBLE
} else { } else {
// Hide RocketChatAvatar widget and show an "user not found" avatar.
rocketChatAvatarWidget.visibility = View.GONE rocketChatAvatarWidget.visibility = View.GONE
userNotFoundAvatarImageView.visibility = View.VISIBLE userNotFoundAvatarImageView.visibility = View.VISIBLE
} }
...@@ -42,17 +43,12 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) { ...@@ -42,17 +43,12 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) {
fun showUsername(usernameTextView: TextView, subUsernameTextView: TextView?) { fun showUsername(usernameTextView: TextView, subUsernameTextView: TextView?) {
if (message.alias == null) { if (message.alias == null) {
usernameTextView.text = message.user?.username ?: usernameTextView.context.getText(R.string.user_not_found) usernameTextView.text = message.user?.username ?: usernameTextView.context.getText(R.string.user_not_found)
if (subUsernameTextView != null)
subUsernameTextView.visibility = View.GONE
} else { } else {
usernameTextView.text = message.alias usernameTextView.text = message.alias
if (subUsernameTextView != null) { val username: String? = message.user?.username
if (message.user != null) { if (username != null && subUsernameTextView != null) {
subUsernameTextView.text = "@" + message.user?.username subUsernameTextView.text = subUsernameTextView.context.getString(R.string.sub_username, username)
subUsernameTextView.visibility = View.VISIBLE subUsernameTextView.visibility = View.VISIBLE
} else {
subUsernameTextView.visibility = View.GONE
}
} }
} }
} }
......
...@@ -17,10 +17,9 @@ class UserRenderer(val user: User) { ...@@ -17,10 +17,9 @@ class UserRenderer(val user: User) {
val username: String? = user.username val username: String? = user.username
if (username != null) { if (username != null) {
rocketChatAvatarWidget.loadImage(RocketChatUserAvatar(hostname, username).imageUri) rocketChatAvatarWidget.loadImage(RocketChatUserAvatar(hostname, username).imageUri)
} else {
rocketChatAvatarWidget.visibility = View.GONE
} }
/**
* TODO Load default image for nullable username.
*/
} }
/** /**
......
...@@ -59,7 +59,8 @@ ...@@ -59,7 +59,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.RocketChat.Message.SubUsername" android:textAppearance="@style/TextAppearance.RocketChat.Message.SubUsername"
tools:text="\@John Doe" /> tools:text="\@John Doe"
android:visibility="gone" />
<Space <Space
android:layout_width="@dimen/margin_8" android:layout_width="@dimen/margin_8"
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
<string name="dialog_user_registration_email">Email</string> <string name="dialog_user_registration_email">Email</string>
<string name="dialog_user_registration_username">Username</string> <string name="dialog_user_registration_username">Username</string>
<string name="sub_username">\@%s</string>
<string name="user_not_found">User not found</string> <string name="user_not_found">User not found</string>
<string name="dialog_user_registration_password">Password</string> <string name="dialog_user_registration_password">Password</string>
<string name="fragment_home_welcome_message">Welcome to Rocket.Chat.Android\nSelect a channel from the drawer.</string> <string name="fragment_home_welcome_message">Welcome to Rocket.Chat.Android\nSelect a channel from the drawer.</string>
......
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