Skip to content

Commit

Permalink
Update README for 0.4.0 (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech authored Feb 14, 2017
1 parent be5db45 commit 026751a
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 38 deletions.
95 changes: 57 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,106 @@
# Emoji

[![Build Status](https://travis-ci.org/vanniktech/Emoji.svg?branch=master)](https://travis-ci.org/vanniktech/Emoji?branch=master)
[![Codecov](https://codecov.io/github/vanniktech/Emoji/coverage.svg?branch=master)](https://codecov.io/github/vanniktech/Emoji?branch=master)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Emoji-green.svg?style=true)](https://android-arsenal.com/details/1/3287)
[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)

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`](library/src/main/java/com/vanniktech/emoji/EmojiEditText.java) & [`EmojiTextView`](library/src/main/java/com/vanniktech/emoji/EmojiTextView.java).

<img src="preview_1.png" alt="Normal Keyboard" width="280">
<img src="preview_2.png" alt="Emoji Keyboard" width="280">
<img src="preview_3.png" alt="Recent Emojis" width="280">
The library has 2 different providers to choose from.

# Setup
## iOS Emojis

**build.gradle**
<img src="preview.png" alt="Normal Keyboard" width="280">
<img src="preview_ios_1.png" alt="Emoji Keyboard" width="280">
<img src="preview_ios_2.png" alt="Recent Emojis" width="280">

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

```groovy
compile 'com.vanniktech:emoji:0.3.0'
compile 'com.vanniktech:emoji:0.4.0-SNAPSHOT'
compile 'com.vanniktech:emoji-ios:0.4.0'
```

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

Modules are located on [Maven Central](https://oss.sonatype.org/#nexus-search;gav~com.vanniktech~emoji~~~).
## EmojiOne

In order to use the SNAPSHOT version please add:
<img src="preview.png" alt="Normal Keyboard" width="280">
<img src="preview_one_1.png" alt="Emoji Keyboard" width="280">
<img src="preview_one_2.png" alt="Recent Emojis" width="280">

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

```groovy
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
compile 'com.vanniktech:emoji-one:0.4.0'
```

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

# Example
### Custom Emojis

If you want to display your own Emojis you can create your own implementation of [`EmojiProvider`](library/src/main/java/com/vanniktech/emoji/EmojiProvider.java) and pass it to `EmojiManager.install`.

All of the core API lays in:

```groovy
compile 'com.vanniktech:emoji:0.4.0'
```

### Inserting Emojis

Declare your [`EmojiEditText`](library/src/main/java/com/vanniktech/emoji/EmojiEditText.java) in your layout xml file.

```xml
<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"
app:emojiSize="26sp"/>
android:id="@+id/emojiEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionSend"
android:inputType="textCapSentences|textMultiLine"
android:maxLines="3"
app:emojiSize="26sp"/>
```

To open the [`EmojiPopup`](library/src/main/java/com/vanniktech/emoji/EmojiPopup.java) execute the code above:
To open the [`EmojiPopup`](library/src/main/java/com/vanniktech/emoji/EmojiPopup.java) execute the code below:

```java
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
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`](library/src/main/java/com/vanniktech/emoji/EmojiEditText.java) that you declared in your layout xml file.

## Displaying Emojis
### Displaying Emojis

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

Just use the [`EmojiTextView`](library/src/main/java/com/vanniktech/emoji/EmojiTextView.java) and call `setText` with the String you got from [`EmojiEditText`](library/src/main/java/com/vanniktech/emoji/EmojiEditText.java) and you're done.
Just use the [`EmojiTextView`](library/src/main/java/com/vanniktech/emoji/EmojiTextView.java) and call `setText` with the String that contains Unicode encoded Emojis.

## Listeners

On the builder for the [`EmojiPopup`](library/src/main/java/com/vanniktech/emoji/EmojiPopup.java) you are able to declare several listeners.
The [`EmojiPopup`](library/src/main/java/com/vanniktech/emoji/EmojiPopup.java) builder allows you to declare several listeners.

```java
setOnSoftKeyboardCloseListener(final OnSoftKeyboardCloseListener listener);
setOnEmojiClickedListener(final OnEmojiClickedListener listener);
setOnSoftKeyboardOpenListener(final OnSoftKeyboardOpenListener listener);
setOnEmojiPopupShownListener(final OnEmojiPopupShownListener listener);
setOnEmojiPopupDismissListener(final OnEmojiPopupDismissListener listener);
setOnEmojiBackspaceClickListener(final OnEmojiBackspaceClickListener listener);
setOnSoftKeyboardCloseListener(OnSoftKeyboardCloseListener listener);
setOnEmojiClickedListener(OnEmojiClickedListener 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`](library/src/main/java/com/vanniktech/emoji/RecentEmoji.java) interface and pass it when you're building the [`EmojiPopup`](library/src/main/java/com/vanniktech/emoji/EmojiPopup.java):
Expand Down
Binary file added preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed preview_1.png
Binary file not shown.
Binary file removed preview_2.png
Binary file not shown.
Binary file removed preview_3.png
Binary file not shown.
Binary file added preview_ios_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added preview_ios_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added preview_one_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added preview_one_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 026751a

Please sign in to comment.