Skip to content

Commit

Permalink
Merge pull request #28 from timigod/dev
Browse files Browse the repository at this point in the history
Sync Dev and Master branches
  • Loading branch information
timigod authored Jul 6, 2018
2 parents 5f871fd + f1e7e0e commit 65b03f2
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 25 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ chatview:inputUseEditorAction="" // true or false
chatview:inputTextAppearance=""
chatview:inputTextSize=""
chatview:inputTextColor=""
chatview:inputHint=""
chatview:inputHintColor=""
chatview:sendBtnIcon=""
chatview:sendBtnIcon=""
chatview:sendBtnIconTint=""
chatview:sendBtnBackgroundTint=""
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ dependencies {
testCompile 'junit:junit:4.12'

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'co.intentservice.android-chat-ui:chat-ui:0.1.1'
compile project(':chat-ui')
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ protected void onCreate(Bundle savedInstanceState) {

ChatView chatView = (ChatView) findViewById(R.id.chat_view);
chatView.addMessage(new ChatMessage("Message received", System.currentTimeMillis(), ChatMessage.Type.RECEIVED));
chatView.addMessage(new ChatMessage("A message with a sender name",
System.currentTimeMillis(), ChatMessage.Type.RECEIVED, "Ryan Java"));
chatView.setOnSentMessageListener(new ChatView.OnSentMessageListener() {
@Override
public boolean sendMessage(ChatMessage chatMessage) {
Expand Down
31 changes: 16 additions & 15 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:chatview="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:chatview="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"

style="@style/Widget.AppCompat.ButtonBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context="co.intentservice.chatui.sample.MainActivity">
style="@style/Widget.AppCompat.ButtonBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context="co.intentservice.chatui.sample.MainActivity">

<co.intentservice.chatui.ChatView
android:id="@+id/chat_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
chatview:backgroundColor="@color/off_white"
chatview:bubbleElevation="elevated"
chatview:bubbleBackgroundRcv="@color/blue"
chatview:bubbleBackgroundSend="@color/white" />
android:id="@+id/chat_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
chatview:backgroundColor="@color/off_white"
chatview:bubbleElevation="elevated"
chatview:bubbleBackgroundRcv="@color/blue"
chatview:bubbleBackgroundSend="@color/white"
chatview:inputHint="@string/start_typing"/>

</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<resources>

<string name="app_name">Android ChatView Sample</string>
<string name="start_typing">Start typing</string>

</resources>
21 changes: 14 additions & 7 deletions chat-ui/src/main/java/co/intentservice/chatui/ChatView.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ChatView extends RelativeLayout {
private ViewBuilderInterface viewBuilder;
private FloatingActionsMenu actionsMenu;
private boolean previousFocusState = false, useEditorAction, isTyping;

private TypingListener typingListener;
private Runnable typingTimerRunnable = new Runnable() {
@Override
public void run() {
Expand All @@ -56,10 +56,10 @@ public void run() {
}
}
};
private TypingListener typingListener;
private OnSentMessageListener onSentMessageListener;
private ChatViewListAdapter chatViewListAdapter;

private String inputHint;
private int inputFrameBackgroundColor, backgroundColor;
private int inputTextSize, inputTextColor, inputHintColor;
private int sendButtonBackgroundTint, sendButtonIconTint;
Expand All @@ -72,8 +72,6 @@ public void run() {
private TypedArray attributes, textAppearanceAttributes;
private Context context;



ChatView(Context context) {
this(context, null);
}
Expand All @@ -94,7 +92,6 @@ public ChatView(Context context, AttributeSet attrs, int defStyleAttr, ViewBuild

}


private void init(Context context, AttributeSet attrs, int defStyleAttr) {
LayoutInflater.from(getContext()).inflate(R.layout.chat_view, this, true);
this.context = context;
Expand Down Expand Up @@ -131,7 +128,6 @@ private void setListAdapter() {
chatListView.setAdapter(chatViewListAdapter);
}


private void setViewAttributes() {
setChatViewBackground();
setInputFrameAttributes();
Expand All @@ -150,7 +146,6 @@ private void getAttributesForChatMessageRow() {
}

private void getAttributesForBubbles() {

float dip4 = context.getResources().getDisplayMetrics().density * 4.0f;
int elevation = attributes.getInt(R.styleable.ChatView_bubbleElevation, ELEVATED);
bubbleElevation = elevation == ELEVATED ? dip4 : 0;
Expand Down Expand Up @@ -184,12 +179,16 @@ private void getAttributesForInputText() {
overrideTextStylesIfSetIndividually();
}


private void setTextAppearanceAttributes() {
final int textAppearanceId = attributes.getResourceId(R.styleable.ChatView_inputTextAppearance, 0);
textAppearanceAttributes = getContext().obtainStyledAttributes(textAppearanceId, R.styleable.ChatViewInputTextAppearance);
}

private void setInputTextAttributes() {
if (inputHint != null) {
inputEditText.setHint(inputHint);
}
inputEditText.setTextColor(inputTextColor);
inputEditText.setHintTextColor(inputHintColor);
inputEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, inputTextSize);
Expand Down Expand Up @@ -229,6 +228,7 @@ private void setInputTextDefaults() {
inputTextSize = context.getResources().getDimensionPixelSize(R.dimen.default_input_text_size);
inputTextColor = ContextCompat.getColor(context, R.color.black);
inputHintColor = ContextCompat.getColor(context, R.color.main_color_gray);
setInputHint();
}

private void setInputTextSize() {
Expand All @@ -243,6 +243,12 @@ private void setInputTextColor() {
}
}

public void setInputHint() {
if (attributes.hasValue(R.styleable.ChatView_inputHint)) {
inputHint = attributes.getString(R.styleable.ChatView_inputHint);
}
}

private void setInputHintColor() {
if (textAppearanceAttributes.hasValue(R.styleable.ChatView_inputHintColor)) {
inputHintColor = attributes.getColor(R.styleable.ChatView_inputHintColor, inputHintColor);
Expand Down Expand Up @@ -392,6 +398,7 @@ public EditText getInputEditText() {
return inputEditText;
}


public FloatingActionsMenu getActionsMenu() {
return actionsMenu;
}
Expand Down
3 changes: 2 additions & 1 deletion chat-ui/src/main/res/layout/chat_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
android:id="@+id/chat_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/input_frame"
android:clipToPadding="false"
android:divider="@android:color/transparent"
android:paddingBottom="96dp"
android:paddingBottom="32dp"
android:paddingTop="8dp"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" />
Expand Down
1 change: 1 addition & 0 deletions chat-ui/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<attr name="inputTextAppearance" format="reference" />
<attr name="inputTextSize" format="dimension" />
<attr name="inputTextColor" format="color" />
<attr name="inputHint" format="string" />
<attr name="inputHintColor" format="color" />

<attr name="sendBtnIcon" format="reference" />
Expand Down

0 comments on commit 65b03f2

Please sign in to comment.