SlideShare a Scribd company logo
1 of 43
Download to read offline
@Miqubel
No More □ (tofu)   
Mastering Emoji on Android
Why Emoji matters?
What problems do Android developers face?
What solutions do we have?
Is EmojiCompat the greatest thing ever?
Emoji: A Brief Story
Source: https://stories.moma.org/the-original-emoji-set-has-been-added-to-the-museum-of-modern-arts-collection-c6060e141f61
Emoji & Android
Source: https://www.androidcentral.com/history-emoji-android
How to be up to date: DIY
Emotions
Source: People interpret the same emoji in completely different ways
https://www.theverge.com/2016/4/11/11406944/emoji-meaning-difference-ios-android
How Emoji Works
Extra-short-intro to Unicode
Hello
U+0048 U+0065 U+006C U+006C U+006F
Unicode: Single character set that contains ALL characters of the Universe
Each character maps to a Codepoint
A Codepoint may be represented in memory differently!
Codepoint UTF-8 UTF-16
H U+0048 48 0048
😂 U+1F602 F0 9F 98 82 D83D DE02
How Emoji works
Emoji: Graphic representation of one or more Unicode chars (Codepoints)
"Face With Tears of Joy” U+1F602
val emoji = "uD83DuDE02"
How Emoji works
“Woman Technologist: Medium-Dark Skin Tone”
val emoji = “uD83DuDC69uD83CuDFFEu200DuD83DuDCBB"
👩 U+1F469
🏾 U+1F3FE
U+200D
💻 U+1F4BB
How long is an Emoji?
Challenge: How many “Woman Technologist: Medium-Dark Skin Tone”
Emojis can you fit on a Tweet?
A: 280
B: 140
C: 40
Solution: 40
🤔🤔🤔🤔🤔🤔🤔🤔
280 / 7 = 40
How long is an Emoji? —> Improvement
emoji.length = 7
emoji.codePointCount(0, emoji.length) = 4
val emoji = “uD83DuDC69uD83CuDFFEu200DuD83DuDCBB"
How long is an Emoji? —> Improvement
val it = BreakIterator.getCharacterInstance()
it.setText(emoji)
var count = 0
while (it.next() != BreakIterator.DONE) {
count++
} count = 3 on API 23
count = 1 on API 25
Challenges so far
Missing Emoji (tofu)
Different Emoji per platform
Length of strings with Emoji
Let’s look at three solutions
Custom solution: Images and Spans
Custom solution: Font file
Using EmojiCompat
Images and Spans
Strategy:
1. Find an Emoji on a String
2. Replace with an ImageSpan
3. Repeat for the whole String
Finding Emoji on Strings
Get a nice dictionary: EmojiOne “emoji.json”: 1.38 MB!
Fast JSON parsing: com.jsoniter —> but you won’t need to 😉
Efficient pattern matching —> Regular Expression
Emoji assets
Download: emojione/emojione-assets
• Free: PNG 32px, 64px, 128px
• Paid: SVG and larger PNG
Example: SLICE OF PIZZA (U+1F355) —> 1f355.png
Matching and displaying
val PATTERN = “ud83cudf55".toRegex()
val matches = PATTERN.findAll(text)
for (match in matches) {
spannableString.setSpan(
ImageSpan(context, R.drawable.emoji_1f355),
match.range.start,
match.range.endInclusive + 1,
SpannableString.SPAN_INCLUSIVE_INCLUSIVE
)
}
Solution: DynamicDrawableSpan (and resize the drawable)
Images and Spans
Pros:
😌 Freedom
Cons:
😟 Lots of manual work needed
😟 APK size (4000 PNGs…)
Custom font file
Strategy:
1. Include font file with Emoji
2. Set font file containing Emoji to TextView
3. Set text to TextView
Custom font file: Setup
1. Download Android font
2. Place in assets/fonts
Download: https://www.emojione.com/download
Custom font file: Setup
val typeface = Typeface.createFromAsset(assets,
“fonts/emojione.ttf”)
textView.typeface = typeface
textView.text = string
Custom font file: Results
Custom font file: Hold on…
textView.text = "Numbers: 1 2 3 4"
Solution: Parse Emoji and create TypefaceSpans
Custom Font: Better but…
Pros:
😌 Easy to setup
Cons:
😟 Manual work needed
EmojiCompat
Strategy:
— Process Strings with EmojiCompat
or
— Use EmojiTextView
EmojiCompat: Setup (bundled)
implementation “com.android.support:support-emoji:x.y.z”
implementation “com.android.support:support-emoji-bundled:x.y.z”
Adds: 7.4 MB
EmojiCompat: Setup (downloadable)
val fontRequest = FontRequest(
"com.google.android.gms.fonts",
"com.google.android.gms",
"Noto Color Emoji Compat",
R.array.com_google_android_gms_fonts_certs)
val config = FontRequestEmojiCompatConfig(this, fontRequest)
EmojiCompat.init(config)
Init takes 150 ms! But happens asynchronously
EmojiCompat: Setup (downloadable)
Downloadable fonts get updated automatically!
EmojiCompat: Setup (downloadable)
Source: https://github.com/googlei18n/noto-emoji
EmojiCompat: Setup (downloadable)
Downloadable fonts get updated automatically!
Find it in data/data/com.google.android.gms/files/fonts/opentype
Noto_Color_Emoji_Compat-400-100_0-0_0.ttf
Version 2.003;GOOG;noto-emoji:20171030:a5efe6ca61db
EmojiCompat: Using it
textView.text = EmojiCompat.get().process(string)
EmojiCompat: Using it
EmojiCompat: Replace All
val config = FontRequestEmojiCompatConfig(…)
config.setReplaceAll(true)
EmojiCompat.init(config)
EmojiCompat: Handling init delay
EmojiCompat.get().registerInitCallback(object :
EmojiCompat.InitCallback() {
override fun onInitialized() {
textView.text = EmojiCompat.get().process(string)
}
override fun onFailed(throwable: Throwable?) {
// handle error?
textView.text = string
}
}
)
EmojiCompat: Using the Views
<android.support.text.emoji.widget.EmojiTextView/>
<android.support.text.emoji.widget.EmojiEditText/>
<android.support.text.emoji.widget.EmojiButton/>
EmojiCompat: Easy!
Wishlist
😇 Customize it
😇 Emoji Keyboard
😇 Emoji tools
Thank you!
Miquel Beltran - @Miqubel

