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
f0d47634
Unverified
Commit
f0d47634
authored
Mar 13, 2018
by
Lucio Maciel
Committed by
GitHub
Mar 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #909 from RocketChat/guggy-gifs
Show Guggy GIFs attachments
parents
619d60b7
7c2544e3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
47 deletions
+82
-47
ImageAttachmentViewHolder.kt
...ket/android/chatroom/adapter/ImageAttachmentViewHolder.kt
+12
-1
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+21
-19
ViewModelMapper.kt
...chat/rocket/android/chatroom/viewmodel/ViewModelMapper.kt
+37
-15
fragment_authentication_server.xml
app/src/main/res/layout/fragment_authentication_server.xml
+10
-10
dependencies.gradle
dependencies.gradle
+2
-2
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/ImageAttachmentViewHolder.kt
View file @
f0d47634
...
@@ -2,6 +2,8 @@ package chat.rocket.android.chatroom.adapter
...
@@ -2,6 +2,8 @@ package chat.rocket.android.chatroom.adapter
import
android.view.View
import
android.view.View
import
chat.rocket.android.chatroom.viewmodel.ImageAttachmentViewModel
import
chat.rocket.android.chatroom.viewmodel.ImageAttachmentViewModel
import
com.facebook.drawee.backends.pipeline.Fresco
import
com.facebook.drawee.interfaces.DraweeController
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
com.stfalcon.frescoimageviewer.ImageViewer
import
com.stfalcon.frescoimageviewer.ImageViewer
import
kotlinx.android.synthetic.main.message_attachment.view.*
import
kotlinx.android.synthetic.main.message_attachment.view.*
...
@@ -20,12 +22,21 @@ class ImageAttachmentViewHolder(itemView: View,
...
@@ -20,12 +22,21 @@ class ImageAttachmentViewHolder(itemView: View,
override
fun
bindViews
(
data
:
ImageAttachmentViewModel
)
{
override
fun
bindViews
(
data
:
ImageAttachmentViewModel
)
{
with
(
itemView
)
{
with
(
itemView
)
{
image_attachment
.
setImageURI
(
data
.
attachmentUrl
)
val
controller
=
Fresco
.
newDraweeControllerBuilder
().
apply
{
setUri
(
data
.
attachmentUrl
)
autoPlayAnimations
=
true
oldController
=
image_attachment
.
controller
}.
build
()
image_attachment
.
controller
=
controller
file_name
.
text
=
data
.
attachmentTitle
file_name
.
text
=
data
.
attachmentTitle
image_attachment
.
setOnClickListener
{
view
->
image_attachment
.
setOnClickListener
{
view
->
// TODO - implement a proper image viewer with a proper Transition
// TODO - implement a proper image viewer with a proper Transition
val
builder
=
ImageViewer
.
createPipelineDraweeControllerBuilder
()
.
setAutoPlayAnimations
(
true
)
ImageViewer
.
Builder
(
view
.
context
,
listOf
(
data
.
attachmentUrl
))
ImageViewer
.
Builder
(
view
.
context
,
listOf
(
data
.
attachmentUrl
))
.
setStartPosition
(
0
)
.
setStartPosition
(
0
)
.
hideStatusBar
(
false
)
.
setCustomDraweeControllerBuilder
(
builder
)
.
show
()
.
show
()
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
f0d47634
...
@@ -200,25 +200,27 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
...
@@ -200,25 +200,27 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
launch
(
parent
=
strategy
.
jobs
)
{
launch
(
parent
=
strategy
.
jobs
)
{
if
(
chatRoomId
!=
null
&&
chatRoomType
!=
null
)
{
if
(
chatRoomId
!=
null
&&
chatRoomType
!=
null
)
{
val
roomType
=
roomTypeOf
(
chatRoomType
!!
)
val
roomType
=
roomTypeOf
(
chatRoomType
!!
)
val
lastMessage
=
messagesRepository
.
getByRoomId
(
chatRoomId
!!
).
sortedByDescending
{
it
.
timestamp
}.
first
()
messagesRepository
.
getByRoomId
(
chatRoomId
!!
)
val
instant
=
Instant
.
ofEpochMilli
(
lastMessage
.
timestamp
)
.
sortedByDescending
{
it
.
timestamp
}.
firstOrNull
()
?.
let
{
lastMessage
->
val
messages
=
client
.
history
(
chatRoomId
!!
,
roomType
,
count
=
50
,
val
instant
=
Instant
.
ofEpochMilli
(
lastMessage
.
timestamp
)
oldest
=
instant
.
toString
())
val
messages
=
client
.
history
(
chatRoomId
!!
,
roomType
,
count
=
50
,
Timber
.
d
(
"History: $messages"
)
oldest
=
instant
.
toString
())
Timber
.
d
(
"History: $messages"
)
if
(
messages
.
result
.
isNotEmpty
())
{
val
models
=
mapper
.
map
(
messages
.
result
)
if
(
messages
.
result
.
isNotEmpty
())
{
messagesRepository
.
saveAll
(
messages
.
result
)
val
models
=
mapper
.
map
(
messages
.
result
)
messagesRepository
.
saveAll
(
messages
.
result
)
launchUI
(
strategy
)
{
view
.
showNewMessage
(
models
)
launchUI
(
strategy
)
{
}
view
.
showNewMessage
(
models
)
}
if
(
messages
.
result
.
size
==
50
)
{
// we loade at least count messages, try one more to fetch more messages
if
(
messages
.
result
.
size
==
50
)
{
loadMissingMessages
()
// we loade at least count messages, try one more to fetch more messages
}
loadMissingMessages
()
}
}
}
}
}
}
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/viewmodel/ViewModelMapper.kt
View file @
f0d47634
...
@@ -96,31 +96,53 @@ class ViewModelMapper @Inject constructor(private val context: Context,
...
@@ -96,31 +96,53 @@ class ViewModelMapper @Inject constructor(private val context: Context,
}
}
private
fun
mapFileAttachment
(
message
:
Message
,
attachment
:
FileAttachment
):
BaseViewModel
<
*
>?
{
private
fun
mapFileAttachment
(
message
:
Message
,
attachment
:
FileAttachment
):
BaseViewModel
<
*
>?
{
val
attachmentUrl
=
attachmentUrl
(
"$baseUrl${attachment.url}"
)
val
attachmentUrl
=
attachmentUrl
(
attachment
)
val
attachmentTitle
=
attachment
.
title
val
attachmentTitle
=
attachment
Title
(
attachment
)
val
id
=
"${message.id}_${attachment.titleLink}"
.
hashCode
().
toLong
(
)
val
id
=
attachmentId
(
message
,
attachment
)
return
when
(
attachment
)
{
return
when
(
attachment
)
{
is
ImageAttachment
->
ImageAttachmentViewModel
(
message
,
attachment
,
message
.
id
,
is
ImageAttachment
->
ImageAttachmentViewModel
(
message
,
attachment
,
message
.
id
,
attachmentUrl
,
attachmentTitle
?:
""
,
id
,
getReactions
(
message
))
attachmentUrl
,
attachmentTitle
,
id
,
getReactions
(
message
))
is
VideoAttachment
->
VideoAttachmentViewModel
(
message
,
attachment
,
message
.
id
,
is
VideoAttachment
->
VideoAttachmentViewModel
(
message
,
attachment
,
message
.
id
,
attachmentUrl
,
attachmentTitle
?:
""
,
id
,
getReactions
(
message
))
attachmentUrl
,
attachmentTitle
,
id
,
getReactions
(
message
))
is
AudioAttachment
->
AudioAttachmentViewModel
(
message
,
attachment
,
message
.
id
,
is
AudioAttachment
->
AudioAttachmentViewModel
(
message
,
attachment
,
message
.
id
,
attachmentUrl
,
attachmentTitle
?:
""
,
id
,
getReactions
(
message
))
attachmentUrl
,
attachmentTitle
,
id
,
getReactions
(
message
))
else
->
null
else
->
null
}
}
}
}
private
fun
attachmentUrl
(
url
:
String
):
String
{
private
fun
attachmentId
(
message
:
Message
,
attachment
:
FileAttachment
):
Long
{
var
response
=
url
return
"${message.id}_${attachment.url}"
.
hashCode
().
toLong
()
val
httpUrl
=
HttpUrl
.
parse
(
url
)
}
httpUrl
?.
let
{
response
=
it
.
newBuilder
().
apply
{
private
fun
attachmentTitle
(
attachment
:
FileAttachment
):
CharSequence
{
addQueryParameter
(
"rc_uid"
,
token
?.
userId
)
return
with
(
attachment
)
{
addQueryParameter
(
"rc_token"
,
token
?.
authToken
)
title
?.
let
{
return
@with
it
}
}.
build
().
toString
()
val
fileUrl
=
HttpUrl
.
parse
(
url
)
fileUrl
?.
let
{
return
@with
it
.
pathSegments
().
last
()
}
return
@with
""
}
}
}
private
fun
attachmentUrl
(
attachment
:
FileAttachment
):
String
{
return
with
(
attachment
)
{
if
(
url
.
startsWith
(
"http"
))
return
@with
url
val
fullUrl
=
"$baseUrl$url"
val
httpUrl
=
HttpUrl
.
parse
(
fullUrl
)
httpUrl
?.
let
{
return
@with
it
.
newBuilder
().
apply
{
addQueryParameter
(
"rc_uid"
,
token
?.
userId
)
addQueryParameter
(
"rc_token"
,
token
?.
authToken
)
}.
build
().
toString
()
}
return
response
// Fallback to baseUrl + url
return
@with
fullUrl
}
}
}
private
suspend
fun
mapMessage
(
message
:
Message
):
MessageViewModel
=
withContext
(
CommonPool
)
{
private
suspend
fun
mapMessage
(
message
:
Message
):
MessageViewModel
=
withContext
(
CommonPool
)
{
...
...
app/src/main/res/layout/fragment_authentication_server.xml
View file @
f0d47634
...
@@ -14,19 +14,11 @@
...
@@ -14,19 +14,11 @@
android:layout_centerHorizontal=
"true"
android:layout_centerHorizontal=
"true"
android:text=
"@string/title_sign_in_your_server"
/>
android:text=
"@string/title_sign_in_your_server"
/>
<TextView
android:id=
"@+id/text_server_protocol"
style=
"@style/Authentication.TextView"
android:layout_below=
"@id/text_headline"
android:layout_marginTop=
"32dp"
android:gravity=
"center_vertical"
android:text=
"@string/default_protocol"
/>
<EditText
<EditText
android:id=
"@+id/text_server_url"
android:id=
"@+id/text_server_url"
style=
"@style/Authentication.EditText"
style=
"@style/Authentication.EditText"
android:layout_below=
"@id/text_headline"
android:layout_below=
"@id/text_headline"
android:layout_marginStart=
"
0
dp"
android:layout_marginStart=
"
-4
dp"
android:layout_marginTop=
"32dp"
android:layout_marginTop=
"32dp"
android:layout_toEndOf=
"@id/text_server_protocol"
android:layout_toEndOf=
"@id/text_server_protocol"
android:cursorVisible=
"false"
android:cursorVisible=
"false"
...
@@ -35,7 +27,15 @@
...
@@ -35,7 +27,15 @@
android:digits=
"0123456789abcdefghijklmnopqrstuvwxyz.-/:"
android:digits=
"0123456789abcdefghijklmnopqrstuvwxyz.-/:"
android:inputType=
"textUri"
android:inputType=
"textUri"
android:paddingEnd=
"0dp"
android:paddingEnd=
"0dp"
android:paddingStart=
"0dp"
/>
android:paddingStart=
"2dp"
/>
<TextView
android:id=
"@+id/text_server_protocol"
style=
"@style/Authentication.TextView"
android:layout_below=
"@id/text_headline"
android:layout_marginTop=
"32dp"
android:gravity=
"center_vertical"
android:text=
"@string/default_protocol"
/>
<com.wang.avi.AVLoadingIndicatorView
<com.wang.avi.AVLoadingIndicatorView
android:id=
"@+id/view_loading"
android:id=
"@+id/view_loading"
...
...
dependencies.gradle
View file @
f0d47634
...
@@ -25,7 +25,7 @@ ext {
...
@@ -25,7 +25,7 @@ ext {
rxBinding
:
'2.0.0'
,
rxBinding
:
'2.0.0'
,
fresco
:
'1.8.1'
,
fresco
:
'1.8.1'
,
kotshi
:
'0.3.0'
,
kotshi
:
'0.3.0'
,
frescoImageViewer
:
'0.5.
0
'
,
frescoImageViewer
:
'0.5.
1
'
,
androidSvg
:
'master-SNAPSHOT'
,
androidSvg
:
'master-SNAPSHOT'
,
markwon
:
'1.0.3'
,
markwon
:
'1.0.3'
,
sheetMenu
:
'1.3.3'
,
sheetMenu
:
'1.3.3'
,
...
@@ -86,7 +86,7 @@ ext {
...
@@ -86,7 +86,7 @@ ext {
kotshiApi
:
"se.ansman.kotshi:api:${versions.kotshi}"
,
kotshiApi
:
"se.ansman.kotshi:api:${versions.kotshi}"
,
kotshiCompiler
:
"se.ansman.kotshi:compiler:${versions.kotshi}"
,
kotshiCompiler
:
"se.ansman.kotshi:compiler:${versions.kotshi}"
,
frescoImageViewer
:
"com.github.
stfalcon:frescoimagev
iewer:${versions.frescoImageViewer}"
,
frescoImageViewer
:
"com.github.
luciofm:FrescoImageV
iewer:${versions.frescoImageViewer}"
,
androidSvg
:
"com.github.BigBadaboom:androidsvg:${versions.androidSvg}"
,
androidSvg
:
"com.github.BigBadaboom:androidsvg:${versions.androidSvg}"
,
markwon
:
"ru.noties:markwon:${versions.markwon}"
,
markwon
:
"ru.noties:markwon:${versions.markwon}"
,
...
...
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