Coder Social home page Coder Social logo

xhsemoticonskeyboard's Introduction

XhsEmoticonsKeyboard

j.s 🇨🇳

最良心的开源表情键盘解决方案。

Features

  • API > 9
  • 表情键盘支持无闪烁自跟随系统软键盘高度,及支持自定义高度
  • 表情支持自定义格式,支持任意来源
  • 组件支持完全自定义,样式支持任意更改
  • 支持全屏
  • 默认微信键盘样式
  • 赠QQ键盘高仿,不谢

Art

Screen Recrod

Emoji

a lib about emoji -> 「w446108264/AndroidEmoji

Samples APK

You can download a sample APK

or

Simple2 APK

Gradle Dependency

Users of your library will need add the jitpack.io repository:

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

and:

dependencies { 
    compile 'com.github.w446108264:XhsEmoticonsKeyboard:2.0.4'
}

Samples Usage

<?xml version="1.0" encoding="utf-8"?>
<sj.keyboard.XhsEmoticonsKeyBoard xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/ek_bar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/XhsEmoticonsKeyboardTheme.AppBarOverlay">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/XhsEmoticonsKeyboardTheme.PopupOverlay" />

        </android.support.design.widget.AppBarLayout>

        <ListView
            android:id="@+id/lv_chat"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:cacheColorHint="#00000000"
            android:divider="@null"
            android:fadingEdge="none"
            android:fitsSystemWindows="true"
            android:listSelector="#00000000"
            android:scrollbarStyle="outsideOverlay"
            android:scrollingCache="false"
            android:smoothScrollbar="true"
            android:stackFromBottom="true" />
    </LinearLayout>

</sj.keyboard.XhsEmoticonsKeyBoard>

