B4A Library msEmoji V1.0.0

msEmoji
Version:
1
  • EmojiEditText
    Fields:
    • ba As BA
    Methods:
    • AddToParent (Parent As ViewGroup, left As Int, top As Int, width As Int, height As Int)
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    Properties:
    • Background As Drawable
    • Backgroundcolor As Int [write only]
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Tag As Object
    • Text As String
    • Textcolor As Int [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • EmojiParser
    Methods:
    • GetEmojiDrawable (DrawableName As String) As Drawable
      Get a Drawable from the Application Resources.
      Returns Null if the Drawable is not found.
    • Initialize (EventName As String)
    • ListEmoji As List
    • demojizedText (text As String) As String
      Return the text with emoticons changed to android code
    • emojiText (text As String) As String
      Parse the text and change emoticons characters to chearsheet characters
      param text
      Input text to be parsed
      returns the Text parsed
  • EmojiTextView
    Fields:
    • ba As BA
    Methods:
    • AddToParent (Parent As ViewGroup, left As Int, top As Int, width As Int, height As Int)
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Tag As Object
    • Text As String [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
This is a wrapper for this Github project.

This Library comes basically with three Objects. All three of them are used in the Example.
EmojiParser, EmojiTextView and EmojiEditText

For the normal work you dont need the EmojiParser. It is only used in the example to get the list of all available Emojis

The Mainobjects are the other two. The EmojiTextview and the EmojiEditText
A Emoji always starts with a [ and ends with a ]. All chars between is the name of the Emoji.

This library is Donationware. You can download the library, you can test the library. But if you want to USE the library in your App you need to Donate for it.
Please click here to donate (You can donate any amount you want to donate for the library (or my work) :)


msEmoji001.png
msEmoji002.png


Due to the size of the needed resources (the example archive is 4mb in size) the Example can be downloaded from my Dropbox.

You can find a overview of all supported Emojis here.

B4X:
    Activity.LoadLayout("Layout1")
    lv.Clear
  Emoji.Initialize("")
    Dim emojilist As List = Emoji.ListEmoji
    For i = 0 To emojilist.Size-1
        Dim s As String = emojilist.Get(i)
        Dim d As BitmapDrawable = Emoji.GetEmojiDrawable(s)
        lv.AddTwoLinesAndBitmap2(s,"Type ["&s&"] to get this Image",d.Bitmap,"["&s&"]")
    Next
 
    lblEmoji.Text = "[de] [uk] [us] [wine_glass] [p1] [see_no_evil] [yellow_heart]"
    edtEmoji.Backgroundcolor = Colors.White
    edtEmoji.Text = "[de][uk][us] Donate much [dollar] [grin] [heart_eyes]"
    edtEmoji.Textcolor = Colors.Black
 

Attachments

  • libmsEmojiV1.0.0.zip
    37.5 KB · Views: 687
Last edited:

lymey

Active Member
Licensed User
Longtime User
This is really good!

However is it possible to add .SelectionStart like the standard EditText?

At the moment it isnt possible to edit the text/insert an emoji other than at the end.
 

DonManfred

Expert
Licensed User
Longtime User
However is it possible to add .SelectionStart like the standard EditText?
Sadly: no... I´m just doing a VIEW-WRAPPER... The view does not expose such methods. Due to this there is nothing i could wrap.
At the moment it isnt possible to edit the text/insert an emoji other than at the end.
You can touch the edit to set the curso to a specific position and then press BACK or enter an new emoji. I can add an emoji this way manually to the first position (or any other) without problem. But you can not do this programatically.
 

lymey

Active Member
Licensed User
Longtime User
You can touch the edit to set the curso to a specific position and then press BACK or enter an new emoji. I can add an emoji this way manually to the first position (or any other) without problem.

When I try this (using your sample app), it just adds the emoji to the end of the text rather than at the position the cursor is. When I try inserting text, it inserts the text.

I'm using a Moto G with KitKat.
 

lymey

Active Member
Licensed User
Longtime User
Aaah...so you can't insert into text from a list - only by typing [emoji name?
You can only add an emoji from a list to the 'end' of the text?

Try this using your example - position the cursor anywhere (but the last position), select a an emoji from your list - the emoji is appended to the text, not inserted in the cursor position.
 

DonManfred

Expert
Licensed User
Longtime User
Now i understand you.
Look at the itemclick event. I put the clicked item always to the END...
B4X:
Sub lv_ItemClick (Position As Int, Value As Object)
    edtEmoji.Text = edtEmoji.Text & Value
End Sub

you can use

B4X:
Sub lv_ItemClick (Position As Int, Value As Object)
    edtEmoji.Text = Value & edtEmoji.Text
End Sub
to add it to the start
 

lymey

Active Member
Licensed User
Longtime User
You also can change the string
Code:
Log(Emoji.demojizedText(edtEmoji.Text))
and add an emoji at any place and then put back the new text to the edit

Can you explain the difference between 'demojizedText' and 'emojiText'? They return the same values:

B4X:
Log("dmojized: " & Emoji.demojizedText(edtEmoji.Text))
    Log("emojitext: " & Emoji.emojiText(edtEmoji.Text))

dmojized: [de][uk][us] Donatemuch [dollar] [grin] [heart_eyes][pizza][pizza]
emojitext: [de][uk][us] Donatemuch [dollar] [grin] [heart_eyes][pizza][pizza]

I am trying to find a way for a user to position the cursor in the edit box and insert an emoji
 

jotaele

Member
Licensed User
Longtime User
Hi

I tried to port this library but it was imposible for me. I was reading a lot of info in the forum, but my knowlegment is not enought.

Take a look

https://github.com/rockerhieu/emojicon

This library contains a lot of functions that could be interesting like a keyboard like whatsapp.

Its only a comment. :)
 

jotaele

Member
Licensed User
Longtime User
It´s nothing more than a grid showing emojs..

Take a panel, put a lot of emojlabels with each one emoj on it on this panel and make them clickable...

B4X:
lblEmoji.Text = "[de]"

Ok. I will try to do an panel and extend your library.

----EDITED----

Sorry, but I'm going to ask for advice on the type of GRID to use. I've seen libraries , classes, etc. , and if you can advise me I'd appreciate it.

I think that this can be the best option, but I ask for your opinion:

https://www.b4x.com/android/forum/threads/grid-table-and-listview-library.16381/

Thanks

----END EDITION----

I undestood you.

I started to do the virtual grid, only with the coordinates, and with a transparent mask (button with transparent color) for the click event Its working well.

In a future, I will post the code if anyone wants a keyboard with icons like whatsapp.

I am resolving the same issue like @lymey with text position. Its very annoying loose the position when an icon is inserted in the emojiedittext.

I think that is imposible to fix because the emojiedittext has no method to get or set the position.

Thanks
 
Last edited:

jotaele

Member
Licensed User
Longtime User
Ok. I will try to do an panel and extend your library.

----EDITED----

Sorry, but I'm going to ask for advice on the type of GRID to use. I've seen libraries , classes, etc. , and if you can advise me I'd appreciate it.

I think that this can be the best option, but I ask for your opinion:

https://www.b4x.com/android/forum/threads/grid-table-and-listview-library.16381/

Thanks

----END EDITION----

I undestood you.

I started to do the virtual grid, only with the coordinates, and with a transparent mask (button with transparent color) for the click event Its working well.

In a future, I will post the code if anyone wants a keyboard with icons like whatsapp.

I am resolving the same issue like @lymey with text position. Its very annoying loose the position when an icon is inserted in the emojiedittext.

I think that is imposible to fix because the emojiedittext has no method to get or set the position.

Thanks

Hi @DonManfred:

I have a question about wrap a library.

I was reading the github of the wrapped library and the EmojiEditText object extends EditText object.

I have no idea than inheritance in the wrapped libraries, but the EditText object has methods to obtain the position. I think that the EmojiEditText can inherit them, isn't it?

Thanks
 
Top