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
29b7faa1
Commit
29b7faa1
authored
Apr 30, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust layout to centralize chat list items` contents when there is no last message stored set
parent
bf078e7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
34 deletions
+52
-34
ChatRoomsAdapter.kt
...java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
+17
-13
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+2
-0
item_chat.xml
app/src/main/res/layout/item_chat.xml
+33
-21
No files found.
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
View file @
29b7faa1
...
...
@@ -16,12 +16,9 @@ import chat.rocket.android.R
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.checkIfMyself
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.showLastMessage
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.android.util.extensions.content
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.textContent
import
chat.rocket.android.util.extensions.*
import
chat.rocket.common.model.RoomType
import
chat.rocket.core.model.ChatRoom
import
com.facebook.drawee.view.SimpleDraweeView
...
...
@@ -51,24 +48,31 @@ class ChatRoomsAdapter(private val context: Context,
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
)
if
(
settings
.
showLastMessage
())
{
text_last_message
.
setVisible
(
true
)
text_last_message_date_time
.
setVisible
(
true
)
bindLastMessageDateTime
(
chatRoom
,
text_last_message_date_time
)
bindLastMessage
(
chatRoom
,
text_last_message
)
}
else
{
text_last_message
.
setVisible
(
false
)
text_last_message_date_time
.
setVisible
(
false
)
}
bindUnreadMessages
(
chatRoom
,
text_total_unread_messages
)
if
(
chatRoom
.
alert
||
chatRoom
.
unread
>
0
)
{
text_chat_name
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorPrimaryText
))
R
.
color
.
colorPrimaryText
))
text_last_message_date_time
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorAccent
))
R
.
color
.
colorAccent
))
text_last_message
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
android
.
R
.
color
.
primary_text_light
))
android
.
R
.
color
.
primary_text_light
))
}
else
{
text_chat_name
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorSecondaryText
))
R
.
color
.
colorSecondaryText
))
text_last_message_date_time
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorSecondaryText
))
R
.
color
.
colorSecondaryText
))
text_last_message
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorSecondaryText
))
R
.
color
.
colorSecondaryText
))
}
setOnClickListener
{
listener
(
chatRoom
)
}
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
29b7faa1
...
...
@@ -23,6 +23,7 @@ import chat.rocket.android.helper.SharedPreferenceHelper
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.showLastMessage
import
chat.rocket.android.util.extensions.*
import
chat.rocket.android.widget.DividerItemDecoration
import
chat.rocket.common.model.RoomType
...
...
@@ -240,6 +241,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
recycler_view
.
itemAnimator
=
DefaultItemAnimator
()
// TODO - use a ViewModel Mapper instead of using settings on the adapter
println
(
serverInteractor
.
get
()
+
" -> ${settingsRepository.get(serverInteractor.get()!!).showLastMessage()}"
)
val
baseAdapter
=
ChatRoomsAdapter
(
it
,
settingsRepository
.
get
(
serverInteractor
.
get
()
!!
),
localRepository
)
{
chatRoom
->
presenter
.
loadChatRoom
(
chatRoom
)
...
...
app/src/main/res/layout/item_chat.xml
View file @
29b7faa1
...
...
@@ -22,46 +22,58 @@
<ImageView
android:id=
"@+id/image_chat_icon"
android:layout_width=
"12dp"
android:layout_height=
"
12
dp"
android:layout_height=
"
0
dp"
android:layout_marginStart=
"16dp"
app:layout_constraintBottom_toTopOf=
"@+id/text_last_message"
app:layout_constraintStart_toEndOf=
"@+id/image_avatar"
app:layout_constraintTop_toTopOf=
"@+id/image_avatar"
tools:src=
"@drawable/ic_hashtag_12dp"
/>
<TextView
android:id=
"@+id/text_last_message"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"8dp"
android:layout_marginTop=
"2dp"
android:layout_weight=
"0.8"
android:ellipsize=
"end"
android:maxLines=
"2"
android:textDirection=
"locale"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/image_chat_icon"
app:layout_constraintTop_toBottomOf=
"@+id/text_chat_name"
tools:text=
"Filipe de Lima Brito: Type something that is very big and need at least to lines, or maybe even more"
/>
<TextView
android:id=
"@+id/text_chat_name"
style=
"@style/ChatRoom.Name.TextView"
android:layout_width=
"
wrap_content
"
android:layout_width=
"
0dp
"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:ellipsize=
"end"
android:lines=
"1"
android:maxLines=
"1"
android:textDirection=
"locale"
app:layout_constraintBottom_toTopOf=
"@+id/text_last_message"
app:layout_constraintEnd_toStartOf=
"@+id/text_last_message_date_time"
app:layout_constraintStart_toEndOf=
"@+id/image_chat_icon"
app:layout_constraintTop_toTopOf=
"parent"
tools:text=
"general"
/>
<TextView
android:id=
"@+id/text_last_message_date_time"
style=
"@style/Timestamp.TextView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
app:layout_constraintBottom_toBottomOf=
"@+id/text_chat_name"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/text_chat_name"
tools:text=
"11:45 AM"
/>
<TextView
android:id=
"@+id/text_last_message"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"0dp"
android:gravity=
"center"
android:layout_marginEnd=
"8dp"
android:layout_marginTop=
"2dp"
android:ellipsize=
"end"
android:maxLines=
"2"
android:textDirection=
"locale"
app:layout_constraintBottom_toBottomOf=
"@+id/layout_unread_messages_badge"
app:layout_constraintEnd_toStartOf=
"@+id/layout_unread_messages_badge"
app:layout_constraintStart_toStartOf=
"@+id/image_chat_icon"
app:layout_constraintTop_toBottomOf=
"@+id/text_chat_name"
tools:text=
"Filipe de Lima Brito: Type something that is very big and need at least to lines, or maybe even more"
/>
app:layout_constraintTop_toTopOf=
"@+id/text_chat_name"
tools:text=
"11:45 AM"
/>
<include
android:id=
"@+id/layout_unread_messages_badge"
...
...
@@ -69,6 +81,6 @@
android:layout_width=
"18dp"
android:layout_height=
"18dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/text_
last_messag
e"
/>
app:layout_constraintTop_toTopOf=
"@+id/text_
chat_nam
e"
/>
</android.support.constraint.ConstraintLayout>
\ 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