Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
7d58b105
Commit
7d58b105
authored
Aug 04, 2017
by
Lucio Maciel
Committed by
GitHub
Aug 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #377 from filipedelimabrito/avatar-with-username-initials
Remove user not found handling.
parents
8ac51b53
d6b188cc
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
174 additions
and
201 deletions
+174
-201
AbstractMessageViewHolder.java
...roid/layouthelper/chatroom/AbstractMessageViewHolder.java
+0
-2
MessageNormalViewHolder.java
...ndroid/layouthelper/chatroom/MessageNormalViewHolder.java
+1
-1
MessageSystemViewHolder.java
...ndroid/layouthelper/chatroom/MessageSystemViewHolder.java
+1
-1
MessageRenderer.kt
...main/java/chat/rocket/android/renderer/MessageRenderer.kt
+11
-12
UserRenderer.kt
...rc/main/java/chat/rocket/android/renderer/UserRenderer.kt
+4
-2
ic_user_not_found_avatar_black_24dp.xml
...main/res/drawable/ic_user_not_found_avatar_black_24dp.xml
+0
-9
list_item_normal_message.xml
app/src/main/res/layout/list_item_normal_message.xml
+91
-99
list_item_system_message.xml
app/src/main/res/layout/list_item_system_message.xml
+66
-74
strings.xml
app/src/main/res/values/strings.xml
+0
-1
No files found.
app/src/main/java/chat/rocket/android/layouthelper/chatroom/AbstractMessageViewHolder.java
View file @
7d58b105
...
...
@@ -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
);
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessageNormalViewHolder.java
View file @
7d58b105
...
...
@@ -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
);
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessageSystemViewHolder.java
View file @
7d58b105
...
...
@@ -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
)
{
...
...
app/src/main/java/chat/rocket/android/renderer/MessageRenderer.kt
View file @
7d58b105
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,14 +37,16 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) {
* Show username in textView.
*/
fun
showUsername
(
usernameTextView
:
TextView
,
subUsernameTextView
:
TextView
?)
{
if
(
message
.
alias
==
null
)
{
usernameTextView
.
text
=
message
.
user
?.
username
?:
usernameTextView
.
context
.
getText
(
R
.
string
.
user_not_found
)
}
else
{
usernameTextView
.
text
=
message
.
alias
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
val
username
:
String
?
=
message
.
user
?.
username
if
(
username
!=
null
)
{
if
(
message
.
alias
==
null
)
{
usernameTextView
.
text
=
username
}
else
{
usernameTextView
.
text
=
message
.
alias
if
(
subUsernameTextView
!=
null
)
{
subUsernameTextView
.
text
=
subUsernameTextView
.
context
.
getString
(
R
.
string
.
sub_username
,
username
)
subUsernameTextView
.
visibility
=
View
.
VISIBLE
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/renderer/UserRenderer.kt
View file @
7d58b105
...
...
@@ -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
}
}
/**
...
...
app/src/main/res/drawable/ic_user_not_found_avatar_black_24dp.xml
deleted
100644 → 0
View file @
8ac51b53
<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
app/src/main/res/layout/list_item_normal_message.xml
View file @
7d58b105
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:theme=
"@style/AppTheme"
>
<include
layout=
"@layout/list_item_message_newday"
/>
<FrameLayout
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"2dp"
>
<chat.rocket.android.widget.RocketChatAvatar
android:id=
"@+id/user_avatar"
android:layout_width=
"32dp"
android:layout_height=
"32dp"
android:layout_margin=
"8dp"
/>
android:orientation=
"vertical"
android:theme=
"@style/AppTheme"
>
<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"
/>
<include
layout=
"@layout/list_item_message_newday"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"8dp"
android:layout_marginStart=
"48dp"
android:orientation=
"vertical"
android:layout_marginRight=
"8dp"
android:layout_marginLeft=
"48dp"
>
<LinearLayout
android:id=
"@+id/user_and_timestamp_container"
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/username"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"@style/TextAppearance.RocketChat.Message.Username"
tools:text=
"John Doe"
/>
<Space
android:layout_width=
"4dp"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/sub_username"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"@style/TextAppearance.RocketChat.Message.SubUsername"
tools:text=
"\@John Doe"
android:visibility=
"gone"
/>
<Space
android:layout_width=
"@dimen/margin_8"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/timestamp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:enabled=
"false"
tools:text=
"12:34"
/>
<View
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_weight=
"1"
/>
<ImageView
android:id=
"@+id/errorImageView"
android:layout_width=
"wrap_content"
android:layout_height=
"16dp"
android:layout_gravity=
"end"
android:gravity=
"end"
android:tint=
"@color/colorRed400"
app:srcCompat=
"@drawable/ic_error_black_24dp"
android:visibility=
"gone"
/>
</LinearLayout>
<chat.rocket.android.widget.message.RocketChatMessageLayout
android:id=
"@+id/message_body"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<chat.rocket.android.widget.message.RocketChatMessageUrlsLayout
android:id=
"@+id/message_urls"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<chat.rocket.android.widget.message.RocketChatMessageAttachmentsLayout
android:id=
"@+id/message_attachments"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
</FrameLayout>
android:layout_marginBottom=
"2dp"
>
<chat.rocket.android.widget.RocketChatAvatar
android:id=
"@+id/user_avatar"
android:layout_width=
"32dp"
android:layout_height=
"32dp"
android:layout_margin=
"8dp"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"8dp"
android:layout_marginStart=
"48dp"
android:orientation=
"vertical"
android:layout_marginRight=
"8dp"
android:layout_marginLeft=
"48dp"
>
<LinearLayout
android:id=
"@+id/user_and_timestamp_container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/username"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"@style/TextAppearance.RocketChat.Message.Username"
tools:text=
"John Doe"
/>
<Space
android:layout_width=
"4dp"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/sub_username"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"@style/TextAppearance.RocketChat.Message.SubUsername"
tools:text=
"\@John Doe"
android:visibility=
"gone"
/>
<Space
android:layout_width=
"@dimen/margin_8"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/timestamp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:enabled=
"false"
tools:text=
"12:34"
/>
<View
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_weight=
"1"
/>
<ImageView
android:id=
"@+id/errorImageView"
android:layout_width=
"wrap_content"
android:layout_height=
"16dp"
android:layout_gravity=
"end"
android:gravity=
"end"
android:tint=
"@color/colorRed400"
app:srcCompat=
"@drawable/ic_error_black_24dp"
android:visibility=
"gone"
/>
</LinearLayout>
<chat.rocket.android.widget.message.RocketChatMessageLayout
android:id=
"@+id/message_body"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<chat.rocket.android.widget.message.RocketChatMessageUrlsLayout
android:id=
"@+id/message_urls"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<chat.rocket.android.widget.message.RocketChatMessageAttachmentsLayout
android:id=
"@+id/message_attachments"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/list_item_system_message.xml
View file @
7d58b105
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:theme=
"@style/AppTheme"
>
<include
layout=
"@layout/list_item_message_newday"
/>
<FrameLayout
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:theme=
"@style/AppTheme"
>
<include
layout=
"@layout/list_item_message_newday"
/>
<chat.rocket.android.widget.RocketChatAvatar
android:id=
"@+id/user_avatar"
android:layout_width=
"32dp"
android:layout_height=
"32dp"
android:layout_margin=
"8dp"
/>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<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"
/>
<chat.rocket.android.widget.RocketChatAvatar
android:id=
"@+id/user_avatar"
android:layout_width=
"32dp"
android:layout_height=
"32dp"
android:layout_margin=
"8dp"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"8dp"
android:layout_marginStart=
"48dp"
android:orientation=
"vertical"
android:layout_marginRight=
"8dp"
android:layout_marginLeft=
"48dp"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"8dp"
android:layout_marginStart=
"48dp"
android:orientation=
"vertical"
android:layout_marginRight=
"8dp"
android:layout_marginLeft=
"48dp"
>
<LinearLayout
android:id=
"@+id/user_and_timestamp_container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<LinearLayout
android:id=
"@+id/user_and_timestamp_container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/username"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"@style/TextAppearance.RocketChat.Message.Username"
tools:text=
"John Doe"
/>
<TextView
android:id=
"@+id/username"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"@style/TextAppearance.RocketChat.Message.Username"
tools:text=
"John Doe"
/>
<Space
android:layout_width=
"@dimen/margin_8"
android:layout_height=
"wrap_content"
/>
<Space
android:layout_width=
"@dimen/margin_8"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/timestamp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:enabled=
"false"
tools:text=
"12:34"
/>
<TextView
android:id=
"@+id/timestamp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:enabled=
"false"
tools:text=
"12:34"
/>
<View
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_weight=
"1"
/>
<View
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_weight=
"1"
/>
<ImageView
android:id=
"@+id/errorImageView"
android:layout_width=
"wrap_content"
android:layout_height=
"16dp"
android:layout_gravity=
"end"
android:gravity=
"end"
android:tint=
"@color/colorRed400"
app:srcCompat=
"@drawable/ic_error_black_24dp"
android:visibility=
"gone"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/errorImageView"
android:layout_width=
"wrap_content"
android:layout_height=
"16dp"
android:layout_gravity=
"end"
android:gravity=
"end"
android:tint=
"@color/colorRed400"
app:srcCompat=
"@drawable/ic_error_black_24dp"
android:visibility=
"gone"
/>
</LinearLayout>
<TextView
android:id=
"@+id/message_body"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textStyle=
"italic"
android:enabled=
"false"
/>
</LinearLayout>
</FrameLayout>
<TextView
android:id=
"@+id/message_body"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textStyle=
"italic"
android:enabled=
"false"
/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
7d58b105
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment