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
8ee1100c
Commit
8ee1100c
authored
Aug 07, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Query custom emojis by current url prefix in order to contemplate multiple servers
parent
37073556
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
1 deletion
+37
-1
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+5
-0
EmojiDao.kt
emoji/src/main/java/chat/rocket/android/emoji/EmojiDao.kt
+3
-0
EmojiRepository.kt
...rc/main/java/chat/rocket/android/emoji/EmojiRepository.kt
+21
-0
EmojiPagerAdapter.kt
...a/chat/rocket/android/emoji/internal/EmojiPagerAdapter.kt
+8
-1
No files found.
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
8ee1100c
...
@@ -125,8 +125,13 @@ class MainPresenter @Inject constructor(
...
@@ -125,8 +125,13 @@ class MainPresenter @Inject constructor(
}
}
}
}
/**
* 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
()
{
fun
loadEmojis
()
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
EmojiRepository
.
setCurrentServerUrl
(
currentServer
)
val
customEmojiList
=
mutableListOf
<
Emoji
>()
val
customEmojiList
=
mutableListOf
<
Emoji
>()
try
{
try
{
for
(
customEmoji
in
retryIO
(
"getCustomEmojis()"
)
{
client
.
getCustomEmojis
()
})
{
for
(
customEmoji
in
retryIO
(
"getCustomEmojis()"
)
{
client
.
getCustomEmojis
()
})
{
...
...
emoji/src/main/java/chat/rocket/android/emoji/EmojiDao.kt
View file @
8ee1100c
...
@@ -25,6 +25,9 @@ interface EmojiDao {
...
@@ -25,6 +25,9 @@ interface EmojiDao {
@Query
(
"SELECT * FROM emoji WHERE UPPER(category)=UPPER(:category)"
)
@Query
(
"SELECT * FROM emoji WHERE UPPER(category)=UPPER(:category)"
)
fun
loadEmojisByCategory
(
category
:
String
):
List
<
Emoji
>
fun
loadEmojisByCategory
(
category
:
String
):
List
<
Emoji
>
@Query
(
"SELECT * FROM emoji WHERE UPPER(category)=UPPER(:category) AND url LIKE :url"
)
fun
loadEmojisByCategoryAndUrl
(
category
:
String
,
url
:
String
):
List
<
Emoji
>
@Insert
(
onConflict
=
IGNORE
)
@Insert
(
onConflict
=
IGNORE
)
fun
insertEmoji
(
emoji
:
Emoji
)
fun
insertEmoji
(
emoji
:
Emoji
)
...
...
emoji/src/main/java/chat/rocket/android/emoji/EmojiRepository.kt
View file @
8ee1100c
...
@@ -31,6 +31,15 @@ object EmojiRepository {
...
@@ -31,6 +31,15 @@ object EmojiRepository {
private
lateinit
var
preferences
:
SharedPreferences
private
lateinit
var
preferences
:
SharedPreferences
internal
lateinit
var
cachedTypeface
:
Typeface
internal
lateinit
var
cachedTypeface
:
Typeface
private
lateinit
var
db
:
EmojiDatabase
private
lateinit
var
db
:
EmojiDatabase
private
lateinit
var
currentServerUrl
:
String
fun
setCurrentServerUrl
(
url
:
String
)
{
currentServerUrl
=
url
}
fun
getCurrentServerUrl
():
String
?
{
return
if
(
::
currentServerUrl
.
isInitialized
)
currentServerUrl
else
null
}
fun
load
(
context
:
Context
,
customEmojis
:
List
<
Emoji
>
=
emptyList
(),
path
:
String
=
"emoji.json"
)
{
fun
load
(
context
:
Context
,
customEmojis
:
List
<
Emoji
>
=
emptyList
(),
path
:
String
=
"emoji.json"
)
{
launch
(
CommonPool
)
{
launch
(
CommonPool
)
{
...
@@ -141,6 +150,18 @@ object EmojiRepository {
...
@@ -141,6 +150,18 @@ object EmojiRepository {
}
}
}
}
internal
suspend
fun
getEmojiSequenceByCategoryAndUrl
(
category
:
EmojiCategory
,
url
:
String
):
Sequence
<
Emoji
>
{
val
list
=
withContext
(
CommonPool
)
{
db
.
emojiDao
().
loadEmojisByCategoryAndUrl
(
category
.
name
,
"$url%"
)
}
return
buildSequence
{
list
.
forEach
{
yield
(
it
)
}
}
}
/**
/**
* Get the emoji given by a specified shortname. Returns null if can't find any.
* Get the emoji given by a specified shortname. Returns null if can't find any.
*
*
...
...
emoji/src/main/java/chat/rocket/android/emoji/internal/EmojiPagerAdapter.kt
View file @
8ee1100c
...
@@ -45,8 +45,15 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
...
@@ -45,8 +45,15 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
container
.
addView
(
view
)
container
.
addView
(
view
)
launch
(
UI
)
{
launch
(
UI
)
{
val
currentServerUrl
=
EmojiRepository
.
getCurrentServerUrl
()
val
emojis
=
if
(
category
!=
EmojiCategory
.
RECENTS
)
{
val
emojis
=
if
(
category
!=
EmojiCategory
.
RECENTS
)
{
if
(
category
==
EmojiCategory
.
CUSTOM
)
{
currentServerUrl
?.
let
{
url
->
EmojiRepository
.
getEmojiSequenceByCategoryAndUrl
(
category
,
url
)
}
?:
emptySequence
()
}
else
{
EmojiRepository
.
getEmojiSequenceByCategory
(
category
)
EmojiRepository
.
getEmojiSequenceByCategory
(
category
)
}
}
else
{
}
else
{
sequenceOf
(*
EmojiRepository
.
getRecents
().
toTypedArray
())
sequenceOf
(*
EmojiRepository
.
getRecents
().
toTypedArray
())
}
}
...
...
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