diff options
Diffstat (limited to 'libs/emojicon/src')
34 files changed, 1044 insertions, 1073 deletions
diff --git a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiAdapter.java b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiAdapter.java index 347870c9d..18842ea0d 100644 --- a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiAdapter.java +++ b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiAdapter.java @@ -33,7 +33,8 @@ import github.ankushsachdeva.emojicon.emoji.Emojicon; * @author Ankush Sachdeva (sankush@yahoo.co.in) */ class EmojiAdapter extends ArrayAdapter<Emojicon> { - OnEmojiconClickedListener emojiClickListener; + OnEmojiconClickedListener emojiClickListener; + public EmojiAdapter(Context context, List<Emojicon> data) { super(context, R.layout.emojicon_item, data); } @@ -41,11 +42,11 @@ class EmojiAdapter extends ArrayAdapter<Emojicon> { public EmojiAdapter(Context context, Emojicon[] data) { super(context, R.layout.emojicon_item, data); } - - public void setEmojiClickListener(OnEmojiconClickedListener listener){ - this.emojiClickListener = listener; + + public void setEmojiClickListener(OnEmojiconClickedListener listener) { + this.emojiClickListener = listener; } - + @Override public View getView(final int position, View convertView, ViewGroup parent) { View v = convertView; @@ -59,11 +60,11 @@ class EmojiAdapter extends ArrayAdapter<Emojicon> { ViewHolder holder = (ViewHolder) v.getTag(); holder.icon.setText(emoji.getEmoji()); holder.icon.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - emojiClickListener.onEmojiconClicked(getItem(position)); - } - }); + @Override + public void onClick(View v) { + emojiClickListener.onEmojiconClicked(getItem(position)); + } + }); return v; } diff --git a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconGridView.java b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconGridView.java index 10379129c..72087e6e6 100644 --- a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconGridView.java +++ b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconGridView.java @@ -30,48 +30,48 @@ import github.ankushsachdeva.emojicon.emoji.People; /** * @author Hieu Rocker (rockerhieu@gmail.com) - * @author Ankush Sachdeva (sankush@yahoo.co.in) + * @author Ankush Sachdeva (sankush@yahoo.co.in) */ -public class EmojiconGridView{ - public View rootView; - EmojiconsPopup mEmojiconPopup; +public class EmojiconGridView { + public View rootView; + EmojiconsPopup mEmojiconPopup; EmojiconRecents mRecents; Emojicon[] mData; - + public EmojiconGridView(Context context, Emojicon[] emojicons, EmojiconRecents recents, EmojiconsPopup emojiconPopup) { - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); - mEmojiconPopup = emojiconPopup; - rootView = inflater.inflate(R.layout.emojicon_grid, null); - setRecents(recents); - GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView); - if (emojicons== null) { - mData = People.DATA; - } else { - Object[] o = (Object[]) emojicons; - mData = Arrays.asList(o).toArray(new Emojicon[o.length]); - } - EmojiAdapter mAdapter = new EmojiAdapter(rootView.getContext(), mData); - mAdapter.setEmojiClickListener(new OnEmojiconClickedListener() { - - @Override - public void onEmojiconClicked(Emojicon emojicon) { - if (mEmojiconPopup.onEmojiconClickedListener != null) { - mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon); - } - if (mRecents != null) { - mRecents.addRecentEmoji(rootView.getContext(), emojicon); - } - } - }); - gridView.setAdapter(mAdapter); - } - - private void setRecents(EmojiconRecents recents) { + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); + mEmojiconPopup = emojiconPopup; + rootView = inflater.inflate(R.layout.emojicon_grid, null); + setRecents(recents); + GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView); + if (emojicons == null) { + mData = People.DATA; + } else { + Object[] o = (Object[]) emojicons; + mData = Arrays.asList(o).toArray(new Emojicon[o.length]); + } + EmojiAdapter mAdapter = new EmojiAdapter(rootView.getContext(), mData); + mAdapter.setEmojiClickListener(new OnEmojiconClickedListener() { + + @Override + public void onEmojiconClicked(Emojicon emojicon) { + if (mEmojiconPopup.onEmojiconClickedListener != null) { + mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon); + } + if (mRecents != null) { + mRecents.addRecentEmoji(rootView.getContext(), emojicon); + } + } + }); + gridView.setAdapter(mAdapter); + } + + private void setRecents(EmojiconRecents recents) { mRecents = recents; } public interface OnEmojiconClickedListener { void onEmojiconClicked(Emojicon emojicon); } - + } diff --git a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconHandler.java b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconHandler.java index bc7a228c0..84f087d86 100644 --- a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconHandler.java +++ b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconHandler.java @@ -1396,7 +1396,7 @@ public final class EmojiconHandler { public static void addEmojis(Context context, Spannable text, int emojiSize, int index, int length) { int textLength = text.length(); int textLengthToProcessMax = textLength - index; - int textLengthToProcess = length < 0 || length >= textLengthToProcessMax ? textLength : (length+index); + int textLengthToProcess = length < 0 || length >= textLengthToProcessMax ? textLength : (length + index); // remove spans throughout all text EmojiconSpan[] oldSpans = text.getSpans(0, textLength, EmojiconSpan.class); diff --git a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecents.java b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecents.java index c7a90c837..e3274ed77 100644 --- a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecents.java +++ b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecents.java @@ -21,8 +21,8 @@ import android.content.Context; import github.ankushsachdeva.emojicon.emoji.Emojicon; /** -* @author Daniele Ricci -*/ + * @author Daniele Ricci + */ public interface EmojiconRecents { public void addRecentEmoji(Context context, Emojicon emojicon); } diff --git a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecentsGridView.java b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecentsGridView.java index ea98c809d..ff65ac06d 100644 --- a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecentsGridView.java +++ b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecentsGridView.java @@ -24,26 +24,26 @@ import github.ankushsachdeva.emojicon.emoji.Emojicon; /** * @author Daniele Ricci - * @author Ankush Sachdeva (sankush@yahoo.co.in) + * @author Ankush Sachdeva (sankush@yahoo.co.in) */ public class EmojiconRecentsGridView extends EmojiconGridView implements EmojiconRecents { - EmojiAdapter mAdapter; - - public EmojiconRecentsGridView(Context context, Emojicon[] emojicons, - EmojiconRecents recents,EmojiconsPopup emojiconsPopup) { - super(context, emojicons, recents, emojiconsPopup); - EmojiconRecentsManager recents1 = EmojiconRecentsManager - .getInstance(rootView.getContext()); - mAdapter = new EmojiAdapter(rootView.getContext(), recents1); - mAdapter.setEmojiClickListener(new OnEmojiconClickedListener() { - - @Override - public void onEmojiconClicked(Emojicon emojicon) { - if (mEmojiconPopup.onEmojiconClickedListener != null) { - mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon); - } - } - }); + EmojiAdapter mAdapter; + + public EmojiconRecentsGridView(Context context, Emojicon[] emojicons, + EmojiconRecents recents, EmojiconsPopup emojiconsPopup) { + super(context, emojicons, recents, emojiconsPopup); + EmojiconRecentsManager recents1 = EmojiconRecentsManager + .getInstance(rootView.getContext()); + mAdapter = new EmojiAdapter(rootView.getContext(), recents1); + mAdapter.setEmojiClickListener(new OnEmojiconClickedListener() { + + @Override + public void onEmojiconClicked(Emojicon emojicon) { + if (mEmojiconPopup.onEmojiconClickedListener != null) { + mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon); + } + } + }); GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView); gridView.setAdapter(mAdapter); } @@ -51,7 +51,7 @@ public class EmojiconRecentsGridView extends EmojiconGridView implements Emojico @Override public void addRecentEmoji(Context context, Emojicon emojicon) { EmojiconRecentsManager recents = EmojiconRecentsManager - .getInstance(context); + .getInstance(context); recents.push(emojicon); // notify dataset changed diff --git a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java index 177f11591..f208b10c4 100644 --- a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java +++ b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java @@ -26,8 +26,8 @@ import github.ankushsachdeva.emojicon.emoji.Emojicon; /** -* @author Daniele Ricci -*/ + * @author Daniele Ricci + */ public class EmojiconRecentsManager extends ArrayList<Emojicon> { private static final String PREFERENCE_NAME = "emojicon"; @@ -88,7 +88,7 @@ public class EmojiconRecentsManager extends ArrayList<Emojicon> { boolean ret = super.remove(object); return ret; } - + private SharedPreferences getPreferences() { return mContext.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); } @@ -99,14 +99,13 @@ public class EmojiconRecentsManager extends ArrayList<Emojicon> { StringTokenizer tokenizer = new StringTokenizer(str, "~"); while (tokenizer.hasMoreTokens()) { try { - add(new Emojicon(tokenizer.nextToken())); - } - catch (NumberFormatException e) { + add(new Emojicon(tokenizer.nextToken())); + } catch (NumberFormatException e) { // ignored } } } - + public void saveRecents() { StringBuilder str = new StringBuilder(); int c = size(); diff --git a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconsPopup.java b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconsPopup.java index 2a35aa9c0..f7d68ddc5 100644 --- a/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconsPopup.java +++ b/libs/emojicon/src/github/ankushsachdeva/emojicon/EmojiconsPopup.java @@ -53,372 +53,376 @@ import github.ankushsachdeva.emojicon.emoji.Symbols; */ public class EmojiconsPopup extends PopupWindow implements ViewPager.OnPageChangeListener, EmojiconRecents { - private int mEmojiTabLastSelectedIndex = -1; - private View[] mEmojiTabs; - private PagerAdapter mEmojisAdapter; - private EmojiconRecentsManager mRecentsManager; - private int keyBoardHeight = 0; - private Boolean pendingOpen = false; - private Boolean isOpened = false; - OnEmojiconClickedListener onEmojiconClickedListener; - OnEmojiconBackspaceClickedListener onEmojiconBackspaceClickedListener; - OnSoftKeyboardOpenCloseListener onSoftKeyboardOpenCloseListener; - View rootView; - Context mContext; - - private ViewPager emojisPager; - /** - * Constructor - * @param rootView The top most layout in your view hierarchy. The difference of this view and the screen height will be used to calculate the keyboard height. - * @param mContext The context of current activity. - */ - public EmojiconsPopup(View rootView, Context mContext){ - super(mContext); - this.mContext = mContext; - this.rootView = rootView; - View customView = createCustomView(); - setContentView(customView); - setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); - //default size - setSize((int) mContext.getResources().getDimension(R.dimen.keyboard_height), LayoutParams.MATCH_PARENT); - } - /** - * Set the listener for the event of keyboard opening or closing. - */ - public void setOnSoftKeyboardOpenCloseListener(OnSoftKeyboardOpenCloseListener listener){ - this.onSoftKeyboardOpenCloseListener = listener; - } - - /** - * Set the listener for the event when any of the emojicon is clicked - */ - public void setOnEmojiconClickedListener(OnEmojiconClickedListener listener){ - this.onEmojiconClickedListener = listener; - } - - /** - * Set the listener for the event when backspace on emojicon popup is clicked - */ - public void setOnEmojiconBackspaceClickedListener(OnEmojiconBackspaceClickedListener listener){ - this.onEmojiconBackspaceClickedListener = listener; - } - - /** - * Use this function to show the emoji popup. - * NOTE: Since, the soft keyboard sizes are variable on different android devices, the - * library needs you to open the soft keyboard atleast once before calling this function. - * If that is not possible see showAtBottomPending() function. - * - */ - public void showAtBottom(){ - showAtLocation(rootView, Gravity.BOTTOM, 0, 0); - } - /** - * Use this function when the soft keyboard has not been opened yet. This - * will show the emoji popup after the keyboard is up next time. - * Generally, you will be calling InputMethodManager.showSoftInput function after - * calling this function. - */ - public void showAtBottomPending(){ - if(isKeyBoardOpen()) - showAtBottom(); - else - pendingOpen = true; - } - - /** - * - * @return Returns true if the soft keyboard is open, false otherwise. - */ - public Boolean isKeyBoardOpen(){ - return isOpened; - } - - /** - * Dismiss the popup - */ - @Override - public void dismiss() { - super.dismiss(); - EmojiconRecentsManager - .getInstance(mContext).saveRecents(); - } - - /** - * Call this function to resize the emoji popup according to your soft keyboard size - */ - public void setSizeForSoftKeyboard(){ - rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - Rect r = new Rect(); - rootView.getWindowVisibleDisplayFrame(r); - - int screenHeight = getUsableScreenHeight(); - int heightDifference = screenHeight - - (r.bottom - r.top); - int resourceId = mContext.getResources() - .getIdentifier("status_bar_height", - "dimen", "android"); - if (resourceId > 0) { - heightDifference -= mContext.getResources() - .getDimensionPixelSize(resourceId); - } - if (heightDifference > 100) { - keyBoardHeight = heightDifference; - setSize(LayoutParams.MATCH_PARENT, keyBoardHeight); - if(isOpened == false){ - if(onSoftKeyboardOpenCloseListener!=null) - onSoftKeyboardOpenCloseListener.onKeyboardOpen(keyBoardHeight); - } - isOpened = true; - if(pendingOpen){ - showAtBottom(); - pendingOpen = false; - } - } - else{ - isOpened = false; - if(onSoftKeyboardOpenCloseListener!=null) - onSoftKeyboardOpenCloseListener.onKeyboardClose(); - } - } - }); - } - - private int getUsableScreenHeight() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - DisplayMetrics metrics = new DisplayMetrics(); - - WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); - windowManager.getDefaultDisplay().getMetrics(metrics); - - return metrics.heightPixels; - - } else { - return rootView.getRootView().getHeight(); - } - } - - /** - * Manually set the popup window size - * @param width Width of the popup - * @param height Height of the popup - */ - public void setSize(int width, int height){ - setWidth(width); - setHeight(height); - } - - private View createCustomView() { - LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); - View view = inflater.inflate(R.layout.emojicons, null, false); - emojisPager = (ViewPager) view.findViewById(R.id.emojis_pager); - emojisPager.setOnPageChangeListener(this); - EmojiconRecents recents = this; - mEmojisAdapter = new EmojisPagerAdapter( - Arrays.asList( - new EmojiconRecentsGridView(mContext, null, null, this), - new EmojiconGridView(mContext, People.DATA, recents, this), - new EmojiconGridView(mContext, Nature.DATA, recents, this), - new EmojiconGridView(mContext, Objects.DATA, recents, this), - new EmojiconGridView(mContext, Places.DATA, recents, this), - new EmojiconGridView(mContext, Symbols.DATA, recents, this) - ) - ); - emojisPager.setAdapter(mEmojisAdapter); - mEmojiTabs = new View[6]; - mEmojiTabs[0] = view.findViewById(R.id.emojis_tab_0_recents); - mEmojiTabs[1] = view.findViewById(R.id.emojis_tab_1_people); - mEmojiTabs[2] = view.findViewById(R.id.emojis_tab_2_nature); - mEmojiTabs[3] = view.findViewById(R.id.emojis_tab_3_objects); - mEmojiTabs[4] = view.findViewById(R.id.emojis_tab_4_cars); - mEmojiTabs[5] = view.findViewById(R.id.emojis_tab_5_punctuation); - for (int i = 0; i < mEmojiTabs.length; i++) { - final int position = i; - mEmojiTabs[i].setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - emojisPager.setCurrentItem(position); - } - }); - } - view.findViewById(R.id.emojis_backspace).setOnTouchListener(new RepeatListener(1000, 50, new OnClickListener() { - - @Override - public void onClick(View v) { - if(onEmojiconBackspaceClickedListener != null) - onEmojiconBackspaceClickedListener.onEmojiconBackspaceClicked(v); - } - })); - - // get last selected page - mRecentsManager = EmojiconRecentsManager.getInstance(view.getContext()); - int page = mRecentsManager.getRecentPage(); - // last page was recents, check if there are recents to use - // if none was found, go to page 1 - if (page == 0 && mRecentsManager.size() == 0) { - page = 1; - } - - if (page == 0) { - onPageSelected(page); - } - else { - emojisPager.setCurrentItem(page, false); - } - return view; - } - - @Override - public void addRecentEmoji(Context context, Emojicon emojicon) { - EmojiconRecentsGridView fragment = ((EmojisPagerAdapter)emojisPager.getAdapter()).getRecentFragment(); - fragment.addRecentEmoji(context, emojicon); - } - - - @Override - public void onPageScrolled(int i, float v, int i2) { - } - - @Override - public void onPageSelected(int i) { - if (mEmojiTabLastSelectedIndex == i) { - return; - } - switch (i) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - if (mEmojiTabLastSelectedIndex >= 0 && mEmojiTabLastSelectedIndex < mEmojiTabs.length) { - mEmojiTabs[mEmojiTabLastSelectedIndex].setSelected(false); - } - mEmojiTabs[i].setSelected(true); - mEmojiTabLastSelectedIndex = i; - mRecentsManager.setRecentPage(i); - break; - } - } - - @Override - public void onPageScrollStateChanged(int i) { - } - - private static class EmojisPagerAdapter extends PagerAdapter { - private List<EmojiconGridView> views; - public EmojiconRecentsGridView getRecentFragment(){ - for (EmojiconGridView it : views) { - if(it instanceof EmojiconRecentsGridView) - return (EmojiconRecentsGridView)it; - } - return null; - } - public EmojisPagerAdapter(List<EmojiconGridView> views) { - super(); - this.views = views; - } - - @Override - public int getCount() { - return views.size(); - } - - - @Override - public Object instantiateItem(ViewGroup container, int position) { - View v = views.get(position).rootView; - ((ViewPager)container).addView(v, 0); - return v; - } - - @Override - public void destroyItem(ViewGroup container, int position, Object view) { - ((ViewPager)container).removeView((View)view); - } - - @Override - public boolean isViewFromObject(View view, Object key) { - return key == view; - } - } - - /** - * A class, that can be used as a TouchListener on any view (e.g. a Button). - * It cyclically runs a clickListener, emulating keyboard-like behaviour. First - * click is fired immediately, next before initialInterval, and subsequent before - * normalInterval. - * <p/> - * <p>Interval is scheduled before the onClick completes, so it has to run fast. - * If it runs slow, it does not generate skipped onClicks. - */ - public static class RepeatListener implements View.OnTouchListener { - - private Handler handler = new Handler(); - - private int initialInterval; - private final int normalInterval; - private final View.OnClickListener clickListener; - - private Runnable handlerRunnable = new Runnable() { - @Override - public void run() { - if (downView == null) { - return; - } - handler.removeCallbacksAndMessages(downView); - handler.postAtTime(this, downView, SystemClock.uptimeMillis() + normalInterval); - clickListener.onClick(downView); - } - }; - - private View downView; - - /** - * @param initialInterval The interval before first click event - * @param normalInterval The interval before second and subsequent click - * events - * @param clickListener The OnClickListener, that will be called - * periodically - */ - public RepeatListener(int initialInterval, int normalInterval, View.OnClickListener clickListener) { - if (clickListener == null) - throw new IllegalArgumentException("null runnable"); - if (initialInterval < 0 || normalInterval < 0) - throw new IllegalArgumentException("negative interval"); - - this.initialInterval = initialInterval; - this.normalInterval = normalInterval; - this.clickListener = clickListener; - } - - public boolean onTouch(View view, MotionEvent motionEvent) { - switch (motionEvent.getAction()) { - case MotionEvent.ACTION_DOWN: - downView = view; - handler.removeCallbacks(handlerRunnable); - handler.postAtTime(handlerRunnable, downView, SystemClock.uptimeMillis() + initialInterval); - clickListener.onClick(view); - return true; - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_CANCEL: - case MotionEvent.ACTION_OUTSIDE: - handler.removeCallbacksAndMessages(downView); - downView = null; - return true; - } - return false; - } - } - - public interface OnEmojiconBackspaceClickedListener { - void onEmojiconBackspaceClicked(View v); - } - - public interface OnSoftKeyboardOpenCloseListener{ - void onKeyboardOpen(int keyBoardHeight); - void onKeyboardClose(); - } + private int mEmojiTabLastSelectedIndex = -1; + private View[] mEmojiTabs; + private PagerAdapter mEmojisAdapter; + private EmojiconRecentsManager mRecentsManager; + private int keyBoardHeight = 0; + private Boolean pendingOpen = false; + private Boolean isOpened = false; + OnEmojiconClickedListener onEmojiconClickedListener; + OnEmojiconBackspaceClickedListener onEmojiconBackspaceClickedListener; + OnSoftKeyboardOpenCloseListener onSoftKeyboardOpenCloseListener; + View rootView; + Context mContext; + + private ViewPager emojisPager; + + /** + * Constructor + * + * @param rootView The top most layout in your view hierarchy. The difference of this view and the screen height will be used to calculate the keyboard height. + * @param mContext The context of current activity. + */ + public EmojiconsPopup(View rootView, Context mContext) { + super(mContext); + this.mContext = mContext; + this.rootView = rootView; + View customView = createCustomView(); + setContentView(customView); + setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); + //default size + setSize((int) mContext.getResources().getDimension(R.dimen.keyboard_height), LayoutParams.MATCH_PARENT); + } + + /** + * Set the listener for the event of keyboard opening or closing. + */ + public void setOnSoftKeyboardOpenCloseListener(OnSoftKeyboardOpenCloseListener listener) { + this.onSoftKeyboardOpenCloseListener = listener; + } + + /** + * Set the listener for the event when any of the emojicon is clicked + */ + public void setOnEmojiconClickedListener(OnEmojiconClickedListener listener) { + this.onEmojiconClickedListener = listener; + } + + /** + * Set the listener for the event when backspace on emojicon popup is clicked + */ + public void setOnEmojiconBackspaceClickedListener(OnEmojiconBackspaceClickedListener listener) { + this.onEmojiconBackspaceClickedListener = listener; + } + + /** + * Use this function to show the emoji popup. + * NOTE: Since, the soft keyboard sizes are variable on different android devices, the + * library needs you to open the soft keyboard atleast once before calling this function. + * If that is not possible see showAtBottomPending() function. + */ + public void showAtBottom() { + showAtLocation(rootView, Gravity.BOTTOM, 0, 0); + } + + /** + * Use this function when the soft keyboard has not been opened yet. This + * will show the emoji popup after the keyboard is up next time. + * Generally, you will be calling InputMethodManager.showSoftInput function after + * calling this function. + */ + public void showAtBottomPending() { + if (isKeyBoardOpen()) + showAtBottom(); + else + pendingOpen = true; + } + + /** + * @return Returns true if the soft keyboard is open, false otherwise. + */ + public Boolean isKeyBoardOpen() { + return isOpened; + } + + /** + * Dismiss the popup + */ + @Override + public void dismiss() { + super.dismiss(); + EmojiconRecentsManager + .getInstance(mContext).saveRecents(); + } + + /** + * Call this function to resize the emoji popup according to your soft keyboard size + */ + public void setSizeForSoftKeyboard() { + rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + Rect r = new Rect(); + rootView.getWindowVisibleDisplayFrame(r); + + int screenHeight = getUsableScreenHeight(); + int heightDifference = screenHeight + - (r.bottom - r.top); + int resourceId = mContext.getResources() + .getIdentifier("status_bar_height", + "dimen", "android"); + if (resourceId > 0) { + heightDifference -= mContext.getResources() + .getDimensionPixelSize(resourceId); + } + if (heightDifference > 100) { + keyBoardHeight = heightDifference; + setSize(LayoutParams.MATCH_PARENT, keyBoardHeight); + if (isOpened == false) { + if (onSoftKeyboardOpenCloseListener != null) + onSoftKeyboardOpenCloseListener.onKeyboardOpen(keyBoardHeight); + } + isOpened = true; + if (pendingOpen) { + showAtBottom(); + pendingOpen = false; + } + } else { + isOpened = false; + if (onSoftKeyboardOpenCloseListener != null) + onSoftKeyboardOpenCloseListener.onKeyboardClose(); + } + } + }); + } + + private int getUsableScreenHeight() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + DisplayMetrics metrics = new DisplayMetrics(); + + WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); + windowManager.getDefaultDisplay().getMetrics(metrics); + + return metrics.heightPixels; + + } else { + return rootView.getRootView().getHeight(); + } + } + + /** + * Manually set the popup window size + * + * @param width Width of the popup + * @param height Height of the popup + */ + public void setSize(int width, int height) { + setWidth(width); + setHeight(height); + } + + private View createCustomView() { + LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); + View view = inflater.inflate(R.layout.emojicons, null, false); + emojisPager = (ViewPager) view.findViewById(R.id.emojis_pager); + emojisPager.setOnPageChangeListener(this); + EmojiconRecents recents = this; + mEmojisAdapter = new EmojisPagerAdapter( + Arrays.asList( + new EmojiconRecentsGridView(mContext, null, null, this), + new EmojiconGridView(mContext, People.DATA, recents, this), + new EmojiconGridView(mContext, Nature.DATA, recents, this), + new EmojiconGridView(mContext, Objects.DATA, recents, this), + new EmojiconGridView(mContext, Places.DATA, recents, this), + new EmojiconGridView(mContext, Symbols.DATA, recents, this) + ) + ); + emojisPager.setAdapter(mEmojisAdapter); + mEmojiTabs = new View[6]; + mEmojiTabs[0] = view.findViewById(R.id.emojis_tab_0_recents); + mEmojiTabs[1] = view.findViewById(R.id.emojis_tab_1_people); + mEmojiTabs[2] = view.findViewById(R.id.emojis_tab_2_nature); + mEmojiTabs[3] = view.findViewById(R.id.emojis_tab_3_objects); + mEmojiTabs[4] = view.findViewById(R.id.emojis_tab_4_cars); + mEmojiTabs[5] = view.findViewById(R.id.emojis_tab_5_punctuation); + for (int i = 0; i < mEmojiTabs.length; i++) { + final int position = i; + mEmojiTabs[i].setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + emojisPager.setCurrentItem(position); + } + }); + } + view.findViewById(R.id.emojis_backspace).setOnTouchListener(new RepeatListener(1000, 50, new OnClickListener() { + + @Override + public void onClick(View v) { + if (onEmojiconBackspaceClickedListener != null) + onEmojiconBackspaceClickedListener.onEmojiconBackspaceClicked(v); + } + })); + + // get last selected page + mRecentsManager = EmojiconRecentsManager.getInstance(view.getContext()); + int page = mRecentsManager.getRecentPage(); + // last page was recents, check if there are recents to use + // if none was found, go to page 1 + if (page == 0 && mRecentsManager.size() == 0) { + page = 1; + } + + if (page == 0) { + onPageSelected(page); + } else { + emojisPager.setCurrentItem(page, false); + } + return view; + } + + @Override + public void addRecentEmoji(Context context, Emojicon emojicon) { + EmojiconRecentsGridView fragment = ((EmojisPagerAdapter) emojisPager.getAdapter()).getRecentFragment(); + fragment.addRecentEmoji(context, emojicon); + } + + + @Override + public void onPageScrolled(int i, float v, int i2) { + } + + @Override + public void onPageSelected(int i) { + if (mEmojiTabLastSelectedIndex == i) { + return; + } + switch (i) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + if (mEmojiTabLastSelectedIndex >= 0 && mEmojiTabLastSelectedIndex < mEmojiTabs.length) { + mEmojiTabs[mEmojiTabLastSelectedIndex].setSelected(false); + } + mEmojiTabs[i].setSelected(true); + mEmojiTabLastSelectedIndex = i; + mRecentsManager.setRecentPage(i); + break; + } + } + + @Override + public void onPageScrollStateChanged(int i) { + } + + private static class EmojisPagerAdapter extends PagerAdapter { + private List<EmojiconGridView> views; + + public EmojiconRecentsGridView getRecentFragment() { + for (EmojiconGridView it : views) { + if (it instanceof EmojiconRecentsGridView) + return (EmojiconRecentsGridView) it; + } + return null; + } + + public EmojisPagerAdapter(List<EmojiconGridView> views) { + super(); + this.views = views; + } + + @Override + public int getCount() { + return views.size(); + } + + + @Override + public Object instantiateItem(ViewGroup container, int position) { + View v = views.get(position).rootView; + ((ViewPager) container).addView(v, 0); + return v; + } + + @Override + public void destroyItem(ViewGroup container, int position, Object view) { + ((ViewPager) container).removeView((View) view); + } + + @Override + public boolean isViewFromObject(View view, Object key) { + return key == view; + } + } + + /** + * A class, that can be used as a TouchListener on any view (e.g. a Button). + * It cyclically runs a clickListener, emulating keyboard-like behaviour. First + * click is fired immediately, next before initialInterval, and subsequent before + * normalInterval. + * <p/> + * <p>Interval is scheduled before the onClick completes, so it has to run fast. + * If it runs slow, it does not generate skipped onClicks. + */ + public static class RepeatListener implements View.OnTouchListener { + + private Handler handler = new Handler(); + + private int initialInterval; + private final int normalInterval; + private final View.OnClickListener clickListener; + + private Runnable handlerRunnable = new Runnable() { + @Override + public void run() { + if (downView == null) { + return; + } + handler.removeCallbacksAndMessages(downView); + handler.postAtTime(this, downView, SystemClock.uptimeMillis() + normalInterval); + clickListener.onClick(downView); + } + }; + + private View downView; + + /** + * @param initialInterval The interval before first click event + * @param normalInterval The interval before second and subsequent click + * events + * @param clickListener The OnClickListener, that will be called + * periodically + */ + public RepeatListener(int initialInterval, int normalInterval, View.OnClickListener clickListener) { + if (clickListener == null) + throw new IllegalArgumentException("null runnable"); + if (initialInterval < 0 || normalInterval < 0) + throw new IllegalArgumentException("negative interval"); + + this.initialInterval = initialInterval; + this.normalInterval = normalInterval; + this.clickListener = clickListener; + } + + public boolean onTouch(View view, MotionEvent motionEvent) { + switch (motionEvent.getAction()) { + case MotionEvent.ACTION_DOWN: + downView = view; + handler.removeCallbacks(handlerRunnable); + handler.postAtTime(handlerRunnable, downView, SystemClock.uptimeMillis() + initialInterval); + clickListener.onClick(view); + return true; + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_CANCEL: + case MotionEvent.ACTION_OUTSIDE: + handler.removeCallbacksAndMessages(downView); + downView = null; + return true; + } + return false; + } + } + + public interface OnEmojiconBackspaceClickedListener { + void onEmojiconBackspaceClicked(View v); + } + + public interface OnSoftKeyboardOpenCloseListener { + void onKeyboardOpen(int keyBoardHeight); + + void onKeyboardClose(); + } } diff --git a/libs/emojicon/src/main/AndroidManifest.xml b/libs/emojicon/src/main/AndroidManifest.xml index a07b8e21b..135e6fec5 100644 --- a/libs/emojicon/src/main/AndroidManifest.xml +++ b/libs/emojicon/src/main/AndroidManifest.xml @@ -1,9 +1,12 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="github.ankushsachdeva.emojicon"> - <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/> + <uses-sdk + android:minSdkVersion="8" + android:targetSdkVersion="19" /> - <application android:allowBackup="true" + <application + android:allowBackup="true" android:label="@string/app_name" android:icon="@drawable/ic_launcher"> diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiAdapter.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiAdapter.java index e33d8d6b9..c6efb45a3 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiAdapter.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiAdapter.java @@ -32,7 +32,8 @@ import github.ankushsachdeva.emojicon.emoji.Emojicon; * @author Ankush Sachdeva (sankush@yahoo.co.in) */ class EmojiAdapter extends ArrayAdapter<Emojicon> { - OnEmojiconClickedListener emojiClickListener; + OnEmojiconClickedListener emojiClickListener; + public EmojiAdapter(Context context, List<Emojicon> data) { super(context, R.layout.emojicon_item, data); } @@ -40,11 +41,11 @@ class EmojiAdapter extends ArrayAdapter<Emojicon> { public EmojiAdapter(Context context, Emojicon[] data) { super(context, R.layout.emojicon_item, data); } - - public void setEmojiClickListener(OnEmojiconClickedListener listener){ - this.emojiClickListener = listener; + + public void setEmojiClickListener(OnEmojiconClickedListener listener) { + this.emojiClickListener = listener; } - + @Override public View getView(final int position, View convertView, ViewGroup parent) { View v = convertView; @@ -58,11 +59,11 @@ class EmojiAdapter extends ArrayAdapter<Emojicon> { ViewHolder holder = (ViewHolder) v.getTag(); holder.icon.setText(emoji.getEmoji()); holder.icon.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - emojiClickListener.onEmojiconClicked(getItem(position)); - } - }); + @Override + public void onClick(View v) { + emojiClickListener.onEmojiconClicked(getItem(position)); + } + }); return v; } diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconGridView.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconGridView.java index 1f2c6bb46..1feda8ac6 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconGridView.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconGridView.java @@ -29,48 +29,48 @@ import github.ankushsachdeva.emojicon.emoji.People; /** * @author Hieu Rocker (rockerhieu@gmail.com) - * @author Ankush Sachdeva (sankush@yahoo.co.in) + * @author Ankush Sachdeva (sankush@yahoo.co.in) */ -public class EmojiconGridView{ - public View rootView; - EmojiconsPopup mEmojiconPopup; +public class EmojiconGridView { + public View rootView; + EmojiconsPopup mEmojiconPopup; EmojiconRecents mRecents; Emojicon[] mData; - + public EmojiconGridView(Context context, Emojicon[] emojicons, EmojiconRecents recents, EmojiconsPopup emojiconPopup) { - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); - mEmojiconPopup = emojiconPopup; - rootView = inflater.inflate(R.layout.emojicon_grid, null); - setRecents(recents); - GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView); - if (emojicons== null) { - mData = People.DATA; - } else { - Object[] o = (Object[]) emojicons; - mData = Arrays.asList(o).toArray(new Emojicon[o.length]); - } - EmojiAdapter mAdapter = new EmojiAdapter(rootView.getContext(), mData); - mAdapter.setEmojiClickListener(new OnEmojiconClickedListener() { - - @Override - public void onEmojiconClicked(Emojicon emojicon) { - if (mEmojiconPopup.onEmojiconClickedListener != null) { - mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon); - } - if (mRecents != null) { - mRecents.addRecentEmoji(rootView.getContext(), emojicon); - } - } - }); - gridView.setAdapter(mAdapter); - } - - private void setRecents(EmojiconRecents recents) { + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); + mEmojiconPopup = emojiconPopup; + rootView = inflater.inflate(R.layout.emojicon_grid, null); + setRecents(recents); + GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView); + if (emojicons == null) { + mData = People.DATA; + } else { + Object[] o = (Object[]) emojicons; + mData = Arrays.asList(o).toArray(new Emojicon[o.length]); + } + EmojiAdapter mAdapter = new EmojiAdapter(rootView.getContext(), mData); + mAdapter.setEmojiClickListener(new OnEmojiconClickedListener() { + + @Override + public void onEmojiconClicked(Emojicon emojicon) { + if (mEmojiconPopup.onEmojiconClickedListener != null) { + mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon); + } + if (mRecents != null) { + mRecents.addRecentEmoji(rootView.getContext(), emojicon); + } + } + }); + gridView.setAdapter(mAdapter); + } + + private void setRecents(EmojiconRecents recents) { mRecents = recents; } public interface OnEmojiconClickedListener { void onEmojiconClicked(Emojicon emojicon); } - + } diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java index 8fac5385b..b9c214bad 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java @@ -1394,7 +1394,7 @@ public final class EmojiconHandler { public static void addEmojis(Context context, Spannable text, int emojiSize, int index, int length) { int textLength = text.length(); int textLengthToProcessMax = textLength - index; - int textLengthToProcess = length < 0 || length >= textLengthToProcessMax ? textLength : (length+index); + int textLengthToProcess = length < 0 || length >= textLengthToProcessMax ? textLength : (length + index); // remove spans throughout all text EmojiconSpan[] oldSpans = text.getSpans(0, textLength, EmojiconSpan.class); diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecents.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecents.java index c7a90c837..e3274ed77 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecents.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecents.java @@ -21,8 +21,8 @@ import android.content.Context; import github.ankushsachdeva.emojicon.emoji.Emojicon; /** -* @author Daniele Ricci -*/ + * @author Daniele Ricci + */ public interface EmojiconRecents { public void addRecentEmoji(Context context, Emojicon emojicon); } diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecentsGridView.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecentsGridView.java index d4f2211e7..c07ba082d 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecentsGridView.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecentsGridView.java @@ -23,26 +23,26 @@ import github.ankushsachdeva.emojicon.emoji.Emojicon; /** * @author Daniele Ricci - * @author Ankush Sachdeva (sankush@yahoo.co.in) + * @author Ankush Sachdeva (sankush@yahoo.co.in) */ public class EmojiconRecentsGridView extends EmojiconGridView implements EmojiconRecents { - EmojiAdapter mAdapter; - - public EmojiconRecentsGridView(Context context, Emojicon[] emojicons, - EmojiconRecents recents,EmojiconsPopup emojiconsPopup) { - super(context, emojicons, recents, emojiconsPopup); - EmojiconRecentsManager recents1 = EmojiconRecentsManager - .getInstance(rootView.getContext()); - mAdapter = new EmojiAdapter(rootView.getContext(), recents1); - mAdapter.setEmojiClickListener(new OnEmojiconClickedListener() { - - @Override - public void onEmojiconClicked(Emojicon emojicon) { - if (mEmojiconPopup.onEmojiconClickedListener != null) { - mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon); - } - } - }); + EmojiAdapter mAdapter; + + public EmojiconRecentsGridView(Context context, Emojicon[] emojicons, + EmojiconRecents recents, EmojiconsPopup emojiconsPopup) { + super(context, emojicons, recents, emojiconsPopup); + EmojiconRecentsManager recents1 = EmojiconRecentsManager + .getInstance(rootView.getContext()); + mAdapter = new EmojiAdapter(rootView.getContext(), recents1); + mAdapter.setEmojiClickListener(new OnEmojiconClickedListener() { + + @Override + public void onEmojiconClicked(Emojicon emojicon) { + if (mEmojiconPopup.onEmojiconClickedListener != null) { + mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon); + } + } + }); GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView); gridView.setAdapter(mAdapter); } @@ -50,7 +50,7 @@ public class EmojiconRecentsGridView extends EmojiconGridView implements Emojico @Override public void addRecentEmoji(Context context, Emojicon emojicon) { EmojiconRecentsManager recents = EmojiconRecentsManager - .getInstance(context); + .getInstance(context); recents.push(emojicon); // notify dataset changed diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java index 177f11591..f208b10c4 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java @@ -26,8 +26,8 @@ import github.ankushsachdeva.emojicon.emoji.Emojicon; /** -* @author Daniele Ricci -*/ + * @author Daniele Ricci + */ public class EmojiconRecentsManager extends ArrayList<Emojicon> { private static final String PREFERENCE_NAME = "emojicon"; @@ -88,7 +88,7 @@ public class EmojiconRecentsManager extends ArrayList<Emojicon> { boolean ret = super.remove(object); return ret; } - + private SharedPreferences getPreferences() { return mContext.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); } @@ -99,14 +99,13 @@ public class EmojiconRecentsManager extends ArrayList<Emojicon> { StringTokenizer tokenizer = new StringTokenizer(str, "~"); while (tokenizer.hasMoreTokens()) { try { - add(new Emojicon(tokenizer.nextToken())); - } - catch (NumberFormatException e) { + add(new Emojicon(tokenizer.nextToken())); + } catch (NumberFormatException e) { // ignored } } } - + public void saveRecents() { StringBuilder str = new StringBuilder(); int c = size(); diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconsPopup.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconsPopup.java index 2a35aa9c0..f7d68ddc5 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconsPopup.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconsPopup.java @@ -53,372 +53,376 @@ import github.ankushsachdeva.emojicon.emoji.Symbols; */ public class EmojiconsPopup extends PopupWindow implements ViewPager.OnPageChangeListener, EmojiconRecents { - private int mEmojiTabLastSelectedIndex = -1; - private View[] mEmojiTabs; - private PagerAdapter mEmojisAdapter; - private EmojiconRecentsManager mRecentsManager; - private int keyBoardHeight = 0; - private Boolean pendingOpen = false; - private Boolean isOpened = false; - OnEmojiconClickedListener onEmojiconClickedListener; - OnEmojiconBackspaceClickedListener onEmojiconBackspaceClickedListener; - OnSoftKeyboardOpenCloseListener onSoftKeyboardOpenCloseListener; - View rootView; - Context mContext; - - private ViewPager emojisPager; - /** - * Constructor - * @param rootView The top most layout in your view hierarchy. The difference of this view and the screen height will be used to calculate the keyboard height. - * @param mContext The context of current activity. - */ - public EmojiconsPopup(View rootView, Context mContext){ - super(mContext); - this.mContext = mContext; - this.rootView = rootView; - View customView = createCustomView(); - setContentView(customView); - setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); - //default size - setSize((int) mContext.getResources().getDimension(R.dimen.keyboard_height), LayoutParams.MATCH_PARENT); - } - /** - * Set the listener for the event of keyboard opening or closing. - */ - public void setOnSoftKeyboardOpenCloseListener(OnSoftKeyboardOpenCloseListener listener){ - this.onSoftKeyboardOpenCloseListener = listener; - } - - /** - * Set the listener for the event when any of the emojicon is clicked - */ - public void setOnEmojiconClickedListener(OnEmojiconClickedListener listener){ - this.onEmojiconClickedListener = listener; - } - - /** - * Set the listener for the event when backspace on emojicon popup is clicked - */ - public void setOnEmojiconBackspaceClickedListener(OnEmojiconBackspaceClickedListener listener){ - this.onEmojiconBackspaceClickedListener = listener; - } - - /** - * Use this function to show the emoji popup. - * NOTE: Since, the soft keyboard sizes are variable on different android devices, the - * library needs you to open the soft keyboard atleast once before calling this function. - * If that is not possible see showAtBottomPending() function. - * - */ - public void showAtBottom(){ - showAtLocation(rootView, Gravity.BOTTOM, 0, 0); - } - /** - * Use this function when the soft keyboard has not been opened yet. This - * will show the emoji popup after the keyboard is up next time. - * Generally, you will be calling InputMethodManager.showSoftInput function after - * calling this function. - */ - public void showAtBottomPending(){ - if(isKeyBoardOpen()) - showAtBottom(); - else - pendingOpen = true; - } - - /** - * - * @return Returns true if the soft keyboard is open, false otherwise. - */ - public Boolean isKeyBoardOpen(){ - return isOpened; - } - - /** - * Dismiss the popup - */ - @Override - public void dismiss() { - super.dismiss(); - EmojiconRecentsManager - .getInstance(mContext).saveRecents(); - } - - /** - * Call this function to resize the emoji popup according to your soft keyboard size - */ - public void setSizeForSoftKeyboard(){ - rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - Rect r = new Rect(); - rootView.getWindowVisibleDisplayFrame(r); - - int screenHeight = getUsableScreenHeight(); - int heightDifference = screenHeight - - (r.bottom - r.top); - int resourceId = mContext.getResources() - .getIdentifier("status_bar_height", - "dimen", "android"); - if (resourceId > 0) { - heightDifference -= mContext.getResources() - .getDimensionPixelSize(resourceId); - } - if (heightDifference > 100) { - keyBoardHeight = heightDifference; - setSize(LayoutParams.MATCH_PARENT, keyBoardHeight); - if(isOpened == false){ - if(onSoftKeyboardOpenCloseListener!=null) - onSoftKeyboardOpenCloseListener.onKeyboardOpen(keyBoardHeight); - } - isOpened = true; - if(pendingOpen){ - showAtBottom(); - pendingOpen = false; - } - } - else{ - isOpened = false; - if(onSoftKeyboardOpenCloseListener!=null) - onSoftKeyboardOpenCloseListener.onKeyboardClose(); - } - } - }); - } - - private int getUsableScreenHeight() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - DisplayMetrics metrics = new DisplayMetrics(); - - WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); - windowManager.getDefaultDisplay().getMetrics(metrics); - - return metrics.heightPixels; - - } else { - return rootView.getRootView().getHeight(); - } - } - - /** - * Manually set the popup window size - * @param width Width of the popup - * @param height Height of the popup - */ - public void setSize(int width, int height){ - setWidth(width); - setHeight(height); - } - - private View createCustomView() { - LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); - View view = inflater.inflate(R.layout.emojicons, null, false); - emojisPager = (ViewPager) view.findViewById(R.id.emojis_pager); - emojisPager.setOnPageChangeListener(this); - EmojiconRecents recents = this; - mEmojisAdapter = new EmojisPagerAdapter( - Arrays.asList( - new EmojiconRecentsGridView(mContext, null, null, this), - new EmojiconGridView(mContext, People.DATA, recents, this), - new EmojiconGridView(mContext, Nature.DATA, recents, this), - new EmojiconGridView(mContext, Objects.DATA, recents, this), - new EmojiconGridView(mContext, Places.DATA, recents, this), - new EmojiconGridView(mContext, Symbols.DATA, recents, this) - ) - ); - emojisPager.setAdapter(mEmojisAdapter); - mEmojiTabs = new View[6]; - mEmojiTabs[0] = view.findViewById(R.id.emojis_tab_0_recents); - mEmojiTabs[1] = view.findViewById(R.id.emojis_tab_1_people); - mEmojiTabs[2] = view.findViewById(R.id.emojis_tab_2_nature); - mEmojiTabs[3] = view.findViewById(R.id.emojis_tab_3_objects); - mEmojiTabs[4] = view.findViewById(R.id.emojis_tab_4_cars); - mEmojiTabs[5] = view.findViewById(R.id.emojis_tab_5_punctuation); - for (int i = 0; i < mEmojiTabs.length; i++) { - final int position = i; - mEmojiTabs[i].setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - emojisPager.setCurrentItem(position); - } - }); - } - view.findViewById(R.id.emojis_backspace).setOnTouchListener(new RepeatListener(1000, 50, new OnClickListener() { - - @Override - public void onClick(View v) { - if(onEmojiconBackspaceClickedListener != null) - onEmojiconBackspaceClickedListener.onEmojiconBackspaceClicked(v); - } - })); - - // get last selected page - mRecentsManager = EmojiconRecentsManager.getInstance(view.getContext()); - int page = mRecentsManager.getRecentPage(); - // last page was recents, check if there are recents to use - // if none was found, go to page 1 - if (page == 0 && mRecentsManager.size() == 0) { - page = 1; - } - - if (page == 0) { - onPageSelected(page); - } - else { - emojisPager.setCurrentItem(page, false); - } - return view; - } - - @Override - public void addRecentEmoji(Context context, Emojicon emojicon) { - EmojiconRecentsGridView fragment = ((EmojisPagerAdapter)emojisPager.getAdapter()).getRecentFragment(); - fragment.addRecentEmoji(context, emojicon); - } - - - @Override - public void onPageScrolled(int i, float v, int i2) { - } - - @Override - public void onPageSelected(int i) { - if (mEmojiTabLastSelectedIndex == i) { - return; - } - switch (i) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - if (mEmojiTabLastSelectedIndex >= 0 && mEmojiTabLastSelectedIndex < mEmojiTabs.length) { - mEmojiTabs[mEmojiTabLastSelectedIndex].setSelected(false); - } - mEmojiTabs[i].setSelected(true); - mEmojiTabLastSelectedIndex = i; - mRecentsManager.setRecentPage(i); - break; - } - } - - @Override - public void onPageScrollStateChanged(int i) { - } - - private static class EmojisPagerAdapter extends PagerAdapter { - private List<EmojiconGridView> views; - public EmojiconRecentsGridView getRecentFragment(){ - for (EmojiconGridView it : views) { - if(it instanceof EmojiconRecentsGridView) - return (EmojiconRecentsGridView)it; - } - return null; - } - public EmojisPagerAdapter(List<EmojiconGridView> views) { - super(); - this.views = views; - } - - @Override - public int getCount() { - return views.size(); - } - - - @Override - public Object instantiateItem(ViewGroup container, int position) { - View v = views.get(position).rootView; - ((ViewPager)container).addView(v, 0); - return v; - } - - @Override - public void destroyItem(ViewGroup container, int position, Object view) { - ((ViewPager)container).removeView((View)view); - } - - @Override - public boolean isViewFromObject(View view, Object key) { - return key == view; - } - } - - /** - * A class, that can be used as a TouchListener on any view (e.g. a Button). - * It cyclically runs a clickListener, emulating keyboard-like behaviour. First - * click is fired immediately, next before initialInterval, and subsequent before - * normalInterval. - * <p/> - * <p>Interval is scheduled before the onClick completes, so it has to run fast. - * If it runs slow, it does not generate skipped onClicks. - */ - public static class RepeatListener implements View.OnTouchListener { - - private Handler handler = new Handler(); - - private int initialInterval; - private final int normalInterval; - private final View.OnClickListener clickListener; - - private Runnable handlerRunnable = new Runnable() { - @Override - public void run() { - if (downView == null) { - return; - } - handler.removeCallbacksAndMessages(downView); - handler.postAtTime(this, downView, SystemClock.uptimeMillis() + normalInterval); - clickListener.onClick(downView); - } - }; - - private View downView; - - /** - * @param initialInterval The interval before first click event - * @param normalInterval The interval before second and subsequent click - * events - * @param clickListener The OnClickListener, that will be called - * periodically - */ - public RepeatListener(int initialInterval, int normalInterval, View.OnClickListener clickListener) { - if (clickListener == null) - throw new IllegalArgumentException("null runnable"); - if (initialInterval < 0 || normalInterval < 0) - throw new IllegalArgumentException("negative interval"); - - this.initialInterval = initialInterval; - this.normalInterval = normalInterval; - this.clickListener = clickListener; - } - - public boolean onTouch(View view, MotionEvent motionEvent) { - switch (motionEvent.getAction()) { - case MotionEvent.ACTION_DOWN: - downView = view; - handler.removeCallbacks(handlerRunnable); - handler.postAtTime(handlerRunnable, downView, SystemClock.uptimeMillis() + initialInterval); - clickListener.onClick(view); - return true; - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_CANCEL: - case MotionEvent.ACTION_OUTSIDE: - handler.removeCallbacksAndMessages(downView); - downView = null; - return true; - } - return false; - } - } - - public interface OnEmojiconBackspaceClickedListener { - void onEmojiconBackspaceClicked(View v); - } - - public interface OnSoftKeyboardOpenCloseListener{ - void onKeyboardOpen(int keyBoardHeight); - void onKeyboardClose(); - } + private int mEmojiTabLastSelectedIndex = -1; + private View[] mEmojiTabs; + private PagerAdapter mEmojisAdapter; + private EmojiconRecentsManager mRecentsManager; + private int keyBoardHeight = 0; + private Boolean pendingOpen = false; + private Boolean isOpened = false; + OnEmojiconClickedListener onEmojiconClickedListener; + OnEmojiconBackspaceClickedListener onEmojiconBackspaceClickedListener; + OnSoftKeyboardOpenCloseListener onSoftKeyboardOpenCloseListener; + View rootView; + Context mContext; + + private ViewPager emojisPager; + + /** + * Constructor + * + * @param rootView The top most layout in your view hierarchy. The difference of this view and the screen height will be used to calculate the keyboard height. + * @param mContext The context of current activity. + */ + public EmojiconsPopup(View rootView, Context mContext) { + super(mContext); + this.mContext = mContext; + this.rootView = rootView; + View customView = createCustomView(); + setContentView(customView); + setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); + //default size + setSize((int) mContext.getResources().getDimension(R.dimen.keyboard_height), LayoutParams.MATCH_PARENT); + } + + /** + * Set the listener for the event of keyboard opening or closing. + */ + public void setOnSoftKeyboardOpenCloseListener(OnSoftKeyboardOpenCloseListener listener) { + this.onSoftKeyboardOpenCloseListener = listener; + } + + /** + * Set the listener for the event when any of the emojicon is clicked + */ + public void setOnEmojiconClickedListener(OnEmojiconClickedListener listener) { + this.onEmojiconClickedListener = listener; + } + + /** + * Set the listener for the event when backspace on emojicon popup is clicked + */ + public void setOnEmojiconBackspaceClickedListener(OnEmojiconBackspaceClickedListener listener) { + this.onEmojiconBackspaceClickedListener = listener; + } + + /** + * Use this function to show the emoji popup. + * NOTE: Since, the soft keyboard sizes are variable on different android devices, the + * library needs you to open the soft keyboard atleast once before calling this function. + * If that is not possible see showAtBottomPending() function. + */ + public void showAtBottom() { + showAtLocation(rootView, Gravity.BOTTOM, 0, 0); + } + + /** + * Use this function when the soft keyboard has not been opened yet. This + * will show the emoji popup after the keyboard is up next time. + * Generally, you will be calling InputMethodManager.showSoftInput function after + * calling this function. + */ + public void showAtBottomPending() { + if (isKeyBoardOpen()) + showAtBottom(); + else + pendingOpen = true; + } + + /** + * @return Returns true if the soft keyboard is open, false otherwise. + */ + public Boolean isKeyBoardOpen() { + return isOpened; + } + + /** + * Dismiss the popup + */ + @Override + public void dismiss() { + super.dismiss(); + EmojiconRecentsManager + .getInstance(mContext).saveRecents(); + } + + /** + * Call this function to resize the emoji popup according to your soft keyboard size + */ + public void setSizeForSoftKeyboard() { + rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + Rect r = new Rect(); + rootView.getWindowVisibleDisplayFrame(r); + + int screenHeight = getUsableScreenHeight(); + int heightDifference = screenHeight + - (r.bottom - r.top); + int resourceId = mContext.getResources() + .getIdentifier("status_bar_height", + "dimen", "android"); + if (resourceId > 0) { + heightDifference -= mContext.getResources() + .getDimensionPixelSize(resourceId); + } + if (heightDifference > 100) { + keyBoardHeight = heightDifference; + setSize(LayoutParams.MATCH_PARENT, keyBoardHeight); + if (isOpened == false) { + if (onSoftKeyboardOpenCloseListener != null) + onSoftKeyboardOpenCloseListener.onKeyboardOpen(keyBoardHeight); + } + isOpened = true; + if (pendingOpen) { + showAtBottom(); + pendingOpen = false; + } + } else { + isOpened = false; + if (onSoftKeyboardOpenCloseListener != null) + onSoftKeyboardOpenCloseListener.onKeyboardClose(); + } + } + }); + } + + private int getUsableScreenHeight() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + DisplayMetrics metrics = new DisplayMetrics(); + + WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); + windowManager.getDefaultDisplay().getMetrics(metrics); + + return metrics.heightPixels; + + } else { + return rootView.getRootView().getHeight(); + } + } + + /** + * Manually set the popup window size + * + * @param width Width of the popup + * @param height Height of the popup + */ + public void setSize(int width, int height) { + setWidth(width); + setHeight(height); + } + + private View createCustomView() { + LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); + View view = inflater.inflate(R.layout.emojicons, null, false); + emojisPager = (ViewPager) view.findViewById(R.id.emojis_pager); + emojisPager.setOnPageChangeListener(this); + EmojiconRecents recents = this; + mEmojisAdapter = new EmojisPagerAdapter( + Arrays.asList( + new EmojiconRecentsGridView(mContext, null, null, this), + new EmojiconGridView(mContext, People.DATA, recents, this), + new EmojiconGridView(mContext, Nature.DATA, recents, this), + new EmojiconGridView(mContext, Objects.DATA, recents, this), + new EmojiconGridView(mContext, Places.DATA, recents, this), + new EmojiconGridView(mContext, Symbols.DATA, recents, this) + ) + ); + emojisPager.setAdapter(mEmojisAdapter); + mEmojiTabs = new View[6]; + mEmojiTabs[0] = view.findViewById(R.id.emojis_tab_0_recents); + mEmojiTabs[1] = view.findViewById(R.id.emojis_tab_1_people); + mEmojiTabs[2] = view.findViewById(R.id.emojis_tab_2_nature); + mEmojiTabs[3] = view.findViewById(R.id.emojis_tab_3_objects); + mEmojiTabs[4] = view.findViewById(R.id.emojis_tab_4_cars); + mEmojiTabs[5] = view.findViewById(R.id.emojis_tab_5_punctuation); + for (int i = 0; i < mEmojiTabs.length; i++) { + final int position = i; + mEmojiTabs[i].setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + emojisPager.setCurrentItem(position); + } + }); + } + view.findViewById(R.id.emojis_backspace).setOnTouchListener(new RepeatListener(1000, 50, new OnClickListener() { + + @Override + public void onClick(View v) { + if (onEmojiconBackspaceClickedListener != null) + onEmojiconBackspaceClickedListener.onEmojiconBackspaceClicked(v); + } + })); + + // get last selected page + mRecentsManager = EmojiconRecentsManager.getInstance(view.getContext()); + int page = mRecentsManager.getRecentPage(); + // last page was recents, check if there are recents to use + // if none was found, go to page 1 + if (page == 0 && mRecentsManager.size() == 0) { + page = 1; + } + + if (page == 0) { + onPageSelected(page); + } else { + emojisPager.setCurrentItem(page, false); + } + return view; + } + + @Override + public void addRecentEmoji(Context context, Emojicon emojicon) { + EmojiconRecentsGridView fragment = ((EmojisPagerAdapter) emojisPager.getAdapter()).getRecentFragment(); + fragment.addRecentEmoji(context, emojicon); + } + + + @Override + public void onPageScrolled(int i, float v, int i2) { + } + + @Override + public void onPageSelected(int i) { + if (mEmojiTabLastSelectedIndex == i) { + return; + } + switch (i) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + if (mEmojiTabLastSelectedIndex >= 0 && mEmojiTabLastSelectedIndex < mEmojiTabs.length) { + mEmojiTabs[mEmojiTabLastSelectedIndex].setSelected(false); + } + mEmojiTabs[i].setSelected(true); + mEmojiTabLastSelectedIndex = i; + mRecentsManager.setRecentPage(i); + break; + } + } + + @Override + public void onPageScrollStateChanged(int i) { + } + + private static class EmojisPagerAdapter extends PagerAdapter { + private List<EmojiconGridView> views; + + public EmojiconRecentsGridView getRecentFragment() { + for (EmojiconGridView it : views) { + if (it instanceof EmojiconRecentsGridView) + return (EmojiconRecentsGridView) it; + } + return null; + } + + public EmojisPagerAdapter(List<EmojiconGridView> views) { + super(); + this.views = views; + } + + @Override + public int getCount() { + return views.size(); + } + + + @Override + public Object instantiateItem(ViewGroup container, int position) { + View v = views.get(position).rootView; + ((ViewPager) container).addView(v, 0); + return v; + } + + @Override + public void destroyItem(ViewGroup container, int position, Object view) { + ((ViewPager) container).removeView((View) view); + } + + @Override + public boolean isViewFromObject(View view, Object key) { + return key == view; + } + } + + /** + * A class, that can be used as a TouchListener on any view (e.g. a Button). + * It cyclically runs a clickListener, emulating keyboard-like behaviour. First + * click is fired immediately, next before initialInterval, and subsequent before + * normalInterval. + * <p/> + * <p>Interval is scheduled before the onClick completes, so it has to run fast. + * If it runs slow, it does not generate skipped onClicks. + */ + public static class RepeatListener implements View.OnTouchListener { + + private Handler handler = new Handler(); + + private int initialInterval; + private final int normalInterval; + private final View.OnClickListener clickListener; + + private Runnable handlerRunnable = new Runnable() { + @Override + public void run() { + if (downView == null) { + return; + } + handler.removeCallbacksAndMessages(downView); + handler.postAtTime(this, downView, SystemClock.uptimeMillis() + normalInterval); + clickListener.onClick(downView); + } + }; + + private View downView; + + /** + * @param initialInterval The interval before first click event + * @param normalInterval The interval before second and subsequent click + * events + * @param clickListener The OnClickListener, that will be called + * periodically + */ + public RepeatListener(int initialInterval, int normalInterval, View.OnClickListener clickListener) { + if (clickListener == null) + throw new IllegalArgumentException("null runnable"); + if (initialInterval < 0 || normalInterval < 0) + throw new IllegalArgumentException("negative interval"); + + this.initialInterval = initialInterval; + this.normalInterval = normalInterval; + this.clickListener = clickListener; + } + + public boolean onTouch(View view, MotionEvent motionEvent) { + switch (motionEvent.getAction()) { + case MotionEvent.ACTION_DOWN: + downView = view; + handler.removeCallbacks(handlerRunnable); + handler.postAtTime(handlerRunnable, downView, SystemClock.uptimeMillis() + initialInterval); + clickListener.onClick(view); + return true; + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_CANCEL: + case MotionEvent.ACTION_OUTSIDE: + handler.removeCallbacksAndMessages(downView); + downView = null; + return true; + } + return false; + } + } + + public interface OnEmojiconBackspaceClickedListener { + void onEmojiconBackspaceClicked(View v); + } + + public interface OnSoftKeyboardOpenCloseListener { + void onKeyboardOpen(int keyBoardHeight); + + void onKeyboardClose(); + } } diff --git a/libs/emojicon/src/main/res/drawable/ic_emoji_nature_light.xml b/libs/emojicon/src/main/res/drawable/ic_emoji_nature_light.xml index 543409e03..87464fb1e 100644 --- a/libs/emojicon/src/main/res/drawable/ic_emoji_nature_light.xml +++ b/libs/emojicon/src/main/res/drawable/ic_emoji_nature_light.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- /* ** ** Copyright 2013, The Android Open Source Project @@ -19,15 +18,8 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item - android:state_focused="true" - android:drawable="@drawable/ic_emoji_nature_light_activated" /> - <item - android:state_pressed="true" - android:drawable="@drawable/ic_emoji_nature_light_activated" /> - <item - android:state_selected="true" - android:drawable="@drawable/ic_emoji_nature_light_activated" /> - <item - android:drawable="@drawable/ic_emoji_nature_light_normal" /> + <item android:state_focused="true" android:drawable="@drawable/ic_emoji_nature_light_activated" /> + <item android:state_pressed="true" android:drawable="@drawable/ic_emoji_nature_light_activated" /> + <item android:state_selected="true" android:drawable="@drawable/ic_emoji_nature_light_activated" /> + <item android:drawable="@drawable/ic_emoji_nature_light_normal" /> </selector> diff --git a/libs/emojicon/src/main/res/drawable/ic_emoji_objects_light.xml b/libs/emojicon/src/main/res/drawable/ic_emoji_objects_light.xml index 4096e695b..74c80e3d0 100644 --- a/libs/emojicon/src/main/res/drawable/ic_emoji_objects_light.xml +++ b/libs/emojicon/src/main/res/drawable/ic_emoji_objects_light.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- /* ** ** Copyright 2013, The Android Open Source Project @@ -19,14 +18,8 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item - android:state_focused="true" - android:drawable="@drawable/ic_emoji_objects_light_activated" /> - <item - android:state_pressed="true" - android:drawable="@drawable/ic_emoji_objects_light_activated" /> - <item - android:state_selected="true" - android:drawable="@drawable/ic_emoji_objects_light_activated" /> + <item android:state_focused="true" android:drawable="@drawable/ic_emoji_objects_light_activated" /> + <item android:state_pressed="true" android:drawable="@drawable/ic_emoji_objects_light_activated" /> + <item android:state_selected="true" android:drawable="@drawable/ic_emoji_objects_light_activated" /> <item android:drawable="@drawable/ic_emoji_objects_light_normal" /> </selector> diff --git a/libs/emojicon/src/main/res/drawable/ic_emoji_people_light.xml b/libs/emojicon/src/main/res/drawable/ic_emoji_people_light.xml index ea9e406a4..06f7aebbf 100644 --- a/libs/emojicon/src/main/res/drawable/ic_emoji_people_light.xml +++ b/libs/emojicon/src/main/res/drawable/ic_emoji_people_light.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- /* ** ** Copyright 2013, The Android Open Source Project @@ -19,14 +18,8 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item - android:state_focused="true" - android:drawable="@drawable/ic_emoji_people_light_activated" /> - <item - android:state_pressed="true" - android:drawable="@drawable/ic_emoji_people_light_activated" /> - <item - android:state_selected="true" - android:drawable="@drawable/ic_emoji_people_light_activated" /> + <item android:state_focused="true" android:drawable="@drawable/ic_emoji_people_light_activated" /> + <item android:state_pressed="true" android:drawable="@drawable/ic_emoji_people_light_activated" /> + <item android:state_selected="true" android:drawable="@drawable/ic_emoji_people_light_activated" /> <item android:drawable="@drawable/ic_emoji_people_light_normal" /> </selector> diff --git a/libs/emojicon/src/main/res/drawable/ic_emoji_places_light.xml b/libs/emojicon/src/main/res/drawable/ic_emoji_places_light.xml index 312cad9c3..36f258876 100644 --- a/libs/emojicon/src/main/res/drawable/ic_emoji_places_light.xml +++ b/libs/emojicon/src/main/res/drawable/ic_emoji_places_light.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- /* ** ** Copyright 2013, The Android Open Source Project @@ -19,14 +18,8 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item - android:state_focused="true" - android:drawable="@drawable/ic_emoji_places_light_activated" /> - <item - android:state_pressed="true" - android:drawable="@drawable/ic_emoji_places_light_activated" /> - <item - android:state_selected="true" - android:drawable="@drawable/ic_emoji_places_light_activated" /> + <item android:state_focused="true" android:drawable="@drawable/ic_emoji_places_light_activated" /> + <item android:state_pressed="true" android:drawable="@drawable/ic_emoji_places_light_activated" /> + <item android:state_selected="true" android:drawable="@drawable/ic_emoji_places_light_activated" /> <item android:drawable="@drawable/ic_emoji_places_light_normal" /> </selector> diff --git a/libs/emojicon/src/main/res/drawable/ic_emoji_recent_light.xml b/libs/emojicon/src/main/res/drawable/ic_emoji_recent_light.xml index 8c2123f83..90f2c8565 100644 --- a/libs/emojicon/src/main/res/drawable/ic_emoji_recent_light.xml +++ b/libs/emojicon/src/main/res/drawable/ic_emoji_recent_light.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- /* ** ** Copyright 2013, The Android Open Source Project @@ -19,14 +18,8 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item - android:state_focused="true" - android:drawable="@drawable/ic_emoji_recent_light_activated" /> - <item - android:state_pressed="true" - android:drawable="@drawable/ic_emoji_recent_light_activated" /> - <item - android:state_selected="true" - android:drawable="@drawable/ic_emoji_recent_light_activated" /> + <item android:state_focused="true" android:drawable="@drawable/ic_emoji_recent_light_activated" /> + <item android:state_pressed="true" android:drawable="@drawable/ic_emoji_recent_light_activated" /> + <item android:state_selected="true" android:drawable="@drawable/ic_emoji_recent_light_activated" /> <item android:drawable="@drawable/ic_emoji_recent_light_normal" /> </selector> diff --git a/libs/emojicon/src/main/res/drawable/ic_emoji_symbols_light.xml b/libs/emojicon/src/main/res/drawable/ic_emoji_symbols_light.xml index 79aaf0fc5..9077c3289 100644 --- a/libs/emojicon/src/main/res/drawable/ic_emoji_symbols_light.xml +++ b/libs/emojicon/src/main/res/drawable/ic_emoji_symbols_light.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- /* ** ** Copyright 2013, The Android Open Source Project @@ -19,14 +18,8 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item - android:state_focused="true" - android:drawable="@drawable/ic_emoji_symbols_light_activated" /> - <item - android:state_pressed="true" - android:drawable="@drawable/ic_emoji_symbols_light_activated" /> - <item - android:state_selected="true" - android:drawable="@drawable/ic_emoji_symbols_light_activated" /> + <item android:state_focused="true" android:drawable="@drawable/ic_emoji_symbols_light_activated" /> + <item android:state_pressed="true" android:drawable="@drawable/ic_emoji_symbols_light_activated" /> + <item android:state_selected="true" android:drawable="@drawable/ic_emoji_symbols_light_activated" /> <item android:drawable="@drawable/ic_emoji_symbols_light_normal" /> </selector> diff --git a/libs/emojicon/src/main/res/drawable/orca_composer_attach_camera_button.xml b/libs/emojicon/src/main/res/drawable/orca_composer_attach_camera_button.xml index 0b255fb27..56e8d0484 100644 --- a/libs/emojicon/src/main/res/drawable/orca_composer_attach_camera_button.xml +++ b/libs/emojicon/src/main/res/drawable/orca_composer_attach_camera_button.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<selector - xmlns:android="http://schemas.android.com/apk/res/android"> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/orca_attach_camera_pressed" /> <item android:drawable="@drawable/orca_attach_camera_normal" /> </selector>
\ No newline at end of file diff --git a/libs/emojicon/src/main/res/drawable/orca_composer_attach_location_button.xml b/libs/emojicon/src/main/res/drawable/orca_composer_attach_location_button.xml index 4971113aa..be898ebcf 100644 --- a/libs/emojicon/src/main/res/drawable/orca_composer_attach_location_button.xml +++ b/libs/emojicon/src/main/res/drawable/orca_composer_attach_location_button.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ Copyright (C) 2013 Klamr. All rights reserved. ~ ~ This software is the confidential and proprietary information of Klamr or one of its @@ -14,8 +13,7 @@ ~ ITS DERIVATIVES. --> -<selector - xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_pressed="true" android:drawable="@drawable/orca_attach_location_pressed"/> - <item android:drawable="@drawable/orca_attach_location_normal"/> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" android:drawable="@drawable/orca_attach_location_pressed" /> + <item android:drawable="@drawable/orca_attach_location_normal" /> </selector>
\ No newline at end of file diff --git a/libs/emojicon/src/main/res/drawable/orca_composer_attach_photo_button.xml b/libs/emojicon/src/main/res/drawable/orca_composer_attach_photo_button.xml index ca7508dd9..21f8e8e6c 100644 --- a/libs/emojicon/src/main/res/drawable/orca_composer_attach_photo_button.xml +++ b/libs/emojicon/src/main/res/drawable/orca_composer_attach_photo_button.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<selector - xmlns:android="http://schemas.android.com/apk/res/android"> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/orca_attach_photo_pressed" /> <item android:drawable="@drawable/orca_attach_photo_normal" /> </selector>
\ No newline at end of file diff --git a/libs/emojicon/src/main/res/drawable/orca_composer_popup_button.xml b/libs/emojicon/src/main/res/drawable/orca_composer_popup_button.xml index d43dc26e4..dccfb4848 100644 --- a/libs/emojicon/src/main/res/drawable/orca_composer_popup_button.xml +++ b/libs/emojicon/src/main/res/drawable/orca_composer_popup_button.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<selector - xmlns:android="http://schemas.android.com/apk/res/android"> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/orca_composer_popup_pressed" /> <item android:drawable="@drawable/orca_composer_popup_normal" /> </selector>
\ No newline at end of file diff --git a/libs/emojicon/src/main/res/drawable/orca_composer_popup_button_active.xml b/libs/emojicon/src/main/res/drawable/orca_composer_popup_button_active.xml index f5e40ef8c..556d0151b 100644 --- a/libs/emojicon/src/main/res/drawable/orca_composer_popup_button_active.xml +++ b/libs/emojicon/src/main/res/drawable/orca_composer_popup_button_active.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<selector - xmlns:android="http://schemas.android.com/apk/res/android"> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/orca_composer_popup_active_pressed" /> <item android:drawable="@drawable/orca_composer_popup_active_normal" /> </selector>
\ No newline at end of file diff --git a/libs/emojicon/src/main/res/drawable/orca_emoji_backspace_front_button.xml b/libs/emojicon/src/main/res/drawable/orca_emoji_backspace_front_button.xml index a2d2f5b62..e922eb686 100644 --- a/libs/emojicon/src/main/res/drawable/orca_emoji_backspace_front_button.xml +++ b/libs/emojicon/src/main/res/drawable/orca_emoji_backspace_front_button.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_pressed="true" android:drawable="@drawable/orca_emoji_backspace_front_pressed"/> - <item android:drawable="@drawable/orca_emoji_backspace_front_normal"/> + <item android:state_pressed="true" android:drawable="@drawable/orca_emoji_backspace_front_pressed" /> + <item android:drawable="@drawable/orca_emoji_backspace_front_normal" /> </selector>
\ No newline at end of file diff --git a/libs/emojicon/src/main/res/drawable/orca_emoji_more_front_button.xml b/libs/emojicon/src/main/res/drawable/orca_emoji_more_front_button.xml index a799d56d9..3e0e9f6f0 100644 --- a/libs/emojicon/src/main/res/drawable/orca_emoji_more_front_button.xml +++ b/libs/emojicon/src/main/res/drawable/orca_emoji_more_front_button.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_pressed="true" android:drawable="@drawable/orca_emoji_more_front_pressed"/> - <item android:drawable="@drawable/orca_emoji_more_front_normal"/> + <item android:state_pressed="true" android:drawable="@drawable/orca_emoji_more_front_pressed" /> + <item android:drawable="@drawable/orca_emoji_more_front_normal" /> </selector>
\ No newline at end of file diff --git a/libs/emojicon/src/main/res/drawable/orca_emoji_tab_background.xml b/libs/emojicon/src/main/res/drawable/orca_emoji_tab_background.xml index f68e6212b..d597dc03a 100644 --- a/libs/emojicon/src/main/res/drawable/orca_emoji_tab_background.xml +++ b/libs/emojicon/src/main/res/drawable/orca_emoji_tab_background.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<selector - xmlns:android="http://schemas.android.com/apk/res/android"> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:drawable="@drawable/orca_composer_tab_pressed" /> <item android:state_pressed="true" android:drawable="@drawable/orca_composer_tab_active" /> <item android:drawable="@drawable/orca_composer_tab" /> diff --git a/libs/emojicon/src/main/res/drawable/orca_emoji_tab_dark_background.xml b/libs/emojicon/src/main/res/drawable/orca_emoji_tab_dark_background.xml index 07ff608c9..f0b0d1a66 100644 --- a/libs/emojicon/src/main/res/drawable/orca_emoji_tab_dark_background.xml +++ b/libs/emojicon/src/main/res/drawable/orca_emoji_tab_dark_background.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ Copyright (C) 2013 Klamr. All rights reserved. ~ ~ This software is the confidential and proprietary information of Klamr or one of its @@ -14,8 +13,7 @@ ~ ITS DERIVATIVES. --> -<selector - xmlns:android="http://schemas.android.com/apk/res/android"> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/orca_composer_tab_pressed" /> <item android:drawable="@drawable/orca_composer_tab_active" android:state_checked="true" /> <item android:drawable="@drawable/orca_composer_tab_dark" /> diff --git a/libs/emojicon/src/main/res/layout/emojicon_grid.xml b/libs/emojicon/src/main/res/layout/emojicon_grid.xml index 457f8756b..7e1579c3f 100644 --- a/libs/emojicon/src/main/res/layout/emojicon_grid.xml +++ b/libs/emojicon/src/main/res/layout/emojicon_grid.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ Copyright (C) 2013 Klamr. All rights reserved. ~ ~ This software is the confidential and proprietary information of Klamr or one of its diff --git a/libs/emojicon/src/main/res/layout/emojicon_item.xml b/libs/emojicon/src/main/res/layout/emojicon_item.xml index ed11041a7..a85b1b640 100644 --- a/libs/emojicon/src/main/res/layout/emojicon_item.xml +++ b/libs/emojicon/src/main/res/layout/emojicon_item.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ Copyright 2014 Ankush Sachdeva ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,18 +14,18 @@ ~ limitations under the License. --> -<FrameLayout - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:emojicon="http://schemas.android.com/apk/res-auto" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:emojicon="http://schemas.android.com/apk/res-auto" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <github.ankushsachdeva.emojicon.EmojiconTextView - android:layout_gravity="center" - android:id="@+id/emojicon_icon" - android:layout_width="36dip" - android:layout_height="36dip" - emojicon:emojiconSize="30dip" - android:focusable="false" - android:focusableInTouchMode="false" - android:gravity="center"/> + android:layout_gravity="center" + android:id="@+id/emojicon_icon" + android:layout_width="36dip" + android:layout_height="36dip" + emojicon:emojiconSize="30dip" + android:focusable="false" + android:focusableInTouchMode="false" + android:gravity="center" /> </FrameLayout>
\ No newline at end of file diff --git a/libs/emojicon/src/main/res/layout/emojicons.xml b/libs/emojicon/src/main/res/layout/emojicons.xml index 287923d1b..e61c2fb34 100644 --- a/libs/emojicon/src/main/res/layout/emojicons.xml +++ b/libs/emojicon/src/main/res/layout/emojicons.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ Copyright 2014 Ankush Sachdeva ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,104 +15,120 @@ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:background="@drawable/keyboard_background_holo" - android:layout_width="match_parent" - android:layout_height="match_parent"> + android:background="@drawable/keyboard_background_holo" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <LinearLayout - android:id="@+id/emojis_tab" - android:layout_width="match_parent" - android:layout_height="50dip" - android:layout_alignParentTop="true" - android:orientation="horizontal"> + android:id="@+id/emojis_tab" + android:layout_width="match_parent" + android:layout_height="50dip" + android:layout_alignParentTop="true" + android:orientation="horizontal"> + <ImageButton - android:background="@null" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1" - android:scaleType="center" - android:id="@+id/emojis_tab_0_recents" - android:src="@drawable/ic_emoji_recent_light"/> + android:background="@null" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_weight="1" + android:scaleType="center" + android:id="@+id/emojis_tab_0_recents" + android:src="@drawable/ic_emoji_recent_light" /> + <View - android:layout_width="1px" - android:layout_height="match_parent" - android:background="#888888"/> + android:layout_width="1px" + android:layout_height="match_parent" + android:background="#888888" /> + <ImageButton - android:background="@null" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1" - android:scaleType="center" - android:id="@+id/emojis_tab_1_people" - android:src="@drawable/ic_emoji_people_light"/> + android:background="@null" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_weight="1" + android:scaleType="center" + android:id="@+id/emojis_tab_1_people" + android:src="@drawable/ic_emoji_people_light" /> + <View - android:layout_width="1px" - android:layout_height="match_parent" - android:background="#888888"/> + android:layout_width="1px" + android:layout_height="match_parent" + android:background="#888888" /> + <ImageButton - android:background="@null" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1" - android:scaleType="center" - android:id="@+id/emojis_tab_2_nature" - android:src="@drawable/ic_emoji_nature_light"/> + android:background="@null" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_weight="1" + android:scaleType="center" + android:id="@+id/emojis_tab_2_nature" + android:src="@drawable/ic_emoji_nature_light" /> + <View - android:layout_width="1px" - android:layout_height="match_parent" - android:background="#888888"/> + android:layout_width="1px" + android:layout_height="match_parent" + android:background="#888888" /> + <ImageButton - android:background="@null" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1" - android:scaleType="center" - android:id="@+id/emojis_tab_3_objects" - android:src="@drawable/ic_emoji_objects_light"/> + android:background="@null" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_weight="1" + android:scaleType="center" + android:id="@+id/emojis_tab_3_objects" + android:src="@drawable/ic_emoji_objects_light" /> + <View - android:layout_width="1px" - android:layout_height="match_parent" - android:background="#888888"/> + android:layout_width="1px" + android:layout_height="match_parent" + android:background="#888888" /> + <ImageButton - android:background="@null" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1" - android:scaleType="center" - android:id="@+id/emojis_tab_4_cars" - android:src="@drawable/ic_emoji_places_light"/> + android:background="@null" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_weight="1" + android:scaleType="center" + android:id="@+id/emojis_tab_4_cars" + android:src="@drawable/ic_emoji_places_light" /> + <View - android:layout_width="1px" - android:layout_height="match_parent" - android:background="#888888"/> + android:layout_width="1px" + android:layout_height="match_parent" + android:background="#888888" /> + <ImageButton - android:background="@null" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1" - android:scaleType="center" - android:id="@+id/emojis_tab_5_punctuation" - android:src="@drawable/ic_emoji_symbols_light"/> + android:background="@null" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_weight="1" + android:scaleType="center" + android:id="@+id/emojis_tab_5_punctuation" + android:src="@drawable/ic_emoji_symbols_light" /> + <View - android:layout_width="1px" - android:layout_height="match_parent" - android:background="#888888"/> + android:layout_width="1px" + android:layout_height="match_parent" + android:background="#888888" /> + <ImageButton - android:background="@null" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1" - android:id="@+id/emojis_backspace" - android:src="@drawable/sym_keyboard_delete_holo_dark"/> + android:background="@null" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_weight="1" + android:id="@+id/emojis_backspace" + android:src="@drawable/sym_keyboard_delete_holo_dark" /> </LinearLayout> + <android.support.v4.view.ViewPager android:layout_below="@id/emojis_tab" android:id="@+id/emojis_pager" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_alignParentBottom="true"/> + android:layout_alignParentBottom="true" /> + <View android:layout_width="match_parent" android:layout_height="1px" android:layout_below="@id/emojis_tab" - android:background="#8f8f8f"/> + android:background="#8f8f8f" /> </RelativeLayout> diff --git a/libs/emojicon/src/main/res/values/attrs.xml b/libs/emojicon/src/main/res/values/attrs.xml index 9810158dc..f4f21f903 100644 --- a/libs/emojicon/src/main/res/values/attrs.xml +++ b/libs/emojicon/src/main/res/values/attrs.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ Copyright 2014 Ankush Sachdeva ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); |