A set of components and classes that make it possible to have emoticons in your app. (Image assets and some sources are grabbed from Telegram open source project)
EmojiPanel
: A panel with tabs and list which will be bound to an EditText and insert emoticons in it.EmojiEditText
andEmojiTextView
: Provide automatic conversion of emoji characters to supportedEmojiSpan
sEmojiImageView
: An ImageView which has aemojiCode
property used to set a displaying emoji. Also hasshowSkinColor
which causes a circle to be drawn at bottom right corner of it.EmojiSpan
: AReplacementSpan
used to display our emojis in texts.PagerPanel
: A panel with a ViewPager and tabs to support a panel with multy views shown as pages.
- Simply initialize it with one line (before using any part of the library):
EmojiUtils.initialize(context)
And now you can use the components.
A class called PanelOpenHelper
is made for this purpose. But the area you want to have your panel in it must has the following structure:
<FrameLayout>
<Everything that you want to show.../> nonEmojiContent
<Your Panel/> panel
</FrameLayout>
To get the helper class working correctly, it is important to consider that the parent must be a FrameLayout
and your panel must be a direct child of it. Also your activity's windowSoftInputMode
must be adjustResize
.
Then you can use it like this:
openHelper = PanelOpenHelper(context, theTextToGetFocus, panel, btn_switch, nonEmojiContent, frameParent)
openHelper.panelVisibilityChanged += { _, args -> if (args.isVisible) emojiPanel.updateRecentEmojis() }
btn_switch.setOnClickListener { openHelper.switchPanel() }
//If you want to close the panel when back button is pressed
override fun onBackPressed() {
if (openHelper.isPanelShowing)
openHelper.closePanel()
else
super.onBackPressed()
}