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
b01c1258
Unverified
Commit
b01c1258
authored
Sep 06, 2018
by
Filipe de Lima Brito
Committed by
GitHub
Sep 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1656 from RocketChat/fix/fix-emoji-crash-gambiarra
[FIX] fix emoji crash
parents
a93e1479
8b385cfb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
6 deletions
+67
-6
build.gradle
app/build.gradle
+1
-1
RocketChatApplication.kt
...ain/java/chat/rocket/android/app/RocketChatApplication.kt
+52
-0
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+1
-1
EmojiRepository.kt
...rc/main/java/chat/rocket/android/emoji/EmojiRepository.kt
+13
-4
No files found.
app/build.gradle
View file @
b01c1258
...
...
@@ -16,7 +16,7 @@ android {
applicationId
"chat.rocket.android"
minSdkVersion
versions
.
minSdk
targetSdkVersion
versions
.
targetSdk
versionCode
204
0
versionCode
204
1
versionName
"2.6.0"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled
true
...
...
app/src/main/java/chat/rocket/android/app/RocketChatApplication.kt
View file @
b01c1258
...
...
@@ -13,6 +13,10 @@ import chat.rocket.android.BuildConfig
import
chat.rocket.android.dagger.DaggerAppComponent
import
chat.rocket.android.dagger.injector.HasWorkerInjector
import
chat.rocket.android.dagger.qualifier.ForMessages
import
chat.rocket.android.emoji.Emoji
import
chat.rocket.android.emoji.EmojiRepository
import
chat.rocket.android.emoji.Fitzpatrick
import
chat.rocket.android.emoji.internal.EmojiCategory
import
chat.rocket.android.helper.CrashlyticsTree
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.AccountsRepository
...
...
@@ -20,7 +24,12 @@ import chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
import
chat.rocket.android.server.domain.SITE_URL
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.retryIO
import
chat.rocket.android.util.setupFabric
import
chat.rocket.common.RocketChatException
import
chat.rocket.core.internal.rest.getCustomEmojis
import
com.facebook.drawee.backends.pipeline.DraweeConfig
import
com.facebook.drawee.backends.pipeline.Fresco
import
com.facebook.imagepipeline.core.ImagePipelineConfig
...
...
@@ -30,6 +39,7 @@ import dagger.android.DispatchingAndroidInjector
import
dagger.android.HasActivityInjector
import
dagger.android.HasBroadcastReceiverInjector
import
dagger.android.HasServiceInjector
import
kotlinx.coroutines.experimental.launch
import
timber.log.Timber
import
java.lang.ref.WeakReference
import
javax.inject.Inject
...
...
@@ -68,6 +78,8 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
lateinit
var
localRepository
:
LocalRepository
@Inject
lateinit
var
accountRepository
:
AccountsRepository
@Inject
lateinit
var
factory
:
RocketChatClientFactory
@Inject
@field
:
ForMessages
...
...
@@ -103,6 +115,9 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
// TODO - remove REALM files.
// TODO - remove this
checkCurrentServer
()
// TODO - FIXME - we need to proper inject the EmojiRepository and initialize it properly
loadEmojis
()
}
private
fun
checkCurrentServer
()
{
...
...
@@ -151,6 +166,43 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
return
context
?.
get
()
}
}
// TODO - FIXME - This is a big Workaround
/**
* Load all emojis for the current server. Simple emojis are always the same for every server,
* but custom emojis vary according to the its url.
*/
fun
loadEmojis
()
{
val
currentServer
=
getCurrentServerInteractor
.
get
()
currentServer
?.
let
{
server
->
launch
{
val
client
=
factory
.
create
(
server
)
EmojiRepository
.
setCurrentServerUrl
(
server
)
val
customEmojiList
=
mutableListOf
<
Emoji
>()
try
{
for
(
customEmoji
in
retryIO
(
"getCustomEmojis()"
)
{
client
.
getCustomEmojis
()
})
{
customEmojiList
.
add
(
Emoji
(
shortname
=
":${customEmoji.name}:"
,
category
=
EmojiCategory
.
CUSTOM
.
name
,
url
=
"$currentServer/emoji-custom/${customEmoji.name}.${customEmoji.extension}"
,
count
=
0
,
fitzpatrick
=
Fitzpatrick
.
Default
.
type
,
keywords
=
customEmoji
.
aliases
,
shortnameAlternates
=
customEmoji
.
aliases
,
siblings
=
mutableListOf
(),
unicode
=
""
,
isDefault
=
true
))
}
EmojiRepository
.
load
(
this
@RocketChatApplication
,
customEmojis
=
customEmojiList
)
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
EmojiRepository
.
load
(
this
@RocketChatApplication
as
Context
)
}
}
}
}
}
private
fun
LocalRepository
.
needOldMessagesCleanUp
()
=
getBoolean
(
CLEANUP_OLD_MESSAGES_NEEDED
,
true
)
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
b01c1258
...
...
@@ -59,7 +59,7 @@ class MainPresenter @Inject constructor(
private
val
saveAccountInteractor
:
SaveAccountInteractor
,
private
val
getAccountsInteractor
:
GetAccountsInteractor
,
private
val
removeAccountInteractor
:
RemoveAccountInteractor
,
private
val
factory
:
RocketChatClientFactory
,
factory
:
RocketChatClientFactory
,
private
val
groupedPush
:
GroupedPush
,
dbManagerFactory
:
DatabaseManagerFactory
,
getSettingsInteractor
:
GetSettingsInteractor
,
...
...
emoji/src/main/java/chat/rocket/android/emoji/EmojiRepository.kt
View file @
b01c1258
...
...
@@ -3,11 +3,13 @@ package chat.rocket.android.emoji
import
android.content.Context
import
android.content.SharedPreferences
import
android.graphics.Typeface
import
android.util.Log
import
chat.rocket.android.emoji.internal.EmojiCategory
import
chat.rocket.android.emoji.internal.PREF_EMOJI_RECENTS
import
chat.rocket.android.emoji.internal.db.EmojiDatabase
import
chat.rocket.android.emoji.internal.isCustom
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.GlideException
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.launch
import
kotlinx.coroutines.experimental.withContext
...
...
@@ -110,10 +112,17 @@ object EmojiRepository {
val
px
=
context
.
resources
.
getDimensionPixelSize
(
R
.
dimen
.
custom_emoji_large
)
customEmojis
.
forEach
{
val
future
=
Glide
.
with
(
context
)
.
load
(
it
.
url
)
.
submit
(
px
,
px
)
future
.
get
()
try
{
val
future
=
Glide
.
with
(
context
)
.
load
(
it
.
url
)
.
submit
(
px
,
px
)
future
.
get
()
}
catch
(
ex
:
Exception
)
{
Log
.
d
(
"EmojiRepository"
,
"Error fetching custom emoji ${it.shortname}"
,
ex
)
if
(
ex
is
GlideException
)
{
ex
.
logRootCauses
(
"EmojiRepository"
)
}
}
}
}
}
...
...
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