Commit 7d58b105 authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge pull request #377 from filipedelimabrito/avatar-with-username-initials

Remove user not found handling.
parents 8ac51b53 d6b188cc
......@@ -13,7 +13,6 @@ import chat.rocket.core.SyncState;
public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMessage> {
protected final RocketChatAvatar avatar;
protected final ImageView userNotFoundAvatarImageView;
protected final ImageView errorImageView;
protected final TextView username;
protected final TextView subUsername;
......@@ -30,7 +29,6 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe
public AbstractMessageViewHolder(View itemView, AbsoluteUrl absoluteUrl, String hostname) {
super(itemView);
avatar = itemView.findViewById(R.id.user_avatar);
userNotFoundAvatarImageView = itemView.findViewById(R.id.userNotFoundAvatarImageView);
errorImageView = itemView.findViewById(R.id.errorImageView);
username = itemView.findViewById(R.id.username);
subUsername = itemView.findViewById(R.id.sub_username);
......
......@@ -29,7 +29,7 @@ public class MessageNormalViewHolder extends AbstractMessageViewHolder {
@Override
protected void bindMessage(PairedMessage pairedMessage, boolean autoloadImages) {
MessageRenderer messageRenderer = new MessageRenderer(pairedMessage.target, autoloadImages);
messageRenderer.showAvatar(avatar, hostname, userNotFoundAvatarImageView);
messageRenderer.showAvatar(avatar, hostname);
messageRenderer.showUsername(username, subUsername);
messageRenderer.showTimestampOrMessageState(timestamp);
messageRenderer.showBody(body);
......
......@@ -24,7 +24,7 @@ public class MessageSystemViewHolder extends AbstractMessageViewHolder {
@Override
protected void bindMessage(PairedMessage pairedMessage, boolean autoloadImages) {
MessageRenderer messageRenderer = new MessageRenderer(pairedMessage.target, autoloadImages);
messageRenderer.showAvatar(avatar, hostname, userNotFoundAvatarImageView);
messageRenderer.showAvatar(avatar, hostname);
messageRenderer.showUsername(username, subUsername);
messageRenderer.showTimestampOrMessageState(timestamp);
if (pairedMessage.target != null) {
......
package chat.rocket.android.renderer
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import chat.rocket.android.R
import chat.rocket.android.helper.DateTime
......@@ -19,10 +18,9 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) {
/**
* Show user's avatar image in RocketChatAvatar widget.
*/
fun showAvatar(rocketChatAvatarWidget: RocketChatAvatar, hostname: String, userNotFoundAvatarImageView: ImageView) {
fun showAvatar(rocketChatAvatarWidget: RocketChatAvatar, hostname: String) {
val username: String? = message.user?.username
if (username != null) {
userNotFoundAvatarImageView.visibility = View.GONE
val placeholderDrawable = UserAvatarHelper.getTextDrawable(username, rocketChatAvatarWidget.context)
if (message.avatar != null) {
// Load user's avatar image from Oauth provider URI.
......@@ -32,7 +30,6 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) {
}
} else {
rocketChatAvatarWidget.visibility = View.GONE
userNotFoundAvatarImageView.visibility = View.VISIBLE
}
}
......@@ -40,17 +37,19 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) {
* Show username in textView.
*/
fun showUsername(usernameTextView: TextView, subUsernameTextView: TextView?) {
val username: String? = message.user?.username
if (username != null) {
if (message.alias == null) {
usernameTextView.text = message.user?.username ?: usernameTextView.context.getText(R.string.user_not_found)
usernameTextView.text = username
} else {
usernameTextView.text = message.alias
val username: String? = message.user?.username
if (username != null && subUsernameTextView != null) {
if (subUsernameTextView != null) {
subUsernameTextView.text = subUsernameTextView.context.getString(R.string.sub_username, username)
subUsernameTextView.visibility = View.VISIBLE
}
}
}
}
/**
* Show timestamp or message state in textView.
......
......@@ -3,7 +3,6 @@ package chat.rocket.android.renderer
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import chat.rocket.android.R
import chat.rocket.android.widget.RocketChatAvatar
import chat.rocket.android.widget.helper.UserAvatarHelper
import chat.rocket.core.models.User
......@@ -26,7 +25,10 @@ class UserRenderer(val user: User) {
* Show username in textView.
*/
fun showUsername(textView: TextView) {
textView.text = user.username ?: textView.context.getText(R.string.user_not_found)
val username: String? = user.username
if (username != null) {
textView.text = username
}
}
/**
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M-0,0L24,0L24,24L-0,24L-0,0ZM11.963,17.661L12.036,17.661L17.162,17.661C17.162,13.975 13.979,13.915 13.178,12.982L13.082,12.474C14.095,11.946 14.807,10.699 14.807,9.245C14.807,7.313 13.55,5.746 12,5.746C10.45,5.746 9.193,7.313 9.193,9.245C9.193,10.712 9.917,11.966 10.944,12.486L10.86,12.933C10.129,13.913 6.837,13.912 6.837,17.661L11.963,17.661Z"
android:fillColor="#FF000000"/>
</vector>
\ No newline at end of file
......@@ -20,14 +20,6 @@
android:layout_height="32dp"
android:layout_margin="8dp" />
<ImageView
android:id="@+id/userNotFoundAvatarImageView"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="8dp"
app:srcCompat="@drawable/ic_user_not_found_avatar_black_24dp"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
......@@ -19,14 +19,6 @@
android:layout_height="32dp"
android:layout_margin="8dp" />
<ImageView
android:id="@+id/userNotFoundAvatarImageView"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="8dp"
app:srcCompat="@drawable/ic_user_not_found_avatar_black_24dp"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
......@@ -35,7 +35,6 @@
<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>
<string name="fragment_input_hostname_hostname">Hostname</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