demo -> Demo

        // simple
        // https://github.com/w446108264/XhsEmoticonsKeyboard/blob/master/Simple2/app/src/main/java/com/simple2/MainActivity.java
        // https://github.com/w446108264/XhsEmoticonsKeyboard/blob/master/XhsEmoticonsKeyboard/app/src/main/java/com/xhsemoticonskeyboard/common/SimpleCommonUtils.java
         
        // dot't forget 
        // compile 'com.github.w446108264:AndroidEmoji:1.0.0'
        
        
        final XhsEmoticonsKeyBoard ek_bar = (XhsEmoticonsKeyBoard) findViewById(R.id.ek_bar);

        // source data
        ArrayList<EmojiBean> emojiArray = new ArrayList<>();
        Collections.addAll(emojiArray, DefEmoticons.sEmojiArray);

        // emoticon click
        final EmoticonClickListener emoticonClickListener = new EmoticonClickListener() {
            @Override
            public void onEmoticonClick(Object o, int actionType, boolean isDelBtn) {
                if (isDelBtn) {
                    int action = KeyEvent.ACTION_DOWN;
                    int code = KeyEvent.KEYCODE_DEL;
                    KeyEvent event = new KeyEvent(action, code);
                    ek_bar.getEtChat().onKeyDown(KeyEvent.KEYCODE_DEL, event);
                } else {
                    if (o == null) {
                        return;
                    }
                    String content = null;
                    if (o instanceof EmojiBean) {
                        content = ((EmojiBean) o).emoji;
                    }
                    int index = ek_bar.getEtChat().getSelectionStart();
                    Editable editable = ek_bar.getEtChat().getText();
                    editable.insert(index, content);
                }
            }
        };

        // emoticon instantiate
        final EmoticonDisplayListener emoticonDisplayListener = new EmoticonDisplayListener() {
            @Override
            public void onBindView(int i, ViewGroup viewGroup, EmoticonsAdapter.ViewHolder viewHolder, Object object, final boolean isDelBtn) {
                final EmojiBean emojiBean = (EmojiBean) object;
                if (emojiBean == null && !isDelBtn) {
                    return;
                }

                viewHolder.ly_root.setBackgroundResource(com.keyboard.view.R.drawable.bg_emoticon);

                if (isDelBtn) {
                    viewHolder.iv_emoticon.setImageResource(R.mipmap.icon_del);
                } else {
                    viewHolder.iv_emoticon.setImageResource(emojiBean.icon);
                }

                viewHolder.rootView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        emoticonClickListener.onEmoticonClick(emojiBean, 0, isDelBtn);
                    }
                });
            }
        };

        //  page instantiate
        PageViewInstantiateListener pageViewInstantiateListener = new PageViewInstantiateListener<EmoticonPageEntity>() {
            @Override
            public View instantiateItem(ViewGroup viewGroup, int i, EmoticonPageEntity pageEntity) {
                if (pageEntity.getRootView() == null) {
                    EmoticonPageView pageView = new EmoticonPageView(viewGroup.getContext());
                    pageView.setNumColumns(pageEntity.getRow());
                    pageEntity.setRootView(pageView);
                    try {
                        EmoticonsAdapter adapter = new EmoticonsAdapter(viewGroup.getContext(), pageEntity, null);
                        // emoticon instantiate
                        adapter.setOnDisPlayListener(emoticonDisplayListener);
                        pageView.getEmoticonsGridView().setAdapter(adapter);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                return pageEntity.getRootView();
            }
        };

        // build
        EmoticonPageSetEntity xhsPageSetEntity
                = new EmoticonPageSetEntity.Builder()
                .setLine(3)
                .setRow(7)
                .setEmoticonList(emojiArray)
                .setIPageViewInstantiateItem(pageViewInstantiateListener)
                .setShowDelBtn(EmoticonPageEntity.DelBtnStatus.LAST)
                .setIconUri(ImageBase.Scheme.DRAWABLE.toUri("ic_launcher"))
                .build();

        PageSetAdapter pageSetAdapter = new PageSetAdapter();
        pageSetAdapter.add(xhsPageSetEntity);
        ek_bar.setAdapter(pageSetAdapter);

        class EmojiFilter extends EmoticonFilter {

            private int emojiSize = -1;

            @Override
            public void filter(EditText editText, CharSequence text, int start, int lengthBefore, int lengthAfter) {
                emojiSize = emojiSize == -1 ? EmoticonsKeyboardUtils.getFontHeight(editText) : emojiSize;
                clearSpan(editText.getText(), start, text.toString().length());
                Matcher m = EmojiDisplay.getMatcher(text.toString().substring(start, text.toString().length()));
                if (m != null) {
                    while (m.find()) {
                        String emojiHex = Integer.toHexString(Character.codePointAt(m.group(), 0));
                        EmojiDisplay.emojiDisplay(editText.getContext(), editText.getText(), emojiHex, emojiSize, start + m.start(), start + m.end());
                    }
                }
            }

            private void clearSpan(Spannable spannable, int start, int end) {
                if (start == end) {
                    return;
                }
                EmojiSpan[] oldSpans = spannable.getSpans(start, end, EmojiSpan.class);
                for (int i = 0; i < oldSpans.length; i++) {
                    spannable.removeSpan(oldSpans[i]);
                }
            }
        }
        // add a filter
        ek_bar.getEtChat().addEmoticonFilter(new EmojiFilter());

Else

if you want to change the System status bar

// like this
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

// this
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
       

you should add a Layout on the outside , demo -> SimpleTranslucentChatActivity

<!-- if you change the System status bar -->
<!-- Add a Layout on the outside -->

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">
    
    <sj.keyboard.XhsEmoticonsKeyBoard
        android:id="@+id/ek_bar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        
        <!-- ... -->
        
    </sj.keyboard.XhsEmoticonsKeyBoard>
</FrameLayout>
    

Simple Default Keyboard Layout Tree 「 SVG high definition

Contact & Help

Please fell free to contact me if there is any problem when using the library.

License

MIT License

Copyright (c) 2017 w446108264

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

xhsemoticonskeyboard's People

Contributors

w446108264 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xhsemoticonskeyboard's Issues

显示不全

EmoticonsToolBarView,EmoticonsIndicatorView这个两个view有时候会不显示出来,为什么呢

竖屏全屏bug

竖屏全屏的时候,AutoHeightLayout不能达到最大高度,原因是onMeasure那里mConfigurationChangedFlag为false!

发送出去的表情图片变了

选择表情区域的一个表情 进入edittext还是那个样子 点击发送到了textivew中就变成同一个意思的另一个表情图片 或者说是另一套表情 因为每个表情区域的图片都有对应的另一个同样意思的图片
好像是使用了手机自带的表情了是吗 我不是很懂 但是这是不妥的 请问怎么解决

缺少的类

activity_userdef这个xml文件里面的com.xhsemoticonskeyboard.common.widget.SimpleDefEmoticonsKeyBoard这个类哪边的
是不是这个compile(libraries.'emoticonkeyboard')里面的

en error when adding emoji and text

when adding emoji and text on the same time
I found this error

java.lang.IndexOutOfBoundsException: setSpan (9 ... 10) ends beyond length 9

and the problem is in setspan method

if (!isEmoticonMatcher) {
                ImageSpan[] oldSpans = getText().getSpans(start, end, ImageSpan.class);
                if(oldSpans != null){
                    for (int i = 0; i < oldSpans.length; i++) {
                        int startOld = end;
                        int endOld = after + getText().getSpanEnd(oldSpans[i]) - 1;
                        if (startOld >= 0 && endOld > startOld) {
                            ImageSpan imageSpan = new ImageSpan(oldSpans[i].getDrawable(), ImageSpan.ALIGN_BASELINE);
                            getText().removeSpan(oldSpans[i]);
                            getText().setSpan(imageSpan, startOld, endOld, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
                        }
                    }
                }
            }

在Nexus6上布局乱掉了

系统版本是6.0.1,用的是Nexus6。下载了APK安装后,选择“Simple Chat Keyboard”输入表情时布局乱掉了。
截图如下
2
1

键盘切换问题

表情键盘与软键盘切换的时候过渡不自然,而且当表情键盘弹出时,点击编辑框,弹出软键盘会遮住下面的表情键盘,当收起软键盘时下面的表情键盘还在

卡顿问题,出现频率较高

弹出键盘的时候输入框弹出卡顿,和隐藏键盘的时候,键盘能够快速隐藏但是键盘隐藏后输入框隐藏卡顿,以及输入框下面的屏幕是一片白底卡在那里,要等待一段时间才能隐藏。
在给出的 XhsEmoticonsKeyboard demo中出现过一次,在我的项目中出现频率较高。我把卡顿的视频发到你的email了,还请帮忙看一看这个bug.

混淆

混淆后表情不显示

ViewPager 的V4包冲突问题

在依赖了楼主的项目后会报出 如下错误:

ViewPager 的错误
Error:(80, 18) 错误: 找不到符号
符号: 方法 addOnPageChangeListener(JobFragment.MyOnPageChangeListener)
位置: 类型为ViewPager的变量 viewPager

Fragment的报错:
Error:(52, 5) 错误: 方法不会覆盖或实现超类型的方法
Error:(54, 24) 错误: 不兼容的类型: Context无法转换为Activity

ToolItemView 控件的移除

希望增加

mEmoticonsToolBarView.addToolItemView(pageSetEntity);
mEmoticonsToolBarView.addFixedToolItemView

相对应的移除方法

表情被裁剪如何处理呢

显示消息时候单行显示TextView列表中全是表情,最后一个表情被裁剪一半应该怎么处理才不会被裁剪呢

自定义布局中高度计算问题

在自定义AppsGirdView中页面下,点击切换到文本输入之后,再关闭键盘,AppsGirdView页面的高度被拉伸至与Emoticons页面高度一样

输入文字app就挂了

引入的库好像有问题,输入文字之后报空指针异常,app挂掉,麻烦帮忙解决下,谢谢!

发送按钮背景色不支持完全自定义

并不像说的那样“组件支持完全自定义,样式支持任意更改”。不知道是我没找到更改的方法还是怎么样,“发送”按钮的背景色没有办法改变。
调用ek_bar.getBtnSend().setBackgroundResource();修改不成功。

添加表情问题

如:QqUtils中:
`
if(sCommonPageSetAdapter != null){
return sCommonPageSetAdapter;
}
PageSetAdapter pageSetAdapter = new PageSetAdapter();

    addQqPageSetEntity(pageSetAdapter, context, emoticonClickListener);

    PageSetEntity pageSetEntity1 = new PageSetEntity.Builder()
            .addPageEntity(new PageEntity(new SimpleQqGridView(context)))
            .setIconUri(R.mipmap.dec)
            .setShowIndicator(false)
            .build();
    pageSetAdapter.add(pageSetEntity1);

    PageSetEntity pageSetEntity2 = new PageSetEntity.Builder()
            .addPageEntity(new PageEntity(new SimpleQqGridView(context)))
            .setIconUri(R.mipmap.mwi)
            .setShowIndicator(false)
            .build();
    pageSetAdapter.add(pageSetEntity2);

    return pageSetAdapter;`

一直在添加,而没有移除的操作,会不会一直内存占用?

功能性提议

作者你好,希望加入gif以及长按表情可以预览的功能

Activity中使用android:windowSoftInputMode="adjustPan"点击编辑框软键盘会顶起表情面板

说明:Activity中使用不使用任何android:windowSoftInputMode属性,点击编辑框弹出软键盘正常的。

Activity中使用android:windowSoftInputMode="adjustPan"属性:
问题1:点击编辑框软键盘会顶起表情面板,发现出现的步骤是:表情面板收起的时候,点击编辑框,软件盘键表情面板顶起来;
问题2:表情面板显示的时候,点击边框,软键盘正常显示,点击物理返回键,整个界面闪动。

使用android:windowSoftInputMode="adjustPan"属性原因:做视频类的界面,底层是播放器,不使用该属性则会压缩变形。

comment keyboard问题

点击表情图标,怎么切换表情键盘和系统键盘?还有bottom_layout的高度

按下返回键时隐藏表情面板是如何设置的?

看示例APK中都支持按下返回键,隐藏表情面板。只有在表情面板和键盘都隐藏的情况下,按下返回键才推出当前页面。试了下重写dispatchKeyEvent的方式和不做任何处理的方式,表现和示例都不一样,而是既隐藏表情面板又返回上一页。请问改如何设置呢?

qq表情问题

image
请问下这些表情是从哪里获取的?reclib-qq中并未找到这些想过图片。

表情过多输入都会很卡

步骤1.下载
2.选择微信样式输入表情很多
3.任意选择一个表情插入信息会很卡顿不管是插入文字还是表情

addEmoticonFilter 多个过滤器重复,导致只有后面的有效

    etContent.addEmoticonFilter(new EmojiFilter());
    etContent.addEmoticonFilter(new QqFilter());

两个都为自定义的,并且继承EmoticonFilter,但如果只单独使用一个,对于的表情没问题,但如果通过使用两个,则前面的过滤无效,显示 字符

ResourceType: No package identifier when getting value for resource number 0x00000000

用了SimpleCommonUtils.java这个,这段代码老是报标题中的错误。。
public void spannableEmoticonFilter(TextView tv_content, String content) {
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(content);
Spannable spannable = EmojiDisplay.spannableFilter(tv_content.getContext(),
spannableStringBuilder,
content,
EmoticonsKeyboardUtils.getFontHeight(tv_content));
tv_content.setText(spannable);
}

用的是
compile 'com.github.w446108264:XhsEmoticonsKeyboard:2.0.4'
compile 'com.github.w446108264:AndroidEmoji:1.0.0'

键盘失效

activity设置android:configChanges="orientation|keyboardHidden|screenSize"后,旋转了方向后,出现各种bug。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.