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
b235eb16
Commit
b235eb16
authored
Jul 17, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update some classes
parent
0595999e
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
67 additions
and
142 deletions
+67
-142
Avatar.java
app/src/main/java/chat/rocket/android/helper/Avatar.java
+5
-13
AbstractMessageViewHolder.java
...roid/layouthelper/chatroom/AbstractMessageViewHolder.java
+9
-11
RoomUserAdapter.java
...android/layouthelper/chatroom/dialog/RoomUserAdapter.java
+2
-2
SuggestUserAdapter.java
...droid/layouthelper/sidebar/dialog/SuggestUserAdapter.java
+1
-1
MessageRenderer.java
...in/java/chat/rocket/android/renderer/MessageRenderer.java
+25
-44
UserRenderer.java
.../main/java/chat/rocket/android/renderer/UserRenderer.java
+3
-16
RocketChatAvatar.java
...ain/java/chat/rocket/android/widget/RocketChatAvatar.java
+11
-32
RocketChatWidgets.java
...in/java/chat/rocket/android/widget/RocketChatWidgets.java
+4
-8
FrescoHelper.java
.../java/chat/rocket/android/widget/helper/FrescoHelper.java
+3
-5
UserViewHolder.java
...roid/widget/message/autocomplete/user/UserViewHolder.java
+4
-10
No files found.
app/src/main/java/chat/rocket/android/helper/Avatar.java
View file @
b235eb16
...
...
@@ -6,8 +6,6 @@ import android.graphics.Canvas;
import
android.graphics.Typeface
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.support.graphics.drawable.VectorDrawableCompat
;
import
chat.rocket.android.R
;
import
chat.rocket.android.log.RCLog
;
import
chat.rocket.android.widget.AbsoluteUrl
;
import
chat.rocket.android.widget.RocketChatAvatar
;
...
...
@@ -87,17 +85,11 @@ public class Avatar {
/**
* render avatar into RocketChatAvatar.
*/
public
void
into
(
final
RocketChatAvatar
rocketChatAvatar
)
{
final
Context
context
=
rocketChatAvatar
.
getContext
();
rocketChatAvatar
.
loadImage
(
getImageUrl
(),
getTextDrawable
(
context
));
}
/**
* render error avatar into RocketChatAvatar.
*/
public
void
errorInto
(
final
RocketChatAvatar
rocketChatAvatar
)
{
final
Context
context
=
rocketChatAvatar
.
getContext
();
rocketChatAvatar
.
loadImage
(
VectorDrawableCompat
.
create
(
context
.
getResources
(),
R
.
drawable
.
ic_error_outline_black_24dp
,
null
));
public
void
into
(
final
RocketChatAvatar
rocketChatAvatar
,
boolean
showFailureImage
)
{
if
(
showFailureImage
)
rocketChatAvatar
.
showFailureImage
();
else
rocketChatAvatar
.
loadImage
(
getImageUrl
());
}
public
Drawable
getTextDrawable
(
Context
context
)
{
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/AbstractMessageViewHolder.java
View file @
b235eb16
...
...
@@ -25,13 +25,13 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe
*/
public
AbstractMessageViewHolder
(
View
itemView
,
AbsoluteUrl
absoluteUrl
)
{
super
(
itemView
);
avatar
=
(
RocketChatAvatar
)
itemView
.
findViewById
(
R
.
id
.
user_avatar
);
username
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
username
);
subUsername
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
sub_username
);
timestamp
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
timestamp
);
avatar
=
itemView
.
findViewById
(
R
.
id
.
user_avatar
);
username
=
itemView
.
findViewById
(
R
.
id
.
username
);
subUsername
=
itemView
.
findViewById
(
R
.
id
.
sub_username
);
timestamp
=
itemView
.
findViewById
(
R
.
id
.
timestamp
);
userAndTimeContainer
=
itemView
.
findViewById
(
R
.
id
.
user_and_timestamp_container
);
newDayContainer
=
itemView
.
findViewById
(
R
.
id
.
newday_container
);
newDayText
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
newday_text
);
newDayText
=
itemView
.
findViewById
(
R
.
id
.
newday_text
);
this
.
absoluteUrl
=
absoluteUrl
;
}
...
...
@@ -39,12 +39,10 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe
* bind the view model.
*/
public
final
void
bind
(
PairedMessage
pairedMessage
,
boolean
autoloadImages
)
{
if
(
pairedMessage
.
target
!=
null
)
{
if
(
pairedMessage
.
target
.
getSyncState
()
!=
SyncState
.
SYNCED
)
itemView
.
setAlpha
(
0.6f
);
else
itemView
.
setAlpha
(
1.0f
);
}
bindMessage
(
pairedMessage
,
autoloadImages
);
renderNewDayAndSequential
(
pairedMessage
);
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/dialog/RoomUserAdapter.java
View file @
b235eb16
...
...
@@ -58,12 +58,12 @@ public class RoomUserAdapter extends RecyclerView.Adapter<RoomUserViewHolder> {
.
setUtcOffset
(
0
)
.
build
();
new
UserRenderer
(
context
,
user
)
.
avatarInto
(
holder
.
avatar
,
absoluteUrl
)
.
avatarInto
(
holder
.
avatar
,
absoluteUrl
,
false
)
.
usernameInto
(
holder
.
username
);
}
else
{
new
UserRenderer
(
context
,
realmUser
.
asUser
())
.
statusColorInto
(
holder
.
status
)
.
avatarInto
(
holder
.
avatar
,
absoluteUrl
)
.
avatarInto
(
holder
.
avatar
,
absoluteUrl
,
false
)
.
usernameInto
(
holder
.
username
);
}
}
...
...
app/src/main/java/chat/rocket/android/layouthelper/sidebar/dialog/SuggestUserAdapter.java
View file @
b235eb16
...
...
@@ -28,7 +28,7 @@ public class SuggestUserAdapter extends RealmAutoCompleteAdapter<RealmUser> {
protected
void
onBindItemView
(
View
itemView
,
RealmUser
user
)
{
new
UserRenderer
(
itemView
.
getContext
(),
user
.
asUser
())
.
statusColorInto
((
ImageView
)
itemView
.
findViewById
(
R
.
id
.
room_user_status
))
.
avatarInto
((
RocketChatAvatar
)
itemView
.
findViewById
(
R
.
id
.
room_user_avatar
),
absoluteUrl
);
.
avatarInto
((
RocketChatAvatar
)
itemView
.
findViewById
(
R
.
id
.
room_user_avatar
),
absoluteUrl
,
false
);
}
@Override
...
...
app/src/main/java/chat/rocket/android/renderer/MessageRenderer.java
View file @
b235eb16
...
...
@@ -4,7 +4,6 @@ import android.content.Context;
import
android.view.View
;
import
android.widget.TextView
;
import
chat.rocket.android.R
;
import
chat.rocket.android.helper.Avatar
;
import
chat.rocket.android.helper.DateTime
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.widget.AbsoluteUrl
;
...
...
@@ -15,7 +14,6 @@ import chat.rocket.android.widget.message.RocketChatMessageUrlsLayout;
import
chat.rocket.core.SyncState
;
import
chat.rocket.core.models.Attachment
;
import
chat.rocket.core.models.Message
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.models.WebContent
;
import
java.util.List
;
...
...
@@ -37,20 +35,20 @@ public class MessageRenderer extends AbstractRenderer<Message> {
* show Avatar image.
*/
public
MessageRenderer
avatarInto
(
RocketChatAvatar
rocketChatAvatar
,
AbsoluteUrl
absoluteUrl
)
{
if
(!
shouldHandle
(
rocketChatAvatar
))
{
if
(!
shouldHandle
(
rocketChatAvatar
))
return
this
;
}
if
(
object
.
getSyncState
()
==
SyncState
.
FAILED
)
// rocketChatAvatar.loadImage(VectorDrawableCompat.create(context.getResources(), R.drawable.ic_error_outline_black_24dp, null));
userRenderer
.
errorAvatarInto
(
rocketChatAvatar
);
else
if
(
TextUtils
.
isEmpty
(
object
.
getAvatar
()))
userRenderer
.
avatarInto
(
rocketChatAvatar
,
absoluteUrl
);
else
{
final
User
user
=
object
.
getUser
();
setAvatarInto
(
object
.
getAvatar
(),
absoluteUrl
,
user
==
null
?
null
:
user
.
getUsername
(),
rocketChatAvatar
);
switch
(
object
.
getSyncState
()){
case
SyncState
.
FAILED
:
userRenderer
.
avatarInto
(
rocketChatAvatar
,
absoluteUrl
,
true
);
break
;
default
:
if
(
TextUtils
.
isEmpty
(
object
.
getAvatar
()))
userRenderer
.
avatarInto
(
rocketChatAvatar
,
absoluteUrl
,
false
);
else
rocketChatAvatar
.
loadImage
(
object
.
getAvatar
());
break
;
}
return
this
;
}
...
...
@@ -60,12 +58,10 @@ public class MessageRenderer extends AbstractRenderer<Message> {
public
MessageRenderer
usernameInto
(
TextView
usernameTextView
,
TextView
subUsernameTextView
)
{
if
(
TextUtils
.
isEmpty
(
object
.
getAlias
()))
{
userRenderer
.
usernameInto
(
usernameTextView
);
if
(
subUsernameTextView
!=
null
)
{
if
(
subUsernameTextView
!=
null
)
subUsernameTextView
.
setVisibility
(
View
.
GONE
);
}
}
else
{
}
else
aliasAndUsernameInto
(
usernameTextView
,
subUsernameTextView
);
}
return
this
;
}
...
...
@@ -73,9 +69,8 @@ public class MessageRenderer extends AbstractRenderer<Message> {
* show timestamp in textView.
*/
public
MessageRenderer
timestampInto
(
TextView
textView
)
{
if
(!
shouldHandle
(
textView
))
{
if
(!
shouldHandle
(
textView
))
return
this
;
}
switch
(
object
.
getSyncState
())
{
case
SyncState
.
SYNCING
:
...
...
@@ -91,7 +86,6 @@ public class MessageRenderer extends AbstractRenderer<Message> {
textView
.
setText
(
DateTime
.
fromEpocMs
(
object
.
getTimestamp
(),
DateTime
.
Format
.
TIME
));
break
;
}
return
this
;
}
...
...
@@ -99,12 +93,10 @@ public class MessageRenderer extends AbstractRenderer<Message> {
* show body in RocketChatMessageLayout.
*/
public
MessageRenderer
bodyInto
(
RocketChatMessageLayout
rocketChatMessageLayout
)
{
if
(!
shouldHandle
(
rocketChatMessageLayout
))
{
if
(!
shouldHandle
(
rocketChatMessageLayout
))
return
this
;
}
rocketChatMessageLayout
.
setText
(
object
.
getMessage
());
return
this
;
}
...
...
@@ -112,59 +104,48 @@ public class MessageRenderer extends AbstractRenderer<Message> {
* show urls in RocketChatMessageUrlsLayout.
*/
public
MessageRenderer
urlsInto
(
RocketChatMessageUrlsLayout
urlsLayout
)
{
if
(!
shouldHandle
(
urlsLayout
))
{
if
(!
shouldHandle
(
urlsLayout
))
return
this
;
}
List
<
WebContent
>
webContents
=
object
.
getWebContents
();
if
(
webContents
==
null
||
webContents
.
size
()
==
0
)
{
if
(
webContents
==
null
||
webContents
.
size
()
==
0
)
urlsLayout
.
setVisibility
(
View
.
GONE
);
}
else
{
else
{
urlsLayout
.
setVisibility
(
View
.
VISIBLE
);
urlsLayout
.
setUrls
(
webContents
,
autoloadImages
);
}
return
this
;
}
/**
* show urls in RocketChatMessageUrlsLayout.
*/
public
MessageRenderer
attachmentsInto
(
RocketChatMessageAttachmentsLayout
attachmentsLayout
,
AbsoluteUrl
absoluteUrl
)
{
if
(!
shouldHandle
(
attachmentsLayout
))
{
public
MessageRenderer
attachmentsInto
(
RocketChatMessageAttachmentsLayout
attachmentsLayout
,
AbsoluteUrl
absoluteUrl
)
{
if
(!
shouldHandle
(
attachmentsLayout
))
return
this
;
}
List
<
Attachment
>
attachments
=
object
.
getAttachments
();
if
(
attachments
==
null
||
attachments
.
size
()
==
0
)
{
if
(
attachments
==
null
||
attachments
.
size
()
==
0
)
attachmentsLayout
.
setVisibility
(
View
.
GONE
);
}
else
{
else
{
attachmentsLayout
.
setVisibility
(
View
.
VISIBLE
);
attachmentsLayout
.
setAbsoluteUrl
(
absoluteUrl
);
attachmentsLayout
.
setAttachments
(
attachments
,
autoloadImages
);
}
return
this
;
}
private
void
setAvatarInto
(
String
avatar
,
AbsoluteUrl
absoluteUrl
,
String
username
,
RocketChatAvatar
imageView
)
{
imageView
.
loadImage
(
avatar
,
new
Avatar
(
absoluteUrl
,
username
).
getTextDrawable
(
context
));
}
private
void
aliasAndUsernameInto
(
TextView
aliasTextView
,
TextView
usernameTextView
)
{
if
(
shouldHandle
(
aliasTextView
))
{
if
(
shouldHandle
(
aliasTextView
))
aliasTextView
.
setText
(
object
.
getAlias
());
}
if
(
shouldHandle
(
usernameTextView
))
{
if
(
object
.
getUser
()
!=
null
)
{
usernameTextView
.
setText
(
"@"
+
object
.
getUser
().
getUsername
());
usernameTextView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
}
else
usernameTextView
.
setVisibility
(
View
.
GONE
);
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/renderer/UserRenderer.java
View file @
b235eb16
...
...
@@ -21,27 +21,14 @@ public class UserRenderer extends AbstractRenderer<User> {
/**
* show Avatar image
*/
public
UserRenderer
avatarInto
(
RocketChatAvatar
rocketChatAvatar
,
AbsoluteUrl
absoluteUrl
)
{
public
UserRenderer
avatarInto
(
RocketChatAvatar
rocketChatAvatar
,
AbsoluteUrl
absoluteUrl
,
boolean
showFailureImage
)
{
if
(!
shouldHandle
(
rocketChatAvatar
))
{
return
this
;
}
if
(!
TextUtils
.
isEmpty
(
object
.
getUsername
()))
{
new
Avatar
(
absoluteUrl
,
object
.
getUsername
()).
into
(
rocketChatAvatar
);
}
return
this
;
}
/**
* show Avatar error image
*/
public
UserRenderer
errorAvatarInto
(
RocketChatAvatar
rocketChatAvatar
)
{
if
(!
shouldHandle
(
rocketChatAvatar
))
{
return
this
;
}
if
(!
TextUtils
.
isEmpty
(
object
.
getUsername
()))
{
new
Avatar
(
null
,
object
.
getUsername
()).
errorInto
(
rocketChatAvatar
);
new
Avatar
(
absoluteUrl
,
object
.
getUsername
())
.
into
(
rocketChatAvatar
,
showFailureImage
);
}
return
this
;
}
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/RocketChatAvatar.java
View file @
b235eb16
...
...
@@ -2,15 +2,11 @@ package chat.rocket.android.widget;
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.graphics.drawable.Drawable
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.util.AttributeSet
;
import
android.view.LayoutInflater
;
import
android.widget.FrameLayout
;
import
com.facebook.drawee.backends.pipeline.Fresco
;
import
com.facebook.drawee.generic.GenericDraweeHierarchy
;
import
com.facebook.drawee.interfaces.DraweeController
;
import
chat.rocket.android.widget.helper.FrescoAvatarHelper
;
import
com.facebook.drawee.view.SimpleDraweeView
;
public
class
RocketChatAvatar
extends
FrameLayout
{
...
...
@@ -39,36 +35,19 @@ public class RocketChatAvatar extends FrameLayout {
}
private
void
initialize
(
Context
context
,
AttributeSet
attrs
)
{
LayoutInflater
.
from
(
context
)
LayoutInflater
.
from
(
context
)
.
inflate
(
R
.
layout
.
message_avatar
,
this
,
true
);
draweeView
=
(
SimpleDraweeView
)
findViewById
(
R
.
id
.
drawee_avatar
);
draweeView
=
findViewById
(
R
.
id
.
drawee_avatar
);
}
public
void
loadImage
(
Drawable
drawable
)
{
// final GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
// hierarchy.setImage(drawable, 100, true); // Is there a better way?
final
GenericDraweeHierarchy
hierarchy
=
draweeView
.
getHierarchy
();
hierarchy
.
setPlaceholderImage
(
drawable
);
hierarchy
.
setFailureImage
(
drawable
);
final
DraweeController
controller
=
Fresco
.
newDraweeControllerBuilder
()
.
setAutoPlayAnimations
(
true
)
.
build
();
draweeView
.
setController
(
controller
);
public
void
loadImage
(
String
imageUrl
)
{
FrescoAvatarHelper
.
loadImage
(
draweeView
,
imageUrl
);
}
public
void
loadImage
(
String
url
,
Drawable
placeholder
)
{
final
GenericDraweeHierarchy
hierarchy
=
draweeView
.
getHierarchy
();
hierarchy
.
setPlaceholderImage
(
placeholder
);
hierarchy
.
setFailureImage
(
placeholder
);
final
DraweeController
controller
=
Fresco
.
newDraweeControllerBuilder
()
.
setUri
(
Uri
.
parse
(
url
))
.
setAutoPlayAnimations
(
true
)
.
build
();
draweeView
.
setController
(
controller
);
public
void
showFailureImage
()
{
FrescoAvatarHelper
.
showFailureImage
(
draweeView
);
}
}
\ No newline at end of file
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/RocketChatWidgets.java
View file @
b235eb16
package
chat
.
rocket
.
android
.
widget
;
import
android.content.Context
;
import
chat.rocket.android.widget.fresco.CustomImageFormatConfigurator
;
import
com.facebook.drawee.backends.pipeline.DraweeConfig
;
import
com.facebook.drawee.backends.pipeline.Fresco
;
import
com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory
;
import
com.facebook.imagepipeline.core.ImagePipelineConfig
;
import
chat.rocket.android.widget.fresco.ImageFormatConfigurator
;
import
okhttp3.OkHttpClient
;
public
class
RocketChatWidgets
{
...
...
@@ -16,14 +14,12 @@ public class RocketChatWidgets {
ImagePipelineConfig
config
=
OkHttpImagePipelineConfigFactory
.
newBuilder
(
context
,
okHttpClient
)
.
setDownsampleEnabled
(
true
)
.
setImageDecoderConfig
(
ImageFormatConfigurator
.
createImageDecoderConfig
())
.
setImageDecoderConfig
(
Custom
ImageFormatConfigurator
.
createImageDecoderConfig
())
.
build
();
DraweeConfig
.
Builder
draweeConfigBuilder
=
DraweeConfig
.
newBuilder
();
ImageFormatConfigurator
.
addCustomDrawableFactories
(
draweeConfigBuilder
);
Custom
ImageFormatConfigurator
.
addCustomDrawableFactories
(
draweeConfigBuilder
);
Fresco
.
initialize
(
context
,
config
,
draweeConfigBuilder
.
build
());
Fresco
.
getImagePipeline
().
clearCaches
();
}
}
\ No newline at end of file
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/helper/FrescoHelper.java
View file @
b235eb16
...
...
@@ -22,10 +22,8 @@ public class FrescoHelper {
public
static
void
setupDrawee
(
SimpleDraweeView
draweeView
)
{
final
GenericDraweeHierarchy
hierarchy
=
draweeView
.
getHierarchy
();
hierarchy
.
setPlaceholderImage
(
VectorDrawableCompat
.
create
(
draweeView
.
getResources
(),
R
.
drawable
.
image_dummy
,
null
));
hierarchy
.
setFailureImage
(
VectorDrawableCompat
.
create
(
draweeView
.
getResources
(),
R
.
drawable
.
image_error
,
null
));
hierarchy
.
setPlaceholderImage
(
VectorDrawableCompat
.
create
(
draweeView
.
getResources
(),
R
.
drawable
.
image_dummy
,
null
));
hierarchy
.
setFailureImage
(
VectorDrawableCompat
.
create
(
draweeView
.
getResources
(),
R
.
drawable
.
image_error
,
null
));
hierarchy
.
setProgressBarImage
(
new
ProgressBarDrawable
());
}
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/autocomplete/user/UserViewHolder.java
View file @
b235eb16
...
...
@@ -54,21 +54,15 @@ public class UserViewHolder extends AutocompleteViewHolder<UserItem> {
final
String
suggestion
=
userItem
.
getSuggestion
();
if
(
titleTextView
!=
null
)
{
if
(
titleTextView
!=
null
)
titleTextView
.
setText
(
suggestion
);
}
if
(
avatar
!=
null
)
{
avatar
.
loadImage
(
getImageUrl
(
suggestion
,
userItem
.
getAbsoluteUrl
()),
getTextDrawable
(
itemView
.
getContext
(),
suggestion
)
);
}
if
(
avatar
!=
null
)
avatar
.
loadImage
(
getImageUrl
(
suggestion
,
userItem
.
getAbsoluteUrl
()));
if
(
status
!=
null
)
{
if
(
status
!=
null
)
status
.
setImageResource
(
userItem
.
getStatusResId
());
}
}
@Override
public
void
showAsEmpty
()
{
...
...
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