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