Coder Social home page Coder Social logo

Comments (5)

sangmingming avatar sangmingming commented on July 23, 2024

需要加入权限控制,有相应权限的人才可以使用相应的表情。

from xhsemoticonskeyboard.

w446108264 avatar w446108264 commented on July 23, 2024

什么意思呢

from xhsemoticonskeyboard.

sangmingming avatar sangmingming commented on July 23, 2024

就是类似小红书里面那样,redclub用户才能使用一部分表情。

from xhsemoticonskeyboard.

w446108264 avatar w446108264 commented on July 23, 2024

重点参考SimpleCommonUtils

redclub用户才能使用一部分表情可以理解为具有某些标志的特殊表情集

那么只需要在构造键盘表情的时候做判断

if(redclub) {
// 有权限用户,直接添加小红书这部分的redclub表情集,参考SimpleCommonUtils/addXhsPageSetEntity()
EmoticonPageSetEntity xhsPageSetEntity
                = new EmoticonPageSetEntity.Builder()
                .setLine(3)
                .setRow(7)
                .setEmoticonList(ParseDataUtils.ParseXhsData(DefXhsEmoticons.xhsEmoticonArray, ImageBase.Scheme.ASSETS))
                .setIPageViewInstantiateItem(getDefaultEmoticonPageViewInstantiateItem(getCommonEmoticonDisplayListener(emoticonClickListener, Constants.EMOTICON_CLICK_TEXT)))
                .setShowDelBtn(EmoticonPageEntity.DelBtnStatus.LAST)
                .setIconUri(ImageBase.Scheme.ASSETS.toUri("xhsemoji_19.png"))
                .build();
        pageSetAdapter.add(xhsPageSetEntity);
} else  {

// 如果只是想在底部表情集合栏添加一个按钮,点击的时候弹出提示,参考SimpleChatActivity/initEmoticonsKeyBoardBar()
 ekBar.getEmoticonsToolBarView().addToolItemView(R.mipmap.icon_setting, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(SimpleChatActivity.this, "SETTING", Toast.LENGTH_SHORT).show();
            }
        });


// 如果只是想在底部表情集合栏添加一个按钮,同时还可以通过滑动的方式滑动到该页面,页面上提示解锁,那么可以插入一个自定义的view代替表情默认view,参考SimpleChatActivity/addTestPageSetEntity()
 PageSetEntity pageSetEntity = new PageSetEntity.Builder()
                .addPageEntity(new PageEntity(new SimpleAppsGridView(context)))
                .setIconUri(ImageBase.Scheme.DRAWABLE.toUri("icon_kaomoji"))
                .setShowIndicator(false)
                .build();
        pageSetAdapter.add(pageSetEntity);
}

// 如果想保持和其他正常的表情集一样的正常显示滑动,但是在表情页上有遮罩式的提示,那么就需要自定义EmoticonsAdapter,参考SimpleCommonUtils/addGoodGoodStudyPageSetEntity()
EmoticonPageSetEntity pageSetEntity
                = new EmoticonPageSetEntity.Builder()
                .setLine(emoticonPageSetEntity.getLine())
                .setRow(emoticonPageSetEntity.getRow())
                .setEmoticonList(emoticonPageSetEntity.getEmoticonList())
                .setIPageViewInstantiateItem(getEmoticonPageViewInstantiateItem(BigEmoticonsAndTitleAdapter.class, emoticonClickListener))
                .setIconUri(ImageBase.Scheme.FILE.toUri(filePath + "/" + emoticonPageSetEntity.getIconUri()))
                .build();
        pageSetAdapter.add(pageSetEntity);

// 如果想保持和其他正常的表情集其他全部都一样,但是在点击的时候提示权限不足,可以自定义EmoticonsAdapter,或者设置自定义actiontype,参考SimpleCommonUtils/getCommonEmoticonClickListener()
return new EmoticonClickListener() {
            @Override
            public void onEmoticonClick(Object o, int actionType, boolean isDelBtn) {
                if (isDelBtn) {
                    SimpleCommonUtils.delClick(editText);
                } else {
                    if (o == null) {
                        return;
                    }
                    if (actionType == Constants.EMOTICON_CLICK_TEXT) {
                        String content = null;
                        if (o instanceof EmojiBean) {
                            content = ((EmojiBean) o).emoji;
                        } else if (o instanceof EmoticonEntity) {
                            content = ((EmoticonEntity) o).getContent();
                        }

                        if (TextUtils.isEmpty(content)) {
                            return;
                        }
                        int index = editText.getSelectionStart();
                        Editable editable = editText.getText();
                        editable.insert(index, content);
                    }
                }
            }
        };

@sangmingming

from xhsemoticonskeyboard.

ValuesFeng avatar ValuesFeng commented on July 23, 2024

~ ~ ///

from xhsemoticonskeyboard.

Related Issues (20)

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.