How to Add Smiley/Emojis in Edittext? - android

How to Add Smiley/Emojis in Edittext?
Any Source code is Available on Internet, if yes Please Give me Link.
Thanks in Advance.

I am using below code for add Smiley/Emojis in edittext.
ImageGetter imageGetter = new ImageGetter() {
public Drawable getDrawable(String source) {
Drawable d = getResources().getDrawable(R.drawable.happy);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return d;
}
};
cs = Html.fromHtml("<img src='" + getResources().getDrawable(R.drawable.happy) + "'/>", imageGetter, null);
edttxtemoji.setText(cs);

Android may not support some special characters, but here is the tutorial anyways:
On a PC, I believe either Alt + 1 or Alt + 2 makes a smiley face.
This website provides an excellent tutorial for how to do alt codes, along with what alt code combination does what.
For a Mac, you can hold "Option + Command + T" down to open a list of special characters. From there, open the category "Miscellaneous." Your smiley is in there.
Is this what you are looking for? If not, just let me know :).
When all else fails, you could just use an image of a smiley-face.
EDIT: I'm using a Mac. I opened TextEdit, followed my above tutorial for the Mac, generated a smiley face, cut the smiley face, and pasted it into the Java code. It worked for me. If it's not working for you, try copying this:
EditText mEditText = null;
mEditText.setText("☺");
EDIT 2: I thought Martin was looking for just a smiley, not a window of Emoji's. Currently, there is no source code to open this window - only a separate app that does this, which can be found at this link or this link.

Related

Animation in vb with wpf

I am working on vb project in visual studio 2015.I need to animate the text "Darkode" from left to right.
I tried the following code which i pulled from the internet,
<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:.8" Storyboard.TargetProperty="Left" From="1920" To="0" AccelerationRatio=".1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
But i didn't understand it Correctly? I need more clarification on the topic.
I had encountered a similar situation where i had to Animate my logo. After searching for hours in the internet i found a solution which was not very useful to me but given your situation (animate a text from left to right) ,it will be more useful to you.
Here is the code :
Private Sub trmText_Timer()
If lblCaption.Caption <> StrCap Then
lblCaption.Caption = Left(StrCap, Len(lblCaption.Caption) + 1)
Else
lblCaption.Caption = ""
End If
End Sub
Here is the source for the code:http://www.setha.info/ict-visualbasic6/72-ict-vb6-0013.html
Here is the link for my qusetion :Animation of words in visual studio
Explanation
Unlike the code you posted in your question which uses storyboard for animation the above code uses Timer control for animation.
In the above code StrCap contains your text darkode and
lblCaption.Caption is an empty string onto which you iterativly put you text charater by charater on each iteration.
Heres a link if you want to know more about timer control :Timer Control

Adobe Air Android / Arabic text issue

i'm using Adobe Flash Air for IOS & Android problem now is the Arabic RTL i can't write arabic.
My
Input Text is Classic not " TLF Text "
The TLF problem is the keyboard not showing up in android..
Example
1) Did you try doing some research? I googled as3 "android" keyboard not showing.
What's wrong with solutions suggested on first page results of the above link?
2) Consider using Stage text and there's an introduction article about it.
3) Try something like below (untested) as a starting point. Hard to fix your code since none shown.
Also read this guide first. Might be useful.
var testInput : TextField = new TextField();
testInput.needsSoftKeyboard = true;
testInput.type = "input";
testInput.addEventListener(FocusEvent.FOCUS_IN, onFocusText);
stage.addChild(testInput);
function onFocusText( e:FocusEvent ):void
{
testInput.requestSoftKeyboard();
}

Android - Shortname to Unicode from Emojione doesn't work

