Coder Social home page Coder Social logo

cppalien / chatkeyboard Goto Github PK

View Code? Open in Web Editor NEW
577.0 18.0 81.0 2.6 MB

ChatKeyboard is a powerful and easy using keyboard lib for Android, includes emoticons selection, audio recording, multi media functions, etc.

License: Apache License 2.0

Java 100.00%

chatkeyboard's Introduction

ChatKeyboard

ChatKeyboard is a powerful and easy using keyboard lib for Android, includes emoticons selection, audio recording, multi media functions, etc.

  • Let the lib handle the difficult keyboard actions, you just need listen the the results you want.
  • Apply different styles of the keyboard.
  • Custom your own icons in keyboard and the click action.
  • More to find out by yourself.

Demo

Apk Download

Import

Gradle:

dependencies { compile 'me.pengtao:ChatKeyboard:2.0.0' }

If the jcenter is not ok, you can use jitpack way as below.

repositories{
    maven { url "https://jitpack.io" }
}
dependencies {
    compile 'com.github.CPPAlien:ChatKeyboard:1.0.1'
}

Latest Version:

How to use

1, ChatKeyboardLayout

make your layout get keyboard ability.

<cn.hadcn.keyboard.ChatKeyboardLayout
        android:id="@+id/kv_bar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/toolbar"
        app:showRightIcon="true"
        app:keyboardStyle="chat_style"
        app:sendButtonBackground="@drawable/send_button_bg"
        app:sendButtonTextColor="#FFFFFF">
        ...your layout
</cn.hadcn.keyboard.ChatKeyboardLayout>

Notice: You can only put one child view in ChatKeyboardLayout.

2, Style and Custom

There are three styles you can set.

chat_style text_emoticon text_only

You can use app:keyboardStyle in xml to set or setKeyboardStyle(@KeyboardStyle int style) method to set, once you set, the keyboard style will change.

There are also some attributes you can custom the icons.

app:sendButtonBackground custom send button background

app:faceIcon custom keyboard bar face icon, you can use state_selected to distinguish emoticon layout pop or not state.

app:showRightIcon when you set the style as chat_style, the right place will just show send button in default, you should set this attribute as true to show the right multi media icon.

… more you need find out yourself in demo.

3, Emoticons and Stickers

if (!ChatKeyboardLayout.isEmoticonInitSuccess(this)) {
	List<EmoticonEntity> entities = new ArrayList<>();
	entities.add(new EmoticonEntity("emoticons/xhs", EmoticonBase.Scheme.ASSETS));
	entities.add(new EmoticonEntity("emoticons/tusiji", EmoticonBase.Scheme.ASSETS));
	ChatKeyboardLayout.initEmoticonsDB(this, true, entities);
}

Notice: Add the code above before the ChatKeyboardLayout used, better in onCreate of Application

4, Keyboard Listener

public interface OnChatKeyBoardListener {
        /**
         * When send button clicked
         *
         * @param text content in input area
         */
        void onSendButtonClicked(String text);

        /**
         * When user input or delete text in input area
         *
         * @param text changing text
         */
        void onInputTextChanged(String text);

        /**
         * Recording button action {@link RecordingAction}
         *
         * @param action action
         */
        void onRecordingAction(RecordingAction action);

        /**
         * When sticker defined by developer clicked
         *
         * @param tag sticker tag
         * @param uri sticker location uri
         */
        void onUserDefEmoticonClicked(String tag, String uri);

        /**
         * when keyboard popped or back, get the pixels of the height include keyboard bar
         *
         * @param height pixel height
         */
        void onKeyboardHeightChanged(int height);
        
        /**
         * when left icon clicked, this will be called
         *
         * @param view view of clicked
         * @return true, won't execute default actions; false, execute default actions
         */
        boolean onLeftIconClicked(View view); 
        
        /**
         * when right icon clicked, this will be called
         *
         * @param view view of clicked
         * @return true, won't execute default actions; false, execute default actions
         */
        boolean onRightIconClicked(View view);
} 

You can use SimpleOnChatKeyboardListener instead of the interface above, so you can just implement these call back method you use.

These you should know

  1. Make sure the bottom of ChatKeyboardLayout align the screen bottom.
  2. Make sure the height of ChatKeyboardLayout be at least 2/3 of you screen height.

Other usage

Please refer to the demo code

Thanks

Thanks for xhsEmoticonsKeyboard powered by w446108264 which is inspired me.

License

Copyright (c) 2017 CPPAlien

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

chatkeyboard's People

Contributors

cppalien avatar ethanleex avatar nishibaiyang 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

chatkeyboard's Issues

替换edittext

请问能不能提供一个替换掉edittext的方式呢?
写了一个有@人功能的edittext,现在除了改源码外好像没其他办法了

SQLiteDatabaseLockedException

android.database.sqlite.SQLiteDatabaseLockedException
database is locked (code 5): , while compiling: PRAGMA journal_mode

1 android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)

2 android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:906)
3 android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:651)
4 android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:333)
5 android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:307)
6 android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:228)
7 android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:206)
8 android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
9 android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
10 android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
11 android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:836)
12 android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:821)
13 android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:714)
14 android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1286)
15 android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:268)
16 android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
17 android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
18 cn.hadcn.keyboard.emoticon.db.EmoticonDBHelper.insertEmoticonSet(EmoticonDBHelper.java:89)
19 cn.hadcn.keyboard.ChatKeyboardLayout$5.run(ChatKeyboardLayout.java:704)
20 java.lang.Thread.run(Thread.java:818)

Stay on the keyboard

hello tnx for this library
i have problem
me after initialise keyboard in my activity , The keyboard is in the open mode
What do you need to solve this problem?

thank you

toolbar导致的问题

在界面上添加toolbar之后,autoview就会比键盘高出一截
而根布局用linearlayout的话就没问题了
但是RecordingLayout要显示在界面**的话又只能用relativelayout…

关于表情的初始化的问题

ChatKeyboardLayout.initEmoticonsDB(this, true, entities)

这里如果第一次运行时,第二个参数为 true ,有默认表情,这个是正常的,但是当我改成 false,再运行还是存在默认表情。

看了你的源码你是否初始化成功的处理,不知道你是怎么考虑的,但是实际开发还是存在有的地方需要有的地方不需要。

SQLiteDatabase: Error

SQLiteDatabase: Error inserting row=4 item_padding=30 horizontal_spacing=0 is_show_del_btn=0 name=sme line=2 icon_uri=assets://emoticons/sme/wg_tab.png vertical_spacing=0 is_show_name=true
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: emoticonset.name (code 2067)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:782)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1471)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
at cn.hadcn.keyboard.emoticon.db.EmoticonDBHelper.insertEmoticonSet(EmoticonDBHelper.java:105)
at cn.hadcn.keyboard.ChatKeyboardLayout$5.run(ChatKeyboardLayout.java:704)
at java.lang.Thread.run(Thread.java:818)

切換 emoji 和鍵盤模式

在打開emoji 畫面和打開鍵盤,高度不同,會跳來跳去,該怎麼處理? (鍵盤模式高度較低)

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.