From 58545344199e6b291595bbd8fc3ab9169b4fcd62 Mon Sep 17 00:00:00 2001 From: Ankush Sachdeva Date: Fri, 9 Jan 2015 20:01:46 +0530 Subject: Added sample project --- example/AndroidManifest.xml | 28 ++++ example/ic_launcher-web.png | Bin 0 -> 51394 bytes example/libs/android-support-v4.jar | Bin 0 -> 648327 bytes example/proguard-project.txt | 20 +++ example/project.properties | 15 ++ example/res/drawable-hdpi/ic_action_keyboard.png | Bin 0 -> 359 bytes example/res/drawable-hdpi/ic_action_send_now.png | Bin 0 -> 465 bytes example/res/drawable-hdpi/ic_launcher.png | Bin 0 -> 7658 bytes example/res/drawable-hdpi/smiley.png | Bin 0 -> 1679 bytes example/res/drawable-mdpi/ic_action_keyboard.png | Bin 0 -> 433 bytes example/res/drawable-mdpi/ic_action_send_now.png | Bin 0 -> 332 bytes example/res/drawable-mdpi/ic_launcher.png | Bin 0 -> 3777 bytes example/res/drawable-mdpi/smiley.png | Bin 0 -> 987 bytes example/res/drawable-xhdpi/ic_action_keyboard.png | Bin 0 -> 492 bytes example/res/drawable-xhdpi/ic_action_send_now.png | Bin 0 -> 578 bytes example/res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 12516 bytes example/res/drawable-xhdpi/smiley.png | Bin 0 -> 1898 bytes example/res/drawable-xxhdpi/ic_action_keyboard.png | Bin 0 -> 472 bytes example/res/drawable-xxhdpi/ic_action_send_now.png | Bin 0 -> 759 bytes example/res/drawable-xxhdpi/ic_launcher.png | Bin 0 -> 24777 bytes example/res/drawable-xxhdpi/smiley.png | Bin 0 -> 3140 bytes example/res/layout/activity_main.xml | 39 +++++ example/res/layout/listview_row_layout.xml | 7 + example/res/values-sw600dp/dimens.xml | 8 ++ example/res/values-sw720dp-land/dimens.xml | 9 ++ example/res/values-v11/styles.xml | 11 ++ example/res/values-v14/styles.xml | 12 ++ example/res/values/dimens.xml | 7 + example/res/values/strings.xml | 8 ++ example/res/values/styles.xml | 20 +++ .../com/example/emojiconsample/MainActivity.java | 157 +++++++++++++++++++++ 31 files changed, 341 insertions(+) create mode 100644 example/AndroidManifest.xml create mode 100644 example/ic_launcher-web.png create mode 100644 example/libs/android-support-v4.jar create mode 100644 example/proguard-project.txt create mode 100644 example/project.properties create mode 100644 example/res/drawable-hdpi/ic_action_keyboard.png create mode 100644 example/res/drawable-hdpi/ic_action_send_now.png create mode 100644 example/res/drawable-hdpi/ic_launcher.png create mode 100644 example/res/drawable-hdpi/smiley.png create mode 100644 example/res/drawable-mdpi/ic_action_keyboard.png create mode 100644 example/res/drawable-mdpi/ic_action_send_now.png create mode 100644 example/res/drawable-mdpi/ic_launcher.png create mode 100644 example/res/drawable-mdpi/smiley.png create mode 100644 example/res/drawable-xhdpi/ic_action_keyboard.png create mode 100644 example/res/drawable-xhdpi/ic_action_send_now.png create mode 100644 example/res/drawable-xhdpi/ic_launcher.png create mode 100644 example/res/drawable-xhdpi/smiley.png create mode 100644 example/res/drawable-xxhdpi/ic_action_keyboard.png create mode 100644 example/res/drawable-xxhdpi/ic_action_send_now.png create mode 100644 example/res/drawable-xxhdpi/ic_launcher.png create mode 100644 example/res/drawable-xxhdpi/smiley.png create mode 100644 example/res/layout/activity_main.xml create mode 100644 example/res/layout/listview_row_layout.xml create mode 100644 example/res/values-sw600dp/dimens.xml create mode 100644 example/res/values-sw720dp-land/dimens.xml create mode 100644 example/res/values-v11/styles.xml create mode 100644 example/res/values-v14/styles.xml create mode 100644 example/res/values/dimens.xml create mode 100644 example/res/values/strings.xml create mode 100644 example/res/values/styles.xml create mode 100644 example/src/com/example/emojiconsample/MainActivity.java (limited to 'example') 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 @@ + + + + + + + + + + + + + + + + diff --git a/example/ic_launcher-web.png b/example/ic_launcher-web.png new file mode 100644 index 0000000..a18cbb4 Binary files /dev/null and b/example/ic_launcher-web.png differ diff --git a/example/libs/android-support-v4.jar b/example/libs/android-support-v4.jar new file mode 100644 index 0000000..187bdf4 Binary files /dev/null and b/example/libs/android-support-v4.jar 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 Binary files /dev/null and b/example/res/drawable-hdpi/ic_action_keyboard.png 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 Binary files /dev/null and b/example/res/drawable-hdpi/ic_action_send_now.png 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 Binary files /dev/null and b/example/res/drawable-hdpi/ic_launcher.png differ diff --git a/example/res/drawable-hdpi/smiley.png b/example/res/drawable-hdpi/smiley.png new file mode 100644 index 0000000..c841c4c Binary files /dev/null and b/example/res/drawable-hdpi/smiley.png 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 Binary files /dev/null and b/example/res/drawable-mdpi/ic_action_keyboard.png 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 Binary files /dev/null and b/example/res/drawable-mdpi/ic_action_send_now.png 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 Binary files /dev/null and b/example/res/drawable-mdpi/ic_launcher.png differ diff --git a/example/res/drawable-mdpi/smiley.png b/example/res/drawable-mdpi/smiley.png new file mode 100644 index 0000000..9f6d651 Binary files /dev/null and b/example/res/drawable-mdpi/smiley.png 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 Binary files /dev/null and b/example/res/drawable-xhdpi/ic_action_keyboard.png 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 Binary files /dev/null and b/example/res/drawable-xhdpi/ic_action_send_now.png 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 Binary files /dev/null and b/example/res/drawable-xhdpi/ic_launcher.png differ diff --git a/example/res/drawable-xhdpi/smiley.png b/example/res/drawable-xhdpi/smiley.png new file mode 100644 index 0000000..b06e007 Binary files /dev/null and b/example/res/drawable-xhdpi/smiley.png 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 Binary files /dev/null and b/example/res/drawable-xxhdpi/ic_action_keyboard.png 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 Binary files /dev/null and b/example/res/drawable-xxhdpi/ic_action_send_now.png 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 Binary files /dev/null and b/example/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/example/res/drawable-xxhdpi/smiley.png b/example/res/drawable-xxhdpi/smiley.png new file mode 100644 index 0000000..2f11d40 Binary files /dev/null and b/example/res/drawable-xxhdpi/smiley.png 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 @@ + + + + + + \ 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 @@ + \ 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 @@ + + + + + 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 @@ + + + + 128dp + + 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 @@ + + + + + + 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 @@ + + + + + + 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 @@ + + + + 16dp + 16dp + + 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 @@ + + + + EmojiconSample + Settings + Hello world! + + 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 @@ + + + + + + + + + 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 mAdapter = new ArrayAdapter(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); + } + +} -- cgit v1.2.3