aboutsummaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/AndroidManifest.xml28
-rw-r--r--example/ic_launcher-web.pngbin0 -> 51394 bytes
-rw-r--r--example/libs/android-support-v4.jarbin0 -> 648327 bytes
-rw-r--r--example/proguard-project.txt20
-rw-r--r--example/project.properties15
-rw-r--r--example/res/drawable-hdpi/ic_action_keyboard.pngbin0 -> 359 bytes
-rw-r--r--example/res/drawable-hdpi/ic_action_send_now.pngbin0 -> 465 bytes
-rw-r--r--example/res/drawable-hdpi/ic_launcher.pngbin0 -> 7658 bytes
-rw-r--r--example/res/drawable-hdpi/smiley.pngbin0 -> 1679 bytes
-rw-r--r--example/res/drawable-mdpi/ic_action_keyboard.pngbin0 -> 433 bytes
-rw-r--r--example/res/drawable-mdpi/ic_action_send_now.pngbin0 -> 332 bytes
-rw-r--r--example/res/drawable-mdpi/ic_launcher.pngbin0 -> 3777 bytes
-rw-r--r--example/res/drawable-mdpi/smiley.pngbin0 -> 987 bytes
-rw-r--r--example/res/drawable-xhdpi/ic_action_keyboard.pngbin0 -> 492 bytes
-rw-r--r--example/res/drawable-xhdpi/ic_action_send_now.pngbin0 -> 578 bytes
-rw-r--r--example/res/drawable-xhdpi/ic_launcher.pngbin0 -> 12516 bytes
-rw-r--r--example/res/drawable-xhdpi/smiley.pngbin0 -> 1898 bytes
-rw-r--r--example/res/drawable-xxhdpi/ic_action_keyboard.pngbin0 -> 472 bytes
-rw-r--r--example/res/drawable-xxhdpi/ic_action_send_now.pngbin0 -> 759 bytes
-rw-r--r--example/res/drawable-xxhdpi/ic_launcher.pngbin0 -> 24777 bytes
-rw-r--r--example/res/drawable-xxhdpi/smiley.pngbin0 -> 3140 bytes
-rw-r--r--example/res/layout/activity_main.xml39
-rw-r--r--example/res/layout/listview_row_layout.xml7
-rw-r--r--example/res/values-sw600dp/dimens.xml8
-rw-r--r--example/res/values-sw720dp-land/dimens.xml9
-rw-r--r--example/res/values-v11/styles.xml11
-rw-r--r--example/res/values-v14/styles.xml12
-rw-r--r--example/res/values/dimens.xml7
-rw-r--r--example/res/values/strings.xml8
-rw-r--r--example/res/values/styles.xml20
-rw-r--r--example/src/com/example/emojiconsample/MainActivity.java157
31 files changed, 341 insertions, 0 deletions
diff --git a/example/AndroidManifest.xml b/example/AndroidManifest.xml
new file mode 100644
index 0000000..79aaf8e
--- /dev/null
+++ b/example/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.emojiconsample"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="18" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.example.emojiconsample.MainActivity"
+ android:windowSoftInputMode="stateHidden"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/example/ic_launcher-web.png b/example/ic_launcher-web.png
new file mode 100644
index 0000000..a18cbb4
--- /dev/null
+++ b/example/ic_launcher-web.png
Binary files differ
diff --git a/example/libs/android-support-v4.jar b/example/libs/android-support-v4.jar
new file mode 100644
index 0000000..187bdf4
--- /dev/null
+++ b/example/libs/android-support-v4.jar
Binary files differ
diff --git a/example/proguard-project.txt b/example/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/example/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/example/project.properties b/example/project.properties
new file mode 100644
index 0000000..d6685c4
--- /dev/null
+++ b/example/project.properties
@@ -0,0 +1,15 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19
+android.library.reference.1=../lib
diff --git a/example/res/drawable-hdpi/ic_action_keyboard.png b/example/res/drawable-hdpi/ic_action_keyboard.png
new file mode 100644
index 0000000..37c04af
--- /dev/null
+++ b/example/res/drawable-hdpi/ic_action_keyboard.png
Binary files differ
diff --git a/example/res/drawable-hdpi/ic_action_send_now.png b/example/res/drawable-hdpi/ic_action_send_now.png
new file mode 100644
index 0000000..7e0d46d
--- /dev/null
+++ b/example/res/drawable-hdpi/ic_action_send_now.png
Binary files differ
diff --git a/example/res/drawable-hdpi/ic_launcher.png b/example/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..288b665
--- /dev/null
+++ b/example/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/example/res/drawable-hdpi/smiley.png b/example/res/drawable-hdpi/smiley.png
new file mode 100644
index 0000000..c841c4c
--- /dev/null
+++ b/example/res/drawable-hdpi/smiley.png
Binary files differ
diff --git a/example/res/drawable-mdpi/ic_action_keyboard.png b/example/res/drawable-mdpi/ic_action_keyboard.png
new file mode 100644
index 0000000..481e422
--- /dev/null
+++ b/example/res/drawable-mdpi/ic_action_keyboard.png
Binary files differ
diff --git a/example/res/drawable-mdpi/ic_action_send_now.png b/example/res/drawable-mdpi/ic_action_send_now.png
new file mode 100644
index 0000000..ab3db5f
--- /dev/null
+++ b/example/res/drawable-mdpi/ic_action_send_now.png
Binary files differ
diff --git a/example/res/drawable-mdpi/ic_launcher.png b/example/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..6ae570b
--- /dev/null
+++ b/example/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/example/res/drawable-mdpi/smiley.png b/example/res/drawable-mdpi/smiley.png
new file mode 100644
index 0000000..9f6d651
--- /dev/null
+++ b/example/res/drawable-mdpi/smiley.png
Binary files differ
diff --git a/example/res/drawable-xhdpi/ic_action_keyboard.png b/example/res/drawable-xhdpi/ic_action_keyboard.png
new file mode 100644
index 0000000..c1af1a2
--- /dev/null
+++ b/example/res/drawable-xhdpi/ic_action_keyboard.png
Binary files differ
diff --git a/example/res/drawable-xhdpi/ic_action_send_now.png b/example/res/drawable-xhdpi/ic_action_send_now.png
new file mode 100644
index 0000000..ff0e369
--- /dev/null
+++ b/example/res/drawable-xhdpi/ic_action_send_now.png
Binary files differ
diff --git a/example/res/drawable-xhdpi/ic_launcher.png b/example/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..d4fb7cd
--- /dev/null
+++ b/example/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/example/res/drawable-xhdpi/smiley.png b/example/res/drawable-xhdpi/smiley.png
new file mode 100644
index 0000000..b06e007
--- /dev/null
+++ b/example/res/drawable-xhdpi/smiley.png
Binary files differ
diff --git a/example/res/drawable-xxhdpi/ic_action_keyboard.png b/example/res/drawable-xxhdpi/ic_action_keyboard.png
new file mode 100644
index 0000000..a4668c4
--- /dev/null
+++ b/example/res/drawable-xxhdpi/ic_action_keyboard.png
Binary files differ
diff --git a/example/res/drawable-xxhdpi/ic_action_send_now.png b/example/res/drawable-xxhdpi/ic_action_send_now.png
new file mode 100644
index 0000000..373dde2
--- /dev/null
+++ b/example/res/drawable-xxhdpi/ic_action_send_now.png
Binary files differ
diff --git a/example/res/drawable-xxhdpi/ic_launcher.png b/example/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..85a6081
--- /dev/null
+++ b/example/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/example/res/drawable-xxhdpi/smiley.png b/example/res/drawable-xxhdpi/smiley.png
new file mode 100644
index 0000000..2f11d40
--- /dev/null
+++ b/example/res/drawable-xxhdpi/smiley.png
Binary files differ
diff --git a/example/res/layout/activity_main.xml b/example/res/layout/activity_main.xml
new file mode 100644
index 0000000..d00932b
--- /dev/null
+++ b/example/res/layout/activity_main.xml
@@ -0,0 +1,39 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:emojicon="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/root_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ >
+ <ImageView
+ android:id="@+id/emoji_btn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:src="@drawable/smiley"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentLeft="true"
+ />
+ <ImageView
+ android:id="@+id/submit_btn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:src="@drawable/ic_action_send_now"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentRight="true"
+ />
+ <github.ankushsachdeva.emojicon.EmojiconEditText
+ android:id="@+id/emojicon_edit_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_toRightOf="@id/emoji_btn"
+ android:layout_toLeftOf="@id/submit_btn"
+ emojicon:emojiconSize="28sp" />
+ <ListView
+ android:id="@+id/lv"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_above="@id/emojicon_edit_text"
+ ></ListView>
+</RelativeLayout> \ No newline at end of file
diff --git a/example/res/layout/listview_row_layout.xml b/example/res/layout/listview_row_layout.xml
new file mode 100644
index 0000000..62e2133
--- /dev/null
+++ b/example/res/layout/listview_row_layout.xml
@@ -0,0 +1,7 @@
+<github.ankushsachdeva.emojicon.EmojiconTextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:emojicon="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ emojicon:emojiconSize="28sp"
+ /> \ No newline at end of file
diff --git a/example/res/values-sw600dp/dimens.xml b/example/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..44f01db
--- /dev/null
+++ b/example/res/values-sw600dp/dimens.xml
@@ -0,0 +1,8 @@
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw600dp devices (e.g. 7" tablets) here.
+ -->
+
+</resources>
diff --git a/example/res/values-sw720dp-land/dimens.xml b/example/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 0000000..61e3fa8
--- /dev/null
+++ b/example/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,9 @@
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+ -->
+ <dimen name="activity_horizontal_margin">128dp</dimen>
+
+</resources>
diff --git a/example/res/values-v11/styles.xml b/example/res/values-v11/styles.xml
new file mode 100644
index 0000000..3c02242
--- /dev/null
+++ b/example/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/example/res/values-v14/styles.xml b/example/res/values-v14/styles.xml
new file mode 100644
index 0000000..a91fd03
--- /dev/null
+++ b/example/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/example/res/values/dimens.xml b/example/res/values/dimens.xml
new file mode 100644
index 0000000..55c1e59
--- /dev/null
+++ b/example/res/values/dimens.xml
@@ -0,0 +1,7 @@
+<resources>
+
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+
+</resources>
diff --git a/example/res/values/strings.xml b/example/res/values/strings.xml
new file mode 100644
index 0000000..e5448c7
--- /dev/null
+++ b/example/res/values/strings.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">EmojiconSample</string>
+ <string name="action_settings">Settings</string>
+ <string name="hello_world">Hello world!</string>
+
+</resources>
diff --git a/example/res/values/styles.xml b/example/res/values/styles.xml
new file mode 100644
index 0000000..6ce89c7
--- /dev/null
+++ b/example/res/values/styles.xml
@@ -0,0 +1,20 @@
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+</resources>
diff --git a/example/src/com/example/emojiconsample/MainActivity.java b/example/src/com/example/emojiconsample/MainActivity.java
new file mode 100644
index 0000000..247eb30
--- /dev/null
+++ b/example/src/com/example/emojiconsample/MainActivity.java
@@ -0,0 +1,157 @@
+package com.example.emojiconsample;
+
+import github.ankushsachdeva.emojicon.EmojiconEditText;
+import github.ankushsachdeva.emojicon.EmojiconGridView.OnEmojiconClickedListener;
+import github.ankushsachdeva.emojicon.EmojiconsPopup;
+import github.ankushsachdeva.emojicon.EmojiconsPopup.OnEmojiconBackspaceClickedListener;
+import github.ankushsachdeva.emojicon.EmojiconsPopup.OnSoftKeyboardOpenCloseListener;
+import github.ankushsachdeva.emojicon.emoji.Emojicon;
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.PopupWindow.OnDismissListener;
+
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ ListView lv = (ListView) findViewById(R.id.lv);
+ final ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(this, R.layout.listview_row_layout);
+ lv.setAdapter(mAdapter);
+ final EmojiconEditText emojiconEditText = (EmojiconEditText) findViewById(R.id.emojicon_edit_text);
+ final View rootView = findViewById(R.id.root_view);
+ final ImageView emojiButton = (ImageView) findViewById(R.id.emoji_btn);
+ final ImageView submitButton = (ImageView) findViewById(R.id.submit_btn);
+
+ // Give the topmost view of your activity layout hierarchy. This will be used to measure soft keyboard height
+ final EmojiconsPopup popup = new EmojiconsPopup(rootView, this);
+
+ //Will automatically set size according to the soft keyboard size
+ popup.setSizeForSoftKeyboard();
+
+ //Set on emojicon click listener
+ popup.setOnEmojiconClickedListener(new OnEmojiconClickedListener() {
+
+ @Override
+ public void onEmojiconClicked(Emojicon emojicon) {
+ emojiconEditText.append(emojicon.getEmoji());
+ }
+ });
+
+ //Set on backspace click listener
+ popup.setOnEmojiconBackspaceClickedListener(new OnEmojiconBackspaceClickedListener() {
+
+ @Override
+ public void onEmojiconBackspaceClicked(View v) {
+ KeyEvent event = new KeyEvent(
+ 0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
+ emojiconEditText.dispatchKeyEvent(event);
+ }
+ });
+
+ //If the emoji popup is dismissed, change emojiButton to smiley icon
+ popup.setOnDismissListener(new OnDismissListener() {
+
+ @Override
+ public void onDismiss() {
+ changeEmojiKeyboardIcon(emojiButton, R.drawable.smiley);
+ }
+ });
+
+ //If the text keyboard closes, also dismiss the emoji popup
+ popup.setOnSoftKeyboardOpenCloseListener(new OnSoftKeyboardOpenCloseListener() {
+
+ @Override
+ public void onKeyboardOpen(int keyBoardHeight) {
+
+ }
+
+ @Override
+ public void onKeyboardClose() {
+ if(popup.isShowing())
+ popup.dismiss();
+ }
+ });
+
+ //On emoji clicked, add it to edittext
+ popup.setOnEmojiconClickedListener(new OnEmojiconClickedListener() {
+
+ @Override
+ public void onEmojiconClicked(Emojicon emojicon) {
+ emojiconEditText.append(emojicon.getEmoji());
+ }
+ });
+
+ //On backspace clicked, emulate the KEYCODE_DEL key event
+ popup.setOnEmojiconBackspaceClickedListener(new OnEmojiconBackspaceClickedListener() {
+
+ @Override
+ public void onEmojiconBackspaceClicked(View v) {
+ KeyEvent event = new KeyEvent(
+ 0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
+ emojiconEditText.dispatchKeyEvent(event);
+ }
+ });
+
+ // To toggle between text keyboard and emoji keyboard keyboard(Popup)
+ emojiButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+ //If popup is not showing => emoji keyboard is not visible, we need to show it
+ if(!popup.isShowing()){
+
+ //If keyboard is visible, simply show the emoji popup
+ if(popup.isKeyBoardOpen()){
+ popup.showAtBottom();
+ changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_action_keyboard);
+ }
+
+ //else, open the text keyboard first and immediately after that show the emoji popup
+ else{
+ emojiconEditText.setFocusableInTouchMode(true);
+ emojiconEditText.requestFocus();
+ popup.showAtBottomPending();
+ final InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ inputMethodManager.showSoftInput(emojiconEditText, InputMethodManager.SHOW_IMPLICIT);
+ changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_action_keyboard);
+ }
+ }
+
+ //If popup is showing, simply dismiss it to show the undelying text keyboard
+ else{
+ popup.dismiss();
+ }
+ }
+ });
+
+ //On submit, add the edittext text to listview and clear the edittext
+ submitButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ String newText = emojiconEditText.getText().toString();
+ emojiconEditText.getText().clear();
+ mAdapter.add(newText);
+ mAdapter.notifyDataSetChanged();
+
+ }
+ });
+ }
+
+ private void changeEmojiKeyboardIcon(ImageView iconToBeChanged, int drawableResourceId){
+ iconToBeChanged.setImageResource(drawableResourceId);
+ }
+
+}