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
15a317a4
Commit
15a317a4
authored
Apr 18, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add drawables / updates the chat list UI.
parent
094c88d4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
33 deletions
+99
-33
DrawableHelper.kt
app/src/main/java/chat/rocket/android/app/DrawableHelper.kt
+1
-1
ChatRoomsAdapter.kt
...java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
+27
-26
ic_hashtag_12dp.xml
app/src/main/res/drawable/ic_hashtag_12dp.xml
+30
-0
ic_lock_12_dp.xml
app/src/main/res/drawable/ic_lock_12_dp.xml
+18
-0
item_chat.xml
app/src/main/res/layout/item_chat.xml
+19
-5
dimens.xml
app/src/main/res/values/dimens.xml
+4
-1
No files found.
app/src/main/java/chat/rocket/android/app/DrawableHelper.kt
View file @
15a317a4
...
...
@@ -108,7 +108,7 @@ object DrawableHelper {
* @see [UserStatus]
* @return The user status drawable.
*/
fun
getUserStatusDrawable
(
userStatus
:
UserStatus
,
context
:
Context
,
getSmallDrawable
:
Boolean
=
false
):
Drawable
{
fun
getUserStatusDrawable
(
userStatus
:
UserStatus
?
,
context
:
Context
,
getSmallDrawable
:
Boolean
=
false
):
Drawable
{
return
when
(
userStatus
)
{
is
UserStatus
.
Online
->
{
getDrawableFromId
(
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
View file @
15a317a4
...
...
@@ -10,6 +10,7 @@ import android.text.SpannableStringBuilder
import
android.text.style.ForegroundColorSpan
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.TextView
import
chat.rocket.android.R
import
chat.rocket.android.infrastructure.LocalRepository
...
...
@@ -50,6 +51,7 @@ class ChatRoomsAdapter(private val context: Context,
fun
bind
(
chatRoom
:
ChatRoom
)
=
with
(
itemView
)
{
bindAvatar
(
chatRoom
,
image_avatar
)
bindName
(
chatRoom
,
text_chat_name
)
bindIcon
(
chatRoom
,
image_chat_icon
)
bindLastMessageDateTime
(
chatRoom
,
text_last_message_date_time
)
bindLastMessage
(
chatRoom
,
text_last_message
)
bindUnreadMessages
(
chatRoom
,
text_total_unread_messages
)
...
...
@@ -81,41 +83,40 @@ class ChatRoomsAdapter(private val context: Context,
}
}
private
fun
bindName
(
chatRoom
:
ChatRoom
,
textView
:
TextView
)
{
textView
.
textContent
=
chatRoom
.
name
private
fun
bindIcon
(
chatRoom
:
ChatRoom
,
imageView
:
ImageView
)
{
val
drawable
=
when
(
chatRoom
.
type
)
{
is
RoomType
.
Channel
->
{
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_room_channel
,
context
)
}
is
RoomType
.
PrivateGroup
->
{
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_room_lock
,
context
)
}
is
RoomType
.
DirectMessage
->
{
val
status
=
chatRoom
.
status
if
(
status
==
null
)
{
DrawableHelper
.
getUserStatusDrawable
(
UserStatus
.
Offline
(),
context
,
true
)
}
else
{
DrawableHelper
.
getUserStatusDrawable
(
status
,
context
,
true
)
}
}
is
RoomType
.
Channel
->
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_hashtag_12dp
,
context
)
is
RoomType
.
PrivateGroup
->
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_lock_12_dp
,
context
)
is
RoomType
.
DirectMessage
->
DrawableHelper
.
getUserStatusDrawable
(
chatRoom
.
status
,
context
,
true
)
else
->
null
}
drawable
?.
let
{
val
wrappedDrawable
=
DrawableHelper
.
wrapDrawable
(
it
)
val
mutableDrawable
=
wrappedDrawable
.
mutate
()
val
color
=
when
(
chatRoom
.
alert
||
chatRoom
.
unread
>
0
)
{
true
->
R
.
color
.
colorPrimaryText
false
->
R
.
color
.
colorSecondaryText
}
if
(
chatRoom
.
type
!
is
RoomType
.
DirectMessage
)
{
DrawableHelper
.
tintDrawable
(
mutableDrawable
,
context
,
color
)
DrawableHelper
.
wrapDrawable
(
it
)
val
color
=
when
(
chatRoom
.
alert
||
chatRoom
.
unread
>
0
)
{
true
->
R
.
color
.
colorPrimaryText
false
->
R
.
color
.
colorSecondaryText
}
DrawableHelper
.
tintDrawable
(
it
,
context
,
color
)
}
DrawableHelper
.
compoundDrawable
(
textView
,
mutableD
rawable
)
imageView
.
setImageDrawable
(
d
rawable
)
}
}
private
fun
bindName
(
chatRoom
:
ChatRoom
,
textView
:
TextView
)
{
textView
.
textContent
=
chatRoom
.
name
}
private
fun
bindLastMessageDateTime
(
chatRoom
:
ChatRoom
,
textView
:
TextView
)
{
val
lastMessage
=
chatRoom
.
lastMessage
if
(
lastMessage
!=
null
)
{
...
...
app/src/main/res/drawable/ic_hashtag_12dp.xml
0 → 100644
View file @
15a317a4
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"12dp"
android:height=
"12dp"
android:viewportHeight=
"12"
android:viewportWidth=
"12"
>
<path
android:fillColor=
"#9EA2A8"
android:fillType=
"evenOdd"
android:pathData=
"M2.4,0h1.2v12h-1.2z"
android:strokeColor=
"#00000000"
android:strokeWidth=
"1"
/>
<path
android:fillColor=
"#9EA2A8"
android:fillType=
"evenOdd"
android:pathData=
"M0,2.4h12v1.2h-12z"
android:strokeColor=
"#00000000"
android:strokeWidth=
"1"
/>
<path
android:fillColor=
"#9EA2A8"
android:fillType=
"evenOdd"
android:pathData=
"M0,8.4h12v1.2h-12z"
android:strokeColor=
"#00000000"
android:strokeWidth=
"1"
/>
<path
android:fillColor=
"#9EA2A8"
android:fillType=
"evenOdd"
android:pathData=
"M8.4,0h1.2v12h-1.2z"
android:strokeColor=
"#00000000"
android:strokeWidth=
"1"
/>
</vector>
\ No newline at end of file
app/src/main/res/drawable/ic_lock_12_dp.xml
0 → 100644
View file @
15a317a4
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"12dp"
android:height=
"12dp"
android:viewportWidth=
"12"
android:viewportHeight=
"12"
>
<path
android:pathData=
"M1.5,5.5h9v6h-9z"
android:strokeWidth=
"1"
android:fillColor=
"#00000000"
android:strokeColor=
"#9EA2A8"
android:fillType=
"evenOdd"
/>
<path
android:pathData=
"M2.5,5.5L9.5,5.5L9.5,4C9.5,2.067 7.933,0.5 6,0.5C4.067,0.5 2.5,2.067 2.5,4L2.5,5.5Z"
android:strokeWidth=
"1"
android:fillColor=
"#00000000"
android:strokeColor=
"#9EA2A8"
android:fillType=
"evenOdd"
/>
</vector>
app/src/main/res/layout/item_chat.xml
View file @
15a317a4
...
...
@@ -19,16 +19,29 @@
app:layout_constraintTop_toTopOf=
"parent"
app:roundedCornerRadius=
"3dp"
/>
<ImageView
android:id=
"@+id/image_chat_icon"
android:layout_width=
"12dp"
android:layout_height=
"12dp"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"5dp"
app:layout_constraintStart_toEndOf=
"@id/image_avatar"
app:layout_constraintTop_toTopOf=
"@+id/image_avatar"
tools:src=
"@drawable/ic_lock_12_dp"
/>
<TextView
android:id=
"@+id/text_chat_name"
style=
"@style/ChatRoom.Name.TextView"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_margin
Start=
"16
dp"
android:
drawablePadding=
"6
dp"
android:layout_margin
End=
"5
dp"
android:
layout_marginStart=
"8
dp"
android:textDirection=
"locale"
app:layout_constraintStart_toEndOf=
"@id/image_avatar"
tools:text=
"General"
/>
app:layout_constraintBottom_toBottomOf=
"@+id/image_chat_icon"
app:layout_constraintEnd_toStartOf=
"@+id/text_last_message_date_time"
app:layout_constraintStart_toEndOf=
"@id/image_chat_icon"
app:layout_constraintTop_toTopOf=
"@+id/image_chat_icon"
tools:text=
"A very very very very big chat room name"
/>
<TextView
android:id=
"@+id/text_last_message_date_time"
...
...
@@ -45,12 +58,13 @@
android:id=
"@+id/text_last_message"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"5dp"
android:layout_marginTop=
"2dp"
android:ellipsize=
"end"
android:maxLines=
"2"
android:textDirection=
"locale"
app:layout_constraintEnd_toStartOf=
"@id/layout_unread_messages_badge"
app:layout_constraintStart_toStartOf=
"@id/
text_chat_name
"
app:layout_constraintStart_toStartOf=
"@id/
image_chat_icon
"
app:layout_constraintTop_toBottomOf=
"@id/text_chat_name"
tools:text=
"You: Type something that is very big and need at least to lines, or maybe even more"
/>
...
...
app/src/main/res/values/dimens.xml
View file @
15a317a4
...
...
@@ -5,7 +5,6 @@
<dimen
name=
"screen_edge_left_and_right_margins"
>
16dp
</dimen>
<dimen
name=
"screen_edge_left_and_right_padding"
>
16dp
</dimen>
<dimen
name=
"chat_item_top_and_bottom_padding"
>
12dp
</dimen>
<dimen
name=
"message_item_top_and_bottom_padding"
>
6dp
</dimen>
<dimen
name=
"member_item_top_and_bottom_padding"
>
6dp
</dimen>
...
...
@@ -23,6 +22,10 @@
<dimen
name=
"nav_header_height"
>
140dp
</dimen>
<!-- ChatRoom -->
<dimen
name=
"chat_item_top_and_bottom_padding"
>
12dp
</dimen>
<!-- Emoji -->
<dimen
name=
"picker_padding_bottom"
>
16dp
</dimen>
<dimen
name=
"supposed_keyboard_height"
>
252dp
</dimen>
...
...
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