More Related Content

Similar to No More Tofu - Mastering Emoji On Android

IRJET- Dynamic Emotion Recognition and Emoji Generation
IRJET- Dynamic Emotion Recognition and Emoji GenerationIRJET- Dynamic Emotion Recognition and Emoji Generation
IRJET- Dynamic Emotion Recognition and Emoji GenerationIRJET Journal
 
Smile, Wink and Pray: Can Emojis Increase your Email Open Rate? (New Research)
Smile, Wink and Pray: Can Emojis Increase your Email Open Rate? (New Research)Smile, Wink and Pray: Can Emojis Increase your Email Open Rate? (New Research)
Smile, Wink and Pray: Can Emojis Increase your Email Open Rate? (New Research)dlvr.it
 
Apple Responds To Emoji Diversity Problem
Apple Responds To Emoji Diversity ProblemApple Responds To Emoji Diversity Problem
Apple Responds To Emoji Diversity Problemjoey parker
 
Future of the Web with Conversational Interface
Future of the Web with Conversational InterfaceFuture of the Web with Conversational Interface
Future of the Web with Conversational InterfaceTomomi Imura
 
Designing a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDesigning a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDroidConTLV
 
Unicode and Legacy Representations of Emoji (IUC 36)
Unicode and Legacy Representations of Emoji (IUC 36)Unicode and Legacy Representations of Emoji (IUC 36)
Unicode and Legacy Representations of Emoji (IUC 36)David Yonge-Mallo
 
Ubercool, pixel perfct & slick design… that just doesn't work
Ubercool, pixel perfct & slick design… that just doesn't workUbercool, pixel perfct & slick design… that just doesn't work
Ubercool, pixel perfct & slick design… that just doesn't workSamuel Bednar
 
SocialCaddy: "Clash of the Titans: Erlang Clusters and Google AppEngine"
SocialCaddy: "Clash of the Titans: Erlang Clusters  and Google AppEngine"SocialCaddy: "Clash of the Titans: Erlang Clusters  and Google AppEngine"
SocialCaddy: "Clash of the Titans: Erlang Clusters and Google AppEngine"SocialCaddy
 
Best Practice iPhone SDK App Design
Best Practice iPhone SDK App DesignBest Practice iPhone SDK App Design
Best Practice iPhone SDK App DesignBess Ho
 
