Using Emoticons in Android - android

I am setting text on a TextView. Text is getting fetched from an EditText. I am able to see all the text that i type in EditText***(Including Emotions/Emojis)***
Then can someone please explain why do we have Emoticons Library in Android ? I did not include any library in my gradle file. Still it works fine. I see all emojis typed in EditText finally in my TextView

The EmojiCompat support library aims to keep Android devices up to date with the latest emoji. It prevents your app from showing missing emoji characters in the form of ☐, which indicates that your device does not have a font to display the text. By using the EmojiCompat support library, your app users do not need to wait for Android OS updates to get the latest emoji.
For more information, you can check this site.
Click here

The EmojiCompat support library aims to keep Android devices up to date with the latest emoji. It prevents your app from showing missing emoji characters in the form of ☐, which indicates that your device does not have a font to display the text. By using the EmojiCompat support library, your app users do not need to wait for Android OS updates to get the latest emoji.
https://developer.android.com/guide/topics/ui/look-and-feel/emoji-compat.html
So basically if your device supports all new Emojis, you should have no problem rendering those - even without the library.

Related

How to detect and replace unsupported emoji?

There is a chat software that is supported on Android versions ranging from 4.0 to 6.0. iOS is supported too. Recently we've introduced option to use system emojis. However, when someone with latest Android, or iOS, sends message containing latest emoji, the older device can't display it properly.
Is there a way to detect those emojis that can't be displayed? We want to replace those with some symbol (eg. an empty box or exclamation mark)
Get the system stock emojis Emojis - Unicode - Bytes.
Then search the recieved message, if you found some code that it's in your android version emojis diplay it, if not add the symbol you want.
Following the comments you can test it with this
Typeface typeface;
//initialize the custom font here
//enter the character to test
String charToTest="\u0978";
Paint paint=new Paint();
paint.setTypeface(typeface);
boolean hasGlyph=paint.hasGlyph(charToTest);
please check the source code from Googles Mozc project. The EmojiRenderableChecker class seems to work pretty well!
it's like a compat version for Paint.hasGlypgh (added in Marshmallow).

Adding images to EditText from Custom IME

I'm working on a custom keyboard for Android, and I'm running into a problem. I need to either be able to output ASCII characters from the keyboard (i.e. ∅, ⌲, ⌓, etc), or be able to add images to the selected EditText from my keyboard. I know this is possible because Emoji does it with their keyboard. They have found a way to add images to any EditText, whether they created the EditText or not.
Does anyone have any idea how they accomplished this?
After many hours of pouring over blogs, Stackoverflow, and the rest of the internet, I've discovered that it's essentially impossible to add a custom image to an EditText unless you own that EditText.
All was not lost however. After looking through documentations on UTF-8, ASCII, and other character sets, I've discovered that all the characters I needed were in UTF-8. I simply output the unicode value using:
InputConnection inputConnection = getCurrentInputConnection();
inputConnection.commitText(text, 1);
and it correctly appears in the EditText. All the characters being added by other keyboards (i.e. stock Android, Emoji, etc.) appear in the UTF-8 character set.
I came across this thread during some research and ended up elsewhere. Yes it is now possible to send images/GIF's to EditText's via a custom IME using the new CommitContent API introduced in 7.1 with backward compatibility till API level 13 - Honeycomb.
Quote from :
https://developer.android.com/guide/topics/text/image-keyboard.html#how_it_works
With Android 7.1 (API level 25), the Android SDK includes the Commit
Content API, which provides a universal way for IMEs to send images
and other rich content directly to a text editor in an app. The API is
also available in v13 Support Library as of revision 25.0.0. We
recommend using the Support Library because it runs on devices as
early as Android 3.2 (API Level 13), and it contains helper methods
that simplify implementation.
I tested this with the latest update of hangouts and it works!.
Sample code here: https://developer.android.com/about/versions/nougat/android-7.1-samples.html#img-kbd-ime
I have merged the main app and the IME app code to a single project and here it is : https://github.com/satheeshwaran/ImageKeyboard-Android/tree/master
UPDATE:
I have published two apps using this API and I think they are doing good,
https://play.google.com/store/apps/details?id=com.theweekendparty.indianmemekeyboard
https://play.google.com/store/apps/details?id=com.theweekendparty.indiangifboardbollywood
Use CompoundDrawables to add images to your EditText. You can add them through XML by android:drawableBottom android:drawableRight android:drawableLeft android:drawableTop. You can also use Spannables for displaying images inline with text inside EditText. See here Spannables and here Displaying emoticons in Android.

Last Harka is showing before the first character of the line in Arabic Reshaper on Android

I am using this Amazing Arabic Reshaper for my app on Android, Every thing works fine, but there is a little problem with it that it always shows last Harka (Harki) before the first character of the line in Android, I have also tried gravity right etc
It works fine for Android version greater 2.3.3, as this is a right to left language I dont understand why its not working fine on Android versions less then 2.3.3 you can see the image below for better understanding.
I also tried that I moved the last Harka to the first character of the line, it works fine for first line only BUT on the after that same issue comes. Kindly help me regarding this issue.
It seems that the reason of this is the Bidi rules; when you mix letters and symbols the last symbol does not follow the sentence direction unless it is between two letters. That's why you are getting it only with the last Haraka.
For Android versions that support bidi natively, you should not use the Arabic reshaper library. Only use it for Android versions that does not connect Arabic letters properly. You can add an option in your application where the user decides weather or not Arabic letters are displayed properly.
Alternatively, you can have in your application an exhaustive list of Android version and weather or not it supports Bidi natively, so you automatically decide when to use the Arabic reshaper.

Android Custom font shows up blank on some phones

I'm using a custom font for a Japanese quiz app on Android. I tried it on a friend's phone at a cookout, and the font did not show up (it shows up on mine and others). The font is delivered with the apk. I don't have access to the logcat, and unfortunately forgot to check the phone model, although I think it's kind of a budget version. Has anyone had this problem this, or have any ideas what might cause it?
well, if you use delivered font with APK and got unexpected results, its generally rendering issue with Android system .. with other words, Android System cannot render all characters correctly. you need to know that earlier versions of Android don't support all Unicodes as well as later but off cause with more supported characters . if you want to test that on emulator, try to test your app with version 1.6.
I got similar issue with Arabic characters ..
I can help you with those guides:
1- try to check the characters you are using, and be away from rare characters.
2- try a different common font if its available.
3- If you built your own font, try to rebuild it again and use supported ID of glyphes. as I told you Android doesn't support all Unicode characters (supports based on ID). and its different from version to another.
4- check and detect unsupported characters ( you can do that by measuring length of character and compare it with pre-measured length of that character) then insert it as image with suitable dimension.
5-you can use webview instead of TextView/EditText ..
I hope that will help you ..
good luck,

Are all the Unicode characters supported on Android

My question is simple. Are all Unicode characters available in Android?
I actually am using the soft keyboard and I want to add a few arabic letters which I can't find the codes for.
Android supports UTF-8 but you will not be able to use arabic, if it's not installed in your OS. There are ways to install new fonts, but some of them needs jailbreaking your phone.
See link for installing font in Android:
https://web.archive.org/web/20091023103506/http://www.android-devs.com/?p=33
It does not appear so. This open issue on the android code site lists many missing characters.
add font (.ttf) containing characters to /system/fonts, modify /system/etc/fallback_fonts.xml so android finds font then reboot. Everything should be working now

Categories

Resources