USE EMOTICON (emoji) LIBRARY IN ANDROID APP
USE EMOJI LIBRARY IN YOUR ANDROID APP
1> first download the zip from github named ankushSachdeva emoji library.
2> import library File>new Modoule> import gradle project>select lib
here you have to select lib folder because it will show error while importing whole extracted folder.
3> if gradle showig error like "sdk must be updated or anything else"
simply upadate gradle files inside emoji library TargetSdk,
CompliledSdkVersion, buildToolVersion, minSdkVersion as same
it is in your app build.gradle.
4> when you'll change all above versions etc it will show you red line below
dependency in lib build.gradle simply press alt+enter and select 3rd option it will look like this.
//noinspection GradleCompatible
compile 'com.android.support:support-v4:19.+'
6> changes that have to made at this lib are ,MainActiviy.java
emojiButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//If popup is not showing => emoji keyboard is not visible, we need to show it
//
//IF POPUP IS SHOWING, SIMPLY DISMISS IT TO SHOW THE UNDELYING TEXT KEYBOARD
if (popup.isShowing()) {
popup.dismiss();
final InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInputFromInputMethod(emojiconEditText.getWindowToken(), InputMethodManager.SHOW_IMPLICIT);
} else {
final InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(emojiconEditText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_action_keyboard);
popup.showAtBottom();
// emojiconEditText.setFocusableInTouchMode(true);
// emojiconEditText.requestFocus();
}
}
});
b> Add This code into onCreate method of mainactivity.java
popup.setOutsideTouchable(true);
popup.setFocusable(true);
popup.getContentView().setFocusableInTouchMode(true);
popup.getContentView().setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
popup.dismiss();
return true;
}
return false;
}
});
c> delete onSoftKeyboardListener method implementation from EmojiPopup in mainactivity.java.
d> Inside EmojiconPopup.java constructor change
I>setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
II>public void showAtBottom(){
showAtLocation(rootView, Gravity.BOTTOM, 0, -1);
}
Comments
Post a Comment