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
befbfb25
Commit
befbfb25
authored
Aug 30, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename UserAvatarHelper to AvatarHelper since it's also being used for the server avatar
parent
ac4f99d5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
41 deletions
+39
-41
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+2
-2
MessageRenderer.kt
...main/java/chat/rocket/android/renderer/MessageRenderer.kt
+3
-3
UserRenderer.kt
...rc/main/java/chat/rocket/android/renderer/UserRenderer.kt
+2
-2
AvatarHelper.kt
...in/java/chat/rocket/android/widget/helper/AvatarHelper.kt
+1
-1
UserViewHolder.java
...roid/widget/message/autocomplete/user/UserViewHolder.java
+4
-6
AvatarHelperTest.kt
...lin/chat/rocket/android/widget/helper/AvatarHelperTest.kt
+27
-0
UserAvatarHelperTest.kt
...chat/rocket/android/widget/helper/UserAvatarHelperTest.kt
+0
-27
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
befbfb25
...
...
@@ -24,7 +24,7 @@ import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
import
chat.rocket.android.helper.KeyboardHelper
;
import
chat.rocket.android.service.ConnectivityManager
;
import
chat.rocket.android.widget.RoomToolbar
;
import
chat.rocket.android.widget.helper.
User
AvatarHelper
;
import
chat.rocket.android.widget.helper.AvatarHelper
;
import
chat.rocket.core.interactors.CanCreateRoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.SessionInteractor
;
...
...
@@ -190,7 +190,7 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
serverButton
.
setOnClickListener
(
view
->
changeServerIfNeeded
(
serverHostname
));
Drawable
drawable
=
User
AvatarHelper
.
INSTANCE
.
getTextDrawable
(
serverHostname
,
this
);
Drawable
drawable
=
AvatarHelper
.
INSTANCE
.
getTextDrawable
(
serverHostname
,
this
);
serverButton
.
getHierarchy
().
setPlaceholderImage
(
drawable
);
serverButton
.
setController
(
Fresco
.
newDraweeControllerBuilder
().
setAutoPlayAnimations
(
true
).
build
());
...
...
app/src/main/java/chat/rocket/android/renderer/MessageRenderer.kt
View file @
befbfb25
...
...
@@ -6,7 +6,7 @@ import chat.rocket.android.R
import
chat.rocket.android.helper.DateTime
import
chat.rocket.android.widget.AbsoluteUrl
import
chat.rocket.android.widget.RocketChatAvatar
import
chat.rocket.android.widget.helper.
User
AvatarHelper
import
chat.rocket.android.widget.helper.AvatarHelper
import
chat.rocket.android.widget.message.RocketChatMessageAttachmentsLayout
import
chat.rocket.android.widget.message.RocketChatMessageLayout
import
chat.rocket.android.widget.message.RocketChatMessageUrlsLayout
...
...
@@ -21,12 +21,12 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) {
fun
showAvatar
(
rocketChatAvatarWidget
:
RocketChatAvatar
,
hostname
:
String
)
{
val
username
:
String
?
=
message
.
user
?.
username
if
(
username
!=
null
)
{
val
placeholderDrawable
=
User
AvatarHelper
.
getTextDrawable
(
username
,
rocketChatAvatarWidget
.
context
)
val
placeholderDrawable
=
AvatarHelper
.
getTextDrawable
(
username
,
rocketChatAvatarWidget
.
context
)
if
(
message
.
avatar
!=
null
)
{
// Load user's avatar image from Oauth provider URI.
rocketChatAvatarWidget
.
loadImage
(
message
.
avatar
,
placeholderDrawable
)
}
else
{
rocketChatAvatarWidget
.
loadImage
(
User
AvatarHelper
.
getUri
(
hostname
,
username
),
placeholderDrawable
)
rocketChatAvatarWidget
.
loadImage
(
AvatarHelper
.
getUri
(
hostname
,
username
),
placeholderDrawable
)
}
}
else
{
rocketChatAvatarWidget
.
visibility
=
View
.
GONE
...
...
app/src/main/java/chat/rocket/android/renderer/UserRenderer.kt
View file @
befbfb25
...
...
@@ -4,7 +4,7 @@ import android.view.View
import
android.widget.ImageView
import
android.widget.TextView
import
chat.rocket.android.widget.RocketChatAvatar
import
chat.rocket.android.widget.helper.
User
AvatarHelper
import
chat.rocket.android.widget.helper.AvatarHelper
import
chat.rocket.core.models.User
class
UserRenderer
(
val
user
:
User
)
{
...
...
@@ -15,7 +15,7 @@ class UserRenderer(val user: User) {
fun
showAvatar
(
rocketChatAvatarWidget
:
RocketChatAvatar
,
hostname
:
String
)
{
val
username
:
String
?
=
user
.
username
if
(
username
!=
null
)
{
rocketChatAvatarWidget
.
loadImage
(
UserAvatarHelper
.
getUri
(
hostname
,
username
),
User
AvatarHelper
.
getTextDrawable
(
username
,
rocketChatAvatarWidget
.
context
))
rocketChatAvatarWidget
.
loadImage
(
AvatarHelper
.
getUri
(
hostname
,
username
),
AvatarHelper
.
getTextDrawable
(
username
,
rocketChatAvatarWidget
.
context
))
}
else
{
rocketChatAvatarWidget
.
visibility
=
View
.
GONE
}
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/helper/
User
AvatarHelper.kt
→
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/helper/AvatarHelper.kt
View file @
befbfb25
...
...
@@ -7,7 +7,7 @@ import chat.rocket.android.widget.AbsoluteUrl
import
com.amulyakhare.textdrawable.TextDrawable
import
java.net.URLEncoder
object
User
AvatarHelper
{
object
AvatarHelper
{
/**
* Returns the user avatar URI.
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/autocomplete/user/UserViewHolder.java
View file @
befbfb25
...
...
@@ -4,13 +4,11 @@ import android.graphics.drawable.Drawable;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
chat.rocket.android.widget.AbsoluteUrl
;
import
chat.rocket.android.widget.R
;
import
chat.rocket.android.widget.RocketChatAvatar
;
import
chat.rocket.android.widget.helper.
User
AvatarHelper
;
import
chat.rocket.android.widget.helper.AvatarHelper
;
import
chat.rocket.android.widget.message.autocomplete.AutocompleteViewHolder
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
public
class
UserViewHolder
extends
AutocompleteViewHolder
<
UserItem
>
{
private
final
TextView
titleTextView
;
...
...
@@ -45,8 +43,8 @@ public class UserViewHolder extends AutocompleteViewHolder<UserItem> {
}
if
(
avatar
!=
null
)
{
String
absoluteUri
=
User
AvatarHelper
.
INSTANCE
.
getAbsoluteUri
(
userItem
.
getAbsoluteUrl
(),
suggestion
);
Drawable
placeholderDrawable
=
User
AvatarHelper
.
INSTANCE
.
getTextDrawable
(
suggestion
,
itemView
.
getContext
());
String
absoluteUri
=
AvatarHelper
.
INSTANCE
.
getAbsoluteUri
(
userItem
.
getAbsoluteUrl
(),
suggestion
);
Drawable
placeholderDrawable
=
AvatarHelper
.
INSTANCE
.
getTextDrawable
(
suggestion
,
itemView
.
getContext
());
avatar
.
loadImage
(
absoluteUri
,
placeholderDrawable
);
}
...
...
rocket-chat-android-widgets/src/test/kotlin/chat/rocket/android/widget/helper/AvatarHelperTest.kt
0 → 100644
View file @
befbfb25
import
chat.rocket.android.widget.helper.AvatarHelper
import
org.junit.Test
import
kotlin.test.assertEquals
class
AvatarHelperTest
{
@Test
fun
getUsernameInitialsTest
()
{
assertEquals
(
"?"
,
AvatarHelper
.
getUsernameInitials
(
""
))
assertEquals
(
"?"
,
AvatarHelper
.
getUsernameInitials
(
"?"
))
assertEquals
(
"F"
,
AvatarHelper
.
getUsernameInitials
(
"f"
))
assertEquals
(
"B"
,
AvatarHelper
.
getUsernameInitials
(
"B"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"Fo"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"FO"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"fOo"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"FOO"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"F.O"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"F.o"
))
assertEquals
(
"FB"
,
AvatarHelper
.
getUsernameInitials
(
"Foo.bar"
))
assertEquals
(
"FB"
,
AvatarHelper
.
getUsernameInitials
(
"Foobar.bar"
))
assertEquals
(
"FZ"
,
AvatarHelper
.
getUsernameInitials
(
"Foobar.bar.zab"
))
assertEquals
(
".."
,
AvatarHelper
.
getUsernameInitials
(
".."
))
assertEquals
(
".."
,
AvatarHelper
.
getUsernameInitials
(
"..."
))
assertEquals
(
".F"
,
AvatarHelper
.
getUsernameInitials
(
".Foo."
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"Foo.."
))
}
}
\ No newline at end of file
rocket-chat-android-widgets/src/test/kotlin/chat/rocket/android/widget/helper/UserAvatarHelperTest.kt
deleted
100644 → 0
View file @
ac4f99d5
import
chat.rocket.android.widget.helper.UserAvatarHelper
import
org.junit.Test
import
kotlin.test.assertEquals
class
UserAvatarHelperTest
{
@Test
fun
getUsernameInitialsTest
()
{
assertEquals
(
"?"
,
UserAvatarHelper
.
getUsernameInitials
(
""
))
assertEquals
(
"?"
,
UserAvatarHelper
.
getUsernameInitials
(
"?"
))
assertEquals
(
"F"
,
UserAvatarHelper
.
getUsernameInitials
(
"f"
))
assertEquals
(
"B"
,
UserAvatarHelper
.
getUsernameInitials
(
"B"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"Fo"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"FO"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"fOo"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"FOO"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"F.O"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"F.o"
))
assertEquals
(
"FB"
,
UserAvatarHelper
.
getUsernameInitials
(
"Foo.bar"
))
assertEquals
(
"FB"
,
UserAvatarHelper
.
getUsernameInitials
(
"Foobar.bar"
))
assertEquals
(
"FZ"
,
UserAvatarHelper
.
getUsernameInitials
(
"Foobar.bar.zab"
))
assertEquals
(
".."
,
UserAvatarHelper
.
getUsernameInitials
(
".."
))
assertEquals
(
".."
,
UserAvatarHelper
.
getUsernameInitials
(
"..."
))
assertEquals
(
".F"
,
UserAvatarHelper
.
getUsernameInitials
(
".Foo."
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"Foo.."
))
}
}
\ No newline at end of file
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