Applied Machine Learning for Chemistry I (HSI2020)
Applied Machine Learning for Chemistry I (HSI2020)Applied Machine Learning for Chemistry I (HSI2020)
Applied Machine Learning for Chemistry I (HSI2020)Ichigaku Takigawa
 
Machine learning, WTF!?
Machine learning, WTF!? Machine learning, WTF!?
Machine learning, WTF!? Alê Borba
 
Emoji In Social Media Operations
Emoji In Social Media OperationsEmoji In Social Media Operations
Emoji In Social Media Operationsduker3100
 
Emoji In Social Media Operations
Emoji In Social Media OperationsEmoji In Social Media Operations
Emoji In Social Media Operationsduker3100
 
History of Emoji
History of EmojiHistory of Emoji
History of Emojiadamzurn
 
Icon style guide - Sivaprasath Selvaraj
Icon style guide - Sivaprasath SelvarajIcon style guide - Sivaprasath Selvaraj
Icon style guide - Sivaprasath SelvarajSivaprasath Selvaraj
 
Noa Ha'aman - 2017 - MojiSem: Varying Linguistic Purposes of Emoji in (Twitte...
Noa Ha'aman - 2017 - MojiSem: Varying Linguistic Purposes of Emoji in (Twitte...Noa Ha'aman - 2017 - MojiSem: Varying Linguistic Purposes of Emoji in (Twitte...
Noa Ha'aman - 2017 - MojiSem: Varying Linguistic Purposes of Emoji in (Twitte...Association for Computational Linguistics
 
Itamoji: Italian Emoji Prediction @ Evalita 2018
Itamoji: Italian Emoji Prediction @ Evalita 2018Itamoji: Italian Emoji Prediction @ Evalita 2018
Itamoji: Italian Emoji Prediction @ Evalita 2018University of Torino
 
Reinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine stepsReinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine stepsJason Hanson
 

Similar to No More Tofu - Mastering Emoji On Android (20)

IRJET- Dynamic Emotion Recognition and Emoji Generation
IRJET- Dynamic Emotion Recognition and Emoji GenerationIRJET- Dynamic Emotion Recognition and Emoji Generation
IRJET- Dynamic Emotion Recognition and Emoji Generation
 
Smile, Wink and Pray: Can Emojis Increase your Email Open Rate? (New Research)
Smile, Wink and Pray: Can Emojis Increase your Email Open Rate? (New Research)Smile, Wink and Pray: Can Emojis Increase your Email Open Rate? (New Research)
Smile, Wink and Pray: Can Emojis Increase your Email Open Rate? (New Research)
 
Apple Responds To Emoji Diversity Problem
Apple Responds To Emoji Diversity ProblemApple Responds To Emoji Diversity Problem
Apple Responds To Emoji Diversity Problem
 
EmojiNet: An Open Service and API for Emoji Sense Discovery
EmojiNet: An Open Service and API for Emoji Sense DiscoveryEmojiNet: An Open Service and API for Emoji Sense Discovery
EmojiNet: An Open Service and API for Emoji Sense Discovery
 
Future of the Web with Conversational Interface
Future of the Web with Conversational InterfaceFuture of the Web with Conversational Interface
Future of the Web with Conversational Interface
 
Designing a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDesigning a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, Gett
 
Unicode and Legacy Representations of Emoji (IUC 36)
Unicode and Legacy Representations of Emoji (IUC 36)Unicode and Legacy Representations of Emoji (IUC 36)
Unicode and Legacy Representations of Emoji (IUC 36)
 
Ubercool, pixel perfct & slick design… that just doesn't work
Ubercool, pixel perfct & slick design… that just doesn't workUbercool, pixel perfct & slick design… that just doesn't work
Ubercool, pixel perfct & slick design… that just doesn't work
 
Introduction to Samsung AR Emoji SDK
Introduction to Samsung AR Emoji SDKIntroduction to Samsung AR Emoji SDK
Introduction to Samsung AR Emoji SDK
 
SocialCaddy: "Clash of the Titans: Erlang Clusters and Google AppEngine"
SocialCaddy: "Clash of the Titans: Erlang Clusters  and Google AppEngine"SocialCaddy: "Clash of the Titans: Erlang Clusters  and Google AppEngine"
SocialCaddy: "Clash of the Titans: Erlang Clusters and Google AppEngine"
 
Best Practice iPhone SDK App Design
Best Practice iPhone SDK App DesignBest Practice iPhone SDK App Design
Best Practice iPhone SDK App Design
 
Applied Machine Learning for Chemistry I (HSI2020)
Applied Machine Learning for Chemistry I (HSI2020)Applied Machine Learning for Chemistry I (HSI2020)
Applied Machine Learning for Chemistry I (HSI2020)
 
Machine learning, WTF!?
Machine learning, WTF!? Machine learning, WTF!?
Machine learning, WTF!?
 
Emoji In Social Media Operations
Emoji In Social Media OperationsEmoji In Social Media Operations
Emoji In Social Media Operations
 
Emoji In Social Media Operations
Emoji In Social Media OperationsEmoji In Social Media Operations
Emoji In Social Media Operations
 
History of Emoji
History of EmojiHistory of Emoji
History of Emoji
 
Icon style guide - Sivaprasath Selvaraj
Icon style guide - Sivaprasath SelvarajIcon style guide - Sivaprasath Selvaraj
Icon style guide - Sivaprasath Selvaraj
 
Noa Ha'aman - 2017 - MojiSem: Varying Linguistic Purposes of Emoji in (Twitte...
Noa Ha'aman - 2017 - MojiSem: Varying Linguistic Purposes of Emoji in (Twitte...Noa Ha'aman - 2017 - MojiSem: Varying Linguistic Purposes of Emoji in (Twitte...
Noa Ha'aman - 2017 - MojiSem: Varying Linguistic Purposes of Emoji in (Twitte...
 
Itamoji: Italian Emoji Prediction @ Evalita 2018
Itamoji: Italian Emoji Prediction @ Evalita 2018Itamoji: Italian Emoji Prediction @ Evalita 2018
Itamoji: Italian Emoji Prediction @ Evalita 2018
 
Reinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine stepsReinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine steps
 

Recently uploaded

Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Hiroshi SHIBATA
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGDSC PJATK
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPTiSEO AI
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Revolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial IntelligenceRevolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial IntelligencePrecisely
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?Paolo Missier
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 

Recently uploaded (20)

Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Revolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial IntelligenceRevolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial Intelligence
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 

No More Tofu - Mastering Emoji On Android

  • 1. @Miqubel No More □ (tofu)    Mastering Emoji on Android
  • 2. Why Emoji matters? What problems do Android developers face? What solutions do we have? Is EmojiCompat the greatest thing ever?
  • 3. Emoji: A Brief Story Source: https://stories.moma.org/the-original-emoji-set-has-been-added-to-the-museum-of-modern-arts-collection-c6060e141f61
  • 4. Emoji & Android Source: https://www.androidcentral.com/history-emoji-android
  • 5. How to be up to date: DIY
  • 6.
  • 7.
  • 8.
  • 9. Emotions Source: People interpret the same emoji in completely different ways https://www.theverge.com/2016/4/11/11406944/emoji-meaning-difference-ios-android
  • 11. Extra-short-intro to Unicode Hello U+0048 U+0065 U+006C U+006C U+006F Unicode: Single character set that contains ALL characters of the Universe Each character maps to a Codepoint A Codepoint may be represented in memory differently! Codepoint UTF-8 UTF-16 H U+0048 48 0048 😂 U+1F602 F0 9F 98 82 D83D DE02
  • 12. How Emoji works Emoji: Graphic representation of one or more Unicode chars (Codepoints) "Face With Tears of Joy” U+1F602 val emoji = "uD83DuDE02"
  • 13. How Emoji works “Woman Technologist: Medium-Dark Skin Tone” val emoji = “uD83DuDC69uD83CuDFFEu200DuD83DuDCBB" 👩 U+1F469 🏾 U+1F3FE U+200D 💻 U+1F4BB
  • 14. How long is an Emoji? Challenge: How many “Woman Technologist: Medium-Dark Skin Tone” Emojis can you fit on a Tweet? A: 280 B: 140 C: 40 Solution: 40 🤔🤔🤔🤔🤔🤔🤔🤔 280 / 7 = 40
  • 15. How long is an Emoji? —> Improvement emoji.length = 7 emoji.codePointCount(0, emoji.length) = 4 val emoji = “uD83DuDC69uD83CuDFFEu200DuD83DuDCBB"
  • 16. How long is an Emoji? —> Improvement val it = BreakIterator.getCharacterInstance() it.setText(emoji) var count = 0 while (it.next() != BreakIterator.DONE) { count++ } count = 3 on API 23 count = 1 on API 25
  • 17. Challenges so far Missing Emoji (tofu) Different Emoji per platform Length of strings with Emoji
  • 18. Let’s look at three solutions Custom solution: Images and Spans Custom solution: Font file Using EmojiCompat
  • 19. Images and Spans Strategy: 1. Find an Emoji on a String 2. Replace with an ImageSpan 3. Repeat for the whole String
  • 20. Finding Emoji on Strings Get a nice dictionary: EmojiOne “emoji.json”: 1.38 MB! Fast JSON parsing: com.jsoniter —> but you won’t need to 😉 Efficient pattern matching —> Regular Expression
  • 21.
  • 22. Emoji assets Download: emojione/emojione-assets • Free: PNG 32px, 64px, 128px • Paid: SVG and larger PNG Example: SLICE OF PIZZA (U+1F355) —> 1f355.png
  • 23. Matching and displaying val PATTERN = “ud83cudf55".toRegex() val matches = PATTERN.findAll(text) for (match in matches) { spannableString.setSpan( ImageSpan(context, R.drawable.emoji_1f355), match.range.start, match.range.endInclusive + 1, SpannableString.SPAN_INCLUSIVE_INCLUSIVE ) } Solution: DynamicDrawableSpan (and resize the drawable)
  • 24. Images and Spans Pros: 😌 Freedom Cons: 😟 Lots of manual work needed 😟 APK size (4000 PNGs…)
  • 25. Custom font file Strategy: 1. Include font file with Emoji 2. Set font file containing Emoji to TextView 3. Set text to TextView
  • 26. Custom font file: Setup 1. Download Android font 2. Place in assets/fonts Download: https://www.emojione.com/download
  • 27. Custom font file: Setup val typeface = Typeface.createFromAsset(assets, “fonts/emojione.ttf”) textView.typeface = typeface textView.text = string
  • 29. Custom font file: Hold on… textView.text = "Numbers: 1 2 3 4" Solution: Parse Emoji and create TypefaceSpans
  • 30. Custom Font: Better but… Pros: 😌 Easy to setup Cons: 😟 Manual work needed
  • 31. EmojiCompat Strategy: — Process Strings with EmojiCompat or — Use EmojiTextView
  • 32. EmojiCompat: Setup (bundled) implementation “com.android.support:support-emoji:x.y.z” implementation “com.android.support:support-emoji-bundled:x.y.z” Adds: 7.4 MB
  • 33. EmojiCompat: Setup (downloadable) val fontRequest = FontRequest( "com.google.android.gms.fonts", "com.google.android.gms", "Noto Color Emoji Compat", R.array.com_google_android_gms_fonts_certs) val config = FontRequestEmojiCompatConfig(this, fontRequest) EmojiCompat.init(config) Init takes 150 ms! But happens asynchronously
  • 34. EmojiCompat: Setup (downloadable) Downloadable fonts get updated automatically!
  • 35. EmojiCompat: Setup (downloadable) Source: https://github.com/googlei18n/noto-emoji
  • 36. EmojiCompat: Setup (downloadable) Downloadable fonts get updated automatically! Find it in data/data/com.google.android.gms/files/fonts/opentype Noto_Color_Emoji_Compat-400-100_0-0_0.ttf Version 2.003;GOOG;noto-emoji:20171030:a5efe6ca61db
  • 37. EmojiCompat: Using it textView.text = EmojiCompat.get().process(string)
  • 39. EmojiCompat: Replace All val config = FontRequestEmojiCompatConfig(…) config.setReplaceAll(true) EmojiCompat.init(config)
  • 40. EmojiCompat: Handling init delay EmojiCompat.get().registerInitCallback(object : EmojiCompat.InitCallback() { override fun onInitialized() { textView.text = EmojiCompat.get().process(string) } override fun onFailed(throwable: Throwable?) { // handle error? textView.text = string } } )
  • 41. EmojiCompat: Using the Views <android.support.text.emoji.widget.EmojiTextView/> <android.support.text.emoji.widget.EmojiEditText/> <android.support.text.emoji.widget.EmojiButton/>
  • 42. EmojiCompat: Easy! Wishlist 😇 Customize it 😇 Emoji Keyboard 😇 Emoji tools