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
66cbbad6
Commit
66cbbad6
authored
Sep 21, 2017
by
Rafael Kellermann Streit
Committed by
GitHub
Sep 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #472 from filipedelimabrito/develop
[FIX] User status changes when scrolling the sidebar
parents
29113cf6
cea1525e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
46 deletions
+34
-46
build.gradle
rocket-chat-android-widgets/build.gradle
+1
-0
DrawableHelper.kt
.../java/chat/rocket/android/widget/helper/DrawableHelper.kt
+8
-4
RoomListItemView.kt
...a/chat/rocket/android/widget/internal/RoomListItemView.kt
+21
-38
room_list_item.xml
...at-android-widgets/src/main/res/layout/room_list_item.xml
+4
-4
No files found.
rocket-chat-android-widgets/build.gradle
View file @
66cbbad6
apply
plugin:
'com.android.library'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android-extensions'
buildscript
{
repositories
{
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/helper/DrawableHelper.kt
View file @
66cbbad6
...
...
@@ -13,8 +13,10 @@ object DrawableHelper {
* @param drawable The drawable to wrap.
* @see tintDrawable
*/
fun
wrapDrawable
(
drawable
:
Drawable
)
{
DrawableCompat
.
wrap
(
drawable
)
fun
wrapDrawable
(
drawable
:
Drawable
?)
{
if
(
drawable
!=
null
)
{
DrawableCompat
.
wrap
(
drawable
)
}
}
/**
...
...
@@ -25,7 +27,9 @@ object DrawableHelper {
* @param resId The resource id color to tint the drawable.
* @see wrapDrawable
*/
fun
tintDrawable
(
drawable
:
Drawable
,
context
:
Context
,
resId
:
Int
)
{
DrawableCompat
.
setTint
(
drawable
,
ContextCompat
.
getColor
(
context
,
resId
))
fun
tintDrawable
(
drawable
:
Drawable
?,
context
:
Context
,
resId
:
Int
)
{
if
(
drawable
!=
null
)
{
DrawableCompat
.
setTint
(
drawable
,
ContextCompat
.
getColor
(
context
,
resId
))
}
}
}
\ No newline at end of file
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/internal/RoomListItemView.kt
View file @
66cbbad6
...
...
@@ -2,35 +2,28 @@ package chat.rocket.android.widget.internal
import
android.annotation.TargetApi
import
android.content.Context
import
android.content.res.TypedArray
import
android.graphics.drawable.Drawable
import
android.os.Build
import
android.support.annotation.ColorRes
import
android.support.annotation.StringRes
import
android.support.graphics.drawable.VectorDrawableCompat
import
android.util.AttributeSet
import
android.view.View
import
android.widget.FrameLayout
import
android.widget.ImageView
import
android.widget.LinearLayout
import
android.widget.TextView
import
chat.rocket.android.widget.R
import
chat.rocket.android.widget.helper.DrawableHelper
import
kotlinx.android.synthetic.main.room_list_item.view.*
/**
* Room list-item view used in sidebar.
*/
class
RoomListItemView
:
FrameLayout
{
lateinit
private
var
roomId
:
String
lateinit
private
var
roomTypeImage
:
ImageView
lateinit
private
var
userStatusImage
:
ImageView
lateinit
private
var
roomNameText
:
TextView
lateinit
private
var
alertCountText
:
TextView
lateinit
private
var
privateChannelDrawable
:
Drawable
lateinit
private
var
publicChannelDrawable
:
Drawable
lateinit
private
var
livechatChannelDrawable
:
Drawable
lateinit
private
var
userStatusDrawable
:
Drawable
private
val
privateChannelDrawable
:
Drawable
?
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_lock_white_24dp
,
null
)
private
val
publicChannelDrawable
:
Drawable
?
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_hashtag_white_24dp
,
null
)
private
val
liveChatChannelDrawable
:
Drawable
?
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_livechat_white_24dp
,
null
)
private
val
userStatusDrawable
:
Drawable
?
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_user_status_black_24dp
,
null
)
constructor
(
context
:
Context
)
:
super
(
context
)
{
initialize
(
context
)
...
...
@@ -60,16 +53,6 @@ class RoomListItemView : FrameLayout {
array
.
recycle
()
View
.
inflate
(
context
,
R
.
layout
.
room_list_item
,
this
)
roomTypeImage
=
findViewById
(
R
.
id
.
image_room_type
)
userStatusImage
=
findViewById
(
R
.
id
.
image_user_status
)
roomNameText
=
findViewById
(
R
.
id
.
text_room_name
)
alertCountText
=
findViewById
(
R
.
id
.
text_alert_count
)
privateChannelDrawable
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_lock_white_24dp
,
null
)
!!
publicChannelDrawable
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_hashtag_white_24dp
,
null
)
!!
livechatChannelDrawable
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_livechat_white_24dp
,
null
)
!!
userStatusDrawable
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_user_status_black_24dp
,
null
)
!!
}
fun
setRoomId
(
roomId
:
String
)
{
...
...
@@ -78,10 +61,10 @@ class RoomListItemView : FrameLayout {
fun
setUnreadCount
(
count
:
Int
)
{
if
(
count
>
0
)
{
alertCount
Text
.
text
=
count
.
toString
()
alertCount
Text
.
visibility
=
View
.
VISIBLE
alertCount
.
text
=
count
.
toString
()
alertCount
.
visibility
=
View
.
VISIBLE
}
else
{
alertCount
Text
.
visibility
=
View
.
GONE
alertCount
.
visibility
=
View
.
GONE
}
}
...
...
@@ -90,25 +73,25 @@ class RoomListItemView : FrameLayout {
}
fun
setRoomName
(
roomName
:
String
)
{
roomNameText
.
text
=
roomName
name
.
text
=
roomName
}
fun
showPrivateChannelIcon
()
{
roomTypeImag
e
.
setImageDrawable
(
privateChannelDrawable
)
userStatus
Image
.
visibility
=
View
.
GONE
roomTypeImag
e
.
visibility
=
View
.
VISIBLE
typ
e
.
setImageDrawable
(
privateChannelDrawable
)
userStatus
.
visibility
=
View
.
GONE
typ
e
.
visibility
=
View
.
VISIBLE
}
fun
showPublicChannelIcon
()
{
roomTypeImag
e
.
setImageDrawable
(
publicChannelDrawable
)
userStatus
Image
.
visibility
=
View
.
GONE
roomTypeImag
e
.
visibility
=
View
.
VISIBLE
typ
e
.
setImageDrawable
(
publicChannelDrawable
)
userStatus
.
visibility
=
View
.
GONE
typ
e
.
visibility
=
View
.
VISIBLE
}
fun
showLivechatChannelIcon
()
{
roomTypeImage
.
setImageDrawable
(
livec
hatChannelDrawable
)
userStatus
Image
.
visibility
=
View
.
GONE
roomTypeImag
e
.
visibility
=
View
.
VISIBLE
type
.
setImageDrawable
(
liveC
hatChannelDrawable
)
userStatus
.
visibility
=
View
.
GONE
typ
e
.
visibility
=
View
.
VISIBLE
}
fun
showOnlineUserStatusIcon
()
{
...
...
@@ -130,8 +113,8 @@ class RoomListItemView : FrameLayout {
private
fun
prepareDrawableAndShow
(
@ColorRes
resId
:
Int
)
{
DrawableHelper
.
wrapDrawable
(
userStatusDrawable
)
DrawableHelper
.
tintDrawable
(
userStatusDrawable
,
context
,
resId
)
userStatus
Image
.
setImageDrawable
(
userStatusDrawable
)
roomTypeImag
e
.
visibility
=
View
.
GONE
userStatus
Image
.
visibility
=
View
.
VISIBLE
userStatus
.
setImageDrawable
(
userStatusDrawable
)
typ
e
.
visibility
=
View
.
GONE
userStatus
.
visibility
=
View
.
VISIBLE
}
}
\ No newline at end of file
rocket-chat-android-widgets/src/main/res/layout/room_list_item.xml
View file @
66cbbad6
...
...
@@ -10,13 +10,13 @@
android:paddingBottom=
"10dp"
>
<ImageView
android:id=
"@+id/
image_room_
type"
android:id=
"@+id/type"
android:layout_width=
"20dp"
android:layout_height=
"wrap_content"
android:visibility=
"gone"
/>
<ImageView
android:id=
"@+id/
image_user_s
tatus"
android:id=
"@+id/
userS
tatus"
android:layout_marginLeft=
"5dp"
android:layout_marginStart=
"5dp"
android:layout_marginRight=
"5dp"
...
...
@@ -26,7 +26,7 @@
android:visibility=
"gone"
/>
<TextView
android:id=
"@+id/
text_room_
name"
android:id=
"@+id/name"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"0.9"
...
...
@@ -40,7 +40,7 @@
android:textAppearance=
"@style/TextAppearance.AppCompat.Body2"
/>
<TextView
android:id=
"@+id/
text_alert_c
ount"
android:id=
"@+id/
alertC
ount"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"0.1"
...
...
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