{"id":13537645,"url":"https://github.com/w446108264/XhsEmoticonsKeyboard","last_synced_at":"2025-04-02T04:31:18.865Z","repository":{"id":28243425,"uuid":"31748893","full_name":"w446108264/XhsEmoticonsKeyboard","owner":"w446108264","description":"android emoticonsKeyboard support emoji and user-defined emoticon. easy to integrated into your project ","archived":false,"fork":false,"pushed_at":"2019-05-17T10:29:14.000Z","size":28220,"stargazers_count":2848,"open_issues_count":37,"forks_count":598,"subscribers_count":81,"default_branch":"master","last_synced_at":"2025-03-24T13:03:31.529Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/w446108264.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-06T02:39:34.000Z","updated_at":"2025-03-23T06:57:33.000Z","dependencies_parsed_at":"2022-09-07T20:22:34.451Z","dependency_job_id":null,"html_url":"https://github.com/w446108264/XhsEmoticonsKeyboard","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w446108264%2FXhsEmoticonsKeyboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w446108264%2FXhsEmoticonsKeyboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w446108264%2FXhsEmoticonsKeyboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w446108264%2FXhsEmoticonsKeyboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/w446108264","download_url":"https://codeload.github.com/w446108264/XhsEmoticonsKeyboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246757249,"owners_count":20828863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T09:01:01.566Z","updated_at":"2025-04-02T04:31:18.859Z","avatar_url":"https://github.com/w446108264.png","language":"Java","funding_links":[],"categories":["Java","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"# XhsEmoticonsKeyboard\n\n\u003e j.s 🇨🇳\n\n最良心的开源表情键盘解决方案。\n\n# Features\n\n* API \u003e 9 \n* 表情键盘支持无闪烁自跟随系统软键盘高度,及支持自定义高度\n* 表情支持自定义格式,支持任意来源\n* 组件支持完全自定义,样式支持任意更改\n* 支持全屏\n* 默认微信键盘样式\n* 赠QQ键盘高仿,不谢\n\n![Art](https://github.com/w446108264/XhsEmoticonsKeyboard/raw/master/output/show.gif)\n \n# Screen Recrod\n\n\u003cimg src=\"output/chat-qqemoticon.png\" width=\"32%\" /\u003e \n\u003cimg src=\"output/chat-qqplug.png\" width=\"32%\" /\u003e \n\u003cimg src=\"output/chat-qqfav.png\" width=\"32%\" /\u003e \n\n\u003cimg src=\"output/chat_simple_fullscreen.png\" width=\"32%\" /\u003e \n\u003cimg src=\"output/chat-bigimage.png\" width=\"32%\" /\u003e \n\u003cimg src=\"output/chat-userdefui.png\" width=\"32%\" /\u003e \n\n\n\u003cimg src=\"output/chat-text.png\" width=\"32%\" /\u003e\n\u003cimg src=\"output/simple-comment.png\" width=\"32%\" /\u003e \n\u003cimg src=\"output/main.png\" width=\"32%\" /\u003e  \n \n# Emoji\na lib about emoji -\u003e 「[w446108264/AndroidEmoji](https://github.com/w446108264/AndroidEmoji)」\n\n\u003cimg src=\"https://github.com/w446108264/AndroidEmoji/raw/master/output/emoji_system.png\" width=\"19%\"/\u003e\n\u003cimg src=\"https://github.com/w446108264/AndroidEmoji/raw/master/output/emoji_apple.png\" width=\"19%\" /\u003e\n\u003cimg src=\"https://github.com/w446108264/AndroidEmoji/raw/master/output/emoji_google.png\" width=\"19%\"/\u003e\n\u003cimg src=\"https://github.com/w446108264/AndroidEmoji/raw/master/output/emoji_twitter.png\" width=\"19%\"/\u003e\n\u003cimg src=\"https://github.com/w446108264/AndroidEmoji/raw/master/output/emoji_emojione.png\" width=\"19%\"/\u003e\n  \n# Samples APK\n\nYou can [download a sample APK](https://github.com/w446108264/XhsEmoticonsKeyboard/raw/master/output/simple.apk) \n\n\u003cimg src=\"output/qc.png\" width=\"22%\" /\u003e \n\nor \n\n[Simple2 APK](https://github.com/w446108264/XhsEmoticonsKeyboard/raw/master/output/simple2.apk) \n\n\n# Gradle Dependency\n\nUsers of your library will need add the jitpack.io repository:\n\n```xml  \nallprojects {\n    repositories {\n        jcenter()\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\n\nand:\n\n```xml\ndependencies { \n    compile 'com.github.w446108264:XhsEmoticonsKeyboard:2.0.4'\n}\n```\n\n# Samples Usage\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003csj.keyboard.XhsEmoticonsKeyBoard xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:id=\"@+id/ek_bar\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\u003e\n\n    \u003cLinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\u003e\n\n        \u003candroid.support.design.widget.AppBarLayout\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:theme=\"@style/XhsEmoticonsKeyboardTheme.AppBarOverlay\"\u003e\n\n            \u003candroid.support.v7.widget.Toolbar\n                android:id=\"@+id/toolbar\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"?attr/actionBarSize\"\n                android:background=\"?attr/colorPrimary\"\n                app:popupTheme=\"@style/XhsEmoticonsKeyboardTheme.PopupOverlay\" /\u003e\n\n        \u003c/android.support.design.widget.AppBarLayout\u003e\n\n        \u003cListView\n            android:id=\"@+id/lv_chat\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:cacheColorHint=\"#00000000\"\n            android:divider=\"@null\"\n            android:fadingEdge=\"none\"\n            android:fitsSystemWindows=\"true\"\n            android:listSelector=\"#00000000\"\n            android:scrollbarStyle=\"outsideOverlay\"\n            android:scrollingCache=\"false\"\n            android:smoothScrollbar=\"true\"\n            android:stackFromBottom=\"true\" /\u003e\n    \u003c/LinearLayout\u003e\n\n\u003c/sj.keyboard.XhsEmoticonsKeyBoard\u003e\n\n```\ndemo -\u003e   [Demo](https://github.com/w446108264/XhsEmoticonsKeyboard/blob/master/Simple2/app/src/main/java/com/simple2/MainActivity.java)\n\n```java\n\n        // simple\n        // https://github.com/w446108264/XhsEmoticonsKeyboard/blob/master/Simple2/app/src/main/java/com/simple2/MainActivity.java\n        // https://github.com/w446108264/XhsEmoticonsKeyboard/blob/master/XhsEmoticonsKeyboard/app/src/main/java/com/xhsemoticonskeyboard/common/SimpleCommonUtils.java\n         \n        // dot't forget \n        // compile 'com.github.w446108264:AndroidEmoji:1.0.0'\n        \n        \n        final XhsEmoticonsKeyBoard ek_bar = (XhsEmoticonsKeyBoard) findViewById(R.id.ek_bar);\n\n        // source data\n        ArrayList\u003cEmojiBean\u003e emojiArray = new ArrayList\u003c\u003e();\n        Collections.addAll(emojiArray, DefEmoticons.sEmojiArray);\n\n        // emoticon click\n        final EmoticonClickListener emoticonClickListener = new EmoticonClickListener() {\n            @Override\n            public void onEmoticonClick(Object o, int actionType, boolean isDelBtn) {\n                if (isDelBtn) {\n                    int action = KeyEvent.ACTION_DOWN;\n                    int code = KeyEvent.KEYCODE_DEL;\n                    KeyEvent event = new KeyEvent(action, code);\n                    ek_bar.getEtChat().onKeyDown(KeyEvent.KEYCODE_DEL, event);\n                } else {\n                    if (o == null) {\n                        return;\n                    }\n                    String content = null;\n                    if (o instanceof EmojiBean) {\n                        content = ((EmojiBean) o).emoji;\n                    }\n                    int index = ek_bar.getEtChat().getSelectionStart();\n                    Editable editable = ek_bar.getEtChat().getText();\n                    editable.insert(index, content);\n                }\n            }\n        };\n\n        // emoticon instantiate\n        final EmoticonDisplayListener emoticonDisplayListener = new EmoticonDisplayListener() {\n            @Override\n            public void onBindView(int i, ViewGroup viewGroup, EmoticonsAdapter.ViewHolder viewHolder, Object object, final boolean isDelBtn) {\n                final EmojiBean emojiBean = (EmojiBean) object;\n                if (emojiBean == null \u0026\u0026 !isDelBtn) {\n                    return;\n                }\n\n                viewHolder.ly_root.setBackgroundResource(com.keyboard.view.R.drawable.bg_emoticon);\n\n                if (isDelBtn) {\n                    viewHolder.iv_emoticon.setImageResource(R.mipmap.icon_del);\n                } else {\n                    viewHolder.iv_emoticon.setImageResource(emojiBean.icon);\n                }\n\n                viewHolder.rootView.setOnClickListener(new View.OnClickListener() {\n                    @Override\n                    public void onClick(View v) {\n                        emoticonClickListener.onEmoticonClick(emojiBean, 0, isDelBtn);\n                    }\n                });\n            }\n        };\n\n        //  page instantiate\n        PageViewInstantiateListener pageViewInstantiateListener = new PageViewInstantiateListener\u003cEmoticonPageEntity\u003e() {\n            @Override\n            public View instantiateItem(ViewGroup viewGroup, int i, EmoticonPageEntity pageEntity) {\n                if (pageEntity.getRootView() == null) {\n                    EmoticonPageView pageView = new EmoticonPageView(viewGroup.getContext());\n                    pageView.setNumColumns(pageEntity.getRow());\n                    pageEntity.setRootView(pageView);\n                    try {\n                        EmoticonsAdapter adapter = new EmoticonsAdapter(viewGroup.getContext(), pageEntity, null);\n                        // emoticon instantiate\n                        adapter.setOnDisPlayListener(emoticonDisplayListener);\n                        pageView.getEmoticonsGridView().setAdapter(adapter);\n                    } catch (Exception e) {\n                        e.printStackTrace();\n                    }\n                }\n                return pageEntity.getRootView();\n            }\n        };\n\n        // build\n        EmoticonPageSetEntity xhsPageSetEntity\n                = new EmoticonPageSetEntity.Builder()\n                .setLine(3)\n                .setRow(7)\n                .setEmoticonList(emojiArray)\n                .setIPageViewInstantiateItem(pageViewInstantiateListener)\n                .setShowDelBtn(EmoticonPageEntity.DelBtnStatus.LAST)\n                .setIconUri(ImageBase.Scheme.DRAWABLE.toUri(\"ic_launcher\"))\n                .build();\n\n        PageSetAdapter pageSetAdapter = new PageSetAdapter();\n        pageSetAdapter.add(xhsPageSetEntity);\n        ek_bar.setAdapter(pageSetAdapter);\n\n        class EmojiFilter extends EmoticonFilter {\n\n            private int emojiSize = -1;\n\n            @Override\n            public void filter(EditText editText, CharSequence text, int start, int lengthBefore, int lengthAfter) {\n                emojiSize = emojiSize == -1 ? EmoticonsKeyboardUtils.getFontHeight(editText) : emojiSize;\n                clearSpan(editText.getText(), start, text.toString().length());\n                Matcher m = EmojiDisplay.getMatcher(text.toString().substring(start, text.toString().length()));\n                if (m != null) {\n                    while (m.find()) {\n                        String emojiHex = Integer.toHexString(Character.codePointAt(m.group(), 0));\n                        EmojiDisplay.emojiDisplay(editText.getContext(), editText.getText(), emojiHex, emojiSize, start + m.start(), start + m.end());\n                    }\n                }\n            }\n\n            private void clearSpan(Spannable spannable, int start, int end) {\n                if (start == end) {\n                    return;\n                }\n                EmojiSpan[] oldSpans = spannable.getSpans(start, end, EmojiSpan.class);\n                for (int i = 0; i \u003c oldSpans.length; i++) {\n                    spannable.removeSpan(oldSpans[i]);\n                }\n            }\n        }\n        // add a filter\n        ek_bar.getEtChat().addEmoticonFilter(new EmojiFilter());\n```\n\n# Else \n\n if you want to change the System status bar   \n \n ```java\n \n // like this\n getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);\n \n // this\n if (Build.VERSION.SDK_INT \u003e= Build.VERSION_CODES.KITKAT) {\n     getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);\n}\n        \n ```\nyou should add a Layout on the outside , demo -\u003e   [SimpleTranslucentChatActivity](https://github.com/w446108264/XhsEmoticonsKeyboard/blob/master/XhsEmoticonsKeyboard/app/src/main/java/com/xhsemoticonskeyboard/activity/SimpleTranslucentChatActivity.java)\n\n\n```xml\n\n\u003c!-- if you change the System status bar --\u003e\n\u003c!-- Add a Layout on the outside --\u003e\n\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cFrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:fitsSystemWindows=\"true\"\n    android:orientation=\"vertical\"\u003e\n    \n    \u003csj.keyboard.XhsEmoticonsKeyBoard\n        android:id=\"@+id/ek_bar\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\u003e\n        \n        \u003c!-- ... --\u003e\n        \n    \u003c/sj.keyboard.XhsEmoticonsKeyBoard\u003e\n\u003c/FrameLayout\u003e\n    \n```\n\n \n \n# Simple Default Keyboard Layout Tree 「 [SVG high definition](http://www.shengjun.red/treeview.svg) 」\n\n\u003cimg src=\"output/treeview.png\" width=\"100%\" /\u003e \n\n\n# Contact \u0026 Help\n\nPlease fell free to contact me if there is any problem when using the library.\n\n* email: shengjun8486@gmail.com \n\n\n# License\n\n```\nMIT License\n\nCopyright (c) 2017 w446108264\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw446108264%2FXhsEmoticonsKeyboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fw446108264%2FXhsEmoticonsKeyboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw446108264%2FXhsEmoticonsKeyboard/lists"}