First of all, I don't know whether I should ask this here or in the repo, but as I saw other questions for other libraries like.. Picasso, so here goes :
I'm trying to implement Emojione into my Android app. I've downloaded a small static class to convert all short name to unicode from Emojione Github Repo.
The problem is, when I try to use it to convert :smile: to unicode..
Emojione.shortnameToUnicode(postMessageText, true); // postMessageText is ":smile:"
It always return.. A square, as if it failed to convert. I tried other short names too like :smiley:, :grinning:, but they also failed. :(something): is really a short name right?
The answer is actually in front of my eyes all the time. It really did convert to unicode but, I might be wrong here, in a font unsupported by Android. So I tried using SpannableStringBuilder to span the emoji part to use emojione-android.ttf
Here's how :
int firstEq = sb.length();
Typeface font = FontCache.getTypeface("emojione-android.ttf", context);
String convertPart = Emojione.shortnameToUnicode(part, true);
sb.append(convertPart + " ");
int lastEq = sb.length();
sb.setSpan(new CustomTypefaceSpan("", font), firstEq, lastEq, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
And that's how I got the TextView to show emojis.. Just use the font!

Embedding emoji(emoticons images) to custom softkeyboard android

I have created a custom soft Keyboard(IME) where we can add custom emoji.
Whenever i try to add my emoticons to it. it override the last text entered. i mean it dont append the emoticons unless it override it. how can i add emoji to currentInputConnection
for example
i image write hello image abcimage ///where image represents emoji
it becomes
i image write hello image image
// and i can add image after space easily or i can repeatedly add images easily .
when i add text it appends to emoji but when i add emoji after entering some text it remove the text and then add it self(emoji image).
Just for testing purpose i put emoji code to shift key
Problem code
else if (primaryCode == Keyboard.KEYCODE_SHIFT)
{
// this.handleShift();
//this.mComposing.append(getSmiledText(getApplicationContext(), ":)"));
ImageGetter imageGetter = new ImageGetter()
{
public Drawable getDrawable(String source) {
Drawable d = getResources().getDrawable(R.drawable.e041);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return d;
}
};
Spanned cs = Html.fromHtml("<img src='" + getResources().getDrawable(R.drawable.e041) + "'/>", imageGetter, null);
// getCurrentInputConnection().commitText(cs, 1);
// this.mComposing.append(cs);
//getCurrentInputConnection().commitText(getSmiledText(getApplicationContext(), ":)"), 1);
getCurrentInputConnection().beginBatchEdit();
getCurrentInputConnection().commitText(cs, 1);
getCurrentInputConnection().endBatchEdit();
//getCurrentInputConnection().setComposingText(cs, 1); // it is giving wrong
}
And tried multiple ways to solve it ,some tried codes are shown in comments
Simple Words : I want to append emoji image to text, but when i add image to text, it remove the written text, how can i solve. full source can't be shown it is lengthy. Ask me if you need any method in my class
Related link :
add custom image as Emoji in android
https://stackoverflow.com/questions/24100615/cannot-add-an-image-to-my-keyboard-service
Implementations of Emoji (Emoticon) View/Keyboard Layouts
Thanks in Advance.
I also tried for the same but always got "obj".Atlast I found a solution try this.
Instead of adding drawables just add emoticons by their uniCodes like this..
getCurrentInputConnection().commitText((CharSequence)"\ud83c\udfb5", 1);
Its working for me perfectly.and also remove beginBatchEdit and endBatchEdit from your code.
Thanks

AutoLink link square brackets of URL in TextView

I have a url:
https://<site name>/pallavi/[Songs.PK]%2002%20.mp3
I have a text view, with property: android:autoLink="all"
If I simply set the text to the text view, my text view simply highlights the portion preceding the [. It looks something like this:
https://< site name >/pallavi/[Songs.PK]%2002%20.mp3
What i want is, the whole link should be highlighted like:
https://< site name >/pallavi/[Songs.PK]%2002%20.mp3
What I have tried till now:
Used the < pre > tag and Html.fromHtml, but it doesn't seem to work! (I don't even know if the < pre > is supported in android though.)
Used Jsoup.parser. But that too doesn't seem to work for me.
UPDATE
I have tried this answer too: https://stackoverflow.com/a/12376115/1320263
Please let me know if the issue is with android that the text view's linkAll property itself does not consider parenthesis as a valid character or not? If it is supported, how do i hyperlink that too?
Also NOTE:
The text(or link) I have written in the question is just a sample text. In reality, I am getting a block of text, from where it would be very difficult to identify where exactly the hyper link starts and where it ends. Also, the number of links present in the block would be un-known. Hence I cannot use the < a href = "" > thing...
If some one else happens to have the same issue, following is the solution which worked for me:
Pattern pattern = Pattern.compile("(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))");
SpannableString spannable = new SpannableString(html);
Matcher matcher = pattern.matcher(spannable);
// Create ActivitySpans for each match
while (matcher.find())
spannable.setSpan(new ActivitySpan(matcher.group()), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// Create a new TextView with these spans and enable the clickable links
mTxtEventDescription.setText(spannable);
You can try this:
((TextView) findViewById(R.id.your_text_view)).setMovementMethod(LinkMovementMethod.getInstance());
((TextView) findViewById(R.id.your_text_view)).setText(Html.fromHtml(getResources().getString(R.string.string_with_links)));`

Categories

Resources