snowf0x/Emoji


A simple library to add Emoji support to your Android Application

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.snowf0x:emoji:0.5.1'
	}
	dependencies {
		implementation("com.github.snowf0x:emoji:0.5.1")
	}
	<dependency>
	    <groupId>com.github.snowf0x</groupId>
	    <artifactId>emoji</artifactId>
	    <version>0.5.1</version>
	</dependency>

                            
    libraryDependencies += "com.github.snowf0x" % "emoji" % "0.5.1"
        
        

                            
    :dependencies [[com.github.snowf0x/emoji "0.5.1"]]
        
        

Readme


Emoji

A simple library to add Emoji support to your Android app. In a PopupWindow Emojis can be chosen. In order to edit and display text with Emojis this library provides public APIs: EmojiEditText, EmojiTextView & EmojiButton.

The library has 4 different providers to choose from (iOS, EmojiOne, Google & Twitter).

iOS Emojis

<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/ios_1_1498998365491.png" alt="Normal Keyboard" width="270"><img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/ios_2_1498998367998.png" alt="Emoji Keyboard" width="270" hspace="20"><img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/ios_3_1498998369550.png" alt="Recent Emojis" width="270">

For getting the above iOS Emojis simply add the dependency and code below.

compile 'com.vanniktech:emoji-ios:0.5.1'

And install the provider (preferably in your Application class):

// This line needs to be executed before any usage of EmojiTextView, EmojiEditText or EmojiButton.
EmojiManager.install(new IosEmojiProvider());

EmojiOne

<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/emoji_one_1_1498998356652.png" alt="Normal Keyboard" width="270"><img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/emoji_one_2_1498998359464.png" alt="Emoji Keyboard" width="270" hspace="20"><img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/emoji_one_3_1498998361072.png" alt="Recent Emojis" width="270">

For getting the above EmojiOne Emojis simply add the dependency and code below.

compile 'com.vanniktech:emoji-one:0.5.1'

And install the provider (preferably in your Application class):

// This line needs to be executed before any usage of EmojiTextView, EmojiEditText or EmojiButton.
EmojiManager.install(new EmojiOneProvider());

Google

<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/google_1_1498998373883.png" alt="Normal Keyboard" width="270"><img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/google_2_1498998376865.png" alt="Emoji Keyboard" width="270" hspace="20"><img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/google_3_1498998378352.png" alt="Recent Emojis" width="270">

For getting the above Google Emojis simply add the dependency and code below.

compile 'com.vanniktech:emoji-google:0.5.1'

And install the provider (preferably in your Application class):

// This line needs to be executed before any usage of EmojiTextView, EmojiEditText or EmojiButton.
EmojiManager.install(new GoogleEmojiProvider());

Twitter

<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/twitter_1_1498998347702.png" alt="Normal Keyboard" width="270"><img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/twitter_2_1498998350492.png" alt="Emoji Keyboard" width="270" hspace="20"><img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/twitter_3_1498998352130.png" alt="Recent Emojis" width="270">

For getting the above Twitter Emojis simply add the dependency and code below.

compile 'com.vanniktech:emoji-twitter:0.5.1'

And install the provider (preferably in your Application class):

// This line needs to be executed before any usage of EmojiTextView, EmojiEditText or EmojiButton.
EmojiManager.install(new TwitterEmojiProvider());

Custom Emojis

If you want to display your own Emojis you can create your own implementation of EmojiProvider and pass it to EmojiManager.install.

All of the core API lays in, which is being pulled in automatically by the provided implementations (iOS, EmojiOne, Google & Twitter):

compile 'com.vanniktech:emoji:0.5.1'

Custom EditText

If you want to add the emoji support to your existing EditText, you only have to implement EmojiEditTextInterface. An example can be seen on the default EditText implementation: EmojiEditText.

Keep in mind that this custom class must be a subclass of android.view.View.


Inserting Emojis

Declare your EmojiEditText in your layout xml file.

<com.vanniktech.emoji.EmojiEditText
  android:id="@+id/emojiEditText"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:imeOptions="actionSend"
  android:inputType="textCapSentences|textMultiLine"
  android:maxLines="3"/>

To open the EmojiPopup execute the code below:

final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(rootView).build(emojiEditText);
emojiPopup.toggle(); // Toggles visibility of the Popup.
emojiPopup.dismiss(); // Dismisses the Popup.
emojiPopup.isShowing(); // Returns true when Popup is showing.

The rootView is the rootView of your layout xml file which will be used for calculating the height of the keyboard. emojiEditText is the EmojiEditText that you declared in your layout xml file.

Displaying Emojis

<com.vanniktech.emoji.EmojiTextView
  android:id="@+id/emojiTextView"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"/>

Just use the EmojiTextView and call setText with the String that contains Unicode encoded Emojis. To change the size of the displayed Emojis use the lineHeight property from TextView.

Listeners

The EmojiPopup builder allows you to declare several listeners.

setOnSoftKeyboardCloseListener(OnSoftKeyboardCloseListener listener);
setOnEmojiClickListener(OnEmojiClickListener listener);
setOnSoftKeyboardOpenListener(OnSoftKeyboardOpenListener listener);
setOnEmojiPopupShownListener(OnEmojiPopupShownListener listener);
setOnEmojiPopupDismissListener(OnEmojiPopupDismissListener listener);
setOnEmojiBackspaceClickListener(OnEmojiBackspaceClickListener listener);

Custom Recent Emoji implementation

You can pass your own implementation of the recent Emojis. Just let one of your classes implement the RecentEmoji interface and pass it when you're building the EmojiPopup:

setRecentEmoji(yourClassThatImplementsRecentEmoji)

If no instance or a null instance is set the default implementation will be used.

Custom Variant Emoji implementation

You can pass your own implementation of the variant Emojis. Just let one of your classes implement the VariantEmoji interface and pass it when you're building the EmojiPopup:

setVariantEmoji(yourClassThatImplementsVariantEmoji)

If no instance or a null instance is set the default implementation will be used.

Snapshots

This library is also distributed as a SNAPSHOT if you like to check out the latest features.

Note: The API is not stable and may change and break your code at any time if you use a SNAPSHOT.

Add this to your repositories:

maven { url "https://oss.sonatype.org/content/repositories/snapshots" }

And one of these to your dependencies:

compile 'com.vanniktech:emoji-ios:0.6.0-SNAPSHOT'
compile 'com.vanniktech:emoji-one:0.6.0-SNAPSHOT'
compile 'com.vanniktech:emoji-google:0.6.0-SNAPSHOT'
compile 'com.vanniktech:emoji-twitter:0.6.0-SNAPSHOT'

Proguard

No configuration needed.

License

Copyright (C) 2016 Vanniktech - Niklas Baudy

Licensed under the Apache License, Version 2.0