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
0fd53611
Unverified
Commit
0fd53611
authored
Jul 11, 2018
by
Filipe de Lima Brito
Committed by
GitHub
Jul 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into fix/oauth-path
parents
bca530f6
47106322
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
25 deletions
+72
-25
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+5
-6
ChatRoomView.kt
...chat/rocket/android/chatroom/presentation/ChatRoomView.kt
+1
-1
Attachment.kt
...c/main/java/chat/rocket/android/chatroom/ui/Attachment.kt
+2
-5
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+22
-3
round_textview.xml
app/src/main/res/drawable/round_textview.xml
+10
-0
message_list.xml
app/src/main/res/layout/message_list.xml
+32
-10
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
0fd53611
...
@@ -255,10 +255,9 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -255,10 +255,9 @@ class ChatRoomPresenter @Inject constructor(
messagesRepository
.
save
(
newMessage
)
messagesRepository
.
save
(
newMessage
)
view
.
showNewMessage
(
view
.
showNewMessage
(
mapper
.
map
(
mapper
.
map
(
newMessage
,
RoomUiModel
(
newMessage
,
roles
=
chatRoles
,
isBroadcast
=
chatIsBroadcast
RoomUiModel
(
roles
=
chatRoles
,
isBroadcast
=
chatIsBroadcast
)
)
),
false
)
)
)
client
.
sendMessage
(
id
,
chatRoomId
,
text
)
client
.
sendMessage
(
id
,
chatRoomId
,
text
)
}
catch
(
ex
:
Exception
)
{
}
catch
(
ex
:
Exception
)
{
...
@@ -473,7 +472,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -473,7 +472,7 @@ class ChatRoomPresenter @Inject constructor(
messagesRepository
.
saveAll
(
messages
.
result
)
messagesRepository
.
saveAll
(
messages
.
result
)
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
view
.
showNewMessage
(
models
)
view
.
showNewMessage
(
models
,
true
)
}
}
if
(
messages
.
result
.
size
==
50
)
{
if
(
messages
.
result
.
size
==
50
)
{
...
@@ -990,7 +989,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -990,7 +989,7 @@ class ChatRoomPresenter @Inject constructor(
}
else
{
}
else
{
Timber
.
d
(
"Adding new message"
)
Timber
.
d
(
"Adding new message"
)
messagesRepository
.
save
(
streamedMessage
)
messagesRepository
.
save
(
streamedMessage
)
view
.
showNewMessage
(
viewModelStreamedMessage
)
view
.
showNewMessage
(
viewModelStreamedMessage
,
true
)
}
}
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomView.kt
View file @
0fd53611
...
@@ -60,7 +60,7 @@ interface ChatRoomView : LoadingView, MessageView {
...
@@ -60,7 +60,7 @@ interface ChatRoomView : LoadingView, MessageView {
*
*
* @param message The (recent) message sent to a chat room.
* @param message The (recent) message sent to a chat room.
*/
*/
fun
showNewMessage
(
message
:
List
<
BaseUiModel
<*
>>)
fun
showNewMessage
(
message
:
List
<
BaseUiModel
<*
>>
,
isMessageReceived
:
Boolean
)
/**
/**
* Dispatch to the recycler views adapter that we should remove a message.
* Dispatch to the recycler views adapter that we should remove a message.
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/Attachment.kt
View file @
0fd53611
...
@@ -9,6 +9,7 @@ import chat.rocket.android.util.extensions.getMimeType
...
@@ -9,6 +9,7 @@ import chat.rocket.android.util.extensions.getMimeType
fun
ChatRoomFragment
.
showFileAttachmentDialog
(
uri
:
Uri
)
{
fun
ChatRoomFragment
.
showFileAttachmentDialog
(
uri
:
Uri
)
{
activity
?.
let
{
fragmentActivity
->
activity
?.
let
{
fragmentActivity
->
uri
.
getMimeType
(
fragmentActivity
).
let
{
mimeType
->
uri
.
getMimeType
(
fragmentActivity
).
let
{
mimeType
->
description
.
text
.
clear
()
when
{
when
{
mimeType
.
startsWith
(
"image"
)
->
{
mimeType
.
startsWith
(
"image"
)
->
{
imagePreview
.
isVisible
=
true
imagePreview
.
isVisible
=
true
...
@@ -27,16 +28,14 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) {
...
@@ -27,16 +28,14 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) {
sendButton
.
setOnClickListener
{
sendButton
.
setOnClickListener
{
presenter
.
uploadFile
(
chatRoomId
,
uri
,
(
citation
?:
""
)
+
description
.
text
.
toString
())
presenter
.
uploadFile
(
chatRoomId
,
uri
,
(
citation
?:
""
)
+
description
.
text
.
toString
())
clearMessageComposition
()
alertDialog
.
dismiss
()
alertDialog
.
dismiss
()
}
}
cancelButton
.
setOnClickListener
{
alertDialog
.
dismiss
()
}
cancelButton
.
setOnClickListener
{
alertDialog
.
dismiss
()
}
alertDialog
.
show
()
alertDialog
.
show
()
}
}
fun
ChatRoomFragment
.
showDrawAttachmentDialog
(
byteArray
:
ByteArray
)
{
fun
ChatRoomFragment
.
showDrawAttachmentDialog
(
byteArray
:
ByteArray
)
{
description
.
text
.
clear
()
imagePreview
.
isVisible
=
true
imagePreview
.
isVisible
=
true
imagePreview
.
setImageDrawable
(
Drawable
.
createFromStream
(
byteArray
.
inputStream
(),
""
))
imagePreview
.
setImageDrawable
(
Drawable
.
createFromStream
(
byteArray
.
inputStream
(),
""
))
...
@@ -46,11 +45,9 @@ fun ChatRoomFragment.showDrawAttachmentDialog(byteArray: ByteArray) {
...
@@ -46,11 +45,9 @@ fun ChatRoomFragment.showDrawAttachmentDialog(byteArray: ByteArray) {
byteArray
,
byteArray
,
(
citation
?:
""
)
+
description
.
text
.
toString
()
(
citation
?:
""
)
+
description
.
text
.
toString
()
)
)
clearMessageComposition
()
alertDialog
.
dismiss
()
alertDialog
.
dismiss
()
}
}
cancelButton
.
setOnClickListener
{
alertDialog
.
dismiss
()
}
cancelButton
.
setOnClickListener
{
alertDialog
.
dismiss
()
}
alertDialog
.
show
()
alertDialog
.
show
()
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
0fd53611
...
@@ -133,6 +133,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -133,6 +133,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
internal
lateinit
var
chatRoomId
:
String
internal
lateinit
var
chatRoomId
:
String
private
lateinit
var
chatRoomName
:
String
private
lateinit
var
chatRoomName
:
String
private
lateinit
var
chatRoomType
:
String
private
lateinit
var
chatRoomType
:
String
private
var
newMessageCount
:
Int
=
0
private
var
chatRoomMessage
:
String
?
=
null
private
var
chatRoomMessage
:
String
?
=
null
private
var
isSubscribed
:
Boolean
=
true
private
var
isSubscribed
:
Boolean
=
true
private
var
isReadOnly
:
Boolean
=
false
private
var
isReadOnly
:
Boolean
=
false
...
@@ -448,10 +449,13 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -448,10 +449,13 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
private
val
fabScrollListener
=
object
:
RecyclerView
.
OnScrollListener
()
{
private
val
fabScrollListener
=
object
:
RecyclerView
.
OnScrollListener
()
{
override
fun
onScrolled
(
recyclerView
:
RecyclerView
,
dx
:
Int
,
dy
:
Int
)
{
override
fun
onScrolled
(
recyclerView
:
RecyclerView
,
dx
:
Int
,
dy
:
Int
)
{
if
(!
recyclerView
.
canScrollVertically
(
1
))
{
if
(!
recyclerView
.
canScrollVertically
(
1
))
{
text_count
.
isVisible
=
false
button_fab
.
hide
()
button_fab
.
hide
()
newMessageCount
=
0
}
else
{
}
else
{
if
(
dy
<
0
&&
!
button_fab
.
isVisible
)
{
if
(
dy
<
0
&&
!
button_fab
.
isVisible
)
{
button_fab
.
show
()
button_fab
.
show
()
if
(
newMessageCount
!=
0
)
text_count
.
isVisible
=
true
}
}
}
}
}
}
...
@@ -504,9 +508,21 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -504,9 +508,21 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
showMessage
(
getString
(
R
.
string
.
msg_invalid_file
))
showMessage
(
getString
(
R
.
string
.
msg_invalid_file
))
}
}
override
fun
showNewMessage
(
message
:
List
<
BaseUiModel
<*
>>)
{
override
fun
showNewMessage
(
message
:
List
<
BaseUiModel
<*
>>
,
isMessageReceived
:
Boolean
)
{
ui
{
ui
{
adapter
.
prependData
(
message
)
adapter
.
prependData
(
message
)
if
(
isMessageReceived
&&
button_fab
.
isVisible
)
{
newMessageCount
++
if
(
newMessageCount
<=
99
)
text_count
.
text
=
newMessageCount
.
toString
()
else
text_count
.
text
=
"99+"
text_count
.
isVisible
=
true
}
else
if
(!
button_fab
.
isVisible
)
recycler_view
.
scrollToPosition
(
0
)
verticalScrollOffset
.
set
(
0
)
verticalScrollOffset
.
set
(
0
)
empty_chat_view
.
isVisible
=
adapter
.
itemCount
==
0
empty_chat_view
.
isVisible
=
adapter
.
itemCount
==
0
}
}
...
@@ -531,8 +547,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -531,8 +547,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
ui
{
ui
{
citation
=
null
citation
=
null
editingMessageId
=
null
editingMessageId
=
null
if
(
deleteMessage
)
if
(
deleteMessage
)
{
text_message
.
textContent
=
""
text_message
.
textContent
=
""
}
actionSnackbar
.
dismiss
()
actionSnackbar
.
dismiss
()
}
}
}
}
...
@@ -742,7 +759,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -742,7 +759,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
button_fab
.
setOnClickListener
{
button_fab
.
setOnClickListener
{
recycler_view
.
scrollToPosition
(
0
)
recycler_view
.
scrollToPosition
(
0
)
verticalScrollOffset
.
set
(
0
)
verticalScrollOffset
.
set
(
0
)
text_count
.
isVisible
=
false
button_fab
.
hide
()
button_fab
.
hide
()
newMessageCount
=
0
}
}
}
}
...
...
app/src/main/res/drawable/round_textview.xml
0 → 100644
View file @
0fd53611
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"oval"
>
<solid
android:color=
"@color/colorAccent"
/>
<size
android:width=
"20dp"
android:height=
"20dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/message_list.xml
View file @
0fd53611
...
@@ -10,18 +10,40 @@
...
@@ -10,18 +10,40 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:scrollbars=
"vertical"
/>
android:scrollbars=
"vertical"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
<RelativeLayout
android:id=
"@+id/button_fab"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"16dp"
android:layout_alignParentEnd=
"true"
android:src=
"@drawable/ic_arrow_downward_24dp"
android:layout_alignParentBottom=
"true"
android:theme=
"@style/Theme.AppCompat"
android:tint=
"@color/actionMenuColor"
android:visibility=
"invisible"
app:backgroundTint=
"@color/colorWhite"
app:fabSize=
"mini"
app:layout_anchor=
"@id/recycler_view"
app:layout_anchor=
"@id/recycler_view"
app:layout_anchorGravity=
"bottom|end"
/>
app:layout_anchorGravity=
"bottom|end"
>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id=
"@+id/button_fab"
android:layout_alignParentEnd=
"true"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:visibility=
"invisible"
android:layout_margin=
"16dp"
android:src=
"@drawable/ic_arrow_downward_24dp"
android:theme=
"@style/Theme.AppCompat"
android:tint=
"@color/actionMenuColor"
app:backgroundTint=
"@color/colorWhite"
app:fabSize=
"mini"
/>
<TextView
android:id=
"@+id/text_count"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:elevation=
"7dp"
android:padding=
"2dp"
android:gravity=
"center"
android:layout_margin=
"10dp"
android:textColor=
"@color/colorWhite"
android:visibility=
"invisible"
android:layout_alignParentEnd=
"true"
android:textSize=
"@dimen/message_time_text_size"
android:background=
"@drawable/round_textview"
/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ 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