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
cfcc4f62
Commit
cfcc4f62
authored
Jul 20, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add different view type to custom emojis, since they need to be displayed on a ImageView
parent
37b86ee9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
11 deletions
+56
-11
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+1
-2
build.gradle
emoji/build.gradle
+2
-0
proguard-rules.pro
emoji/proguard-rules.pro
+9
-0
EmojiPagerAdapter.kt
...a/chat/rocket/android/emoji/internal/EmojiPagerAdapter.kt
+29
-9
emoji_image_row_item.xml
emoji/src/main/res/layout/emoji_image_row_item.xml
+14
-0
emoji_row_item.xml
emoji/src/main/res/layout/emoji_row_item.xml
+1
-0
No files found.
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
cfcc4f62
...
@@ -126,7 +126,7 @@ class MainPresenter @Inject constructor(
...
@@ -126,7 +126,7 @@ class MainPresenter @Inject constructor(
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
val
customEmojiList
=
mutableListOf
<
Emoji
>()
val
customEmojiList
=
mutableListOf
<
Emoji
>()
try
{
try
{
for
(
customEmoji
in
client
.
getCustomEmojis
()
)
{
for
(
customEmoji
in
retryIO
(
"getCustomEmojis()"
)
{
client
.
getCustomEmojis
()
}
)
{
customEmojiList
.
add
(
Emoji
(
customEmojiList
.
add
(
Emoji
(
shortname
=
":${customEmoji.name}:"
,
shortname
=
":${customEmoji.name}:"
,
category
=
EmojiCategory
.
CUSTOM
.
name
,
category
=
EmojiCategory
.
CUSTOM
.
name
,
...
@@ -138,7 +138,6 @@ class MainPresenter @Inject constructor(
...
@@ -138,7 +138,6 @@ class MainPresenter @Inject constructor(
siblings
=
mutableListOf
(),
siblings
=
mutableListOf
(),
unicode
=
""
unicode
=
""
))
))
}
}
EmojiRepository
.
load
(
view
as
Context
,
customEmojis
=
customEmojiList
)
EmojiRepository
.
load
(
view
as
Context
,
customEmojis
=
customEmojiList
)
...
...
emoji/build.gradle
View file @
cfcc4f62
...
@@ -34,6 +34,8 @@ dependencies {
...
@@ -34,6 +34,8 @@ dependencies {
implementation
libraries
.
constraintlayout
implementation
libraries
.
constraintlayout
implementation
libraries
.
recyclerview
implementation
libraries
.
recyclerview
implementation
libraries
.
material
implementation
libraries
.
material
implementation
'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor
'com.github.bumptech.glide:compiler:4.7.1'
}
}
kotlin
{
kotlin
{
...
...
emoji/proguard-rules.pro
View file @
cfcc4f62
...
@@ -19,3 +19,12 @@
...
@@ -19,3 +19,12 @@
#
If
you
keep
the
line
number
information
,
uncomment
this
to
#
If
you
keep
the
line
number
information
,
uncomment
this
to
#
hide
the
original
source
file
name
.
#
hide
the
original
source
file
name
.
#-
renamesourcefileattribute
SourceFile
#-
renamesourcefileattribute
SourceFile
-
keep
public
class
*
implements
com
.
bumptech
.
glide
.
module
.
GlideModule
-
keep
public
class
*
extends
com
.
bumptech
.
glide
.
module
.
AppGlideModule
-
keep
public
enum
com
.
bumptech
.
glide
.
load
.
ImageHeaderParser
$
**
{
**
[]
$
VALUES
;
public
*
;
}
#
for
DexGuard
only
-
keepresourcexmlelements
manifest
/
application
/
meta
-
data
@
value
=
GlideModule
emoji/src/main/java/chat/rocket/android/emoji/internal/EmojiPagerAdapter.kt
View file @
cfcc4f62
...
@@ -14,7 +14,10 @@ import chat.rocket.android.emoji.EmojiParser
...
@@ -14,7 +14,10 @@ import chat.rocket.android.emoji.EmojiParser
import
chat.rocket.android.emoji.EmojiRepository
import
chat.rocket.android.emoji.EmojiRepository
import
chat.rocket.android.emoji.Fitzpatrick
import
chat.rocket.android.emoji.Fitzpatrick
import
chat.rocket.android.emoji.R
import
chat.rocket.android.emoji.R
import
com.bumptech.glide.Glide
import
com.bumptech.glide.request.RequestOptions
import
kotlinx.android.synthetic.main.emoji_category_layout.view.*
import
kotlinx.android.synthetic.main.emoji_category_layout.view.*
import
kotlinx.android.synthetic.main.emoji_image_row_item.view.*
import
kotlinx.android.synthetic.main.emoji_row_item.view.*
import
kotlinx.android.synthetic.main.emoji_row_item.view.*
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.android.UI
import
kotlinx.coroutines.experimental.android.UI
...
@@ -88,6 +91,8 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
...
@@ -88,6 +91,8 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
private
val
listener
:
EmojiKeyboardListener
private
val
listener
:
EmojiKeyboardListener
)
:
RecyclerView
.
Adapter
<
EmojiRowViewHolder
>()
{
)
:
RecyclerView
.
Adapter
<
EmojiRowViewHolder
>()
{
private
val
TYPE_CUSTOM
=
1
private
val
TYPE_NORMAL
=
2
private
val
emojis
=
mutableListOf
<
Emoji
>()
private
val
emojis
=
mutableListOf
<
Emoji
>()
fun
addEmojis
(
emojis
:
List
<
Emoji
>)
{
fun
addEmojis
(
emojis
:
List
<
Emoji
>)
{
...
@@ -96,6 +101,10 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
...
@@ -96,6 +101,10 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
notifyDataSetChanged
()
notifyDataSetChanged
()
}
}
override
fun
getItemViewType
(
position
:
Int
):
Int
{
return
if
(
emojis
[
position
].
url
!=
null
)
TYPE_CUSTOM
else
TYPE_NORMAL
}
suspend
fun
addEmojisFromSequence
(
emojiSequence
:
Sequence
<
Emoji
>)
{
suspend
fun
addEmojisFromSequence
(
emojiSequence
:
Sequence
<
Emoji
>)
{
withContext
(
CommonPool
)
{
withContext
(
CommonPool
)
{
emojiSequence
.
forEachIndexed
{
index
,
emoji
->
emojiSequence
.
forEachIndexed
{
index
,
emoji
->
...
@@ -120,7 +129,11 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
...
@@ -120,7 +129,11 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
}
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
EmojiRowViewHolder
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
EmojiRowViewHolder
{
val
view
=
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
emoji_row_item
,
parent
,
false
)
val
view
=
if
(
viewType
==
TYPE_CUSTOM
)
{
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
emoji_image_row_item
,
parent
,
false
)
}
else
{
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
emoji_row_item
,
parent
,
false
)
}
return
EmojiRowViewHolder
(
view
,
listener
)
return
EmojiRowViewHolder
(
view
,
listener
)
}
}
...
@@ -134,16 +147,23 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
...
@@ -134,16 +147,23 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
fun
bind
(
emoji
:
Emoji
)
{
fun
bind
(
emoji
:
Emoji
)
{
with
(
itemView
)
{
with
(
itemView
)
{
val
parsedUnicode
=
unicodeCache
[
emoji
.
unicode
]
if
(
emoji
.
unicode
.
isNotEmpty
())
{
emoji_view
.
setSpannableFactory
(
spannableFactory
)
val
parsedUnicode
=
unicodeCache
[
emoji
.
unicode
]
emoji_view
.
text
=
if
(
parsedUnicode
==
null
)
{
emoji_view
.
setSpannableFactory
(
spannableFactory
)
EmojiParser
.
parse
(
emoji
.
unicode
,
spannableFactory
).
let
{
emoji_view
.
text
=
if
(
parsedUnicode
==
null
)
{
unicodeCache
[
emoji
.
unicode
]
=
it
EmojiParser
.
parse
(
emoji
.
unicode
,
spannableFactory
).
let
{
it
unicodeCache
[
emoji
.
unicode
]
=
it
it
}
}
else
{
parsedUnicode
}
}
}
else
{
}
else
{
parsedUnicode
Glide
.
with
(
context
)
.
load
(
emoji
.
url
)
.
into
(
emoji_image_view
)
}
}
itemView
.
setOnClickListener
{
itemView
.
setOnClickListener
{
listener
.
onEmojiAdded
(
emoji
)
listener
.
onEmojiAdded
(
emoji
)
}
}
...
@@ -155,4 +175,4 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
...
@@ -155,4 +175,4 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
private
val
unicodeCache
=
mutableMapOf
<
CharSequence
,
CharSequence
>()
private
val
unicodeCache
=
mutableMapOf
<
CharSequence
,
CharSequence
>()
}
}
}
}
}
}
\ No newline at end of file
emoji/src/main/res/layout/emoji_image_row_item.xml
0 → 100644
View file @
cfcc4f62
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"48dp"
android:layout_height=
"48dp"
android:layout_gravity=
"center"
>
<ImageView
android:id=
"@+id/emoji_image_view"
android:layout_width=
"32dp"
android:layout_height=
"32dp"
android:layout_gravity=
"center"
tools:src=
"@tools:sample/avatars"
/>
</FrameLayout>
emoji/src/main/res/layout/emoji_row_item.xml
View file @
cfcc4f62
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
android:layout_width=
"48dp"
android:layout_width=
"48dp"
android:layout_height=
"48dp"
android:layout_height=
"48dp"
android:foreground=
"?selectableItemBackground"
android:foreground=
"?selectableItemBackground"
android:gravity=
"center"
android:textColor=
"#000000"
android:textColor=
"#000000"
android:textSize=
"26sp"
android:textSize=
"26sp"
tools:text=
"😀"
/>
tools:text=
"😀"
/>
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