# ChatView for Android
### Repo no longer being maintained
<img src="https://raw.githubusercontent.com/shrikanth7698/ChatView/master/chatview_library_icon_1.png" width="100" >
<br/>
This is an Android library which can be used to add chat functionality to your android application with just a few lines of code.
<br/>
This library is still in beta but will be improved over time.
<br/>
<table>
<tr>
<td>
<img src="https://drive.google.com/uc?id=1NDELjyr1T0Y-JMfFmEFpQvZfT6rRXIX-" width="300" >
</td>
<td>
<img src="https://drive.google.com/uc?id=1w1rgZd5oHaDX_FKRfvCb1ddS_LMzJuHK" width="300">
</td>
</tr>
<tr>
<td>
<img src="https://drive.google.com/uc?id=1XzzM3QJjz2IqZ5mrsLKB15q_lelnx9oW" width="300">
</td>
<td>
<img src="https://raw.githubusercontent.com/shrikanth7698/ChatView/master/Explanation%20Screenshot%202.png" width="300">
</td>
</tr>
</table>
### Version
[![](https://jitpack.io/v/shrikanth7698/ChatView.svg)](https://jitpack.io/#shrikanth7698/ChatView)
### Installation
Add this to your root build.gradle at the end of repositories:
```gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
Then add dependency
```gradle
dependencies {
compile 'com.github.shrikanth7698:ChatView:v0.1.2'
}
```
### Usage
Drop the ChatView in your XML layout as is shown below:
```xml
<com.shrikanthravi.chatview.widget.ChatView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:showSenderLayout="false"
app:leftBubbleLayoutColor="#ff7b7b"
app:rightBubbleLayoutColor="@color/colorAccent2"
app:leftBubbleTextColor="@android:color/white"
app:rightBubbleTextColor="@android:color/black"
android:layout_above="@+id/sendLL"
app:showSenderName="true"
android:id="@+id/chatView">
</com.shrikanthravi.chatview.widget.ChatView>
```
don't forget to add this attribute to your root layout.
```xml
xmlns:app="http://schemas.android.com/apk/res-auto"
```
And then in your Activity or Fragment
```java
ChatView chatView = (ChatView) findViewById(R.id.chatview);
```
Sample code
```java
//sample code to add message to right
Message message = new Message();
message.setBody(messageET.getText().toString().trim()); //message body
message.setType(Message.RightSimpleMessage); //message type
message.setTime(getTime()); //message time (String)
message.setUserName("Groot"); //sender name
//sender icon
message.setUserIcon(Uri.parse("android.resource://com.shrikanthravi.chatviewlibrary/drawable/groot"));
chatView.addMessage(message);
//sample code to add message to left
Message message1 = new Message();
message1.setBody(messageET.getText().toString().trim());
message1.setType(Message.LeftSimpleMessage);
message1.setTime(getTime());
message1.setUserName("Hodor");
message1.setUserIcon(Uri.parse("android.resource://com.shrikanthravi.chatviewlibrary/drawable/hodor"));
chatView.addMessage(message);
//to clear messages
chatview.clearMessages();
//to remove message
chatview.remove(position) //or chatview.remove(message)
```
Message types
```java
//Message.LeftSimpleMessage
Message message = new Message();
message.setType(Message.LeftSimpleMessage);
message.setBody(body); //string
message.setTime(getTime());
chatView.addMessage(message);
//Message.RightSimpleMessage
Message message = new Message();
message.setType(Message.RightSimpleMessage);
message.setBody(body); //string
message.setTime(getTime());
chatView.addMessage(message);
//Message.LeftSingleImage (when clicked it will go to fullscreen mode)
Message message = new Message();
List<Uri> mSelected = new ArrayList<>();
mselected.add(Uri.parse("Your image"))
message.setTime(getTime());
message.setType(Message.LeftSingleImage);
message.setImageList(mSelected);
chatView.addMessage(message);
// Message.RightSingleImage (when clicked it will go to fullscreen mode)
Message message = new Message();
List<Uri> mSelected = new ArrayList<>();
mselected.add(Uri.parse("Your image"));
message.setTime(getTime());
message.setType(Message.RightSingleImage);
message.setImageList(mSelected);
chatView.addMessage(message);
// Message.LeftMultipleImages (can hold upto 10 images in a single row as a collage view)
Message message = new Message();
List<Uri> mSelected = new ArrayList<>();
mselected.add(Uri.parse("Your image"));
mselected.add(Uri.parse("Your image"));
mselected.add(Uri.parse("Your image"));
message.setTime(getTime());
message.setType(Message.LeftMultipleImages);
message.setImageList(mSelected);
chatView.addMessage(message);
// Message.RightMultipleImages (can hold upto 10 images in a single row as a collage view)
Message message = new Message();
List<Uri> mSelected = new ArrayList<>();
mselected.add(Uri.parse("Your image"));
mselected.add(Uri.parse("Your image"));
mselected.add(Uri.parse("Your image"));
message.setTime(getTime());
message.setType(Message.RightMultipleImages);
message.setImageList(mSelected);
chatView.addMessage(message);
// Message.LeftVideo (when clicked it will go to fullscreen mode)
Message message = new Message();
message.setType(Message.LeftVideo);
message.setTime(getTime());
message.setUserName("Hodor");
message.setVideoUri(Uri.parse(getPath(data.getData())));
message.setUserIcon(Uri.parse("android.resource://com.shrikanthravi.chatviewlibrary/drawable/hodor"));
hatView.addMessage(message);
// Message.RightVideo (when clicked it will go to fullscreen mode)
Message message = new Message();
message.setType(Message.RightVideo);
message.setTime(getTime());
message.setUserName("Groot");
message.setVideoUri(Uri.parse(getPath(data.getData())));
message.setUserIcon(Uri.parse("android.resource://com.shrikanthravi.chatviewlibrary/drawable/groot"));
chatView.addMessage(message);
```
### Sender Layout
<img src="https://raw.githubusercontent.com/shrikanth7698/ChatView/master/Sender_Layout.png" width="400" >
You should have a accent color in your colors.xml otherwise view will crash.
You can hide or show sender layout
```xml
app:showSenderLayout="true or false"
```
This is still in beta
Sender Layout has 4 buttons for now.
* Send Button
* Camera Button
* Gallery Button
* Video Button
and a Text box
You can change the color of buttons by changing the accent color you use in your app.
Note: You should use your own logic of picking images,videos and capturing images.
In this sample I used an external library to pick images from gallery.
```java
//Send button click listerer
chatView.setOnClickSendButtonListener(new ChatView.OnClickSendButtonListener() {
@Override
public void onSendButtonClick(String body) {
if(switchbool) {
Message message = new Message();
message.setBody(body);
message.setType(Message.RightSimpleMessage);
message.setTime(getTime());
message.setUserName("Groot");
message.setUserIcon(Uri.parse("android.resource://com.shrikanthravi.chatviewlibrary/drawable/groot"));
chatView.addMessage(message);
switchbool=false;
}
else{
Message message1 = new Message();
message1.setBody(body);
message1.setType(Message.LeftSimpleMessage);
message1.setTime(getTime());
message1.setUserName("Hodor");
message1.setUserIcon(Uri.parse("android.resource://com.shrikanthravi.chatviewlibrary/drawable/hodor"));
chatView.addMessage(mes
没有合适的资源?快使用搜索试试~ 我知道了~
这是一个Android库,只需几行代码即可用于向您的Android应用程序添加聊天功能。_Java_下载.zip
共245个文件
png:122个
xml:67个
java:20个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 108 浏览量
2023-04-24
13:46:36
上传
评论
收藏 61.48MB ZIP 举报
温馨提示
这是一个Android库,只需几行代码即可用于向您的Android应用程序添加聊天功能。_Java_下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
这是一个Android库,只需几行代码即可用于向您的Android应用程序添加聊天功能。_Java_下载.zip (245个子文件)
gradlew.bat 2KB
chatview library video.gif 50.71MB
.gitignore 118B
.gitignore 7B
.gitignore 7B
build.gradle 2KB
build.gradle 2KB
build.gradle 653B
settings.gradle 28B
gradlew 5KB
gradle-wrapper.jar 52KB
MessageAdapter.java 66KB
ChatViewTestActivity.java 15KB
ChatView.java 14KB
VideoFFActivity.java 9KB
VideoPlayer.java 8KB
DBHandler.java 4KB
Message.java 3KB
Message.java 2KB
ImageFFActivity.java 2KB
ImageFFActivity.java 2KB
EndlessRecyclerOnScrollListener.java 1KB
App.java 1KB
ProfileActivity.java 1KB
MessageFilter.java 1KB
FontChanger.java 773B
FontChanger.java 773B
ExampleInstrumentedTest.java 767B
ExampleInstrumentedTest.java 758B
ExampleUnitTest.java 411B
ExampleUnitTest.java 404B
top_bg.jpeg 529KB
hodor.jpeg 6KB
hodor.jpeg 6KB
top_bg1.jpg 5.35MB
groot.jpg 52KB
groot.jpg 52KB
leonardo.jpg 33KB
leonardo.jpg 33KB
margot.jpg 27KB
margot.jpg 27KB
LICENSE 1KB
README.md 19KB
Explanation Screenshot.png 3.37MB
Explanation Screenshot 2.png 577KB
Explanation Screenshot 1.png 574KB
Sender_Layout.png 49KB
man1.png 25KB
man1.png 25KB
man.png 23KB
man.png 23KB
girl.png 23KB
girl.png 23KB
boy1.png 23KB
boy1.png 23KB
girl1.png 22KB
girl1.png 22KB
man2.png 20KB
man2.png 20KB
chatview_library_icon.png 19KB
chatview_library_icon_1.png 18KB
man3.png 18KB
man3.png 18KB
boy.png 17KB
boy.png 17KB
man4.png 17KB
man4.png 17KB
ic_launcher_round.png 15KB
ic_launcher_round.png 10KB
ic_launcher.png 9KB
ic_launcher_round.png 7KB
ic_launcher.png 6KB
ic_launcher_round.png 5KB
ic_launcher.png 4KB
ic_launcher.png 3KB
ic_launcher_round.png 3KB
ic_launcher.png 2KB
media_icon.png 2KB
media_icon.png 2KB
report_icon.png 1KB
report_icon.png 1KB
search_icon.png 1KB
search_icon.png 1KB
clock_icon.png 1KB
clock_icon.png 1KB
media_icon.png 1KB
media_icon.png 1KB
camera_icon.png 1022B
camera_icon.png 1022B
mic_icon.png 1007B
mic_icon.png 1007B
location_icon.png 980B
location_icon.png 980B
profile_icon.png 918B
profile_icon.png 918B
gallery_icon.png 846B
gallery_icon.png 846B
report_icon.png 765B
report_icon.png 765B
search_icon.png 754B
共 245 条
- 1
- 2
- 3
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功