Skip to content

Commit

Permalink
Fix scroll issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bassaer committed Dec 3, 2016
1 parent c6f35af commit af6e8c5
Show file tree
Hide file tree
Showing 55 changed files with 1,530 additions and 418 deletions.
148 changes: 141 additions & 7 deletions .gitignore
@@ -1,12 +1,146 @@

# Created by https://www.gitignore.io/api/android,intellij,java,gradle

### Android ###
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/libraries

# Keystore files
*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

### Android Patch ###
gen-external-apklibs


### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:

# Sensitive or high-churn files:
.idea/dataSources/
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Gradle:
.idea/gradle.xml

# Mongo Explorer plugin:
.idea/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr


### Java ###

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*


### Gradle ###
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
libs/
/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
app/
chatmessageview/.idea/
example/.idea/
example/gradle/
example/gradlew
example/gradlew.bat
example/local.properties
chatmessageview/libs/
example/libs/
example/src/main/res/drawable/
7 changes: 7 additions & 0 deletions .idea/dictionaries/nakayama.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 85 additions & 26 deletions README.md
Expand Up @@ -2,14 +2,14 @@

This library aims to provide an chat UI view for Android.

<img src="https://github.com/bassaer/ChatMessageView/blob/master/Screenshot.png" width="270dp">
<img src="https://github.com/bassaer/ChatMessageView/blob/master/screens.png" height="285dp">


##Feature

- You need to write just few code to create chat view.
- Auto date setting
- Easy to user for bot app
- Easy to use for bot app

##Gradle

Expand All @@ -19,16 +19,18 @@ repositories {
}
dependencies {
compile 'jp.bassaer.chatmessageview:chatmessageview:1.0.0'
compile 'jp.bassaer.chatmessageview:chatmessageview:1.2.0'
}
```

##Usage

Layoutfile
Layout file

```xml:activity_main.xml
Only MessageView

```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
Expand All @@ -42,33 +44,90 @@ Layoutfile
</LinearLayout>
```

Sample code

```java:MainActivity.java

public class MainActivity extends Activity {
ChatView has MessageView and text box.

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Bitmap icon1 = BitmapFactory.decodeResource(getResources(), jp.bassaer.chatmessageview.R.drawable.face_1);
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
Message message1 = new Message();
message1.setUserIcon(icon1);
message1.setUserName("Michael");
message1.setMessageText("hey! how are you?");
message1.setRightMessage(true);
<jp.bassaer.chatmessageview.views.ChatView
android:id="@+id/chat_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
ArrayList<Message> messages = new ArrayList<>();
</LinearLayout>
```

messages.add(message1);
Sample code

MessageView messageView = (MessageView) findViewById(R.id.message_view);
```
messageView.init(messages);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_messenger);
//User icon
final Bitmap myIcon = BitmapFactory.decodeResource(getResources(), R.drawable.face_2);
//User name
final String myName = "Michael";
final Bitmap yourIcon = BitmapFactory.decodeResource(getResources(), R.drawable.face_1);
final String yourName = "Emily";
mChatView = (ChatView)findViewById(R.id.chat_view);
//Set UI options
mChatView.setRightBubbleColor(ContextCompat.getColor(this, R.color.deepOrange500));
mChatView.setLeftBubbleColor(Color.WHITE);
mChatView.setBackgroundColor(ContextCompat.getColor(this, R.color.blueGray700));
mChatView.setSendButtonColor(ContextCompat.getColor(this, R.color.cyan500));
mChatView.setSendIcon(R.drawable.ic_action_send);
mChatView.setRightMessageTextColor(Color.WHITE);
mChatView.setLeftMessageTextColor(Color.BLACK);
mChatView.setUsernameTextColor(Color.WHITE);
mChatView.setSendTimeTextColor(Color.WHITE);
mChatView.setDateSeparatorColor(Color.WHITE);
mChatView.setInputTextHint("new message...");
//Click Send Button
mChatView.setOnClickSendButtonListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//new message
Message message = new Message.Builder()
.setUserIcon(myIcon)
.setUserName(myName)
.setRightMessage(true)
.setMessageText(mChatView.getInputText())
.build();
//Set to chat view
mChatView.send(message);
//Reset edit text
mChatView.setInputText("");
//Receive message
final Message receivedMessage = new Message.Builder()
.setUserIcon(yourIcon)
.setUserName(yourName)
.setRightMessage(false)
.setMessageText(ChatBot.talk(message.getUserName(), message.getMessageText()))
.build();
// This is a demo bot
// Return within 3 seconds
int sendDelay = (new Random().nextInt(4) +1) * 1000;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mChatView.receive(receivedMessage);
}
}, sendDelay);
}
});
}
```
Expand Down

0 comments on commit af6e8c5

Please sign in to comment.