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
2f59e9e2
Commit
2f59e9e2
authored
Feb 07, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'markdown-support' into message-actions
parents
df9f1480
0749391e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
10 deletions
+18
-10
MessageViewModelMapper.kt
...cket/android/chatroom/viewmodel/MessageViewModelMapper.kt
+10
-3
AppModule.kt
.../main/java/chat/rocket/android/dagger/module/AppModule.kt
+4
-3
MessageParser.kt
...src/main/java/chat/rocket/android/helper/MessageParser.kt
+4
-4
No files found.
app/src/main/java/chat/rocket/android/chatroom/viewmodel/MessageViewModelMapper.kt
View file @
2f59e9e2
...
@@ -7,7 +7,7 @@ import chat.rocket.core.TokenRepository
...
@@ -7,7 +7,7 @@ import chat.rocket.core.TokenRepository
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.Value
import
chat.rocket.core.model.Value
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.
launch
import
kotlinx.coroutines.experimental.
withContext
import
javax.inject.Inject
import
javax.inject.Inject
class
MessageViewModelMapper
@Inject
constructor
(
private
val
context
:
Context
,
class
MessageViewModelMapper
@Inject
constructor
(
private
val
context
:
Context
,
...
@@ -15,8 +15,15 @@ class MessageViewModelMapper @Inject constructor(private val context: Context,
...
@@ -15,8 +15,15 @@ class MessageViewModelMapper @Inject constructor(private val context: Context,
private
val
messageParser
:
MessageParser
,
private
val
messageParser
:
MessageParser
,
private
val
messagesRepository
:
MessagesRepository
)
{
private
val
messagesRepository
:
MessagesRepository
)
{
suspend
fun
mapToViewModel
(
message
:
Message
,
settings
:
Map
<
String
,
Value
<
Any
>>)
=
launch
(
CommonPool
)
{
suspend
fun
mapToViewModel
(
message
:
Message
,
settings
:
Map
<
String
,
Value
<
Any
>>):
MessageViewModel
=
withContext
(
CommonPool
)
{
MessageViewModel
(
this
@MessageViewModelMapper
.
context
,
tokenRepository
.
get
(),
message
,
settings
,
messageParser
,
messagesRepository
)
MessageViewModel
(
this
@MessageViewModelMapper
.
context
,
tokenRepository
.
get
(),
message
,
settings
,
messageParser
,
messagesRepository
)
}
}
suspend
fun
mapToViewModelList
(
messageList
:
List
<
Message
>,
settings
:
Map
<
String
,
Value
<
Any
>>):
List
<
MessageViewModel
>
{
suspend
fun
mapToViewModelList
(
messageList
:
List
<
Message
>,
settings
:
Map
<
String
,
Value
<
Any
>>):
List
<
MessageViewModel
>
{
...
...
app/src/main/java/chat/rocket/android/dagger/module/AppModule.kt
View file @
2f59e9e2
...
@@ -4,8 +4,8 @@ import android.app.Application
...
@@ -4,8 +4,8 @@ import android.app.Application
import
android.arch.persistence.room.Room
import
android.arch.persistence.room.Room
import
android.content.Context
import
android.content.Context
import
android.content.SharedPreferences
import
android.content.SharedPreferences
import
android.graphics.Color
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.R
import
chat.rocket.android.app.RocketChatDatabase
import
chat.rocket.android.app.RocketChatDatabase
import
chat.rocket.android.app.utils.CustomImageFormatConfigurator
import
chat.rocket.android.app.utils.CustomImageFormatConfigurator
import
chat.rocket.android.authentication.infraestructure.MemoryTokenRepository
import
chat.rocket.android.authentication.infraestructure.MemoryTokenRepository
...
@@ -206,14 +206,15 @@ class AppModule {
...
@@ -206,14 +206,15 @@ class AppModule {
@Provides
@Provides
@Singleton
@Singleton
fun
provideConfiguration
(
context
:
Application
,
client
:
OkHttpClient
):
SpannableConfiguration
{
fun
provideConfiguration
(
context
:
Application
,
client
:
OkHttpClient
):
SpannableConfiguration
{
val
res
=
context
.
resources
return
SpannableConfiguration
.
builder
(
context
)
return
SpannableConfiguration
.
builder
(
context
)
.
asyncDrawableLoader
(
AsyncDrawableLoader
.
builder
()
.
asyncDrawableLoader
(
AsyncDrawableLoader
.
builder
()
.
client
(
client
)
.
client
(
client
)
.
executorService
(
Executors
.
newCachedThreadPool
())
.
executorService
(
Executors
.
newCachedThreadPool
())
.
resources
(
context
.
resourc
es
)
.
resources
(
r
es
)
.
build
())
.
build
())
.
theme
(
SpannableTheme
.
builder
()
.
theme
(
SpannableTheme
.
builder
()
.
linkColor
(
Color
.
BLUE
)
.
linkColor
(
res
.
getColor
(
R
.
color
.
colorAccent
)
)
.
build
())
.
build
())
.
build
()
.
build
()
}
}
...
...
app/src/main/java/chat/rocket/android/helper/MessageParser.kt
View file @
2f59e9e2
...
@@ -129,7 +129,7 @@ class MessageParser @Inject constructor(val context: Application, private val co
...
@@ -129,7 +129,7 @@ class MessageParser @Inject constructor(val context: Application, private val co
}
}
class
QuoteMarginSpan
(
quoteDrawable
:
Drawable
,
private
var
pad
:
Int
)
:
LeadingMarginSpan
,
LineHeightSpan
{
class
QuoteMarginSpan
(
quoteDrawable
:
Drawable
,
private
var
pad
:
Int
)
:
LeadingMarginSpan
,
LineHeightSpan
{
private
va
r
drawable
:
Drawable
=
quoteDrawable
private
va
l
drawable
:
Drawable
=
quoteDrawable
override
fun
getLeadingMargin
(
first
:
Boolean
):
Int
{
override
fun
getLeadingMargin
(
first
:
Boolean
):
Int
{
return
drawable
.
intrinsicWidth
+
pad
return
drawable
.
intrinsicWidth
+
pad
...
@@ -150,14 +150,14 @@ class MessageParser @Inject constructor(val context: Application, private val co
...
@@ -150,14 +150,14 @@ class MessageParser @Inject constructor(val context: Application, private val co
}
}
override
fun
chooseHeight
(
text
:
CharSequence
,
start
:
Int
,
end
:
Int
,
override
fun
chooseHeight
(
text
:
CharSequence
,
start
:
Int
,
end
:
Int
,
i
startv
:
Int
,
v
:
Int
,
span
startv
:
Int
,
v
:
Int
,
fm
:
Paint
.
FontMetricsInt
)
{
fm
:
Paint
.
FontMetricsInt
)
{
if
(
end
==
(
text
as
Spanned
).
getSpanEnd
(
this
))
{
if
(
end
==
(
text
as
Spanned
).
getSpanEnd
(
this
))
{
val
ht
=
drawable
.
intrinsicHeight
val
ht
=
drawable
.
intrinsicHeight
var
need
=
ht
-
(
v
+
fm
.
descent
-
fm
.
ascent
-
i
startv
)
var
need
=
ht
-
(
v
+
fm
.
descent
-
fm
.
ascent
-
span
startv
)
if
(
need
>
0
)
if
(
need
>
0
)
fm
.
descent
+=
need
fm
.
descent
+=
need
need
=
ht
-
(
v
+
fm
.
bottom
-
fm
.
top
-
i
startv
)
need
=
ht
-
(
v
+
fm
.
bottom
-
fm
.
top
-
span
startv
)
if
(
need
>
0
)
if
(
need
>
0
)
fm
.
bottom
+=
need
fm
.
bottom
+=
need
}
}
...
...
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